Changeset 277069 in webkit
- Timestamp:
- May 5, 2021 11:43:14 PM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r277068 r277069 1 2021-05-05 Megan Gardner <megan_gardner@apple.com> 2 3 AppHighlight scrolls should be smooth 4 https://bugs.webkit.org/show_bug.cgi?id=225395 5 6 Reviewed by Simon Fraser. 7 8 Leverage smooth scrolling experimental feature to allow AppHighlight scrolls 9 to be smooth. 10 11 * Modules/highlight/AppHighlightStorage.cpp: 12 (WebCore::AppHighlightStorage::attemptToRestoreHighlightAndScroll): 13 * editing/Editor.cpp: 14 (WebCore::TemporarySelectionChange::setSelection): 15 * editing/Editor.h: 16 * editing/FrameSelection.cpp: 17 (WebCore::FrameSelection::setSelection): 18 (WebCore::FrameSelection::updateAndRevealSelection): 19 (WebCore::FrameSelection::revealSelection): 20 * editing/FrameSelection.h: 21 * page/DOMWindow.cpp: 22 (WebCore::DOMWindow::scrollTo const): 23 * page/ScrollBehavior.cpp: 24 (WebCore::useSmoothScrolling): 25 * platform/ScrollTypes.h: 26 1 27 2021-05-05 Mark Lam <mark.lam@apple.com> 2 28 -
trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp
r276347 r277069 261 261 strongDocument->appHighlightRegister().addAppHighlight(StaticRange::create(*range)); 262 262 263 if (scroll == ScrollToHighlight::Yes) { 264 OptionSet<TemporarySelectionOption> temporarySelectionOptions; 265 temporarySelectionOptions.add(TemporarySelectionOption::RevealSelection); 266 TemporarySelectionChange selectionChange(*strongDocument, { range.value() }, temporarySelectionOptions); 267 } 263 if (scroll == ScrollToHighlight::Yes) 264 TemporarySelectionChange selectionChange(*strongDocument, { range.value() }, { TemporarySelectionOption::RevealSelection, TemporarySelectionOption::SmoothScroll, TemporarySelectionOption::OverrideSmoothScrollFeatureEnablment }); 265 268 266 return true; 269 267 } -
trunk/Source/WebCore/dom/Element.cpp
r276698 r277069 937 937 isHorizontal ? alignY : alignX, 938 938 ShouldAllowCrossOriginScrolling::No, 939 options.behavior.valueOr(ScrollBehavior::Auto) 939 options.behavior.valueOr(ScrollBehavior::Auto), 940 SmoothScrollFeatureEnablement::Default 940 941 }; 941 942 renderer()->scrollRectToVisible(absoluteBounds, insideFixed, visibleOptions); -
trunk/Source/WebCore/editing/Editor.cpp
r276347 r277069 266 266 if (m_options & TemporarySelectionOption::RevealSelection) 267 267 options.add(FrameSelection::RevealSelection); 268 if (m_options & TemporarySelectionOption::SmoothScroll) 269 options.add(FrameSelection::SmoothScroll); 270 if (m_options & TemporarySelectionOption::OverrideSmoothScrollFeatureEnablment) 271 options.add(FrameSelection::OverrideSmoothScrollFeatureEnablement); 268 272 m_document->selection().setSelection(selection, options); 269 273 } -
trunk/Source/WebCore/editing/Editor.h
r276191 r277069 119 119 // Force the render tree to update selection state. Only respected on iOS. 120 120 EnableAppearanceUpdates = 1 << 3, 121 122 SmoothScroll = 1 << 4, 123 124 OverrideSmoothScrollFeatureEnablment = 1 << 5, 121 125 }; 122 126 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r275161 r277069 445 445 return; 446 446 447 updateAndRevealSelection(intent );447 updateAndRevealSelection(intent, options.contains(SmoothScroll) ? ScrollBehavior::Smooth : ScrollBehavior::Instant, options.contains(OverrideSmoothScrollFeatureEnablement) ? SmoothScrollFeatureEnablement::Override : SmoothScrollFeatureEnablement::Default); 448 448 449 449 if (options & IsUserTriggered) { … … 472 472 } 473 473 474 void FrameSelection::updateAndRevealSelection(const AXTextStateChangeIntent& intent )474 void FrameSelection::updateAndRevealSelection(const AXTextStateChangeIntent& intent, ScrollBehavior scrollBehavior, SmoothScrollFeatureEnablement overideFeatureEnablement) 475 475 { 476 476 if (!m_pendingSelectionUpdate) … … 489 489 alignment = m_alwaysAlignCursorOnScrollWhenRevealingSelection ? ScrollAlignment::alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded; 490 490 491 revealSelection(m_selectionRevealMode, alignment, RevealExtent );491 revealSelection(m_selectionRevealMode, alignment, RevealExtent, scrollBehavior, overideFeatureEnablement); 492 492 } 493 493 … … 2379 2379 } 2380 2380 2381 void FrameSelection::revealSelection(SelectionRevealMode revealMode, const ScrollAlignment& alignment, RevealExtentOption revealExtentOption )2381 void FrameSelection::revealSelection(SelectionRevealMode revealMode, const ScrollAlignment& alignment, RevealExtentOption revealExtentOption, ScrollBehavior scrollBehavior, SmoothScrollFeatureEnablement overrideFeatureEnablement) 2382 2382 { 2383 2383 if (revealMode == SelectionRevealMode::DoNotReveal) … … 2402 2402 auto* scrollableArea = layer->ensureLayerScrollableArea(); 2403 2403 scrollableArea->setAdjustForIOSCaretWhenScrolling(true); 2404 layer->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes 2404 layer->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes, scrollBehavior, overrideFeatureEnablement}); 2405 2405 scrollableArea->setAdjustForIOSCaretWhenScrolling(false); 2406 2406 updateAppearance(); … … 2413 2413 // the selection rect could intersect more than just that. 2414 2414 // See <rdar://problem/4799899>. 2415 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes 2415 if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes, scrollBehavior, overrideFeatureEnablement})) 2416 2416 updateAppearance(); 2417 2417 #endif -
trunk/Source/WebCore/editing/FrameSelection.h
r274862 r277069 33 33 #include "LayoutRect.h" 34 34 #include "ScrollAlignment.h" 35 #include "ScrollBehavior.h" 35 36 #include "Timer.h" 36 37 #include "VisibleSelection.h" … … 123 124 RevealSelection = 1 << 7, 124 125 RevealSelectionUpToMainFrame = 1 << 8, 126 SmoothScroll = 1 << 9, 127 OverrideSmoothScrollFeatureEnablement = 1 << 10 125 128 }; 126 129 static constexpr OptionSet<SetSelectionOption> defaultSetSelectionOptions(EUserTriggered = NotUserTriggered); … … 246 249 WEBCORE_EXPORT HTMLFormElement* currentForm() const; 247 250 248 WEBCORE_EXPORT void revealSelection(SelectionRevealMode = SelectionRevealMode::Reveal, const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent );251 WEBCORE_EXPORT void revealSelection(SelectionRevealMode = SelectionRevealMode::Reveal, const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent, ScrollBehavior = ScrollBehavior::Instant, SmoothScrollFeatureEnablement = SmoothScrollFeatureEnablement::Default); 249 252 WEBCORE_EXPORT void setSelectionFromNone(); 250 253 … … 261 264 262 265 private: 263 void updateAndRevealSelection(const AXTextStateChangeIntent& );266 void updateAndRevealSelection(const AXTextStateChangeIntent&, ScrollBehavior = ScrollBehavior::Instant, SmoothScrollFeatureEnablement = SmoothScrollFeatureEnablement::Override); 264 267 void updateDataDetectorsForSelection(); 265 268 -
trunk/Source/WebCore/page/ScrollBehavior.cpp
r272295 r277069 34 34 namespace WebCore { 35 35 36 bool useSmoothScrolling(ScrollBehavior behavior, Element* associatedElement )36 bool useSmoothScrolling(ScrollBehavior behavior, Element* associatedElement, SmoothScrollFeatureEnablement overrideFeatureEnablement) 37 37 { 38 38 if (!associatedElement) … … 44 44 associatedElement = associatedElement->document().documentElement(); 45 45 46 if (!associatedElement->renderer() || !associatedElement->document().settings().CSSOMViewSmoothScrollingEnabled())46 if (!associatedElement->renderer() || (overrideFeatureEnablement == SmoothScrollFeatureEnablement::Default && !associatedElement->document().settings().CSSOMViewSmoothScrollingEnabled())) 47 47 return false; 48 48 -
trunk/Source/WebCore/page/ScrollBehavior.h
r255957 r277069 36 36 }; 37 37 38 bool useSmoothScrolling(ScrollBehavior, Element* associatedElement); 38 enum class SmoothScrollFeatureEnablement : bool { Default, Override }; 39 40 bool useSmoothScrolling(ScrollBehavior, Element* associatedElement, SmoothScrollFeatureEnablement = SmoothScrollFeatureEnablement::Default); 39 41 40 42 } // namespace WebCore -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r276718 r277069 2408 2408 { 2409 2409 auto scrollPositionOptions = ScrollPositionChangeOptions::createProgrammatic(); 2410 if (!renderer().frame().eventHandler().autoscrollInProgress() && element && useSmoothScrolling(options.behavior, element ))2410 if (!renderer().frame().eventHandler().autoscrollInProgress() && element && useSmoothScrolling(options.behavior, element, options.overrideFeatureEnablement)) 2411 2411 scrollPositionOptions.animated = AnimatedScroll::Yes; 2412 2412 return scrollPositionOptions; -
trunk/Source/WebCore/rendering/RenderLayer.h
r276842 r277069 142 142 ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling { ShouldAllowCrossOriginScrolling::No }; 143 143 ScrollBehavior behavior { ScrollBehavior::Auto }; 144 SmoothScrollFeatureEnablement overrideFeatureEnablement { SmoothScrollFeatureEnablement::Default }; 144 145 }; 145 146
Note: See TracChangeset
for help on using the changeset viewer.