Changeset 102264 in webkit


Ignore:
Timestamp:
Dec 7, 2011 12:03:50 PM (12 years ago)
Author:
adamk@chromium.org
Message:

Layout Test inspector/debugger/dom-breakpoints.html fails on chromium linux debug with ENABLE(MUTATION_OBSERVERS)
https://bugs.webkit.org/show_bug.cgi?id=73919

Reviewed by Ojan Vafai.

Source/WebCore:

Use StyleAttributeMutationScope to manage DOM breakpoints for style property changes.

Instead of calling InspectorInstrumentation::didInvalidateStyleAttr()
directly in setNeedsStyleRecalc, set a bool in the current
StyleAttributeMutationScope, and delay the call until the scope's
counter runs down to zero. This keeps the inspector JS from re-entering
CSSMutableStyleDeclaration until all StyleAttributeMutationScope work is done.

Also fix a small bug in StyleAttributeMutationScope, where
s_shouldDeliver wasn't getting reset properly to false.

  • css/CSSMutableStyleDeclaration.cpp:

(WebCore::CSSMutableStyleDeclaration::setNeedsStyleRecalc):

LayoutTests:

Added test that no-op style mutations don't create MutationRecords.

  • fast/mutation/observe-attributes-expected.txt:
  • fast/mutation/observe-attributes.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r102263 r102264  
     12011-12-07  Adam Klein  <adamk@chromium.org>
     2
     3        Layout Test inspector/debugger/dom-breakpoints.html fails on chromium linux debug with ENABLE(MUTATION_OBSERVERS)
     4        https://bugs.webkit.org/show_bug.cgi?id=73919
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Added test that no-op style mutations don't create MutationRecords.
     9
     10        * fast/mutation/observe-attributes-expected.txt:
     11        * fast/mutation/observe-attributes.html:
     12
    1132011-12-07  Ken Buchanan <kenrb@chromium.org>
    214
  • trunk/LayoutTests/fast/mutation/observe-attributes-expected.txt

    r102100 r102264  
    187187PASS mutations is null
    188188
     189Testing that a no-op style property mutation does not create Mutation Records.
     190PASS mutations is null
     191
    189192PASS successfullyParsed is true
    190193
  • trunk/LayoutTests/fast/mutation/observe-attributes.html

    r102100 r102264  
    653653
    654654function testStyleAttributePropertyAccess() {
    655     var svgDoc, div, path;
     655    var div, path;
    656656    var observer;
    657657
     
    705705
    706706function testStyleAttributePropertyAccessOldValue() {
    707     var svgDoc, div, path;
     707    var div, path;
    708708    var observer;
    709709
     
    746746        debug('...mutation record created.');
    747747
     748        shouldBe('mutations', 'null');
     749
     750        observer.disconnect();
     751        debug('');
     752        runNextTest();
     753    }
     754
     755    start();
     756}
     757
     758function testStyleAttributePropertyAccessIgnoreNoop() {
     759    var div, path;
     760    var observer;
     761
     762    function start() {
     763        debug('Testing that a no-op style property mutation does not create Mutation Records.');
     764
     765        mutations = null;
     766        observer = new WebKitMutationObserver(function(m) {
     767            mutations = m;
     768        });
     769
     770        div = document.createElement('div');
     771        div.setAttribute('style', 'color: yellow; width: 100px; ');
     772        observer.observe(div, { attributes: true });
     773        div.style.removeProperty('height');
     774
     775        setTimeout(finish, 0);
     776    }
     777
     778    function finish() {
    748779        shouldBe('mutations', 'null');
    749780
     
    773804    testAttributeFilterNonHTMLDocument,
    774805    testStyleAttributePropertyAccess,
    775     testStyleAttributePropertyAccessOldValue
     806    testStyleAttributePropertyAccessOldValue,
     807    testStyleAttributePropertyAccessIgnoreNoop
    776808];
    777809var testIndex = 0;
  • trunk/Source/WebCore/ChangeLog

    r102263 r102264  
     12011-12-07  Adam Klein  <adamk@chromium.org>
     2
     3        Layout Test inspector/debugger/dom-breakpoints.html fails on chromium linux debug with ENABLE(MUTATION_OBSERVERS)
     4        https://bugs.webkit.org/show_bug.cgi?id=73919
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Use StyleAttributeMutationScope to manage DOM breakpoints for style property changes.
     9
     10        Instead of calling InspectorInstrumentation::didInvalidateStyleAttr()
     11        directly in setNeedsStyleRecalc, set a bool in the current
     12        StyleAttributeMutationScope, and delay the call until the scope's
     13        counter runs down to zero. This keeps the inspector JS from re-entering
     14        CSSMutableStyleDeclaration until all StyleAttributeMutationScope work is done.
     15
     16        Also fix a small bug in StyleAttributeMutationScope, where
     17        s_shouldDeliver wasn't getting reset properly to false.
     18
     19        * css/CSSMutableStyleDeclaration.cpp:
     20        (WebCore::CSSMutableStyleDeclaration::setNeedsStyleRecalc):
     21
    1222011-12-07  Ken Buchanan <kenrb@chromium.org>
    223
  • trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp

    r101970 r102264  
    4646namespace WebCore {
    4747
    48 #if ENABLE(MUTATION_OBSERVERS)
    4948namespace {
    5049
     
    6463        s_currentDecl = decl;
    6564
     65#if ENABLE(MUTATION_OBSERVERS)
    6666        if (!s_currentDecl->isInlineStyleDeclaration())
    6767            return;
     
    7676        AtomicString oldValue = m_mutationRecipients->isOldValueRequested() ? inlineDecl->element()->getAttribute(HTMLNames::styleAttr) : nullAtom;
    7777        m_mutation = MutationRecord::createAttributes(inlineDecl->element(), HTMLNames::styleAttr, oldValue);
     78#endif
    7879    }
    7980
     
    8485            return;
    8586
    86         s_currentDecl = 0;
     87#if ENABLE(MUTATION_OBSERVERS)
    8788        if (m_mutation && s_shouldDeliver)
    8889            m_mutationRecipients->enqueueMutationRecord(m_mutation);
    89     }
    90 
     90        s_shouldDeliver = false;
     91#endif
     92
     93        if (!s_shouldNotifyInspector) {
     94            s_currentDecl = 0;
     95            return;
     96        }
     97
     98        CSSInlineStyleDeclaration* inlineDecl = toCSSInlineStyleDeclaration(s_currentDecl);
     99        s_currentDecl = 0;
     100        s_shouldNotifyInspector = false;
     101        if (inlineDecl->element()->document())
     102            InspectorInstrumentation::didInvalidateStyleAttr(inlineDecl->element()->document(), inlineDecl->element());
     103    }
     104
     105#if ENABLE(MUTATION_OBSERVERS)
    91106    void enqueueMutationRecord()
    92107    {
    93108        s_shouldDeliver = true;
    94109    }
     110#endif
     111
     112    void didInvalidateStyleAttr()
     113    {
     114        ASSERT(s_currentDecl->isInlineStyleDeclaration());
     115        s_shouldNotifyInspector = true;
     116    }
    95117
    96118private:
    97119    static unsigned s_scopeCount;
    98120    static CSSMutableStyleDeclaration* s_currentDecl;
     121    static bool s_shouldNotifyInspector;
     122#if ENABLE(MUTATION_OBSERVERS)
    99123    static bool s_shouldDeliver;
    100124
    101125    OwnPtr<MutationObserverInterestGroup> m_mutationRecipients;
    102126    RefPtr<MutationRecord> m_mutation;
     127#endif
    103128};
    104129
    105130unsigned StyleAttributeMutationScope::s_scopeCount = 0;
    106131CSSMutableStyleDeclaration* StyleAttributeMutationScope::s_currentDecl = 0;
     132bool StyleAttributeMutationScope::s_shouldNotifyInspector = false;
     133#if ENABLE(MUTATION_OBSERVERS)
    107134bool StyleAttributeMutationScope::s_shouldDeliver = false;
     135#endif
    108136
    109137} // namespace
    110 #endif // ENABLE(MUTATION_OBSERVERS)
    111138
    112139CSSMutableStyleDeclaration::CSSMutableStyleDeclaration()
     
    621648            element->setNeedsStyleRecalc(InlineStyleChange);
    622649            element->invalidateStyleAttribute();
    623             if (Document* document = element->document())
    624                 InspectorInstrumentation::didInvalidateStyleAttr(document, element);
     650            StyleAttributeMutationScope(this).didInvalidateStyleAttr();
    625651        }
    626652        return;
Note: See TracChangeset for help on using the changeset viewer.