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

Side by Side Diff: Source/core/dom/custom/CustomElementRegistrationContext.cpp

Issue 296703009: Oilpan: move custom element objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix compilation issue pointed out by clang Created 6 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 unified diff | Download patch
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 27 matching lines...) Expand all
38 #include "core/dom/custom/CustomElement.h" 38 #include "core/dom/custom/CustomElement.h"
39 #include "core/dom/custom/CustomElementDefinition.h" 39 #include "core/dom/custom/CustomElementDefinition.h"
40 #include "core/dom/custom/CustomElementScheduler.h" 40 #include "core/dom/custom/CustomElementScheduler.h"
41 #include "core/html/HTMLElement.h" 41 #include "core/html/HTMLElement.h"
42 #include "core/html/HTMLUnknownElement.h" 42 #include "core/html/HTMLUnknownElement.h"
43 #include "core/svg/SVGUnknownElement.h" 43 #include "core/svg/SVGUnknownElement.h"
44 #include "wtf/RefPtr.h" 44 #include "wtf/RefPtr.h"
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 CustomElementRegistrationContext::CustomElementRegistrationContext()
49 : m_candidates(CustomElementUpgradeCandidateMap::create())
50 {
51 }
52
48 void CustomElementRegistrationContext::registerElement(Document* document, Custo mElementConstructorBuilder* constructorBuilder, const AtomicString& type, Custom Element::NameSet validNames, ExceptionState& exceptionState) 53 void CustomElementRegistrationContext::registerElement(Document* document, Custo mElementConstructorBuilder* constructorBuilder, const AtomicString& type, Custom Element::NameSet validNames, ExceptionState& exceptionState)
49 { 54 {
50 CustomElementDefinition* definition = m_registry.registerElement(document, c onstructorBuilder, type, validNames, exceptionState); 55 CustomElementDefinition* definition = m_registry.registerElement(document, c onstructorBuilder, type, validNames, exceptionState);
51 56
52 if (!definition) 57 if (!definition)
53 return; 58 return;
54 59
55 // Upgrade elements that were waiting for this definition. 60 // Upgrade elements that were waiting for this definition.
56 const CustomElementUpgradeCandidateMap::ElementSet& upgradeCandidates = m_ca ndidates.takeUpgradeCandidatesFor(definition->descriptor()); 61 OwnPtrWillBeRawPtr<CustomElementUpgradeCandidateMap::ElementSet> upgradeCand idates = m_candidates->takeUpgradeCandidatesFor(definition->descriptor());
57 for (CustomElementUpgradeCandidateMap::ElementSet::const_iterator it = upgra deCandidates.begin(); it != upgradeCandidates.end(); ++it) 62
63 if (!upgradeCandidates)
64 return;
65
66 for (CustomElementUpgradeCandidateMap::ElementSet::const_iterator it = upgra deCandidates->begin(); it != upgradeCandidates->end(); ++it)
58 CustomElement::define(*it, definition); 67 CustomElement::define(*it, definition);
59 } 68 }
60 69
61 PassRefPtrWillBeRawPtr<Element> CustomElementRegistrationContext::createCustomTa gElement(Document& document, const QualifiedName& tagName) 70 PassRefPtrWillBeRawPtr<Element> CustomElementRegistrationContext::createCustomTa gElement(Document& document, const QualifiedName& tagName)
62 { 71 {
63 ASSERT(CustomElement::isValidName(tagName.localName())); 72 ASSERT(CustomElement::isValidName(tagName.localName()));
64 73
65 RefPtrWillBeRawPtr<Element> element; 74 RefPtrWillBeRawPtr<Element> element;
66 75
67 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { 76 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) {
(...skipping 30 matching lines...) Expand all
98 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto r); 107 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto r);
99 } 108 }
100 109
101 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle mentDescriptor& descriptor) 110 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle mentDescriptor& descriptor)
102 { 111 {
103 CustomElementDefinition* definition = m_registry.find(descriptor); 112 CustomElementDefinition* definition = m_registry.find(descriptor);
104 if (definition) { 113 if (definition) {
105 CustomElement::define(element, definition); 114 CustomElement::define(element, definition);
106 } else { 115 } else {
107 ASSERT(element->customElementState() == Element::WaitingForUpgrade); 116 ASSERT(element->customElementState() == Element::WaitingForUpgrade);
108 m_candidates.add(descriptor, element); 117 m_candidates->add(descriptor, element);
109 } 118 }
110 } 119 }
111 120
112 PassRefPtr<CustomElementRegistrationContext> CustomElementRegistrationContext::c reate()
113 {
114 return adoptRef(new CustomElementRegistrationContext());
115 }
116
117 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e lement, const AtomicString& type) 121 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e lement, const AtomicString& type)
118 { 122 {
119 ASSERT(element); 123 ASSERT(element);
120 ASSERT(!type.isEmpty()); 124 ASSERT(!type.isEmpty());
121 element->setAttribute(HTMLNames::isAttr, type); 125 element->setAttribute(HTMLNames::isAttr, type);
122 setTypeExtension(element, type); 126 setTypeExtension(element, type);
123 } 127 }
124 128
125 void CustomElementRegistrationContext::setTypeExtension(Element* element, const AtomicString& type) 129 void CustomElementRegistrationContext::setTypeExtension(Element* element, const AtomicString& type)
126 { 130 {
(...skipping 16 matching lines...) Expand all
143 // Custom tags take precedence over type extensions 147 // Custom tags take precedence over type extensions
144 ASSERT(!CustomElement::isValidName(element->localName())); 148 ASSERT(!CustomElement::isValidName(element->localName()));
145 149
146 if (!CustomElement::isValidName(type)) 150 if (!CustomElement::isValidName(type))
147 return; 151 return;
148 152
149 element->setCustomElementState(Element::WaitingForUpgrade); 153 element->setCustomElementState(Element::WaitingForUpgrade);
150 context->didGiveTypeExtension(element, type); 154 context->didGiveTypeExtension(element, type);
151 } 155 }
152 156
157 void CustomElementRegistrationContext::trace(Visitor* visitor)
158 {
159 visitor->trace(m_candidates);
160 }
161
153 } // namespace WebCore 162 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/custom/CustomElementRegistrationContext.h ('k') | Source/core/dom/custom/CustomElementScheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698