Add more assertions to find root cause for release assert hit in StyleResolver
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2019 16:03:31 +0000 (16:03 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2019 16:03:31 +0000 (16:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193488
<rdar://problem/30983040>

Reviewed by Zalan Bujtas.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::~StyleResolver):

Release assert we are not resolving tree style.

* dom/Document.cpp:
(WebCore::Document::setIsResolvingTreeStyle):
* dom/Document.h:
(WebCore::Document::isResolvingTreeStyle const):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::Scope::Scope):
(WebCore::Style::TreeResolver::Scope::~Scope):

Set isResolvingTreeStyle bit when we have a tree resolver scope.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240037 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/style/StyleTreeResolver.cpp

index 9552883..ebfe83d 100644 (file)
@@ -1,3 +1,26 @@
+2019-01-16  Antti Koivisto  <antti@apple.com>
+
+        Add more assertions to find root cause for release assert hit in StyleResolver
+        https://bugs.webkit.org/show_bug.cgi?id=193488
+        <rdar://problem/30983040>
+
+        Reviewed by Zalan Bujtas.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::~StyleResolver):
+
+        Release assert we are not resolving tree style.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setIsResolvingTreeStyle):
+        * dom/Document.h:
+        (WebCore::Document::isResolvingTreeStyle const):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::Scope::Scope):
+        (WebCore::Style::TreeResolver::Scope::~Scope):
+
+        Set isResolvingTreeStyle bit when we have a tree resolver scope.
+
 2019-01-16  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][Out-of-flow] Set used vertical margin values when top/height/bottom are non-auto.
index bfcc624..9423ed0 100644 (file)
@@ -267,6 +267,7 @@ void StyleResolver::addKeyframeStyle(Ref<StyleRuleKeyframes>&& rule)
 
 StyleResolver::~StyleResolver()
 {
+    RELEASE_ASSERT(!m_document.isResolvingTreeStyle());
     RELEASE_ASSERT(!m_isDeleted);
     m_isDeleted = true;
 
index fe5c951..67eb1a1 100644 (file)
@@ -2326,6 +2326,12 @@ void Document::didClearStyleResolver()
     m_userAgentShadowTreeStyleResolver = nullptr;
 }
 
+void Document::setIsResolvingTreeStyle(bool value)
+{
+    RELEASE_ASSERT(value != m_isResolvingTreeStyle);
+    m_isResolvingTreeStyle = value;
+}
+
 void Document::createRenderTree()
 {
     ASSERT(!renderView());
index eb44551..308929e 100644 (file)
@@ -1334,6 +1334,8 @@ public:
 
     bool inStyleRecalc() const { return m_inStyleRecalc; }
     bool inRenderTreeUpdate() const { return m_inRenderTreeUpdate; }
+    bool isResolvingTreeStyle() const { return m_isResolvingTreeStyle; }
+    void setIsResolvingTreeStyle(bool);
 
     void updateTextRenderer(Text&, unsigned offsetOfReplacedText, unsigned lengthOfReplacedText);
 
@@ -2017,6 +2019,7 @@ private:
     bool m_inStyleRecalc { false };
     bool m_closeAfterStyleRecalc { false };
     bool m_inRenderTreeUpdate { false };
+    bool m_isResolvingTreeStyle { false };
 
     bool m_gotoAnchorNeededAfterStylesheetsLoad { false };
     bool m_isDNSPrefetchEnabled { false };
index 34f8f3c..1b134df 100644 (file)
@@ -67,6 +67,7 @@ TreeResolver::Scope::Scope(Document& document)
     : styleResolver(document.styleScope().resolver())
     , sharingResolver(document, styleResolver.ruleSets(), selectorFilter)
 {
+    document.setIsResolvingTreeStyle(true);
 }
 
 TreeResolver::Scope::Scope(ShadowRoot& shadowRoot, Scope& enclosingScope)
@@ -80,6 +81,9 @@ TreeResolver::Scope::Scope(ShadowRoot& shadowRoot, Scope& enclosingScope)
 
 TreeResolver::Scope::~Scope()
 {
+    if (!shadowRoot)
+        styleResolver.document().setIsResolvingTreeStyle(false);
+
     styleResolver.setOverrideDocumentElementStyle(nullptr);
 }