Diff
Modified: trunk/LayoutTests/ChangeLog (261819 => 261820)
--- trunk/LayoutTests/ChangeLog 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/LayoutTests/ChangeLog 2020-05-18 17:50:11 UTC (rev 261820)
@@ -1,3 +1,13 @@
+2020-05-18 Antti Koivisto <an...@apple.com>
+
+ [Wheel event region] Invalidation for root style
+ https://bugs.webkit.org/show_bug.cgi?id=212029
+
+ Reviewed by Simon Fraser.
+
+ * fast/scrolling/mac/wheel-event-listener-region-root-invalidation-expected.txt: Added.
+ * fast/scrolling/mac/wheel-event-listener-region-root-invalidation.html: Added.
+
2020-05-18 Simon Fraser <simon.fra...@apple.com>
Find doesn't always scroll search results into view
Added: trunk/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-root-invalidation-expected.txt (0 => 261820)
--- trunk/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-root-invalidation-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-root-invalidation-expected.txt 2020-05-18 17:50:11 UTC (rev 261820)
@@ -0,0 +1,40 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backgroundColor #FFFFFF)
+ (event region
+ (rect (0,0) width=800 height=600)
+ (wheel event listener region
+ (rect (0,0) width=800 height=600)
+ (non-passive
+ (rect (0,0) width=800 height=600)
+ )
+ )
+ )
+ )
+ )
+)
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backgroundColor #FFFFFF)
+ (event region
+ (rect (0,0) width=800 height=600)
+ (wheel event listener region
+ (rect (0,0) width=800 height=600)
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-root-invalidation.html (0 => 261820)
--- trunk/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-root-invalidation.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-root-invalidation.html 2020-05-18 17:50:11 UTC (rev 261820)
@@ -0,0 +1,56 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<style>
+.event {
+ position:relative;
+ background-color:blue;
+ width:200px;
+ height:200px;
+}
+.child {
+ position:relative;
+ background-color:blue;
+ left:200px;
+ width:50px;
+ height:50px;
+}
+.offset {
+ left: 200px;
+}
+
+</style>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+window._onload_ = () => {
+ document.body.offsetLeft;
+
+ function listener() {
+ results.textContent += 'wheel\n';
+ }
+ window.addEventListener("wheel", listener);
+
+ let log = "";
+ if (window.internals)
+ log += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
+
+ window.removeEventListener('wheel', listener);
+ document.addEventListener('wheel', () => { results.textContent += 'passive wheel\n' }, { passive: true });
+
+ if (window.internals)
+ log += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
+
+ results.textContent = log;
+}
+</script>
+<body>
+<div class="event" id="active">
+ <div class="child"></div>
+</div>
+<div class="event offset" id="passive">
+ <div class="child"></div>
+</div>
+<pre id="results"></pre>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (261819 => 261820)
--- trunk/Source/WebCore/ChangeLog 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/ChangeLog 2020-05-18 17:50:11 UTC (rev 261820)
@@ -1,3 +1,33 @@
+2020-05-18 Antti Koivisto <an...@apple.com>
+
+ [Wheel event region] Invalidation for root style
+ https://bugs.webkit.org/show_bug.cgi?id=212029
+
+ Reviewed by Simon Fraser.
+
+ Test: fast/scrolling/mac/wheel-event-listener-region-root-invalidation.html
+
+ Invalidate the region when event listeners change on Document or Window.
+
+ * dom/Document.cpp:
+ (WebCore::Document::invalidateEventListenerRegions):
+ * dom/Document.h:
+ (isType):
+ * dom/Element.cpp:
+ (WebCore::Element::invalidateEventListenerRegions):
+ * dom/Element.h:
+ * dom/EventTarget.cpp:
+ (WebCore::EventTarget::addEventListener):
+ (WebCore::EventTarget::removeEventListener):
+ (WebCore::EventTarget::removeAllEventListeners):
+ (WebCore::EventTarget::invalidateEventListenerRegions):
+ * dom/EventTarget.h:
+ * style/StyleAdjuster.cpp:
+ (WebCore::Style::Adjuster::adjustEventListenerRegionTypesForRootStyle):
+ * style/StyleAdjuster.h:
+ * style/StyleResolveForDocument.cpp:
+ (WebCore::Style::resolveForDocument):
+
2020-05-18 Simon Fraser <simon.fra...@apple.com>
Find doesn't always scroll search results into view
Modified: trunk/Source/WebCore/dom/Document.cpp (261819 => 261820)
--- trunk/Source/WebCore/dom/Document.cpp 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/dom/Document.cpp 2020-05-18 17:50:11 UTC (rev 261820)
@@ -210,6 +210,7 @@
#include "SocketProvider.h"
#include "StorageEvent.h"
#include "StringCallback.h"
+#include "StyleAdjuster.h"
#include "StyleColor.h"
#include "StyleProperties.h"
#include "StyleResolveForDocument.h"
@@ -4272,6 +4273,19 @@
ownerElement->document().invalidateEventRegionsForFrame(*ownerElement);
}
+void Document::invalidateEventListenerRegions()
+{
+ if (!renderView() || !documentElement())
+ return;
+
+ // We don't track style validity for Document and full rebuild is too big of a hammer.
+ // Instead just mutate the style directly and trigger a minimal style update.
+ auto& rootStyle = renderView()->mutableStyle();
+ Style::Adjuster::adjustEventListenerRegionTypesForRootStyle(rootStyle, *this);
+
+ documentElement()->invalidateStyleInternal();
+}
+
void Document::invalidateRenderingDependentRegions()
{
#if PLATFORM(IOS_FAMILY) && ENABLE(TOUCH_EVENTS)
Modified: trunk/Source/WebCore/dom/Document.h (261819 => 261820)
--- trunk/Source/WebCore/dom/Document.h 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/dom/Document.h 2020-05-18 17:50:11 UTC (rev 261820)
@@ -1148,6 +1148,8 @@
void invalidateRenderingDependentRegions();
void invalidateEventRegionsForFrame(HTMLFrameOwnerElement&);
+ void invalidateEventListenerRegions();
+
void removeAllEventListeners() final;
WEBCORE_EXPORT const SVGDocumentExtensions* svgExtensions();
@@ -2175,4 +2177,5 @@
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Document)
static bool isType(const WebCore::ScriptExecutionContext& context) { return context.isDocument(); }
static bool isType(const WebCore::Node& node) { return node.isDocumentNode(); }
+ static bool isType(const WebCore::EventTarget& target) { return is<WebCore::Node>(target) && isType(downcast<WebCore::Node>(target)); }
SPECIALIZE_TYPE_TRAITS_END()
Modified: trunk/Source/WebCore/dom/Element.cpp (261819 => 261820)
--- trunk/Source/WebCore/dom/Element.cpp 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/dom/Element.cpp 2020-05-18 17:50:11 UTC (rev 261820)
@@ -1966,6 +1966,12 @@
Node::invalidateStyle(Style::Validity::SubtreeInvalid);
}
+void Element::invalidateEventListenerRegions()
+{
+ // Event listener region is updated via style update.
+ invalidateStyleInternal();
+}
+
bool Element::hasDisplayContents() const
{
if (!hasRareData())
Modified: trunk/Source/WebCore/dom/Element.h (261819 => 261820)
--- trunk/Source/WebCore/dom/Element.h 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/dom/Element.h 2020-05-18 17:50:11 UTC (rev 261820)
@@ -591,6 +591,8 @@
void invalidateStyleInternal();
void invalidateStyleForSubtreeInternal();
+ void invalidateEventListenerRegions();
+
bool hasDisplayContents() const;
void storeDisplayContentsStyle(std::unique_ptr<RenderStyle>);
Modified: trunk/Source/WebCore/dom/EventTarget.cpp (261819 => 261820)
--- trunk/Source/WebCore/dom/EventTarget.cpp 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/dom/EventTarget.cpp 2020-05-18 17:50:11 UTC (rev 261820)
@@ -95,10 +95,8 @@
if (listenerCreatedFromScript)
InspectorInstrumentation::didAddEventListener(*this, eventType, listenerRef.get(), options.capture);
- if (eventNames().isWheelEventType(eventType)) {
- if (is<Element>(*this))
- downcast<Element>(*this).invalidateStyleInternal();
- }
+ if (eventNames().isWheelEventType(eventType))
+ invalidateEventListenerRegions();
eventListenersDidChange();
return true;
@@ -141,10 +139,8 @@
InspectorInstrumentation::willRemoveEventListener(*this, eventType, listener, options.capture);
if (data->eventListenerMap.remove(eventType, listener, options.capture)) {
- if (eventNames().isWheelEventType(eventType)) {
- if (is<Element>(*this))
- downcast<Element>(*this).invalidateStyleInternal();
- }
+ if (eventNames().isWheelEventType(eventType))
+ invalidateEventListenerRegions();
eventListenersDidChange();
return true;
@@ -377,10 +373,8 @@
auto* data = ""
if (data && !data->eventListenerMap.isEmpty()) {
- if (data->eventListenerMap.contains(eventNames().wheelEvent) || data->eventListenerMap.contains(eventNames().mousewheelEvent)) {
- if (is<Element>(*this))
- downcast<Element>(*this).invalidateStyleInternal();
- }
+ if (data->eventListenerMap.contains(eventNames().wheelEvent) || data->eventListenerMap.contains(eventNames().mousewheelEvent))
+ invalidateEventListenerRegions();
data->eventListenerMap.clear();
eventListenersDidChange();
@@ -401,4 +395,23 @@
listener->visitJSFunction(visitor);
}
+void EventTarget::invalidateEventListenerRegions()
+{
+ if (is<Element>(*this)) {
+ downcast<Element>(*this).invalidateEventListenerRegions();
+ return;
+ }
+
+ auto* document = [&]() -> Document* {
+ if (is<Document>(*this))
+ return &downcast<Document>(*this);
+ if (is<DOMWindow>(*this))
+ return downcast<DOMWindow>(*this).document();
+ return nullptr;
+ }();
+
+ if (document)
+ document->invalidateEventListenerRegions();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/EventTarget.h (261819 => 261820)
--- trunk/Source/WebCore/dom/EventTarget.h 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/dom/EventTarget.h 2020-05-18 17:50:11 UTC (rev 261820)
@@ -132,6 +132,7 @@
virtual void derefEventTarget() = 0;
void innerInvokeEventListeners(Event&, EventListenerVector, EventInvokePhase);
+ void invalidateEventListenerRegions();
friend class EventListenerIterator;
};
Modified: trunk/Source/WebCore/style/StyleAdjuster.cpp (261819 => 261820)
--- trunk/Source/WebCore/style/StyleAdjuster.cpp 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/style/StyleAdjuster.cpp 2020-05-18 17:50:11 UTC (rev 261820)
@@ -32,6 +32,7 @@
#include "AnimationBase.h"
#include "CSSFontSelector.h"
+#include "DOMWindow.h"
#include "Element.h"
#include "EventNames.h"
#include "FrameView.h"
@@ -193,6 +194,15 @@
return sharedTouchActions;
}
+void Adjuster::adjustEventListenerRegionTypesForRootStyle(RenderStyle& rootStyle, const Document& document)
+{
+ auto regionTypes = computeEventListenerRegionTypes(document, { });
+ if (auto* window = document.domWindow())
+ regionTypes.add(computeEventListenerRegionTypes(*window, { }));
+
+ rootStyle.setEventListenerRegionTypes(regionTypes);
+}
+
OptionSet<EventListenerRegionType> Adjuster::computeEventListenerRegionTypes(const EventTarget& eventTarget, OptionSet<EventListenerRegionType> parentTypes)
{
#if !PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebCore/style/StyleAdjuster.h (261819 => 261820)
--- trunk/Source/WebCore/style/StyleAdjuster.h 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/style/StyleAdjuster.h 2020-05-18 17:50:11 UTC (rev 261820)
@@ -50,7 +50,7 @@
static void adjustSVGElementStyle(RenderStyle&, const SVGElement&);
static void adjustAnimatedStyle(RenderStyle&, const RenderStyle* parentBoxStyle, OptionSet<AnimationImpact>);
- static OptionSet<EventListenerRegionType> computeEventListenerRegionTypes(const EventTarget&, OptionSet<EventListenerRegionType>);
+ static void adjustEventListenerRegionTypesForRootStyle(RenderStyle&, const Document&);
#if ENABLE(TEXT_AUTOSIZING)
struct AdjustmentForTextAutosizing {
@@ -67,6 +67,7 @@
private:
void adjustDisplayContentsStyle(RenderStyle&) const;
void adjustForSiteSpecificQuirks(RenderStyle&) const;
+ static OptionSet<EventListenerRegionType> computeEventListenerRegionTypes(const EventTarget&, OptionSet<EventListenerRegionType>);
const Document& m_document;
const RenderStyle& m_parentStyle;
Modified: trunk/Source/WebCore/style/StyleResolveForDocument.cpp (261819 => 261820)
--- trunk/Source/WebCore/style/StyleResolveForDocument.cpp 2020-05-18 17:47:10 UTC (rev 261819)
+++ trunk/Source/WebCore/style/StyleResolveForDocument.cpp 2020-05-18 17:50:11 UTC (rev 261820)
@@ -30,7 +30,6 @@
#include "StyleResolveForDocument.h"
#include "CSSFontSelector.h"
-#include "DOMWindow.h"
#include "Document.h"
#include "FontCascade.h"
#include "Frame.h"
@@ -74,12 +73,8 @@
documentStyle.setTextSizeAdjust(TextSizeAdjustment(NoTextSizeAdjustment));
#endif
- auto regionTypes = Adjuster::computeEventListenerRegionTypes(document, { });
- if (auto* window = document.domWindow())
- regionTypes.add(Adjuster::computeEventListenerRegionTypes(*window, { }));
+ Adjuster::adjustEventListenerRegionTypesForRootStyle(documentStyle, document);
- documentStyle.setEventListenerRegionTypes(regionTypes);
-
Element* docElement = document.documentElement();
RenderObject* docElementRenderer = docElement ? docElement->renderer() : nullptr;
if (docElementRenderer) {