Title: [125397] trunk
Revision
125397
Author
[email protected]
Date
2012-08-13 01:22:24 -0700 (Mon, 13 Aug 2012)

Log Message

Cannot select the AuthorShadowDOM inner element of an img element
https://bugs.webkit.org/show_bug.cgi?id=91591

Reviewed by Dimitri Glazkov.

Source/WebCore:

Since HTMLImageElement::canStartSelection always returns false, we cannot start selection
from any children (including shadow dom) of an img element. When the img element has a shadow dom,
we should be able to start selection.

Test: fast/dom/shadow/select-image-with-shadow.html

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::canStartSelection):
(WebCore):
* html/HTMLImageElement.h:
(HTMLImageElement):
* html/shadow/ImageInnerElement.h:
(WebCore::ImageInnerElement::canStartSelection): Since ImageInnerElement is really an image,
this should return always false to obey the exising behavior.
(ImageInnerElement):

LayoutTests:

* fast/dom/shadow/select-image-with-shadow-expected.txt: Added.
* fast/dom/shadow/select-image-with-shadow.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125396 => 125397)


--- trunk/LayoutTests/ChangeLog	2012-08-13 08:11:43 UTC (rev 125396)
+++ trunk/LayoutTests/ChangeLog	2012-08-13 08:22:24 UTC (rev 125397)
@@ -1,3 +1,13 @@
+2012-08-13  Shinya Kawanaka  <[email protected]>
+
+        Cannot select the AuthorShadowDOM inner element of an img element
+        https://bugs.webkit.org/show_bug.cgi?id=91591
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/select-image-with-shadow-expected.txt: Added.
+        * fast/dom/shadow/select-image-with-shadow.html: Added.
+
 2012-08-13  Yuta Kitamura  <[email protected]>
 
         [Chromium] Unreviewed gardening. Add expectations for flaky tests.

Added: trunk/LayoutTests/fast/dom/shadow/select-image-with-shadow-expected.txt (0 => 125397)


--- trunk/LayoutTests/fast/dom/shadow/select-image-with-shadow-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/select-image-with-shadow-expected.txt	2012-08-13 08:22:24 UTC (rev 125397)
@@ -0,0 +1,5 @@
+PASS selectedString is "KotoriPiyo"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/shadow/select-image-with-shadow.html (0 => 125397)


--- trunk/LayoutTests/fast/dom/shadow/select-image-with-shadow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/select-image-with-shadow.html	2012-08-13 08:22:24 UTC (rev 125397)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+<img id="host" src=""
+
+<script>
+var shadowRoot = new WebKitShadowRoot(host);
+shadowRoot.innerHTML = "<span id='span1'>Kotori</span><shadow></shadow><span id='span2'>Piyo</span>";
+
+var span1 = shadowRoot.getElementById('span1');
+var span2 = shadowRoot.getElementById('span2');
+if (window.eventSender) {
+    eventSender.mouseMoveTo(span1.offsetLeft + 1, span1.offsetTop + span1.offsetHeight / 2);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(span2.offsetLeft + span2.offsetWidth - 1, span2.offsetTop + span2.offsetHeight / 2);
+    eventSender.mouseUp();
+
+    var selectedString = shadowRoot.getSelection().toString();
+    shouldBe('selectedString', '"KotoriPiyo"');
+}
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (125396 => 125397)


--- trunk/Source/WebCore/ChangeLog	2012-08-13 08:11:43 UTC (rev 125396)
+++ trunk/Source/WebCore/ChangeLog	2012-08-13 08:22:24 UTC (rev 125397)
@@ -1,3 +1,26 @@
+2012-08-13  Shinya Kawanaka  <[email protected]>
+
+        Cannot select the AuthorShadowDOM inner element of an img element
+        https://bugs.webkit.org/show_bug.cgi?id=91591
+
+        Reviewed by Dimitri Glazkov.
+
+        Since HTMLImageElement::canStartSelection always returns false, we cannot start selection
+        from any children (including shadow dom) of an img element. When the img element has a shadow dom,
+        we should be able to start selection.
+
+        Test: fast/dom/shadow/select-image-with-shadow.html
+
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::canStartSelection):
+        (WebCore):
+        * html/HTMLImageElement.h:
+        (HTMLImageElement):
+        * html/shadow/ImageInnerElement.h:
+        (WebCore::ImageInnerElement::canStartSelection): Since ImageInnerElement is really an image,
+        this should return always false to obey the exising behavior.
+        (ImageInnerElement):
+
 2012-08-13  Peter Wang  <[email protected]>
 
         REGRESSION (r124723-r124741): 5 inspector/debugger tests failing on Apple Lion Debug WK1 (Tests)

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (125396 => 125397)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2012-08-13 08:11:43 UTC (rev 125396)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2012-08-13 08:22:24 UTC (rev 125397)
@@ -202,6 +202,14 @@
     return createRendererForImage(this, arena);
 }
 
+bool HTMLImageElement::canStartSelection() const
+{
+    if (shadow())
+        return HTMLElement::canStartSelection();
+
+    return false;
+}
+
 void HTMLImageElement::attach()
 {
     HTMLElement::attach();

Modified: trunk/Source/WebCore/html/HTMLImageElement.h (125396 => 125397)


--- trunk/Source/WebCore/html/HTMLImageElement.h	2012-08-13 08:11:43 UTC (rev 125396)
+++ trunk/Source/WebCore/html/HTMLImageElement.h	2012-08-13 08:22:24 UTC (rev 125397)
@@ -110,7 +110,7 @@
     virtual void attach();
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 
-    virtual bool canStartSelection() const { return false; }
+    virtual bool canStartSelection() const;
 
     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
 

Modified: trunk/Source/WebCore/html/shadow/ImageInnerElement.h (125396 => 125397)


--- trunk/Source/WebCore/html/shadow/ImageInnerElement.h	2012-08-13 08:11:43 UTC (rev 125396)
+++ trunk/Source/WebCore/html/shadow/ImageInnerElement.h	2012-08-13 08:22:24 UTC (rev 125397)
@@ -54,6 +54,8 @@
     virtual void attach() OVERRIDE;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE;
 
+    virtual bool canStartSelection() const { return false; }
+
     virtual const AtomicString& shadowPseudoId() const OVERRIDE;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to