Bug 1383650 - Remove some redundant attribute observing logic r=longsonr

Since geometry property values are computed from CSS, which also
takes care of change hint via `CalcDifference`, we can just remove
some logic to observe attribute change for `x`, `y`, etc.

Differential Revision: https://phabricator.services.mozilla.com/D32564

--HG--
extra : moz-landing-system : lando
This commit is contained in:
violet 2019-05-25 11:17:49 +00:00
parent e88940a4dc
commit 374f6c917e
3 changed files with 15 additions and 23 deletions

View File

@ -83,21 +83,7 @@ nsresult nsSVGForeignObjectFrame::AttributeChanged(int32_t aNameSpaceID,
nsAtom* aAttribute,
int32_t aModType) {
if (aNameSpaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height) {
nsLayoutUtils::PostRestyleEvent(
mContent->AsElement(), RestyleHint{0},
nsChangeHint_InvalidateRenderingObservers);
nsSVGUtils::ScheduleReflowSVG(this);
// XXXjwatt: why mark intrinsic widths dirty? can't we just use eResize?
RequestReflow(IntrinsicDirty::StyleChange);
} else if (aAttribute == nsGkAtoms::x || aAttribute == nsGkAtoms::y) {
// make sure our cached transform matrix gets (lazily) updated
mCanvasTM = nullptr;
nsLayoutUtils::PostRestyleEvent(
mContent->AsElement(), RestyleHint{0},
nsChangeHint_InvalidateRenderingObservers);
nsSVGUtils::ScheduleReflowSVG(this);
} else if (aAttribute == nsGkAtoms::transform) {
if (aAttribute == nsGkAtoms::transform) {
// We don't invalidate for transform changes (the layers code does that).
// Also note that SVGTransformableElement::GetAttributeChangeHint will
// return nsChangeHint_UpdateOverflow for "transform" attribute changes
@ -114,6 +100,18 @@ nsresult nsSVGForeignObjectFrame::AttributeChanged(int32_t aNameSpaceID,
return NS_OK;
}
void nsSVGForeignObjectFrame::DidSetComputedStyle(
ComputedStyle* aOldComputedStyle) {
if (aOldComputedStyle) {
if (StyleSVGReset()->mX != aOldComputedStyle->StyleSVGReset()->mX ||
StyleSVGReset()->mY != aOldComputedStyle->StyleSVGReset()->mY) {
// Invalidate cached transform matrix.
mCanvasTM = nullptr;
nsSVGUtils::ScheduleReflowSVG(this);
}
}
}
void nsSVGForeignObjectFrame::Reflow(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,

View File

@ -85,6 +85,8 @@ class nsSVGForeignObjectFrame final : public nsContainerFrame,
// Return our ::-moz-svg-foreign-content anonymous box.
void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
protected:
// implementation helpers:
void DoReflow();

View File

@ -120,14 +120,6 @@ nsresult nsSVGImageFrame::AttributeChanged(int32_t aNameSpaceID,
nsAtom* aAttribute,
int32_t aModType) {
if (aNameSpaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::x || aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height) {
nsLayoutUtils::PostRestyleEvent(
mContent->AsElement(), RestyleHint{0},
nsChangeHint_InvalidateRenderingObservers);
nsSVGUtils::ScheduleReflowSVG(this);
return NS_OK;
}
if (aAttribute == nsGkAtoms::preserveAspectRatio) {
// We don't paint the content of the image using display lists, therefore
// we have to invalidate for this children-only transform changes since