Title: [262390] trunk/Source
Revision
262390
Author
simon.fra...@apple.com
Date
2020-06-01 12:38:37 -0700 (Mon, 01 Jun 2020)

Log Message

Add ENABLE(TOUCH_ACTION_REGIONS) to wrap code that's only relevant for platforms that consult touch-action for event handling
https://bugs.webkit.org/show_bug.cgi?id=212572

Reviewed by Andy Estes.

Source/WebCore:

This will allow for optimizations in event region painting without ambiguity.

* dom/Document.h:
* page/Frame.cpp:
(WebCore::Frame::invalidateContentEventRegionsIfNeeded):
* page/scrolling/ScrollingTreeNode.h:
* rendering/EventRegion.cpp:
(WebCore::EventRegion::operator== const):
(WebCore::EventRegion::unite):
(WebCore::EventRegion::translate):
(WebCore::EventRegion::dump const):
* rendering/EventRegion.h:
(WebCore::EventRegion::encode const):
(WebCore::EventRegion::decode):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintObject):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleWillChange):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::maintainsEventRegion const):
(WebCore::RenderLayerBacking::paintDebugOverlays):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveElement):

Source/WTF:

* wtf/PlatformEnable.h:
* wtf/PlatformEnableCocoa.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (262389 => 262390)


--- trunk/Source/WTF/ChangeLog	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WTF/ChangeLog	2020-06-01 19:38:37 UTC (rev 262390)
@@ -1,3 +1,13 @@
+2020-06-01  Simon Fraser  <simon.fra...@apple.com>
+
+        Add ENABLE(TOUCH_ACTION_REGIONS) to wrap code that's only relevant for platforms that consult touch-action for event handling
+        https://bugs.webkit.org/show_bug.cgi?id=212572
+
+        Reviewed by Andy Estes.
+
+        * wtf/PlatformEnable.h:
+        * wtf/PlatformEnableCocoa.h:
+
 2020-05-31  Mark Lam  <mark....@apple.com>
 
         Change JSC::Config to use storage in WTF::Config instead of its own.

Modified: trunk/Source/WTF/wtf/PlatformEnable.h (262389 => 262390)


--- trunk/Source/WTF/wtf/PlatformEnable.h	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WTF/wtf/PlatformEnable.h	2020-06-01 19:38:37 UTC (rev 262390)
@@ -486,6 +486,10 @@
 #define ENABLE_TOUCH_EVENTS 0
 #endif
 
+#if !defined(ENABLE_TOUCH_ACTION_REGIONS)
+#define ENABLE_TOUCH_ACTION_REGIONS 0
+#endif
+
 #if !defined(ENABLE_VIDEO)
 #define ENABLE_VIDEO 0
 #endif

Modified: trunk/Source/WTF/wtf/PlatformEnableCocoa.h (262389 => 262390)


--- trunk/Source/WTF/wtf/PlatformEnableCocoa.h	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WTF/wtf/PlatformEnableCocoa.h	2020-06-01 19:38:37 UTC (rev 262390)
@@ -429,6 +429,10 @@
 #define ENABLE_TOUCH_EVENTS 1
 #endif
 
+#if !defined(ENABLE_TOUCH_ACTION_REGIONS) && PLATFORM(IOS_FAMILY)
+#define ENABLE_TOUCH_ACTION_REGIONS 1
+#endif
+
 #if !defined(ENABLE_UI_SIDE_COMPOSITING)
 #define ENABLE_UI_SIDE_COMPOSITING 1
 #endif

Modified: trunk/Source/WebCore/ChangeLog (262389 => 262390)


