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, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class SecurityOrigin; | 42 class SecurityOrigin; |
43 class StyleSheetContents; | 43 class StyleSheetContents; |
44 | 44 |
45 enum StyleSheetUpdateType { | 45 enum StyleSheetUpdateType { |
46 PartialRuleUpdate, | 46 PartialRuleUpdate, |
47 EntireStyleSheetUpdate | 47 EntireStyleSheetUpdate |
48 }; | 48 }; |
49 | 49 |
50 class CSSStyleSheet FINAL : public StyleSheet { | 50 class CSSStyleSheet FINAL : public StyleSheet { |
51 public: | 51 public: |
52 static PassRefPtr<CSSStyleSheet> create(PassRefPtrWillBeRawPtr<StyleSheetCon
tents>, CSSImportRule* ownerRule = 0); | 52 static PassRefPtrWillBeRawPtr<CSSStyleSheet> create(PassRefPtrWillBeRawPtr<S
tyleSheetContents>, CSSImportRule* ownerRule = 0); |
53 static PassRefPtr<CSSStyleSheet> create(PassRefPtrWillBeRawPtr<StyleSheetCon
tents>, Node* ownerNode); | 53 static PassRefPtrWillBeRawPtr<CSSStyleSheet> create(PassRefPtrWillBeRawPtr<S
tyleSheetContents>, Node* ownerNode); |
54 static PassRefPtr<CSSStyleSheet> createInline(Node*, const KURL&, const Text
Position& startPosition = TextPosition::minimumPosition(), const String& encodin
g = String()); | 54 static PassRefPtrWillBeRawPtr<CSSStyleSheet> createInline(Node*, const KURL&
, const TextPosition& startPosition = TextPosition::minimumPosition(), const Str
ing& encoding = String()); |
55 static PassRefPtr<CSSStyleSheet> createInline(PassRefPtrWillBeRawPtr<StyleSh
eetContents>, Node* ownerNode, const TextPosition& startPosition = TextPosition:
:minimumPosition()); | 55 static PassRefPtrWillBeRawPtr<CSSStyleSheet> createInline(PassRefPtrWillBeRa
wPtr<StyleSheetContents>, Node* ownerNode, const TextPosition& startPosition = T
extPosition::minimumPosition()); |
56 | 56 |
57 virtual ~CSSStyleSheet(); | 57 virtual ~CSSStyleSheet(); |
58 | 58 |
59 virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE; | 59 virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE; |
60 virtual Node* ownerNode() const OVERRIDE { return m_ownerNode; } | 60 virtual Node* ownerNode() const OVERRIDE { return m_ownerNode; } |
61 virtual MediaList* media() const OVERRIDE; | 61 virtual MediaList* media() const OVERRIDE; |
62 virtual String href() const OVERRIDE; | 62 virtual String href() const OVERRIDE; |
63 virtual String title() const OVERRIDE { return m_title; } | 63 virtual String title() const OVERRIDE { return m_title; } |
64 virtual bool disabled() const OVERRIDE { return m_isDisabled; } | 64 virtual bool disabled() const OVERRIDE { return m_isDisabled; } |
65 virtual void setDisabled(bool) OVERRIDE; | 65 virtual void setDisabled(bool) OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... |
77 | 77 |
78 // For CSSRuleList. | 78 // For CSSRuleList. |
79 unsigned length() const; | 79 unsigned length() const; |
80 CSSRule* item(unsigned index); | 80 CSSRule* item(unsigned index); |
81 | 81 |
82 virtual void clearOwnerNode() OVERRIDE { didMutate(EntireStyleSheetUpdate);
m_ownerNode = 0; } | 82 virtual void clearOwnerNode() OVERRIDE { didMutate(EntireStyleSheetUpdate);
m_ownerNode = 0; } |
83 virtual CSSRule* ownerRule() const OVERRIDE { return m_ownerRule; } | 83 virtual CSSRule* ownerRule() const OVERRIDE { return m_ownerRule; } |
84 virtual KURL baseURL() const OVERRIDE; | 84 virtual KURL baseURL() const OVERRIDE; |
85 virtual bool isLoading() const OVERRIDE; | 85 virtual bool isLoading() const OVERRIDE; |
86 | 86 |
87 void clearOwnerRule() { m_ownerRule = 0; } | 87 void clearOwnerRule() { m_ownerRule = nullptr; } |
88 Document* ownerDocument() const; | 88 Document* ownerDocument() const; |
89 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } | 89 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } |
90 void setMediaQueries(PassRefPtrWillBeRawPtr<MediaQuerySet>); | 90 void setMediaQueries(PassRefPtrWillBeRawPtr<MediaQuerySet>); |
91 void setTitle(const String& title) { m_title = title; } | 91 void setTitle(const String& title) { m_title = title; } |
92 | 92 |
93 class RuleMutationScope { | 93 class RuleMutationScope { |
94 WTF_MAKE_NONCOPYABLE(RuleMutationScope); | 94 WTF_MAKE_NONCOPYABLE(RuleMutationScope); |
95 public: | 95 public: |
96 RuleMutationScope(CSSStyleSheet*); | 96 RuleMutationScope(CSSStyleSheet*); |
97 RuleMutationScope(CSSRule*); | 97 RuleMutationScope(CSSRule*); |
(...skipping 11 matching lines...) Expand all Loading... |
109 | 109 |
110 StyleSheetContents* contents() const { return m_contents.get(); } | 110 StyleSheetContents* contents() const { return m_contents.get(); } |
111 | 111 |
112 bool isInline() const { return m_isInlineStylesheet; } | 112 bool isInline() const { return m_isInlineStylesheet; } |
113 TextPosition startPositionInSource() const { return m_startPosition; } | 113 TextPosition startPositionInSource() const { return m_startPosition; } |
114 | 114 |
115 bool sheetLoaded(); | 115 bool sheetLoaded(); |
116 bool loadCompleted() const { return m_loadCompleted; } | 116 bool loadCompleted() const { return m_loadCompleted; } |
117 void startLoadingDynamicSheet(); | 117 void startLoadingDynamicSheet(); |
118 | 118 |
| 119 virtual void trace(Visitor*) OVERRIDE; |
| 120 |
119 private: | 121 private: |
120 CSSStyleSheet(PassRefPtrWillBeRawPtr<StyleSheetContents>, CSSImportRule* own
erRule); | 122 CSSStyleSheet(PassRefPtrWillBeRawPtr<StyleSheetContents>, CSSImportRule* own
erRule); |
121 CSSStyleSheet(PassRefPtrWillBeRawPtr<StyleSheetContents>, Node* ownerNode, b
ool isInlineStylesheet, const TextPosition& startPosition); | 123 CSSStyleSheet(PassRefPtrWillBeRawPtr<StyleSheetContents>, Node* ownerNode, b
ool isInlineStylesheet, const TextPosition& startPosition); |
122 | 124 |
123 virtual bool isCSSStyleSheet() const OVERRIDE { return true; } | 125 virtual bool isCSSStyleSheet() const OVERRIDE { return true; } |
124 virtual String type() const OVERRIDE { return "text/css"; } | 126 virtual String type() const OVERRIDE { return "text/css"; } |
125 | 127 |
126 void reattachChildRuleCSSOMWrappers(); | 128 void reattachChildRuleCSSOMWrappers(); |
127 | 129 |
128 bool canAccessRules() const; | 130 bool canAccessRules() const; |
129 | 131 |
130 RefPtrWillBePersistent<StyleSheetContents> m_contents; | 132 RefPtrWillBeMember<StyleSheetContents> m_contents; |
131 bool m_isInlineStylesheet; | 133 bool m_isInlineStylesheet; |
132 bool m_isDisabled; | 134 bool m_isDisabled; |
133 String m_title; | 135 String m_title; |
134 RefPtrWillBePersistent<MediaQuerySet> m_mediaQueries; | 136 RefPtrWillBeMember<MediaQuerySet> m_mediaQueries; |
135 | 137 |
136 Node* m_ownerNode; | 138 Node* m_ownerNode; |
137 // FIXME: oilpan: This is a back pointer from CSSImportRule, corresponding | 139 RawPtrWillBeMember<CSSRule> m_ownerRule; |
138 // to the forward pointer on that, called m_styleSheetCSSOMWrapper. (It is | |
139 // not related to the m_parentStyleSheet pointer which is also typed as | |
140 // CSSStyleSheet, and which is inherited by CSSImportRule from CSSRule). | |
141 // Since m_styleSheetCSSOMWrapper is a RefPtr we know that this object | |
142 // cannot die before the CSSImportRule is destructed, which makes it OK to | |
143 // clear this from ~CSSImportRule. When this is on the GC heap we can make | |
144 // this a regular Member. | |
145 CSSRule* m_ownerRule; | |
146 | 140 |
147 TextPosition m_startPosition; | 141 TextPosition m_startPosition; |
148 bool m_loadCompleted; | 142 bool m_loadCompleted; |
149 | 143 |
150 mutable RefPtrWillBePersistent<MediaList> m_mediaCSSOMWrapper; | 144 mutable RefPtrWillBeMember<MediaList> m_mediaCSSOMWrapper; |
151 mutable WillBePersistentHeapVector<RefPtrWillBeMember<CSSRule> > m_childRule
CSSOMWrappers; | 145 mutable WillBeHeapVector<RefPtrWillBeMember<CSSRule> > m_childRuleCSSOMWrapp
ers; |
152 mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper; | 146 mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper; |
153 }; | 147 }; |
154 | 148 |
155 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet) | 149 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet) |
156 : m_styleSheet(sheet) | 150 : m_styleSheet(sheet) |
157 { | 151 { |
158 if (m_styleSheet) | 152 if (m_styleSheet) |
159 m_styleSheet->willMutateRules(); | 153 m_styleSheet->willMutateRules(); |
160 } | 154 } |
161 | 155 |
162 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSRule* rule) | 156 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSRule* rule) |
163 : m_styleSheet(rule ? rule->parentStyleSheet() : 0) | 157 : m_styleSheet(rule ? rule->parentStyleSheet() : 0) |
164 { | 158 { |
165 if (m_styleSheet) | 159 if (m_styleSheet) |
166 m_styleSheet->willMutateRules(); | 160 m_styleSheet->willMutateRules(); |
167 } | 161 } |
168 | 162 |
169 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope() | 163 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope() |
170 { | 164 { |
171 if (m_styleSheet) | 165 if (m_styleSheet) |
172 m_styleSheet->didMutateRules(); | 166 m_styleSheet->didMutateRules(); |
173 } | 167 } |
174 | 168 |
175 DEFINE_TYPE_CASTS(CSSStyleSheet, StyleSheet, sheet, sheet->isCSSStyleSheet(), sh
eet.isCSSStyleSheet()); | 169 DEFINE_TYPE_CASTS(CSSStyleSheet, StyleSheet, sheet, sheet->isCSSStyleSheet(), sh
eet.isCSSStyleSheet()); |
176 | 170 |
177 } // namespace | 171 } // namespace |
178 | 172 |
179 #endif | 173 #endif |
OLD | NEW |