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

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

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win Created 4 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
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 if (!upgradeCandidates) 62 if (!upgradeCandidates)
63 return; 63 return;
64 64
65 for (const auto& candidate : *upgradeCandidates) 65 for (const auto& candidate : *upgradeCandidates)
66 CustomElement::define(candidate, definition); 66 CustomElement::define(candidate, definition);
67 } 67 }
68 68
69 RawPtr<Element> CustomElementRegistrationContext::createCustomTagElement(Documen t& document, const QualifiedName& tagName) 69 RawPtr<Element> CustomElementRegistrationContext::createCustomTagElement(Documen t& document, const QualifiedName& tagName)
70 { 70 {
71 ASSERT(CustomElement::isValidName(tagName.localName())); 71 DCHECK(CustomElement::isValidName(tagName.localName()));
72 72
73 RawPtr<Element> element; 73 RawPtr<Element> element;
74 74
75 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { 75 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) {
76 element = HTMLElement::create(tagName, document); 76 element = HTMLElement::create(tagName, document);
77 } else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) { 77 } else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) {
78 element = SVGUnknownElement::create(tagName, document); 78 element = SVGUnknownElement::create(tagName, document);
79 } else { 79 } else {
80 // XML elements are not custom elements, so return early. 80 // XML elements are not custom elements, so return early.
81 return Element::create(tagName, &document); 81 return Element::create(tagName, &document);
82 } 82 }
83 83
84 element->setCustomElementState(Element::WaitingForUpgrade); 84 element->setCustomElementState(Element::WaitingForUpgrade);
85 resolveOrScheduleResolution(element.get(), nullAtom); 85 resolveOrScheduleResolution(element.get(), nullAtom);
86 return element.release(); 86 return element.release();
87 } 87 }
88 88
89 void CustomElementRegistrationContext::didGiveTypeExtension(Element* element, co nst AtomicString& type) 89 void CustomElementRegistrationContext::didGiveTypeExtension(Element* element, co nst AtomicString& type)
90 { 90 {
91 resolveOrScheduleResolution(element, type); 91 resolveOrScheduleResolution(element, type);
92 } 92 }
93 93
94 void CustomElementRegistrationContext::resolveOrScheduleResolution(Element* elem ent, const AtomicString& typeExtension) 94 void CustomElementRegistrationContext::resolveOrScheduleResolution(Element* elem ent, const AtomicString& typeExtension)
95 { 95 {
96 // If an element has a custom tag name it takes precedence over 96 // If an element has a custom tag name it takes precedence over
97 // the "is" attribute (if any). 97 // the "is" attribute (if any).
98 const AtomicString& type = CustomElement::isValidName(element->localName()) 98 const AtomicString& type = CustomElement::isValidName(element->localName())
99 ? element->localName() 99 ? element->localName()
100 : typeExtension; 100 : typeExtension;
101 ASSERT(!type.isNull()); 101 DCHECK(!type.isNull());
102 102
103 CustomElementDescriptor descriptor(type, element->namespaceURI(), element->l ocalName()); 103 CustomElementDescriptor descriptor(type, element->namespaceURI(), element->l ocalName());
104 ASSERT(element->getCustomElementState() == Element::WaitingForUpgrade); 104 DCHECK_EQ(element->getCustomElementState(), Element::WaitingForUpgrade);
105 105
106 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto r); 106 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto r);
107 } 107 }
108 108
109 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle mentDescriptor& descriptor) 109 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle mentDescriptor& descriptor)
110 { 110 {
111 CustomElementDefinition* definition = m_registry.find(descriptor); 111 CustomElementDefinition* definition = m_registry.find(descriptor);
112 if (definition) { 112 if (definition) {
113 CustomElement::define(element, definition); 113 CustomElement::define(element, definition);
114 } else { 114 } else {
115 ASSERT(element->getCustomElementState() == Element::WaitingForUpgrade); 115 DCHECK_EQ(element->getCustomElementState(), Element::WaitingForUpgrade);
116 m_candidates->add(descriptor, element); 116 m_candidates->add(descriptor, element);
117 } 117 }
118 } 118 }
119 119
120 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e lement, const AtomicString& type) 120 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e lement, const AtomicString& type)
121 { 121 {
122 ASSERT(element); 122 DCHECK(element);
123 ASSERT(!type.isEmpty()); 123 DCHECK(!type.isEmpty());
124 element->setAttribute(HTMLNames::isAttr, type); 124 element->setAttribute(HTMLNames::isAttr, type);
125 setTypeExtension(element, type); 125 setTypeExtension(element, type);
126 } 126 }
127 127
128 void CustomElementRegistrationContext::setTypeExtension(Element* element, const AtomicString& type) 128 void CustomElementRegistrationContext::setTypeExtension(Element* element, const AtomicString& type)
129 { 129 {
130 if (!element->isHTMLElement() && !element->isSVGElement()) 130 if (!element->isHTMLElement() && !element->isSVGElement())
131 return; 131 return;
132 132
133 CustomElementRegistrationContext* context = element->document().registration Context(); 133 CustomElementRegistrationContext* context = element->document().registration Context();
134 if (!context) 134 if (!context)
135 return; 135 return;
136 136
137 if (element->isCustomElement()) { 137 if (element->isCustomElement()) {
138 // This can happen if: 138 // This can happen if:
139 // 1. The element has a custom tag, which takes precedence over 139 // 1. The element has a custom tag, which takes precedence over
140 // type extensions. 140 // type extensions.
141 // 2. Undoing a command (eg ReplaceNodeWithSpan) recycles an 141 // 2. Undoing a command (eg ReplaceNodeWithSpan) recycles an
142 // element but tries to overwrite its attribute list. 142 // element but tries to overwrite its attribute list.
143 return; 143 return;
144 } 144 }
145 145
146 // Custom tags take precedence over type extensions 146 // Custom tags take precedence over type extensions
147 ASSERT(!CustomElement::isValidName(element->localName())); 147 DCHECK(!CustomElement::isValidName(element->localName()));
148 148
149 if (!CustomElement::isValidName(type)) 149 if (!CustomElement::isValidName(type))
150 return; 150 return;
151 151
152 element->setCustomElementState(Element::WaitingForUpgrade); 152 element->setCustomElementState(Element::WaitingForUpgrade);
153 context->didGiveTypeExtension(element, element->document().convertLocalName( type)); 153 context->didGiveTypeExtension(element, element->document().convertLocalName( type));
154 } 154 }
155 155
156 DEFINE_TRACE(CustomElementRegistrationContext) 156 DEFINE_TRACE(CustomElementRegistrationContext)
157 { 157 {
158 visitor->trace(m_candidates); 158 visitor->trace(m_candidates);
159 visitor->trace(m_registry); 159 visitor->trace(m_registry);
160 } 160 }
161 161
162 } // namespace blink 162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698