<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[244588] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/244588">244588</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2019-04-24 08:38:23 -0700 (Wed, 24 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[ContentChangeObserver] Do not use the global _WKContentChange in WebKitLegacy
https://bugs.webkit.org/show_bug.cgi?id=196286
<rdar://problem/49364417>

Reviewed by Simon Fraser.

By reporting WKContentIndeterminateChange in sendMouseMoveEvent enables us to remove the global _WKContentChange state.
Using _WKContentChange is fine as long as only the observed frame reports content change during the synthetic click event.
In case of multiple frames, we should really consult the local state instead.
Unfortunately sendMouseMoveEvent has no access to the observed Document object so we can't really identify the observed content change.
WKContentIndeterminateChange triggers asynchronous decision making at the callsite and in the callback we have access
to the active Document/ContentChangeObverver object and can report the correct state.
This is inline with current WebKit(WK2) behaviour.

Manually tested with a WebKitLegacy test app.

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* page/ios/ContentChangeObserver.h:
(WebCore::ContentChangeObserver::setHasNoChangeState):
(WebCore::ContentChangeObserver::setHasIndeterminateState):
(WebCore::ContentChangeObserver::setHasVisibleChangeState):
(WebCore::ContentChangeObserver::setObservedContentState): Deleted.
* page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::mouseMoved):
* platform/ios/wak/WAKWindow.mm:
(-[WAKWindow sendMouseMoveEvent:contentChange:]):
* platform/ios/wak/WKContentObservation.cpp: Removed.
* platform/ios/wak/WKContentObservation.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreSourcesCocoatxt">trunk/Source/WebCore/SourcesCocoa.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorepageiosContentChangeObserverh">trunk/Source/WebCore/page/ios/ContentChangeObserver.h</a></li>
<li><a href="#trunkSourceWebCorepageiosEventHandlerIOSmm">trunk/Source/WebCore/page/ios/EventHandlerIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformioswakWAKWindowmm">trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformioswakWKContentObservationh">trunk/Source/WebCore/platform/ios/wak/WKContentObservation.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformioswakWKContentObservationcpp">trunk/Source/WebCore/platform/ios/wak/WKContentObservation.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244587 => 244588)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-04-24 14:47:33 UTC (rev 244587)
+++ trunk/Source/WebCore/ChangeLog      2019-04-24 15:38:23 UTC (rev 244588)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2019-04-24  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Do not use the global _WKContentChange in WebKitLegacy
+        https://bugs.webkit.org/show_bug.cgi?id=196286
+        <rdar://problem/49364417>
+
+        Reviewed by Simon Fraser.
+
+        By reporting WKContentIndeterminateChange in sendMouseMoveEvent enables us to remove the global _WKContentChange state.
+        Using _WKContentChange is fine as long as only the observed frame reports content change during the synthetic click event.
+        In case of multiple frames, we should really consult the local state instead.
+        Unfortunately sendMouseMoveEvent has no access to the observed Document object so we can't really identify the observed content change.
+        WKContentIndeterminateChange triggers asynchronous decision making at the callsite and in the callback we have access
+        to the active Document/ContentChangeObverver object and can report the correct state.
+        This is inline with current WebKit(WK2) behaviour.
+
+        Manually tested with a WebKitLegacy test app.
+
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/ios/ContentChangeObserver.h:
+        (WebCore::ContentChangeObserver::setHasNoChangeState):
+        (WebCore::ContentChangeObserver::setHasIndeterminateState):
+        (WebCore::ContentChangeObserver::setHasVisibleChangeState):
+        (WebCore::ContentChangeObserver::setObservedContentState): Deleted.
+        * page/ios/EventHandlerIOS.mm:
+        (WebCore::EventHandler::mouseMoved):
+        * platform/ios/wak/WAKWindow.mm:
+        (-[WAKWindow sendMouseMoveEvent:contentChange:]):
+        * platform/ios/wak/WKContentObservation.cpp: Removed.
+        * platform/ios/wak/WKContentObservation.h:
+
</ins><span class="cx"> 2019-04-24  Philippe Normand  <pnormand@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [GTK][GStreamer] Flaky ASSERTION FAILED: m_lock.isHeld() in TextureMapperPlatformLayerProxy
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcesCocoatxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/SourcesCocoa.txt (244587 => 244588)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/SourcesCocoa.txt    2019-04-24 14:47:33 UTC (rev 244587)
+++ trunk/Source/WebCore/SourcesCocoa.txt       2019-04-24 15:38:23 UTC (rev 244588)
</span><span class="lines">@@ -417,7 +417,6 @@
</span><span class="cx"> platform/ios/wak/WebCoreThread.mm
</span><span class="cx"> platform/ios/wak/WebCoreThreadRun.cpp
</span><span class="cx"> platform/ios/wak/WebCoreThreadSystemInterface.cpp
</span><del>-platform/ios/wak/WKContentObservation.cpp
</del><span class="cx"> platform/ios/wak/WKGraphics.mm
</span><span class="cx"> platform/ios/wak/WKView.mm
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (244587 => 244588)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-04-24 14:47:33 UTC (rev 244587)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-04-24 15:38:23 UTC (rev 244588)
</span><span class="lines">@@ -11077,7 +11077,6 @@
</span><span class="cx">          A148329E187F508700DA63A6 /* WebCoreThreadRun.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreThreadRun.h; sourceTree = "<group>"; };
</span><span class="cx">          A14832A0187F508700DA63A6 /* WebCoreThreadSystemInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreThreadSystemInterface.cpp; sourceTree = "<group>"; };
</span><span class="cx">          A14832A1187F508700DA63A6 /* WebCoreThreadSystemInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreThreadSystemInterface.h; sourceTree = "<group>"; };
</span><del>-               A14832A2187F508700DA63A6 /* WKContentObservation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKContentObservation.cpp; sourceTree = "<group>"; };
</del><span class="cx">           A14832A3187F508700DA63A6 /* WKContentObservation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContentObservation.h; sourceTree = "<group>"; };
</span><span class="cx">          A14832A4187F508700DA63A6 /* WKGraphics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKGraphics.h; sourceTree = "<group>"; };
</span><span class="cx">          A14832A5187F508700DA63A6 /* WKGraphics.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKGraphics.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -22067,7 +22066,6 @@
</span><span class="cx">                          A148329E187F508700DA63A6 /* WebCoreThreadRun.h */,
</span><span class="cx">                          A14832A0187F508700DA63A6 /* WebCoreThreadSystemInterface.cpp */,
</span><span class="cx">                          A14832A1187F508700DA63A6 /* WebCoreThreadSystemInterface.h */,
</span><del>-                               A14832A2187F508700DA63A6 /* WKContentObservation.cpp */,
</del><span class="cx">                           A14832A3187F508700DA63A6 /* WKContentObservation.h */,
</span><span class="cx">                          A14832A4187F508700DA63A6 /* WKGraphics.h */,
</span><span class="cx">                          A14832A5187F508700DA63A6 /* WKGraphics.mm */,
</span></span></pre></div>
<a id="trunkSourceWebCorepageiosContentChangeObserverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.h (244587 => 244588)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ios/ContentChangeObserver.h    2019-04-24 14:47:33 UTC (rev 244587)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.h       2019-04-24 15:38:23 UTC (rev 244588)
</span><span class="lines">@@ -154,9 +154,9 @@
</span><span class="cx">     void stopObservingPendingActivities();
</span><span class="cx">     void reset();
</span><span class="cx"> 
</span><del>-    void setHasNoChangeState() { setObservedContentState(WKContentNoChange); }
-    void setHasIndeterminateState() { setObservedContentState(WKContentIndeterminateChange); }
-    void setHasVisibleChangeState() { setObservedContentState(WKContentVisibilityChange); } 
</del><ins>+    void setHasNoChangeState() { m_observedContentState = WKContentNoChange; }
+    void setHasIndeterminateState() { m_observedContentState = WKContentIndeterminateChange; }
+    void setHasVisibleChangeState() { m_observedContentState = WKContentVisibilityChange; } 
</ins><span class="cx"> 
</span><span class="cx">     bool hasVisibleChangeState() const { return observedContentChange() == WKContentVisibilityChange; }
</span><span class="cx">     bool hasObservedDOMTimer() const { return !m_DOMTimerList.isEmpty(); }
</span><span class="lines">@@ -170,7 +170,6 @@
</span><span class="cx">     bool isObservationTimeWindowActive() const { return m_contentObservationTimer.isActive(); }
</span><span class="cx"> 
</span><span class="cx">     void completeDurationBasedContentObservation();
</span><del>-    void setObservedContentState(WKContentChange);
</del><span class="cx"> 
</span><span class="cx">     void renderTreeUpdateDidStart();
</span><span class="cx">     void renderTreeUpdateDidFinish();
</span><span class="lines">@@ -217,12 +216,6 @@
</span><span class="cx">     bool m_isInObservedRenderTreeUpdate { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline void ContentChangeObserver::setObservedContentState(WKContentChange observedContentChange)
-{
-    m_observedContentState = observedContentChange;
-    WKSetObservedContentChange(observedContentChange);
-}
-
</del><span class="cx"> inline bool ContentChangeObserver::isObservingContentChanges() const
</span><span class="cx"> {
</span><span class="cx">     return m_touchEventIsBeingDispatched
</span></span></pre></div>
<a id="trunkSourceWebCorepageiosEventHandlerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ios/EventHandlerIOS.mm (244587 => 244588)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ios/EventHandlerIOS.mm 2019-04-24 14:47:33 UTC (rev 244587)
+++ trunk/Source/WebCore/page/ios/EventHandlerIOS.mm    2019-04-24 15:38:23 UTC (rev 244588)
</span><span class="lines">@@ -487,7 +487,7 @@
</span><span class="cx"> {
</span><span class="cx">     // Reject a mouse moved if the button is down - screws up tracking during autoscroll
</span><span class="cx">     // These happen because WebKit sometimes has to fake up moved events.
</span><del>-    if (!m_frame.view() || m_mousePressed || m_sendingEventToSubview)
</del><ins>+    if (!m_frame.document() || !m_frame.view() || m_mousePressed || m_sendingEventToSubview)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><span class="lines">@@ -500,6 +500,10 @@
</span><span class="cx">         event.wasHandled = mouseMoved(currentPlatformMouseEvent());
</span><span class="cx">         // Run style recalc to be able to capture content changes as the result of the mouse move event.
</span><span class="cx">         document.updateStyleIfNeeded();
</span><ins>+        callOnMainThread([protectedFrame = makeRef(m_frame)] {
+            if (auto* document = protectedFrame->document())
+                document->page()->chrome().client().observedContentChange(*document->frame());
+        });
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     END_BLOCK_OBJC_EXCEPTIONS;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformioswakWAKWindowmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm (244587 => 244588)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm       2019-04-24 14:47:33 UTC (rev 244587)
+++ trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm  2019-04-24 15:38:23 UTC (rev 244588)
</span><span class="lines">@@ -361,8 +361,10 @@
</span><span class="cx">     WebThreadRun(^{
</span><span class="cx">         [self sendEvent:anEvent];
</span><span class="cx"> 
</span><del>-        if (aContentChange)
-            *aContentChange = WKObservedContentChange();
</del><ins>+        if (aContentChange) {
+            // We always make the decision asynchronously. See EventHandler::mouseMoved.
+            *aContentChange = WKContentIndeterminateChange;
+        }
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformioswakWKContentObservationcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/ios/wak/WKContentObservation.cpp (244587 => 244588)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/wak/WKContentObservation.cpp   2019-04-24 14:47:33 UTC (rev 244587)
+++ trunk/Source/WebCore/platform/ios/wak/WKContentObservation.cpp      2019-04-24 15:38:23 UTC (rev 244588)
</span><span class="lines">@@ -1,43 +0,0 @@
</span><del>-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WKContentObservation.h"
-
-#if PLATFORM(IOS_FAMILY)
-
-WKContentChange _WKContentChange = WKContentNoChange;
-
-WKContentChange WKObservedContentChange(void)
-{
-    return _WKContentChange;
-}
-
-void WKSetObservedContentChange(WKContentChange change)
-{
-    _WKContentChange = change;
-}
-
-#endif // PLATFORM(IOS_FAMILY)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformioswakWKContentObservationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/wak/WKContentObservation.h (244587 => 244588)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/wak/WKContentObservation.h     2019-04-24 14:47:33 UTC (rev 244587)
+++ trunk/Source/WebCore/platform/ios/wak/WKContentObservation.h        2019-04-24 15:38:23 UTC (rev 244588)
</span><span class="lines">@@ -39,9 +39,6 @@
</span><span class="cx">     WKContentIndeterminateChange    = 1
</span><span class="cx"> }   WKContentChange;
</span><span class="cx"> 
</span><del>-WEBCORE_EXPORT WKContentChange WKObservedContentChange(void);
-WEBCORE_EXPORT void WKSetObservedContentChange(WKContentChange);
-
</del><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>