Title: [181168] trunk
Revision
181168
Author
commit-qu...@webkit.org
Date
2015-03-06 10:44:33 -0800 (Fri, 06 Mar 2015)

Log Message

Setting any of the <object> element plugin controlling attributes does not have any affect.
https://bugs.webkit.org/show_bug.cgi?id=141936.

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2015-03-06
Reviewed by Simon Fraser.
Source/WebCore:

When setting any of the <object> element plugin controlling attributes
dynamically we need to mark the the element to be dirty by calling
setNeedsStyleRecalc(), so it has to recreate its renderer when needed.

Tests: fast/css/image-object-hover-inherit.html
       svg/as-object/svg-in-object-dynamic-attribute-change.html

* dom/Element.h: Delete unimplemented function.

* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::parseAttribute): Mark the element dirty by
calling setNeedsStyleRecalc() when one of the plugin controlling attributes
gets changed. We have to clear m_useFallbackContent because the attribute's
new value might fix the object rendering.

* html/HTMLObjectElement.h: Add a function to clear m_useFallbackContent.

LayoutTests:

* fast/css/image-object-hover-inherit-expected.html: Added.
* fast/css/image-object-hover-inherit.html: Added.
A guarding test to catch the case of reconstructing the image <object>
renderer while performing a synchronous resolveTree() followed by page
rendering or dump render tree.

* svg/as-object/resources/lime100x100.html: Added.
* svg/as-object/resources/lime100x100.png: Added.
* svg/as-object/resources/lime100x100.svg: Added.
* svg/as-object/resources/red100x100.svg: Added.
* svg/as-object/svg-in-object-dynamic-attribute-change-expected.html: Added.
* svg/as-object/svg-in-object-dynamic-attribute-change.html: Added.
Ensure that changing the 'type' and the 'data' attributes of the <object>
element will have the expected outcome. Also make sure that the <object>
element renderer falls back correctly when setting any of the attributes
to some unexpected value.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181167 => 181168)


--- trunk/LayoutTests/ChangeLog	2015-03-06 18:21:36 UTC (rev 181167)
+++ trunk/LayoutTests/ChangeLog	2015-03-06 18:44:33 UTC (rev 181168)
@@ -1,3 +1,27 @@
+2015-03-06  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        Setting any of the <object> element plugin controlling attributes does not have any affect.
+        https://bugs.webkit.org/show_bug.cgi?id=141936.
+
+        Reviewed by Simon Fraser.
+
+        * fast/css/image-object-hover-inherit-expected.html: Added.
+        * fast/css/image-object-hover-inherit.html: Added.
+        A guarding test to catch the case of reconstructing the image <object>
+        renderer while performing a synchronous resolveTree() followed by page
+        rendering or dump render tree.
+        
+        * svg/as-object/resources/lime100x100.html: Added.
+        * svg/as-object/resources/lime100x100.png: Added.
+        * svg/as-object/resources/lime100x100.svg: Added.
+        * svg/as-object/resources/red100x100.svg: Added.
+        * svg/as-object/svg-in-object-dynamic-attribute-change-expected.html: Added.
+        * svg/as-object/svg-in-object-dynamic-attribute-change.html: Added.
+        Ensure that changing the 'type' and the 'data' attributes of the <object>
+        element will have the expected outcome. Also make sure that the <object>
+        element renderer falls back correctly when setting any of the attributes
+        to some unexpected value.
+
 2015-03-06  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Test horiz-origin-x and horiz-origin-y in SVG fonts

Added: trunk/LayoutTests/fast/css/image-object-hover-inherit-expected.html (0 => 181168)


--- trunk/LayoutTests/fast/css/image-object-hover-inherit-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/image-object-hover-inherit-expected.html	2015-03-06 18:44:33 UTC (rev 181168)
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <style>
+    div {
+      width: 100px;
+      height: 100px;
+      background-color:lime;
+    }
+  </style>
+</head>
+<body>
+  <div></div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/image-object-hover-inherit.html (0 => 181168)


--- trunk/LayoutTests/fast/css/image-object-hover-inherit.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/image-object-hover-inherit.html	2015-03-06 18:44:33 UTC (rev 181168)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <style>
+    div {
+      width: 100px;
+      height: 100px;
+      background-color:red;
+    }
+    div:hover {
+      border-bottom-color: inherit;
+    }
+  </style>
+</head>
+<body>
+  <div>
+    <object id="image" data=""
+      iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
+      jwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABh0RVh0
+      U29mdHdhcmUAUGFpbnQuTkVUIHYzLjA4ZXKc4QAAAeNJREFUeF7t0sERgDAQw0DSf9FAqvA+lBRw
+      Gsnnef/fgwzcIH3HQDEwAxiOs9QVSUEwAxjOapfO3YJgBjAcZ6krkoJgBjCc1S6duwXBDGA4zlJX
+      JAXBDGA4q106dwuCGcBwnKWuSAqCGcBwVrt07hYEM4DhOEtdkRQEM4DhrHbp3C0IZgDDcZa6IikI
+      ZgDDWe3SuVsQzACG4yx1RVIQzACGs9qlc7cgmAEMx1nqiqQgmAEMZ7VL525BMAMYjrPUFUlBMAMY
+      zmqXzt2CYAYwHGepK5KCYAYwnNUunbsFwQxgOM5SVyQFwQxgOKtdOncLghnAcJylrkgKghnAcFa7
+      dO4WBDOA4ThLXZEUBDOA4ax26dwtCGYAw3GWuiIpCGYAw1nt0rlbEMwAhuMsdUVSEMwAhrPapXO3
+      IJgBDMdZ6oqkIJgBDGe1S+duQTADGI6z1BVJQTADGM5ql87dgmAGMBxnqSuSgmAGMJzVLp27BcEM
+      YDjOUlckBcEMYDirXTp3C4IZwHCcpa5ICoIZwHBWu3TuFgQzgOE4S12RFAQzgOGsduncLQhmAMNx
+      lroiKQhmAMNZ7dK5WxDMAIbjLHVFUhDMAIaz2qVztyCYAQzHWeqKpCCYAQxntUvnbkEwAxiOs9QR
+      yQemSBErQhZ+LAAAAABJRU5ErkJggg==">
+    </object>
+  </div>
+  <script>
+  window._onload_ = function() {
+    if (window.eventSender) {
+      image = document.getElementById('image');
+      window.eventSender.mouseMoveTo(image.offsetLeft + 10, image.offsetTop + 10);
+    }
+  }
+  </script>
+</body>
+</html>

Added: trunk/LayoutTests/svg/as-object/resources/lime100x100.html (0 => 181168)


--- trunk/LayoutTests/svg/as-object/resources/lime100x100.html	                        (rev 0)
+++ trunk/LayoutTests/svg/as-object/resources/lime100x100.html	2015-03-06 18:44:33 UTC (rev 181168)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style>
+    html, body {
+      margin: 0 0 0 0;
+      overflow:hidden;
+    }
+  </style>
+</head>
+<body>
+  <img src=""
+</body>
+</html>

Added: trunk/LayoutTests/svg/as-object/resources/lime100x100.png


(Binary files differ)
Property changes on: trunk/LayoutTests/svg/as-object/resources/lime100x100.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/svg/as-object/resources/lime100x100.svg (0 => 181168)


--- trunk/LayoutTests/svg/as-object/resources/lime100x100.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/as-object/resources/lime100x100.svg	2015-03-06 18:44:33 UTC (rev 181168)
@@ -0,0 +1,3 @@
+<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'>
+  <rect width='100%' height='100%' fill='lime'/>
+</svg>

Added: trunk/LayoutTests/svg/as-object/resources/red100x100.svg (0 => 181168)


--- trunk/LayoutTests/svg/as-object/resources/red100x100.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/as-object/resources/red100x100.svg	2015-03-06 18:44:33 UTC (rev 181168)
@@ -0,0 +1,3 @@
+<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'>
+  <rect width='100%' height='100%' fill='red'/>
+</svg>
\ No newline at end of file

