OLD | NEW |
---|---|
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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) | 475 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) |
476 wasEnabled(); | 476 wasEnabled(); |
477 } | 477 } |
478 | 478 |
479 void InspectorCSSAgent::flushPendingFrontendMessages() | 479 void InspectorCSSAgent::flushPendingFrontendMessages() |
480 { | 480 { |
481 if (!m_invalidatedDocuments.size()) | 481 if (!m_invalidatedDocuments.size()) |
482 return; | 482 return; |
483 WillBeHeapHashSet<RawPtrWillBeMember<Document> > invalidatedDocuments; | 483 WillBeHeapHashSet<RawPtrWillBeMember<Document> > invalidatedDocuments; |
484 m_invalidatedDocuments.swap(&invalidatedDocuments); | 484 m_invalidatedDocuments.swap(&invalidatedDocuments); |
485 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = invalid atedDocuments.begin(); it != invalidatedDocuments.end(); ++it) | 485 for (auto it : invalidatedDocuments) |
pfeldman
2014/12/16 16:52:10
Here and below:
Document* document: docs
zhaoze.zhou
2014/12/16 18:56:39
Done.
| |
486 updateActiveStyleSheets(*it, ExistingFrontendRefresh); | 486 updateActiveStyleSheets(it, ExistingFrontendRefresh); |
487 } | 487 } |
488 | 488 |
489 void InspectorCSSAgent::reset() | 489 void InspectorCSSAgent::reset() |
490 { | 490 { |
491 m_idToInspectorStyleSheet.clear(); | 491 m_idToInspectorStyleSheet.clear(); |
492 m_idToInspectorStyleSheetForInlineStyle.clear(); | 492 m_idToInspectorStyleSheetForInlineStyle.clear(); |
493 m_cssStyleSheetToInspectorStyleSheet.clear(); | 493 m_cssStyleSheetToInspectorStyleSheet.clear(); |
494 m_documentToCSSStyleSheets.clear(); | 494 m_documentToCSSStyleSheets.clear(); |
495 m_invalidatedDocuments.clear(); | 495 m_invalidatedDocuments.clear(); |
496 m_nodeToInspectorStyleSheet.clear(); | 496 m_nodeToInspectorStyleSheet.clear(); |
(...skipping 23 matching lines...) Expand all Loading... | |
520 | 520 |
521 void InspectorCSSAgent::wasEnabled() | 521 void InspectorCSSAgent::wasEnabled() |
522 { | 522 { |
523 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { | 523 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { |
524 // We were disabled while fetching resources. | 524 // We were disabled while fetching resources. |
525 return; | 525 return; |
526 } | 526 } |
527 | 527 |
528 m_instrumentingAgents->setInspectorCSSAgent(this); | 528 m_instrumentingAgents->setInspectorCSSAgent(this); |
529 WillBeHeapVector<RawPtrWillBeMember<Document> > documents = m_domAgent->docu ments(); | 529 WillBeHeapVector<RawPtrWillBeMember<Document> > documents = m_domAgent->docu ments(); |
530 for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = document s.begin(); it != documents.end(); ++it) | 530 for (auto it : documents) |
531 updateActiveStyleSheets(*it, InitialFrontendLoad); | 531 updateActiveStyleSheets(it, InitialFrontendLoad); |
532 } | 532 } |
533 | 533 |
534 void InspectorCSSAgent::disable(ErrorString*) | 534 void InspectorCSSAgent::disable(ErrorString*) |
535 { | 535 { |
536 reset(); | 536 reset(); |
537 m_instrumentingAgents->setInspectorCSSAgent(0); | 537 m_instrumentingAgents->setInspectorCSSAgent(0); |
538 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); | 538 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); |
539 } | 539 } |
540 | 540 |
541 void InspectorCSSAgent::didCommitLoadForMainFrame() | 541 void InspectorCSSAgent::didCommitLoadForMainFrame() |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 | 607 |
608 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >* documentCSSStyleSheet s = m_documentToCSSStyleSheets.get(document); | 608 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >* documentCSSStyleSheet s = m_documentToCSSStyleSheets.get(document); |
609 if (!documentCSSStyleSheets) { | 609 if (!documentCSSStyleSheets) { |
610 documentCSSStyleSheets = new WillBeHeapHashSet<RawPtrWillBeMember<CSSSty leSheet> >(); | 610 documentCSSStyleSheets = new WillBeHeapHashSet<RawPtrWillBeMember<CSSSty leSheet> >(); |
611 OwnPtrWillBeRawPtr<WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > > documentCSSStyleSheetsPtr = adoptPtrWillBeNoop(documentCSSStyleSheets); | 611 OwnPtrWillBeRawPtr<WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > > documentCSSStyleSheetsPtr = adoptPtrWillBeNoop(documentCSSStyleSheets); |
612 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea se()); | 612 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea se()); |
613 } | 613 } |
614 | 614 |
615 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > removedSheets(*documen tCSSStyleSheets); | 615 WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > removedSheets(*documen tCSSStyleSheets); |
616 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > addedSheets; | 616 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > addedSheets; |
617 for (WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) { | 617 for (const auto& it : allSheetsVector) { |
pfeldman
2014/12/16 16:52:10
Here and below:
CSSStyleSheet* sheet :
zhaoze.zhou
2014/12/16 18:56:39
Done.
| |
618 CSSStyleSheet* cssStyleSheet = *it; | 618 CSSStyleSheet* cssStyleSheet = it; |
619 if (removedSheets.contains(cssStyleSheet)) { | 619 if (removedSheets.contains(cssStyleSheet)) { |
620 removedSheets.remove(cssStyleSheet); | 620 removedSheets.remove(cssStyleSheet); |
621 if (isInitialFrontendLoad) | 621 if (isInitialFrontendLoad) |
622 addedSheets.append(cssStyleSheet); | 622 addedSheets.append(cssStyleSheet); |
623 } else { | 623 } else { |
624 addedSheets.append(cssStyleSheet); | 624 addedSheets.append(cssStyleSheet); |
625 } | 625 } |
626 } | 626 } |
627 | 627 |
628 for (WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = re movedSheets.begin(); it != removedSheets.end(); ++it) { | 628 for (auto it : removedSheets) { |
629 CSSStyleSheet* cssStyleSheet = *it; | 629 CSSStyleSheet* cssStyleSheet = it; |
630 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyle SheetToInspectorStyleSheet.get(cssStyleSheet); | 630 RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyle SheetToInspectorStyleSheet.get(cssStyleSheet); |
631 ASSERT(inspectorStyleSheet); | 631 ASSERT(inspectorStyleSheet); |
632 | 632 |
633 documentCSSStyleSheets->remove(cssStyleSheet); | 633 documentCSSStyleSheets->remove(cssStyleSheet); |
634 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { | 634 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { |
635 String id = unbindStyleSheet(inspectorStyleSheet.get()); | 635 String id = unbindStyleSheet(inspectorStyleSheet.get()); |
636 if (m_frontend && !isInitialFrontendLoad) | 636 if (m_frontend && !isInitialFrontendLoad) |
637 m_frontend->styleSheetRemoved(id); | 637 m_frontend->styleSheetRemoved(id); |
638 } | 638 } |
639 } | 639 } |
640 | 640 |
641 for (WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >::iterator it = add edSheets.begin(); it != addedSheets.end(); ++it) { | 641 for (auto it : addedSheets) { |
642 CSSStyleSheet* cssStyleSheet = *it; | 642 CSSStyleSheet* cssStyleSheet = it; |
643 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh eet.contains(cssStyleSheet); | 643 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh eet.contains(cssStyleSheet); |
644 if (isNew) { | 644 if (isNew) { |
645 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); | 645 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); |
646 documentCSSStyleSheets->add(cssStyleSheet); | 646 documentCSSStyleSheets->add(cssStyleSheet); |
647 if (m_frontend) | 647 if (m_frontend) |
648 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo()); | 648 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo()); |
649 } | 649 } |
650 } | 650 } |
651 | 651 |
652 if (documentCSSStyleSheets->isEmpty()) | 652 if (documentCSSStyleSheets->isEmpty()) |
(...skipping 30 matching lines...) Expand all Loading... | |
683 case CSSSelector::PseudoVisited: | 683 case CSSSelector::PseudoVisited: |
684 return forcedPseudoState & PseudoVisited; | 684 return forcedPseudoState & PseudoVisited; |
685 default: | 685 default: |
686 return false; | 686 return false; |
687 } | 687 } |
688 } | 688 } |
689 | 689 |
690 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) | 690 void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBui lder::Array<TypeBuilder::CSS::CSSMedia> >& medias) |
691 { | 691 { |
692 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); | 692 medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); |
693 for (IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.begin( ); it != m_idToInspectorStyleSheet.end(); ++it) { | 693 for (auto it : m_idToInspectorStyleSheet) { |
694 RefPtrWillBeRawPtr<InspectorStyleSheet> styleSheet = it->value; | 694 RefPtrWillBeRawPtr<InspectorStyleSheet> styleSheet = it.value; |
695 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g et()); | 695 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g et()); |
696 const CSSRuleVector& flatRules = styleSheet->flatRules(); | 696 const CSSRuleVector& flatRules = styleSheet->flatRules(); |
697 for (unsigned i = 0; i < flatRules.size(); ++i) { | 697 for (unsigned i = 0; i < flatRules.size(); ++i) { |
698 CSSRule* rule = flatRules.at(i).get(); | 698 CSSRule* rule = flatRules.at(i).get(); |
699 if (rule->type() == CSSRule::MEDIA_RULE || rule->type() == CSSRule:: IMPORT_RULE) | 699 if (rule->type() == CSSRule::MEDIA_RULE || rule->type() == CSSRule:: IMPORT_RULE) |
700 collectMediaQueriesFromRule(rule, medias.get()); | 700 collectMediaQueriesFromRule(rule, medias.get()); |
701 } | 701 } |
702 } | 702 } |
703 } | 703 } |
704 | 704 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
855 | 855 |
856 if (!previous->isPseudoElement() || !previous->node()->isFirstLetterPseu doElement()) | 856 if (!previous->isPseudoElement() || !previous->node()->isFirstLetterPseu doElement()) |
857 continue; | 857 continue; |
858 | 858 |
859 // The first-letter pseudoElement only has one child, which is the | 859 // The first-letter pseudoElement only has one child, which is the |
860 // first-letter renderer. | 860 // first-letter renderer. |
861 collectPlatformFontsForRenderer(toRenderText(previous->slowFirstChild()) , &fontStats); | 861 collectPlatformFontsForRenderer(toRenderText(previous->slowFirstChild()) , &fontStats); |
862 } | 862 } |
863 | 863 |
864 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre ate(); | 864 platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::cre ate(); |
865 for (HashCountedSet<String>::iterator it = fontStats.begin(), end = fontStat s.end(); it != end; ++it) { | 865 for (auto it : fontStats) { |
866 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder:: CSS::PlatformFontUsage::create() | 866 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder:: CSS::PlatformFontUsage::create() |
867 .setFamilyName(it->key) | 867 .setFamilyName(it.key) |
868 .setGlyphCount(it->value); | 868 .setGlyphCount(it.value); |
869 platformFonts->addItem(platformFont); | 869 platformFonts->addItem(platformFont); |
870 } | 870 } |
871 } | 871 } |
872 | 872 |
873 void InspectorCSSAgent::getStyleSheetText(ErrorString* errorString, const String & styleSheetId, String* result) | 873 void InspectorCSSAgent::getStyleSheetText(ErrorString* errorString, const String & styleSheetId, String* result) |
874 { | 874 { |
875 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt ring, styleSheetId); | 875 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt ring, styleSheetId); |
876 if (!inspectorStyleSheet) | 876 if (!inspectorStyleSheet) |
877 return; | 877 return; |
878 | 878 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1271 *errorString = "Not an element node"; | 1271 *errorString = "Not an element node"; |
1272 return 0; | 1272 return 0; |
1273 } | 1273 } |
1274 return toElement(node); | 1274 return toElement(node); |
1275 } | 1275 } |
1276 | 1276 |
1277 // static | 1277 // static |
1278 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, WillBe HeapVector<RawPtrWillBeMember<CSSStyleSheet> >& result) | 1278 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, WillBe HeapVector<RawPtrWillBeMember<CSSStyleSheet> >& result) |
1279 { | 1279 { |
1280 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector(); | 1280 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector(); |
1281 for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) { | 1281 for (const auto& it : activeStyleSheets) { |
1282 CSSStyleSheet* styleSheet = it->get(); | 1282 CSSStyleSheet* styleSheet = it.get(); |
1283 InspectorCSSAgent::collectStyleSheets(styleSheet, result); | 1283 InspectorCSSAgent::collectStyleSheets(styleSheet, result); |
1284 } | 1284 } |
1285 } | 1285 } |
1286 | 1286 |
1287 // static | 1287 // static |
1288 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, WillBeHeap Vector<RawPtrWillBeMember<CSSStyleSheet> >& result) | 1288 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, WillBeHeap Vector<RawPtrWillBeMember<CSSStyleSheet> >& result) |
1289 { | 1289 { |
1290 result.append(styleSheet); | 1290 result.append(styleSheet); |
1291 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { | 1291 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { |
1292 CSSRule* rule = styleSheet->item(i); | 1292 CSSRule* rule = styleSheet->item(i); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1532 | 1532 |
1533 void InspectorCSSAgent::didReparseStyleSheet() | 1533 void InspectorCSSAgent::didReparseStyleSheet() |
1534 { | 1534 { |
1535 ASSERT(m_isSettingStyleSheetText); | 1535 ASSERT(m_isSettingStyleSheetText); |
1536 m_isSettingStyleSheetText = false; | 1536 m_isSettingStyleSheetText = false; |
1537 } | 1537 } |
1538 | 1538 |
1539 void InspectorCSSAgent::resetPseudoStates() | 1539 void InspectorCSSAgent::resetPseudoStates() |
1540 { | 1540 { |
1541 WillBeHeapHashSet<RawPtrWillBeMember<Document> > documentsToChange; | 1541 WillBeHeapHashSet<RawPtrWillBeMember<Document> > documentsToChange; |
1542 for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.be gin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) { | 1542 for (auto it : m_nodeIdToForcedPseudoState) { |
1543 Element* element = toElement(m_domAgent->nodeForId(it->key)); | 1543 Element* element = toElement(m_domAgent->nodeForId(it.key)); |
1544 if (element && element->ownerDocument()) | 1544 if (element && element->ownerDocument()) |
1545 documentsToChange.add(element->ownerDocument()); | 1545 documentsToChange.add(element->ownerDocument()); |
1546 } | 1546 } |
1547 | 1547 |
1548 m_nodeIdToForcedPseudoState.clear(); | 1548 m_nodeIdToForcedPseudoState.clear(); |
1549 for (WillBeHeapHashSet<RawPtrWillBeMember<Document> >::iterator it = documen tsToChange.begin(), end = documentsToChange.end(); it != end; ++it) | 1549 for (auto it : documentsToChange) |
1550 (*it)->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci ng::create(StyleChangeReason::Inspector)); | 1550 it->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing: :create(StyleChangeReason::Inspector)); |
1551 } | 1551 } |
1552 | 1552 |
1553 void InspectorCSSAgent::trace(Visitor* visitor) | 1553 void InspectorCSSAgent::trace(Visitor* visitor) |
1554 { | 1554 { |
1555 visitor->trace(m_domAgent); | 1555 visitor->trace(m_domAgent); |
1556 visitor->trace(m_pageAgent); | 1556 visitor->trace(m_pageAgent); |
1557 visitor->trace(m_resourceAgent); | 1557 visitor->trace(m_resourceAgent); |
1558 #if ENABLE(OILPAN) | 1558 #if ENABLE(OILPAN) |
1559 visitor->trace(m_idToInspectorStyleSheet); | 1559 visitor->trace(m_idToInspectorStyleSheet); |
1560 visitor->trace(m_idToInspectorStyleSheetForInlineStyle); | 1560 visitor->trace(m_idToInspectorStyleSheetForInlineStyle); |
1561 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); | 1561 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); |
1562 visitor->trace(m_documentToCSSStyleSheets); | 1562 visitor->trace(m_documentToCSSStyleSheets); |
1563 visitor->trace(m_invalidatedDocuments); | 1563 visitor->trace(m_invalidatedDocuments); |
1564 visitor->trace(m_nodeToInspectorStyleSheet); | 1564 visitor->trace(m_nodeToInspectorStyleSheet); |
1565 visitor->trace(m_documentToViaInspectorStyleSheet); | 1565 visitor->trace(m_documentToViaInspectorStyleSheet); |
1566 #endif | 1566 #endif |
1567 visitor->trace(m_inspectorUserAgentStyleSheet); | 1567 visitor->trace(m_inspectorUserAgentStyleSheet); |
1568 InspectorBaseAgent::trace(visitor); | 1568 InspectorBaseAgent::trace(visitor); |
1569 } | 1569 } |
1570 | 1570 |
1571 } // namespace blink | 1571 } // namespace blink |
1572 | 1572 |
OLD | NEW |