Changeset 199003 in webkit


Ignore:
Timestamp:
Apr 4, 2016 5:56:33 AM (8 years ago)
Author:
Antti Koivisto
Message:

Enable assertions against DOM mutations in RenderTreeUpdater
https://bugs.webkit.org/show_bug.cgi?id=156156

Reviewed by Andreas Kling.

Ensure we don't mutate DOM or dispatch events during render tree updates.

  • WebCore.xcodeproj/project.pbxproj:
  • dom/ContainerNode.cpp:
  • dom/ContainerNode.h:

(WebCore::NoEventDispatchAssertion::NoEventDispatchAssertion): Deleted.
(WebCore::NoEventDispatchAssertion::~NoEventDispatchAssertion): Deleted.
(WebCore::NoEventDispatchAssertion::isEventDispatchForbidden): Deleted.

Move NoEventDispatchAssertion to a header of its own.

  • dom/NoEventDispatchAssertion.h: Added.

(WebCore::NoEventDispatchAssertion::NoEventDispatchAssertion):
(WebCore::NoEventDispatchAssertion::~NoEventDispatchAssertion):
(WebCore::NoEventDispatchAssertion::isEventDispatchForbidden):
(WebCore::NoEventDispatchAssertion::dropTemporarily):
(WebCore::NoEventDispatchAssertion::restoreDropped):

Add a way to disable event assertions temporarily.

  • loader/cache/CachedSVGFont.cpp:

(WebCore::CachedSVGFont::ensureCustomFontData):

Temporary SVG font document may get constructed during render tree update. These can't run scripts or generally
affect anything outside the font document as it does not have a frame. Disable event assertions temporarily.

Tested by svg/W3C-SVG-1.1/fonts-elem-07-b.svg

  • style/RenderTreeUpdater.cpp:

(WebCore::RenderTreeUpdater::updateRenderTree):

Enable assertions.

