Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit bf434b1

Browse files
committed
Bug 864832 - Get rid of the majority of the remaining nsSVGUtils::InvalidateBounds calls, except for those related to transforms and nsSVGTextFrame2. r=mattwoodrow
1 parent df0343a commit bf434b1

11 files changed

Lines changed: 47 additions & 31 deletions

content/svg/content/src/SVGSwitchElement.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
55

66
#include "mozilla/dom/SVGSwitchElement.h"
7+
8+
#include "nsSVGEffects.h"
79
#include "nsSVGUtils.h"
810
#include "mozilla/Preferences.h"
911
#include "mozilla/dom/SVGSwitchElementBinding.h"
@@ -64,7 +66,7 @@ SVGSwitchElement::MaybeInvalidate()
6466

6567
nsIFrame *frame = GetPrimaryFrame();
6668
if (frame) {
67-
nsSVGUtils::InvalidateBounds(frame, false);
69+
nsSVGEffects::InvalidateRenderingObservers(frame);
6870
nsSVGUtils::ScheduleReflowSVG(frame);
6971
}
7072

layout/base/nsCSSFrameConstructor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7728,8 +7728,8 @@ DoApplyRenderingChangeToTree(nsIFrame* aFrame,
77287728
!(aFrame->GetStateBits() & NS_STATE_IS_OUTER_SVG)) {
77297729
if (aChange & nsChangeHint_UpdateEffects) {
77307730
needInvalidatingPaint = true;
7731-
// Invalidate and update our area:
7732-
nsSVGUtils::InvalidateBounds(aFrame, false);
7731+
nsSVGEffects::InvalidateRenderingObservers(aFrame);
7732+
// Need to update our overflow rects:
77337733
nsSVGUtils::ScheduleReflowSVG(aFrame);
77347734
} else {
77357735
needInvalidatingPaint = true;

layout/svg/nsSVGForeignObjectFrame.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,24 @@ nsSVGForeignObjectFrame::AttributeChanged(int32_t aNameSpaceID,
9393
if (aNameSpaceID == kNameSpaceID_None) {
9494
if (aAttribute == nsGkAtoms::width ||
9595
aAttribute == nsGkAtoms::height) {
96-
nsSVGUtils::InvalidateBounds(this, false);
96+
nsSVGEffects::InvalidateRenderingObservers(this);
9797
nsSVGUtils::ScheduleReflowSVG(this);
9898
// XXXjwatt: why mark intrinsic widths dirty? can't we just use eResize?
9999
RequestReflow(nsIPresShell::eStyleChange);
100100
} else if (aAttribute == nsGkAtoms::x ||
101-
aAttribute == nsGkAtoms::y ||
102-
aAttribute == nsGkAtoms::transform) {
101+
aAttribute == nsGkAtoms::y) {
102+
// make sure our cached transform matrix gets (lazily) updated
103+
mCanvasTM = nullptr;
104+
nsSVGEffects::InvalidateRenderingObservers(this);
105+
nsSVGUtils::ScheduleReflowSVG(this);
106+
} else if (aAttribute == nsGkAtoms::transform) {
103107
// make sure our cached transform matrix gets (lazily) updated
104108
mCanvasTM = nullptr;
105109
nsSVGUtils::InvalidateBounds(this, false);
106110
nsSVGUtils::ScheduleReflowSVG(this);
107111
} else if (aAttribute == nsGkAtoms::viewBox ||
108112
aAttribute == nsGkAtoms::preserveAspectRatio) {
109-
nsSVGUtils::InvalidateBounds(this);
113+
nsSVGEffects::InvalidateRenderingObservers(this);
110114
}
111115
}
112116

@@ -125,7 +129,7 @@ nsSVGForeignObjectFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
125129
// XXXperf: probably only need a bounds update if 'font-size' changed and
126130
// we have em unit width/height. Or, once we map 'transform' into style,
127131
// if some transform property changed.
128-
nsSVGUtils::InvalidateBounds(this, false);
132+
nsSVGEffects::InvalidateRenderingObservers(this);
129133
nsSVGUtils::ScheduleReflowSVG(this);
130134
}
131135
}

layout/svg/nsSVGGlyphFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ nsSVGGlyphFrame::CharacterDataChanged(CharacterDataChangeInfo* aInfo)
290290
// nsSVGUtils::InvalidateAndScheduleBoundsUpdate properly is when all our
291291
// text is gone, since it skips empty frames. So we have to invalidate
292292
// ourself.
293-
nsSVGUtils::InvalidateBounds(this);
293+
nsSVGEffects::InvalidateRenderingObservers(this);
294294
}
295295

