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
+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
--- /dev/null
+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
+
--- /dev/null
+<!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>
+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
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);
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();