Bug 1341690 - stylo: Make URLs work in inline style; r?emilio draft
authorManish Goregaokar <manishearth@gmail.com>
Fri, 10 Mar 2017 18:28:02 -0800
changeset 497120 cc20b7fe16050db62e869201c953639185643980
parent 496989 134eeb65c57390d966b97fa67ce0dd1e752f5fff
child 548803 3a8bd25f630a699938096f636b7ad8bdcbc2c5fc
push id48803
push userbmo:manishearth@gmail.com
push dateSat, 11 Mar 2017 19:03:54 +0000
reviewersemilio
bugs1341690
milestone55.0a1
Bug 1341690 - stylo: Make URLs work in inline style; r?emilio MozReview-Commit-ID: 6Tc0kBw4V8c
dom/base/nsAttrValue.cpp
layout/reftests/backgrounds/reftest-stylo.list
layout/reftests/ogg-video/reftest-stylo.list
layout/reftests/svg/svg-integration/reftest-stylo.list
layout/reftests/webm-video/reftest-stylo.list
layout/style/ServoBindingList.h
layout/style/ServoDeclarationBlock.cpp
layout/style/ServoDeclarationBlock.h
layout/style/nsDOMCSSDeclaration.cpp
layout/style/test/stylo-failures.md
--- a/dom/base/nsAttrValue.cpp
+++ b/dom/base/nsAttrValue.cpp
@@ -1720,17 +1720,18 @@ nsAttrValue::ParseStyleAttribute(const n
       NS_ADDREF(cont);
       SetPtrValueAndType(cont, eOtherBase);
       return true;
     }
   }
 
   RefPtr<DeclarationBlock> decl;
   if (ownerDoc->GetStyleBackendType() == StyleBackendType::Servo) {
-    decl = ServoDeclarationBlock::FromCssText(aString);
+    GeckoParserExtraData data(baseURI, docURI, aElement->NodePrincipal());
+    decl = ServoDeclarationBlock::FromCssText(aString, data);
   } else {
     css::Loader* cssLoader = ownerDoc->CSSLoader();
     nsCSSParser cssParser(cssLoader);
     decl = cssParser.ParseStyleAttribute(aString, docURI, baseURI,
                                          aElement->NodePrincipal());
   }
   if (!decl) {
     return false;
--- a/layout/reftests/backgrounds/reftest-stylo.list
+++ b/layout/reftests/backgrounds/reftest-stylo.list
@@ -133,17 +133,17 @@ fails == background-size-monster-rem.htm
 fails == background-moz-default-background-color.html background-moz-default-background-color.html
 
 fails == fixed-bg-with-transform-outside-viewport-1.html fixed-bg-with-transform-outside-viewport-1.html
 fuzzy(2,83) == fixed-bg-border-radius.html fixed-bg-border-radius.html
 
 fails HTTP == root-background-1.html root-background-1.html
 fails HTTP == root-background-1.html root-background-1.html
 
-fails == really-big-background.html really-big-background.html # Bug 1341690
+== really-big-background.html really-big-background.html # Bug 1341690
 fails == body-background.html body-background.html # Bug 1339711
 fails == table-background.html table-background.html # Bug 1339711
 fails == table-background-print.html table-background-print.html
 == div-background.html div-background.html
 
 == background-repeat-1-ref.html background-repeat-1-ref.html
 
 == multi-background-clip-content-border.html multi-background-clip-content-border.html
--- a/layout/reftests/ogg-video/reftest-stylo.list
+++ b/layout/reftests/ogg-video/reftest-stylo.list
@@ -10,18 +10,18 @@ HTTP(..) == aspect-ratio-3b.xhtml aspect
 == encoded-aspect-ratio-1.html encoded-aspect-ratio-1.html
 == basic-1.xhtml basic-1.xhtml
 == canvas-1a.xhtml canvas-1a.xhtml
 == canvas-1b.xhtml canvas-1b.xhtml
 == clipping-1a.html clipping-1a.html
 == empty-1a.html empty-1a.html
 == empty-1b.html empty-1b.html
 #these is skipped because we hang on the htmlparser tests when this is ran
-fails == object-aspect-ratio-1a.xhtml object-aspect-ratio-1a.xhtml
-fails == object-aspect-ratio-1b.xhtml object-aspect-ratio-1b.xhtml
+== object-aspect-ratio-1a.xhtml object-aspect-ratio-1a.xhtml
+== object-aspect-ratio-1b.xhtml object-aspect-ratio-1b.xhtml
 == offset-1.xhtml offset-1.xhtml
 random == object-aspect-ratio-2a.xhtml object-aspect-ratio-2a.xhtml
 random == object-aspect-ratio-2b.xhtml object-aspect-ratio-2b.xhtml
 skip-if(Android) fuzzy-if(winWidget,1,56000) fuzzy-if(cocoaWidget,1,56000) HTTP(..) == zoomed-1.xhtml zoomed-1.xhtml
 == poster-1.html poster-1.html
 == poster-2.html poster-2.html
 skip-if(Android) == poster-3.html poster-3.html
 skip-if(Android) == poster-4.html poster-4.html
--- a/layout/reftests/svg/svg-integration/reftest-stylo.list
+++ b/layout/reftests/svg/svg-integration/reftest-stylo.list
@@ -16,18 +16,18 @@ fails == clipPath-html-06.xhtml clipPath
 fails == clipPath-html-06-extref.xhtml clipPath-html-06-extref.xhtml
 == clipPath-html-07.xhtml clipPath-html-07.xhtml
 fails == clipPath-html-08.xhtml clipPath-html-08.xhtml
 fails == clipPath-html-zoomed-01.xhtml clipPath-html-zoomed-01.xhtml
 == clipPath-transformed-html-01.xhtml clipPath-transformed-html-01.xhtml
 == clipPath-transformed-html-02.xhtml clipPath-transformed-html-02.xhtml
 == conditions-outer-svg-01.xhtml conditions-outer-svg-01.xhtml
 == conditions-outer-svg-02.xhtml conditions-outer-svg-02.xhtml
-fails == dynamic-conditions-outer-svg-01.xhtml dynamic-conditions-outer-svg-01.xhtml
-fails == dynamic-conditions-outer-svg-02.xhtml dynamic-conditions-outer-svg-02.xhtml
+== dynamic-conditions-outer-svg-01.xhtml dynamic-conditions-outer-svg-01.xhtml
+== dynamic-conditions-outer-svg-02.xhtml dynamic-conditions-outer-svg-02.xhtml
 fails == dynamic-conditions-outer-svg-03.xhtml dynamic-conditions-outer-svg-03.xhtml
 == dynamic-conditions-outer-svg-04.xhtml dynamic-conditions-outer-svg-04.xhtml
 fails == filter-html-01.xhtml filter-html-01.xhtml
 fails == filter-html-01-extref.xhtml filter-html-01-extref.xhtml
 fails == filter-html-zoomed-01.xhtml filter-html-zoomed-01.xhtml
 fails == mask-html-01.xhtml mask-html-01.xhtml
 fails == mask-html-01-extref-01.xhtml mask-html-01-extref-01.xhtml
 random == mask-html-01-extref-02.xhtml mask-html-01-extref-02.xhtml
--- a/layout/reftests/webm-video/reftest-stylo.list
+++ b/layout/reftests/webm-video/reftest-stylo.list
@@ -9,18 +9,18 @@ HTTP(..) == aspect-ratio-3b.xhtml aspect
 == encoded-aspect-ratio-1.html encoded-aspect-ratio-1.html
 == basic-1.xhtml basic-1.xhtml
 == canvas-1a.xhtml canvas-1a.xhtml
 == canvas-1b.xhtml canvas-1b.xhtml
 == clipping-1a.html clipping-1a.html
 == empty-1a.html empty-1a.html
 == empty-1b.html empty-1b.html
 #these is skipped because we hang on the htmlparser tests when this is ran
-fails == object-aspect-ratio-1a.xhtml object-aspect-ratio-1a.xhtml
-fails == object-aspect-ratio-1b.xhtml object-aspect-ratio-1b.xhtml
+== object-aspect-ratio-1a.xhtml object-aspect-ratio-1a.xhtml
+== object-aspect-ratio-1b.xhtml object-aspect-ratio-1b.xhtml
 == offset-1.xhtml offset-1.xhtml
 random == object-aspect-ratio-2a.xhtml object-aspect-ratio-2a.xhtml
 random == object-aspect-ratio-2b.xhtml object-aspect-ratio-2b.xhtml
 skip-if(Android) fuzzy-if(winWidget,1,56000) fuzzy-if(cocoaWidget,1,56000) HTTP(..) == zoomed-1.xhtml zoomed-1.xhtml
 == poster-1.html poster-1.html
 == poster-2.html poster-2.html
 skip-if(Android) == poster-3.html poster-3.html
 skip-if(Android) == poster-4.html poster-4.html
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -130,17 +130,19 @@ SERVO_BINDING_FUNC(Servo_AnimationValue_
                    RawServoAnimationValueBorrowed value,
                    RefPtr<nsCSSValueSharedList>* list)
 SERVO_BINDING_FUNC(Servo_AnimationValue_DeepEqual, bool,
                    RawServoAnimationValueBorrowed,
                    RawServoAnimationValueBorrowed)
 
 // Style attribute
 SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, RawServoDeclarationBlockStrong,
-                   const nsACString* data)
+                   const nsACString* data,
+                   const nsACString* base,
+                   const GeckoParserExtraData* extraData)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_CreateEmpty,
                    RawServoDeclarationBlockStrong)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_Clone, RawServoDeclarationBlockStrong,
                    RawServoDeclarationBlockBorrowed declarations)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_Equals, bool,
                    RawServoDeclarationBlockBorrowed a,
                    RawServoDeclarationBlockBorrowed b)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetCssText, void,