Added: trunk/LayoutTests/svg/as-object/svg-in-object-dynamic-attribute-change-expected.html (0 => 181168)


--- trunk/LayoutTests/svg/as-object/svg-in-object-dynamic-attribute-change-expected.html	                        (rev 0)
+++ trunk/LayoutTests/svg/as-object/svg-in-object-dynamic-attribute-change-expected.html	2015-03-06 18:44:33 UTC (rev 181168)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style>
+    div {
+        width: 100px;
+        height: 100px;
+        background-color: lime;
+        display: inline-block;
+    }
+  </style>
+</head>
+<body>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+  <div></div>
+</body>
+</html>

Added: trunk/LayoutTests/svg/as-object/svg-in-object-dynamic-attribute-change.html (0 => 181168)


--- trunk/LayoutTests/svg/as-object/svg-in-object-dynamic-attribute-change.html	                        (rev 0)
+++ trunk/LayoutTests/svg/as-object/svg-in-object-dynamic-attribute-change.html	2015-03-06 18:44:33 UTC (rev 181168)
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+<body>
+  <object id="object1" data=""
+    <img src=""
+  </object>
+  <object id="object2" type="image/svg+xml" data=""
+    <img src=""
+  </object>
+  <object width="100px" height="100px" id="object3">
+    <img src=""
+  </object>
+  <object id="object4" type="dummy">
+    <img src=""
+  </object>
+  <object id="object5" type="dummy">
+    <img src=""
+  </object>
+  <object id="object6" type="image/svg+xml" data=""
+    <img src=""
+  </object>
+  <script>
+    function onObjectLoad() {
+      if (!window.testRunner)
+        return;
+        
+      if (typeof onObjectLoad.counter == 'undefined')
+        onObjectLoad.counter = 0;
+    
+      if (++onObjectLoad.counter == 4)
+        testRunner.notifyDone();
+    }
+ 
+    window.addEventListener("load", function() {
+      if (window.testRunner)
+        testRunner.waitUntilDone();
+
+      // change the 'type' attribute
+      var object1 = document.getElementById("object1");
+      object1.setAttribute("type", "image/svg+xml");
+
+      // change the 'data' attribute
+      var object2 = document.getElementById("object2");
+      object2._onload_ = onObjectLoad;
+      object2.setAttribute("data", "resources/lime100x100.svg");
+
+      // change the 'data' attribute
+      var object3 = document.getElementById("object3");
+      object3._onload_ = onObjectLoad;
+      object3.setAttribute("data", "resources/lime100x100.html");
+
+      // change the 'type' then the 'data' attributes of an image object
+      var object4 = document.getElementById("object4");
+      object4._onload_ = onObjectLoad;
+      object4.setAttribute("type", "image/png");
+      object4.setAttribute("data", "resources/lime100x100.png");
+
+      // change the 'data' then the 'type' attributes of an image object
+      var object5 = document.getElementById("object5");
+      object5._onload_ = onObjectLoad;
+      object5.setAttribute("data", "resources/lime100x100.png");
+      object5.setAttribute("type", "image/png");
+
+      // object rederer fallback
+      var object6 = document.getElementById("object6");
+      object6.setAttribute("type", "dummy");
+    });
+  </script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (181167 => 181168)


