Modified: trunk/Source/WebCore/ChangeLog (242318 => 242319)
--- trunk/Source/WebCore/ChangeLog 2019-03-02 22:40:43 UTC (rev 242318)
+++ trunk/Source/WebCore/ChangeLog 2019-03-02 22:57:18 UTC (rev 242319)
@@ -1,3 +1,40 @@
+2019-03-02 Zalan Bujtas <[email protected]>
+
+ [ContentChangeObserver] Move away from WKContentChange values
+ https://bugs.webkit.org/show_bug.cgi?id=195240
+ <rdar://problem/48532358>
+
+ Reviewed by Simon Fraser.
+
+ This is in preparation for moving towards a state machine-like implementation.
+
+ * page/ios/ContentChangeObserver.cpp:
+ (WebCore::ContentChangeObserver::didInstallDOMTimer): Do not install the timer if we are already in "hover" state.
+ (WebCore::ContentChangeObserver::didRemoveDOMTimer):
+ (WebCore::ContentChangeObserver::startObservingDOMTimerExecute):
+ (WebCore::ContentChangeObserver::stopObservingDOMTimerExecute):
+ (WebCore::ContentChangeObserver::startObservingStyleRecalc): No need to start observing the style recalc if we are already in "hover" state.
+ (WebCore::ContentChangeObserver::stopObservingStyleRecalc):
+ (WebCore::ContentChangeObserver::clearTimersAndReportContentChange):
+ (WebCore::ContentChangeObserver::didContentVisibilityChange):
+ (WebCore::ContentChangeObserver::startObservingContentChanges):
+ (WebCore::ContentChangeObserver::observedContentChange const):
+ (WebCore::ContentChangeObserver::removeObservedDOMTimer):
+ (WebCore::ContentChangeObserver::hasDeterminedState const):
+ (WebCore::ContentChangeObserver::observedContentChange): Deleted.
+ (WebCore::ContentChangeObserver::resetObservedContentChange): Deleted.
+ (WebCore::ContentChangeObserver::setObservedContentChange): Deleted.
+ (WebCore::ContentChangeObserver::addObservedDOMTimer): Deleted.
+ * page/ios/ContentChangeObserver.h:
+ (WebCore::ContentChangeObserver::addObservedDOMTimer):
+ (WebCore::ContentChangeObserver::clearObservedDOMTimers):
+ (WebCore::ContentChangeObserver::hasVisibleChangeState const):
+ (WebCore::ContentChangeObserver::hasObservedDOMTimer const):
+ (WebCore::ContentChangeObserver::setHasNoChangeState):
+ (WebCore::ContentChangeObserver::setHasIndeterminateState):
+ (WebCore::ContentChangeObserver::setHasVisibleChangeState):
+ (WebCore::ContentChangeObserver::countOfObservedDOMTimers const): Deleted.
+
2019-03-02 Wenson Hsieh <[email protected]>
[iOS] Programmatic paste access should be granted when copying and pasting within the same origin
Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp (242318 => 242319)
--- trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp 2019-03-02 22:40:43 UTC (rev 242318)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp 2019-03-02 22:57:18 UTC (rev 242319)
@@ -61,9 +61,12 @@
return;
if (!isObservingDOMTimerScheduling())
return;
- setObservedContentChange(WKContentIndeterminateChange);
+ if (hasVisibleChangeState())
+ return;
+ LOG_WITH_STREAM(ContentObservation, stream << "didInstallDOMTimer: register this timer: (" << &timer << ") and observe when it fires.");
+
+ setHasIndeterminateState();
addObservedDOMTimer(timer);
- LOG_WITH_STREAM(ContentObservation, stream << "didInstallDOMTimer: register this timer: (" << &timer << ") and observe when it fires.");
}
void ContentChangeObserver::didRemoveDOMTimer(const DOMTimer& timer)
@@ -70,11 +73,12 @@
{
if (!containsObservedDOMTimer(timer))
return;
+ LOG_WITH_STREAM(ContentObservation, stream << "removeDOMTimer: remove registered timer (" << &timer << ")");
+
removeObservedDOMTimer(timer);
- LOG_WITH_STREAM(ContentObservation, stream << "removeDOMTimer: remove registered timer (" << &timer << ")");
- if (countOfObservedDOMTimers())
- return;
- m_page.chrome().client().observedContentChange(m_page.mainFrame());
+ // FIXME: Just because this is the last timer, it does not mean we are in a determined state.
+ if (!hasObservedDOMTimer())
+ m_page.chrome().client().observedContentChange(m_page.mainFrame());
}
void ContentChangeObserver::startObservingDOMTimerExecute(const DOMTimer& timer)
@@ -82,6 +86,7 @@
if (!containsObservedDOMTimer(timer))
return;
LOG_WITH_STREAM(ContentObservation, stream << "startObservingDOMTimerExecute: start observing (" << &timer << ") timer callback.");
+
m_isObservingContentChanges = true;
}
@@ -93,16 +98,13 @@
removeObservedDOMTimer(timer);
stopObservingContentChanges();
- auto observedContentChange = this->observedContentChange();
- auto hasPendingStyleRecalc = WebCore::hasPendingStyleRecalc(m_page);
// Check if the timer callback triggered either a sync or async style update.
- auto hasDeterminedState = observedContentChange == WKContentVisibilityChange || (!countOfObservedDOMTimers() && observedContentChange == WKContentNoChange && !hasPendingStyleRecalc);
- if (hasDeterminedState) {
+ if (hasDeterminateState()) {
LOG_WITH_STREAM(ContentObservation, stream << "stopObservingDOMTimerExecute: (" << &timer << ") in determined state.");
m_page.chrome().client().observedContentChange(m_page.mainFrame());
return;
}
- if (hasPendingStyleRecalc) {
+ if (WebCore::hasPendingStyleRecalc(m_page)) {
// An async style recalc has been scheduled. Let's observe it.
LOG_WITH_STREAM(ContentObservation, stream << "stopObservingDOMTimerExecute: (" << &timer << ") wait until next style recalc fires.");
setShouldObserveStyleRecalc(true);
@@ -113,7 +115,10 @@
{
if (!shouldObserveStyleRecalc())
return;
+ if (hasVisibleChangeState())
+ return;
LOG(ContentObservation, "startObservingStyleRecalc: start observing style recalc.");
+
m_isObservingContentChanges = true;
}
@@ -122,21 +127,22 @@
if (!shouldObserveStyleRecalc())
return;
LOG(ContentObservation, "stopObservingStyleRecalc: stop observing style recalc");
+
setShouldObserveStyleRecalc(false);
- auto hasDeterminedState = observedContentChange() == WKContentVisibilityChange || !countOfObservedDOMTimers();
- if (!hasDeterminedState) {
- LOG(ContentObservation, "stopObservingStyleRecalc: can't decided it yet.");
+ if (hasDeterminateState()) {
+ LOG(ContentObservation, "stopObservingStyleRecalc: has determinate state, report content change.");
+ m_page.chrome().client().observedContentChange(m_page.mainFrame());
return;
}
- LOG(ContentObservation, "stopObservingStyleRecalc: notify the pending synthetic click handler.");
- m_page.chrome().client().observedContentChange(m_page.mainFrame());
+ LOG(ContentObservation, "stopObservingStyleRecalc: can't decide it yet.");
}
void ContentChangeObserver::clearTimersAndReportContentChange()
{
- if (!countOfObservedDOMTimers())
+ if (!hasObservedDOMTimer())
return;
LOG(ContentObservation, "clearTimersAndReportContentChange: remove registered timers and report content change.");
+
clearObservedDOMTimers();
m_page.chrome().client().observedContentChange(m_page.mainFrame());
}
@@ -153,7 +159,7 @@
void ContentChangeObserver::didContentVisibilityChange()
{
- setObservedContentChange(WKContentVisibilityChange);
+ setHasVisibleChangeState();
}
void ContentChangeObserver::startObservingContentChanges()
@@ -160,7 +166,7 @@
{
ASSERT(!hasPendingStyleRecalc(m_page));
startObservingDOMTimerScheduling();
- resetObservedContentChange();
+ setHasNoChangeState();
clearObservedDOMTimers();
m_isObservingContentChanges = true;
}
@@ -171,39 +177,26 @@
m_isObservingContentChanges = false;
}
-WKContentChange ContentChangeObserver::observedContentChange()
+WKContentChange ContentChangeObserver::observedContentChange() const
{
return WKObservedContentChange();
}
-void ContentChangeObserver::resetObservedContentChange()
+void ContentChangeObserver::removeObservedDOMTimer(const DOMTimer& timer)
{
- WKSetObservedContentChange(WKContentNoChange);
+ m_DOMTimerList.remove(&timer);
+ // Force reset the content change flag when the last observed content modifier is removed. We should not be in an indeterminate state anymore.
+ if (!hasObservedDOMTimer() && observedContentChange() == WKContentIndeterminateChange)
+ setHasNoChangeState();
}
-void ContentChangeObserver::setObservedContentChange(WKContentChange change)
+bool ContentChangeObserver::hasDeterminateState() const
{
- if (observedContentChange() == WKContentVisibilityChange)
- return;
- WKSetObservedContentChange(change);
+ if (hasVisibleChangeState())
+ return true;
+ return observedContentChange() == WKContentNoChange && !hasObservedDOMTimer() && !hasPendingStyleRecalc(m_page);
}
-void ContentChangeObserver::addObservedDOMTimer(const DOMTimer& timer)
-{
- ASSERT(isObservingDOMTimerScheduling());
- if (observedContentChange() == WKContentVisibilityChange)
- return;
- m_DOMTimerList.add(&timer);
-}
-
-void ContentChangeObserver::removeObservedDOMTimer(const DOMTimer& timer)
-{
- m_DOMTimerList.remove(&timer);
- // Force reset the content change flag when the last observed content modifier is removed. We should not be in an indeterminate state anymore.
- if (!countOfObservedDOMTimers() && observedContentChange() == WKContentIndeterminateChange)
- resetObservedContentChange();
-}
-
static Visibility elementImplicitVisibility(const Element& element)
{
auto* renderer = element.renderer();
Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.h (242318 => 242319)
--- trunk/Source/WebCore/page/ios/ContentChangeObserver.h 2019-03-02 22:40:43 UTC (rev 242318)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.h 2019-03-02 22:57:18 UTC (rev 242319)
@@ -40,7 +40,7 @@
WEBCORE_EXPORT void startObservingContentChanges();
WEBCORE_EXPORT void stopObservingContentChanges();
- WEBCORE_EXPORT WKContentChange observedContentChange();
+ WEBCORE_EXPORT WKContentChange observedContentChange() const;
void didInstallDOMTimer(const DOMTimer&, Seconds timeout, bool singleShot);
void didRemoveDOMTimer(const DOMTimer&);
@@ -89,7 +89,7 @@
void startObservingStyleRecalc();
void stopObservingStyleRecalc();
- void addObservedDOMTimer(const DOMTimer&);
+ void addObservedDOMTimer(const DOMTimer& timer) { m_DOMTimerList.add(&timer); }
bool isObservingDOMTimerScheduling() const { return m_isObservingDOMTimerScheduling; }
void removeObservedDOMTimer(const DOMTimer&);
bool containsObservedDOMTimer(const DOMTimer& timer) const { return m_DOMTimerList.contains(&timer); }
@@ -97,15 +97,19 @@
void setShouldObserveStyleRecalc(bool shouldObserve) { m_shouldObserveStyleRecalc = shouldObserve; }
bool shouldObserveStyleRecalc() const { return m_shouldObserveStyleRecalc; }
- void setObservedContentChange(WKContentChange);
- void resetObservedContentChange();
bool isObservingContentChanges() const { return m_isObservingContentChanges; }
- unsigned countOfObservedDOMTimers() const { return m_DOMTimerList.size(); }
void clearObservedDOMTimers() { m_DOMTimerList.clear(); }
-
void clearTimersAndReportContentChange();
+ void setHasIndeterminateState();
+ void setHasVisibleChangeState();
+ void setHasNoChangeState();
+
+ bool hasVisibleChangeState() const { return observedContentChange() == WKContentVisibilityChange; }
+ bool hasObservedDOMTimer() const { return !m_DOMTimerList.isEmpty(); }
+ bool hasDeterminateState() const;
+
Page& m_page;
HashSet<const DOMTimer*> m_DOMTimerList;
bool m_shouldObserveStyleRecalc { false };
@@ -113,5 +117,21 @@
bool m_isObservingContentChanges { false };
};
+inline void ContentChangeObserver::setHasNoChangeState()
+{
+ WKSetObservedContentChange(WKContentNoChange);
}
+
+inline void ContentChangeObserver::setHasIndeterminateState()
+{
+ ASSERT(!hasVisibleChangeState());
+ WKSetObservedContentChange(WKContentIndeterminateChange);
+}
+
+inline void ContentChangeObserver::setHasVisibleChangeState()
+{
+ WKSetObservedContentChange(WKContentVisibilityChange);
+}
+
+}
#endif