Add ENABLE(TOUCH_ACTION_REGIONS) to wrap code that's only relevant for platforms...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jun 2020 19:38:37 +0000 (19:38 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jun 2020 19:38:37 +0000 (19:38 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262390 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/PlatformEnable.h
Source/WTF/wtf/PlatformEnableCocoa.h
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.h
Source/WebCore/page/Frame.cpp
Source/WebCore/page/scrolling/ScrollingTreeNode.h
Source/WebCore/rendering/EventRegion.cpp
Source/WebCore/rendering/EventRegion.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/style/StyleTreeResolver.cpp

index 0e9a2b4..6c163e1 100644 (file)
@@ -1,3 +1,13 @@
+2020-06-01  Simon Fraser  <simon.fraser@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.lam@apple.com>
 
         Change JSC::Config to use storage in WTF::Config instead of its own.
index 1e0f3eb..3700078 100644 (file)
 #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
index 379bdae..28b7240 100644 (file)
 #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
index e8a794d..20ea15e 100644 (file)
@@ -1,3 +1,34 @@
+2020-06-01  Simon Fraser  <simon.fraser@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.ohzeki@gmail.com>
 
         Implement ParentNode.prototype.replaceChildren
index b5c4260..e388366 100644 (file)
@@ -1259,7 +1259,7 @@ public:
     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 @@ private:
 #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)
index b86e95e..d8e6209 100644 (file)
@@ -309,12 +309,13 @@ void Frame::invalidateContentEventRegionsIfNeeded()
         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())
index c67d50a..a9cc86e 100644 (file)
@@ -31,7 +31,6 @@
 #include "ScrollTypes.h"
 #include "ScrollingCoordinator.h"
 #include "ScrollingStateNode.h"
-#include "TouchAction.h"
 #include <wtf/RefCounted.h>
 #include <wtf/TypeCasts.h>
 
index 944dba9..36887ad 100644 (file)
@@ -98,8 +98,10 @@ EventRegion::EventRegion() = default;
 
 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 @@ void EventRegion::unite(const Region& region, const RenderStyle& style, bool ove
 {
     m_region.unite(region);
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
     uniteTouchActions(region, style.effectiveTouchActions());
+#endif
     uniteEventListeners(region, style.eventListenerRegionTypes());
 
 #if ENABLE(EDITABLE_REGION)
@@ -130,8 +134,12 @@ void EventRegion::translate(const IntSize& offset)
 {
     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);
@@ -178,6 +186,7 @@ static inline TouchAction toTouchAction(unsigned index)
     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 @@ OptionSet<TouchAction> EventRegion::touchActionsForPoint(const IntPoint& point)
 
     return actions;
 }
+#endif
 
 void EventRegion::uniteEventListeners(const Region& region, OptionSet<EventListenerRegionType> eventListenerRegionTypes)
 {
@@ -269,6 +279,7 @@ void EventRegion::dump(TextStream& ts) const
 {
     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 @@ void EventRegion::dump(TextStream& ts) const
         }
         ts << indent << ")\n";
     }
+#endif
 
     if (!m_wheelEventListenerRegion.isEmpty()) {
         ts << indent << "(wheel event listener region" << m_wheelEventListenerRegion;
index a701404..4d7f6c9 100644 (file)
@@ -75,9 +75,11 @@ public:
 
     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 @@ public:
     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 @@ template<class Encoder>
 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,12 +138,14 @@ Optional<EventRegion> EventRegion::decode(Decoder& decoder)
     EventRegion eventRegion;
     eventRegion.m_region = WTFMove(*region);
 
+#if ENABLE(TOUCH_ACTION_REGIONS)
     Optional<Vector<Region>> touchActionRegions;
     decoder >> touchActionRegions;
     if (!touchActionRegions)
         return WTF::nullopt;
 
     eventRegion.m_touchActionRegions = WTFMove(*touchActionRegions);
+#endif
 
 #if ENABLE(EDITABLE_REGION)
     Optional<Region> editableRegion;
index 567125e..151fdd4 100644 (file)
@@ -1253,7 +1253,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
         }
 
         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)
index df95211..17dc83b 100644 (file)
@@ -739,8 +739,10 @@ void RenderElement::styleWillChange(StyleDifference diff, const RenderStyle& new
         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)
index d74857a..35e02f6 100644 (file)
@@ -1700,7 +1700,7 @@ bool RenderLayerBacking::maintainsEventRegion() const
     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 @@ static RefPtr<Pattern> patternForDescription(PatternDescription description, Flo
     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 @@ static RefPtr<Pattern> patternForTouchAction(TouchAction touchAction, FloatSize
 
     return patternForDescription(patternDescriptions[actionIndex], contentOffset, destContext);
 }
+#endif
 
 static RefPtr<Pattern> patternForEventListenerRegionType(EventListenerRegionType type, FloatSize contentOffset, GraphicsContext& destContext)
 {
@@ -3199,6 +3201,7 @@ void RenderLayerBacking::paintDebugOverlays(const GraphicsLayer* graphicsLayer,
     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 @@ void RenderLayerBacking::paintDebugOverlays(const GraphicsLayer* graphicsLayer,
                 context.fillRect(rect);
         }
     }
+#endif
 
     if (visibleDebugOverlayRegions & WheelEventHandlerRegion) {
         for (auto type : { EventListenerRegionType::Wheel, EventListenerRegionType::NonPassiveWheel }) {
index 9b15f87..5147aca 100644 (file)
@@ -244,7 +244,7 @@ ElementUpdates TreeResolver::resolveElement(Element& element)
     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();