From 4214f262bdae9b22c8cebd9d84cd55b2f52aa20b Mon Sep 17 00:00:00 2001 From: "tor%cs.brown.edu" Date: Thu, 11 May 2006 21:24:59 +0000 Subject: [PATCH] Bug 337483 - one copy of child list region gathering logic. r+sr=roc git-svn-id: svn://10.0.0.236/trunk@196347 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/svg/base/src/nsSVGGFrame.cpp | 24 +---------------- .../base/src/nsSVGGenericContainerFrame.cpp | 24 +---------------- .../svg/base/src/nsSVGInnerSVGFrame.cpp | 24 +---------------- .../layout/svg/base/src/nsSVGTSpanFrame.cpp | 24 +---------------- .../layout/svg/base/src/nsSVGTextFrame.cpp | 24 +---------------- mozilla/layout/svg/base/src/nsSVGUtils.cpp | 26 +++++++++++++++++++ mozilla/layout/svg/base/src/nsSVGUtils.h | 6 +++++ 7 files changed, 37 insertions(+), 115 deletions(-) diff --git a/mozilla/layout/svg/base/src/nsSVGGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGFrame.cpp index 5d4b4f915dd..48f5547fcb7 100644 --- a/mozilla/layout/svg/base/src/nsSVGGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGFrame.cpp @@ -107,29 +107,7 @@ nsSVGGFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit) NS_IMETHODIMP_(already_AddRefed) nsSVGGFrame::GetCoveredRegion() { - nsISVGRendererRegion *accu_region=nsnull; - - nsIFrame* kid = mFrames.FirstChild(); - while (kid) { - nsISVGChildFrame* SVGFrame=0; - kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); - if (SVGFrame) { - nsCOMPtr dirty_region = SVGFrame->GetCoveredRegion(); - if (dirty_region) { - if (accu_region) { - nsCOMPtr temp = dont_AddRef(accu_region); - dirty_region->Combine(temp, &accu_region); - } - else { - accu_region = dirty_region; - NS_IF_ADDREF(accu_region); - } - } - } - kid = kid->GetNextSibling(); - } - - return accu_region; + return nsSVGUtils::GetCoveredRegion(mFrames); } NS_IMETHODIMP diff --git a/mozilla/layout/svg/base/src/nsSVGGenericContainerFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGenericContainerFrame.cpp index 05da63e54bd..43d8d7c49be 100644 --- a/mozilla/layout/svg/base/src/nsSVGGenericContainerFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGenericContainerFrame.cpp @@ -205,29 +205,7 @@ nsSVGGenericContainerFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit NS_IMETHODIMP_(already_AddRefed) nsSVGGenericContainerFrame::GetCoveredRegion() { - nsISVGRendererRegion *accu_region=nsnull; - - nsIFrame* kid = mFrames.FirstChild(); - while (kid) { - nsISVGChildFrame* SVGFrame=0; - kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); - if (SVGFrame) { - nsCOMPtr dirty_region = SVGFrame->GetCoveredRegion(); - if (dirty_region) { - if (accu_region) { - nsCOMPtr temp = dont_AddRef(accu_region); - dirty_region->Combine(temp, &accu_region); - } - else { - accu_region = dirty_region; - NS_IF_ADDREF(accu_region); - } - } - } - kid = kid->GetNextSibling(); - } - - return accu_region; + return nsSVGUtils::GetCoveredRegion(mFrames); } NS_IMETHODIMP diff --git a/mozilla/layout/svg/base/src/nsSVGInnerSVGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGInnerSVGFrame.cpp index 5cd54954e49..f99395e2bbb 100644 --- a/mozilla/layout/svg/base/src/nsSVGInnerSVGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGInnerSVGFrame.cpp @@ -329,29 +329,7 @@ nsSVGInnerSVGFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit) NS_IMETHODIMP_(already_AddRefed) nsSVGInnerSVGFrame::GetCoveredRegion() { - nsISVGRendererRegion *accu_region=nsnull; - - nsIFrame* kid = mFrames.FirstChild(); - while (kid) { - nsISVGChildFrame* SVGFrame=0; - kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); - if (SVGFrame) { - nsCOMPtr dirty_region = SVGFrame->GetCoveredRegion(); - if (dirty_region) { - if (accu_region) { - nsCOMPtr temp = dont_AddRef(accu_region); - dirty_region->Combine(temp, &accu_region); - } - else { - accu_region = dirty_region; - NS_IF_ADDREF(accu_region); - } - } - } - kid = kid->GetNextSibling(); - } - - return accu_region; + return nsSVGUtils::GetCoveredRegion(mFrames); } NS_IMETHODIMP diff --git a/mozilla/layout/svg/base/src/nsSVGTSpanFrame.cpp b/mozilla/layout/svg/base/src/nsSVGTSpanFrame.cpp index 05fe537a4a2..bb7f41fb386 100644 --- a/mozilla/layout/svg/base/src/nsSVGTSpanFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGTSpanFrame.cpp @@ -308,29 +308,7 @@ nsSVGTSpanFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit) NS_IMETHODIMP_(already_AddRefed) nsSVGTSpanFrame::GetCoveredRegion() { - nsISVGRendererRegion *accu_region=nsnull; - - nsIFrame* kid = mFrames.FirstChild(); - while (kid) { - nsISVGChildFrame* SVGFrame=0; - kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); - if (SVGFrame) { - nsCOMPtr dirty_region = SVGFrame->GetCoveredRegion(); - if (accu_region) { - if (dirty_region) { - nsCOMPtr temp = dont_AddRef(accu_region); - dirty_region->Combine(temp, &accu_region); - } - } - else { - accu_region = dirty_region; - NS_IF_ADDREF(accu_region); - } - } - kid = kid->GetNextSibling(); - } - - return accu_region; + return nsSVGUtils::GetCoveredRegion(mFrames); } NS_IMETHODIMP diff --git a/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp b/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp index 543ada0bf2f..5472a3506b0 100644 --- a/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGTextFrame.cpp @@ -531,29 +531,7 @@ nsSVGTextFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit) NS_IMETHODIMP_(already_AddRefed) nsSVGTextFrame::GetCoveredRegion() { - nsISVGRendererRegion *accu_region=nsnull; - - nsIFrame* kid = mFrames.FirstChild(); - while (kid) { - nsISVGChildFrame* SVGFrame=0; - kid->QueryInterface(NS_GET_IID(nsISVGChildFrame),(void**)&SVGFrame); - if (SVGFrame) { - nsCOMPtr dirty_region = SVGFrame->GetCoveredRegion(); - if (dirty_region) { - if (accu_region) { - nsCOMPtr temp = dont_AddRef(accu_region); - dirty_region->Combine(temp, &accu_region); - } - else { - accu_region = dirty_region; - NS_IF_ADDREF(accu_region); - } - } - } - kid = kid->GetNextSibling(); - } - - return accu_region; + return nsSVGUtils::GetCoveredRegion(mFrames); } NS_IMETHODIMP diff --git a/mozilla/layout/svg/base/src/nsSVGUtils.cpp b/mozilla/layout/svg/base/src/nsSVGUtils.cpp index 11fe1a79b76..e48a8d41018 100644 --- a/mozilla/layout/svg/base/src/nsSVGUtils.cpp +++ b/mozilla/layout/svg/base/src/nsSVGUtils.cpp @@ -1120,3 +1120,29 @@ nsSVGUtils::GetCoordContextProvider(nsSVGElement *aElement) NS_IF_ADDREF(ctx); return ctx; } + +already_AddRefed +nsSVGUtils::GetCoveredRegion(const nsFrameList &aFrames) +{ + nsCOMPtr accu_region; + + for (nsIFrame* kid = aFrames.FirstChild(); + kid; + kid = kid->GetNextSibling()) { + nsISVGChildFrame* child = nsnull; + CallQueryInterface(kid, &child); + if (child) { + nsCOMPtr dirty_region = child->GetCoveredRegion(); + if (dirty_region) { + if (accu_region) + dirty_region->Combine(accu_region, getter_AddRefs(accu_region)); + else + accu_region = dirty_region; + } + } + } + + nsISVGRendererRegion* result = nsnull; + accu_region.swap(result); + return result; +} diff --git a/mozilla/layout/svg/base/src/nsSVGUtils.h b/mozilla/layout/svg/base/src/nsSVGUtils.h index 334b01a4def..568df69d3d5 100644 --- a/mozilla/layout/svg/base/src/nsSVGUtils.h +++ b/mozilla/layout/svg/base/src/nsSVGUtils.h @@ -277,6 +277,12 @@ public: static already_AddRefed GetCoordContextProvider(nsSVGElement *aElement); + /* + * Get frame's covered region by walking the children and doing union. + */ + static already_AddRefed + GetCoveredRegion(const nsFrameList &aFrames); + private: /* * Returns the glyph fragment containing a particular character