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

Unified Diff: Source/core/dom/CustomElementUpgradeCandidateMap.h

Issue 14626005: Upgrade elements that are created before a custom element definition is registered (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Feedback+test Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/CustomElementRegistry.cpp ('k') | Source/core/dom/CustomElementUpgradeCandidateMap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/CustomElementUpgradeCandidateMap.h
diff --git a/Source/core/dom/CustomElementConstructor.cpp b/Source/core/dom/CustomElementUpgradeCandidateMap.h
similarity index 58%
copy from Source/core/dom/CustomElementConstructor.cpp
copy to Source/core/dom/CustomElementUpgradeCandidateMap.h
index f664ecf92864d5eadb5d9316e46ffe2df99ae40c..1cc8c35387e88bf9d35dec933db8eadf3fe9413a 100644
--- a/Source/core/dom/CustomElementConstructor.cpp
+++ b/Source/core/dom/CustomElementUpgradeCandidateMap.h
@@ -28,34 +28,43 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
+#ifndef CustomElementUpgradeCandidateMap_h
+#define CustomElementUpgradeCandidateMap_h
-#include "core/dom/CustomElementConstructor.h"
-
-#include "core/dom/Document.h"
+#include "core/dom/CustomElementDefinition.h"
#include "core/dom/Element.h"
+#include "wtf/HashMap.h"
+#include "wtf/HashSet.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/AtomicStringHash.h"
namespace WebCore {
-PassRefPtr<CustomElementConstructor> CustomElementConstructor::create(Document* document, const QualifiedName& tag, const AtomicString& typeExtension) {
- return adoptRef(new CustomElementConstructor(document, tag, typeExtension));
-}
+class CustomElementUpgradeCandidateMap {
+ WTF_MAKE_NONCOPYABLE(CustomElementUpgradeCandidateMap);
+public:
+ CustomElementUpgradeCandidateMap() { }
-CustomElementConstructor::CustomElementConstructor(Document* document, const QualifiedName& tag, const AtomicString& typeExtension)
- : ContextDestructionObserver(document)
- , m_tag(tag)
- , m_typeExtension(typeExtension)
-{
-}
+ typedef HashSet<Element*> ElementSet;
-Document* CustomElementConstructor::document() const {
- return toDocument(m_scriptExecutionContext);
-}
+ void add(CustomElementDefinition::CustomElementKind, const AtomicString& type, Element*);
+ bool contains(Element*) const;
+ void remove(Element*);
+ ElementSet takeUpgradeCandidatesFor(CustomElementDefinition* definition);
-PassRefPtr<Element> CustomElementConstructor::createElement(ExceptionCode& ec) {
- if (!document())
- return 0;
- return document()->createElementNS(m_tag.namespaceURI(), m_tag.localName(), m_typeExtension, ec);
-}
+private:
+ typedef std::pair<CustomElementDefinition::CustomElementKind, AtomicString> RequiredDefinition;
+ typedef HashMap<Element*, RequiredDefinition> UnresolvedElementMap;
+ typedef HashMap<AtomicString, ElementSet> UnresolvedDefinitionMap;
+
+ bool matches(CustomElementDefinition*, Element*);
+
+ UnresolvedElementMap m_unresolvedElements;
+ UnresolvedDefinitionMap m_unresolvedDefinitions;
+};
}
+
+#endif // CustomElementUpgradeCandidateMap_h
+
« no previous file with comments | « Source/core/dom/CustomElementRegistry.cpp ('k') | Source/core/dom/CustomElementUpgradeCandidateMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698