296296
return NS_OK;

layout/svg/nsSVGImageFrame.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ nsSVGImageFrame::AttributeChanged(int32_t aNameSpaceID,
184184
aAttribute == nsGkAtoms::y ||
185185
aAttribute == nsGkAtoms::width ||
186186
aAttribute == nsGkAtoms::height) {
187-
nsSVGUtils::InvalidateBounds(this, false);
187+
nsSVGEffects::InvalidateRenderingObservers(this);
188188
nsSVGUtils::ScheduleReflowSVG(this);
189189
return NS_OK;
190190
}
@@ -559,21 +559,20 @@ nsSVGImageListener::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect
559559
return NS_ERROR_FAILURE;
560560

561561
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
562-
nsSVGUtils::InvalidateBounds(mFrame, false);
562+
nsSVGEffects::InvalidateRenderingObservers(mFrame);
563563
nsSVGUtils::ScheduleReflowSVG(mFrame);
564564
}
565565

566566
if (aType == imgINotificationObserver::FRAME_UPDATE) {
567567
// No new dimensions, so we don't need to call
568568
// nsSVGUtils::InvalidateAndScheduleBoundsUpdate.
569569
nsSVGEffects::InvalidateRenderingObservers(mFrame);
570-
nsSVGUtils::InvalidateBounds(mFrame);
571570
}
572571

573572
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
574573
// Called once the resource's dimensions have been obtained.
575574
aRequest->GetImage(getter_AddRefs(mFrame->mImageContainer));
576-
nsSVGUtils::InvalidateBounds(mFrame, false);
575+
nsSVGEffects::InvalidateRenderingObservers(mFrame);
577576
nsSVGUtils::ScheduleReflowSVG(mFrame);
578577
}
579578

layout/svg/nsSVGInnerSVGFrame.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "nsISVGChildFrame.h"
1313
#include "nsRenderingContext.h"
1414
#include "nsSVGContainerFrame.h"
15+
#include "nsSVGEffects.h"
1516
#include "nsSVGIntegrationUtils.h"
1617
#include "mozilla/dom/SVGSVGElement.h"
1718