--- trunk/Source/WebCore/ChangeLog	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/ChangeLog	2020-06-01 19:38:37 UTC (rev 262390)
@@ -1,3 +1,34 @@
+2020-06-01  Simon Fraser  <simon.fra...@apple.com>
+
+        Add ENABLE(TOUCH_ACTION_REGIONS) to wrap code that's only relevant for platforms that consult touch-action for event handling
+        https://bugs.webkit.org/show_bug.cgi?id=212572
+
+        Reviewed by Andy Estes.
+
+        This will allow for optimizations in event region painting without ambiguity.
+
+        * dom/Document.h:
+        * page/Frame.cpp:
+        (WebCore::Frame::invalidateContentEventRegionsIfNeeded):
+        * page/scrolling/ScrollingTreeNode.h:
+        * rendering/EventRegion.cpp:
+        (WebCore::EventRegion::operator== const):
+        (WebCore::EventRegion::unite):
+        (WebCore::EventRegion::translate):
+        (WebCore::EventRegion::dump const):
+        * rendering/EventRegion.h:
+        (WebCore::EventRegion::encode const):
+        (WebCore::EventRegion::decode):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintObject):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::styleWillChange):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::maintainsEventRegion const):
+        (WebCore::RenderLayerBacking::paintDebugOverlays):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::resolveElement):
+
 2020-06-01  Tetsuharu Ohzeki  <tetsuharu.ohz...@gmail.com>
 
         Implement ParentNode.prototype.replaceChildren

Modified: trunk/Source/WebCore/dom/Document.h (262389 => 262390)


--- trunk/Source/WebCore/dom/Document.h	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/dom/Document.h	2020-06-01 19:38:37 UTC (rev 262390)
@@ -1259,7 +1259,7 @@
     bool hasTouchEventHandlers() const { return false; }
     bool touchEventTargetsContain(Node&) const { return false; }
 #endif
-#if PLATFORM(IOS_FAMILY)
+#if ENABLE(TOUCH_ACTION_REGIONS)
     bool mayHaveElementsWithNonAutoTouchAction() const { return m_mayHaveElementsWithNonAutoTouchAction; }
     void setMayHaveElementsWithNonAutoTouchAction() { m_mayHaveElementsWithNonAutoTouchAction = true; }
 #endif
@@ -1888,7 +1888,7 @@
 #if ENABLE(TOUCH_EVENTS)
     std::unique_ptr<EventTargetSet> m_touchEventTargets;
 #endif
-#if PLATFORM(IOS_FAMILY)
+#if ENABLE(TOUCH_ACTION_REGIONS)
     bool m_mayHaveElementsWithNonAutoTouchAction { false };
 #endif
 #if ENABLE(EDITABLE_REGION)

Modified: trunk/Source/WebCore/page/Frame.cpp (262389 => 262390)


--- trunk/Source/WebCore/page/Frame.cpp	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/page/Frame.cpp	2020-06-01 19:38:37 UTC (rev 262390)
@@ -309,12 +309,13 @@
         return;
     bool hasTouchActionElements = false;
     bool hasEditableElements = false;
-#if PLATFORM(IOS)
+#if ENABLE(TOUCH_ACTION_REGIONS)
     hasTouchActionElements = m_doc->mayHaveElementsWithNonAutoTouchAction();
 #endif
 #if ENABLE(EDITABLE_REGION)
     hasEditableElements = m_doc->mayHaveEditableElements();
 #endif
+    // FIXME: This needs to look at wheel event handlers too.
     if (!hasTouchActionElements && !hasEditableElements)
         return;
     if (!m_doc->renderView()->compositor().viewNeedsToInvalidateEventRegionOfEnclosingCompositingLayerForRepaint())

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h (262389 => 262390)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h	2020-06-01 19:38:37 UTC (rev 262390)
@@ -31,7 +31,6 @@
 #include "ScrollTypes.h"
 #include "ScrollingCoordinator.h"
 #include "ScrollingStateNode.h"
-#include "TouchAction.h"
 #include <wtf/RefCounted.h>
 #include <wtf/TypeCasts.h>
 

Modified: trunk/Source/WebCore/rendering/EventRegion.cpp (262389 => 262390)


