- Revision
- 248759
- Author
- [email protected]
- Date
- 2019-08-15 19:20:57 -0700 (Thu, 15 Aug 2019)
Log Message
[ContentChangeObserver] Keep track of all the visibility candidates.
https://bugs.webkit.org/show_bug.cgi?id=200777
<rdar://problem/54356331>
Reviewed by Simon Fraser.
Source/WebCore:
In order to find out whether a visible (and actionable) content change happened, we need to keep track of all the candidate elements.
Test: fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2.html
* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::reset):
(WebCore::ContentChangeObserver::rendererWillBeDestroyed):
(WebCore::ContentChangeObserver::contentVisibilityDidChange):
(WebCore::ContentChangeObserver::shouldObserveVisibilityChangeForElement):
* page/ios/ContentChangeObserver.h:
Source/WTF:
* wtf/WeakHashSet.h:
LayoutTests:
* fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2-expected.txt: Added.
* fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (248758 => 248759)
--- trunk/LayoutTests/ChangeLog 2019-08-16 02:08:29 UTC (rev 248758)
+++ trunk/LayoutTests/ChangeLog 2019-08-16 02:20:57 UTC (rev 248759)
@@ -1,3 +1,14 @@
+2019-08-15 Zalan Bujtas <[email protected]>
+
+ [ContentChangeObserver] Keep track of all the visibility candidates.
+ https://bugs.webkit.org/show_bug.cgi?id=200777
+ <rdar://problem/54356331>
+
+ Reviewed by Simon Fraser.
+
+ * fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2-expected.txt: Added.
+ * fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2.html: Added.
+
2019-08-15 Myles C. Maxfield <[email protected]>
[WHLSL] Add unary plus
Added: trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2-expected.txt (0 => 248759)
--- trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2-expected.txt 2019-08-16 02:20:57 UTC (rev 248759)
@@ -0,0 +1 @@
+PASS if 'clicked' text is not shown below.
Added: trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2.html (0 => 248759)
--- trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2.html (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2.html 2019-08-16 02:20:57 UTC (rev 248759)
@@ -0,0 +1,70 @@
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<title>This tests the case when 2 visible and actionable elements show up and the first one gets destroyed right away.</title>
+<script src=""
+<style>
+#tapThis {
+ width: 400px;
+ height: 400px;
+ border: 1px solid green;
+}
+
+#willBecomeVisibleMomentarily {
+ display: none;
+ width: 100px;
+ height: 100px;
+ background-color: red;
+}
+#willBecomeVisible {
+ display: none;
+ width: 100px;
+ height: 100px;
+ background-color: green;
+}
+</style>
+<script>
+async function test() {
+ if (!window.testRunner || !testRunner.runUIScript)
+ return;
+ if (window.internals)
+ internals.settings.setContentChangeObserverEnabled(true);
+
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+
+ await UIHelper.activateElement(tapThis);
+}
+</script>
+</head>
+<body _onload_="test()">
+<div id=tapThis>PASS if 'clicked' text is not shown below.</div>
+<div id=willBecomeVisibleMomentarily></div>
+<div id=willBecomeVisible></div>
+<pre id=result></pre>
+<script>
+tapThis.addEventListener("touchstart", function( event ) {
+ willBecomeVisibleMomentarily.style.display = "block";
+ willBecomeVisible.style.display = "block";
+}, false);
+
+tapThis.addEventListener("mouseover", function( event ) {
+ willBecomeVisibleMomentarily.style.display = "none";
+ if (window.testRunner)
+ setTimeout("testRunner.notifyDone()", 50);
+}, false);
+
+willBecomeVisibleMomentarily.addEventListener("click", function( event ) {
+ result.innerHTML = "clicked willBecomeVisibleMomentarily";
+}, false);
+
+willBecomeVisible.addEventListener("click", function( event ) {
+ result.innerHTML = "clicked willBecomeVisible";
+}, false);
+
+tapThis.addEventListener("click", function( event ) {
+ result.innerHTML = "clicked";
+}, false);
+</script>
+</body>
+</html>
Modified: trunk/Source/WTF/ChangeLog (248758 => 248759)
--- trunk/Source/WTF/ChangeLog 2019-08-16 02:08:29 UTC (rev 248758)
+++ trunk/Source/WTF/ChangeLog 2019-08-16 02:20:57 UTC (rev 248759)
@@ -1,3 +1,13 @@
+2019-08-15 Zalan Bujtas <[email protected]>
+
+ [ContentChangeObserver] Keep track of all the visibility candidates.
+ https://bugs.webkit.org/show_bug.cgi?id=200777
+ <rdar://problem/54356331>
+
+ Reviewed by Simon Fraser.
+
+ * wtf/WeakHashSet.h:
+
2019-08-15 Brent Fulgham <[email protected]>
[FTW] Enable CoreFoundation use if building for Apple target
Modified: trunk/Source/WTF/wtf/WeakHashSet.h (248758 => 248759)
--- trunk/Source/WTF/wtf/WeakHashSet.h 2019-08-16 02:08:29 UTC (rev 248758)
+++ trunk/Source/WTF/wtf/WeakHashSet.h 2019-08-16 02:20:57 UTC (rev 248759)
@@ -112,6 +112,8 @@
return m_set.remove(*weakPtrImpl);
}
+ void clear() { m_set.clear(); }
+
template <typename U>
bool contains(const U& value) const
{
Modified: trunk/Source/WebCore/ChangeLog (248758 => 248759)
--- trunk/Source/WebCore/ChangeLog 2019-08-16 02:08:29 UTC (rev 248758)
+++ trunk/Source/WebCore/ChangeLog 2019-08-16 02:20:57 UTC (rev 248759)
@@ -1,3 +1,22 @@
+2019-08-15 Zalan Bujtas <[email protected]>
+
+ [ContentChangeObserver] Keep track of all the visibility candidates.
+ https://bugs.webkit.org/show_bug.cgi?id=200777
+ <rdar://problem/54356331>
+
+ Reviewed by Simon Fraser.
+
+ In order to find out whether a visible (and actionable) content change happened, we need to keep track of all the candidate elements.
+
+ Test: fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden2.html
+
+ * page/ios/ContentChangeObserver.cpp:
+ (WebCore::ContentChangeObserver::reset):
+ (WebCore::ContentChangeObserver::rendererWillBeDestroyed):
+ (WebCore::ContentChangeObserver::contentVisibilityDidChange):
+ (WebCore::ContentChangeObserver::shouldObserveVisibilityChangeForElement):
+ * page/ios/ContentChangeObserver.h:
+
2019-08-15 Myles C. Maxfield <[email protected]>
[WHLSL] Add unary plus
Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp (248758 => 248759)
--- trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp 2019-08-16 02:08:29 UTC (rev 248758)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp 2019-08-16 02:20:57 UTC (rev 248759)
@@ -371,7 +371,7 @@
m_isInObservedStyleRecalc = false;
m_observedDomTimerIsBeingExecuted = false;
- m_visibilityCandidateElement = { };
+ m_visibilityCandidateList.clear();
m_contentObservationTimer.stop();
m_elementsWithDestroyedVisibleRenderer.clear();
@@ -401,11 +401,11 @@
if (!isVisuallyHidden(element))
m_elementsWithDestroyedVisibleRenderer.add(&element);
// Candidate element is no longer visible.
- if (m_visibilityCandidateElement == &element) {
+ if (m_visibilityCandidateList.remove(element)) {
// FIXME: We should also check for other type of visiblity changes.
ASSERT(hasVisibleChangeState());
- m_visibilityCandidateElement = { };
- setHasIndeterminateState();
+ if (m_visibilityCandidateList.computesEmpty())
+ setHasIndeterminateState();
}
}
@@ -412,8 +412,7 @@
void ContentChangeObserver::contentVisibilityDidChange(const Element& element)
{
LOG(ContentObservation, "contentVisibilityDidChange: visible content change did happen.");
- // FIXME: This should evolve into a list of candidate elements.
- m_visibilityCandidateElement = makeWeakPtr(element);
+ m_visibilityCandidateList.add(element);
adjustObservedState(Event::ContentVisibilityChanged);
}
@@ -623,7 +622,7 @@
bool ContentChangeObserver::shouldObserveVisibilityChangeForElement(const Element& element)
{
- return isObservingContentChanges() && !hasVisibleChangeState() && !visibleRendererWasDestroyed(element) && !element.document().quirks().shouldIgnoreContentChange(element);
+ return isObservingContentChanges() && !visibleRendererWasDestroyed(element) && !element.document().quirks().shouldIgnoreContentChange(element);
}
ContentChangeObserver::StyleChangeScope::StyleChangeScope(Document& document, const Element& element)
Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.h (248758 => 248759)
--- trunk/Source/WebCore/page/ios/ContentChangeObserver.h 2019-08-16 02:08:29 UTC (rev 248758)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.h 2019-08-16 02:20:57 UTC (rev 248759)
@@ -207,7 +207,7 @@
HashSet<const Element*> m_elementsWithDestroyedVisibleRenderer;
WKContentChange m_observedContentState { WKContentNoChange };
WeakPtr<Element> m_hiddenTouchTargetElement;
- WeakPtr<Element> m_visibilityCandidateElement;
+ WeakHashSet<Element> m_visibilityCandidateList;
bool m_touchEventIsBeingDispatched { false };
bool m_isWaitingForStyleRecalc { false };
bool m_isInObservedStyleRecalc { false };