@@ -172,7 +173,7 @@ nsSVGInnerSVGFrame::AttributeChanged(int32_t aNameSpaceID,
172173

173174
if (aAttribute == nsGkAtoms::width ||
174175
aAttribute == nsGkAtoms::height) {
175-
nsSVGUtils::InvalidateBounds(this, false);
176+
nsSVGEffects::InvalidateRenderingObservers(this);
176177
nsSVGUtils::ScheduleReflowSVG(this);
177178

178179
if (content->HasViewBoxOrSyntheticViewBox()) {
@@ -197,16 +198,21 @@ nsSVGInnerSVGFrame::AttributeChanged(int32_t aNameSpaceID,
197198
// make sure our cached transform matrix gets (lazily) updated
198199
mCanvasTM = nullptr;
199200

200-
nsSVGUtils::InvalidateBounds(this, false);
201-
nsSVGUtils::ScheduleReflowSVG(this);
202-
203201
nsSVGUtils::NotifyChildrenOfSVGChange(
204202
this, aAttribute == nsGkAtoms::viewBox ?
205203
TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED : TRANSFORM_CHANGED);
206204

207-
if (aAttribute == nsGkAtoms::viewBox ||
208-
(aAttribute == nsGkAtoms::preserveAspectRatio &&
209-
content->HasViewBoxOrSyntheticViewBox())) {
205+
if (aAttribute == nsGkAtoms::x || aAttribute == nsGkAtoms::y) {
206+
nsSVGEffects::InvalidateRenderingObservers(this);
207+
nsSVGUtils::ScheduleReflowSVG(this);
208+
} else if (aAttribute == nsGkAtoms::transform) {
209+
nsSVGUtils::InvalidateBounds(this, false);
210+
nsSVGUtils::ScheduleReflowSVG(this);
211+
} else if (aAttribute == nsGkAtoms::viewBox ||
212+
(aAttribute == nsGkAtoms::preserveAspectRatio &&
213+
content->HasViewBoxOrSyntheticViewBox())) {
214+
nsSVGUtils::InvalidateBounds(this, false);
215+
nsSVGUtils::ScheduleReflowSVG(this);
210216
content->ChildrenOnlyTransformChanged();
211217
}
212218
}

layout/svg/nsSVGPathGeometryFrame.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ nsSVGPathGeometryFrame::AttributeChanged(int32_t aNameSpaceID,
108108
{
109109
if (aNameSpaceID == kNameSpaceID_None &&
110110
(static_cast<nsSVGPathGeometryElement*>
111-
(mContent)->AttributeDefinesGeometry(aAttribute) ||
112-
aAttribute == nsGkAtoms::transform)) {
111+
(mContent)->AttributeDefinesGeometry(aAttribute))) {
112+
nsSVGEffects::InvalidateRenderingObservers(this);
113+
nsSVGUtils::ScheduleReflowSVG(this);
114+
} else if (aAttribute == nsGkAtoms::transform) {
113115
nsSVGUtils::InvalidateBounds(this, false);
114116
nsSVGUtils::ScheduleReflowSVG(this);
115117
}
@@ -127,7 +129,7 @@ nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
127129
// style_hints don't map very well onto svg. Here seems to be the
128130
// best place to deal with style changes:
129131

130-
nsSVGUtils::InvalidateBounds(this, false);
132+
nsSVGEffects::InvalidateRenderingObservers(this);
131133
nsSVGUtils::ScheduleReflowSVG(this);
132134
}
133135

layout/svg/nsSVGTSpanFrame.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "nsSVGTSpanFrame.h"
88

99
// Keep others in (case-insensitive) order:
10+
#include "nsSVGEffects.h"
1011
#include "nsSVGIntegrationUtils.h"
1112
#include "nsSVGUtils.h"
1213

@@ -78,7 +79,7 @@ nsSVGTSpanFrame::AttributeChanged(int32_t aNameSpaceID,
7879
aAttribute == nsGkAtoms::dx ||
7980
aAttribute == nsGkAtoms::dy ||
8081
aAttribute == nsGkAtoms::rotate)) {
81-
nsSVGUtils::InvalidateBounds(this, false);
82+
nsSVGEffects::InvalidateRenderingObservers(this);
8283
nsSVGUtils::ScheduleReflowSVG(this);
8384
NotifyGlyphMetricsChange();
8485
}

layout/svg/nsSVGTextFrame.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "nsGkAtoms.h"
1111
#include "mozilla/dom/SVGIRect.h"
1212
#include "nsISVGGlyphFragmentNode.h"
13+
#include "nsSVGEffects.h"
1314
#include "nsSVGGlyphFrame.h"
1415
#include "nsSVGIntegrationUtils.h"
1516
#include "nsSVGTextPathFrame.h"
@@ -62,7 +63,7 @@ nsSVGTextFrame::AttributeChanged(int32_t aNameSpaceID,
6263
aAttribute == nsGkAtoms::dx ||
6364
aAttribute == nsGkAtoms::dy ||
6465
aAttribute == nsGkAtoms::rotate) {
65-
nsSVGUtils::InvalidateBounds(this, false);
66+
nsSVGEffects::InvalidateRenderingObservers(this);
6667
nsSVGUtils::ScheduleReflowSVG(this);
6768
NotifyGlyphMetricsChange();
6869
}
@@ -320,7 +321,7 @@ nsSVGTextFrame::NotifyGlyphMetricsChange()
320321
// as fully dirty to get ReflowSVG() called on them:
321322
MarkDirtyBitsOnDescendants(this);
322323

323-
nsSVGUtils::InvalidateBounds(this, false);
324+
nsSVGEffects::InvalidateRenderingObservers(this);
324325
nsSVGUtils::ScheduleReflowSVG(this);
325326

326327
mPositioningDirty = true;

layout/svg/nsSVGTextPathFrame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ nsSVGTextPathFrame::AttributeChanged(int32_t aNameSpaceID,
158158
{
159159
if (aNameSpaceID == kNameSpaceID_None &&
160160
aAttribute == nsGkAtoms::startOffset) {
161-
nsSVGUtils::InvalidateBounds(this, false);
161+
nsSVGEffects::InvalidateRenderingObservers(this);
162162
nsSVGUtils::ScheduleReflowSVG(this);
163163
NotifyGlyphMetricsChange();
164164
} else if (aNameSpaceID == kNameSpaceID_XLink &&
165165
aAttribute == nsGkAtoms::href) {
166-
nsSVGUtils::InvalidateBounds(this, false);
166+
nsSVGEffects::InvalidateRenderingObservers(this);
167167
nsSVGUtils::ScheduleReflowSVG(this);
168168
// Blow away our reference, if any
169169
Properties().Delete(nsSVGEffects::HrefProperty());

0 commit comments

Comments
 (0)