Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 9b010fc

Browse files
Update touch event regions once per frame
https://bugs.webkit.org/show_bug.cgi?id=209153 Reviewed by Zalan Bujtas. Call document->updateTouchEventRegions() once at the end of Page::updateRendering() instead of relying on a timer. Also rename the functions called from Internal to make it clear they are testing-only. Page::scrollingStateTreeAsText() needs to eagerly update event regions because they are input to the scrolling tree. * dom/Document.cpp: (WebCore::Document::Document): * page/Page.cpp: (WebCore::Page::scrollingStateTreeAsText): (WebCore::Page::touchEventRectsForEventForTesting): (WebCore::Page::passiveTouchEventListenerRectsForTesting): (WebCore::Page::doAfterUpdateRendering): (WebCore::Page::touchEventRectsForEvent): Deleted. (WebCore::Page::passiveTouchEventListenerRects): Deleted. * page/Page.h: * page/scrolling/ScrollingCoordinator.cpp: (WebCore::ScrollingCoordinator::absoluteEventTrackingRegionsForFrame const): * testing/Internals.cpp: (WebCore::Internals::touchEventRectsForEvent): (WebCore::Internals::passiveTouchEventListenerRects): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@258528 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent fb77699 commit 9b010fc

File tree

6 files changed

+49
-11
lines changed

6 files changed

+49
-11
lines changed

Source/WebCore/ChangeLog

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
2020-03-16 Simon Fraser <[email protected]>
2+
3+
Update touch event regions once per frame
4+
https://bugs.webkit.org/show_bug.cgi?id=209153
5+
6+
Reviewed by Zalan Bujtas.
7+
8+
Call document->updateTouchEventRegions() once at the end of Page::updateRendering() instead
9+
of relying on a timer.
10+
11+
Also rename the functions called from Internal to make it clear they are testing-only.
12+
13+
Page::scrollingStateTreeAsText() needs to eagerly update event regions because they are input
14+
to the scrolling tree.
15+
16+
* dom/Document.cpp:
17+
(WebCore::Document::Document):
18+
* page/Page.cpp:
19+
(WebCore::Page::scrollingStateTreeAsText):
20+
(WebCore::Page::touchEventRectsForEventForTesting):
21+
(WebCore::Page::passiveTouchEventListenerRectsForTesting):
22+
(WebCore::Page::doAfterUpdateRendering):
23+
(WebCore::Page::touchEventRectsForEvent): Deleted.
24+
(WebCore::Page::passiveTouchEventListenerRects): Deleted.
25+
* page/Page.h:
26+
* page/scrolling/ScrollingCoordinator.cpp:
27+
(WebCore::ScrollingCoordinator::absoluteEventTrackingRegionsForFrame const):
28+
* testing/Internals.cpp:
29+
(WebCore::Internals::touchEventRectsForEvent):
30+
(WebCore::Internals::passiveTouchEventListenerRects):
31+
132
2020-03-15 Darin Adler <[email protected]>
233

334
Move most of TextIterator off of live ranges

Source/WebCore/dom/Document.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,6 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
536536
: ContainerNode(*this, CreateDocument)
537537
, TreeScope(*this)
538538
, FrameDestructionObserver(frame)
539-
#if ENABLE(IOS_TOUCH_EVENTS)
540-
, m_touchEventsChangedTimer(*this, &Document::touchEventsChangedTimerFired)
541-
#endif
542539
, m_settings(frame ? Ref<Settings>(frame->settings()) : Settings::create(nullptr))
543540
, m_quirks(makeUniqueRef<Quirks>(*this))
544541
, m_cachedResourceLoader(m_frame ? Ref<CachedResourceLoader>(m_frame->loader().activeDocumentLoader()->cachedResourceLoader()) : CachedResourceLoader::create(nullptr))

Source/WebCore/page/Page.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,12 @@ ScrollingCoordinator* Page::scrollingCoordinator()
434434

