| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "core/page/ContentSecurityPolicy.h" | 57 #include "core/page/ContentSecurityPolicy.h" |
| 58 #include "core/platform/text/RegularExpression.h" | 58 #include "core/platform/text/RegularExpression.h" |
| 59 #include "heap/Handle.h" | 59 #include "heap/Handle.h" |
| 60 | 60 |
| 61 #include <wtf/OwnPtr.h> | 61 #include <wtf/OwnPtr.h> |
| 62 #include <wtf/PassOwnPtr.h> | 62 #include <wtf/PassOwnPtr.h> |
| 63 #include <wtf/text/StringBuilder.h> | 63 #include <wtf/text/StringBuilder.h> |
| 64 #include <wtf/Vector.h> | 64 #include <wtf/Vector.h> |
| 65 | 65 |
| 66 using WebCore::CSSRuleSourceData; | 66 using WebCore::CSSRuleSourceData; |
| 67 using WebCore::Handle; | 67 // FIXME(oilpan): On mac we cannot add 'using WebCore::Handle' here because |
| 68 // it conflicts with a core framework Handle type that is visible here. |
| 68 using WebCore::Member; | 69 using WebCore::Member; |
| 69 using WebCore::Result; | 70 using WebCore::Result; |
| 70 using WebCore::RuleSourceDataVectorCollection; | 71 using WebCore::RuleSourceDataVectorCollection; |
| 71 using WebCore::TypeBuilder::Array; | 72 using WebCore::TypeBuilder::Array; |
| 72 | 73 |
| 73 class ParsedStyleSheet { | 74 class ParsedStyleSheet { |
| 74 WTF_MAKE_FAST_ALLOCATED; | 75 WTF_MAKE_FAST_ALLOCATED; |
| 75 public: | 76 public: |
| 76 ParsedStyleSheet(); | 77 ParsedStyleSheet(); |
| 77 | 78 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 102 m_hasText = true; | 103 m_hasText = true; |
| 103 m_text = text; | 104 m_text = text; |
| 104 setSourceData(nullptr); | 105 setSourceData(nullptr); |
| 105 } | 106 } |
| 106 | 107 |
| 107 // It's safe to use a reference since the lifetime of RuleSourceDataVectorCollec
tion | 108 // It's safe to use a reference since the lifetime of RuleSourceDataVectorCollec
tion |
| 108 // is retained by ParsedStyleSheet::setSourceData(). | 109 // is retained by ParsedStyleSheet::setSourceData(). |
| 109 static void flattenSourceData(Vector<Member<CSSRuleSourceData> >& dataList, Vect
or<Member<CSSRuleSourceData> >& target) | 110 static void flattenSourceData(Vector<Member<CSSRuleSourceData> >& dataList, Vect
or<Member<CSSRuleSourceData> >& target) |
| 110 { | 111 { |
| 111 for (size_t i = 0; i < dataList.size(); ++i) { | 112 for (size_t i = 0; i < dataList.size(); ++i) { |
| 112 Handle<CSSRuleSourceData> data = dataList.at(i); | 113 WebCore::Handle<CSSRuleSourceData> data = dataList.at(i); |
| 113 if (data->type == CSSRuleSourceData::STYLE_RULE) | 114 if (data->type == CSSRuleSourceData::STYLE_RULE) |
| 114 target.append(data); | 115 target.append(data); |
| 115 else if (data->type == CSSRuleSourceData::MEDIA_RULE) | 116 else if (data->type == CSSRuleSourceData::MEDIA_RULE) |
| 116 flattenSourceData(data->childRules, target); | 117 flattenSourceData(data->childRules, target); |
| 117 else if (data->type == CSSRuleSourceData::HOST_RULE) | 118 else if (data->type == CSSRuleSourceData::HOST_RULE) |
| 118 flattenSourceData(data->childRules, target); | 119 flattenSourceData(data->childRules, target); |
| 119 else if (data->type == CSSRuleSourceData::SUPPORTS_RULE) | 120 else if (data->type == CSSRuleSourceData::SUPPORTS_RULE) |
| 120 flattenSourceData(data->childRules, target); | 121 flattenSourceData(data->childRules, target); |
| 121 } | 122 } |
| 122 } | 123 } |
| (...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 } | 1828 } |
| 1828 Handle<StylePropertySet> tempDeclaration = StylePropertySet::create(); | 1829 Handle<StylePropertySet> tempDeclaration = StylePropertySet::create(); |
| 1829 RuleSourceDataVectorCollection ruleSourceDataResult; | 1830 RuleSourceDataVectorCollection ruleSourceDataResult; |
| 1830 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc
ument()->elementSheet()->contents(), &ruleSourceDataResult); | 1831 StyleSheetHandler handler(m_styleText, m_element->document(), m_element->doc
ument()->elementSheet()->contents(), &ruleSourceDataResult); |
| 1831 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration, m_
styleText, &handler, m_element->document()->elementSheet()->contents()); | 1832 createCSSParser(m_element->document())->parseDeclaration(tempDeclaration, m_
styleText, &handler, m_element->document()->elementSheet()->contents()); |
| 1832 return ruleSourceDataResult->first(); | 1833 return ruleSourceDataResult->first(); |
| 1833 } | 1834 } |
| 1834 | 1835 |
| 1835 } // namespace WebCore | 1836 } // namespace WebCore |
| 1836 | 1837 |
| OLD | NEW |