Bug 337483 - one copy of child list region gathering logic. r+sr=roc

This commit is contained in:
tor%cs.brown.edu 2006-05-11 21:24:59 +00:00
parent 9712fdba80
commit 9a3aab1d6e
7 changed files with 37 additions and 115 deletions

View File

@ -107,29 +107,7 @@ nsSVGGFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
NS_IMETHODIMP_(already_AddRefed<nsISVGRendererRegion>)
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<nsISVGRendererRegion> dirty_region = SVGFrame->GetCoveredRegion();
if (dirty_region) {
if (accu_region) {
nsCOMPtr<nsISVGRendererRegion> 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

View File

@ -205,29 +205,7 @@ nsSVGGenericContainerFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit
NS_IMETHODIMP_(already_AddRefed<nsISVGRendererRegion>)
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<nsISVGRendererRegion> dirty_region = SVGFrame->GetCoveredRegion();
if (dirty_region) {
if (accu_region) {
nsCOMPtr<nsISVGRendererRegion> 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

View File

@ -329,29 +329,7 @@ nsSVGInnerSVGFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
NS_IMETHODIMP_(already_AddRefed<nsISVGRendererRegion>)
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<nsISVGRendererRegion> dirty_region = SVGFrame->GetCoveredRegion();
if (dirty_region) {
if (accu_region) {
nsCOMPtr<nsISVGRendererRegion> 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

View File

@ -308,29 +308,7 @@ nsSVGTSpanFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
NS_IMETHODIMP_(already_AddRefed<nsISVGRendererRegion>)
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<nsISVGRendererRegion> dirty_region = SVGFrame->GetCoveredRegion();
if (accu_region) {
if (dirty_region) {
nsCOMPtr<nsISVGRendererRegion> 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

View File

@ -531,29 +531,7 @@ nsSVGTextFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
NS_IMETHODIMP_(already_AddRefed<nsISVGRendererRegion>)
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<nsISVGRendererRegion> dirty_region = SVGFrame->GetCoveredRegion();
if (dirty_region) {
if (accu_region) {
nsCOMPtr<nsISVGRendererRegion> 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

View File

@ -1120,3 +1120,29 @@ nsSVGUtils::GetCoordContextProvider(nsSVGElement *aElement)
NS_IF_ADDREF(ctx);
return ctx;
}
already_AddRefed<nsISVGRendererRegion>
nsSVGUtils::GetCoveredRegion(const nsFrameList &aFrames)
{
nsCOMPtr<nsISVGRendererRegion> accu_region;
for (nsIFrame* kid = aFrames.FirstChild();
kid;
kid = kid->GetNextSibling()) {
nsISVGChildFrame* child = nsnull;
CallQueryInterface(kid, &child);
if (child) {
nsCOMPtr<nsISVGRendererRegion> 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;
}

View File

@ -277,6 +277,12 @@ public:
static already_AddRefed<nsSVGCoordCtxProvider>
GetCoordContextProvider(nsSVGElement *aElement);
/*
* Get frame's covered region by walking the children and doing union.
*/
static already_AddRefed<nsISVGRendererRegion>
GetCoveredRegion(const nsFrameList &aFrames);
private:
/*
* Returns the glyph fragment containing a particular character