| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef LinkStyle_h | 5 #ifndef LinkStyle_h |
| 6 #define LinkStyle_h | 6 #define LinkStyle_h |
| 7 | 7 |
| 8 #include "core/dom/Node.h" | 8 #include "core/dom/Node.h" |
| 9 #include "core/dom/StyleEngine.h" | 9 #include "core/dom/StyleEngine.h" |
| 10 #include "core/fetch/ResourceOwner.h" | 10 #include "core/fetch/ResourceOwner.h" |
| 11 #include "core/html/LinkResource.h" | 11 #include "core/html/LinkResource.h" |
| 12 #include "core/loader/resource/StyleSheetResource.h" | 12 #include "core/loader/resource/StyleSheetResource.h" |
| 13 #include "core/loader/resource/StyleSheetResourceClient.h" | 13 #include "core/loader/resource/StyleSheetResourceClient.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class HTMLLinkElement; | 17 class HTMLLinkElement; |
| 18 class KURL; |
| 19 |
| 18 // | 20 // |
| 19 // LinkStyle handles dynamically change-able link resources, which is | 21 // LinkStyle handles dynamically change-able link resources, which is |
| 20 // typically @rel="stylesheet". | 22 // typically @rel="stylesheet". |
| 21 // | 23 // |
| 22 // It could be @rel="shortcut icon" or something else though. Each of | 24 // It could be @rel="shortcut icon" or something else though. Each of |
| 23 // types might better be handled by a separate class, but dynamically | 25 // types might better be handled by a separate class, but dynamically |
| 24 // changing @rel makes it harder to move such a design so we are | 26 // changing @rel makes it harder to move such a design so we are |
| 25 // sticking current way so far. | 27 // sticking current way so far. |
| 26 // | 28 // |
| 27 class LinkStyle final : public LinkResource, ResourceOwner<StyleSheetResource> { | 29 class LinkStyle final : public LinkResource, ResourceOwner<StyleSheetResource> { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 61 |
| 60 CSSStyleSheet* sheet() const { return m_sheet.get(); } | 62 CSSStyleSheet* sheet() const { return m_sheet.get(); } |
| 61 | 63 |
| 62 private: | 64 private: |
| 63 // From StyleSheetResourceClient | 65 // From StyleSheetResourceClient |
| 64 void setCSSStyleSheet(const String& href, | 66 void setCSSStyleSheet(const String& href, |
| 65 const KURL& baseURL, | 67 const KURL& baseURL, |
| 66 const String& charset, | 68 const String& charset, |
| 67 const CSSStyleSheetResource*) override; | 69 const CSSStyleSheetResource*) override; |
| 68 String debugName() const override { return "LinkStyle"; } | 70 String debugName() const override { return "LinkStyle"; } |
| 69 enum LoadReturnValue { Loaded, NotNeeded, Bail }; | 71 bool shouldLoadResource() const; |
| 70 LoadReturnValue loadStylesheetIfNeeded(const LinkRequestBuilder&, | 72 void loadStylesheetIfNeeded(const String& type); |
| 71 const String& type); | 73 LocalFrame* loadingFrame() const; |
| 74 void loadStylesheet(); |
| 72 | 75 |
| 73 enum DisabledState { Unset, EnabledViaScript, Disabled }; | 76 enum DisabledState { Unset, EnabledViaScript, Disabled }; |
| 74 | 77 |
| 75 enum PendingSheetType { None, NonBlocking, Blocking }; | 78 enum PendingSheetType { None, NonBlocking, Blocking }; |
| 76 | 79 |
| 77 void clearSheet(); | 80 void clearSheet(); |
| 78 void addPendingSheet(PendingSheetType); | 81 void addPendingSheet(PendingSheetType); |
| 79 void removePendingSheet(); | 82 void removePendingSheet(); |
| 80 Document& document(); | 83 Document& document(); |
| 84 const Document& document() const; |
| 81 | 85 |
| 82 void setCrossOriginStylesheetStatus(CSSStyleSheet*); | 86 void setCrossOriginStylesheetStatus(); |
| 83 void setFetchFollowingCORS() { | |
| 84 DCHECK(!m_fetchFollowingCORS); | |
| 85 m_fetchFollowingCORS = true; | |
| 86 } | |
| 87 void clearFetchFollowingCORS() { m_fetchFollowingCORS = false; } | |
| 88 | 87 |
| 89 Member<CSSStyleSheet> m_sheet; | 88 Member<CSSStyleSheet> m_sheet; |
| 90 DisabledState m_disabledState; | 89 DisabledState m_disabledState; |
| 91 PendingSheetType m_pendingSheetType; | 90 PendingSheetType m_pendingSheetType; |
| 92 StyleEngineContext m_styleEngineContext; | 91 StyleEngineContext m_styleEngineContext; |
| 93 bool m_loading; | 92 bool m_loading; |
| 94 bool m_firedLoad; | 93 bool m_firedLoad; |
| 95 bool m_loadedSheet; | 94 bool m_loadedSheet; |
| 96 bool m_fetchFollowingCORS; | 95 bool m_fetchFollowingCORS; |
| 97 }; | 96 }; |
| 98 | 97 |
| 99 } // namespace blink | 98 } // namespace blink |
| 100 | 99 |
| 101 #endif | 100 #endif |
| OLD | NEW |