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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 TextPosition end = TextPosition::fromOffsetAndLineEndings(range.end, *lineEn
dings); | 464 TextPosition end = TextPosition::fromOffsetAndLineEndings(range.end, *lineEn
dings); |
465 | 465 |
466 RefPtr<TypeBuilder::CSS::SourceRange> result = TypeBuilder::CSS::SourceRange
::create() | 466 RefPtr<TypeBuilder::CSS::SourceRange> result = TypeBuilder::CSS::SourceRange
::create() |
467 .setStartLine(start.m_line.zeroBasedInt()) | 467 .setStartLine(start.m_line.zeroBasedInt()) |
468 .setStartColumn(start.m_column.zeroBasedInt()) | 468 .setStartColumn(start.m_column.zeroBasedInt()) |
469 .setEndLine(end.m_line.zeroBasedInt()) | 469 .setEndLine(end.m_line.zeroBasedInt()) |
470 .setEndColumn(end.m_column.zeroBasedInt()); | 470 .setEndColumn(end.m_column.zeroBasedInt()); |
471 return result.release(); | 471 return result.release(); |
472 } | 472 } |
473 | 473 |
474 static PassRefPtr<CSSRuleList> asCSSRuleList(CSSStyleSheet* styleSheet) | 474 static PassRefPtrWillBeRawPtr<CSSRuleList> asCSSRuleList(CSSStyleSheet* styleShe
et) |
475 { | 475 { |
476 if (!styleSheet) | 476 if (!styleSheet) |
477 return nullptr; | 477 return nullptr; |
478 | 478 |
479 RefPtr<StaticCSSRuleList> list = StaticCSSRuleList::create(); | 479 RefPtrWillBeRawPtr<StaticCSSRuleList> list = StaticCSSRuleList::create(); |
480 WillBePersistentHeapVector<RefPtrWillBeMember<CSSRule> >& listRules = list->
rules(); | 480 WillBeHeapVector<RefPtrWillBeMember<CSSRule> >& listRules = list->rules(); |
481 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { | 481 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { |
482 CSSRule* item = styleSheet->item(i); | 482 CSSRule* item = styleSheet->item(i); |
483 if (item->type() == CSSRule::CHARSET_RULE) | 483 if (item->type() == CSSRule::CHARSET_RULE) |
484 continue; | 484 continue; |
485 listRules.append(item); | 485 listRules.append(item); |
486 } | 486 } |
487 return list.release(); | 487 return list.release(); |
488 } | 488 } |
489 | 489 |
490 static PassRefPtr<CSSRuleList> asCSSRuleList(CSSRule* rule) | 490 static PassRefPtrWillBeRawPtr<CSSRuleList> asCSSRuleList(CSSRule* rule) |
491 { | 491 { |
492 if (!rule) | 492 if (!rule) |
493 return nullptr; | 493 return nullptr; |
494 | 494 |
495 if (rule->type() == CSSRule::MEDIA_RULE) | 495 if (rule->type() == CSSRule::MEDIA_RULE) |
496 return toCSSMediaRule(rule)->cssRules(); | 496 return toCSSMediaRule(rule)->cssRules(); |
497 | 497 |
498 if (rule->type() == CSSRule::KEYFRAMES_RULE) | 498 if (rule->type() == CSSRule::KEYFRAMES_RULE) |
499 return toCSSKeyframesRule(rule)->cssRules(); | 499 return toCSSKeyframesRule(rule)->cssRules(); |
500 | 500 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 | 840 |
841 // static | 841 // static |
842 String InspectorStyleSheet::styleSheetURL(CSSStyleSheet* pageStyleSheet) | 842 String InspectorStyleSheet::styleSheetURL(CSSStyleSheet* pageStyleSheet) |
843 { | 843 { |
844 if (pageStyleSheet && !pageStyleSheet->contents()->baseURL().isEmpty()) | 844 if (pageStyleSheet && !pageStyleSheet->contents()->baseURL().isEmpty()) |
845 return pageStyleSheet->contents()->baseURL().string(); | 845 return pageStyleSheet->contents()->baseURL().string(); |
846 return emptyString(); | 846 return emptyString(); |
847 } | 847 } |
848 | 848 |
849 // static | 849 // static |
850 void InspectorStyleSheet::collectFlatRules(PassRefPtr<CSSRuleList> ruleList, CSS
RuleVector* result) | 850 void InspectorStyleSheet::collectFlatRules(PassRefPtrWillBeRawPtr<CSSRuleList> r
uleList, CSSRuleVector* result) |
851 { | 851 { |
852 if (!ruleList) | 852 if (!ruleList) |
853 return; | 853 return; |
854 | 854 |
855 for (unsigned i = 0, size = ruleList->length(); i < size; ++i) { | 855 for (unsigned i = 0, size = ruleList->length(); i < size; ++i) { |
856 CSSRule* rule = ruleList->item(i); | 856 CSSRule* rule = ruleList->item(i); |
857 | 857 |
858 // The result->append()'ed types should be exactly the same as in Parsed
StyleSheet::flattenSourceData(). | 858 // The result->append()'ed types should be exactly the same as in Parsed
StyleSheet::flattenSourceData(). |
859 switch (rule->type()) { | 859 switch (rule->type()) { |
860 case CSSRule::STYLE_RULE: | 860 case CSSRule::STYLE_RULE: |
861 result->append(rule); | 861 result->append(rule); |
862 continue; | 862 continue; |
863 case CSSRule::IMPORT_RULE: | 863 case CSSRule::IMPORT_RULE: |
864 case CSSRule::MEDIA_RULE: | 864 case CSSRule::MEDIA_RULE: |
865 result->append(rule); | 865 result->append(rule); |
866 break; | 866 break; |
867 default: | 867 default: |
868 break; | 868 break; |
869 } | 869 } |
870 RefPtr<CSSRuleList> childRuleList = asCSSRuleList(rule); | 870 RefPtrWillBeRawPtr<CSSRuleList> childRuleList = asCSSRuleList(rule); |
871 if (childRuleList) | 871 if (childRuleList) |
872 collectFlatRules(childRuleList, result); | 872 collectFlatRules(childRuleList, result); |
873 } | 873 } |
874 } | 874 } |
875 | 875 |
876 InspectorStyleSheet::InspectorStyleSheet(InspectorPageAgent* pageAgent, Inspecto
rResourceAgent* resourceAgent, const String& id, PassRefPtr<CSSStyleSheet> pageS
tyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& docume
ntURL, Listener* listener) | 876 InspectorStyleSheet::InspectorStyleSheet(InspectorPageAgent* pageAgent, Inspecto
rResourceAgent* resourceAgent, const String& id, PassRefPtr<CSSStyleSheet> pageS
tyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum origin, const String& docume
ntURL, Listener* listener) |
877 : m_pageAgent(pageAgent) | 877 : m_pageAgent(pageAgent) |
878 , m_resourceAgent(resourceAgent) | 878 , m_resourceAgent(resourceAgent) |
879 , m_id(id) | 879 , m_id(id) |
880 , m_pageStyleSheet(pageStyleSheet) | 880 , m_pageStyleSheet(pageStyleSheet) |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 | 1650 |
1651 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); | 1651 RefPtr<MutableStylePropertySet> tempDeclaration = MutableStylePropertySet::c
reate(); |
1652 RuleSourceDataList ruleSourceDataResult; | 1652 RuleSourceDataList ruleSourceDataResult; |
1653 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do
cument().elementSheet().contents(), &ruleSourceDataResult); | 1653 StyleSheetHandler handler(m_styleText, &m_element->document(), m_element->do
cument().elementSheet().contents(), &ruleSourceDataResult); |
1654 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge
t(), m_styleText, &handler, m_element->document().elementSheet().contents()); | 1654 createCSSParser(&m_element->document())->parseDeclaration(tempDeclaration.ge
t(), m_styleText, &handler, m_element->document().elementSheet().contents()); |
1655 return ruleSourceDataResult.first().release(); | 1655 return ruleSourceDataResult.first().release(); |
1656 } | 1656 } |
1657 | 1657 |
1658 } // namespace WebCore | 1658 } // namespace WebCore |
1659 | 1659 |
OLD | NEW |