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

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

Issue 24253004: Cleanup: Start using toFoo methods as part of newly adopted coding guideline. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 | « Source/core/html/shadow/SpinButtonElement.h ('k') | Source/core/rendering/HitTestResult.cpp » ('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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe ctorStyleSheet.get(styleSheet); 98 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe ctorStyleSheet.get(styleSheet);
99 // Avoid creating m_childRuleCSSOMWrappers in the stylesheet if it is in the process of re-parsing. 99 // Avoid creating m_childRuleCSSOMWrappers in the stylesheet if it is in the process of re-parsing.
100 // Otherwise m_childRuleCSSOMWrappers size will be initialized only for a part of rules, resulting in an ASSERT failure in CSSStyleSheet::item(). 100 // Otherwise m_childRuleCSSOMWrappers size will be initialized only for a part of rules, resulting in an ASSERT failure in CSSStyleSheet::item().
101 // Instead, wait for the RuleMutationScope destruction and handle the co mplete CSSStyleSheet. 101 // Instead, wait for the RuleMutationScope destruction and handle the co mplete CSSStyleSheet.
102 if (inspectorStyleSheet && inspectorStyleSheet->isReparsing()) 102 if (inspectorStyleSheet && inspectorStyleSheet->isReparsing())
103 return; 103 return;
104 m_result.append(styleSheet); 104 m_result.append(styleSheet);
105 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { 105 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) {
106 CSSRule* rule = styleSheet->item(i); 106 CSSRule* rule = styleSheet->item(i);
107 if (rule->type() == CSSRule::IMPORT_RULE) { 107 if (rule->type() == CSSRule::IMPORT_RULE) {
108 CSSStyleSheet* importedStyleSheet = static_cast<CSSImportRule*>( rule)->styleSheet(); 108 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->style Sheet();
109 if (importedStyleSheet) 109 if (importedStyleSheet)
110 run(importedStyleSheet); 110 run(importedStyleSheet);
111 } 111 }
112 } 112 }
113 } 113 }
114 114
115 private: 115 private:
116 CSSStyleSheetToInspectorStyleSheet& m_cssStyleSheetToInspectorStyleSheet; 116 CSSStyleSheetToInspectorStyleSheet& m_cssStyleSheetToInspectorStyleSheet;
117 Vector<CSSStyleSheet*>& m_result; 117 Vector<CSSStyleSheet*>& m_result;
118 }; 118 };
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 InspectorCSSId m_newId; 530 InspectorCSSId m_newId;
531 String m_selector; 531 String m_selector;
532 String m_oldSelector; 532 String m_oldSelector;
533 }; 533 };
534 534
535 // static 535 // static
536 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) 536 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule)
537 { 537 {
538 if (!rule || rule->type() != CSSRule::STYLE_RULE) 538 if (!rule || rule->type() != CSSRule::STYLE_RULE)
539 return 0; 539 return 0;
540 return static_cast<CSSStyleRule*>(rule); 540 return toCSSStyleRule(rule);
541 } 541 }
542 542
543 template <typename CharType, size_t bufferLength> 543 template <typename CharType, size_t bufferLength>
544 static size_t vendorPrefixLowerCase(const CharType* string, size_t stringLength, char (&buffer)[bufferLength]) 544 static size_t vendorPrefixLowerCase(const CharType* string, size_t stringLength, char (&buffer)[bufferLength])
545 { 545 {
546 static const char lowerCaseOffset = 'a' - 'A'; 546 static const char lowerCaseOffset = 'a' - 'A';
547 547
548 if (string[0] != '-') 548 if (string[0] != '-')
549 return 0; 549 return 0;
550 550
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 CSSRule* parentRule = rule; 1368 CSSRule* parentRule = rule;
1369 String sourceURL; 1369 String sourceURL;
1370 while (parentRule) { 1370 while (parentRule) {
1371 CSSStyleSheet* parentStyleSheet = 0; 1371 CSSStyleSheet* parentStyleSheet = 0;
1372 bool isMediaRule = true; 1372 bool isMediaRule = true;
1373 if (parentRule->type() == CSSRule::MEDIA_RULE) { 1373 if (parentRule->type() == CSSRule::MEDIA_RULE) {
1374 CSSMediaRule* mediaRule = static_cast<CSSMediaRule*>(parentRule); 1374 CSSMediaRule* mediaRule = static_cast<CSSMediaRule*>(parentRule);
1375 mediaList = mediaRule->media(); 1375 mediaList = mediaRule->media();
1376 parentStyleSheet = mediaRule->parentStyleSheet(); 1376 parentStyleSheet = mediaRule->parentStyleSheet();
1377 } else if (parentRule->type() == CSSRule::IMPORT_RULE) { 1377 } else if (parentRule->type() == CSSRule::IMPORT_RULE) {
1378 CSSImportRule* importRule = static_cast<CSSImportRule*>(parentRule); 1378 CSSImportRule* importRule = toCSSImportRule(parentRule);
1379 mediaList = importRule->media(); 1379 mediaList = importRule->media();
1380 parentStyleSheet = importRule->parentStyleSheet(); 1380 parentStyleSheet = importRule->parentStyleSheet();
1381 isMediaRule = false; 1381 isMediaRule = false;
1382 } else { 1382 } else {
1383 mediaList = 0; 1383 mediaList = 0;
1384 } 1384 }
1385 1385
1386 if (parentStyleSheet) { 1386 if (parentStyleSheet) {
1387 sourceURL = parentStyleSheet->contents()->baseURL(); 1387 sourceURL = parentStyleSheet->contents()->baseURL();
1388 if (sourceURL.isEmpty()) 1388 if (sourceURL.isEmpty())
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 } 1476 }
1477 } 1477 }
1478 1478
1479 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<Ins pectorStyleSheet*>& result) 1479 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<Ins pectorStyleSheet*>& result)
1480 { 1480 {
1481 InspectorStyleSheet* inspectorStyleSheet = bindStyleSheet(static_cast<CSSSty leSheet*>(styleSheet)); 1481 InspectorStyleSheet* inspectorStyleSheet = bindStyleSheet(static_cast<CSSSty leSheet*>(styleSheet));
1482 result.append(inspectorStyleSheet); 1482 result.append(inspectorStyleSheet);
1483 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { 1483 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) {
1484 CSSRule* rule = styleSheet->item(i); 1484 CSSRule* rule = styleSheet->item(i);
1485 if (rule->type() == CSSRule::IMPORT_RULE) { 1485 if (rule->type() == CSSRule::IMPORT_RULE) {
1486 CSSStyleSheet* importedStyleSheet = static_cast<CSSImportRule*>(rule )->styleSheet(); 1486 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee t();
1487 if (importedStyleSheet) 1487 if (importedStyleSheet)
1488 collectStyleSheets(importedStyleSheet, result); 1488 collectStyleSheets(importedStyleSheet, result);
1489 } 1489 }
1490 } 1490 }
1491 } 1491 }
1492 1492
1493 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet ) 1493 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet )
1494 { 1494 {
1495 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector StyleSheet.get(styleSheet); 1495 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector StyleSheet.get(styleSheet);
1496 if (!inspectorStyleSheet) { 1496 if (!inspectorStyleSheet) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 documentsToChange.add(element->ownerDocument()); 1799 documentsToChange.add(element->ownerDocument());
1800 } 1800 }
1801 1801
1802 m_nodeIdToForcedPseudoState.clear(); 1802 m_nodeIdToForcedPseudoState.clear();
1803 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1803 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1804 (*it)->setNeedsStyleRecalc(); 1804 (*it)->setNeedsStyleRecalc();
1805 } 1805 }
1806 1806
1807 } // namespace WebCore 1807 } // namespace WebCore
1808 1808
OLDNEW
« no previous file with comments | « Source/core/html/shadow/SpinButtonElement.h ('k') | Source/core/rendering/HitTestResult.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698