Caret's screen position does not update during an overflow scroll
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 May 2014 21:14:20 +0000 (21:14 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 May 2014 21:14:20 +0000 (21:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133256

Reviewed by Simon Fraser.

Source/WebCore:
During a scroll, we set a flag which caret position is gated on, but we never
actually invalidate the caret's position. This patch does so.

Test: editing/input/caret-position-during-scroll.html

* editing/FrameSelection.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo):

LayoutTests:
This test places the caret, inspects its position, scrolls, and then immediately inspects its
position again. The two positions should be different.

* editing/input/caret-position-during-scroll-expected.txt: Added.
* editing/input/caret-position-during-scroll.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/input/caret-position-during-scroll-expected.txt [new file with mode: 0644]
LayoutTests/editing/input/caret-position-during-scroll.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/FrameSelection.h
Source/WebCore/rendering/RenderLayer.cpp

index 966873f3456b5a103b7a7a1dcfaa34c4bb20491e..0495ee225a99b570486a8b99f99a52372a9e94e2 100644 (file)
@@ -1,3 +1,16 @@
+2014-05-23  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Caret's screen position does not update during an overflow scroll
+        https://bugs.webkit.org/show_bug.cgi?id=133256
+
+        Reviewed by Simon Fraser.
+
+        This test places the caret, inspects its position, scrolls, and then immediately inspects its
+        position again. The two positions should be different.
+
+        * editing/input/caret-position-during-scroll-expected.txt: Added.
+        * editing/input/caret-position-during-scroll.html: Added.
+
 2014-05-27  David Hyatt  <hyatt@apple.com>
 
         REGRESSION: Audio volume scrubber does not show volume level thumb
diff --git a/LayoutTests/editing/input/caret-position-during-scroll-expected.txt b/LayoutTests/editing/input/caret-position-during-scroll-expected.txt
new file mode 100644 (file)
index 0000000..4b1836f
--- /dev/null
@@ -0,0 +1,34 @@
+This test places the caret, inspects its position, scrolls, and immediately inspects the caret's position again. The two positions should be different. If this test passes, "Result: Pass" will be printed below the list of numbers.
+Scrolling with the mouse does not cause the caret's screen position to be recomputed
+00
+01
+02
+03
+04
+05
+06
+07
+08
+09
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+Result: PASS
diff --git a/LayoutTests/editing/input/caret-position-during-scroll.html b/LayoutTests/editing/input/caret-position-during-scroll.html
new file mode 100644 (file)
index 0000000..3c08d52
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<head>
+<script type="text/javascript" src="resources/reveal-utilities.js"></script>
+</head>
+<body>
+<div>This test places the caret, inspects its position, scrolls, and immediately inspects the caret's position again.
+The two positions should be different. If this test passes, "Result: Pass" will be printed below the list of numbers.</div>
+<div>Scrolling with the mouse does not cause the caret's screen position to be recomputed</div>
+<span style="position:absolute; visibility:hidden" id="single-digit">0</span>
+<div style="border:thin solid black; overflow:scroll" contenteditable="true" id="input-contenteditable"></div>
+Result: <span id="console"></div>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+var contentEditable = document.getElementById("input-contenteditable");
+contentEditable.innerHTML = generateNumbers(0, 30, 2, "<br>");
+var singleDigitHeight = document.getElementById("single-digit").clientHeight;
+var contentEditableSize = 10;
+contentEditable.style.height = (singleDigitHeight * contentEditableSize) + "px";
+contentEditable.focus();
+var child = contentEditable.firstChild;
+for (var i = 0; i < 36; ++i)
+    child = child.nextSibling;
+getSelection().collapse(child, 0);
+var before;
+if (window.internals)
+    before = internals.absoluteCaretBounds(document).top;
+if (window.eventSender) {
+    var input = document.getElementById('input-contenteditable');
+    var x = contentEditable.offsetLeft + contentEditable.offsetWidth / 2;
+    var y = contentEditable.offsetTop + contentEditable.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseScrollBy(0, -50);
+}
+var after;
+if (window.internals)
+    after = internals.absoluteCaretBounds(document).top;
+var result = "FAIL";
+if (before != after)
+    result = "PASS";
+document.getElementById("console").textContent = result;
+</script>
+</body>
index ab34538912e9191153532597e68c21eab3ccbcdf..8c5efd487a66d9a78eb9a1e201217c6d924a7956 100644 (file)
@@ -1,3 +1,19 @@
+2014-05-23  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Caret's screen position does not update during an overflow scroll
+        https://bugs.webkit.org/show_bug.cgi?id=133256
+
+        Reviewed by Simon Fraser.
+
+        During a scroll, we set a flag which caret position is gated on, but we never
+        actually invalidate the caret's position. This patch does so.
+
+        Test: editing/input/caret-position-during-scroll.html
+
+        * editing/FrameSelection.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollTo):
+
 2014-05-27  Timothy Horton  <timothy_horton@apple.com>
 
         Turn on the LayerPool for iOS
index a44d5bdd68abf8cfe730b3cdd03be46cef6f766d..ed401493adcb2db1092f6dcdc8644204fe81fd69 100644 (file)
@@ -269,6 +269,8 @@ public:
     bool shouldShowBlockCursor() const { return m_shouldShowBlockCursor; }
     void setShouldShowBlockCursor(bool);
 
+    void invalidateCaretRect();
+
 private:
     enum EPositionType { START, END, BASE, EXTENT };
 
@@ -311,7 +313,6 @@ private:
 
     void setCaretVisibility(CaretVisibility);
     bool recomputeCaretRect();
-    void invalidateCaretRect();
 
     bool dispatchSelectStart();
 
index e140c278729ac03b647d15b1610d8c3cf269e39c..ecd079b5c4d7b208fec431c2592da32e122be310 100644 (file)
@@ -2294,7 +2294,7 @@ void RenderLayer::scrollTo(int x, int y)
     Frame& frame = renderer().frame();
     RenderLayerModelObject* repaintContainer = renderer().containerForRepaint();
     // The caret rect needs to be invalidated after scrolling
-    frame.selection().setCaretRectNeedsUpdate();
+    frame.selection().invalidateCaretRect();
 
     FloatQuad quadForFakeMouseMoveEvent = FloatQuad(m_repaintRect);
     if (repaintContainer)