Changeset 235749 in webkit
- Timestamp:
- Sep 6, 2018 12:48:08 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r235748 r235749 1 2018-09-06 Frederic Wang <fwang@igalia.com> 2 3 Group options of scrollRectToVisible into a struct 4 https://bugs.webkit.org/show_bug.cgi?id=189352 5 6 Reviewed by Simon Fraser. 7 8 RenderLayer::scrollRectToVisible and RenderObject::scrollRectToVisible have several 9 parameters to configure the type of scrolling. This patch groups the const options into a 10 single struct to make easier to handle them in the future. For example, an #ifdefed scroll 11 behavior option will be added in bug 188043. This refactoring can maybe help too for other 12 scroll extensions (e.g. bug 176454 and bug 161611). 13 14 No new tests, behavior unchanged. 15 16 * accessibility/AccessibilityObject.cpp: 17 (WebCore::AccessibilityObject::scrollToMakeVisible const): Pass options via a struct. 18 * dom/Element.cpp: 19 (WebCore::Element::scrollIntoView): Ditto. 20 (WebCore::Element::scrollIntoViewIfNeeded): Ditto. 21 (WebCore::Element::scrollIntoViewIfNotVisible): Ditto. 22 * editing/FrameSelection.cpp: Include RenderLayer.h in all WebKit ports in order to define 23 ScrollRectToVisibleOptions. 24 (WebCore::FrameSelection::revealSelection): Pass options via a struct. 25 * page/FrameView.cpp: 26 (WebCore::FrameView::scrollToFocusedElementInternal): Ditto. 27 (WebCore::FrameView::scrollToAnchor): Ditto. 28 * rendering/RenderLayer.cpp: 29 (WebCore::RenderLayer::scrollRectToVisible): Pass options via a struct. Note that 30 absoluteRect and insideFixed are modified in this function. 31 (WebCore::RenderLayer::autoscroll): Pass options via a struct. 32 * rendering/RenderLayer.h: Add ScrollRectToVisibleOptions and use it in order to pass 33 scrollRectToVisible options. 34 * rendering/RenderObject.cpp: 35 (WebCore::RenderObject::scrollRectToVisible): Pass options via a struct 36 * rendering/RenderObject.h: Forward-declare ScrollRectToVisibleOptions and use in order to 37 pass scrollRectToVisible options. 38 1 39 2018-09-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 40 -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r235560 r235749 2993 2993 2994 2994 if (auto* renderer = this->renderer()) 2995 renderer->scrollRectToVisible( SelectionRevealMode::Reveal, boundingBoxRect(), false, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::Yes);2995 renderer->scrollRectToVisible(boundingBoxRect(), false, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::Yes }); 2996 2996 } 2997 2997 -
trunk/Source/WebCore/dom/Element.cpp
r235736 r235749 693 693 ScrollAlignment alignX = toScrollAlignment(options.inlinePosition, false); 694 694 ScrollAlignment alignY = toScrollAlignment(options.blockPosition, true); 695 renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, absoluteBounds, insideFixed, alignX, alignY, ShouldAllowCrossOriginScrolling::No);695 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, alignX, alignY, ShouldAllowCrossOriginScrolling::No }); 696 696 } 697 697 … … 707 707 // Align to the top / bottom and to the closest edge. 708 708 if (alignToTop) 709 renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No);709 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No }); 710 710 else 711 renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways, ShouldAllowCrossOriginScrolling::No);711 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways, ShouldAllowCrossOriginScrolling::No }); 712 712 } 713 713 … … 722 722 LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed); 723 723 if (centerIfNeeded) 724 renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No);724 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No }); 725 725 else 726 renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No);726 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No }); 727 727 } 728 728 … … 737 737 LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed); 738 738 if (centerIfNotVisible) 739 renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible, ShouldAllowCrossOriginScrolling::No);739 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible, ShouldAllowCrossOriginScrolling::No }); 740 740 else 741 renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, absoluteBounds, insideFixed, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible, ShouldAllowCrossOriginScrolling::No);741 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNotVisible, ScrollAlignment::alignToEdgeIfNotVisible, ShouldAllowCrossOriginScrolling::No }); 742 742 } 743 743 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r235560 r235749 54 54 #include "InlineTextBox.h" 55 55 #include "Page.h" 56 #include "RenderLayer.h" 56 57 #include "RenderText.h" 57 58 #include "RenderTextControl.h" … … 72 73 #include "ChromeClient.h" 73 74 #include "Color.h" 74 #include "RenderLayer.h"75 75 #include "RenderObject.h" 76 76 #include "RenderStyle.h" … … 2375 2375 if (!m_scrollingSuppressCount) { 2376 2376 layer->setAdjustForIOSCaretWhenScrolling(true); 2377 layer->scrollRectToVisible(re vealMode, rect, insideFixed, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes);2377 layer->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes }); 2378 2378 layer->setAdjustForIOSCaretWhenScrolling(false); 2379 2379 updateAppearance(); … … 2386 2386 // the selection rect could intersect more than just that. 2387 2387 // See <rdar://problem/4799899>. 2388 if (start.deprecatedNode()->renderer()->scrollRectToVisible(re vealMode, rect, insideFixed, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes))2388 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes })) 2389 2389 updateAppearance(); 2390 2390 #endif -
trunk/Source/WebCore/page/FrameView.cpp
r235560 r235749 2337 2337 bool insideFixed; 2338 2338 LayoutRect absoluteBounds = renderer->absoluteAnchorRect(&insideFixed); 2339 renderer->scrollRectToVisible( m_selectionRevealModeForFocusedElement, absoluteBounds, insideFixed, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No);2339 renderer->scrollRectToVisible(absoluteBounds, insideFixed, { m_selectionRevealModeForFocusedElement, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No }); 2340 2340 } 2341 2341 … … 3111 3111 // Align to the top and to the closest side (this matches other browsers). 3112 3112 if (anchorNode->renderer()->style().isHorizontalWritingMode()) 3113 anchorNode->renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, rect, insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No);3113 anchorNode->renderer()->scrollRectToVisible(rect, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No }); 3114 3114 else if (anchorNode->renderer()->style().isFlippedBlocksWritingMode()) 3115 anchorNode->renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, rect, insideFixed, ScrollAlignment::alignRightAlways, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No);3115 anchorNode->renderer()->scrollRectToVisible(rect, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignRightAlways, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No }); 3116 3116 else 3117 anchorNode->renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, rect, insideFixed, ScrollAlignment::alignLeftAlways, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No);3117 anchorNode->renderer()->scrollRectToVisible(rect, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignLeftAlways, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::No }); 3118 3118 3119 3119 if (AXObjectCache* cache = frame().document()->existingAXObjectCache()) -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r235630 r235749 2503 2503 } 2504 2504 2505 void RenderLayer::scrollRectToVisible( SelectionRevealMode revealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling)2505 void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions& options) 2506 2506 { 2507 2507 LOG_WITH_STREAM(Scrolling, stream << "Layer " << this << " scrollRectToVisible " << absoluteRect); … … 2524 2524 LayoutRect localExposeRect(box->absoluteToLocalQuad(FloatQuad(FloatRect(absoluteRect))).boundingBox()); 2525 2525 LayoutRect layerBounds(0, 0, box->clientWidth(), box->clientHeight()); 2526 LayoutRect revealRect = getRectToExpose(layerBounds, localExposeRect, insideFixed, alignX,alignY);2526 LayoutRect revealRect = getRectToExpose(layerBounds, localExposeRect, insideFixed, options.alignX, options.alignY); 2527 2527 2528 2528 ScrollOffset clampedScrollOffset = clampScrollOffset(scrollOffset() + toIntSize(roundedIntRect(revealRect).location())); … … 2548 2548 2549 2549 LayoutRect viewRect = frameView.visibleContentRect(LegacyIOSDocumentVisibleRect); 2550 LayoutRect exposeRect = getRectToExpose(viewRect, absoluteRect, insideFixed, alignX,alignY);2550 LayoutRect exposeRect = getRectToExpose(viewRect, absoluteRect, insideFixed, options.alignX, options.alignY); 2551 2551 2552 2552 IntPoint scrollOffset(roundedIntPoint(exposeRect.location())); … … 2555 2555 frameView.setScrollPosition(scrollOffset); 2556 2556 2557 if ( shouldAllowCrossOriginScrolling == ShouldAllowCrossOriginScrolling::Yes || frameView.safeToPropagateScrollToParent()) {2557 if (options.shouldAllowCrossOriginScrolling == ShouldAllowCrossOriginScrolling::Yes || frameView.safeToPropagateScrollToParent()) { 2558 2558 parentLayer = ownerElement->renderer()->enclosingLayer(); 2559 2559 // Convert the rect into the coordinate space of the parent frame's document. … … 2564 2564 } 2565 2565 } else { 2566 if ( revealMode == SelectionRevealMode::RevealUpToMainFrame && frameView.frame().isMainFrame())2566 if (options.revealMode == SelectionRevealMode::RevealUpToMainFrame && frameView.frame().isMainFrame()) 2567 2567 return; 2568 2568 … … 2576 2576 targetRect.move(0, frameView.headerHeight()); 2577 2577 2578 LayoutRect revealRect = getRectToExpose(viewRect, targetRect, insideFixed, alignX,alignY);2578 LayoutRect revealRect = getRectToExpose(viewRect, targetRect, insideFixed, options.alignX, options.alignY); 2579 2579 2580 2580 frameView.setScrollPosition(roundedIntPoint(revealRect.location())); … … 2590 2590 2591 2591 if (parentLayer) 2592 parentLayer->scrollRectToVisible( revealMode, newRect, insideFixed, alignX, alignY, shouldAllowCrossOriginScrolling);2592 parentLayer->scrollRectToVisible(newRect, insideFixed, options); 2593 2593 } 2594 2594 … … 2713 2713 { 2714 2714 IntPoint currentDocumentPosition = renderer().view().frameView().windowToContents(positionInWindow); 2715 scrollRectToVisible( SelectionRevealMode::Reveal, LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), false, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes);2715 scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), false, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes }); 2716 2716 } 2717 2717 -
trunk/Source/WebCore/rendering/RenderLayer.h
r235630 r235749 121 121 }; 122 122 123 struct ScrollRectToVisibleOptions { 124 SelectionRevealMode revealMode { SelectionRevealMode::Reveal }; 125 const ScrollAlignment& alignX { ScrollAlignment::alignCenterIfNeeded }; 126 const ScrollAlignment& alignY { ScrollAlignment::alignCenterIfNeeded }; 127 ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling { ShouldAllowCrossOriginScrolling::No }; 128 }; 129 123 130 class RenderLayer final : public ScrollableArea { 124 131 WTF_MAKE_FAST_ALLOCATED; … … 219 226 220 227 // "absoluteRect" is in scaled document coordinates. 221 void scrollRectToVisible( SelectionRevealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ShouldAllowCrossOriginScrolling);228 void scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions&); 222 229 223 230 bool scrollsOverflow() const; -
trunk/Source/WebCore/rendering/RenderObject.cpp
r232178 r235749 415 415 } 416 416 417 bool RenderObject::scrollRectToVisible( SelectionRevealMode revealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling)418 { 419 if ( revealMode == SelectionRevealMode::DoNotReveal)417 bool RenderObject::scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions& options) 418 { 419 if (options.revealMode == SelectionRevealMode::DoNotReveal) 420 420 return false; 421 421 … … 424 424 return false; 425 425 426 enclosingLayer->scrollRectToVisible( revealMode, absoluteRect, insideFixed, alignX, alignY, shouldAllowCrossOriginScrolling);426 enclosingLayer->scrollRectToVisible(absoluteRect, insideFixed, options); 427 427 return true; 428 428 } -
trunk/Source/WebCore/rendering/RenderObject.h
r234215 r235749 84 84 enum class ShouldAllowCrossOriginScrolling { No, Yes }; 85 85 86 struct ScrollRectToVisibleOptions; 87 86 88 #if ENABLE(DASHBOARD_SUPPORT) 87 89 struct AnnotatedRegionValue { … … 159 161 160 162 // Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s). 161 WEBCORE_EXPORT bool scrollRectToVisible( SelectionRevealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling = ShouldAllowCrossOriginScrolling::No);163 WEBCORE_EXPORT bool scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions&); 162 164 163 165 // Convenience function for getting to the nearest enclosing box of a RenderObject. -
trunk/Source/WebKitLegacy/mac/ChangeLog
r235748 r235749 1 2018-09-06 Frederic Wang <fwang@igalia.com> 2 3 Group options of scrollRectToVisible into a struct 4 https://bugs.webkit.org/show_bug.cgi?id=189352 5 6 Reviewed by Simon Fraser. 7 8 * WebView/WebFrame.mm: Add header to use ScrollRectToVisibleOptions. 9 (-[WebFrame _scrollDOMRangeToVisible:]): Pass options via a struct. 10 (-[WebFrame _scrollDOMRangeToVisible:withInset:]): Ditto. 11 1 12 2018-09-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 13 -
trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm
r235560 r235749 90 90 #import <WebCore/PluginData.h> 91 91 #import <WebCore/PrintContext.h> 92 #import <WebCore/RenderLayer.h> 92 93 #import <WebCore/RenderView.h> 93 94 #import <WebCore/RenderWidget.h> … … 742 743 if (startNode && startNode->renderer()) { 743 744 #if !PLATFORM(IOS) 744 startNode->renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes);745 startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes }); 745 746 #else 746 747 RenderLayer* layer = startNode->renderer()->enclosingLayer(); 747 748 if (layer) { 748 749 layer->setAdjustForIOSCaretWhenScrolling(true); 749 startNode->renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes);750 startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes }); 750 751 layer->setAdjustForIOSCaretWhenScrolling(false); 751 752 _private->coreFrame->selection().setCaretRectNeedsUpdate(); … … 767 768 if (layer) { 768 769 layer->setAdjustForIOSCaretWhenScrolling(true); 769 startNode->renderer()->scrollRectToVisible( SelectionRevealMode::Reveal, enclosingIntRect(rangeRect), insideFixed, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes);770 startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes}); 770 771 layer->setAdjustForIOSCaretWhenScrolling(false); 771 772
Note: See TracChangeset
for help on using the changeset viewer.