Title: [235749] trunk/Source
Revision
235749
Author
[email protected]
Date
2018-09-06 12:48:08 -0700 (Thu, 06 Sep 2018)

Log Message

Group options of scrollRectToVisible into a struct
https://bugs.webkit.org/show_bug.cgi?id=189352

Patch by Frederic Wang <[email protected]> on 2018-09-06
Reviewed by Simon Fraser.

Source/WebCore:

RenderLayer::scrollRectToVisible and RenderObject::scrollRectToVisible have several
parameters to configure the type of scrolling. This patch groups the const options into a
single struct to make easier to handle them in the future. For example, an #ifdefed scroll
behavior option will be added in bug 188043. This refactoring can maybe help too for other
scroll extensions (e.g. bug 176454 and bug 161611).

No new tests, behavior unchanged.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::scrollToMakeVisible const): Pass options via a struct.
* dom/Element.cpp:
(WebCore::Element::scrollIntoView): Ditto.
(WebCore::Element::scrollIntoViewIfNeeded): Ditto.
(WebCore::Element::scrollIntoViewIfNotVisible): Ditto.
* editing/FrameSelection.cpp: Include RenderLayer.h in all WebKit ports in order to define
ScrollRectToVisibleOptions.
(WebCore::FrameSelection::revealSelection): Pass options via a struct.
* page/FrameView.cpp:
(WebCore::FrameView::scrollToFocusedElementInternal): Ditto.
(WebCore::FrameView::scrollToAnchor): Ditto.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible): Pass options via a struct. Note that
absoluteRect and insideFixed are modified in this function.
(WebCore::RenderLayer::autoscroll): Pass options via a struct.
* rendering/RenderLayer.h: Add ScrollRectToVisibleOptions and use it in order to pass
scrollRectToVisible options.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::scrollRectToVisible): Pass options via a struct
* rendering/RenderObject.h: Forward-declare ScrollRectToVisibleOptions and use in order to
pass scrollRectToVisible options.

Source/WebKitLegacy/mac:

* WebView/WebFrame.mm: Add header to use ScrollRectToVisibleOptions.
(-[WebFrame _scrollDOMRangeToVisible:]): Pass options via a struct.
(-[WebFrame _scrollDOMRangeToVisible:withInset:]): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235748 => 235749)


--- trunk/Source/WebCore/ChangeLog	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/ChangeLog	2018-09-06 19:48:08 UTC (rev 235749)
@@ -1,3 +1,41 @@
+2018-09-06  Frederic Wang  <[email protected]>
+
+        Group options of scrollRectToVisible into a struct
+        https://bugs.webkit.org/show_bug.cgi?id=189352
+
+        Reviewed by Simon Fraser.
+
+        RenderLayer::scrollRectToVisible and RenderObject::scrollRectToVisible have several
+        parameters to configure the type of scrolling. This patch groups the const options into a
+        single struct to make easier to handle them in the future. For example, an #ifdefed scroll
+        behavior option will be added in bug 188043. This refactoring can maybe help too for other
+        scroll extensions (e.g. bug 176454 and bug 161611).
+
+        No new tests, behavior unchanged.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::scrollToMakeVisible const): Pass options via a struct.
+        * dom/Element.cpp:
+        (WebCore::Element::scrollIntoView): Ditto.
+        (WebCore::Element::scrollIntoViewIfNeeded): Ditto.
+        (WebCore::Element::scrollIntoViewIfNotVisible): Ditto.
+        * editing/FrameSelection.cpp: Include RenderLayer.h in all WebKit ports in order to define
+        ScrollRectToVisibleOptions.
+        (WebCore::FrameSelection::revealSelection): Pass options via a struct.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollToFocusedElementInternal): Ditto.
+        (WebCore::FrameView::scrollToAnchor): Ditto.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollRectToVisible): Pass options via a struct. Note that
+        absoluteRect and insideFixed are modified in this function.
+        (WebCore::RenderLayer::autoscroll): Pass options via a struct.
+        * rendering/RenderLayer.h: Add ScrollRectToVisibleOptions and use it in order to pass
+        scrollRectToVisible options.
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::scrollRectToVisible): Pass options via a struct
+        * rendering/RenderObject.h: Forward-declare ScrollRectToVisibleOptions and use in order to
+        pass scrollRectToVisible options.
+
 2018-09-06  Wenson Hsieh  <[email protected]>
 
         [macOS] Cannot change font size at selection until font panel is shown

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (235748 => 235749)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2018-09-06 19:48:08 UTC (rev 235749)
@@ -2992,7 +2992,7 @@
         parentObject()->scrollToMakeVisible();
 
     if (auto* renderer = this->renderer())
