Title: [101736] trunk/Source/WebCore
Revision
101736
Author
[email protected]
Date
2011-12-01 19:39:11 -0800 (Thu, 01 Dec 2011)

Log Message

[MutationObservers] StyleAttributeMutationScope shouldn't be implemented with static classes
https://bugs.webkit.org/show_bug.cgi?id=73596

Patch by Rafael Weinstein <[email protected]> on 2011-12-01
Reviewed by Ojan Vafai.

No tests needed. This patch is a minor refactor.

* css/CSSMutableStyleDeclaration.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101735 => 101736)


--- trunk/Source/WebCore/ChangeLog	2011-12-02 03:31:20 UTC (rev 101735)
+++ trunk/Source/WebCore/ChangeLog	2011-12-02 03:39:11 UTC (rev 101736)
@@ -1,3 +1,14 @@
+2011-12-01  Rafael Weinstein  <[email protected]>
+
+        [MutationObservers] StyleAttributeMutationScope shouldn't be implemented with static classes
+        https://bugs.webkit.org/show_bug.cgi?id=73596
+
+        Reviewed by Ojan Vafai.
+
+        No tests needed. This patch is a minor refactor.
+
+        * css/CSSMutableStyleDeclaration.cpp:
+
 2011-12-01  Andreas Kling  <[email protected]>
 
         CSSMutableStyleDeclaration: Remove unused function setStringProperty().

Modified: trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp (101735 => 101736)


--- trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp	2011-12-02 03:31:20 UTC (rev 101735)
+++ trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp	2011-12-02 03:39:11 UTC (rev 101736)
@@ -67,43 +67,44 @@
             return;
 
         CSSInlineStyleDeclaration* inlineDecl = toCSSInlineStyleDeclaration(s_currentDecl);
-        s_mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(inlineDecl->element(), HTMLNames::styleAttr);
-        if (s_mutationRecipients->isEmpty()) {
-            s_mutationRecipients.clear();
+        m_mutationRecipients = MutationObserverInterestGroup::createForAttributesMutation(inlineDecl->element(), HTMLNames::styleAttr);
+        if (m_mutationRecipients->isEmpty()) {
+            m_mutationRecipients.clear();
             return;
         }
 
-        AtomicString oldValue = s_mutationRecipients->isOldValueRequested() ? inlineDecl->element()->getAttribute(HTMLNames::styleAttr) : nullAtom;
-        s_mutation = MutationRecord::createAttributes(inlineDecl->element(), HTMLNames::styleAttr, oldValue);
+        AtomicString oldValue = m_mutationRecipients->isOldValueRequested() ? inlineDecl->element()->getAttribute(HTMLNames::styleAttr) : nullAtom;
+        m_mutation = MutationRecord::createAttributes(inlineDecl->element(), HTMLNames::styleAttr, oldValue);
     }
 
     ~StyleAttributeMutationScope()
     {
         --s_scopeCount;
-        if (!s_scopeCount)
-            s_currentDecl = 0;
+        if (s_scopeCount)
+            return;
+
+        s_currentDecl = 0;
+        if (m_mutation && s_shouldDeliver)
+            m_mutationRecipients->enqueueMutationRecord(m_mutation);
     }
 
     void enqueueMutationRecord()
     {
-        if (!s_mutation)
-            return;
-        s_mutationRecipients->enqueueMutationRecord(s_mutation);
-        s_mutation.clear();
-        s_mutationRecipients.clear();
+        s_shouldDeliver = true;
     }
 
 private:
     static unsigned s_scopeCount;
-    static OwnPtr<MutationObserverInterestGroup> s_mutationRecipients;
-    static RefPtr<MutationRecord> s_mutation;
     static CSSMutableStyleDeclaration* s_currentDecl;
+    static bool s_shouldDeliver;
+
+    OwnPtr<MutationObserverInterestGroup> m_mutationRecipients;
+    RefPtr<MutationRecord> m_mutation;
 };
 
 unsigned StyleAttributeMutationScope::s_scopeCount = 0;
-OwnPtr<MutationObserverInterestGroup> StyleAttributeMutationScope::s_mutationRecipients;
-RefPtr<MutationRecord> StyleAttributeMutationScope::s_mutation;
 CSSMutableStyleDeclaration* StyleAttributeMutationScope::s_currentDecl = 0;
+bool StyleAttributeMutationScope::s_shouldDeliver = false;
 
 } // namespace
 #endif // ENABLE(MUTATION_OBSERVERS)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to