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

Side by Side Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 192473003: Move CSSRuleList to the garbage collected heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ager feedback Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/DOMWindow.cpp ('k') | Source/core/inspector/InspectorStyleSheet.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) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 if (!ownerDocument->isActive()) 676 if (!ownerDocument->isActive())
677 return; 677 return;
678 678
679 // FIXME: It's really gross for the inspector to reach in and access StyleRe solver 679 // FIXME: It's really gross for the inspector to reach in and access StyleRe solver
680 // directly here. We need to provide the Inspector better APIs to get this i nformation 680 // directly here. We need to provide the Inspector better APIs to get this i nformation
681 // without grabbing at internal style classes! 681 // without grabbing at internal style classes!
682 682
683 // Matched rules. 683 // Matched rules.
684 StyleResolver& styleResolver = ownerDocument->ensureStyleResolver(); 684 StyleResolver& styleResolver = ownerDocument->ensureStyleResolver();
685 685
686 RefPtr<CSSRuleList> matchedRules = styleResolver.pseudoCSSRulesForElement(el ement, elementPseudoId, StyleResolver::AllCSSRules); 686 RefPtrWillBeRawPtr<CSSRuleList> matchedRules = styleResolver.pseudoCSSRulesF orElement(element, elementPseudoId, StyleResolver::AllCSSRules);
687 matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), originalE lement); 687 matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), originalE lement);
688 688
689 // Pseudo elements. 689 // Pseudo elements.
690 if (!elementPseudoId && (!includePseudo || *includePseudo)) { 690 if (!elementPseudoId && (!includePseudo || *includePseudo)) {
691 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> > pseudoEle ments = TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create(); 691 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> > pseudoEle ments = TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create();
692 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_IN TERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { 692 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_IN TERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) {
693 RefPtr<CSSRuleList> matchedRules = styleResolver.pseudoCSSRulesForEl ement(element, pseudoId, StyleResolver::AllCSSRules); 693 RefPtrWillBeRawPtr<CSSRuleList> matchedRules = styleResolver.pseudoC SSRulesForElement(element, pseudoId, StyleResolver::AllCSSRules);
694 if (matchedRules && matchedRules->length()) { 694 if (matchedRules && matchedRules->length()) {
695 RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder: :CSS::PseudoIdMatches::create() 695 RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder: :CSS::PseudoIdMatches::create()
696 .setPseudoId(static_cast<int>(pseudoId)) 696 .setPseudoId(static_cast<int>(pseudoId))
697 .setMatches(buildArrayForMatchedRuleList(matchedRules.get(), element)); 697 .setMatches(buildArrayForMatchedRuleList(matchedRules.get(), element));
698 pseudoElements->addItem(matches.release()); 698 pseudoElements->addItem(matches.release());
699 } 699 }
700 } 700 }
701 701
702 pseudoIdMatches = pseudoElements.release(); 702 pseudoIdMatches = pseudoElements.release();
703 } 703 }
704 704
705 // Inherited styles. 705 // Inherited styles.
706 if (!elementPseudoId && (!includeInherited || *includeInherited)) { 706 if (!elementPseudoId && (!includeInherited || *includeInherited)) {
707 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); 707 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create();
708 Element* parentElement = element->parentElement(); 708 Element* parentElement = element->parentElement();
709 while (parentElement) { 709 while (parentElement) {
710 StyleResolver& parentStyleResolver = parentElement->ownerDocument()- >ensureStyleResolver(); 710 StyleResolver& parentStyleResolver = parentElement->ownerDocument()- >ensureStyleResolver();
711 RefPtr<CSSRuleList> parentMatchedRules = parentStyleResolver.cssRule sForElement(parentElement, StyleResolver::AllCSSRules); 711 RefPtrWillBeRawPtr<CSSRuleList> parentMatchedRules = parentStyleReso lver.cssRulesForElement(parentElement, StyleResolver::AllCSSRules);
712 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C SS::InheritedStyleEntry::create() 712 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C SS::InheritedStyleEntry::create()
713 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu les.get(), parentElement)); 713 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu les.get(), parentElement));
714 if (parentElement->style() && parentElement->style()->length()) { 714 if (parentElement->style() && parentElement->style()->length()) {
715 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle Sheet(parentElement); 715 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle Sheet(parentElement);
716 if (styleSheet) 716 if (styleSheet)
717 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS heet->styleForId(InspectorCSSId(styleSheet->id(), 0)))); 717 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS heet->styleForId(InspectorCSSId(styleSheet->id(), 0))));
718 } 718 }
719 719
720 entries->addItem(entry.release()); 720 entries->addItem(entry.release());
721 parentElement = parentElement->parentElement(); 721 parentElement = parentElement->parentElement();
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 Vector<CSSStyleSheet*> cssStyleSheets; 1077 Vector<CSSStyleSheet*> cssStyleSheets;
1078 Vector<Document*> documents = m_domAgent->documents(); 1078 Vector<Document*> documents = m_domAgent->documents();
1079 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end (); ++it) 1079 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end (); ++it)
1080 collectAllDocumentStyleSheets(*it, cssStyleSheets); 1080 collectAllDocumentStyleSheets(*it, cssStyleSheets);
1081 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css StyleSheets.end(); ++it) 1081 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css StyleSheets.end(); ++it)
1082 result.append(bindStyleSheet(*it)); 1082 result.append(bindStyleSheet(*it));
1083 } 1083 }
1084 1084
1085 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector <CSSStyleSheet*>& result) 1085 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector <CSSStyleSheet*>& result)
1086 { 1086 {
1087 const Vector<RefPtr<StyleSheet> > activeStyleSheets = document->styleEngine( )->activeStyleSheetsForInspector(); 1087 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector();
1088 for (Vector<RefPtr<StyleSheet> >::const_iterator it = activeStyleSheets.begi n(); it != activeStyleSheets.end(); ++it) { 1088 for (WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) {
1089 StyleSheet* styleSheet = (*it).get(); 1089 StyleSheet* styleSheet = (*it).get();
1090 if (styleSheet->isCSSStyleSheet()) 1090 if (styleSheet->isCSSStyleSheet())
1091 collectStyleSheets(toCSSStyleSheet(styleSheet), result); 1091 collectStyleSheets(toCSSStyleSheet(styleSheet), result);
1092 } 1092 }
1093 } 1093 }
1094 1094
1095 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<CSS StyleSheet*>& result) 1095 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<CSS StyleSheet*>& result)
1096 { 1096 {
1097 result.append(styleSheet); 1097 result.append(styleSheet);
1098 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { 1098 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 documentsToChange.add(element->ownerDocument()); 1337 documentsToChange.add(element->ownerDocument());
1338 } 1338 }
1339 1339
1340 m_nodeIdToForcedPseudoState.clear(); 1340 m_nodeIdToForcedPseudoState.clear();
1341 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1341 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1342 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1342 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1343 } 1343 }
1344 1344
1345 } // namespace WebCore 1345 } // namespace WebCore
1346 1346
OLDNEW
« no previous file with comments | « Source/core/frame/DOMWindow.cpp ('k') | Source/core/inspector/InspectorStyleSheet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698