--- a/layout/style/ServoDeclarationBlock.cpp
+++ b/layout/style/ServoDeclarationBlock.cpp
@@ -7,21 +7,25 @@
 
 #include "mozilla/ServoBindings.h"
 
 #include "nsCSSProps.h"
 
 namespace mozilla {
 
 /* static */ already_AddRefed<ServoDeclarationBlock>
-ServoDeclarationBlock::FromCssText(const nsAString& aCssText)
+ServoDeclarationBlock::FromCssText(const nsAString& aCssText,
+                                   const GeckoParserExtraData& aExtraData)
 {
   NS_ConvertUTF16toUTF8 value(aCssText);
+  nsCString baseString;
+  // FIXME (bug 1343964): Figure out a better solution for sending the base uri to servo
+  aExtraData.mBaseURI->get()->GetSpec(baseString);
   RefPtr<RawServoDeclarationBlock>
-    raw = Servo_ParseStyleAttribute(&value).Consume();
+    raw = Servo_ParseStyleAttribute(&value, &baseString, &aExtraData).Consume();
   RefPtr<ServoDeclarationBlock> decl = new ServoDeclarationBlock(raw.forget());
   return decl.forget();
 }
 
 void
 ServoDeclarationBlock::GetPropertyValue(const nsAString& aProperty,
                                         nsAString& aValue) const
 {
--- a/layout/style/ServoDeclarationBlock.h
+++ b/layout/style/ServoDeclarationBlock.h
@@ -23,17 +23,18 @@ public:
 
   ServoDeclarationBlock(const ServoDeclarationBlock& aCopy)
     : DeclarationBlock(aCopy)
     , mRaw(Servo_DeclarationBlock_Clone(aCopy.mRaw).Consume()) {}
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ServoDeclarationBlock)
 
   static already_AddRefed<ServoDeclarationBlock>
-  FromCssText(const nsAString& aCssText);
+  FromCssText(const nsAString& aCssText,
+              const GeckoParserExtraData& aExtraData);
 
   RawServoDeclarationBlock* Raw() const { return mRaw; }
   RawServoDeclarationBlock* const* RefRaw() const {
     static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
                   sizeof(RawServoDeclarationBlock*),
                   "RefPtr should just be a pointer");
     return reinterpret_cast<RawServoDeclarationBlock* const*>(&mRaw);
   }
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -126,17 +126,18 @@ nsDOMCSSDeclaration::SetCssText(const ns
   // Attribute setting code, which leads in turn to BeginUpdate.  We
   // need to start the update now so that the old rule doesn't get used
   // between when we mutate the declaration and when we set the new
   // rule (see stack in bug 209575).
   mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
 
   RefPtr<DeclarationBlock> newdecl;
   if (olddecl->IsServo()) {
-    newdecl = ServoDeclarationBlock::FromCssText(aCssText);
+    GeckoParserExtraData data(env.mBaseURI, env.mSheetURI, env.mPrincipal);
+    newdecl = ServoDeclarationBlock::FromCssText(aCssText, data);
   } else {
     RefPtr<css::Declaration> decl(new css::Declaration());
     decl->InitializeEmpty();
     nsCSSParser cssParser(env.mCSSLoader);
     bool changed;
     nsresult result = cssParser.ParseDeclarations(aCssText, env.mSheetURI,
                                                   env.mBaseURI, env.mPrincipal,
                                                   decl, &changed);
--- a/layout/style/test/stylo-failures.md
+++ b/layout/style/test/stylo-failures.md
@@ -105,18 +105,17 @@ Any line which doesn't follow the format
   * test_transitions_step_functions.html [24]
   * test_value_storage.html `transition` [776]
 * test_bug798843_pref.html: conditional opentype svg support [7]
 * test_computed_style.html `gradient`: -moz-prefixed radient value [9]
 * url value in style attribute bug 1310886
   * test_computed_style.html `url` [12]
   * test_parse_url.html [4]
   * test_value_storage.html `url` [92]
-  * test_shorthand_property_getters.html `background shorthand` [1]
-  * ... `url` [3]
+  * test_shorthand_property_getters.html `url` [3]
 * test_computed_style.html `mask`: setting mask shorthand resets subproperties to non-initial value bug 1331516 [11]
 * auto value for min-{width,height} servo/servo#15045
 * test_compute_data_with_start_struct.html `timing-function`: incorrectly computing keywords to bezier function servo/servo#15086 [2]
 * test_condition_text.html: @-moz-document, CSSOM support of @media, @support [2]
 * @counter-style support:
   * test_counter_descriptor_storage.html [1]
   * test_counter_style.html [1]
   * test_rule_insertion.html `@counter-style` [4]