Title: [284138] trunk
Revision
284138
Author
[email protected]
Date
2021-10-13 17:41:04 -0700 (Wed, 13 Oct 2021)

Log Message

Remove adjustForIOSCaretWhenScrolling() code
https://bugs.webkit.org/show_bug.cgi?id=230454

Reviewed by Simon Fraser.

Source/WebCore:

The "adjustForIOSCaretWhenScrolling" code attempted to over-scroll horizontally at the start
or end of an overflow scroll in order to make space for the caret to show. However, it was
wrong in various ways. It always did this, even for scrollers with no visible caret. It was
web-detectable that the scrollX for a scroller could end up as -2. And removing the code
doesn't result in obviously incorrect behavior.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::revealSelection):
* rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::scrollTo):
(WebCore::RenderLayerScrollableArea::updateScrollInfoAfterLayout):
* rendering/RenderLayerScrollableArea.h:

Source/WebKitLegacy/mac:

The "adjustForIOSCaretWhenScrolling" code attempted to over-scroll horizontally at the start
or end of an overflow scroll in order to make space for the caret to show. However, it was
wrong in various ways. It always did this, even for scrollers with no visible caret. It was
web-detectable that the scrollX for a scroller could end up as -2. And removing the code
doesn't result in obviously incorrect behavior.

* DOM/DOMHTML.mm:
(-[DOMHTMLElement setScrollXOffset:scrollYOffset:adjustForIOSCaret:]):
* WebView/WebFrame.mm:
(-[WebFrame _scrollDOMRangeToVisible:]):
(-[WebFrame _scrollDOMRangeToVisible:withInset:]):

LayoutTests:

Rebase tests with the unified code path.

* platform/ios-wk2/editing/input/caret-at-the-edge-of-input-expected.txt:
* platform/ios-wk2/fast/layers/scroll-rect-to-visible-expected.txt:
* platform/ios/fast/forms/input-text-scroll-left-on-blur-expected.txt:
* platform/ios/fast/forms/textfield-outline-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284137 => 284138)


--- trunk/LayoutTests/ChangeLog	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/LayoutTests/ChangeLog	2021-10-14 00:41:04 UTC (rev 284138)
@@ -1,3 +1,17 @@
+2021-10-13  Megan Gardner  <[email protected]>
+
+        Remove adjustForIOSCaretWhenScrolling() code
+        https://bugs.webkit.org/show_bug.cgi?id=230454
+
+        Reviewed by Simon Fraser.
+
+        Rebase tests with the unified code path.
+
+        * platform/ios-wk2/editing/input/caret-at-the-edge-of-input-expected.txt:
+        * platform/ios-wk2/fast/layers/scroll-rect-to-visible-expected.txt:
+        * platform/ios/fast/forms/input-text-scroll-left-on-blur-expected.txt:
+        * platform/ios/fast/forms/textfield-outline-expected.txt:
+
 2021-10-13  Ayumi Kojima  <[email protected]>
 
         [ Windows EWS ] js/dom & js/dfg- tests are a flaky crash.

Modified: trunk/LayoutTests/platform/ios/fast/forms/input-text-scroll-left-on-blur-expected.txt (284137 => 284138)


