REGRESSION(r145788): mouse drag on canvas shouldn't start selection
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jun 2013 03:52:46 +0000 (03:52 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jun 2013 03:52:46 +0000 (03:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117860

Reviewed by Benjamin Poulain.

Source/WebCore:

Like HTMLImageElement, HTMLCanvasElement shouldn't start selection.

Also uninline some virtual function overrides.

Test: fast/events/mosuedrag-on-canvas-should-not-start-selection.html

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::areAuthorShadowsAllowed):
(WebCore::HTMLCanvasElement::canContainRangeEndPoint):
(WebCore::HTMLCanvasElement::canStartSelection):
* html/HTMLCanvasElement.h:

LayoutTests:

Add a regression test for dragging mouse inside a canvas.
The canvas should not be selected and mouseup event should fire.

* fast/events/mosuedrag-on-canvas-should-not-start-selection-expected.txt: Added.
* fast/events/mosuedrag-on-canvas-should-not-start-selection.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@151822 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/mosuedrag-on-canvas-should-not-start-selection-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/mosuedrag-on-canvas-should-not-start-selection.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLCanvasElement.h

index 89a31d4..def32fa 100644 (file)
@@ -1,5 +1,18 @@
 2013-06-20  Ryosuke Niwa  <rniwa@webkit.org>
 
+        REGRESSION(r145788): mouse drag on canvas shouldn't start selection
+        https://bugs.webkit.org/show_bug.cgi?id=117860
+
+        Reviewed by Benjamin Poulain.
+
+        Add a regression test for dragging mouse inside a canvas.
+        The canvas should not be selected and mouseup event should fire.
+
+        * fast/events/mosuedrag-on-canvas-should-not-start-selection-expected.txt: Added.
+        * fast/events/mosuedrag-on-canvas-should-not-start-selection.html: Added.
+
+2013-06-20  Ryosuke Niwa  <rniwa@webkit.org>
+
         REGRESSION(r149652): accessing items in .children via id doesn't work when element is not rooted in DOM tree
         https://bugs.webkit.org/show_bug.cgi?id=117836
 
diff --git a/LayoutTests/fast/events/mosuedrag-on-canvas-should-not-start-selection-expected.txt b/LayoutTests/fast/events/mosuedrag-on-canvas-should-not-start-selection-expected.txt
new file mode 100644 (file)
index 0000000..d26eb06
--- /dev/null
@@ -0,0 +1,10 @@
+This tests initiating a mouse drag on a canvas element doesn't start selection. To manually test, drag mouse on the canvas below. WebKit shouldn't select the canvas.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+getSelection().removeAllRanges(); mouseDown = false; mouseUp = false
+PASS eventSender.mouseMoveTo(canvas.offsetLeft + 10, canvas.offsetTop + 10); eventSender.mouseDown(); mouseDown is true
+PASS eventSender.mouseMoveTo(canvas.offsetLeft + 100, canvas.offsetTop + 100); eventSender.mouseUp(); mouseUp is true
+PASS getSelection().isCollapsed is true
+
diff --git a/LayoutTests/fast/events/mosuedrag-on-canvas-should-not-start-selection.html b/LayoutTests/fast/events/mosuedrag-on-canvas-should-not-start-selection.html
new file mode 100644 (file)
index 0000000..2e6714d
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="editor" contenteditable>
+<canvas width="100" height="100" style="border: 1px solid black" onmousedown="mouseDown=true;" onmouseup="mouseUp=true;"></canvas>
+</div>
+<script src="../js/resources/js-test-pre.js"></script>
+<script>
+
+description("This tests initiating a mouse drag on a canvas element doesn't start selection."
+    + " To manually test, drag mouse on the canvas below. WebKit shouldn't select the canvas.")
+
+if (window.eventSender) {
+    var canvas = document.querySelector('canvas');
+
+    evalAndLog('getSelection().removeAllRanges(); mouseDown = false; mouseUp = false');
+    shouldBeTrue("eventSender.mouseMoveTo(canvas.offsetLeft + 10, canvas.offsetTop + 10); eventSender.mouseDown(); mouseDown");
+    eventSender.leapForward(200);
+    shouldBeTrue("eventSender.mouseMoveTo(canvas.offsetLeft + 100, canvas.offsetTop + 100); eventSender.mouseUp(); mouseUp");
+    shouldBeTrue("getSelection().isCollapsed");
+}
+
+</script>
+</body>
+</html>
index f4f7931..5f2f0d2 100644 (file)
@@ -1,5 +1,24 @@
 2013-06-20  Ryosuke Niwa  <rniwa@webkit.org>
 
+        REGRESSION(r145788): mouse drag on canvas shouldn't start selection
+        https://bugs.webkit.org/show_bug.cgi?id=117860
+
+        Reviewed by Benjamin Poulain.
+
+        Like HTMLImageElement, HTMLCanvasElement shouldn't start selection.
+
+        Also uninline some virtual function overrides.
+
+        Test: fast/events/mosuedrag-on-canvas-should-not-start-selection.html
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::areAuthorShadowsAllowed):
+        (WebCore::HTMLCanvasElement::canContainRangeEndPoint):
+        (WebCore::HTMLCanvasElement::canStartSelection):
+        * html/HTMLCanvasElement.h:
+
+2013-06-20  Ryosuke Niwa  <rniwa@webkit.org>
+
         REGRESSION(r149652): accessing items in .children via id doesn't work when element is not rooted in DOM tree
         https://bugs.webkit.org/show_bug.cgi?id=117836
 
index 16fef40..43ee773 100644 (file)
@@ -127,6 +127,21 @@ void HTMLCanvasElement::attach(const AttachContext& context)
     HTMLElement::attach(context);
 }
 
+bool HTMLCanvasElement::areAuthorShadowsAllowed() const
+{
+    return false;
+}
+
+bool HTMLCanvasElement::canContainRangeEndPoint() const
+{
+    return false;
+}
+
+bool HTMLCanvasElement::canStartSelection() const
+{
+    return false;
+}
+
 void HTMLCanvasElement::addObserver(CanvasObserver* observer)
 {
     m_observers.add(observer);
index e607567..60ea0cd 100644 (file)
@@ -142,15 +142,16 @@ public:
 
     float deviceScaleFactor() const { return m_deviceScaleFactor; }
 
-    virtual bool canContainRangeEndPoint() const { return false; }
-
 private:
     HTMLCanvasElement(const QualifiedName&, Document*);
 
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
-    virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
+    virtual bool areAuthorShadowsAllowed() const OVERRIDE;
+
+    virtual bool canContainRangeEndPoint() const OVERRIDE;
+    virtual bool canStartSelection() const OVERRIDE;
 
     void reset();