-        renderer->scrollRectToVisible(SelectionRevealMode::Reveal, boundingBoxRect(), false, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::Yes);
+        renderer->scrollRectToVisible(boundingBoxRect(), false, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::Yes });
 }
 
 void AccessibilityObject::scrollToMakeVisibleWithSubFocus(const IntRect& subfocus) const

Modified: trunk/Source/WebCore/dom/Element.cpp (235748 => 235749)


--- trunk/Source/WebCore/dom/Element.cpp	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/dom/Element.cpp	2018-09-06 19:48:08 UTC (rev 235749)
@@ -692,7 +692,7 @@
 
     ScrollAlignment alignX = toScrollAlignment(options.inlinePosition, false);
     ScrollAlignment alignY = toScrollAlignment(options.blockPosition, true);
-    renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, absoluteBounds, insideFixed, alignX, alignY, ShouldAllowCrossOriginScrolling::No);
+    renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, alignX, alignY, ShouldAllowCrossOriginScrolling::No });
 }
 
 void Element::scrollIntoView(bool alignToTop) 
@@ -706,9 +706,9 @@
     LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
     // Align to the top / bottom and to the closest edge.
     if (alignToTop)
-        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No);
+        renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No });
     else
-        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways, ShouldAllowCrossOriginScrolling::No);
+        renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways, ShouldAllowCrossOriginScrolling::No });
 }
 
 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
@@ -721,9 +721,9 @@
     bool insideFixed;
     LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
     if (centerIfNeeded)
-        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No);
+        renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No });
     else
-        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No);
+        renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No });
 }
 
 void Element::scrollIntoViewIfNotVisible(bool centerIfNotVisible)
@@ -736,9 +736,9 @@
     bool insideFixed;
     LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
     if (centerIfNotVisible)
-        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible, ShouldAllowCrossOriginScrolling::No);
+        renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible, ShouldAllowCrossOriginScrolling::No });
     else
-        renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible, ShouldAllowCrossOriginScrolling::No);
+        renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible, ShouldAllowCrossOriginScrolling::No });
 }
 
 void Element::scrollBy(const ScrollToOptions& options)

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (235748 => 235749)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2018-09-06 19:48:08 UTC (rev 235749)
@@ -53,6 +53,7 @@
 #include "HitTestResult.h"
 #include "InlineTextBox.h"
 #include "Page.h"
+#include "RenderLayer.h"
 #include "RenderText.h"
 #include "RenderTextControl.h"
 #include "RenderTheme.h"
@@ -71,7 +72,6 @@
 #include "Chrome.h"
 #include "ChromeClient.h"
 #include "Color.h"
-#include "RenderLayer.h"
 #include "RenderObject.h"
 #include "RenderStyle.h"
 #endif
@@ -2374,7 +2374,7 @@
         if (RenderLayer* layer = start.deprecatedNode()->renderer()->enclosingLayer()) {
             if (!m_scrollingSuppressCount) {
                 layer->setAdjustForIOSCaretWhenScrolling(true);
-                layer->scrollRectToVisible(revealMode, rect, insideFixed, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes);
+                layer->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes });
                 layer->setAdjustForIOSCaretWhenScrolling(false);
                 updateAppearance();
                 if (m_frame->page())