--- trunk/LayoutTests/platform/ios/fast/forms/input-text-scroll-left-on-blur-expected.txt	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/LayoutTests/platform/ios/fast/forms/input-text-scroll-left-on-blur-expected.txt	2021-10-14 00:41:04 UTC (rev 284138)
@@ -24,7 +24,7 @@
   RenderBlock {DIV} at (6,3) size 141x15
     RenderText {#text} at (-162,0) size 303x14
       text run at (-162,0) width 302: "this text field has a lot of text in it so that it needs to scrol"
-layer at (340,13) size 141x14 scrollX 164 scrollWidth 304
+layer at (340,13) size 141x14 scrollX 162 scrollWidth 304
   RenderBlock {DIV} at (6,3) size 143x15
     RenderText {#text} at (0,0) size 303x14
       text run at (0,0) width 303: "this text field has a lot of text in it so that it needs to scrol"

Modified: trunk/LayoutTests/platform/ios/fast/forms/textfield-outline-expected.txt (284137 => 284138)


--- trunk/LayoutTests/platform/ios/fast/forms/textfield-outline-expected.txt	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/LayoutTests/platform/ios/fast/forms/textfield-outline-expected.txt	2021-10-14 00:41:04 UTC (rev 284138)
@@ -8,7 +8,7 @@
       RenderBR {BR} at (562,0) size 1x19
       RenderTextControl {INPUT} at (2,22) size 265x37 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
       RenderText {#text} at (0,0) size 0x0
-layer at (21,35) size 243x25 scrollX 270 scrollWidth 511
+layer at (21,35) size 243x25 scrollX 268 scrollWidth 511
   RenderBlock {DIV} at (11,5) size 243x25
     RenderText {#text} at (0,0) size 509x25
       text run at (0,0) width 509: "This tests that typing doesn't cut holes in the focus outline"

Modified: trunk/LayoutTests/platform/ios-wk2/editing/input/caret-at-the-edge-of-input-expected.txt (284137 => 284138)


--- trunk/LayoutTests/platform/ios-wk2/editing/input/caret-at-the-edge-of-input-expected.txt	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/LayoutTests/platform/ios-wk2/editing/input/caret-at-the-edge-of-input-expected.txt	2021-10-14 00:41:04 UTC (rev 284138)
@@ -10,7 +10,7 @@
         RenderTextControl {INPUT} at (2,2) size 85x22 [bgcolor=#FFFFFF] [border: (1px solid #3C3C4399)]
         RenderText {#text} at (0,0) size 0x0
         RenderText {#text} at (0,0) size 0x0
-layer at (17,33) size 71x14 scrollX 134 scrollWidth 204
+layer at (17,33) size 71x14 scrollX 132 scrollWidth 204
   RenderBlock {DIV} at (6,3) size 73x15
     RenderText {#text} at (0,0) size 202x14
       text run at (0,0) width 202: "012345678901234567890123456789"

Modified: trunk/LayoutTests/platform/ios-wk2/fast/layers/scroll-rect-to-visible-expected.txt (284137 => 284138)


--- trunk/LayoutTests/platform/ios-wk2/fast/layers/scroll-rect-to-visible-expected.txt	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/LayoutTests/platform/ios-wk2/fast/layers/scroll-rect-to-visible-expected.txt	2021-10-14 00:41:04 UTC (rev 284138)
@@ -19,22 +19,22 @@
       RenderBlock {P} at (0,56) size 784x20
         RenderText {#text} at (0,0) size 465x19
           text run at (0,0) width 465: "The letter A should be fully visible in each one of the eight boxes below."
-layer at (28,104) size 150x50 clip at (28,104) size 150x35 scrollX 52 scrollWidth 200
+layer at (28,104) size 150x50 clip at (28,104) size 150x35 scrollX 50 scrollWidth 200
   RenderBlock {DIV} at (20,96) size 150x50
     RenderBlock {DIV} at (0,0) size 200x20
       RenderText {#text} at (188,0) size 12x19
         text run at (188,0) width 12: "A"
-layer at (28,174) size 160x50 clip at (38,174) size 150x35 scrollX 52 scrollWidth 200
+layer at (28,174) size 160x50 clip at (38,174) size 150x35 scrollX 50 scrollWidth 200
   RenderBlock {DIV} at (20,166) size 160x50 [border: none (10px solid #000000)]
     RenderBlock {DIV} at (10,0) size 200x20
       RenderText {#text} at (188,0) size 12x19
         text run at (188,0) width 12: "A"
-layer at (28,244) size 160x50 clip at (28,244) size 150x35 scrollX 52 scrollWidth 200
+layer at (28,244) size 160x50 clip at (28,244) size 150x35 scrollX 50 scrollWidth 200
   RenderBlock {DIV} at (20,236) size 160x50 [border: none (10px solid #000000) none]
     RenderBlock {DIV} at (0,0) size 200x20
       RenderText {#text} at (188,0) size 12x19
         text run at (188,0) width 12: "A"
-layer at (28,314) size 150x50 clip at (28,314) size 135x35 scrollX 67 scrollWidth 200
+layer at (28,314) size 150x50 clip at (28,314) size 135x35 scrollX 65 scrollWidth 200
   RenderBlock {DIV} at (20,306) size 150x50
     RenderBlock {DIV} at (0,0) size 200x20
       RenderText {#text} at (188,0) size 12x19

Modified: trunk/Source/WebCore/ChangeLog (284137 => 284138)


--- trunk/Source/WebCore/ChangeLog	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/Source/WebCore/ChangeLog	2021-10-14 00:41:04 UTC (rev 284138)
@@ -1,3 +1,23 @@
+2021-10-13  Megan Gardner  <[email protected]>
+
+        Remove adjustForIOSCaretWhenScrolling() code
+        https://bugs.webkit.org/show_bug.cgi?id=230454
+
+        Reviewed by Simon Fraser.
+
+        The "adjustForIOSCaretWhenScrolling" code attempted to over-scroll horizontally at the start
+        or end of an overflow scroll in order to make space for the caret to show. However, it was
+        wrong in various ways. It always did this, even for scrollers with no visible caret. It was
+        web-detectable that the scrollX for a scroller could end up as -2. And removing the code
+        doesn't result in obviously incorrect behavior.
+
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::revealSelection):
+        * rendering/RenderLayerScrollableArea.cpp:
+        (WebCore::RenderLayerScrollableArea::scrollTo):
+        (WebCore::RenderLayerScrollableArea::updateScrollInfoAfterLayout):
+        * rendering/RenderLayerScrollableArea.h:
+
 2021-10-13  Simon Fraser  <[email protected]>
 
         Use a ScrollAnimation for rubber-banding

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (284137 => 284138)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2021-10-14 00:41:04 UTC (rev 284138)
@@ -2439,10 +2439,7 @@
 #if PLATFORM(IOS_FAMILY)
         if (RenderLayer* layer = start.deprecatedNode()->renderer()->enclosingLayer()) {
             if (!m_scrollingSuppressCount) {
-                auto* scrollableArea = layer->ensureLayerScrollableArea();
-                scrollableArea->setAdjustForIOSCaretWhenScrolling(true);
                 layer->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes, scrollBehavior});
-                scrollableArea->setAdjustForIOSCaretWhenScrolling(false);
                 updateAppearance();
                 if (m_document->page())
                     m_document->page()->chrome().client().notifyRevealedSelectionByScrollingFrame(*m_document->frame());

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp (284137 => 284138)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-10-14 00:41:04 UTC (rev 284138)
@@ -313,23 +313,6 @@
         // Ensure that the dimensions will be computed if they need to be (for overflow:hidden blocks).
         if (m_scrollDimensionsDirty)
             computeScrollDimensions();
-#if PLATFORM(IOS_FAMILY)
-        if (adjustForIOSCaretWhenScrolling()) {
-            // FIXME: It's not clear what this code is trying to do. Behavior seems reasonable with it removed.
-            int maxOffset = scrollWidth() - roundToInt(box->clientWidth());
-            ScrollOffset newOffset = scrollOffsetFromPosition(newPosition);
-            int scrollXOffset = newOffset.x();
-            if (scrollXOffset > maxOffset - caretWidth) {
-                scrollXOffset += caretWidth;
-                if (scrollXOffset <= caretWidth)
-                    scrollXOffset = 0;
-            } else if (scrollXOffset < m_scrollPosition.x() - caretWidth)
-                scrollXOffset -= caretWidth;
-
-            newOffset.setX(scrollXOffset);
-            newPosition = scrollPositionFromOffset(newOffset);
-        }
-#endif
     }
 
     if (m_scrollPosition == newPosition && scrollAnimationStatus() == ScrollAnimationStatus::NotAnimating) {
@@ -1250,18 +1233,8 @@
         // Layout may cause us to be at an invalid scroll position. In this case we need
         // to pull our scroll offsets back to the max (or push them up to the min).
         ScrollOffset clampedScrollOffset = clampScrollOffset(scrollOffset());
-#if PLATFORM(IOS_FAMILY)
-        // FIXME: This looks wrong. The caret adjust mode should only be enabled on editing related entry points.
-        // This code was added to fix an issue where the text insertion point would always be drawn on the right edge
-        // of a text field whose content overflowed its bounds. See <rdar://problem/15579797> for more details.
-        setAdjustForIOSCaretWhenScrolling(true);
-#endif
         if (clampedScrollOffset != scrollOffset())
             scrollToOffset(clampedScrollOffset);
-
-#if PLATFORM(IOS_FAMILY)
-        setAdjustForIOSCaretWhenScrolling(false);
-#endif
     }
 
     updateScrollbarsAfterLayout();

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h (284137 => 284138)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h	2021-10-14 00:41:04 UTC (rev 284138)
@@ -237,11 +237,6 @@
 
     std::optional<LayoutRect> updateScrollPosition(const ScrollPositionChangeOptions&, const LayoutRect& revealRect, const LayoutRect& localExposeRect);
 
-#if PLATFORM(IOS_FAMILY)
-    bool adjustForIOSCaretWhenScrolling() const { return m_adjustForIOSCaretWhenScrolling; }
-    void setAdjustForIOSCaretWhenScrolling(bool adjustForIOSCaretWhenScrolling) { m_adjustForIOSCaretWhenScrolling = adjustForIOSCaretWhenScrolling; }
-#endif
-
 private:
     bool hasHorizontalOverflow() const;
     bool hasVerticalOverflow() const;
@@ -274,12 +269,9 @@
     bool m_registeredScrollableArea { false };
     bool m_hasCompositedScrollableOverflow { false };
 
-#if PLATFORM(IOS_FAMILY)
-#if ENABLE(IOS_TOUCH_EVENTS)
+#if PLATFORM(IOS_FAMILY) && ENABLE(IOS_TOUCH_EVENTS)
     bool m_registeredAsTouchEventListenerForScrolling { false };
 #endif
-    bool m_adjustForIOSCaretWhenScrolling { false };
-#endif
     bool m_requiresScrollPositionReconciliation { false };
     bool m_containsDirtyOverlayScrollbars { false };
     bool m_updatingMarqueePosition { false };

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (284137 => 284138)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-10-14 00:41:04 UTC (rev 284138)
@@ -1,3 +1,22 @@
+2021-10-13  Megan Gardner  <[email protected]>
+
+        Remove adjustForIOSCaretWhenScrolling() code
+        https://bugs.webkit.org/show_bug.cgi?id=230454
+
+        Reviewed by Simon Fraser.
+
+        The "adjustForIOSCaretWhenScrolling" code attempted to over-scroll horizontally at the start
+        or end of an overflow scroll in order to make space for the caret to show. However, it was
+        wrong in various ways. It always did this, even for scrollers with no visible caret. It was
+        web-detectable that the scrollX for a scroller could end up as -2. And removing the code
+        doesn't result in obviously incorrect behavior.
+
+        * DOM/DOMHTML.mm:
+        (-[DOMHTMLElement setScrollXOffset:scrollYOffset:adjustForIOSCaret:]):
+        * WebView/WebFrame.mm:
+        (-[WebFrame _scrollDOMRangeToVisible:]):
+        (-[WebFrame _scrollDOMRangeToVisible:withInset:]):
+
 2021-10-13  Alex Christensen  <[email protected]>
 
         Remove WTF::Variant and WTF::get

Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMHTML.mm (284137 => 284138)


--- trunk/Source/WebKitLegacy/mac/DOM/DOMHTML.mm	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMHTML.mm	2021-10-14 00:41:04 UTC (rev 284138)
@@ -130,14 +130,9 @@
         return;
     auto* scrollableArea = layer->ensureLayerScrollableArea();
 
-    if (adjustForIOSCaret)
-        scrollableArea->setAdjustForIOSCaretWhenScrolling(true);
-
     auto scrollPositionChangeOptions = WebCore::ScrollPositionChangeOptions::createProgrammatic();
     scrollPositionChangeOptions.clamping = WebCore::ScrollClamping::Unclamped;
     scrollableArea->scrollToOffset(WebCore::ScrollOffset(x, y), scrollPositionChangeOptions);
-    if (adjustForIOSCaret)
-        scrollableArea->setAdjustForIOSCaretWhenScrolling(false);
 }
 
 - (void)absolutePosition:(int *)x :(int *)y :(int *)w :(int *)h

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm (284137 => 284138)


--- trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm	2021-10-14 00:39:19 UTC (rev 284137)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm	2021-10-14 00:41:04 UTC (rev 284138)
@@ -731,10 +731,7 @@
 #else
         auto* layer = startNode->renderer()->enclosingLayer();
         if (layer) {
-            auto* scrollableArea = layer->ensureLayerScrollableArea();
-            scrollableArea->setAdjustForIOSCaretWhenScrolling(true);
             startNode->renderer()->scrollRectToVisible(WebCore::enclosingIntRect(rangeRect), insideFixed, { WebCore::SelectionRevealMode::Reveal, WebCore::ScrollAlignment::alignToEdgeIfNeeded, WebCore::ScrollAlignment::alignToEdgeIfNeeded, WebCore::ShouldAllowCrossOriginScrolling::Yes });
-            scrollableArea->setAdjustForIOSCaretWhenScrolling(false);
             _private->coreFrame->selection().setCaretRectNeedsUpdate();
             _private->coreFrame->selection().updateAppearance();
         }
@@ -752,10 +749,7 @@
     if (startNode && startNode->renderer()) {
         auto* layer = startNode->renderer()->enclosingLayer();
         if (layer) {
-            auto* scrollableArea = layer->ensureLayerScrollableArea();
-            scrollableArea->setAdjustForIOSCaretWhenScrolling(true);
             startNode->renderer()->scrollRectToVisible(WebCore::enclosingIntRect(rangeRect), insideFixed, { WebCore::SelectionRevealMode::Reveal, WebCore::ScrollAlignment::alignToEdgeIfNeeded, WebCore::ScrollAlignment::alignToEdgeIfNeeded, WebCore::ShouldAllowCrossOriginScrolling::Yes});
-            scrollableArea->setAdjustForIOSCaretWhenScrolling(false);
 
             auto coreFrame = core(self);
             if (coreFrame) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to