summaryrefslogtreecommitdiffstats
path: root/layout/svg
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-08-18 16:25:15 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-08-18 16:26:16 +0200
commit202296d02aa99afa90581333ab059c050b9c3ade (patch)
tree6ed8a1289bed1bb06d2703ea77cba5fccd3bdffa /layout/svg
parent1530f48c27fb13d7cbd2708c9f0fcf2dabc6ed6a (diff)
parentab6242a93b849b0a3c7525b16bc01dd3172fc167 (diff)
downloadUXP-202296d02aa99afa90581333ab059c050b9c3ade.tar
UXP-202296d02aa99afa90581333ab059c050b9c3ade.tar.gz
UXP-202296d02aa99afa90581333ab059c050b9c3ade.tar.lz
UXP-202296d02aa99afa90581333ab059c050b9c3ade.tar.xz
UXP-202296d02aa99afa90581333ab059c050b9c3ade.zip
Pull Basilisk-release forward.
Diffstat (limited to 'layout/svg')
-rw-r--r--layout/svg/SVGTextFrame.cpp10
-rw-r--r--layout/svg/nsSVGEffects.cpp47
-rw-r--r--layout/svg/nsSVGEffects.h2
-rw-r--r--layout/svg/nsSVGFilterFrame.cpp4
-rw-r--r--layout/svg/nsSVGGradientFrame.cpp4
-rw-r--r--layout/svg/nsSVGIntegrationUtils.cpp5
-rw-r--r--layout/svg/nsSVGOuterSVGFrame.cpp53
-rw-r--r--layout/svg/nsSVGPatternFrame.cpp4
-rw-r--r--layout/svg/nsSVGUtils.cpp5
9 files changed, 71 insertions, 63 deletions
diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp
index e5a03333f..6ba267ee8 100644
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -1328,7 +1328,7 @@ NS_DECLARE_FRAME_PROPERTY_DELETABLE(TextNodeCorrespondenceProperty,
static uint32_t
GetUndisplayedCharactersBeforeFrame(nsTextFrame* aFrame)
{
- void* value = aFrame->Properties().Get(TextNodeCorrespondenceProperty());
+ void* value = aFrame->GetProperty(TextNodeCorrespondenceProperty());
TextNodeCorrespondence* correspondence =
static_cast<TextNodeCorrespondence*>(value);
if (!correspondence) {
@@ -1517,8 +1517,8 @@ TextNodeCorrespondenceRecorder::TraverseAndRecord(nsIFrame* aFrame)
}
// Set the frame property.
- frame->Properties().Set(TextNodeCorrespondenceProperty(),
- new TextNodeCorrespondence(undisplayed));
+ frame->SetProperty(TextNodeCorrespondenceProperty(),
+ new TextNodeCorrespondence(undisplayed));
// Remember how far into the current nsTextNode we are.
mNodeCharIndex = frame->GetContentEnd();
@@ -3391,7 +3391,7 @@ SVGTextFrame::HandleAttributeChangeInDescendant(Element* aElement,
// Blow away our reference, if any
nsIFrame* childElementFrame = aElement->GetPrimaryFrame();
if (childElementFrame) {
- childElementFrame->Properties().Delete(
+ childElementFrame->DeleteProperty(
nsSVGEffects::HrefAsTextPathProperty());
NotifyGlyphMetricsChange();
}
@@ -4817,7 +4817,7 @@ SVGPathElement*
SVGTextFrame::GetTextPathPathElement(nsIFrame* aTextPathFrame)
{
nsSVGTextPathProperty *property =
- aTextPathFrame->Properties().Get(nsSVGEffects::HrefAsTextPathProperty());
+ aTextPathFrame->GetProperty(nsSVGEffects::HrefAsTextPathProperty());
if (!property) {
nsIContent* content = aTextPathFrame->GetContent();
diff --git a/layout/svg/nsSVGEffects.cpp b/layout/svg/nsSVGEffects.cpp
index e75c973c8..ca4c5778c 100644
--- a/layout/svg/nsSVGEffects.cpp
+++ b/layout/svg/nsSVGEffects.cpp
@@ -480,27 +480,26 @@ GetOrCreateFilterProperty(nsIFrame* aFrame)
if (!effects->HasFilters())
return nullptr;
- FrameProperties props = aFrame->Properties();
- nsSVGFilterProperty *prop = props.Get(nsSVGEffects::FilterProperty());
+ nsSVGFilterProperty *prop =
+ aFrame->GetProperty(nsSVGEffects::FilterProperty());
if (prop)
return prop;
prop = new nsSVGFilterProperty(effects->mFilters, aFrame);
NS_ADDREF(prop);
- props.Set(nsSVGEffects::FilterProperty(), prop);
+ aFrame->SetProperty(nsSVGEffects::FilterProperty(), prop);
return prop;
}
static nsSVGMaskProperty*
GetOrCreateMaskProperty(nsIFrame* aFrame)
{
- FrameProperties props = aFrame->Properties();
- nsSVGMaskProperty *prop = props.Get(nsSVGEffects::MaskProperty());
+ nsSVGMaskProperty *prop = aFrame->GetProperty(nsSVGEffects::MaskProperty());
if (prop)
return prop;
prop = new nsSVGMaskProperty(aFrame);
NS_ADDREF(prop);
- props.Set(nsSVGEffects::MaskProperty(), prop);
+ aFrame->SetProperty(nsSVGEffects::MaskProperty(), prop);
return prop;
}
@@ -512,13 +511,12 @@ GetEffectProperty(nsIURI* aURI, nsIFrame* aFrame,
if (!aURI)
return nullptr;
- FrameProperties props = aFrame->Properties();
- T* prop = props.Get(aProperty);
+ T* prop = aFrame->GetProperty(aProperty);
if (prop)
return prop;
prop = new T(aURI, aFrame, false);
NS_ADDREF(prop);
- props.Set(aProperty, prop);
+ aFrame->SetProperty(aProperty, prop);
return prop;
}
@@ -553,11 +551,11 @@ nsSVGEffects::GetPaintingPropertyForURI(nsIURI* aURI, nsIFrame* aFrame,
if (!aURI)
return nullptr;
- FrameProperties props = aFrame->Properties();
- nsSVGEffects::URIObserverHashtable *hashtable = props.Get(aProperty);
+ nsSVGEffects::URIObserverHashtable *hashtable =
+ aFrame->GetProperty(aProperty);
if (!hashtable) {
hashtable = new nsSVGEffects::URIObserverHashtable();
- props.Set(aProperty, hashtable);
+ aFrame->SetProperty(aProperty, hashtable);
}
nsSVGPaintingProperty* prop =
static_cast<nsSVGPaintingProperty*>(hashtable->GetWeak(aURI));
@@ -689,16 +687,15 @@ nsSVGEffects::UpdateEffects(nsIFrame* aFrame)
NS_ASSERTION(aFrame->GetContent()->IsElement(),
"aFrame's content should be an element");
- FrameProperties props = aFrame->Properties();
- props.Delete(FilterProperty());
- props.Delete(MaskProperty());
- props.Delete(ClipPathProperty());
- props.Delete(MarkerBeginProperty());
- props.Delete(MarkerMiddleProperty());
- props.Delete(MarkerEndProperty());
- props.Delete(FillProperty());
- props.Delete(StrokeProperty());
- props.Delete(BackgroundImageProperty());
+ aFrame->DeleteProperty(FilterProperty());
+ aFrame->DeleteProperty(MaskProperty());
+ aFrame->DeleteProperty(ClipPathProperty());
+ aFrame->DeleteProperty(MarkerBeginProperty());
+ aFrame->DeleteProperty(MarkerMiddleProperty());
+ aFrame->DeleteProperty(MarkerEndProperty());
+ aFrame->DeleteProperty(FillProperty());
+ aFrame->DeleteProperty(StrokeProperty());
+ aFrame->DeleteProperty(BackgroundImageProperty());
// Ensure that the filter is repainted correctly
// We can't do that in DoUpdate as the referenced frame may not be valid
@@ -725,7 +722,7 @@ nsSVGEffects::GetFilterProperty(nsIFrame* aFrame)
if (!aFrame->StyleEffects()->HasFilters())
return nullptr;
- return aFrame->Properties().Get(FilterProperty());
+ return aFrame->GetProperty(FilterProperty());
}
void
@@ -835,7 +832,7 @@ nsSVGEffects::InvalidateRenderingObservers(nsIFrame* aFrame)
return;
// If the rendering has changed, the bounds may well have changed too:
- aFrame->Properties().Delete(nsSVGUtils::ObjectBoundingBoxProperty());
+ aFrame->DeleteProperty(nsSVGUtils::ObjectBoundingBoxProperty());
nsSVGRenderingObserverList *observerList =
GetObserverList(content->AsElement());
@@ -864,7 +861,7 @@ nsSVGEffects::InvalidateDirectRenderingObservers(Element* aElement, uint32_t aFl
nsIFrame* frame = aElement->GetPrimaryFrame();
if (frame) {
// If the rendering has changed, the bounds may well have changed too:
- frame->Properties().Delete(nsSVGUtils::ObjectBoundingBoxProperty());
+ frame->DeleteProperty(nsSVGUtils::ObjectBoundingBoxProperty());
}
if (aElement->HasRenderingObservers()) {
diff --git a/layout/svg/nsSVGEffects.h b/layout/svg/nsSVGEffects.h
index 0cf9b1500..b8b2e53c1 100644
--- a/layout/svg/nsSVGEffects.h
+++ b/layout/svg/nsSVGEffects.h
@@ -7,7 +7,7 @@
#define NSSVGEFFECTS_H_
#include "mozilla/Attributes.h"
-#include "FramePropertyTable.h"
+#include "FrameProperties.h"
#include "mozilla/dom/Element.h"
#include "nsHashKeys.h"
#include "nsID.h"
diff --git a/layout/svg/nsSVGFilterFrame.cpp b/layout/svg/nsSVGFilterFrame.cpp
index 13ce16993..3b99f413e 100644
--- a/layout/svg/nsSVGFilterFrame.cpp
+++ b/layout/svg/nsSVGFilterFrame.cpp
@@ -107,7 +107,7 @@ nsSVGFilterFrame::GetReferencedFilter()
return nullptr;
nsSVGPaintingProperty *property =
- Properties().Get(nsSVGEffects::HrefAsPaintingProperty());
+ GetProperty(nsSVGEffects::HrefAsPaintingProperty());
if (!property) {
// Fetch our Filter element's href or xlink:href attribute
@@ -183,7 +183,7 @@ nsSVGFilterFrame::AttributeChanged(int32_t aNameSpaceID,
aNameSpaceID == kNameSpaceID_None) &&
aAttribute == nsGkAtoms::href) {
// Blow away our reference, if any
- Properties().Delete(nsSVGEffects::HrefAsPaintingProperty());
+ DeleteProperty(nsSVGEffects::HrefAsPaintingProperty());
mNoHRefURI = false;
// And update whoever references us
nsSVGEffects::InvalidateDirectRenderingObservers(this);
diff --git a/layout/svg/nsSVGGradientFrame.cpp b/layout/svg/nsSVGGradientFrame.cpp
index 2d7684f5a..340cfa881 100644
--- a/layout/svg/nsSVGGradientFrame.cpp
+++ b/layout/svg/nsSVGGradientFrame.cpp
@@ -72,7 +72,7 @@ nsSVGGradientFrame::AttributeChanged(int32_t aNameSpaceID,
aNameSpaceID == kNameSpaceID_None) &&
aAttribute == nsGkAtoms::href) {
// Blow away our reference, if any
- Properties().Delete(nsSVGEffects::HrefAsPaintingProperty());
+ DeleteProperty(nsSVGEffects::HrefAsPaintingProperty());
mNoHRefURI = false;
// And update whoever references us
nsSVGEffects::InvalidateDirectRenderingObservers(this);
@@ -316,7 +316,7 @@ nsSVGGradientFrame::GetReferencedGradient()
return nullptr;
nsSVGPaintingProperty *property =
- Properties().Get(nsSVGEffects::HrefAsPaintingProperty());
+ GetProperty(nsSVGEffects::HrefAsPaintingProperty());
if (!property) {
// Fetch our gradient element's href or xlink:href attribute
diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp
index 0003e1a73..4ce2941d4 100644
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -75,7 +75,7 @@ public:
private:
static nsRect GetPreEffectsVisualOverflowRect(nsIFrame* aFrame) {
- nsRect* r = aFrame->Properties().Get(nsIFrame::PreEffectsBBoxProperty());
+ nsRect* r = aFrame->GetProperty(nsIFrame::PreEffectsBBoxProperty());
if (r) {
return *r;
}
@@ -113,8 +113,7 @@ private:
NS_ASSERTION(aFrame->GetParent()->StyleContext()->GetPseudo() ==
nsCSSAnonBoxes::mozAnonymousBlock,
"How did we getting here, then?");
- NS_ASSERTION(!aFrame->Properties().Get(
- aFrame->PreTransformOverflowAreasProperty()),
+ NS_ASSERTION(!aFrame->GetProperty(aFrame->PreTransformOverflowAreasProperty()),
"GetVisualOverflowRect() won't return the pre-effects rect!");
return aFrame->GetVisualOverflowRect();
}
diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp
index e1b97bb40..b1ee54eb9 100644
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -979,43 +979,56 @@ nsSVGOuterSVGAnonChildFrame::GetType() const
return nsGkAtoms::svgOuterSVGAnonChildFrame;
}
-bool
-nsSVGOuterSVGAnonChildFrame::IsSVGTransformed(Matrix* aOwnTransform,
- Matrix* aFromParentTransform) const
+static Matrix
+ComputeOuterSVGAnonChildFrameTransform(const nsSVGOuterSVGAnonChildFrame* aFrame)
{
// Our elements 'transform' attribute is applied to our nsSVGOuterSVGFrame
// parent, and the element's children-only transforms are applied to us, the
// anonymous child frame. Since we are the child frame, we apply the
// children-only transforms as if they are our own transform.
- SVGSVGElement* content = static_cast<SVGSVGElement*>(mContent);
+ SVGSVGElement* content = static_cast<SVGSVGElement*>(aFrame->GetContent());
if (!content->HasChildrenOnlyTransform()) {
- return false;
+ return Matrix();
}
// Outer-<svg> doesn't use x/y, so we can pass eChildToUserSpace here.
gfxMatrix ownMatrix =
content->PrependLocalTransformsTo(gfxMatrix(), eChildToUserSpace);
- if (ownMatrix.IsIdentity()) {
- return false;
+ if (ownMatrix.HasNonTranslation()) {
+ // viewBox, currentScale and currentTranslate should only produce a
+ // rectilinear transform.
+ MOZ_ASSERT(ownMatrix.IsRectilinear(),
+ "Non-rectilinear transform will break the following logic");
+
+ // The nsDisplayTransform code will apply this transform to our frame,
+ // including to our frame position. We don't want our frame position to
+ // be scaled though, so we need to correct for that in the transform.
+ CSSPoint pos = CSSPixel::FromAppUnits(aFrame->GetPosition());
+ CSSPoint scaledPos = CSSPoint(ownMatrix._11 * pos.x, ownMatrix._22 * pos.y);
+ CSSPoint deltaPos = scaledPos - pos;
+ ownMatrix *= gfxMatrix::Translation(-deltaPos.x, -deltaPos.y);
}
- if (aOwnTransform) {
- if (ownMatrix.HasNonTranslation()) {
- // Note: viewBox, currentScale and currentTranslate should only
- // produce a rectilinear transform.
- // The nsDisplayTransform code will apply this transform to our frame,
- // including to our frame position. We don't want our frame position to
- // be scaled though, so we need to correct for that in the transform.
- CSSPoint pos = CSSPixel::FromAppUnits(GetPosition());
- CSSPoint scaledPos = CSSPoint(ownMatrix._11 * pos.x, ownMatrix._22 * pos.y);
- CSSPoint deltaPos = scaledPos - pos;
- ownMatrix *= gfxMatrix::Translation(-deltaPos.x, -deltaPos.y);
- }
+ return gfx::ToMatrix(ownMatrix);
+}
- *aOwnTransform = gfx::ToMatrix(ownMatrix);
+// We want this frame to be a reference frame. An easy way to achieve that is
+// to always return true from this method, even for identity transforms.
+// This frame being a reference frame ensures that the offset between this
+// <svg> element and the parent reference frame is completely absorbed by the
+// nsDisplayTransform that's created for this frame, and that this offset does
+// not affect our descendants' transforms. Consequently, if the <svg> element
+// moves, e.g. during scrolling, the transform matrices of our contents are
+// unaffected. This simplifies invalidation.
+bool
+nsSVGOuterSVGAnonChildFrame::IsSVGTransformed(Matrix* aOwnTransform,
+ Matrix* aFromParentTransform) const
+{
+ if (aOwnTransform) {
+ *aOwnTransform = ComputeOuterSVGAnonChildFrameTransform(this);
}
return true;
diff --git a/layout/svg/nsSVGPatternFrame.cpp b/layout/svg/nsSVGPatternFrame.cpp
index 198163d7f..2cd7eeaad 100644
--- a/layout/svg/nsSVGPatternFrame.cpp
+++ b/layout/svg/nsSVGPatternFrame.cpp
@@ -89,7 +89,7 @@ nsSVGPatternFrame::AttributeChanged(int32_t aNameSpaceID,
aNameSpaceID == kNameSpaceID_None) &&
aAttribute == nsGkAtoms::href) {
// Blow away our reference, if any
- Properties().Delete(nsSVGEffects::HrefAsPaintingProperty());
+ DeleteProperty(nsSVGEffects::HrefAsPaintingProperty());
mNoHRefURI = false;
// And update whoever references us
nsSVGEffects::InvalidateDirectRenderingObservers(this);
@@ -548,7 +548,7 @@ nsSVGPatternFrame::GetReferencedPattern()
return nullptr;
nsSVGPaintingProperty *property =
- Properties().Get(nsSVGEffects::HrefAsPaintingProperty());
+ GetProperty(nsSVGEffects::HrefAsPaintingProperty());
if (!property) {
// Fetch our pattern element's href or xlink:href attribute
diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp
index 98e5f9b5f..c3394e292 100644
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1060,10 +1060,9 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, uint32_t aFlags)
return bbox;
}
- FrameProperties props = aFrame->Properties();
if (aFlags == eBBoxIncludeFillGeometry) {
- gfxRect* prop = props.Get(ObjectBoundingBoxProperty());
+ gfxRect* prop = aFrame->GetProperty(ObjectBoundingBoxProperty());
if (prop) {
return *prop;
}
@@ -1139,7 +1138,7 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, uint32_t aFlags)
if (aFlags == eBBoxIncludeFillGeometry) {
// Obtaining the bbox for objectBoundingBox calculations is common so we
// cache the result for future calls, since calculation can be expensive:
- props.Set(ObjectBoundingBoxProperty(), new gfxRect(bbox));
+ aFrame->SetProperty(ObjectBoundingBoxProperty(), new gfxRect(bbox));
}
return bbox;