Changeset 224131 in webkit


Ignore:
Timestamp:
Oct 27, 2017 2:35:14 PM (7 years ago)
Author:
Ryan Haddad
Message:

Unreviewed, rolling out r224011.

xsl LayoutTests hit an assertion added with this change since
r223999 was rolled out.

Reverted changeset:

"Assert that no script is executed during style recalc"
https://bugs.webkit.org/show_bug.cgi?id=178845
https://trac.webkit.org/changeset/224011

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r224128 r224131  
     12017-10-27  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r224011.
     4
     5        xsl LayoutTests hit an assertion added with this change since
     6        r223999 was rolled out.
     7
     8        Reverted changeset:
     9
     10        "Assert that no script is executed during style recalc"
     11        https://bugs.webkit.org/show_bug.cgi?id=178845
     12        https://trac.webkit.org/changeset/224011
     13
    1142017-10-27  Antoine Quint  <graouts@apple.com>
    215
  • trunk/Source/WebCore/dom/Document.cpp

    r224116 r224131  
    17901790    // hits a null-dereference due to security code always assuming the document has a SecurityOrigin.
    17911791
    1792     {
    1793         NoEventDispatchAssertion noEventDispatchAssertion;
    1794         styleScope().flushPendingUpdate();
    1795         frameView.willRecalcStyle();
    1796     }
     1792    styleScope().flushPendingUpdate();
     1793
     1794    frameView.willRecalcStyle();
    17971795
    17981796    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(*this);
    17991797
     1798    m_inStyleRecalc = true;
    18001799    bool updatedCompositingLayers = false;
    18011800    {
    18021801        Style::PostResolutionCallbackDisabler disabler(*this);
    18031802        WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
    1804         NoEventDispatchAssertion noEventDispatchAssertion;
    1805 
    1806         m_inStyleRecalc = true;
    18071803
    18081804        if (m_pendingStyleRecalcShouldForce)
     
    18531849        if (m_renderView->needsLayout())
    18541850            frameView.scheduleRelayout();
    1855 
    1856         // Usually this is handled by post-layout.
    1857         if (!frameView.needsLayout())
    1858             frameView.frame().selection().scheduleAppearanceUpdateAfterStyleChange();
    1859 
    1860         // As a result of the style recalculation, the currently hovered element might have been
    1861         // detached (for example, by setting display:none in the :hover style), schedule another mouseMove event
    1862         // to check if any other elements ended up under the mouse pointer due to re-layout.
    1863         if (m_hoveredElement && !m_hoveredElement->renderer())
    1864             frameView.frame().mainFrame().eventHandler().dispatchFakeMouseMoveEventSoon();
    1865 
    1866         ++m_styleRecalcCount;
    1867         // FIXME: Assert ASSERT(!needsStyleRecalc()) here. Do we still have some cases where it's not true?
    18681851    }
    18691852
     
    18731856        implicitClose();
    18741857    }
     1858   
     1859    ++m_styleRecalcCount;
    18751860
    18761861    InspectorInstrumentation::didRecalculateStyle(cookie);
     
    18821867        frameView.viewportContentsChanged();
    18831868
     1869    // Usually this is handled by post-layout.
     1870    if (!frameView.needsLayout())
     1871        frameView.frame().selection().scheduleAppearanceUpdateAfterStyleChange();
     1872
     1873    // As a result of the style recalculation, the currently hovered element might have been
     1874    // detached (for example, by setting display:none in the :hover style), schedule another mouseMove event
     1875    // to check if any other elements ended up under the mouse pointer due to re-layout.
     1876    if (m_hoveredElement && !m_hoveredElement->renderer())
     1877        frameView.frame().mainFrame().eventHandler().dispatchFakeMouseMoveEventSoon();
     1878
    18841879    if (m_gotoAnchorNeededAfterStylesheetsLoad && !styleScope().hasPendingSheets())
    18851880        frameView.scrollToFragment(m_url);
     1881
     1882    // FIXME: Ideally we would ASSERT(!needsStyleRecalc()) here but we have some cases where it is not true.
    18861883}
    18871884
     
    19211918bool Document::updateStyleIfNeeded()
    19221919{
    1923     {
    1924         NoEventDispatchAssertion noEventDispatchAssertion;
    1925         ASSERT(isMainThread());
    1926         ASSERT(!view() || !view()->isPainting());
    1927 
    1928         if (!view() || view()->isInRenderTreeLayout())
    1929             return false;
    1930 
    1931         styleScope().flushPendingUpdate();
    1932 
    1933         if (!needsStyleRecalc())
    1934             return false;
    1935     }
     1920    ASSERT(isMainThread());
     1921    ASSERT(!view() || !view()->isPainting());
     1922
     1923    if (!view() || view()->isInRenderTreeLayout())
     1924        return false;
     1925
     1926    styleScope().flushPendingUpdate();
     1927
     1928    if (!needsStyleRecalc())
     1929        return false;
    19361930
    19371931    resolveStyle();
  • trunk/Source/WebCore/dom/Element.cpp

    r224053 r224131  
    342342{
    343343    Ref<Element> clone = cloneElementWithoutChildren(targetDocument);
    344 
    345     // It's safe to dispatch events on the cloned node since author scripts have no access to it yet.
    346     // This is needed for SVGUseElement::cloneTarget.
    347     NoEventDispatchAssertion::EventAllowedScope allowedScope(clone.get());
    348 
    349344    cloneChildNodes(clone);
    350345    return clone;
     
    354349{
    355350    Ref<Element> clone = cloneElementWithoutAttributesAndChildren(targetDocument);
    356 
    357     // It's safe to dispatch events on the cloned node since author scripts have no access to it yet.
    358     // This is needed for SVGUseElement::cloneTarget.
    359     NoEventDispatchAssertion::EventAllowedScope allowedScope(clone.get());
    360 
    361351    // This will catch HTML elements in the wrong namespace that are not correctly copied.
    362352    // This is a sanity check as HTML overloads some of the DOM methods.
  • trunk/Source/WebCore/dom/EventDispatcher.cpp

    r224011 r224131  
    131131bool EventDispatcher::dispatchEvent(Node& node, Event& event)
    132132{
    133     ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::isEventDispatchAllowedInSubtree(node));
     133    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::isEventAllowedInMainThread());
    134134    Ref<Node> protectedNode(node);
    135135    RefPtr<FrameView> view = node.document().view();
     
    149149    if (!event.target())
    150150        return true;
     151
     152    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::isEventAllowedInMainThread());
    151153
    152154    InputElementClickState clickHandlingState;
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r224011 r224131  
    217217{
    218218    if (auto root = userAgentShadowRoot()) {
    219         // Safe because SVG use element's shadow tree is never used to fire synchronous events during layout or DOM mutations.
    220219        NoEventDispatchAssertion::EventAllowedScope scope(*root);
    221220        root->removeChildren();
     
    245244    }
    246245
    247     {
    248         // Safe because the cloned shadow tree has never been exposed to author scripts.
    249         auto& shadowRoot = ensureUserAgentShadowRoot();
    250         NoEventDispatchAssertion::EventAllowedScope scope(shadowRoot);
    251         cloneTarget(shadowRoot, *target);
    252         expandUseElementsInShadowTree();
    253         expandSymbolElementsInShadowTree();
    254         updateRelativeLengthsInformation();
    255     }
    256 
     246    cloneTarget(ensureUserAgentShadowRoot(), *target);
     247    expandUseElementsInShadowTree();
     248    expandSymbolElementsInShadowTree();
    257249    transferEventListenersToShadowTree();
     250
     251    updateRelativeLengthsInformation();
    258252
    259253    // When we invalidate the other shadow trees, it's important that we don't
     
    437431{
    438432    Ref<SVGElement> targetClone = static_cast<SVGElement&>(target.cloneElementWithChildren(document()).get());
    439     // Safe because the newy cloned nodes in the shadow tree has not been exposed to author scripts yet.
    440     NoEventDispatchAssertion::EventAllowedScope scope(targetClone);
    441433    associateClonesWithOriginals(targetClone.get(), target);
    442434    removeDisallowedElementsFromSubtree(targetClone.get());
     
    471463
    472464        auto replacementClone = SVGGElement::create(document());
    473         // Safe because the use element's shadow tree is not exposed to author scripts, and we don't fire synchronous events during layout & DOM layout.
    474         NoEventDispatchAssertion::EventAllowedScope scope(replacementClone);
    475 
    476465        cloneDataAndChildren(replacementClone.get(), originalClone);
    477466
     
    507496
    508497        auto replacementClone = SVGSVGElement::create(document());
    509         // Safe because the newly created SVG element and the newly created shadow tree has not been exposed to author scripts yet.
    510         NoEventDispatchAssertion::EventAllowedScope scope(replacementClone);
    511498        cloneDataAndChildren(replacementClone.get(), originalClone);
    512499
     
    520507void SVGUseElement::transferEventListenersToShadowTree() const
    521508{
    522     // FIXME: Don't directly add event listeners on each descendant. Copy event listeners on the use element instead.
    523509    for (auto& descendant : descendantsOfType<SVGElement>(*userAgentShadowRoot())) {
    524510        if (EventTargetData* data = descendant.correspondingElement()->eventTargetData())
Note: See TracChangeset for help on using the changeset viewer.