Bug 1360662, part 1 - Only expose properties that are listed in '-moz-context-properties' as image context properties. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Wed, 19 Apr 2017 14:52:25 +0100
changeset 406864 657e214ca5280eb8b626b230864125389d25459d
parent 406863 69ceb4c8dbb84e0e9c1a0869eb60499681aca92d
child 406865 13b354344cf7cf0881ba80dc41730db1e1a53d35
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1360662
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1360662, part 1 - Only expose properties that are listed in '-moz-context-properties' as image context properties. r=dholbert MozReview-Commit-ID: B17M2vQZ92e
layout/svg/SVGImageContext.cpp
--- a/layout/svg/SVGImageContext.cpp
+++ b/layout/svg/SVGImageContext.cpp
@@ -26,17 +26,19 @@ SVGImageContext::MaybeStoreContextPaint(
   static bool sEnabledForContentCached = false;
 
   if (!sEnabledForContentCached) {
     Preferences::AddBoolVarCache(&sEnabledForContent,
                                  "svg.context-properties.content.enabled", false);
     sEnabledForContentCached = true;
   }
 
-  if (!aFromFrame->StyleSVG()->ExposesContextProperties()) {
+  const nsStyleSVG* style = aFromFrame->StyleSVG();
+
+  if (!style->ExposesContextProperties()) {
     // Content must have '-moz-context-properties' set to the names of the
     // properties it wants to expose to images it links to.
     return;
   }
 
   if (!sEnabledForContent &&
       !nsContentUtils::IsChromeDoc(aFromFrame->PresContext()->Document())) {
     // Context paint is pref'ed off for content and this is a content doc.
@@ -47,25 +49,23 @@ SVGImageContext::MaybeStoreContextPaint(
     // Avoid this overhead for raster images.
     return;
   }
 
   bool haveContextPaint = false;
 
   RefPtr<SVGEmbeddingContextPaint> contextPaint = new SVGEmbeddingContextPaint();
 
-  const nsStyleSVG* style = aFromFrame->StyleSVG();
-
-  // XXX don't set values for properties not listed in 'context-properties'.
-
-  if (style->mFill.Type() == eStyleSVGPaintType_Color) {
+  if ((style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_FILL) &&
+      style->mFill.Type() == eStyleSVGPaintType_Color) {
     haveContextPaint = true;
     contextPaint->SetFill(style->mFill.GetColor());
   }
-  if (style->mStroke.Type() == eStyleSVGPaintType_Color) {
+  if ((style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_STROKE) &&
+      style->mStroke.Type() == eStyleSVGPaintType_Color) {
     haveContextPaint = true;
     contextPaint->SetStroke(style->mStroke.GetColor());
   }
 
   if (haveContextPaint) {
     if (!aContext) {
       aContext.emplace();
     }