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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 | 636 |
637 namespace blink { | 637 namespace blink { |
638 | 638 |
639 enum MediaListSource { | 639 enum MediaListSource { |
640 MediaListSourceLinkedSheet, | 640 MediaListSourceLinkedSheet, |
641 MediaListSourceInlineSheet, | 641 MediaListSourceInlineSheet, |
642 MediaListSourceMediaRule, | 642 MediaListSourceMediaRule, |
643 MediaListSourceImportRule | 643 MediaListSourceImportRule |
644 }; | 644 }; |
645 | 645 |
646 static PassRefPtr<TypeBuilder::CSS::SourceRange> buildSourceRangeObject(const So
urceRange& range, const LineEndings* lineEndings) | 646 PassRefPtr<TypeBuilder::CSS::SourceRange> InspectorStyleSheetBase::buildSourceRa
ngeObject(const SourceRange& range) |
647 { | 647 { |
| 648 const LineEndings* lineEndings = this->lineEndings(); |
648 if (!lineEndings) | 649 if (!lineEndings) |
649 return nullptr; | 650 return nullptr; |
650 TextPosition start = TextPosition::fromOffsetAndLineEndings(range.start, *li
neEndings); | 651 TextPosition start = TextPosition::fromOffsetAndLineEndings(range.start, *li
neEndings); |
651 TextPosition end = TextPosition::fromOffsetAndLineEndings(range.end, *lineEn
dings); | 652 TextPosition end = TextPosition::fromOffsetAndLineEndings(range.end, *lineEn
dings); |
652 | 653 |
653 RefPtr<TypeBuilder::CSS::SourceRange> result = TypeBuilder::CSS::SourceRange
::create() | 654 RefPtr<TypeBuilder::CSS::SourceRange> result = TypeBuilder::CSS::SourceRange
::create() |
654 .setStartLine(start.m_line.zeroBasedInt()) | 655 .setStartLine(start.m_line.zeroBasedInt()) |
655 .setStartColumn(start.m_column.zeroBasedInt()) | 656 .setStartColumn(start.m_column.zeroBasedInt()) |
656 .setEndLine(end.m_line.zeroBasedInt()) | 657 .setEndLine(end.m_line.zeroBasedInt()) |
657 .setEndColumn(end.m_column.zeroBasedInt()); | 658 .setEndColumn(end.m_column.zeroBasedInt()); |
(...skipping 12 matching lines...) Expand all Loading... |
670 { | 671 { |
671 ASSERT(m_style); | 672 ASSERT(m_style); |
672 } | 673 } |
673 | 674 |
674 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::buildObjectForStyle() | 675 PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorStyle::buildObjectForStyle() |
675 { | 676 { |
676 RefPtr<TypeBuilder::CSS::CSSStyle> result = styleWithProperties(); | 677 RefPtr<TypeBuilder::CSS::CSSStyle> result = styleWithProperties(); |
677 if (m_sourceData) { | 678 if (m_sourceData) { |
678 if (m_parentStyleSheet && !m_parentStyleSheet->id().isEmpty()) | 679 if (m_parentStyleSheet && !m_parentStyleSheet->id().isEmpty()) |
679 result->setStyleSheetId(m_parentStyleSheet->id()); | 680 result->setStyleSheetId(m_parentStyleSheet->id()); |
680 result->setRange(buildSourceRangeObject(m_sourceData->ruleBodyRange, m_p
arentStyleSheet->lineEndings())); | 681 result->setRange(m_parentStyleSheet->buildSourceRangeObject(m_sourceData
->ruleBodyRange)); |
681 String sheetText; | 682 String sheetText; |
682 bool success = m_parentStyleSheet->getText(&sheetText); | 683 bool success = m_parentStyleSheet->getText(&sheetText); |
683 if (success) { | 684 if (success) { |
684 const SourceRange& bodyRange = m_sourceData->ruleBodyRange; | 685 const SourceRange& bodyRange = m_sourceData->ruleBodyRange; |
685 result->setCssText(sheetText.substring(bodyRange.start, bodyRange.en
d - bodyRange.start)); | 686 result->setCssText(sheetText.substring(bodyRange.start, bodyRange.en
d - bodyRange.start)); |
686 } | 687 } |
687 } | 688 } |
688 | 689 |
689 return result.release(); | 690 return result.release(); |
690 } | 691 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 772 |
772 // Default "parsedOk" == true. | 773 // Default "parsedOk" == true. |
773 if (!propertyEntry.parsedOk) | 774 if (!propertyEntry.parsedOk) |
774 property->setParsedOk(false); | 775 property->setParsedOk(false); |
775 String text; | 776 String text; |
776 if (styleProperty.range.length() && textForRange(styleProperty.range, &t
ext)) | 777 if (styleProperty.range.length() && textForRange(styleProperty.range, &t
ext)) |
777 property->setText(text); | 778 property->setText(text); |
778 if (propertyEntry.important) | 779 if (propertyEntry.important) |
779 property->setImportant(true); | 780 property->setImportant(true); |
780 if (styleProperty.range.length()) { | 781 if (styleProperty.range.length()) { |
781 property->setRange(buildSourceRangeObject(propertyEntry.range, m_par
entStyleSheet ? m_parentStyleSheet->lineEndings() : nullptr)); | 782 property->setRange(m_parentStyleSheet ? m_parentStyleSheet->buildSou
rceRangeObject(propertyEntry.range) : nullptr); |
782 if (!propertyEntry.disabled) { | 783 if (!propertyEntry.disabled) { |
783 property->setImplicit(false); | 784 property->setImplicit(false); |
784 } | 785 } |
785 property->setDisabled(propertyEntry.disabled); | 786 property->setDisabled(propertyEntry.disabled); |
786 } else if (!propertyEntry.disabled) { | 787 } else if (!propertyEntry.disabled) { |
787 bool implicit = m_style->isPropertyImplicit(name); | 788 bool implicit = m_style->isPropertyImplicit(name); |
788 // Default "implicit" == false. | 789 // Default "implicit" == false. |
789 if (implicit) | 790 if (implicit) |
790 property->setImplicit(true); | 791 property->setImplicit(true); |
791 | 792 |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 String selector = sheetText.substring(range.start, range.length()); | 1299 String selector = sheetText.substring(range.start, range.length()); |
1299 | 1300 |
1300 // We don't want to see any comments in the selector components, only th
e meaningful parts. | 1301 // We don't want to see any comments in the selector components, only th
e meaningful parts. |
1301 int matchLength; | 1302 int matchLength; |
1302 int offset = 0; | 1303 int offset = 0; |
1303 while ((offset = comment.match(selector, offset, &matchLength)) >= 0) | 1304 while ((offset = comment.match(selector, offset, &matchLength)) >= 0) |
1304 selector.replace(offset, matchLength, ""); | 1305 selector.replace(offset, matchLength, ""); |
1305 | 1306 |
1306 RefPtr<TypeBuilder::CSS::Selector> simpleSelector = TypeBuilder::CSS::Se
lector::create() | 1307 RefPtr<TypeBuilder::CSS::Selector> simpleSelector = TypeBuilder::CSS::Se
lector::create() |
1307 .setValue(selector.stripWhiteSpace()); | 1308 .setValue(selector.stripWhiteSpace()); |
1308 simpleSelector->setRange(buildSourceRangeObject(range, lineEndings())); | 1309 simpleSelector->setRange(buildSourceRangeObject(range)); |
1309 result->addItem(simpleSelector.release()); | 1310 result->addItem(simpleSelector.release()); |
1310 } | 1311 } |
1311 return result.release(); | 1312 return result.release(); |
1312 } | 1313 } |
1313 | 1314 |
1314 PassRefPtr<TypeBuilder::CSS::SelectorList> InspectorStyleSheet::buildObjectForSe
lectorList(CSSStyleRule* rule) | 1315 PassRefPtr<TypeBuilder::CSS::SelectorList> InspectorStyleSheet::buildObjectForSe
lectorList(CSSStyleRule* rule) |
1315 { | 1316 { |
1316 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = sourceDataForRule(rule); | 1317 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = sourceDataForRule(rule); |
1317 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectors; | 1318 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectors; |
1318 | 1319 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 return false; | 1368 return false; |
1368 } | 1369 } |
1369 | 1370 |
1370 PassRefPtr<TypeBuilder::CSS::SourceRange> InspectorStyleSheet::ruleHeaderSourceR
ange(CSSRule* rule) | 1371 PassRefPtr<TypeBuilder::CSS::SourceRange> InspectorStyleSheet::ruleHeaderSourceR
ange(CSSRule* rule) |
1371 { | 1372 { |
1372 if (!m_sourceData) | 1373 if (!m_sourceData) |
1373 return nullptr; | 1374 return nullptr; |
1374 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = sourceDataForRule(rule); | 1375 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = sourceDataForRule(rule); |
1375 if (!sourceData) | 1376 if (!sourceData) |
1376 return nullptr; | 1377 return nullptr; |
1377 return buildSourceRangeObject(sourceData->ruleHeaderRange, lineEndings()); | 1378 return buildSourceRangeObject(sourceData->ruleHeaderRange); |
1378 } | 1379 } |
1379 | 1380 |
1380 PassRefPtr<TypeBuilder::CSS::SourceRange> InspectorStyleSheet::mediaQueryExpValu
eSourceRange(CSSRule* rule, size_t mediaQueryIndex, size_t mediaQueryExpIndex) | 1381 PassRefPtr<TypeBuilder::CSS::SourceRange> InspectorStyleSheet::mediaQueryExpValu
eSourceRange(CSSRule* rule, size_t mediaQueryIndex, size_t mediaQueryExpIndex) |
1381 { | 1382 { |
1382 if (!m_sourceData) | 1383 if (!m_sourceData) |
1383 return nullptr; | 1384 return nullptr; |
1384 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = sourceDataForRule(rule); | 1385 RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = sourceDataForRule(rule); |
1385 if (!sourceData || !sourceData->mediaSourceData || mediaQueryIndex >= source
Data->mediaSourceData->queryData.size()) | 1386 if (!sourceData || !sourceData->mediaSourceData || mediaQueryIndex >= source
Data->mediaSourceData->queryData.size()) |
1386 return nullptr; | 1387 return nullptr; |
1387 RefPtrWillBeRawPtr<CSSMediaQuerySourceData> mediaQueryData = sourceData->med
iaSourceData->queryData.at(mediaQueryIndex); | 1388 RefPtrWillBeRawPtr<CSSMediaQuerySourceData> mediaQueryData = sourceData->med
iaSourceData->queryData.at(mediaQueryIndex); |
1388 if (mediaQueryExpIndex >= mediaQueryData->expData.size()) | 1389 if (mediaQueryExpIndex >= mediaQueryData->expData.size()) |
1389 return nullptr; | 1390 return nullptr; |
1390 return buildSourceRangeObject(mediaQueryData->expData.at(mediaQueryExpIndex)
.valueRange, lineEndings()); | 1391 return buildSourceRangeObject(mediaQueryData->expData.at(mediaQueryExpIndex)
.valueRange); |
1391 } | 1392 } |
1392 | 1393 |
1393 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyleSheet::inspectorStyle(RefPt
rWillBeRawPtr<CSSStyleDeclaration> style) | 1394 PassRefPtrWillBeRawPtr<InspectorStyle> InspectorStyleSheet::inspectorStyle(RefPt
rWillBeRawPtr<CSSStyleDeclaration> style) |
1394 { | 1395 { |
1395 return style ? InspectorStyle::create(style, sourceDataForRule(style->parent
Rule()), this) : nullptr; | 1396 return style ? InspectorStyle::create(style, sourceDataForRule(style->parent
Rule()), this) : nullptr; |
1396 } | 1397 } |
1397 | 1398 |
1398 String InspectorStyleSheet::sourceURL() | 1399 String InspectorStyleSheet::sourceURL() |
1399 { | 1400 { |
1400 if (!m_sourceURL.isNull()) | 1401 if (!m_sourceURL.isNull()) |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 } | 1709 } |
1709 | 1710 |
1710 DEFINE_TRACE(InspectorStyleSheetForInlineStyle) | 1711 DEFINE_TRACE(InspectorStyleSheetForInlineStyle) |
1711 { | 1712 { |
1712 visitor->trace(m_element); | 1713 visitor->trace(m_element); |
1713 visitor->trace(m_inspectorStyle); | 1714 visitor->trace(m_inspectorStyle); |
1714 InspectorStyleSheetBase::trace(visitor); | 1715 InspectorStyleSheetBase::trace(visitor); |
1715 } | 1716 } |
1716 | 1717 |
1717 } // namespace blink | 1718 } // namespace blink |
OLD | NEW |