--- trunk/Source/WebCore/rendering/EventRegion.cpp	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/rendering/EventRegion.cpp	2020-06-01 19:38:37 UTC (rev 262390)
@@ -98,8 +98,10 @@
 
 bool EventRegion::operator==(const EventRegion& other) const
 {
+#if ENABLE(TOUCH_ACTION_REGIONS)
     if (m_touchActionRegions != other.m_touchActionRegions)
         return false;
+#endif
     if (m_wheelEventListenerRegion != other.m_wheelEventListenerRegion)
         return false;
     if (m_nonPassiveWheelEventListenerRegion != other.m_nonPassiveWheelEventListenerRegion)
@@ -115,7 +117,9 @@
 {
     m_region.unite(region);
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
     uniteTouchActions(region, style.effectiveTouchActions());
+#endif
     uniteEventListeners(region, style.eventListenerRegionTypes());
 
 #if ENABLE(EDITABLE_REGION)
@@ -130,9 +134,13 @@
 {
     m_region.translate(offset);
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
     for (auto& touchActionRegion : m_touchActionRegions)
         touchActionRegion.translate(offset);
+#endif
 
+    // FIXME: Translate m_wheelEventListenerRegion and m_nonPassiveWheelEventListenerRegion
+
 #if ENABLE(EDITABLE_REGION)
     m_editableRegion.translate(offset);
 #endif
@@ -178,6 +186,7 @@
     return TouchAction::Auto;
 }
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
 void EventRegion::uniteTouchActions(const Region& touchRegion, OptionSet<TouchAction> touchActions)
 {
     for (auto touchAction : touchActions) {
@@ -224,6 +233,7 @@
 
     return actions;
 }
+#endif
 
 void EventRegion::uniteEventListeners(const Region& region, OptionSet<EventListenerRegionType> eventListenerRegionTypes)
 {
@@ -269,6 +279,7 @@
 {
     ts << m_region;
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
     if (!m_touchActionRegions.isEmpty()) {
         TextStream::IndentScope indentScope(ts);
         ts << indent << "(touch-action\n";
@@ -282,6 +293,7 @@
         }
         ts << indent << ")\n";
     }
+#endif
 
     if (!m_wheelEventListenerRegion.isEmpty()) {
         ts << indent << "(wheel event listener region" << m_wheelEventListenerRegion;

Modified: trunk/Source/WebCore/rendering/EventRegion.h (262389 => 262390)


--- trunk/Source/WebCore/rendering/EventRegion.h	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/rendering/EventRegion.h	2020-06-01 19:38:37 UTC (rev 262390)
@@ -75,9 +75,11 @@
 
     const Region& region() const { return m_region; }
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
     bool hasTouchActions() const { return !m_touchActionRegions.isEmpty(); }
     WEBCORE_EXPORT OptionSet<TouchAction> touchActionsForPoint(const IntPoint&) const;
     const Region* regionForTouchAction(TouchAction) const;
+#endif
 
     OptionSet<EventListenerRegionType> eventListenerRegionTypesForPoint(const IntPoint&) const;
     const Region& eventListenerRegionForType(EventListenerRegionType) const;
@@ -95,11 +97,15 @@
     void dump(TextStream&) const;
 
 private:
+#if ENABLE(TOUCH_ACTION_REGIONS)
     void uniteTouchActions(const Region&, OptionSet<TouchAction>);
+#endif
     void uniteEventListeners(const Region&, OptionSet<EventListenerRegionType>);
 
     Region m_region;
+#if ENABLE(TOUCH_ACTION_REGIONS)
     Vector<Region> m_touchActionRegions;
+#endif
     Region m_wheelEventListenerRegion;
     Region m_nonPassiveWheelEventListenerRegion;
 #if ENABLE(EDITABLE_REGION)
@@ -113,7 +119,9 @@
 void EventRegion::encode(Encoder& encoder) const
 {
     encoder << m_region;
+#if ENABLE(TOUCH_ACTION_REGIONS)
     encoder << m_touchActionRegions;
+#endif
 #if ENABLE(EDITABLE_REGION)
     encoder << m_editableRegion;
 #endif
@@ -130,6 +138,7 @@
     EventRegion eventRegion;
     eventRegion.m_region = WTFMove(*region);
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
     Optional<Vector<Region>> touchActionRegions;
     decoder >> touchActionRegions;
     if (!touchActionRegions)
@@ -136,6 +145,7 @@
         return WTF::nullopt;
 
     eventRegion.m_touchActionRegions = WTFMove(*touchActionRegions);
+#endif
 
 #if ENABLE(EDITABLE_REGION)
     Optional<Region> editableRegion;

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (262389 => 262390)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2020-06-01 19:38:37 UTC (rev 262390)
@@ -1253,7 +1253,7 @@
         }
 
         bool needsTraverseDescendants = hasVisualOverflow() || containsFloats() || !paintInfo.eventRegionContext->contains(enclosingIntRect(borderRect)) || view().needsEventRegionUpdateForNonCompositedFrame();
-#if PLATFORM(IOS_FAMILY)
+#if ENABLE(TOUCH_ACTION_REGIONS)
         needsTraverseDescendants |= document().mayHaveElementsWithNonAutoTouchAction();
 #endif
 #if !PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (262389 => 262390)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2020-06-01 19:38:37 UTC (rev 262390)
@@ -739,8 +739,10 @@
         auto needsInvalidateEventRegion = [&] {
             if (m_style.pointerEvents() != newStyle.pointerEvents())
                 return true;
+#if ENABLE(TOUCH_ACTION_REGIONS)
             if (m_style.effectiveTouchActions() != newStyle.effectiveTouchActions())
                 return true;
+#endif
             if (m_style.eventListenerRegionTypes() != newStyle.eventListenerRegionTypes())
                 return true;
 #if ENABLE(EDITABLE_REGION)

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (262389 => 262390)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2020-06-01 19:38:37 UTC (rev 262390)
@@ -1700,7 +1700,7 @@
     if (renderer().view().needsEventRegionUpdateForNonCompositedFrame())
         return true;
 
-#if PLATFORM(IOS_FAMILY)
+#if ENABLE(TOUCH_ACTION_REGIONS)
     if (renderer().document().mayHaveElementsWithNonAutoTouchAction())
         return true;
 #endif
@@ -3128,6 +3128,7 @@
     return fillPattern;
 };
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
 static RefPtr<Pattern> patternForTouchAction(TouchAction touchAction, FloatSize contentOffset, GraphicsContext& destContext)
 {
     auto toIndex = [](TouchAction touchAction) -> unsigned {
@@ -3165,6 +3166,7 @@
 
     return patternForDescription(patternDescriptions[actionIndex], contentOffset, destContext);
 }
+#endif
 
 static RefPtr<Pattern> patternForEventListenerRegionType(EventListenerRegionType type, FloatSize contentOffset, GraphicsContext& destContext)
 {
@@ -3199,6 +3201,7 @@
     auto visibleDebugOverlayRegions = renderer().settings().visibleDebugOverlayRegions();
 
     // The interactive part.
+#if ENABLE(TOUCH_ACTION_REGIONS)
     // Paint rects for touch action.
     if (visibleDebugOverlayRegions & TouchActionRegion) {
         constexpr auto regionColor = makeSimpleColor(0, 0, 255, 50);
@@ -3228,6 +3231,7 @@
                 context.fillRect(rect);
         }
     }
+#endif
 
     if (visibleDebugOverlayRegions & WheelEventHandlerRegion) {
         for (auto type : { EventListenerRegionType::Wheel, EventListenerRegionType::NonPassiveWheel }) {

Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (262389 => 262390)


--- trunk/Source/WebCore/style/StyleTreeResolver.cpp	2020-06-01 19:35:53 UTC (rev 262389)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp	2020-06-01 19:38:37 UTC (rev 262390)
@@ -244,7 +244,7 @@
     auto beforeUpdate = resolvePseudoStyle(element, update, PseudoId::Before);
     auto afterUpdate = resolvePseudoStyle(element, update, PseudoId::After);
 
-#if PLATFORM(IOS_FAMILY)
+#if ENABLE(TOUCH_ACTION_REGIONS)
     // FIXME: Track this exactly.
     if (update.style->touchActions() != TouchAction::Auto && !m_document.quirks().shouldDisablePointerEventsQuirk())
         m_document.setMayHaveElementsWithNonAutoTouchAction();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to