OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved. |
5 * Copyright (C) 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2011 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // | 48 // |
49 // LinkStyle handles dynaically change-able link resources, which is | 49 // LinkStyle handles dynaically change-able link resources, which is |
50 // typically @rel="stylesheet". | 50 // typically @rel="stylesheet". |
51 // | 51 // |
52 // It could be @rel="shortcut icon" or soething else though. Each of | 52 // It could be @rel="shortcut icon" or soething else though. Each of |
53 // types might better be handled by a separate class, but dynamically | 53 // types might better be handled by a separate class, but dynamically |
54 // changing @rel makes it harder to move such a design so we are | 54 // changing @rel makes it harder to move such a design so we are |
55 // sticking current way so far. | 55 // sticking current way so far. |
56 // | 56 // |
57 class LinkStyle FINAL : public LinkResource, ResourceOwner<StyleSheetResource> { | 57 class LinkStyle final : public LinkResource, ResourceOwner<StyleSheetResource> { |
58 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 58 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
59 public: | 59 public: |
60 static PassOwnPtrWillBeRawPtr<LinkStyle> create(HTMLLinkElement* owner); | 60 static PassOwnPtrWillBeRawPtr<LinkStyle> create(HTMLLinkElement* owner); |
61 | 61 |
62 explicit LinkStyle(HTMLLinkElement* owner); | 62 explicit LinkStyle(HTMLLinkElement* owner); |
63 virtual ~LinkStyle(); | 63 virtual ~LinkStyle(); |
64 | 64 |
65 virtual Type type() const OVERRIDE { return Style; } | 65 virtual Type type() const override { return Style; } |
66 virtual void process() OVERRIDE; | 66 virtual void process() override; |
67 virtual void ownerRemoved() OVERRIDE; | 67 virtual void ownerRemoved() override; |
68 virtual bool hasLoaded() const OVERRIDE { return m_loadedSheet; } | 68 virtual bool hasLoaded() const override { return m_loadedSheet; } |
69 virtual void trace(Visitor*) OVERRIDE; | 69 virtual void trace(Visitor*) override; |
70 | 70 |
71 void startLoadingDynamicSheet(); | 71 void startLoadingDynamicSheet(); |
72 void notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred); | 72 void notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred); |
73 bool sheetLoaded(); | 73 bool sheetLoaded(); |
74 | 74 |
75 void setDisabledState(bool); | 75 void setDisabledState(bool); |
76 void setSheetTitle(const String&); | 76 void setSheetTitle(const String&); |
77 | 77 |
78 bool styleSheetIsLoading() const; | 78 bool styleSheetIsLoading() const; |
79 bool hasSheet() const { return m_sheet; } | 79 bool hasSheet() const { return m_sheet; } |
80 bool isDisabled() const { return m_disabledState == Disabled; } | 80 bool isDisabled() const { return m_disabledState == Disabled; } |
81 bool isEnabledViaScript() const { return m_disabledState == EnabledViaScript
; } | 81 bool isEnabledViaScript() const { return m_disabledState == EnabledViaScript
; } |
82 bool isUnset() const { return m_disabledState == Unset; } | 82 bool isUnset() const { return m_disabledState == Unset; } |
83 | 83 |
84 CSSStyleSheet* sheet() const { return m_sheet.get(); } | 84 CSSStyleSheet* sheet() const { return m_sheet.get(); } |
85 | 85 |
86 private: | 86 private: |
87 // From StyleSheetResourceClient | 87 // From StyleSheetResourceClient |
88 virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource*) OVERRIDE; | 88 virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource*) override; |
89 | 89 |
90 enum DisabledState { | 90 enum DisabledState { |
91 Unset, | 91 Unset, |
92 EnabledViaScript, | 92 EnabledViaScript, |
93 Disabled | 93 Disabled |
94 }; | 94 }; |
95 | 95 |
96 enum PendingSheetType { | 96 enum PendingSheetType { |
97 None, | 97 None, |
98 NonBlocking, | 98 NonBlocking, |
99 Blocking | 99 Blocking |
100 }; | 100 }; |
101 | 101 |
102 void clearSheet(); | 102 void clearSheet(); |
103 void addPendingSheet(PendingSheetType); | 103 void addPendingSheet(PendingSheetType); |
104 void removePendingSheet(); | 104 void removePendingSheet(); |
105 Document& document(); | 105 Document& document(); |
106 | 106 |
107 RefPtrWillBeMember<CSSStyleSheet> m_sheet; | 107 RefPtrWillBeMember<CSSStyleSheet> m_sheet; |
108 DisabledState m_disabledState; | 108 DisabledState m_disabledState; |
109 PendingSheetType m_pendingSheetType; | 109 PendingSheetType m_pendingSheetType; |
110 bool m_loading; | 110 bool m_loading; |
111 bool m_firedLoad; | 111 bool m_firedLoad; |
112 bool m_loadedSheet; | 112 bool m_loadedSheet; |
113 }; | 113 }; |
114 | 114 |
115 | 115 |
116 class HTMLLinkElement FINAL : public HTMLElement, public LinkLoaderClient { | 116 class HTMLLinkElement final : public HTMLElement, public LinkLoaderClient { |
117 DEFINE_WRAPPERTYPEINFO(); | 117 DEFINE_WRAPPERTYPEINFO(); |
118 public: | 118 public: |
119 static PassRefPtrWillBeRawPtr<HTMLLinkElement> create(Document&, bool create
dByParser); | 119 static PassRefPtrWillBeRawPtr<HTMLLinkElement> create(Document&, bool create
dByParser); |
120 virtual ~HTMLLinkElement(); | 120 virtual ~HTMLLinkElement(); |
121 | 121 |
122 KURL href() const; | 122 KURL href() const; |
123 const AtomicString& rel() const; | 123 const AtomicString& rel() const; |
124 String media() const { return m_media; } | 124 String media() const { return m_media; } |
125 String typeValue() const { return m_type; } | 125 String typeValue() const { return m_type; } |
126 const LinkRelAttribute& relAttribute() const { return m_relAttribute; } | 126 const LinkRelAttribute& relAttribute() const { return m_relAttribute; } |
(...skipping 18 matching lines...) Expand all Loading... |
145 void enableIfExitTransitionStyle(); | 145 void enableIfExitTransitionStyle(); |
146 | 146 |
147 DOMSettableTokenList* sizes() const; | 147 DOMSettableTokenList* sizes() const; |
148 | 148 |
149 void dispatchPendingEvent(LinkEventSender*); | 149 void dispatchPendingEvent(LinkEventSender*); |
150 void scheduleEvent(); | 150 void scheduleEvent(); |
151 void dispatchEventImmediately(); | 151 void dispatchEventImmediately(); |
152 static void dispatchPendingLoadEvents(); | 152 static void dispatchPendingLoadEvents(); |
153 | 153 |
154 // From LinkLoaderClient | 154 // From LinkLoaderClient |
155 virtual bool shouldLoadLink() OVERRIDE; | 155 virtual bool shouldLoadLink() override; |
156 | 156 |
157 // For LinkStyle | 157 // For LinkStyle |
158 bool loadLink(const String& type, const KURL&); | 158 bool loadLink(const String& type, const KURL&); |
159 bool isAlternate() const { return linkStyle()->isUnset() && m_relAttribute.i
sAlternate(); } | 159 bool isAlternate() const { return linkStyle()->isUnset() && m_relAttribute.i
sAlternate(); } |
160 bool shouldProcessStyle() { return linkResourceToProcess() && linkStyle(); } | 160 bool shouldProcessStyle() { return linkResourceToProcess() && linkStyle(); } |
161 bool isCreatedByParser() const { return m_createdByParser; } | 161 bool isCreatedByParser() const { return m_createdByParser; } |
162 | 162 |
163 // Parse the icon size attribute into |iconSizes|, make this method public | 163 // Parse the icon size attribute into |iconSizes|, make this method public |
164 // visible for testing purpose. | 164 // visible for testing purpose. |
165 static void parseSizesAttribute(const AtomicString& value, Vector<IntSize>&
iconSizes); | 165 static void parseSizesAttribute(const AtomicString& value, Vector<IntSize>&
iconSizes); |
166 | 166 |
167 virtual void trace(Visitor*) OVERRIDE; | 167 virtual void trace(Visitor*) override; |
168 | 168 |
169 private: | 169 private: |
170 virtual void attributeWillChange(const QualifiedName&, const AtomicString& o
ldValue, const AtomicString& newValue) OVERRIDE; | 170 virtual void attributeWillChange(const QualifiedName&, const AtomicString& o
ldValue, const AtomicString& newValue) override; |
171 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; | 171 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr
ide; |
172 | 172 |
173 LinkStyle* linkStyle() const; | 173 LinkStyle* linkStyle() const; |
174 LinkImport* linkImport() const; | 174 LinkImport* linkImport() const; |
175 LinkResource* linkResourceToProcess(); | 175 LinkResource* linkResourceToProcess(); |
176 | 176 |
177 void process(); | 177 void process(); |
178 static void processCallback(Node*); | 178 static void processCallback(Node*); |
179 | 179 |
180 // From Node and subclassses | 180 // From Node and subclassses |
181 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; | 181 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; |
182 virtual void removedFrom(ContainerNode*) OVERRIDE; | 182 virtual void removedFrom(ContainerNode*) override; |
183 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; | 183 virtual bool isURLAttribute(const Attribute&) const override; |
184 virtual bool hasLegalLinkAttribute(const QualifiedName&) const OVERRIDE; | 184 virtual bool hasLegalLinkAttribute(const QualifiedName&) const override; |
185 virtual const QualifiedName& subResourceAttributeName() const OVERRIDE; | 185 virtual const QualifiedName& subResourceAttributeName() const override; |
186 virtual bool sheetLoaded() OVERRIDE; | 186 virtual bool sheetLoaded() override; |
187 virtual void notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred)
OVERRIDE; | 187 virtual void notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred)
override; |
188 virtual void startLoadingDynamicSheet() OVERRIDE; | 188 virtual void startLoadingDynamicSheet() override; |
189 virtual void finishParsingChildren() OVERRIDE; | 189 virtual void finishParsingChildren() override; |
190 | 190 |
191 // From LinkLoaderClient | 191 // From LinkLoaderClient |
192 virtual void linkLoaded() OVERRIDE; | 192 virtual void linkLoaded() override; |
193 virtual void linkLoadingErrored() OVERRIDE; | 193 virtual void linkLoadingErrored() override; |
194 virtual void didStartLinkPrerender() OVERRIDE; | 194 virtual void didStartLinkPrerender() override; |
195 virtual void didStopLinkPrerender() OVERRIDE; | 195 virtual void didStopLinkPrerender() override; |
196 virtual void didSendLoadForLinkPrerender() OVERRIDE; | 196 virtual void didSendLoadForLinkPrerender() override; |
197 virtual void didSendDOMContentLoadedForLinkPrerender() OVERRIDE; | 197 virtual void didSendDOMContentLoadedForLinkPrerender() override; |
198 | 198 |
199 private: | 199 private: |
200 HTMLLinkElement(Document&, bool createdByParser); | 200 HTMLLinkElement(Document&, bool createdByParser); |
201 | 201 |
202 OwnPtrWillBeMember<LinkResource> m_link; | 202 OwnPtrWillBeMember<LinkResource> m_link; |
203 LinkLoader m_linkLoader; | 203 LinkLoader m_linkLoader; |
204 | 204 |
205 String m_type; | 205 String m_type; |
206 String m_media; | 206 String m_media; |
207 RefPtrWillBeMember<DOMSettableTokenList> m_sizes; | 207 RefPtrWillBeMember<DOMSettableTokenList> m_sizes; |
208 Vector<IntSize> m_iconSizes; | 208 Vector<IntSize> m_iconSizes; |
209 LinkRelAttribute m_relAttribute; | 209 LinkRelAttribute m_relAttribute; |
210 | 210 |
211 bool m_createdByParser; | 211 bool m_createdByParser; |
212 bool m_isInShadowTree; | 212 bool m_isInShadowTree; |
213 }; | 213 }; |
214 | 214 |
215 } // namespace blink | 215 } // namespace blink |
216 | 216 |
217 #endif // HTMLLinkElement_h | 217 #endif // HTMLLinkElement_h |
OLD | NEW |