Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Unified Diff: Source/core/html/HTMLLinkElement.h

Issue 15856002: First step of HTMLImports (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Got rid of CachedDocument usage Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLLinkElement.h
diff --git a/Source/core/html/HTMLLinkElement.h b/Source/core/html/HTMLLinkElement.h
index ce818a1d95ce7789c3df7ab63d6199bdfacaf6bb..4baa8a88058af776c50a6dc9c9398256c3b2e0dc 100644
--- a/Source/core/html/HTMLLinkElement.h
+++ b/Source/core/html/HTMLLinkElement.h
@@ -29,6 +29,7 @@
#include "core/html/DOMSettableTokenList.h"
#include "core/html/HTMLElement.h"
#include "core/html/LinkRelAttribute.h"
+#include "core/html/LinkResource.h"
#include "core/loader/LinkLoader.h"
#include "core/loader/LinkLoaderClient.h"
#include "core/loader/cache/CachedResourceHandle.h"
@@ -37,24 +38,39 @@
namespace WebCore {
+class DocumentFragment;
class HTMLLinkElement;
class KURL;
+class LinkImport;
template<typename T> class EventSender;
typedef EventSender<HTMLLinkElement> LinkEventSender;
-class LinkStyle FINAL : public CachedStyleSheetClient {
+//
+// LinkStyle handles dynaically change-able link resources, which is
+// typically @rel="stylesheet".
+//
+// It could be @rel="shortcut icon" or soething else though. Each of
+// types might better be handled by a separate class, but dynamically
+// changing @rel makes it harder to move such a design so we are
+// sticking current way so far.
+//
+class LinkStyle FINAL : public LinkResource, CachedStyleSheetClient {
public:
+ static PassRefPtr<LinkStyle> create(HTMLLinkElement* owner);
+
explicit LinkStyle(HTMLLinkElement* owner);
- ~LinkStyle();
+ virtual ~LinkStyle();
+
+ virtual Type type() const OVERRIDE { return Style; }
+ virtual void process() OVERRIDE;
+ virtual void ownerRemoved() OVERRIDE;
void startLoadingDynamicSheet();
void notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred);
bool sheetLoaded();
void setDisabledState(bool);
- void process();
- void ownerRemoved();
void setSheetTitle(const String&);
bool styleSheetIsLoading() const;
@@ -99,7 +115,6 @@ private:
bool m_loading;
bool m_firedLoad;
bool m_loadedSheet;
- HTMLLinkElement* m_owner;
};
@@ -123,12 +138,13 @@ public:
// the icon size string as parsed from the HTML attribute
String iconSizes() const;
- CSSStyleSheet* sheet() const { return m_link->sheet(); }
+ CSSStyleSheet* sheet() const { return linkStyle() ? linkStyle()->sheet() : 0; }
+ DocumentFragment* import() const;
bool styleSheetIsLoading() const;
- bool isDisabled() const { return m_link->isDisabled(); }
- bool isEnabledViaScript() const { return m_link->isEnabledViaScript(); }
+ bool isDisabled() const { return linkStyle() && linkStyle()->isDisabled(); }
+ bool isEnabledViaScript() const { return linkStyle() && linkStyle()->isEnabledViaScript(); }
void setSizes(const String&);
DOMSettableTokenList* sizes() const;
@@ -140,14 +156,15 @@ public:
// For LinkStyle
bool loadLink(const String& type, const KURL& url) { return m_linkLoader.loadLink(m_relAttribute, type, url, document()); }
- bool isAlternate() const { return m_link->isUnset() && m_relAttribute.isAlternate(); }
- bool shouldProcessStyle() { return linkStyleToProcess(); }
+ bool isAlternate() const { return linkStyle()->isUnset() && m_relAttribute.isAlternate(); }
+ bool shouldProcessStyle() { return linkResourceToProcess() && linkStyle(); }
private:
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
- LinkStyle* linkStyle() const { return m_link.get(); }
- LinkStyle* linkStyleToProcess();
+ LinkStyle* linkStyle() const;
+ LinkImport* linkImport() const;
+ LinkResource* linkResourceToProcess();
void process();
static void processCallback(Node*);
@@ -173,7 +190,7 @@ private:
private:
HTMLLinkElement(const QualifiedName&, Document*, bool createdByParser);
- OwnPtr<LinkStyle> m_link;
+ RefPtr<LinkResource> m_link;
LinkLoader m_linkLoader;
String m_type;

Powered by Google App Engine
This is Rietveld 408576698