@@ -2385,7 +2385,7 @@
         // FIXME: This code only handles scrolling the startContainer's layer, but
         // the selection rect could intersect more than just that.
         // See <rdar://problem/4799899>.
-        if (start.deprecatedNode()->renderer()->scrollRectToVisible(revealMode, rect, insideFixed, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes))
+        if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes }))
             updateAppearance();
 #endif
     }

Modified: trunk/Source/WebCore/page/FrameView.cpp (235748 => 235749)


--- trunk/Source/WebCore/page/FrameView.cpp	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/page/FrameView.cpp	2018-09-06 19:48:08 UTC (rev 235749)
@@ -2336,7 +2336,7 @@
 
     bool insideFixed;
     LayoutRect absoluteBounds = renderer->absoluteAnchorRect(&insideFixed);
-    renderer->scrollRectToVisible(m_selectionRevealModeForFocusedElement, absoluteBounds, insideFixed, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No);
+    renderer->scrollRectToVisible(absoluteBounds, insideFixed, { m_selectionRevealModeForFocusedElement, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No });
 }
 
 void FrameView::contentsResized()
@@ -3110,11 +3110,11 @@
     // Scroll nested layers and frames to reveal the anchor.
     // Align to the top and to the closest side (this matches other browsers).
     if (anchorNode->renderer()->style().isHorizontalWritingMode())
-        anchorNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, rect, insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No);
+        anchorNode->renderer()->scrollRectToVisible(rect, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No });
     else if (anchorNode->renderer()->style().isFlippedBlocksWritingMode())
-        anchorNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, rect, insideFixed, ScrollAlignment::alignRightAlways, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No);
+        anchorNode->renderer()->scrollRectToVisible(rect, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignRightAlways, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No });
     else
-        anchorNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, rect, insideFixed, ScrollAlignment::alignLeftAlways, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No);
+        anchorNode->renderer()->scrollRectToVisible(rect, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignLeftAlways, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No });
 
     if (AXObjectCache* cache = frame().document()->existingAXObjectCache())
         cache->handleScrolledToAnchor(anchorNode.get());

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (235748 => 235749)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2018-09-06 19:48:08 UTC (rev 235749)
@@ -2502,7 +2502,7 @@
     return box->hasHorizontalOverflow() || box->hasVerticalOverflow();
 }
 