Location:
trunk/Source/WebCore
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r199001 r199003  
     12016-04-04  Antti Koivisto  <antti@apple.com>
     2
     3        Enable assertions against DOM mutations in RenderTreeUpdater
     4        https://bugs.webkit.org/show_bug.cgi?id=156156
     5
     6        Reviewed by Andreas Kling.
     7
     8        Ensure we don't mutate DOM or dispatch events during render tree updates.
     9
     10        * WebCore.xcodeproj/project.pbxproj:
     11        * dom/ContainerNode.cpp:
     12        * dom/ContainerNode.h:
     13        (WebCore::NoEventDispatchAssertion::NoEventDispatchAssertion): Deleted.
     14        (WebCore::NoEventDispatchAssertion::~NoEventDispatchAssertion): Deleted.
     15        (WebCore::NoEventDispatchAssertion::isEventDispatchForbidden): Deleted.
     16
     17            Move NoEventDispatchAssertion to a header of its own.
     18
     19        * dom/NoEventDispatchAssertion.h: Added.
     20        (WebCore::NoEventDispatchAssertion::NoEventDispatchAssertion):
     21        (WebCore::NoEventDispatchAssertion::~NoEventDispatchAssertion):
     22        (WebCore::NoEventDispatchAssertion::isEventDispatchForbidden):
     23        (WebCore::NoEventDispatchAssertion::dropTemporarily):
     24        (WebCore::NoEventDispatchAssertion::restoreDropped):
     25
     26            Add a way to disable event assertions temporarily.
     27
     28        * loader/cache/CachedSVGFont.cpp:
     29        (WebCore::CachedSVGFont::ensureCustomFontData):
     30
     31            Temporary SVG font document may get constructed during render tree update. These can't run scripts or generally
     32            affect anything outside the font document as it does not have a frame. Disable event assertions temporarily.
     33
     34            Tested by svg/W3C-SVG-1.1/fonts-elem-07-b.svg
     35
     36        * style/RenderTreeUpdater.cpp:
     37        (WebCore::RenderTreeUpdater::updateRenderTree):
     38
     39            Enable assertions.
     40
    1412016-04-04  Emanuele Aina  <emanuele.aina@collabora.com>
    242
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r198943 r199003  
    66266626                E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    66276627                E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     6628                E46B41F91CB24E70008F11DE /* NoEventDispatchAssertion.h in Headers */ = {isa = PBXBuildFile; fileRef = E46B41F81CB24E70008F11DE /* NoEventDispatchAssertion.h */; settings = {ATTRIBUTES = (Private, ); }; };
    66286629                E47127CA163438A100ED6F5A /* StyleInvalidationAnalysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47A97CE163059FC005DCD99 /* StyleInvalidationAnalysis.cpp */; };
    66296630                E47127CB163438AE00ED6F5A /* StyleInvalidationAnalysis.h in Headers */ = {isa = PBXBuildFile; fileRef = E47A97CF163059FC005DCD99 /* StyleInvalidationAnalysis.h */; };
     
    1465814659                E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedElementDescendantIterator.h; sourceTree = "<group>"; };
    1465914660                E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementChildIterator.h; sourceTree = "<group>"; };
     14661                E46B41F81CB24E70008F11DE /* NoEventDispatchAssertion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoEventDispatchAssertion.h; sourceTree = "<group>"; };
    1466014662                E4778B7D115A581A00B5D372 /* JSCustomEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomEvent.cpp; sourceTree = "<group>"; };
    1466114663                E4778B7E115A581A00B5D372 /* JSCustomEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomEvent.h; sourceTree = "<group>"; };
     
    2442124423                                E43105BA16750F1600DB2FB8 /* NodeTraversal.h */,
    2442224424                                9382AAB10D8C386100F357A6 /* NodeWithIndex.h */,
     24425                                E46B41F81CB24E70008F11DE /* NoEventDispatchAssertion.h */,
    2442324426                                8369E58F1AFDD0300087DF68 /* NonDocumentTypeChildNode.idl */,
    2442424427                                7C6752BA1B06E82000C279CB /* NonElementParentNode.idl */,
     
    2630726310                                5185FC9B1BB4C4E80012898F /* IDBKeyRange.h in Headers */,
    2630826311                                5185FC9E1BB4C4E80012898F /* IDBKeyRangeData.h in Headers */,
     26312                                E46B41F91CB24E70008F11DE /* NoEventDispatchAssertion.h in Headers */,
    2630926313                                5185FCA01BB4C4E80012898F /* IDBObjectStore.h in Headers */,
    2631026314                                5160712F1BD8307800DBC4F2 /* IDBObjectStoreInfo.h in Headers */,
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r196888 r199003  
    4343#include "MutationEvent.h"
    4444#include "NameNodeList.h"
     45#include "NoEventDispatchAssertion.h"
    4546#include "NodeOrString.h"
    4647#include "NodeRareData.h"
  • trunk/Source/WebCore/dom/ContainerNode.h

    r197887 r199003  
    3434class RadioNodeList;
    3535class RenderElement;
    36 
    37 class NoEventDispatchAssertion {
    38 public:
    39     NoEventDispatchAssertion()
    40     {
    41 #if !ASSERT_DISABLED
    42         if (!isMainThread())
    43             return;
    44         ++s_count;
    45 #endif
    46     }
    47 
    48     NoEventDispatchAssertion(const NoEventDispatchAssertion&)
    49         : NoEventDispatchAssertion()
    50     {
    51     }
    52 
    53     ~NoEventDispatchAssertion()
    54     {
    55 #if !ASSERT_DISABLED
    56         if (!isMainThread())
    57             return;
    58         ASSERT(s_count);
    59         s_count--;
    60 #endif
    61     }
    62 
    63     static bool isEventDispatchForbidden()
    64     {
    65 #if ASSERT_DISABLED
    66         return false;
    67 #else
    68         return isMainThread() && s_count;
    69 #endif
    70     }
    71 
    72 #if !ASSERT_DISABLED
    73 
    74 private:
    75     WEBCORE_EXPORT static unsigned s_count;
    76 
    77 #endif
    78 };
    7936
    8037class ContainerNode : public Node {
  • trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp

    r191955 r199003  
    2727#include "ContainerNodeAlgorithms.h"
    2828
     29#include "NoEventDispatchAssertion.h"
    2930
    3031namespace WebCore {
  • trunk/Source/WebCore/dom/Document.cpp

    r198943 r199003  
    117117#include "NameNodeList.h"
    118118#include "NestingLevelIncrementer.h"
     119#include "NoEventDispatchAssertion.h"
    119120#include "NodeIterator.h"
    120121#include "NodeRareData.h"
  • trunk/Source/WebCore/dom/Element.cpp

    r198992 r199003  
    6767#include "MutationObserverInterestGroup.h"
    6868#include "MutationRecord.h"
     69#include "NoEventDispatchAssertion.h"
    6970#include "NodeRenderStyle.h"
    7071#include "PlatformWheelEvent.h"
  • trunk/Source/WebCore/dom/ElementIteratorAssertions.h

    r196281 r199003  
    2828
    2929#include "Element.h"
     30#include "NoEventDispatchAssertion.h"
    3031
    3132namespace WebCore {
  • trunk/Source/WebCore/dom/EventDispatcher.cpp

    r198483 r199003  
    3232#include "HTMLInputElement.h"
    3333#include "MouseEvent.h"
     34#include "NoEventDispatchAssertion.h"
    3435#include "PseudoElement.h"
    3536#include "ScopedEventQueue.h"
  • trunk/Source/WebCore/dom/EventTarget.cpp

    r196520 r199003  
    3535#include "ExceptionCode.h"
    3636#include "InspectorInstrumentation.h"
     37#include "NoEventDispatchAssertion.h"
    3738#include "ScriptController.h"
    3839#include "WebKitAnimationEvent.h"
  • trunk/Source/WebCore/dom/Node.cpp

    r198992 r199003  
    5252#include "Logging.h"
    5353#include "MutationEvent.h"
     54#include "NoEventDispatchAssertion.h"
    5455#include "NodeOrString.h"
    5556#include "NodeRenderStyle.h"
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r197690 r199003  
    3535#include "ErrorEvent.h"
    3636#include "MessagePort.h"
     37#include "NoEventDispatchAssertion.h"
    3738#include "PublicURLManager.h"
    3839#include "Settings.h"
  • trunk/Source/WebCore/dom/WebKitNamedFlow.cpp

    r194324 r199003  
    3232
    3333#include "NamedFlowCollection.h"
     34#include "NoEventDispatchAssertion.h"
    3435#include "RenderNamedFlowFragment.h"
    3536#include "RenderNamedFlowThread.h"
  • trunk/Source/WebCore/history/PageCache.cpp

    r198924 r199003  
    4747#include "MainFrame.h"
    4848#include "MemoryPressureHandler.h"
     49#include "NoEventDispatchAssertion.h"
    4950#include "Page.h"
    5051#include "Settings.h"
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r198901 r199003  
    6969#include "MemoryPressureHandler.h"
    7070#include "NetworkingContext.h"
     71#include "NoEventDispatchAssertion.h"
    7172#include "PageGroup.h"
    7273#include "PageThrottler.h"
  • trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp

    r198074 r199003  
    3232#include "FontDescription.h"
    3333#include "FontPlatformData.h"
     34#include "NoEventDispatchAssertion.h"
    3435#include "SVGDocument.h"
    3536#include "SVGFontElement.h"
     
    6566{
    6667    if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) {
     68        // We may get here during render tree updates when events are forbidden.
     69        // Frameless document can't run scripts or call back to the client so this is safe.
     70        auto count = NoEventDispatchAssertion::dropTemporarily();
     71
    6772        m_externalSVGDocument = SVGDocument::create(nullptr, URL());
    6873        RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml");
    6974        m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size()));
     75
     76        NoEventDispatchAssertion::restoreDropped(count);
     77
    7078        if (decoder->sawError())
    7179            m_externalSVGDocument = nullptr;
  • trunk/Source/WebCore/style/RenderTreeUpdater.cpp

    r198992 r199003  
    110110    auto end = descendants.end();
    111111
    112     // FIXME: SVG <use> element may cause tree mutations during style recalc.
    113     it.dropAssertions();
    114 
    115112    while (it != end) {
    116113        popParentsToDepth(it.depth());
Note: See TracChangeset for help on using the changeset viewer.