Title: [248790] trunk
- Revision
- 248790
- Author
- za...@apple.com
- Date
- 2019-08-16 13:24:53 -0700 (Fri, 16 Aug 2019)
Log Message
[ContentChangeObserver] Add ContentChangeObserver::elementDidBecomeHidden
https://bugs.webkit.org/show_bug.cgi?id=200819
Source/WebCore:
Reviewed by Simon Fraser.
r248750 started tracking candidate elements that become hidden through renderer destruction. This patch expands the check for other visibility style changes.
<rdar://problem/54400223>
Test: fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3.html
* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::rendererWillBeDestroyed):
(WebCore::ContentChangeObserver::elementDidBecomeHidden):
(WebCore::ContentChangeObserver::StyleChangeScope::~StyleChangeScope):
* page/ios/ContentChangeObserver.h:
LayoutTests:
<rdar://problem/54400223>
Reviewed by Simon Fraser.
* fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3-expected.txt: Added.
* fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (248789 => 248790)
--- trunk/LayoutTests/ChangeLog 2019-08-16 20:17:17 UTC (rev 248789)
+++ trunk/LayoutTests/ChangeLog 2019-08-16 20:24:53 UTC (rev 248790)
@@ -1,3 +1,14 @@
+2019-08-16 Zalan Bujtas <za...@apple.com>
+
+ [ContentChangeObserver] Add ContentChangeObserver::elementDidBecomeHidden
+ https://bugs.webkit.org/show_bug.cgi?id=200819
+ <rdar://problem/54400223>
+
+ Reviewed by Simon Fraser.
+
+ * fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3-expected.txt: Added.
+ * fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3.html: Added.
+
2019-08-16 Joseph Pecoraro <pecor...@apple.com>
Web Inspector: _javascript_ formatting of single statement arrow function can be poor
Added: trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3-expected.txt (0 => 248790)
--- trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3-expected.txt 2019-08-16 20:24:53 UTC (rev 248790)
@@ -0,0 +1,2 @@
+PASS if 'clicked' text is shown below.
+clicked
Added: trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3.html (0 => 248790)
--- trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3.html (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3.html 2019-08-16 20:24:53 UTC (rev 248790)
@@ -0,0 +1,59 @@
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<title>This tests the case when visible and actionable content shows up and gets invisible 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;
+}
+</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 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";
+}, false);
+
+tapThis.addEventListener("mouseover", function( event ) {
+ willBecomeVisibleMomentarily.style.visibility = "hidden";
+}, false);
+
+willBecomeVisibleMomentarily.addEventListener("click", function( event ) {
+ result.innerHTML = "clicked willBecomeVisibleMomentarily";
+}, false);
+
+tapThis.addEventListener("click", function( event ) {
+ result.innerHTML = "clicked";
+ if (window.testRunner)
+ testRunner.notifyDone();
+}, false);
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (248789 => 248790)
--- trunk/Source/WebCore/ChangeLog 2019-08-16 20:17:17 UTC (rev 248789)
+++ trunk/Source/WebCore/ChangeLog 2019-08-16 20:24:53 UTC (rev 248790)
@@ -1,3 +1,21 @@
+2019-08-16 Zalan Bujtas <za...@apple.com>
+
+ [ContentChangeObserver] Add ContentChangeObserver::elementDidBecomeHidden
+ https://bugs.webkit.org/show_bug.cgi?id=200819
+
+ Reviewed by Simon Fraser.
+
+ r248750 started tracking candidate elements that become hidden through renderer destruction. This patch expands the check for other visibility style changes.
+ <rdar://problem/54400223>
+
+ Test: fast/events/touch/ios/content-observation/going-from-hidden-to-visible-and-to-hidden3.html
+
+ * page/ios/ContentChangeObserver.cpp:
+ (WebCore::ContentChangeObserver::rendererWillBeDestroyed):
+ (WebCore::ContentChangeObserver::elementDidBecomeHidden):
+ (WebCore::ContentChangeObserver::StyleChangeScope::~StyleChangeScope):
+ * page/ios/ContentChangeObserver.h:
+
2019-08-16 Ryosuke Niwa <rn...@webkit.org>
Split tabIndex computation for DOM and the rest of WebCore
Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp (248789 => 248790)
--- trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp 2019-08-16 20:17:17 UTC (rev 248789)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp 2019-08-16 20:24:53 UTC (rev 248790)
@@ -400,22 +400,27 @@
if (!isVisuallyHidden(element))
m_elementsWithDestroyedVisibleRenderer.add(&element);
- // Candidate element is no longer visible.
- if (m_visibilityCandidateList.remove(element)) {
- // FIXME: We should also check for other type of visiblity changes.
- ASSERT(hasVisibleChangeState());
- if (m_visibilityCandidateList.computesEmpty())
- setHasIndeterminateState();
- }
+ elementDidBecomeHidden(element);
}
void ContentChangeObserver::elementDidBecomeVisible(const Element& element)
{
- LOG(ContentObservation, "elementDidBecomeVisible: visible content change did happen.");
+ LOG_WITH_STREAM(ContentObservation, stream << "elementDidBecomeVisible: element went from hidden to visible: " << &element);
m_visibilityCandidateList.add(element);
adjustObservedState(Event::ElementDidBecomeVisible);
}
+void ContentChangeObserver::elementDidBecomeHidden(const Element& element)
+{
+ LOG_WITH_STREAM(ContentObservation, stream << "elementDidBecomeHidden: element went from visible to hidden: " << &element);
+ // Candidate element is no longer visible.
+ if (!m_visibilityCandidateList.remove(element))
+ return;
+ ASSERT(hasVisibleChangeState());
+ if (m_visibilityCandidateList.computesEmpty())
+ setHasIndeterminateState();
+}
+
void ContentChangeObserver::touchEventDidStart(PlatformEvent::Type eventType)
{
#if ENABLE(TOUCH_EVENTS)
@@ -636,12 +641,19 @@
ContentChangeObserver::StyleChangeScope::~StyleChangeScope()
{
- auto changedFromHiddenToVisible = [&] {
- return m_wasHidden && isConsideredVisible(m_element);
- };
+ // Do we track this element?
+ if (!m_wasHidden.hasValue())
+ return;
- if (changedFromHiddenToVisible() && isConsideredClickable(m_element, m_hadRenderer ? ElementHadRenderer::Yes : ElementHadRenderer::No))
+ if (!isConsideredClickable(m_element, m_hadRenderer ? ElementHadRenderer::Yes : ElementHadRenderer::No))
+ return;
+
+ auto wasVisible = !m_wasHidden.value();
+ auto isVisible = isConsideredVisible(m_element);
+ if (!wasVisible && isVisible)
m_contentChangeObserver.elementDidBecomeVisible(m_element);
+ else if (wasVisible && !isVisible)
+ m_contentChangeObserver.elementDidBecomeHidden(m_element);
}
#if ENABLE(TOUCH_EVENTS)
Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.h (248789 => 248790)
--- trunk/Source/WebCore/page/ios/ContentChangeObserver.h 2019-08-16 20:17:17 UTC (rev 248789)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.h 2019-08-16 20:24:53 UTC (rev 248790)
@@ -83,7 +83,7 @@
private:
ContentChangeObserver& m_contentChangeObserver;
const Element& m_element;
- bool m_wasHidden { false };
+ Optional<bool> m_wasHidden;
bool m_hadRenderer { false };
};
@@ -130,6 +130,7 @@
void didRecognizeLongPress();
void elementDidBecomeVisible(const Element&);
+ void elementDidBecomeHidden(const Element&);
void setShouldObserveDOMTimerSchedulingAndTransitions(bool);
bool isObservingDOMTimerScheduling() const { return m_isObservingDOMTimerScheduling; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes