Bug 1418930 Part 5: Update nsStyleStruct::FinishStyle and nsRuleNode::ComputeDisplayData to set CORS mode for shape-outside images. draft
authorBrad Werth <bwerth@mozilla.com>
Wed, 31 Jan 2018 16:08:01 -0500
changeset 751874 8a74c1b92c03ff74e2c876e68174fd2f1dcbcff0
parent 751873 ddc15fa984ec306168493bbdcc6ff36c6bb3366e
child 751875 801e9d09b215f0cf975faf7b1558bb34053c829b
push id98080
push userbwerth@mozilla.com
push dateWed, 07 Feb 2018 01:10:26 +0000
bugs1418930
milestone60.0a1
Bug 1418930 Part 5: Update nsStyleStruct::FinishStyle and nsRuleNode::ComputeDisplayData to set CORS mode for shape-outside images. MozReview-Commit-ID: 7MXJHE2vidS
layout/style/nsRuleNode.cpp
layout/style/nsStyleStruct.cpp
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -6448,16 +6448,20 @@ nsRuleNode::ComputeDisplayData(void* aSt
       display->mShapeOutside = parentDisplay->mShapeOutside;
       break;
     case eCSSUnit_Image:
     case eCSSUnit_Function:
     case eCSSUnit_Gradient:
     case eCSSUnit_Element: {
       auto shapeImage = MakeUnique<nsStyleImage>();
       SetStyleImage(aContext, *shapeOutsideValue, *shapeImage, conditions);
+      if (shapeImage->GetType() == eStyleImageType_Image) {
+        shapeImage->GetImageRequest()->GetImageValue()->SetCORSMode(
+          CORSMode::CORS_ANONYMOUS);
+      }
       display->mShapeOutside = StyleShapeSource();
       display->mShapeOutside.SetShapeImage(Move(shapeImage));
       break;
     }
     case eCSSUnit_Array: {
       display->mShapeOutside = StyleShapeSource();
       SetStyleShapeSourceToCSSValue(&display->mShapeOutside, shapeOutsideValue,
                                     aContext, mPresContext, conditions);
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -30,16 +30,17 @@
 
 #include "imgIRequest.h"
 #include "imgIContainer.h"
 #include "CounterStyleManager.h"
 
 #include "mozilla/dom/AnimationEffectReadOnlyBinding.h" // for PlaybackDirection
 #include "mozilla/dom/DocGroup.h"
 #include "mozilla/dom/ImageTracker.h"
+#include "mozilla/CORSMode.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Likely.h"
 #include "nsIURI.h"
 #include "nsIDocument.h"
 #include <algorithm>
 #include "ImageLoader.h"
 
 using namespace mozilla;
@@ -3726,16 +3727,23 @@ void
 nsStyleDisplay::FinishStyle(nsPresContext* aPresContext)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
 
   if (mShapeOutside.GetType() == StyleShapeSourceType::Image) {
     const UniquePtr<nsStyleImage>& shapeImage = mShapeOutside.GetShapeImage();
     if (shapeImage) {
+      // Bug 1434963: The CORS mode should instead be set when the
+      // ImageValue is created, in both Gecko and Stylo. That will
+      // avoid doing a mutation here.
+      if (shapeImage->GetType() == eStyleImageType_Image) {
+        shapeImage->GetImageRequest()->GetImageValue()->SetCORSMode(
+          CORSMode::CORS_ANONYMOUS);
+      }
       shapeImage->ResolveImage(aPresContext);
     }
   }
 
   GenerateCombinedTransform();
 }
 
 static inline nsChangeHint