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

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

Issue 800113002: Use C++11 range-based for loop in Source/core/inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: REBASE AGAIN! Created 6 years 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
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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 552
553 return result.release(); 553 return result.release();
554 } 554 }
555 555
556 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > Insp ectorStyle::buildArrayForComputedStyle() const 556 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > Insp ectorStyle::buildArrayForComputedStyle() const
557 { 557 {
558 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > resu lt = TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty>::create(); 558 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > resu lt = TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty>::create();
559 WillBeHeapVector<InspectorStyleProperty> properties; 559 WillBeHeapVector<InspectorStyleProperty> properties;
560 populateAllProperties(properties); 560 populateAllProperties(properties);
561 561
562 for (WillBeHeapVector<InspectorStyleProperty>::iterator it = properties.begi n(), itEnd = properties.end(); it != itEnd; ++it) { 562 for (auto it : properties) {
563 const CSSPropertySourceData& propertyEntry = it->sourceData; 563 const CSSPropertySourceData& propertyEntry = it.sourceData;
564 RefPtr<TypeBuilder::CSS::CSSComputedStyleProperty> entry = TypeBuilder:: CSS::CSSComputedStyleProperty::create() 564 RefPtr<TypeBuilder::CSS::CSSComputedStyleProperty> entry = TypeBuilder:: CSS::CSSComputedStyleProperty::create()
565 .setName(propertyEntry.name) 565 .setName(propertyEntry.name)
566 .setValue(propertyEntry.value); 566 .setValue(propertyEntry.value);
567 result->addItem(entry); 567 result->addItem(entry);
568 } 568 }
569 569
570 return result.release(); 570 return result.release();
571 } 571 }
572 572
573 bool InspectorStyle::verifyPropertyText(const String& propertyText, bool canOmit Semicolon) 573 bool InspectorStyle::verifyPropertyText(const String& propertyText, bool canOmit Semicolon)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 return true; 662 return true;
663 } 663 }
664 664
665 void InspectorStyle::populateAllProperties(WillBeHeapVector<InspectorStyleProper ty>& result) const 665 void InspectorStyle::populateAllProperties(WillBeHeapVector<InspectorStyleProper ty>& result) const
666 { 666 {
667 HashSet<String> sourcePropertyNames; 667 HashSet<String> sourcePropertyNames;
668 668
669 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData(); 669 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData();
670 if (sourceData && sourceData->styleSourceData) { 670 if (sourceData && sourceData->styleSourceData) {
671 WillBeHeapVector<CSSPropertySourceData>& sourcePropertyData = sourceData ->styleSourceData->propertyData; 671 WillBeHeapVector<CSSPropertySourceData>& sourcePropertyData = sourceData ->styleSourceData->propertyData;
672 for (WillBeHeapVector<CSSPropertySourceData>::const_iterator it = source PropertyData.begin(); it != sourcePropertyData.end(); ++it) { 672 for (const auto& it : sourcePropertyData) {
673 InspectorStyleProperty p(*it, true); 673 InspectorStyleProperty p(it, true);
674 bool isPropertyTextKnown = textForRange(p.sourceData.range, &p.rawTe xt); 674 bool isPropertyTextKnown = textForRange(p.sourceData.range, &p.rawTe xt);
675 ASSERT_UNUSED(isPropertyTextKnown, isPropertyTextKnown); 675 ASSERT_UNUSED(isPropertyTextKnown, isPropertyTextKnown);
676 result.append(p); 676 result.append(p);
677 sourcePropertyNames.add(it->name.lower()); 677 sourcePropertyNames.add(it.name.lower());
678 } 678 }
679 } 679 }
680 680
681 for (int i = 0, size = m_style->length(); i < size; ++i) { 681 for (int i = 0, size = m_style->length(); i < size; ++i) {
682 String name = m_style->item(i); 682 String name = m_style->item(i);
683 if (!sourcePropertyNames.add(name.lower()).isNewEntry) 683 if (!sourcePropertyNames.add(name.lower()).isNewEntry)
684 continue; 684 continue;
685 685
686 String value = m_style->getPropertyValue(name); 686 String value = m_style->getPropertyValue(name);
687 if (value.isEmpty()) 687 if (value.isEmpty())
688 continue; 688 continue;
689 result.append(InspectorStyleProperty(CSSPropertySourceData(name, value, !m_style->getPropertyPriority(name).isEmpty(), false, true, SourceRange()), fals e)); 689 result.append(InspectorStyleProperty(CSSPropertySourceData(name, value, !m_style->getPropertyPriority(name).isEmpty(), false, true, SourceRange()), fals e));
690 } 690 }
691 } 691 }
692 692
693 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::styleWithProperties() con st 693 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::styleWithProperties() con st
694 { 694 {
695 RefPtr<Array<TypeBuilder::CSS::CSSProperty> > propertiesObject = Array<TypeB uilder::CSS::CSSProperty>::create(); 695 RefPtr<Array<TypeBuilder::CSS::CSSProperty> > propertiesObject = Array<TypeB uilder::CSS::CSSProperty>::create();
696 RefPtr<Array<TypeBuilder::CSS::ShorthandEntry> > shorthandEntries = Array<Ty peBuilder::CSS::ShorthandEntry>::create(); 696 RefPtr<Array<TypeBuilder::CSS::ShorthandEntry> > shorthandEntries = Array<Ty peBuilder::CSS::ShorthandEntry>::create();
697 HashSet<String> foundShorthands; 697 HashSet<String> foundShorthands;
698 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData(); 698 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData();
699 699
700 WillBeHeapVector<InspectorStyleProperty> properties; 700 WillBeHeapVector<InspectorStyleProperty> properties;
701 populateAllProperties(properties); 701 populateAllProperties(properties);
702 702
703 for (WillBeHeapVector<InspectorStyleProperty>::iterator it = properties.begi n(), itEnd = properties.end(); it != itEnd; ++it) { 703 for (auto it : properties) {
704 const CSSPropertySourceData& propertyEntry = it->sourceData; 704 const CSSPropertySourceData& propertyEntry = it.sourceData;
705 const String& name = propertyEntry.name; 705 const String& name = propertyEntry.name;
706 706
707 RefPtr<TypeBuilder::CSS::CSSProperty> property = TypeBuilder::CSS::CSSPr operty::create() 707 RefPtr<TypeBuilder::CSS::CSSProperty> property = TypeBuilder::CSS::CSSPr operty::create()
708 .setName(name) 708 .setName(name)
709 .setValue(propertyEntry.value); 709 .setValue(propertyEntry.value);
710 propertiesObject->addItem(property); 710 propertiesObject->addItem(property);
711 711
712 // Default "parsedOk" == true. 712 // Default "parsedOk" == true.
713 if (!propertyEntry.parsedOk) 713 if (!propertyEntry.parsedOk)
714 property->setParsedOk(false); 714 property->setParsedOk(false);
715 if (it->hasRawText()) 715 if (it.hasRawText())
716 property->setText(it->rawText); 716 property->setText(it.rawText);
717 717
718 if (propertyEntry.important) 718 if (propertyEntry.important)
719 property->setImportant(true); 719 property->setImportant(true);
720 if (it->hasSource) { 720 if (it.hasSource) {
721 property->setRange(buildSourceRangeObject(propertyEntry.range, m_par entStyleSheet ? m_parentStyleSheet->lineEndings() : nullptr)); 721 property->setRange(buildSourceRangeObject(propertyEntry.range, m_par entStyleSheet ? m_parentStyleSheet->lineEndings() : nullptr));
722 if (!propertyEntry.disabled) { 722 if (!propertyEntry.disabled) {
723 ASSERT_UNUSED(sourceData, sourceData); 723 ASSERT_UNUSED(sourceData, sourceData);
724 property->setImplicit(false); 724 property->setImplicit(false);
725 } 725 }
726 property->setDisabled(propertyEntry.disabled); 726 property->setDisabled(propertyEntry.disabled);
727 } else if (!propertyEntry.disabled) { 727 } else if (!propertyEntry.disabled) {
728 bool implicit = m_style->isPropertyImplicit(name); 728 bool implicit = m_style->isPropertyImplicit(name);
729 // Default "implicit" == false. 729 // Default "implicit" == false.
730 if (implicit) 730 if (implicit)
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 1956
1957 void InspectorStyleSheetForInlineStyle::trace(Visitor* visitor) 1957 void InspectorStyleSheetForInlineStyle::trace(Visitor* visitor)
1958 { 1958 {
1959 visitor->trace(m_element); 1959 visitor->trace(m_element);
1960 visitor->trace(m_ruleSourceData); 1960 visitor->trace(m_ruleSourceData);
1961 visitor->trace(m_inspectorStyle); 1961 visitor->trace(m_inspectorStyle);
1962 InspectorStyleSheetBase::trace(visitor); 1962 InspectorStyleSheetBase::trace(visitor);
1963 } 1963 }
1964 1964
1965 } // namespace blink 1965 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698