OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights
reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #ifndef CSSStyleSheet_h | 21 #ifndef CSSStyleSheet_h |
22 #define CSSStyleSheet_h | 22 #define CSSStyleSheet_h |
23 | 23 |
24 #include "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
25 #include "core/css/CSSRule.h" | 25 #include "core/css/CSSRule.h" |
| 26 #include "core/css/MediaQueryEvaluator.h" |
26 #include "core/css/StyleSheet.h" | 27 #include "core/css/StyleSheet.h" |
27 #include "platform/heap/Handle.h" | 28 #include "platform/heap/Handle.h" |
28 #include "wtf/Noncopyable.h" | 29 #include "wtf/Noncopyable.h" |
29 #include "wtf/text/TextPosition.h" | 30 #include "wtf/text/TextPosition.h" |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 class CSSImportRule; | 34 class CSSImportRule; |
34 class CSSRule; | 35 class CSSRule; |
35 class CSSRuleList; | 36 class CSSRuleList; |
36 class CSSStyleSheet; | 37 class CSSStyleSheet; |
37 class Document; | 38 class Document; |
38 class ExceptionState; | 39 class ExceptionState; |
39 class MediaQuerySet; | 40 class MediaQuerySet; |
40 class SecurityOrigin; | 41 class SecurityOrigin; |
41 class StyleSheetContents; | 42 class StyleSheetContents; |
42 | 43 |
43 enum StyleSheetUpdateType { | |
44 PartialRuleUpdate, | |
45 EntireStyleSheetUpdate | |
46 }; | |
47 | |
48 class CORE_EXPORT CSSStyleSheet final : public StyleSheet { | 44 class CORE_EXPORT CSSStyleSheet final : public StyleSheet { |
49 DEFINE_WRAPPERTYPEINFO(); | 45 DEFINE_WRAPPERTYPEINFO(); |
50 WTF_MAKE_NONCOPYABLE(CSSStyleSheet); | 46 WTF_MAKE_NONCOPYABLE(CSSStyleSheet); |
51 public: | 47 public: |
52 static CSSStyleSheet* create(StyleSheetContents*, CSSImportRule* ownerRule =
0); | 48 static CSSStyleSheet* create(StyleSheetContents*, CSSImportRule* ownerRule =
0); |
53 static CSSStyleSheet* create(StyleSheetContents*, Node* ownerNode); | 49 static CSSStyleSheet* create(StyleSheetContents*, Node* ownerNode); |
54 static CSSStyleSheet* createInline(Node*, const KURL&, const TextPosition& s
tartPosition = TextPosition::minimumPosition(), const String& encoding = String(
)); | 50 static CSSStyleSheet* createInline(Node*, const KURL&, const TextPosition& s
tartPosition = TextPosition::minimumPosition(), const String& encoding = String(
)); |
55 static CSSStyleSheet* createInline(StyleSheetContents*, Node* ownerNode, con
st TextPosition& startPosition = TextPosition::minimumPosition()); | 51 static CSSStyleSheet* createInline(StyleSheetContents*, Node* ownerNode, con
st TextPosition& startPosition = TextPosition::minimumPosition()); |
56 | 52 |
57 ~CSSStyleSheet() override; | 53 ~CSSStyleSheet() override; |
(...skipping 24 matching lines...) Expand all Loading... |
82 void clearOwnerNode() override; | 78 void clearOwnerNode() override; |
83 | 79 |
84 CSSRule* ownerRule() const override { return m_ownerRule; } | 80 CSSRule* ownerRule() const override { return m_ownerRule; } |
85 KURL baseURL() const override; | 81 KURL baseURL() const override; |
86 bool isLoading() const override; | 82 bool isLoading() const override; |
87 | 83 |
88 void clearOwnerRule() { m_ownerRule = nullptr; } | 84 void clearOwnerRule() { m_ownerRule = nullptr; } |
89 Document* ownerDocument() const; | 85 Document* ownerDocument() const; |
90 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } | 86 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } |
91 void setMediaQueries(MediaQuerySet*); | 87 void setMediaQueries(MediaQuerySet*); |
| 88 bool matchesMediaQueries(const MediaQueryEvaluator&); |
| 89 const MediaQueryResultList& viewportDependentMediaQueryResults() const { ret
urn m_viewportDependentMediaQueryResults; } |
| 90 const MediaQueryResultList& deviceDependentMediaQueryResults() const { retur
n m_deviceDependentMediaQueryResults; } |
92 void setTitle(const String& title) { m_title = title; } | 91 void setTitle(const String& title) { m_title = title; } |
93 // Set by LinkStyle iff CORS-enabled fetch of stylesheet succeeded from this
origin. | 92 // Set by LinkStyle iff CORS-enabled fetch of stylesheet succeeded from this
origin. |
94 void setAllowRuleAccessFromOrigin(PassRefPtr<SecurityOrigin> allowedOrigin); | 93 void setAllowRuleAccessFromOrigin(PassRefPtr<SecurityOrigin> allowedOrigin); |
95 | 94 |
96 class RuleMutationScope { | 95 class RuleMutationScope { |
97 WTF_MAKE_NONCOPYABLE(RuleMutationScope); | 96 WTF_MAKE_NONCOPYABLE(RuleMutationScope); |
98 STACK_ALLOCATED(); | 97 STACK_ALLOCATED(); |
99 public: | 98 public: |
100 explicit RuleMutationScope(CSSStyleSheet*); | 99 explicit RuleMutationScope(CSSStyleSheet*); |
101 explicit RuleMutationScope(CSSRule*); | 100 explicit RuleMutationScope(CSSRule*); |
102 ~RuleMutationScope(); | 101 ~RuleMutationScope(); |
103 | 102 |
104 private: | 103 private: |
105 Member<CSSStyleSheet> m_styleSheet; | 104 Member<CSSStyleSheet> m_styleSheet; |
106 }; | 105 }; |
107 | 106 |
108 void willMutateRules(); | 107 void willMutateRules(); |
109 void didMutateRules(); | 108 void didMutateRules(); |
110 void didMutate(StyleSheetUpdateType = PartialRuleUpdate); | 109 void didMutate(); |
111 | 110 |
112 StyleSheetContents* contents() const { return m_contents.get(); } | 111 StyleSheetContents* contents() const { return m_contents.get(); } |
113 | 112 |
114 bool isInline() const { return m_isInlineStylesheet; } | 113 bool isInline() const { return m_isInlineStylesheet; } |
115 TextPosition startPositionInSource() const { return m_startPosition; } | 114 TextPosition startPositionInSource() const { return m_startPosition; } |
116 | 115 |
117 bool sheetLoaded(); | 116 bool sheetLoaded(); |
118 bool loadCompleted() const { return m_loadCompleted; } | 117 bool loadCompleted() const { return m_loadCompleted; } |
119 void startLoadingDynamicSheet(); | 118 void startLoadingDynamicSheet(); |
120 void setText(const String&); | 119 void setText(const String&); |
(...skipping 11 matching lines...) Expand all Loading... |
132 | 131 |
133 bool canAccessRules() const; | 132 bool canAccessRules() const; |
134 | 133 |
135 void setLoadCompleted(bool); | 134 void setLoadCompleted(bool); |
136 | 135 |
137 Member<StyleSheetContents> m_contents; | 136 Member<StyleSheetContents> m_contents; |
138 bool m_isInlineStylesheet; | 137 bool m_isInlineStylesheet; |
139 bool m_isDisabled; | 138 bool m_isDisabled; |
140 String m_title; | 139 String m_title; |
141 Member<MediaQuerySet> m_mediaQueries; | 140 Member<MediaQuerySet> m_mediaQueries; |
| 141 MediaQueryResultList m_viewportDependentMediaQueryResults; |
| 142 MediaQueryResultList m_deviceDependentMediaQueryResults; |
142 | 143 |
143 RefPtr<SecurityOrigin> m_allowRuleAccessFromOrigin; | 144 RefPtr<SecurityOrigin> m_allowRuleAccessFromOrigin; |
144 | 145 |
145 Member<Node> m_ownerNode; | 146 Member<Node> m_ownerNode; |
146 Member<CSSRule> m_ownerRule; | 147 Member<CSSRule> m_ownerRule; |
147 | 148 |
148 TextPosition m_startPosition; | 149 TextPosition m_startPosition; |
149 bool m_loadCompleted; | 150 bool m_loadCompleted; |
150 mutable Member<MediaList> m_mediaCSSOMWrapper; | 151 mutable Member<MediaList> m_mediaCSSOMWrapper; |
151 mutable HeapVector<Member<CSSRule>> m_childRuleCSSOMWrappers; | 152 mutable HeapVector<Member<CSSRule>> m_childRuleCSSOMWrappers; |
(...skipping 18 matching lines...) Expand all Loading... |
170 { | 171 { |
171 if (m_styleSheet) | 172 if (m_styleSheet) |
172 m_styleSheet->didMutateRules(); | 173 m_styleSheet->didMutateRules(); |
173 } | 174 } |
174 | 175 |
175 DEFINE_TYPE_CASTS(CSSStyleSheet, StyleSheet, sheet, sheet->isCSSStyleSheet(), sh
eet.isCSSStyleSheet()); | 176 DEFINE_TYPE_CASTS(CSSStyleSheet, StyleSheet, sheet, sheet->isCSSStyleSheet(), sh
eet.isCSSStyleSheet()); |
176 | 177 |
177 } // namespace blink | 178 } // namespace blink |
178 | 179 |
179 #endif | 180 #endif |
OLD | NEW |