| 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. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 * | 21 * |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #ifndef HTMLLinkElement_h | 24 #ifndef HTMLLinkElement_h |
| 25 #define HTMLLinkElement_h | 25 #define HTMLLinkElement_h |
| 26 | 26 |
| 27 #include "core/CoreExport.h" | 27 #include "core/CoreExport.h" |
| 28 #include "core/css/CSSStyleSheet.h" | |
| 29 #include "core/dom/DOMTokenList.h" | 28 #include "core/dom/DOMTokenList.h" |
| 30 #include "core/dom/IconURL.h" | |
| 31 #include "core/dom/IncrementLoadEventDelayCount.h" | 29 #include "core/dom/IncrementLoadEventDelayCount.h" |
| 32 #include "core/dom/StyleEngine.h" | |
| 33 #include "core/fetch/ResourceOwner.h" | |
| 34 #include "core/fetch/StyleSheetResource.h" | |
| 35 #include "core/fetch/StyleSheetResourceClient.h" | |
| 36 #include "core/html/HTMLElement.h" | 30 #include "core/html/HTMLElement.h" |
| 37 #include "core/html/LinkRelAttribute.h" | 31 #include "core/html/LinkRelAttribute.h" |
| 38 #include "core/html/LinkResource.h" | 32 #include "core/html/LinkResource.h" |
| 33 #include "core/html/LinkStyle.h" |
| 39 #include "core/html/RelList.h" | 34 #include "core/html/RelList.h" |
| 40 #include "core/loader/LinkLoader.h" | 35 #include "core/loader/LinkLoader.h" |
| 41 #include "core/loader/LinkLoaderClient.h" | 36 #include "core/loader/LinkLoaderClient.h" |
| 42 #include <memory> | 37 #include <memory> |
| 43 | 38 |
| 44 namespace blink { | 39 namespace blink { |
| 45 | 40 |
| 46 class HTMLLinkElement; | |
| 47 class KURL; | 41 class KURL; |
| 48 class LinkImport; | 42 class LinkImport; |
| 49 | 43 |
| 50 // | |
| 51 // LinkStyle handles dynamically change-able link resources, which is | |
| 52 // typically @rel="stylesheet". | |
| 53 // | |
| 54 // It could be @rel="shortcut icon" or something else though. Each of | |
| 55 // types might better be handled by a separate class, but dynamically | |
| 56 // changing @rel makes it harder to move such a design so we are | |
| 57 // sticking current way so far. | |
| 58 // | |
| 59 class LinkStyle final : public LinkResource, ResourceOwner<StyleSheetResource> { | |
| 60 USING_GARBAGE_COLLECTED_MIXIN(LinkStyle); | |
| 61 | |
| 62 public: | |
| 63 static LinkStyle* create(HTMLLinkElement* owner); | |
| 64 | |
| 65 explicit LinkStyle(HTMLLinkElement* owner); | |
| 66 ~LinkStyle() override; | |
| 67 | |
| 68 LinkResourceType type() const override { return Style; } | |
| 69 void process() override; | |
| 70 void ownerRemoved() override; | |
| 71 bool hasLoaded() const override { return m_loadedSheet; } | |
| 72 DECLARE_VIRTUAL_TRACE(); | |
| 73 | |
| 74 void startLoadingDynamicSheet(); | |
| 75 void notifyLoadedSheetAndAllCriticalSubresources( | |
| 76 Node::LoadedSheetErrorStatus); | |
| 77 bool sheetLoaded(); | |
| 78 | |
| 79 void setDisabledState(bool); | |
| 80 void setSheetTitle( | |
| 81 const String&, | |
| 82 StyleEngine::ActiveSheetsUpdate = StyleEngine::DontUpdateActiveSheets); | |
| 83 | |
| 84 bool styleSheetIsLoading() const; | |
| 85 bool hasSheet() const { return m_sheet; } | |
| 86 bool isDisabled() const { return m_disabledState == Disabled; } | |
| 87 bool isEnabledViaScript() const { | |
| 88 return m_disabledState == EnabledViaScript; | |
| 89 } | |
| 90 bool isUnset() const { return m_disabledState == Unset; } | |
| 91 | |
| 92 CSSStyleSheet* sheet() const { return m_sheet.get(); } | |
| 93 | |
| 94 private: | |
| 95 // From StyleSheetResourceClient | |
| 96 void setCSSStyleSheet(const String& href, | |
| 97 const KURL& baseURL, | |
| 98 const String& charset, | |
| 99 const CSSStyleSheetResource*) override; | |
| 100 String debugName() const override { return "LinkStyle"; } | |
| 101 | |
| 102 enum DisabledState { Unset, EnabledViaScript, Disabled }; | |
| 103 | |
| 104 enum PendingSheetType { None, NonBlocking, Blocking }; | |
| 105 | |
| 106 void clearSheet(); | |
| 107 void addPendingSheet(PendingSheetType); | |
| 108 void removePendingSheet(); | |
| 109 Document& document(); | |
| 110 | |
| 111 void setCrossOriginStylesheetStatus(CSSStyleSheet*); | |
| 112 void setFetchFollowingCORS() { | |
| 113 DCHECK(!m_fetchFollowingCORS); | |
| 114 m_fetchFollowingCORS = true; | |
| 115 } | |
| 116 void clearFetchFollowingCORS() { m_fetchFollowingCORS = false; } | |
| 117 | |
| 118 Member<CSSStyleSheet> m_sheet; | |
| 119 DisabledState m_disabledState; | |
| 120 PendingSheetType m_pendingSheetType; | |
| 121 StyleEngineContext m_styleEngineContext; | |
| 122 bool m_loading; | |
| 123 bool m_firedLoad; | |
| 124 bool m_loadedSheet; | |
| 125 bool m_fetchFollowingCORS; | |
| 126 }; | |
| 127 | |
| 128 class CORE_EXPORT HTMLLinkElement final : public HTMLElement, | 44 class CORE_EXPORT HTMLLinkElement final : public HTMLElement, |
| 129 public LinkLoaderClient, | 45 public LinkLoaderClient, |
| 130 private DOMTokenListObserver { | 46 private DOMTokenListObserver { |
| 131 DEFINE_WRAPPERTYPEINFO(); | 47 DEFINE_WRAPPERTYPEINFO(); |
| 132 USING_GARBAGE_COLLECTED_MIXIN(HTMLLinkElement); | 48 USING_GARBAGE_COLLECTED_MIXIN(HTMLLinkElement); |
| 133 | 49 |
| 134 public: | 50 public: |
| 135 static HTMLLinkElement* create(Document&, bool createdByParser); | 51 static HTMLLinkElement* create(Document&, bool createdByParser); |
| 136 ~HTMLLinkElement() override; | 52 ~HTMLLinkElement() override; |
| 137 | 53 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 Member<RelList> m_relList; | 154 Member<RelList> m_relList; |
| 239 LinkRelAttribute m_relAttribute; | 155 LinkRelAttribute m_relAttribute; |
| 240 String m_scope; | 156 String m_scope; |
| 241 | 157 |
| 242 bool m_createdByParser; | 158 bool m_createdByParser; |
| 243 }; | 159 }; |
| 244 | 160 |
| 245 } // namespace blink | 161 } // namespace blink |
| 246 | 162 |
| 247 #endif // HTMLLinkElement_h | 163 #endif // HTMLLinkElement_h |
| OLD | NEW |