435435
String Page::scrollingStateTreeAsText()
436436
{
437-
if (Document* document = m_mainFrame->document())
437+
if (Document* document = m_mainFrame->document()) {
438438
document->updateLayout();
439+
#if ENABLE(IOS_TOUCH_EVENTS)
440+
document->updateTouchEventRegions();
441+
#endif
442+
}
439443

440444
if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
441445
return scrollingCoordinator->scrollingStateTreeAsText();
@@ -473,7 +477,7 @@ Ref<DOMRectList> Page::nonFastScrollableRects()
473477
return DOMRectList::create(quads);
474478
}
475479

476-
Ref<DOMRectList> Page::touchEventRectsForEvent(const String& eventName)
480+
Ref<DOMRectList> Page::touchEventRectsForEventForTesting(const String& eventName)
477481
{
478482
if (Document* document = m_mainFrame->document()) {
479483
document->updateLayout();
@@ -496,7 +500,7 @@ Ref<DOMRectList> Page::touchEventRectsForEvent(const String& eventName)
496500
return DOMRectList::create(quads);
497501
}
498502

499-
Ref<DOMRectList> Page::passiveTouchEventListenerRects()
503+
Ref<DOMRectList> Page::passiveTouchEventListenerRectsForTesting()
500504
{
501505
if (Document* document = m_mainFrame->document()) {
502506
document->updateLayout();
@@ -1380,6 +1384,12 @@ void Page::doAfterUpdateRendering()
13801384
});
13811385
#endif
13821386

1387+
#if ENABLE(IOS_TOUCH_EVENTS)
1388+
// updateTouchEventRegions() needs to be called only on the top document.
1389+
if (RefPtr<Document> document = mainFrame().document())
1390+
document->updateTouchEventRegions();
1391+
#endif
1392+
13831393
#if ASSERT_ENABLED
13841394
for (Frame* child = mainFrame().tree().firstRenderedChild(); child; child = child->tree().traverseNextRendered()) {
13851395
auto* frameView = child->view();

Source/WebCore/page/Page.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ class Page : public Supplementable<Page>, public CanMakeWeakPtr<Page> {
268268
WEBCORE_EXPORT String synchronousScrollingReasonsAsText();
269269
WEBCORE_EXPORT Ref<DOMRectList> nonFastScrollableRects();
270270

271-
WEBCORE_EXPORT Ref<DOMRectList> touchEventRectsForEvent(const String& eventName);
272-
WEBCORE_EXPORT Ref<DOMRectList> passiveTouchEventListenerRects();
271+
WEBCORE_EXPORT Ref<DOMRectList> touchEventRectsForEventForTesting(const String& eventName);
272+
WEBCORE_EXPORT Ref<DOMRectList> passiveTouchEventListenerRectsForTesting();
273273

274274
Settings& settings() const { return *m_settings; }
275275
ProgressTracker& progress() const { return *m_progress; }

Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ EventTrackingRegions ScrollingCoordinator::absoluteEventTrackingRegionsForFrame(
111111
ASSERT(frame.isMainFrame());
112112
auto* document = frame.document();
113113
if (!document)
114-
return EventTrackingRegions();
114+
return { };
115115
return document->eventTrackingRegions();
116116
#else
117117
auto* frameView = frame.view();

Source/WebCore/testing/Internals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ ExceptionOr<Ref<DOMRectList>> Internals::touchEventRectsForEvent(const String& e
21502150
if (!document || !document->page())
21512151
return Exception { InvalidAccessError };
21522152

2153-
return document->page()->touchEventRectsForEvent(eventName);
2153+
return document->page()->touchEventRectsForEventForTesting(eventName);
21542154
}
21552155

21562156
ExceptionOr<Ref<DOMRectList>> Internals::passiveTouchEventListenerRects()
@@ -2159,7 +2159,7 @@ ExceptionOr<Ref<DOMRectList>> Internals::passiveTouchEventListenerRects()
21592159
if (!document || !document->page())
21602160
return Exception { InvalidAccessError };
21612161

2162-
return document->page()->passiveTouchEventListenerRects();
2162+
return document->page()->passiveTouchEventListenerRectsForTesting();
21632163
}
21642164

21652165
// FIXME: Remove the document argument. It is almost always the same as

0 commit comments

Comments
 (0)