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

Side by Side Diff: Source/core/html/imports/HTMLImport.h

Issue 234063004: Refactoring: Get rid of HTMLImportRoot. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/html/imports/HTMLImport.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 23 matching lines...) Expand all
34 #include "core/html/imports/HTMLImportState.h" 34 #include "core/html/imports/HTMLImportState.h"
35 #include "wtf/TreeNode.h" 35 #include "wtf/TreeNode.h"
36 #include "wtf/Vector.h" 36 #include "wtf/Vector.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 class CustomElementMicrotaskImportStep; 40 class CustomElementMicrotaskImportStep;
41 class Document; 41 class Document;
42 class LocalFrame; 42 class LocalFrame;
43 class HTMLImportChild; 43 class HTMLImportChild;
44 class HTMLImportRoot;
45 class HTMLImportsController; 44 class HTMLImportsController;
46 class KURL; 45 class KURL;
47 46
48 // 47 //
49 // # Basic Data Structure and Algorithms of HTML Imports implemenation. 48 // # Basic Data Structure and Algorithms of HTML Imports implemenation.
50 // 49 //
51 // ## The Import Tree 50 // ## The Import Tree
52 // 51 //
53 // HTML Imports form a tree: 52 // HTML Imports form a tree:
54 // 53 //
55 // * The root of the tree is HTMLImportsController, which is owned by the master 54 // * The root of the tree is HTMLImportsController, which is owned by the master
56 // document as a DocumentSupplement. HTMLImportsController has an abstract cla ss called 55 // document as a DocumentSupplement.
57 // HTMLImportRoot to deal with cycler dependency.
58 // 56 //
59 // * The non-root nodes are HTMLImportChild, which is owned by LinkStyle, that i s owned by HTMLLinkElement. 57 // * The non-root nodes are HTMLImportChild, which is owned by LinkStyle, that i s owned by HTMLLinkElement.
60 // LinkStyle is wired into HTMLImportChild by implementing HTMLImportChildClie nt interface 58 // LinkStyle is wired into HTMLImportChild by implementing HTMLImportChildClie nt interface
61 // 59 //
62 // * Both HTMLImportsController and HTMLImportChild are derived from HTMLImport superclass 60 // * Both HTMLImportsController and HTMLImportChild are derived from HTMLImport superclass
63 // that models the tree data structure using WTF::TreeNode and provides a set of 61 // that models the tree data structure using WTF::TreeNode and provides a set of
64 // virtual functions. 62 // virtual functions.
65 // 63 //
66 // HTMLImportsController also owns all loaders in the tree and manages their lif etime through it. 64 // HTMLImportsController also owns all loaders in the tree and manages their lif etime through it.
67 // One assumption is that the tree is append-only and nodes are never inserted i n the middle of the tree nor removed. 65 // One assumption is that the tree is append-only and nodes are never inserted i n the middle of the tree nor removed.
68 // 66 //
69 // 67 //
70 // HTMLImport <|- HTMLImportRoot <|- HTMLImportsController <- Document 68 // HTMLImport <|- HTMLImportsController <- Document
71 // * 69 // *
72 // | 70 // |
73 // <|- HTMLImportChild <- LinkStyle <- HTMLLink Element 71 // <|- HTMLImportChild <- LinkStyle <- HTMLLinkElement
74 // 72 //
75 // 73 //
76 // # Import Sharing and HTMLImportLoader 74 // # Import Sharing and HTMLImportLoader
77 // 75 //
78 // The HTML Imports spec calls for de-dup mechanism to share already loaded impo rts. 76 // The HTML Imports spec calls for de-dup mechanism to share already loaded impo rts.
79 // To implement this, the actual loading machinery is split out from HTMLImportC hild to 77 // To implement this, the actual loading machinery is split out from HTMLImportC hild to
80 // HTMLImportLoader, and each loader shares HTMLImportLoader with other loader i f the URL is same. 78 // HTMLImportLoader, and each loader shares HTMLImportLoader with other loader i f the URL is same.
81 // Check around HTMLImportsController::findLink() for more detail. 79 // Check around HTMLImportsController::findLink() for more detail.
82 // 80 //
83 // HTMLImportLoader can be shared by multiple imports. 81 // HTMLImportLoader can be shared by multiple imports.
(...skipping 16 matching lines...) Expand all
100 // This represents the import tree data structure. 98 // This represents the import tree data structure.
101 class HTMLImport : public TreeNode<HTMLImport> { 99 class HTMLImport : public TreeNode<HTMLImport> {
102 public: 100 public:
103 enum SyncMode { 101 enum SyncMode {
104 Sync = 0, 102 Sync = 0,
105 Async = 1 103 Async = 1
106 }; 104 };
107 105
108 virtual ~HTMLImport() { } 106 virtual ~HTMLImport() { }
109 107
108 HTMLImport* root();
110 bool isRoot() const { return !isChild(); } 109 bool isRoot() const { return !isChild(); }
111 bool isSync() const { return SyncMode(m_sync) == Sync; } 110 bool isSync() const { return SyncMode(m_sync) == Sync; }
112 const HTMLImportState& state() const { return m_state; } 111 const HTMLImportState& state() const { return m_state; }
113 112
114 void appendChild(HTMLImport*); 113 void appendChild(HTMLImport*);
115 114
116 virtual bool isChild() const { return false; } 115 virtual bool isChild() const { return false; }
117 virtual HTMLImportRoot* root() = 0;
118 virtual Document* document() const = 0; 116 virtual Document* document() const = 0;
119 virtual bool isDone() const = 0; // FIXME: Should be renamed to haveFinished Loading() 117 virtual bool isDone() const = 0; // FIXME: Should be renamed to haveFinished Loading()
120 virtual bool hasLoader() const = 0; 118 virtual bool hasLoader() const = 0;
121 virtual bool ownsLoader() const { return false; } 119 virtual bool ownsLoader() const { return false; }
122 virtual CustomElementMicrotaskImportStep* customElementMicrotaskStep() const { return 0; } 120 virtual CustomElementMicrotaskImportStep* customElementMicrotaskStep() const { return 0; }
121 virtual void stateWillChange() { }
123 virtual void stateDidChange(); 122 virtual void stateDidChange();
124 123
125 protected: 124 protected:
126 // Stating from most conservative state. 125 // Stating from most conservative state.
127 // It will be corrected through state update flow. 126 // It will be corrected through state update flow.
128 explicit HTMLImport(SyncMode sync) 127 explicit HTMLImport(SyncMode sync)
129 : m_sync(sync) 128 : m_sync(sync)
130 { } 129 { }
131 130
132 void stateWillChange();
133 static void recalcTreeState(HTMLImport* root); 131 static void recalcTreeState(HTMLImport* root);
134 132
135 #if !defined(NDEBUG) 133 #if !defined(NDEBUG)
136 void show(); 134 void show();
137 void showTree(HTMLImport* highlight, unsigned depth); 135 void showTree(HTMLImport* highlight, unsigned depth);
138 virtual void showThis(); 136 virtual void showThis();
139 #endif 137 #endif
140 138
141 private: 139 private:
142 HTMLImportState m_state; 140 HTMLImportState m_state;
143 unsigned m_sync : 1; 141 unsigned m_sync : 1;
144 }; 142 };
145 143
146 // An abstract class to decouple its sublcass HTMLImportsController.
147 class HTMLImportRoot : public HTMLImport {
148 public:
149 HTMLImportRoot() : HTMLImport(Sync) { }
150
151 virtual void scheduleRecalcState() = 0;
152 virtual HTMLImportsController* toController() = 0;
153 virtual HTMLImportChild* findLinkFor(const KURL&, HTMLImport* excluding = 0) const = 0;
154 };
155
156 } // namespace WebCore 144 } // namespace WebCore
157 145
158 #endif // HTMLImport_h 146 #endif // HTMLImport_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/imports/HTMLImport.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698