Diff
Modified: trunk/Source/WebCore/ChangeLog (277068 => 277069)
--- trunk/Source/WebCore/ChangeLog 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/ChangeLog 2021-05-06 06:43:14 UTC (rev 277069)
@@ -1,3 +1,29 @@
+2021-05-05 Megan Gardner <megan_gard...@apple.com>
+
+ AppHighlight scrolls should be smooth
+ https://bugs.webkit.org/show_bug.cgi?id=225395
+
+ Reviewed by Simon Fraser.
+
+ Leverage smooth scrolling experimental feature to allow AppHighlight scrolls
+ to be smooth.
+
+ * Modules/highlight/AppHighlightStorage.cpp:
+ (WebCore::AppHighlightStorage::attemptToRestoreHighlightAndScroll):
+ * editing/Editor.cpp:
+ (WebCore::TemporarySelectionChange::setSelection):
+ * editing/Editor.h:
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::setSelection):
+ (WebCore::FrameSelection::updateAndRevealSelection):
+ (WebCore::FrameSelection::revealSelection):
+ * editing/FrameSelection.h:
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::scrollTo const):
+ * page/ScrollBehavior.cpp:
+ (WebCore::useSmoothScrolling):
+ * platform/ScrollTypes.h:
+
2021-05-05 Mark Lam <mark....@apple.com>
Introduce VM::hasPendingTerminationException() to make code a little more terse.
Modified: trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp (277068 => 277069)
--- trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp 2021-05-06 06:43:14 UTC (rev 277069)
@@ -260,11 +260,9 @@
strongDocument->appHighlightRegister().addAppHighlight(StaticRange::create(*range));
- if (scroll == ScrollToHighlight::Yes) {
- OptionSet<TemporarySelectionOption> temporarySelectionOptions;
- temporarySelectionOptions.add(TemporarySelectionOption::RevealSelection);
- TemporarySelectionChange selectionChange(*strongDocument, { range.value() }, temporarySelectionOptions);
- }
+ if (scroll == ScrollToHighlight::Yes)
+ TemporarySelectionChange selectionChange(*strongDocument, { range.value() }, { TemporarySelectionOption::RevealSelection, TemporarySelectionOption::SmoothScroll, TemporarySelectionOption::OverrideSmoothScrollFeatureEnablment });
+
return true;
}
Modified: trunk/Source/WebCore/dom/Element.cpp (277068 => 277069)
--- trunk/Source/WebCore/dom/Element.cpp 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/dom/Element.cpp 2021-05-06 06:43:14 UTC (rev 277069)
@@ -936,7 +936,8 @@
isHorizontal ? alignX : alignY,
isHorizontal ? alignY : alignX,
ShouldAllowCrossOriginScrolling::No,
- options.behavior.valueOr(ScrollBehavior::Auto)
+ options.behavior.valueOr(ScrollBehavior::Auto),
+ SmoothScrollFeatureEnablement::Default
};
renderer()->scrollRectToVisible(absoluteBounds, insideFixed, visibleOptions);
}
Modified: trunk/Source/WebCore/editing/Editor.cpp (277068 => 277069)
--- trunk/Source/WebCore/editing/Editor.cpp 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/editing/Editor.cpp 2021-05-06 06:43:14 UTC (rev 277069)
@@ -265,6 +265,10 @@
options.add(FrameSelection::DoNotSetFocus);
if (m_options & TemporarySelectionOption::RevealSelection)
options.add(FrameSelection::RevealSelection);
+ if (m_options & TemporarySelectionOption::SmoothScroll)
+ options.add(FrameSelection::SmoothScroll);
+ if (m_options & TemporarySelectionOption::OverrideSmoothScrollFeatureEnablment)
+ options.add(FrameSelection::OverrideSmoothScrollFeatureEnablement);
m_document->selection().setSelection(selection, options);
}
Modified: trunk/Source/WebCore/editing/Editor.h (277068 => 277069)
--- trunk/Source/WebCore/editing/Editor.h 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/editing/Editor.h 2021-05-06 06:43:14 UTC (rev 277069)
@@ -118,6 +118,10 @@
// Force the render tree to update selection state. Only respected on iOS.
EnableAppearanceUpdates = 1 << 3,
+
+ SmoothScroll = 1 << 4,
+
+ OverrideSmoothScrollFeatureEnablment = 1 << 5,
};
class TemporarySelectionChange {
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (277068 => 277069)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2021-05-06 06:43:14 UTC (rev 277069)
@@ -444,7 +444,7 @@
if (frameView && frameView->layoutContext().isLayoutPending())
return;
- updateAndRevealSelection(intent);
+ updateAndRevealSelection(intent, options.contains(SmoothScroll) ? ScrollBehavior::Smooth : ScrollBehavior::Instant, options.contains(OverrideSmoothScrollFeatureEnablement) ? SmoothScrollFeatureEnablement::Override : SmoothScrollFeatureEnablement::Default);
if (options & IsUserTriggered) {
if (auto* client = protectedDocument->editor().client())
@@ -471,7 +471,7 @@
view->selection().clear();
}
-void FrameSelection::updateAndRevealSelection(const AXTextStateChangeIntent& intent)
+void FrameSelection::updateAndRevealSelection(const AXTextStateChangeIntent& intent, ScrollBehavior scrollBehavior, SmoothScrollFeatureEnablement overideFeatureEnablement)
{
if (!m_pendingSelectionUpdate)
return;
@@ -488,7 +488,7 @@
else
alignment = m_alwaysAlignCursorOnScrollWhenRevealingSelection ? ScrollAlignment::alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded;
- revealSelection(m_selectionRevealMode, alignment, RevealExtent);
+ revealSelection(m_selectionRevealMode, alignment, RevealExtent, scrollBehavior, overideFeatureEnablement);
}
notifyAccessibilityForSelectionChange(intent);
@@ -2378,7 +2378,7 @@
return scanForForm(start);
}
-void FrameSelection::revealSelection(SelectionRevealMode revealMode, const ScrollAlignment& alignment, RevealExtentOption revealExtentOption)
+void FrameSelection::revealSelection(SelectionRevealMode revealMode, const ScrollAlignment& alignment, RevealExtentOption revealExtentOption, ScrollBehavior scrollBehavior, SmoothScrollFeatureEnablement overrideFeatureEnablement)
{
if (revealMode == SelectionRevealMode::DoNotReveal)
return;
@@ -2401,7 +2401,7 @@
if (!m_scrollingSuppressCount) {
auto* scrollableArea = layer->ensureLayerScrollableArea();
scrollableArea->setAdjustForIOSCaretWhenScrolling(true);
- layer->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes });
+ layer->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes, scrollBehavior, overrideFeatureEnablement});
scrollableArea->setAdjustForIOSCaretWhenScrolling(false);
updateAppearance();
if (m_document->page())
@@ -2412,7 +2412,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(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes }))
+ if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, insideFixed, { revealMode, alignment, alignment, ShouldAllowCrossOriginScrolling::Yes, scrollBehavior, overrideFeatureEnablement}))
updateAppearance();
#endif
}
Modified: trunk/Source/WebCore/editing/FrameSelection.h (277068 => 277069)
--- trunk/Source/WebCore/editing/FrameSelection.h 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/editing/FrameSelection.h 2021-05-06 06:43:14 UTC (rev 277069)
@@ -32,6 +32,7 @@
#include "IntRect.h"
#include "LayoutRect.h"
#include "ScrollAlignment.h"
+#include "ScrollBehavior.h"
#include "Timer.h"
#include "VisibleSelection.h"
#include <wtf/Noncopyable.h>
@@ -122,6 +123,8 @@
IsUserTriggered = 1 << 6,
RevealSelection = 1 << 7,
RevealSelectionUpToMainFrame = 1 << 8,
+ SmoothScroll = 1 << 9,
+ OverrideSmoothScrollFeatureEnablement = 1 << 10
};
static constexpr OptionSet<SetSelectionOption> defaultSetSelectionOptions(EUserTriggered = NotUserTriggered);
@@ -245,7 +248,7 @@
WEBCORE_EXPORT HTMLFormElement* currentForm() const;
- WEBCORE_EXPORT void revealSelection(SelectionRevealMode = SelectionRevealMode::Reveal, const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
+ WEBCORE_EXPORT void revealSelection(SelectionRevealMode = SelectionRevealMode::Reveal, const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent, ScrollBehavior = ScrollBehavior::Instant, SmoothScrollFeatureEnablement = SmoothScrollFeatureEnablement::Default);
WEBCORE_EXPORT void setSelectionFromNone();
bool shouldShowBlockCursor() const { return m_shouldShowBlockCursor; }
@@ -260,7 +263,7 @@
void updateFromAssociatedLiveRange();
private:
- void updateAndRevealSelection(const AXTextStateChangeIntent&);
+ void updateAndRevealSelection(const AXTextStateChangeIntent&, ScrollBehavior = ScrollBehavior::Instant, SmoothScrollFeatureEnablement = SmoothScrollFeatureEnablement::Override);
void updateDataDetectorsForSelection();
bool setSelectionWithoutUpdatingAppearance(const VisibleSelection&, OptionSet<SetSelectionOption>, CursorAlignOnScroll, TextGranularity);
Modified: trunk/Source/WebCore/page/ScrollBehavior.cpp (277068 => 277069)
--- trunk/Source/WebCore/page/ScrollBehavior.cpp 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/page/ScrollBehavior.cpp 2021-05-06 06:43:14 UTC (rev 277069)
@@ -33,7 +33,7 @@
namespace WebCore {
-bool useSmoothScrolling(ScrollBehavior behavior, Element* associatedElement)
+bool useSmoothScrolling(ScrollBehavior behavior, Element* associatedElement, SmoothScrollFeatureEnablement overrideFeatureEnablement)
{
if (!associatedElement)
return false;
@@ -43,7 +43,7 @@
if (associatedElement == associatedElement->document().scrollingElement())
associatedElement = associatedElement->document().documentElement();
- if (!associatedElement->renderer() || !associatedElement->document().settings().CSSOMViewSmoothScrollingEnabled())
+ if (!associatedElement->renderer() || (overrideFeatureEnablement == SmoothScrollFeatureEnablement::Default && !associatedElement->document().settings().CSSOMViewSmoothScrollingEnabled()))
return false;
// https://drafts.csswg.org/cssom-view/#scrolling
Modified: trunk/Source/WebCore/page/ScrollBehavior.h (277068 => 277069)
--- trunk/Source/WebCore/page/ScrollBehavior.h 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/page/ScrollBehavior.h 2021-05-06 06:43:14 UTC (rev 277069)
@@ -35,6 +35,8 @@
Smooth
};
-bool useSmoothScrolling(ScrollBehavior, Element* associatedElement);
+enum class SmoothScrollFeatureEnablement : bool { Default, Override };
+bool useSmoothScrolling(ScrollBehavior, Element* associatedElement, SmoothScrollFeatureEnablement = SmoothScrollFeatureEnablement::Default);
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (277068 => 277069)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2021-05-06 06:43:14 UTC (rev 277069)
@@ -2407,7 +2407,7 @@
auto scrollPositionChangeOptionsForElement = [this, options](Element* element)
{
auto scrollPositionOptions = ScrollPositionChangeOptions::createProgrammatic();
- if (!renderer().frame().eventHandler().autoscrollInProgress() && element && useSmoothScrolling(options.behavior, element))
+ if (!renderer().frame().eventHandler().autoscrollInProgress() && element && useSmoothScrolling(options.behavior, element, options.overrideFeatureEnablement))
scrollPositionOptions.animated = AnimatedScroll::Yes;
return scrollPositionOptions;
};
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (277068 => 277069)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2021-05-06 03:37:15 UTC (rev 277068)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2021-05-06 06:43:14 UTC (rev 277069)
@@ -141,6 +141,7 @@
const ScrollAlignment& alignY { ScrollAlignment::alignCenterIfNeeded };
ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling { ShouldAllowCrossOriginScrolling::No };
ScrollBehavior behavior { ScrollBehavior::Auto };
+ SmoothScrollFeatureEnablement overrideFeatureEnablement { SmoothScrollFeatureEnablement::Default };
};
using ScrollingScope = uint64_t;