Backed out changeset de8bbf1eb200 (bug 1359762) for failing reftest context-fill-01.html. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 28 Apr 2017 22:54:00 +0200
changeset 355623 8d2edaa9631613a4d4b57d49f26bedca67e5f5b9
parent 355622 7a257ad733fb90f359aa64a8b7432d81ed2677f2
child 355624 51304049d0a216ec5a09dc221444c36af07c2aac
push id89718
push userarchaeopteryx@coole-files.de
push dateFri, 28 Apr 2017 20:54:26 +0000
treeherdermozilla-inbound@8d2edaa96316 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1359762
milestone55.0a1
backs outde8bbf1eb20017db722ba77dbe3e187a4bbe359b
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
Backed out changeset de8bbf1eb200 (bug 1359762) for failing reftest context-fill-01.html. r=backout
image/VectorImage.cpp
layout/svg/SVGContextPaint.cpp
layout/svg/SVGContextPaint.h
layout/svg/SVGImageContext.cpp
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -896,21 +896,18 @@ VectorImage::Draw(gfxContext* aContext,
   // Set the animation time:
   AutoSVGTimeSetRestore autoSVGTime(mSVGDocumentWrapper->GetRootSVGElem(),
                                     animTime);
 
   // Set context paint (if specified) on the document:
   Maybe<AutoSetRestoreSVGContextPaint> autoContextPaint;
   if (aSVGContext &&
       aSVGContext->GetContextPaint()) {
-    nsCOMPtr<nsIURI> uri = mURI->ToIURI();
-    if (SVGContextPaint::IsAllowedForImageFromURI(uri)) {
-      autoContextPaint.emplace(aSVGContext->GetContextPaint(),
-                               mSVGDocumentWrapper->GetDocument());
-    }
+    autoContextPaint.emplace(aSVGContext->GetContextPaint(),
+                             mSVGDocumentWrapper->GetDocument());
   }
 
   // We didn't get a hit in the surface cache, so we'll need to rerasterize.
   CreateSurfaceAndShow(params, aContext->GetDrawTarget()->GetBackendType());
   return DrawResult::SUCCESS;
 }
 
 already_AddRefed<gfxDrawable>
--- a/layout/svg/SVGContextPaint.cpp
+++ b/layout/svg/SVGContextPaint.cpp
@@ -2,73 +2,26 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SVGContextPaint.h"
 
 #include "gfxContext.h"
 #include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
-#include "mozilla/Preferences.h"
 #include "nsIDocument.h"
 #include "nsSVGPaintServerFrame.h"
 #include "nsSVGEffects.h"
 #include "nsSVGPaintServerFrame.h"
 
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 namespace mozilla {
 
-/* static */ bool
-SVGContextPaint::IsAllowedForImageFromURI(nsIURI* aURI)
-{
-  static bool sEnabledForContent = false;
-  static bool sEnabledForContentCached = false;
-
-  if (!sEnabledForContentCached) {
-    Preferences::AddBoolVarCache(&sEnabledForContent,
-                                 "svg.context-properties.content.enabled", false);
-    sEnabledForContentCached = true;
-  }
-
-  if (sEnabledForContent) {
-    return true;
-  }
-
-  // Context paint is pref'ed off for Web content.  Ideally we'd have some
-  // easy means to determine whether the frame that has linked to the image
-  // is a frame for a content node that originated from Web content.
-  // Unfortunately different types of anonymous content, about: documents
-  // such as about:reader, etc. that are "our" code that we ship are
-  // sometimes hard to distinguish from real Web content.  As a result,
-  // instead of trying to figure out what content is "ours" we instead let
-  // any content provide image context paint, but only if the image is
-  // chrome:// or resource:// do we return true.  This should be sufficient
-  // to stop the image context paint feature being useful to (and therefore
-  // used by and relied upon by) Web content.  (We don't want Web content to
-  // use this feature because we're not sure that image context paint is a
-  // good mechanism for wider use, or suitable for specification.)
-  //
-  // One case where we may return false here and prevent image context paint
-  // being used by "our" content is in-tree WebExtensions.  These have scheme
-  // 'moz-extension://', but so do other developers' extensions, and we don't
-  // want extension developers coming to rely on image context paint either.
-  // We may be able to provide our in-tree extensions access to context paint
-  // once they are signed. For more information see:
-  // https://bugzilla.mozilla.org/show_bug.cgi?id=1359762#c5
-  //
-  nsAutoCString scheme;
-  if (NS_SUCCEEDED(aURI->GetScheme(scheme)) &&
-      (scheme.EqualsLiteral("chrome") || scheme.EqualsLiteral("resource"))) {
-    return true;
-  }
-  return false;
-}
-
 /**
  * Stores in |aTargetPaint| information on how to reconstruct the current
  * fill or stroke pattern. Will also set the paint opacity to transparent if
  * the paint is set to "none".
  * @param aOuterContextPaint pattern information from the outer text context
  * @param aTargetPaint where to store the current pattern information
  * @param aFillOrStroke member pointer to the paint we are setting up
  * @param aProperty the frame property descriptor of the fill or stroke paint
--- a/layout/svg/SVGContextPaint.h
+++ b/layout/svg/SVGContextPaint.h
@@ -109,22 +109,16 @@ public:
 
   virtual uint32_t Hash() const {
     MOZ_ASSERT_UNREACHABLE("Only VectorImage needs to hash, and that should "
                            "only be operating on our SVGEmbeddingContextPaint "
                            "subclass");
     return 0;
   }
 
-  /**
-   * Returns true if image context paint is allowed to be used in an image that
-   * has the given URI, else returns false.
-   */
-  static bool IsAllowedForImageFromURI(nsIURI* aURI);
-
 private:
   // Member-vars are initialized in InitStrokeGeometry.
   FallibleTArray<gfxFloat> mDashes;
   MOZ_INIT_OUTSIDE_CTOR gfxFloat mDashOffset;
   MOZ_INIT_OUTSIDE_CTOR gfxFloat mStrokeWidth;
 };
 
 /**
--- a/layout/svg/SVGImageContext.cpp
+++ b/layout/svg/SVGImageContext.cpp
@@ -4,35 +4,50 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 // Main header first:
 #include "SVGImageContext.h"
 
 // Keep others in (case-insensitive) order:
 #include "gfxUtils.h"
+#include "mozilla/Preferences.h"
 #include "nsContentUtils.h"
 #include "nsIFrame.h"
 #include "nsPresContext.h"
 #include "nsStyleStruct.h"
 
 namespace mozilla {
 
 /* static */ void
 SVGImageContext::MaybeStoreContextPaint(Maybe<SVGImageContext>& aContext,
                                         nsIFrame* aFromFrame,
                                         imgIContainer* aImgContainer)
 {
-  // This check is cheap, so we put it first:
+  static bool sEnabledForContent = false;
+  static bool sEnabledForContentCached = false;
+
+  if (!sEnabledForContentCached) {
+    Preferences::AddBoolVarCache(&sEnabledForContent,
+                                 "svg.context-properties.content.enabled", false);
+    sEnabledForContentCached = true;
+  }
+
   if (!aFromFrame->StyleSVG()->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.
+    return;
+  }
+
   if (aImgContainer->GetType() != imgIContainer::TYPE_VECTOR) {
     // Avoid this overhead for raster images.
     return;
   }
 
   bool haveContextPaint = false;
 
   RefPtr<SVGEmbeddingContextPaint> contextPaint = new SVGEmbeddingContextPaint();