-void RenderLayer::scrollRectToVisible(SelectionRevealMode revealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling)
+void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions& options)
 {
     LOG_WITH_STREAM(Scrolling, stream << "Layer " << this << " scrollRectToVisible " << absoluteRect);
 
@@ -2523,7 +2523,7 @@
         ASSERT(box);
         LayoutRect localExposeRect(box->absoluteToLocalQuad(FloatQuad(FloatRect(absoluteRect))).boundingBox());
         LayoutRect layerBounds(0, 0, box->clientWidth(), box->clientHeight());
-        LayoutRect revealRect = getRectToExpose(layerBounds, localExposeRect, insideFixed, alignX, alignY);
+        LayoutRect revealRect = getRectToExpose(layerBounds, localExposeRect, insideFixed, options.alignX, options.alignY);
 
         ScrollOffset clampedScrollOffset = clampScrollOffset(scrollOffset() + toIntSize(roundedIntRect(revealRect).location()));
         if (clampedScrollOffset != scrollOffset()) {
@@ -2547,7 +2547,7 @@
                 ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
                 LayoutRect viewRect = frameView.visibleContentRect(LegacyIOSDocumentVisibleRect);
-                LayoutRect exposeRect = getRectToExpose(viewRect, absoluteRect, insideFixed, alignX, alignY);
+                LayoutRect exposeRect = getRectToExpose(viewRect, absoluteRect, insideFixed, options.alignX, options.alignY);
 
                 IntPoint scrollOffset(roundedIntPoint(exposeRect.location()));
                 // Adjust offsets if they're outside of the allowable range.
@@ -2554,7 +2554,7 @@
                 scrollOffset = scrollOffset.constrainedBetween(IntPoint(), IntPoint(frameView.contentsSize()));
                 frameView.setScrollPosition(scrollOffset);
 
-                if (shouldAllowCrossOriginScrolling == ShouldAllowCrossOriginScrolling::Yes || frameView.safeToPropagateScrollToParent()) {
+                if (options.shouldAllowCrossOriginScrolling == ShouldAllowCrossOriginScrolling::Yes || frameView.safeToPropagateScrollToParent()) {
                     parentLayer = ownerElement->renderer()->enclosingLayer();
                     // Convert the rect into the coordinate space of the parent frame's document.
                     newRect = frameView.contentsToContainingViewContents(enclosingIntRect(newRect));
@@ -2563,7 +2563,7 @@
                     parentLayer = nullptr;
             }
         } else {
-            if (revealMode == SelectionRevealMode::RevealUpToMainFrame && frameView.frame().isMainFrame())
+            if (options.revealMode == SelectionRevealMode::RevealUpToMainFrame && frameView.frame().isMainFrame())
                 return;
 
 #if !PLATFORM(IOS)
@@ -2575,7 +2575,7 @@
             LayoutRect targetRect = absoluteRect;
             targetRect.move(0, frameView.headerHeight());
 
-            LayoutRect revealRect = getRectToExpose(viewRect, targetRect, insideFixed, alignX, alignY);
+            LayoutRect revealRect = getRectToExpose(viewRect, targetRect, insideFixed, options.alignX, options.alignY);
             
             frameView.setScrollPosition(roundedIntPoint(revealRect.location()));
 
@@ -2589,7 +2589,7 @@
     }
     
     if (parentLayer)
-        parentLayer->scrollRectToVisible(revealMode, newRect, insideFixed, alignX, alignY, shouldAllowCrossOriginScrolling);
+        parentLayer->scrollRectToVisible(newRect, insideFixed, options);
 }
 
 void RenderLayer::updateCompositingLayersAfterScroll()
@@ -2712,7 +2712,7 @@
 void RenderLayer::autoscroll(const IntPoint& positionInWindow)
 {
     IntPoint currentDocumentPosition = renderer().view().frameView().windowToContents(positionInWindow);
-    scrollRectToVisible(SelectionRevealMode::Reveal, LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), false, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes);
+    scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), false, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes });
 }
 
 bool RenderLayer::canResize() const

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (235748 => 235749)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2018-09-06 19:48:08 UTC (rev 235749)
@@ -120,6 +120,13 @@
     Undetermined
 };
 
+struct ScrollRectToVisibleOptions {
+    SelectionRevealMode revealMode { SelectionRevealMode::Reveal };
+    const ScrollAlignment& alignX { ScrollAlignment::alignCenterIfNeeded };
+    const ScrollAlignment& alignY { ScrollAlignment::alignCenterIfNeeded };
+    ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling { ShouldAllowCrossOriginScrolling::No };
+};
+
 class RenderLayer final : public ScrollableArea {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -218,7 +225,7 @@
     void availableContentSizeChanged(AvailableSizeChangeReason) override;
 
     // "absoluteRect" is in scaled document coordinates.
-    void scrollRectToVisible(SelectionRevealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ShouldAllowCrossOriginScrolling);
+    void scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions&);
 
     bool scrollsOverflow() const;
     bool hasScrollbars() const { return m_hBar || m_vBar; }

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (235748 => 235749)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2018-09-06 19:48:08 UTC (rev 235749)
@@ -414,9 +414,9 @@
     return nullptr;
 }
 
