Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: Source/core/css/RuleFeature.cpp

Issue 664033002: [Invalidation Tracking] Trace ScheduleStyleInvalidation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: no regression :) Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/inspector/InspectorTraceEvents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 19 matching lines...) Expand all
30 #include "core/css/RuleFeature.h" 30 #include "core/css/RuleFeature.h"
31 31
32 #include "core/HTMLNames.h" 32 #include "core/HTMLNames.h"
33 #include "core/css/CSSSelector.h" 33 #include "core/css/CSSSelector.h"
34 #include "core/css/CSSSelectorList.h" 34 #include "core/css/CSSSelectorList.h"
35 #include "core/css/RuleSet.h" 35 #include "core/css/RuleSet.h"
36 #include "core/css/StyleRule.h" 36 #include "core/css/StyleRule.h"
37 #include "core/css/invalidation/DescendantInvalidationSet.h" 37 #include "core/css/invalidation/DescendantInvalidationSet.h"
38 #include "core/dom/Element.h" 38 #include "core/dom/Element.h"
39 #include "core/dom/Node.h" 39 #include "core/dom/Node.h"
40 #include "core/inspector/InspectorTraceEvents.h"
40 #include "wtf/BitVector.h" 41 #include "wtf/BitVector.h"
41 42
42 namespace blink { 43 namespace blink {
43 44
44 #if ENABLE(ASSERT) 45 #if ENABLE(ASSERT)
45 46
46 static bool supportsInvalidation(CSSSelector::Match match) 47 static bool supportsInvalidation(CSSSelector::Match match)
47 { 48 {
48 switch (match) { 49 switch (match) {
49 case CSSSelector::Tag: 50 case CSSSelector::Tag:
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 case CSSSelector::PseudoHostContext: 182 case CSSSelector::PseudoHostContext:
182 // :host-context matches a shadow host, yet the simple selectors inside 183 // :host-context matches a shadow host, yet the simple selectors inside
183 // :host-context matches an ancestor of the shadow host. 184 // :host-context matches an ancestor of the shadow host.
184 return true; 185 return true;
185 default: 186 default:
186 ASSERT(supportsInvalidation(selector.pseudoType())); 187 ASSERT(supportsInvalidation(selector.pseudoType()));
187 return false; 188 return false;
188 } 189 }
189 } 190 }
190 191
192 static const unsigned char* s_tracingEnabled = nullptr;
193
194 #define TRACE_SCHEDULE_STYLE_INVALIDATION_IF_ENABLED(...) \
195 if (UNLIKELY(*s_tracingEnabled)) \
196 TRACE_SCHEDULE_STYLE_INVALIDATION(__VA_ARGS__);
197
191 RuleFeature::RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocume ntSecurityOrigin) 198 RuleFeature::RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocume ntSecurityOrigin)
192 : rule(rule) 199 : rule(rule)
193 , selectorIndex(selectorIndex) 200 , selectorIndex(selectorIndex)
194 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) 201 , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin)
195 { 202 {
203 s_tracingEnabled = TRACE_EVENT_API_GET_CATEGORY_ENABLED(TRACE_DISABLED_BY_DE FAULT("devtools.timeline.invalidationTracking"));
rune 2014/10/20 07:24:03 This looks like a strange place to initialize that
kouhei (in TOK) 2014/10/20 09:06:20 Thanks for your comment. This is a bit confusing
rune 2014/10/20 09:18:18 Yes, I see that now. Still, I think it would be be
196 } 204 }
197 205
198 void RuleFeature::trace(Visitor* visitor) 206 void RuleFeature::trace(Visitor* visitor)
199 { 207 {
200 visitor->trace(rule); 208 visitor->trace(rule);
201 } 209 }
202 210
203 // This method is somewhat conservative in what it accepts. 211 // This method is somewhat conservative in what it accepts.
204 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect or(const CSSSelector& selector) 212 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect or(const CSSSelector& selector)
205 { 213 {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 for (unsigned i = 0; i < oldClasses.size(); ++i) { 599 for (unsigned i = 0; i < oldClasses.size(); ++i) {
592 if (remainingClassBits.quickGet(i)) 600 if (remainingClassBits.quickGet(i))
593 continue; 601 continue;
594 // Class was removed. 602 // Class was removed.
595 addClassToInvalidationSet(oldClasses[i], element); 603 addClassToInvalidationSet(oldClasses[i], element);
596 } 604 }
597 } 605 }
598 606
599 void RuleFeatureSet::scheduleStyleInvalidationForAttributeChange(const Qualified Name& attributeName, Element& element) 607 void RuleFeatureSet::scheduleStyleInvalidationForAttributeChange(const Qualified Name& attributeName, Element& element)
600 { 608 {
601 609 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_attrib uteInvalidationSets.get(attributeName.localName())) {
602 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_attrib uteInvalidationSets.get(attributeName.localName())) 610 TRACE_SCHEDULE_STYLE_INVALIDATION_IF_ENABLED(element, *invalidationSet, attributeChange, attributeName);
603 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); 611 m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
612 }
604 } 613 }
605 614
606 void RuleFeatureSet::scheduleStyleInvalidationForIdChange(const AtomicString& ol dId, const AtomicString& newId, Element& element) 615 void RuleFeatureSet::scheduleStyleInvalidationForIdChange(const AtomicString& ol dId, const AtomicString& newId, Element& element)
607 { 616 {
608 if (!oldId.isEmpty()) { 617 if (!oldId.isEmpty()) {
609 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_id InvalidationSets.get(oldId)) 618 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_id InvalidationSets.get(oldId)) {
619 TRACE_SCHEDULE_STYLE_INVALIDATION_IF_ENABLED(element, *invalidationS et, idChange, oldId);
610 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); 620 m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
621 }
611 } 622 }
612 if (!newId.isEmpty()) { 623 if (!newId.isEmpty()) {
613 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_id InvalidationSets.get(newId)) 624 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_id InvalidationSets.get(newId)) {
625 TRACE_SCHEDULE_STYLE_INVALIDATION_IF_ENABLED(element, *invalidationS et, idChange, newId);
614 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); 626 m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
627 }
615 } 628 }
616 } 629 }
617 630
618 void RuleFeatureSet::scheduleStyleInvalidationForPseudoChange(CSSSelector::Pseud oType pseudo, Element& element) 631 void RuleFeatureSet::scheduleStyleInvalidationForPseudoChange(CSSSelector::Pseud oType pseudo, Element& element)
619 { 632 {
620 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_pseudo InvalidationSets.get(pseudo)) 633 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_pseudo InvalidationSets.get(pseudo)) {
634 TRACE_SCHEDULE_STYLE_INVALIDATION_IF_ENABLED(element, *invalidationSet, pseudoChange, pseudo);
621 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); 635 m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
636 }
622 } 637 }
623 638
624 void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, El ement& element) 639 void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, El ement& element)
625 { 640 {
626 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_classI nvalidationSets.get(className)) 641 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_classI nvalidationSets.get(className)) {
642 TRACE_SCHEDULE_STYLE_INVALIDATION_IF_ENABLED(element, *invalidationSet, classChange, className);
627 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); 643 m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
644 }
628 } 645 }
629 646
630 StyleInvalidator& RuleFeatureSet::styleInvalidator() 647 StyleInvalidator& RuleFeatureSet::styleInvalidator()
631 { 648 {
632 return m_styleInvalidator; 649 return m_styleInvalidator;
633 } 650 }
634 651
635 void RuleFeatureSet::trace(Visitor* visitor) 652 void RuleFeatureSet::trace(Visitor* visitor)
636 { 653 {
637 #if ENABLE(OILPAN) 654 #if ENABLE(OILPAN)
638 visitor->trace(siblingRules); 655 visitor->trace(siblingRules);
639 visitor->trace(uncommonAttributeRules); 656 visitor->trace(uncommonAttributeRules);
640 visitor->trace(m_classInvalidationSets); 657 visitor->trace(m_classInvalidationSets);
641 visitor->trace(m_attributeInvalidationSets); 658 visitor->trace(m_attributeInvalidationSets);
642 visitor->trace(m_idInvalidationSets); 659 visitor->trace(m_idInvalidationSets);
643 visitor->trace(m_pseudoInvalidationSets); 660 visitor->trace(m_pseudoInvalidationSets);
644 visitor->trace(m_styleInvalidator); 661 visitor->trace(m_styleInvalidator);
645 #endif 662 #endif
646 } 663 }
647 664
648 } // namespace blink 665 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/inspector/InspectorTraceEvents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698