--- trunk/Source/WebCore/ChangeLog	2015-03-06 18:21:36 UTC (rev 181167)
+++ trunk/Source/WebCore/ChangeLog	2015-03-06 18:44:33 UTC (rev 181168)
@@ -1,3 +1,27 @@
+2015-03-06  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        Setting any of the <object> element plugin controlling attributes does not have any affect.
+        https://bugs.webkit.org/show_bug.cgi?id=141936.
+
+        Reviewed by Simon Fraser.
+        
+        When setting any of the <object> element plugin controlling attributes
+        dynamically we need to mark the the element to be dirty by calling
+        setNeedsStyleRecalc(), so it has to recreate its renderer when needed.
+
+        Tests: fast/css/image-object-hover-inherit.html
+               svg/as-object/svg-in-object-dynamic-attribute-change.html
+
+        * dom/Element.h: Delete unimplemented function.
+        
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::parseAttribute): Mark the element dirty by
+        calling setNeedsStyleRecalc() when one of the plugin controlling attributes
+        gets changed. We have to clear m_useFallbackContent because the attribute's
+        new value might fix the object rendering.
+        
+        * html/HTMLObjectElement.h: Add a function to clear m_useFallbackContent.
+
 2015-03-06  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Test horiz-origin-x and horiz-origin-y in SVG fonts

Modified: trunk/Source/WebCore/dom/Element.h (181167 => 181168)


--- trunk/Source/WebCore/dom/Element.h	2015-03-06 18:21:36 UTC (rev 181167)
+++ trunk/Source/WebCore/dom/Element.h	2015-03-06 18:44:33 UTC (rev 181168)
@@ -310,8 +310,6 @@
 
     virtual void copyNonAttributePropertiesFromElement(const Element&) { }
 
-    void lazyReattach();
-
     virtual RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&);
     virtual bool rendererIsNeeded(const RenderStyle&);
 

Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (181167 => 181168)


--- trunk/Source/WebCore/html/HTMLObjectElement.cpp	2015-03-06 18:21:36 UTC (rev 181167)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp	2015-03-06 18:44:33 UTC (rev 181168)
@@ -107,28 +107,37 @@
 
 void HTMLObjectElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
+    bool invalidateRenderer = false;
+
     if (name == formAttr)
         formAttributeChanged();
     else if (name == typeAttr) {
         m_serviceType = value.string().left(value.find(';')).lower();
+        invalidateRenderer = !fastHasAttribute(classidAttr);
         setNeedsWidgetUpdate(true);
     } else if (name == dataAttr) {
         m_url = stripLeadingAndTrailingHTMLSpaces(value);
-        setNeedsWidgetUpdate(true);
         document().updateStyleIfNeeded();
-        if (renderer()) {
-            if (isImageType()) {
-                if (!m_imageLoader)
-                    m_imageLoader = std::make_unique<HTMLImageLoader>(*this);
-                m_imageLoader->updateFromElementIgnoringPreviousError();
-            }
+        if (isImageType() && renderer()) {
+            if (!m_imageLoader)
+                m_imageLoader = std::make_unique<HTMLImageLoader>(*this);
+            m_imageLoader->updateFromElementIgnoringPreviousError();
         }
-    } else if (name == classidAttr)
+        invalidateRenderer = !fastHasAttribute(classidAttr);
         setNeedsWidgetUpdate(true);
-    else if (name == onbeforeloadAttr)
+    } else if (name == classidAttr) {
+        invalidateRenderer = true;
+        setNeedsWidgetUpdate(true);
+    } else if (name == onbeforeloadAttr)
         setAttributeEventListener(eventNames().beforeloadEvent, name, value);
     else
         HTMLPlugInImageElement::parseAttribute(name, value);
+
+    if (!invalidateRenderer || !inDocument() || !renderer())
+        return;
+
+    clearUseFallbackContent();
+    setNeedsStyleRecalc(ReconstructRenderTree);
 }
 
 static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramValues)

Modified: trunk/Source/WebCore/html/HTMLObjectElement.h (181167 => 181168)


--- trunk/Source/WebCore/html/HTMLObjectElement.h	2015-03-06 18:21:36 UTC (rev 181167)
+++ trunk/Source/WebCore/html/HTMLObjectElement.h	2015-03-06 18:44:33 UTC (rev 181168)
@@ -85,6 +85,7 @@
     
     bool shouldAllowQuickTimeClassIdQuirk();
     bool hasValidClassId();
+    void clearUseFallbackContent() { m_useFallbackContent = false; }
 
     virtual void refFormAssociatedElement() override { ref(); }
     virtual void derefFormAssociatedElement() override { deref(); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to