-bool RenderObject::scrollRectToVisible(SelectionRevealMode revealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling)
+bool RenderObject::scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions& options)
 {
-    if (revealMode == SelectionRevealMode::DoNotReveal)
+    if (options.revealMode == SelectionRevealMode::DoNotReveal)
         return false;
 
     RenderLayer* enclosingLayer = this->enclosingLayer();
@@ -423,7 +423,7 @@
     if (!enclosingLayer)
         return false;
 
-    enclosingLayer->scrollRectToVisible(revealMode, absoluteRect, insideFixed, alignX, alignY, shouldAllowCrossOriginScrolling);
+    enclosingLayer->scrollRectToVisible(absoluteRect, insideFixed, options);
     return true;
 }
 

Modified: trunk/Source/WebCore/rendering/RenderObject.h (235748 => 235749)


--- trunk/Source/WebCore/rendering/RenderObject.h	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2018-09-06 19:48:08 UTC (rev 235749)
@@ -83,6 +83,8 @@
 
 enum class ShouldAllowCrossOriginScrolling { No, Yes };
 
+struct ScrollRectToVisibleOptions;
+
 #if ENABLE(DASHBOARD_SUPPORT)
 struct AnnotatedRegionValue {
     bool operator==(const AnnotatedRegionValue& o) const
@@ -158,7 +160,7 @@
     WEBCORE_EXPORT RenderLayer* enclosingLayer() const;
 
     // Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s).
-    WEBCORE_EXPORT bool scrollRectToVisible(SelectionRevealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling = ShouldAllowCrossOriginScrolling::No);
+    WEBCORE_EXPORT bool scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions&);
 
     // Convenience function for getting to the nearest enclosing box of a RenderObject.
     WEBCORE_EXPORT RenderBox& enclosingBox() const;

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (235748 => 235749)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-09-06 19:48:08 UTC (rev 235749)
@@ -1,3 +1,14 @@
+2018-09-06  Frederic Wang  <[email protected]>
+
+        Group options of scrollRectToVisible into a struct
+        https://bugs.webkit.org/show_bug.cgi?id=189352
+
+        Reviewed by Simon Fraser.
+
+        * WebView/WebFrame.mm: Add header to use ScrollRectToVisibleOptions.
+        (-[WebFrame _scrollDOMRangeToVisible:]): Pass options via a struct.
+        (-[WebFrame _scrollDOMRangeToVisible:withInset:]): Ditto.
+
 2018-09-06  Wenson Hsieh  <[email protected]>
 
         [macOS] Cannot change font size at selection until font panel is shown

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm (235748 => 235749)


--- trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm	2018-09-06 19:46:38 UTC (rev 235748)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm	2018-09-06 19:48:08 UTC (rev 235749)
@@ -89,6 +89,7 @@
 #import <WebCore/PlatformEventFactoryMac.h>
 #import <WebCore/PluginData.h>
 #import <WebCore/PrintContext.h>
+#import <WebCore/RenderLayer.h>
 #import <WebCore/RenderView.h>
 #import <WebCore/RenderWidget.h>
 #import <WebCore/RenderedDocumentMarker.h>
@@ -741,12 +742,12 @@
         
     if (startNode && startNode->renderer()) {
 #if !PLATFORM(IOS)
-        startNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes);
+        startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes });
 #else
         RenderLayer* layer = startNode->renderer()->enclosingLayer();
         if (layer) {
             layer->setAdjustForIOSCaretWhenScrolling(true);
-            startNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes);
+            startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes });
             layer->setAdjustForIOSCaretWhenScrolling(false);
             _private->coreFrame->selection().setCaretRectNeedsUpdate();
             _private->coreFrame->selection().updateAppearance();
@@ -766,7 +767,7 @@
         RenderLayer* layer = startNode->renderer()->enclosingLayer();
         if (layer) {
             layer->setAdjustForIOSCaretWhenScrolling(true);
-            startNode->renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes);
+            startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes});
             layer->setAdjustForIOSCaretWhenScrolling(false);
 
             Frame *coreFrame = core(self);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to