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

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

Issue 884753003: Fix template angle bracket syntax in inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Some more fixes Created 5 years, 10 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
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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (!m_styleId.isEmpty()) 547 if (!m_styleId.isEmpty())
548 result->setStyleSheetId(m_styleId.styleSheetId()); 548 result->setStyleSheetId(m_styleId.styleSheetId());
549 549
550 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData(); 550 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData();
551 if (sourceData) 551 if (sourceData)
552 result->setRange(buildSourceRangeObject(sourceData->ruleBodyRange, m_par entStyleSheet->lineEndings())); 552 result->setRange(buildSourceRangeObject(sourceData->ruleBodyRange, m_par entStyleSheet->lineEndings()));
553 553
554 return result.release(); 554 return result.release();
555 } 555 }
556 556
557 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > Insp ectorStyle::buildArrayForComputedStyle() const 557 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty>> Inspe ctorStyle::buildArrayForComputedStyle() const
558 { 558 {
559 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > resu lt = TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty>::create(); 559 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty>> resul t = TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty>::create();
560 WillBeHeapVector<InspectorStyleProperty> properties; 560 WillBeHeapVector<InspectorStyleProperty> properties;
561 populateAllProperties(properties); 561 populateAllProperties(properties);
562 562
563 for (auto& property : properties) { 563 for (auto& property : properties) {
564 const CSSPropertySourceData& propertyEntry = property.sourceData; 564 const CSSPropertySourceData& propertyEntry = property.sourceData;
565 RefPtr<TypeBuilder::CSS::CSSComputedStyleProperty> entry = TypeBuilder:: CSS::CSSComputedStyleProperty::create() 565 RefPtr<TypeBuilder::CSS::CSSComputedStyleProperty> entry = TypeBuilder:: CSS::CSSComputedStyleProperty::create()
566 .setName(propertyEntry.name) 566 .setName(propertyEntry.name)
567 .setValue(propertyEntry.value); 567 .setValue(propertyEntry.value);
568 result->addItem(entry); 568 result->addItem(entry);
569 } 569 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 686
687 String value = m_style->getPropertyValue(name); 687 String value = m_style->getPropertyValue(name);
688 if (value.isEmpty()) 688 if (value.isEmpty())
689 continue; 689 continue;
690 result.append(InspectorStyleProperty(CSSPropertySourceData(name, value, !m_style->getPropertyPriority(name).isEmpty(), false, true, SourceRange()), fals e)); 690 result.append(InspectorStyleProperty(CSSPropertySourceData(name, value, !m_style->getPropertyPriority(name).isEmpty(), false, true, SourceRange()), fals e));
691 } 691 }
692 } 692 }
693 693
694 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::styleWithProperties() con st 694 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::styleWithProperties() con st
695 { 695 {
696 RefPtr<Array<TypeBuilder::CSS::CSSProperty> > propertiesObject = Array<TypeB uilder::CSS::CSSProperty>::create(); 696 RefPtr<Array<TypeBuilder::CSS::CSSProperty>> propertiesObject = Array<TypeBu ilder::CSS::CSSProperty>::create();
697 RefPtr<Array<TypeBuilder::CSS::ShorthandEntry> > shorthandEntries = Array<Ty peBuilder::CSS::ShorthandEntry>::create(); 697 RefPtr<Array<TypeBuilder::CSS::ShorthandEntry>> shorthandEntries = Array<Typ eBuilder::CSS::ShorthandEntry>::create();
698 HashSet<String> foundShorthands; 698 HashSet<String> foundShorthands;
699 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData(); 699 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = extractSourceData();
700 700
701 WillBeHeapVector<InspectorStyleProperty> properties; 701 WillBeHeapVector<InspectorStyleProperty> properties;
702 populateAllProperties(properties); 702 populateAllProperties(properties);
703 703
704 for (auto& styleProperty : properties) { 704 for (auto& styleProperty : properties) {
705 const CSSPropertySourceData& propertyEntry = styleProperty.sourceData; 705 const CSSPropertySourceData& propertyEntry = styleProperty.sourceData;
706 const String& name = propertyEntry.name; 706 const String& name = propertyEntry.name;
707 707
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 1419
1420 if (styleSheet->ownerNode()) 1420 if (styleSheet->ownerNode())
1421 result->setOwnerNode(InspectorNodeIds::idForNode(styleSheet->ownerNode() )); 1421 result->setOwnerNode(InspectorNodeIds::idForNode(styleSheet->ownerNode() ));
1422 1422
1423 String sourceMapURLValue = sourceMapURL(); 1423 String sourceMapURLValue = sourceMapURL();
1424 if (!sourceMapURLValue.isEmpty()) 1424 if (!sourceMapURLValue.isEmpty())
1425 result->setSourceMapURL(sourceMapURLValue); 1425 result->setSourceMapURL(sourceMapURLValue);
1426 return result.release(); 1426 return result.release();
1427 } 1427 }
1428 1428
1429 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > InspectorStyleSheet: :selectorsFromSource(const CSSRuleSourceData* sourceData, const String& sheetTex t) 1429 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector>> InspectorStyleSheet:: selectorsFromSource(const CSSRuleSourceData* sourceData, const String& sheetText )
1430 { 1430 {
1431 ScriptRegexp comment("/\\*[^]*?\\*/", TextCaseSensitive, MultilineEnabled); 1431 ScriptRegexp comment("/\\*[^]*?\\*/", TextCaseSensitive, MultilineEnabled);
1432 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > result = TypeBuilder ::Array<TypeBuilder::CSS::Selector>::create(); 1432 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector>> result = TypeBuilder: :Array<TypeBuilder::CSS::Selector>::create();
1433 const SelectorRangeList& ranges = sourceData->selectorRanges; 1433 const SelectorRangeList& ranges = sourceData->selectorRanges;
1434 for (size_t i = 0, size = ranges.size(); i < size; ++i) { 1434 for (size_t i = 0, size = ranges.size(); i < size; ++i) {
1435 const SourceRange& range = ranges.at(i); 1435 const SourceRange& range = ranges.at(i);
1436 String selector = sheetText.substring(range.start, range.length()); 1436 String selector = sheetText.substring(range.start, range.length());
1437 1437
1438 // We don't want to see any comments in the selector components, only th e meaningful parts. 1438 // We don't want to see any comments in the selector components, only th e meaningful parts.
1439 int matchLength; 1439 int matchLength;
1440 int offset = 0; 1440 int offset = 0;
1441 while ((offset = comment.match(selector, offset, &matchLength)) >= 0) 1441 while ((offset = comment.match(selector, offset, &matchLength)) >= 0)
1442 selector.replace(offset, matchLength, ""); 1442 selector.replace(offset, matchLength, "");
1443 1443
1444 RefPtr<TypeBuilder::CSS::Selector> simpleSelector = TypeBuilder::CSS::Se lector::create() 1444 RefPtr<TypeBuilder::CSS::Selector> simpleSelector = TypeBuilder::CSS::Se lector::create()
1445 .setValue(selector.stripWhiteSpace()); 1445 .setValue(selector.stripWhiteSpace());
1446 simpleSelector->setRange(buildSourceRangeObject(range, lineEndings())); 1446 simpleSelector->setRange(buildSourceRangeObject(range, lineEndings()));
1447 result->addItem(simpleSelector.release()); 1447 result->addItem(simpleSelector.release());
1448 } 1448 }
1449 return result.release(); 1449 return result.release();
1450 } 1450 }
1451 1451
1452 PassRefPtr<TypeBuilder::CSS::SelectorList> InspectorStyleSheet::buildObjectForSe lectorList(CSSStyleRule* rule) 1452 PassRefPtr<TypeBuilder::CSS::SelectorList> InspectorStyleSheet::buildObjectForSe lectorList(CSSStyleRule* rule)
1453 { 1453 {
1454 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = nullptr; 1454 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = nullptr;
1455 if (ensureParsedDataReady()) 1455 if (ensureParsedDataReady())
1456 sourceData = ruleSourceDataAt(styleId(rule->style()).ordinal()); 1456 sourceData = ruleSourceDataAt(styleId(rule->style()).ordinal());
1457 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectors; 1457 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector>> selectors;
1458 1458
1459 // This intentionally does not rely on the source data to avoid catching the trailing comments (before the declaration starting '{'). 1459 // This intentionally does not rely on the source data to avoid catching the trailing comments (before the declaration starting '{').
1460 String selectorText = rule->selectorText(); 1460 String selectorText = rule->selectorText();
1461 1461
1462 if (sourceData) 1462 if (sourceData)
1463 selectors = selectorsFromSource(sourceData.get(), m_parsedStyleSheet->te xt()); 1463 selectors = selectorsFromSource(sourceData.get(), m_parsedStyleSheet->te xt());
1464 else { 1464 else {
1465 selectors = TypeBuilder::Array<TypeBuilder::CSS::Selector>::create(); 1465 selectors = TypeBuilder::Array<TypeBuilder::CSS::Selector>::create();
1466 const CSSSelectorList& selectorList = rule->styleRule()->selectorList(); 1466 const CSSSelectorList& selectorList = rule->styleRule()->selectorList();
1467 for (const CSSSelector* selector = selectorList.first(); selector; selec tor = CSSSelectorList::next(*selector)) 1467 for (const CSSSelector* selector = selectorList.first(); selector; selec tor = CSSSelectorList::next(*selector))
1468 selectors->addItem(TypeBuilder::CSS::Selector::create().setValue(sel ector->selectorText()).release()); 1468 selectors->addItem(TypeBuilder::CSS::Selector::create().setValue(sel ector->selectorText()).release());
1469 } 1469 }
1470 RefPtr<TypeBuilder::CSS::SelectorList> result = TypeBuilder::CSS::SelectorLi st::create() 1470 RefPtr<TypeBuilder::CSS::SelectorList> result = TypeBuilder::CSS::SelectorLi st::create()
1471 .setSelectors(selectors) 1471 .setSelectors(selectors)
1472 .setText(selectorText) 1472 .setText(selectorText)
1473 .release(); 1473 .release();
1474 return result.release(); 1474 return result.release();
1475 } 1475 }
1476 1476
1477 static bool canBind(TypeBuilder::CSS::StyleSheetOrigin::Enum origin) 1477 static bool canBind(TypeBuilder::CSS::StyleSheetOrigin::Enum origin)
1478 { 1478 {
1479 return origin != TypeBuilder::CSS::StyleSheetOrigin::User_agent && origin != TypeBuilder::CSS::StyleSheetOrigin::Injected; 1479 return origin != TypeBuilder::CSS::StyleSheetOrigin::User_agent && origin != TypeBuilder::CSS::StyleSheetOrigin::Injected;
1480 } 1480 }
1481 1481
1482 PassRefPtr<TypeBuilder::CSS::CSSRule> InspectorStyleSheet::buildObjectForRule(CS SStyleRule* rule, PassRefPtr<Array<TypeBuilder::CSS::CSSMedia> > mediaStack) 1482 PassRefPtr<TypeBuilder::CSS::CSSRule> InspectorStyleSheet::buildObjectForRule(CS SStyleRule* rule, PassRefPtr<Array<TypeBuilder::CSS::CSSMedia>> mediaStack)
1483 { 1483 {
1484 CSSStyleSheet* styleSheet = pageStyleSheet(); 1484 CSSStyleSheet* styleSheet = pageStyleSheet();
1485 if (!styleSheet) 1485 if (!styleSheet)
1486 return nullptr; 1486 return nullptr;
1487 1487
1488 RefPtr<TypeBuilder::CSS::CSSRule> result = TypeBuilder::CSS::CSSRule::create () 1488 RefPtr<TypeBuilder::CSS::CSSRule> result = TypeBuilder::CSS::CSSRule::create ()
1489 .setSelectorList(buildObjectForSelectorList(rule)) 1489 .setSelectorList(buildObjectForSelectorList(rule))
1490 .setOrigin(m_origin) 1490 .setOrigin(m_origin)
1491 .setStyle(buildObjectForStyle(rule->style())); 1491 .setStyle(buildObjectForStyle(rule->style()));
1492 1492
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 1989
1990 void InspectorStyleSheetForInlineStyle::trace(Visitor* visitor) 1990 void InspectorStyleSheetForInlineStyle::trace(Visitor* visitor)
1991 { 1991 {
1992 visitor->trace(m_element); 1992 visitor->trace(m_element);
1993 visitor->trace(m_ruleSourceData); 1993 visitor->trace(m_ruleSourceData);
1994 visitor->trace(m_inspectorStyle); 1994 visitor->trace(m_inspectorStyle);
1995 InspectorStyleSheetBase::trace(visitor); 1995 InspectorStyleSheetBase::trace(visitor);
1996 } 1996 }
1997 1997
1998 } // namespace blink 1998 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorStyleSheet.h ('k') | Source/core/inspector/InspectorTimelineAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698