| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef LinkStyle_h |
| 6 #define LinkStyle_h |
| 7 |
| 8 #include "core/dom/Node.h" |
| 9 #include "core/dom/StyleEngine.h" |
| 10 #include "core/fetch/ResourceOwner.h" |
| 11 #include "core/fetch/StyleSheetResource.h" |
| 12 #include "core/fetch/StyleSheetResourceClient.h" |
| 13 #include "core/html/LinkResource.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 class HTMLLinkElement; |
| 18 // |
| 19 // LinkStyle handles dynamically change-able link resources, which is |
| 20 // typically @rel="stylesheet". |
| 21 // |
| 22 // It could be @rel="shortcut icon" or something else though. Each of |
| 23 // 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 |
| 25 // sticking current way so far. |
| 26 // |
| 27 class LinkStyle final : public LinkResource, ResourceOwner<StyleSheetResource> { |
| 28 USING_GARBAGE_COLLECTED_MIXIN(LinkStyle); |
| 29 |
| 30 public: |
| 31 static LinkStyle* create(HTMLLinkElement* owner); |
| 32 |
| 33 explicit LinkStyle(HTMLLinkElement* owner); |
| 34 ~LinkStyle() override; |
| 35 |
| 36 LinkResourceType type() const override { return Style; } |
| 37 void process() override; |
| 38 void ownerRemoved() override; |
| 39 bool hasLoaded() const override { return m_loadedSheet; } |
| 40 DECLARE_VIRTUAL_TRACE(); |
| 41 |
| 42 void startLoadingDynamicSheet(); |
| 43 void notifyLoadedSheetAndAllCriticalSubresources( |
| 44 Node::LoadedSheetErrorStatus); |
| 45 bool sheetLoaded(); |
| 46 |
| 47 void setDisabledState(bool); |
| 48 void setSheetTitle( |
| 49 const String&, |
| 50 StyleEngine::ActiveSheetsUpdate = StyleEngine::DontUpdateActiveSheets); |
| 51 |
| 52 bool styleSheetIsLoading() const; |
| 53 bool hasSheet() const { return m_sheet; } |
| 54 bool isDisabled() const { return m_disabledState == Disabled; } |
| 55 bool isEnabledViaScript() const { |
| 56 return m_disabledState == EnabledViaScript; |
| 57 } |
| 58 bool isUnset() const { return m_disabledState == Unset; } |
| 59 |
| 60 CSSStyleSheet* sheet() const { return m_sheet.get(); } |
| 61 |
| 62 private: |
| 63 // From StyleSheetResourceClient |
| 64 void setCSSStyleSheet(const String& href, |
| 65 const KURL& baseURL, |
| 66 const String& charset, |
| 67 const CSSStyleSheetResource*) override; |
| 68 String debugName() const override { return "LinkStyle"; } |
| 69 |
| 70 enum DisabledState { Unset, EnabledViaScript, Disabled }; |
| 71 |
| 72 enum PendingSheetType { None, NonBlocking, Blocking }; |
| 73 |
| 74 void clearSheet(); |
| 75 void addPendingSheet(PendingSheetType); |
| 76 void removePendingSheet(); |
| 77 Document& document(); |
| 78 |
| 79 void setCrossOriginStylesheetStatus(CSSStyleSheet*); |
| 80 void setFetchFollowingCORS() { |
| 81 DCHECK(!m_fetchFollowingCORS); |
| 82 m_fetchFollowingCORS = true; |
| 83 } |
| 84 void clearFetchFollowingCORS() { m_fetchFollowingCORS = false; } |
| 85 |
| 86 Member<CSSStyleSheet> m_sheet; |
| 87 DisabledState m_disabledState; |
| 88 PendingSheetType m_pendingSheetType; |
| 89 StyleEngineContext m_styleEngineContext; |
| 90 bool m_loading; |
| 91 bool m_firedLoad; |
| 92 bool m_loadedSheet; |
| 93 bool m_fetchFollowingCORS; |
| 94 }; |
| 95 |
| 96 } // namespace blink |
| 97 |
| 98 #endif |
| OLD | NEW |