Assert that updateStyle and updateLayout are only called when it's safe to dispatch...
[WebKit-https.git] / Source / WebCore / ChangeLog
index 8c3f6bc..fb872b6 100644 (file)
@@ -1,3 +1,45 @@
+2017-11-01  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Assert that updateStyle and updateLayout are only called when it's safe to dispatch events
+        https://bugs.webkit.org/show_bug.cgi?id=179157
+        <rdar://problem/35144778>
+
+        Reviewed by Zalan Bujtas.
+
+        Added assertions to Document::updateStyleIfNeeded and Document::updateLayout that these functions are
+        only called when NoEventDispatchAssertion::isEventAllowedInMainThread() is true with two exceptions:
+        1. Inside SVGImage::draw which triggers a layout on a separate document.
+        2. While doing a nested layout for a frame flattening.
+
+        No new tests since there should be no behavioral changes.
+
+        * dom/ContainerNode.cpp:
+        (NoEventDispatchAssertion::DisableAssertionsInScope::s_existingCount): Deleted. This is now an instance
+        variable of DisableAssertionsInScope.
+        (ContainerNode::removeNodeWithScriptAssertion): Moved childrenChanged out of the scope since it could
+        invoke respondToChangedSelection via HTMLTextAreaElement::childrenChanged.
+        * dom/Document.cpp:
+        (WebCore::Document::updateStyleIfNeeded): Added the assertion. Allow updateWidgetPositions() to call
+        this function but exit early when checking needsStyleRecalc().
+        (WebCore::Document::updateLayout): Added the assertion.
+        * dom/NoEventDispatchAssertion.h:
+        (WebCore::NoEventDispatchAssertion::DisableAssertionsInScope::DisableAssertionsInScope): Made this class
+        store the original value of s_count as an instance variable to support re-entrancy.
+        (WebCore::NoEventDispatchAssertion::DisableAssertionsInScope::~DisableAssertionsInScope): Ditto.
+        * page/LayoutContext.cpp:
+        (WebCore::LayoutContext::runOrScheduleAsynchronousTasks): Temporarily disable the assertion. This is safe
+        since SVGImage has its own document.
+        * svg/SVGSVGElement.cpp:
+        (WebCore::checkIntersectionWithoutUpdatingLayout): Extracted out of SVGSVGElement::checkIntersection.
+        (WebCore::checkEnclosureWithoutUpdatingLayout): Extracted out of SVGSVGElement::checkEnclosure.
+        (WebCore::SVGSVGElement::getIntersectionList): Use checkIntersectionWithoutUpdatingLayout to avoid
+        calling updateLayoutIgnorePendingStylesheets while iterating over elements.
+        (WebCore::SVGSVGElement::getEnclosureList): Ditto.
+        (WebCore::SVGSVGElement::checkIntersection):
+        (WebCore::SVGSVGElement::checkEnclosure):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::draw): Temporarily disable the assertion. This is safe as SVGImage has its own page.
+
 2017-11-02  Alex Christensen  <achristensen@webkit.org>
 
         Fix Windows debug build after r224371