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

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 // We need to retain the scroll customization callbacks until the element 141 // We need to retain the scroll customization callbacks until the element
142 // they're associated with is destroyed. It would be simplest if the callbacks 142 // they're associated with is destroyed. It would be simplest if the callbacks
143 // could be stored in ElementRareData, but we can't afford the space 143 // could be stored in ElementRareData, but we can't afford the space
144 // increase. Instead, keep the scroll customization callbacks here. The other 144 // increase. Instead, keep the scroll customization callbacks here. The other
145 // option would be to store these callbacks on the FrameHost or document, but 145 // option would be to store these callbacks on the FrameHost or document, but
146 // that necessitates a bunch more logic for transferring the callbacks between 146 // that necessitates a bunch more logic for transferring the callbacks between
147 // FrameHosts when elements are moved around. 147 // FrameHosts when elements are moved around.
148 ScrollCustomizationCallbacks& scrollCustomizationCallbacks() 148 ScrollCustomizationCallbacks& scrollCustomizationCallbacks()
149 { 149 {
150 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled()); 150 DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled());
151 DEFINE_STATIC_LOCAL(ScrollCustomizationCallbacks, scrollCustomizationCallbac ks, (new ScrollCustomizationCallbacks)); 151 DEFINE_STATIC_LOCAL(ScrollCustomizationCallbacks, scrollCustomizationCallbac ks, (new ScrollCustomizationCallbacks));
152 return scrollCustomizationCallbacks; 152 return scrollCustomizationCallbacks;
153 } 153 }
154 154
155 } // namespace 155 } // namespace
156 156
157 using namespace HTMLNames; 157 using namespace HTMLNames;
158 using namespace XMLNames; 158 using namespace XMLNames;
159 159
160 enum class ClassStringContent { Empty, WhiteSpaceOnly, HasClasses }; 160 enum class ClassStringContent { Empty, WhiteSpaceOnly, HasClasses };
161 161
162 RawPtr<Element> Element::create(const QualifiedName& tagName, Document* document ) 162 RawPtr<Element> Element::create(const QualifiedName& tagName, Document* document )
163 { 163 {
164 return new Element(tagName, document, CreateElement); 164 return new Element(tagName, document, CreateElement);
165 } 165 }
166 166
167 Element::Element(const QualifiedName& tagName, Document* document, ConstructionT ype type) 167 Element::Element(const QualifiedName& tagName, Document* document, ConstructionT ype type)
168 : ContainerNode(document, type) 168 : ContainerNode(document, type)
169 , m_tagName(tagName) 169 , m_tagName(tagName)
170 { 170 {
171 } 171 }
172 172
173 Element::~Element() 173 Element::~Element()
174 { 174 {
175 ASSERT(needsAttach()); 175 DCHECK(needsAttach());
176 176
177 #if !ENABLE(OILPAN) 177 #if !ENABLE(OILPAN)
178 if (hasRareData()) { 178 if (hasRareData()) {
179 elementRareData()->clearShadow(); 179 elementRareData()->clearShadow();
180 detachAllAttrNodesFromElement(); 180 detachAllAttrNodesFromElement();
181 } 181 }
182 182
183 if (isCustomElement()) 183 if (isCustomElement())
184 CustomElement::wasDestroyed(this); 184 CustomElement::wasDestroyed(this);
185 185
186 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) 186 if (RuntimeEnabledFeatures::scrollCustomizationEnabled())
187 scrollCustomizationCallbacks().removeCallbacksForElement(this); 187 scrollCustomizationCallbacks().removeCallbacksForElement(this);
188 188
189 // With Oilpan, either the Element has been removed from the Document 189 // With Oilpan, either the Element has been removed from the Document
190 // or the Document is dead as well. If the Element has been removed from 190 // or the Document is dead as well. If the Element has been removed from
191 // the Document the element has already been removed from the pending 191 // the Document the element has already been removed from the pending
192 // resources. If the document is also dead, there is no need to remove 192 // resources. If the document is also dead, there is no need to remove
193 // the element from the pending resources. 193 // the element from the pending resources.
194 if (hasPendingResources()) { 194 if (hasPendingResources()) {
195 document().accessSVGExtensions().removeElementFromPendingResources(this) ; 195 document().accessSVGExtensions().removeElementFromPendingResources(this) ;
196 ASSERT(!hasPendingResources()); 196 DCHECK(!hasPendingResources());
197 } 197 }
198 #endif 198 #endif
199 } 199 }
200 200
201 inline ElementRareData* Element::elementRareData() const 201 inline ElementRareData* Element::elementRareData() const
202 { 202 {
203 ASSERT(hasRareData()); 203 DCHECK(hasRareData());
204 return static_cast<ElementRareData*>(rareData()); 204 return static_cast<ElementRareData*>(rareData());
205 } 205 }
206 206
207 inline ElementRareData& Element::ensureElementRareData() 207 inline ElementRareData& Element::ensureElementRareData()
208 { 208 {
209 return static_cast<ElementRareData&>(ensureRareData()); 209 return static_cast<ElementRareData&>(ensureRareData());
210 } 210 }
211 211
212 bool Element::hasElementFlagInternal(ElementFlags mask) const 212 bool Element::hasElementFlagInternal(ElementFlags mask) const
213 { 213 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 { 248 {
249 return hasRareData() ? elementRareData()->tabIndex() : 0; 249 return hasRareData() ? elementRareData()->tabIndex() : 0;
250 } 250 }
251 251
252 bool Element::layoutObjectIsFocusable() const 252 bool Element::layoutObjectIsFocusable() const
253 { 253 {
254 // Elements in canvas fallback content are not rendered, but they are allowe d to be 254 // Elements in canvas fallback content are not rendered, but they are allowe d to be
255 // focusable as long as their canvas is displayed and visible. 255 // focusable as long as their canvas is displayed and visible.
256 if (isInCanvasSubtree()) { 256 if (isInCanvasSubtree()) {
257 const HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAnc estorOrSelf(*this); 257 const HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAnc estorOrSelf(*this);
258 ASSERT(canvas); 258 DCHECK(canvas);
259 return canvas->layoutObject() && canvas->layoutObject()->style()->visibi lity() == VISIBLE; 259 return canvas->layoutObject() && canvas->layoutObject()->style()->visibi lity() == VISIBLE;
260 } 260 }
261 261
262 // FIXME: Even if we are not visible, we might have a child that is visible. 262 // FIXME: Even if we are not visible, we might have a child that is visible.
263 // Hyatt wants to fix that some day with a "has visible content" flag or the like. 263 // Hyatt wants to fix that some day with a "has visible content" flag or the like.
264 return layoutObject() && layoutObject()->style()->visibility() == VISIBLE; 264 return layoutObject() && layoutObject()->style()->visibility() == VISIBLE;
265 } 265 }
266 266
267 RawPtr<Node> Element::cloneNode(bool deep) 267 RawPtr<Node> Element::cloneNode(bool deep)
268 { 268 {
269 return deep ? cloneElementWithChildren() : cloneElementWithoutChildren(); 269 return deep ? cloneElementWithChildren() : cloneElementWithoutChildren();
270 } 270 }
271 271
272 RawPtr<Element> Element::cloneElementWithChildren() 272 RawPtr<Element> Element::cloneElementWithChildren()
273 { 273 {
274 RawPtr<Element> clone = cloneElementWithoutChildren(); 274 RawPtr<Element> clone = cloneElementWithoutChildren();
275 cloneChildNodes(clone.get()); 275 cloneChildNodes(clone.get());
276 return clone.release(); 276 return clone.release();
277 } 277 }
278 278
279 RawPtr<Element> Element::cloneElementWithoutChildren() 279 RawPtr<Element> Element::cloneElementWithoutChildren()
280 { 280 {
281 RawPtr<Element> clone = cloneElementWithoutAttributesAndChildren(); 281 RawPtr<Element> clone = cloneElementWithoutAttributesAndChildren();
282 // This will catch HTML elements in the wrong namespace that are not correct ly copied. 282 // This will catch HTML elements in the wrong namespace that are not correct ly copied.
283 // This is a sanity check as HTML overloads some of the DOM methods. 283 // This is a sanity check as HTML overloads some of the DOM methods.
284 ASSERT(isHTMLElement() == clone->isHTMLElement()); 284 DCHECK_EQ(isHTMLElement(), clone->isHTMLElement());
285 285
286 clone->cloneDataFromElement(*this); 286 clone->cloneDataFromElement(*this);
287 return clone.release(); 287 return clone.release();
288 } 288 }
289 289
290 RawPtr<Element> Element::cloneElementWithoutAttributesAndChildren() 290 RawPtr<Element> Element::cloneElementWithoutAttributesAndChildren()
291 { 291 {
292 return document().createElement(tagQName(), false); 292 return document().createElement(tagQName(), false);
293 } 293 }
294 294
295 RawPtr<Attr> Element::detachAttribute(size_t index) 295 RawPtr<Attr> Element::detachAttribute(size_t index)
296 { 296 {
297 ASSERT(elementData()); 297 DCHECK(elementData());
298 const Attribute& attribute = elementData()->attributes().at(index); 298 const Attribute& attribute = elementData()->attributes().at(index);
299 RawPtr<Attr> attrNode = attrIfExists(attribute.name()); 299 RawPtr<Attr> attrNode = attrIfExists(attribute.name());
300 if (attrNode) { 300 if (attrNode) {
301 detachAttrNodeAtIndex(attrNode.get(), index); 301 detachAttrNodeAtIndex(attrNode.get(), index);
302 } else { 302 } else {
303 attrNode = Attr::create(document(), attribute.name(), attribute.value()) ; 303 attrNode = Attr::create(document(), attribute.name(), attribute.value()) ;
304 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); 304 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute);
305 } 305 }
306 return attrNode.release(); 306 return attrNode.release();
307 } 307 }
308 308
309 void Element::detachAttrNodeAtIndex(Attr* attr, size_t index) 309 void Element::detachAttrNodeAtIndex(Attr* attr, size_t index)
310 { 310 {
311 ASSERT(attr); 311 DCHECK(attr);
312 ASSERT(elementData()); 312 DCHECK(elementData());
313 313
314 const Attribute& attribute = elementData()->attributes().at(index); 314 const Attribute& attribute = elementData()->attributes().at(index);
315 ASSERT(attribute.name() == attr->getQualifiedName()); 315 DCHECK(attribute.name() == attr->getQualifiedName());
316 detachAttrNodeFromElementWithValue(attr, attribute.value()); 316 detachAttrNodeFromElementWithValue(attr, attribute.value());
317 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); 317 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute);
318 } 318 }
319 319
320 void Element::removeAttribute(const QualifiedName& name) 320 void Element::removeAttribute(const QualifiedName& name)
321 { 321 {
322 if (!elementData()) 322 if (!elementData())
323 return; 323 return;
324 324
325 size_t index = elementData()->attributes().findIndex(name); 325 size_t index = elementData()->attributes().findIndex(name);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 382 }
383 383
384 void Element::synchronizeAllAttributes() const 384 void Element::synchronizeAllAttributes() const
385 { 385 {
386 if (!elementData()) 386 if (!elementData())
387 return; 387 return;
388 // NOTE: anyAttributeMatches in SelectorChecker.cpp 388 // NOTE: anyAttributeMatches in SelectorChecker.cpp
389 // currently assumes that all lazy attributes have a null namespace. 389 // currently assumes that all lazy attributes have a null namespace.
390 // If that ever changes we'll need to fix that code. 390 // If that ever changes we'll need to fix that code.
391 if (elementData()->m_styleAttributeIsDirty) { 391 if (elementData()->m_styleAttributeIsDirty) {
392 ASSERT(isStyledElement()); 392 DCHECK(isStyledElement());
393 synchronizeStyleAttributeInternal(); 393 synchronizeStyleAttributeInternal();
394 } 394 }
395 if (elementData()->m_animatedSVGAttributesAreDirty) { 395 if (elementData()->m_animatedSVGAttributesAreDirty) {
396 ASSERT(isSVGElement()); 396 DCHECK(isSVGElement());
397 toSVGElement(this)->synchronizeAnimatedSVGAttribute(anyQName()); 397 toSVGElement(this)->synchronizeAnimatedSVGAttribute(anyQName());
398 } 398 }
399 } 399 }
400 400
401 inline void Element::synchronizeAttribute(const QualifiedName& name) const 401 inline void Element::synchronizeAttribute(const QualifiedName& name) const
402 { 402 {
403 if (!elementData()) 403 if (!elementData())
404 return; 404 return;
405 if (UNLIKELY(name == styleAttr && elementData()->m_styleAttributeIsDirty)) { 405 if (UNLIKELY(name == styleAttr && elementData()->m_styleAttributeIsDirty)) {
406 ASSERT(isStyledElement()); 406 DCHECK(isStyledElement());
407 synchronizeStyleAttributeInternal(); 407 synchronizeStyleAttributeInternal();
408 return; 408 return;
409 } 409 }
410 if (UNLIKELY(elementData()->m_animatedSVGAttributesAreDirty)) { 410 if (UNLIKELY(elementData()->m_animatedSVGAttributesAreDirty)) {
411 ASSERT(isSVGElement()); 411 DCHECK(isSVGElement());
412 // See comment in the AtomicString version of synchronizeAttribute() 412 // See comment in the AtomicString version of synchronizeAttribute()
413 // also. 413 // also.
414 toSVGElement(this)->synchronizeAnimatedSVGAttribute(name); 414 toSVGElement(this)->synchronizeAnimatedSVGAttribute(name);
415 } 415 }
416 } 416 }
417 417
418 void Element::synchronizeAttribute(const AtomicString& localName) const 418 void Element::synchronizeAttribute(const AtomicString& localName) const
419 { 419 {
420 // This version of synchronizeAttribute() is streamlined for the case where you don't have a full QualifiedName, 420 // This version of synchronizeAttribute() is streamlined for the case where you don't have a full QualifiedName,
421 // e.g when called from DOM API. 421 // e.g when called from DOM API.
422 if (!elementData()) 422 if (!elementData())
423 return; 423 return;
424 if (elementData()->m_styleAttributeIsDirty && equalPossiblyIgnoringCase(loca lName, styleAttr.localName(), shouldIgnoreAttributeCase())) { 424 if (elementData()->m_styleAttributeIsDirty && equalPossiblyIgnoringCase(loca lName, styleAttr.localName(), shouldIgnoreAttributeCase())) {
425 ASSERT(isStyledElement()); 425 DCHECK(isStyledElement());
426 synchronizeStyleAttributeInternal(); 426 synchronizeStyleAttributeInternal();
427 return; 427 return;
428 } 428 }
429 if (elementData()->m_animatedSVGAttributesAreDirty) { 429 if (elementData()->m_animatedSVGAttributesAreDirty) {
430 // We're not passing a namespace argument on purpose. SVGNames::*Attr ar e defined w/o namespaces as well. 430 // We're not passing a namespace argument on purpose. SVGNames::*Attr ar e defined w/o namespaces as well.
431 431
432 // FIXME: this code is called regardless of whether name is an 432 // FIXME: this code is called regardless of whether name is an
433 // animated SVG Attribute. It would seem we should only call this method 433 // animated SVG Attribute. It would seem we should only call this method
434 // if SVGElement::isAnimatableAttribute is true, but the list of 434 // if SVGElement::isAnimatableAttribute is true, but the list of
435 // animatable attributes in isAnimatableAttribute does not suffice to 435 // animatable attributes in isAnimatableAttribute does not suffice to
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 499 }
500 500
501 void Element::setApplyScroll(ScrollStateCallback* scrollStateCallback, String na tiveScrollBehavior) 501 void Element::setApplyScroll(ScrollStateCallback* scrollStateCallback, String na tiveScrollBehavior)
502 { 502 {
503 scrollStateCallback->setNativeScrollBehavior(ScrollStateCallback::toNativeSc rollBehavior(nativeScrollBehavior)); 503 scrollStateCallback->setNativeScrollBehavior(ScrollStateCallback::toNativeSc rollBehavior(nativeScrollBehavior));
504 scrollCustomizationCallbacks().setApplyScroll(this, scrollStateCallback); 504 scrollCustomizationCallbacks().setApplyScroll(this, scrollStateCallback);
505 } 505 }
506 506
507 void Element::nativeDistributeScroll(ScrollState& scrollState) 507 void Element::nativeDistributeScroll(ScrollState& scrollState)
508 { 508 {
509 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled()); 509 DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled());
510 if (scrollState.fullyConsumed()) 510 if (scrollState.fullyConsumed())
511 return; 511 return;
512 512
513 scrollState.distributeToScrollChainDescendant(); 513 scrollState.distributeToScrollChainDescendant();
514 514
515 // If the scroll doesn't propagate, and we're currently scrolling 515 // If the scroll doesn't propagate, and we're currently scrolling
516 // an element other than this one, prevent the scroll from 516 // an element other than this one, prevent the scroll from
517 // propagating to this element. 517 // propagating to this element.
518 if (!scrollState.shouldPropagate() 518 if (!scrollState.shouldPropagate()
519 && scrollState.deltaConsumedForScrollSequence() 519 && scrollState.deltaConsumedForScrollSequence()
(...skipping 20 matching lines...) Expand all
540 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte rNativeScroll) 540 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte rNativeScroll)
541 callback->handleEvent(&scrollState); 541 callback->handleEvent(&scrollState);
542 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati veScroll) 542 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati veScroll)
543 nativeDistributeScroll(scrollState); 543 nativeDistributeScroll(scrollState);
544 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte rNativeScroll) 544 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte rNativeScroll)
545 callback->handleEvent(&scrollState); 545 callback->handleEvent(&scrollState);
546 }; 546 };
547 547
548 void Element::nativeApplyScroll(ScrollState& scrollState) 548 void Element::nativeApplyScroll(ScrollState& scrollState)
549 { 549 {
550 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled()); 550 DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled());
551 if (scrollState.fullyConsumed()) 551 if (scrollState.fullyConsumed())
552 return; 552 return;
553 553
554 const double deltaX = scrollState.deltaX(); 554 const double deltaX = scrollState.deltaX();
555 const double deltaY = scrollState.deltaY(); 555 const double deltaY = scrollState.deltaY();
556 bool scrolled = false; 556 bool scrolled = false;
557 557
558 // TODO(esprehn): This should use updateLayoutIgnorePendingStylesheetsForNod e. 558 // TODO(esprehn): This should use updateLayoutIgnorePendingStylesheetsForNod e.
559 if (deltaY || deltaX) 559 if (deltaY || deltaX)
560 document().updateLayoutIgnorePendingStylesheets(); 560 document().updateLayoutIgnorePendingStylesheets();
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1033 }
1034 } 1034 }
1035 1035
1036 if (quads.isEmpty()) 1036 if (quads.isEmpty())
1037 return ClientRect::create(); 1037 return ClientRect::create();
1038 1038
1039 FloatRect result = quads[0].boundingBox(); 1039 FloatRect result = quads[0].boundingBox();
1040 for (size_t i = 1; i < quads.size(); ++i) 1040 for (size_t i = 1; i < quads.size(); ++i)
1041 result.unite(quads[i].boundingBox()); 1041 result.unite(quads[i].boundingBox());
1042 1042
1043 ASSERT(elementLayoutObject); 1043 DCHECK(elementLayoutObject);
1044 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj ect); 1044 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj ect);
1045 return ClientRect::create(result); 1045 return ClientRect::create(result);
1046 } 1046 }
1047 1047
1048 const AtomicString& Element::computedRole() 1048 const AtomicString& Element::computedRole()
1049 { 1049 {
1050 document().updateLayoutIgnorePendingStylesheetsForNode(this); 1050 document().updateLayoutIgnorePendingStylesheetsForNode(this);
1051 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); 1051 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document());
1052 return cache->get()->computedRoleForNode(this); 1052 return cache->get()->computedRoleForNode(this);
1053 } 1053 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName& name, const AtomicString& newValue, AttributeModificationReason reason) 1198 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName& name, const AtomicString& newValue, AttributeModificationReason reason)
1199 { 1199 {
1200 if (name == isAttr) 1200 if (name == isAttr)
1201 CustomElementRegistrationContext::setTypeExtension(this, newValue); 1201 CustomElementRegistrationContext::setTypeExtension(this, newValue);
1202 attributeChanged(name, nullAtom, newValue, reason); 1202 attributeChanged(name, nullAtom, newValue, reason);
1203 } 1203 }
1204 1204
1205 template <typename CharacterType> 1205 template <typename CharacterType>
1206 static inline ClassStringContent classStringHasClassName(const CharacterType* ch aracters, unsigned length) 1206 static inline ClassStringContent classStringHasClassName(const CharacterType* ch aracters, unsigned length)
1207 { 1207 {
1208 ASSERT(length > 0); 1208 DCHECK_GT(length, 0u);
1209 1209
1210 unsigned i = 0; 1210 unsigned i = 0;
1211 do { 1211 do {
1212 if (isNotHTMLSpace<CharacterType>(characters[i])) 1212 if (isNotHTMLSpace<CharacterType>(characters[i]))
1213 break; 1213 break;
1214 ++i; 1214 ++i;
1215 } while (i < length); 1215 } while (i < length);
1216 1216
1217 if (i == length && length == 1) 1217 if (i == length && length == 1)
1218 return ClassStringContent::Empty; 1218 return ClassStringContent::Empty;
(...skipping 10 matching lines...) Expand all
1229 if (!length) 1229 if (!length)
1230 return ClassStringContent::Empty; 1230 return ClassStringContent::Empty;
1231 1231
1232 if (newClassString.is8Bit()) 1232 if (newClassString.is8Bit())
1233 return classStringHasClassName(newClassString.characters8(), length); 1233 return classStringHasClassName(newClassString.characters8(), length);
1234 return classStringHasClassName(newClassString.characters16(), length); 1234 return classStringHasClassName(newClassString.characters16(), length);
1235 } 1235 }
1236 1236
1237 void Element::classAttributeChanged(const AtomicString& newClassString) 1237 void Element::classAttributeChanged(const AtomicString& newClassString)
1238 { 1238 {
1239 ASSERT(elementData()); 1239 DCHECK(elementData());
1240 ClassStringContent classStringContentType = classStringHasClassName(newClass String); 1240 ClassStringContent classStringContentType = classStringHasClassName(newClass String);
1241 const bool shouldFoldCase = document().inQuirksMode(); 1241 const bool shouldFoldCase = document().inQuirksMode();
1242 if (classStringContentType == ClassStringContent::HasClasses) { 1242 if (classStringContentType == ClassStringContent::HasClasses) {
1243 const SpaceSplitString oldClasses = elementData()->classNames(); 1243 const SpaceSplitString oldClasses = elementData()->classNames();
1244 elementData()->setClass(newClassString, shouldFoldCase); 1244 elementData()->setClass(newClassString, shouldFoldCase);
1245 const SpaceSplitString& newClasses = elementData()->classNames(); 1245 const SpaceSplitString& newClasses = elementData()->classNames();
1246 document().styleEngine().classChangedForElement(oldClasses, newClasses, *this); 1246 document().styleEngine().classChangedForElement(oldClasses, newClasses, *this);
1247 } else { 1247 } else {
1248 const SpaceSplitString& oldClasses = elementData()->classNames(); 1248 const SpaceSplitString& oldClasses = elementData()->classNames();
1249 document().styleEngine().classChangedForElement(oldClasses, *this); 1249 document().styleEngine().classChangedForElement(oldClasses, *this);
1250 if (classStringContentType == ClassStringContent::WhiteSpaceOnly) 1250 if (classStringContentType == ClassStringContent::WhiteSpaceOnly)
1251 elementData()->setClass(newClassString, shouldFoldCase); 1251 elementData()->setClass(newClassString, shouldFoldCase);
1252 else 1252 else
1253 elementData()->clearClass(); 1253 elementData()->clearClass();
1254 } 1254 }
1255 1255
1256 if (hasRareData()) 1256 if (hasRareData())
1257 elementRareData()->clearClassListValueForQuirksMode(); 1257 elementRareData()->clearClassListValueForQuirksMode();
1258 } 1258 }
1259 1259
1260 bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* el ementShadow, const QualifiedName& name, const AtomicString& newValue) 1260 bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* el ementShadow, const QualifiedName& name, const AtomicString& newValue)
1261 { 1261 {
1262 ASSERT(elementShadow); 1262 DCHECK(elementShadow);
1263 const SelectRuleFeatureSet& featureSet = elementShadow->ensureSelectFeatureS et(); 1263 const SelectRuleFeatureSet& featureSet = elementShadow->ensureSelectFeatureS et();
1264 1264
1265 if (name == HTMLNames::idAttr) { 1265 if (name == HTMLNames::idAttr) {
1266 AtomicString oldId = elementData()->idForStyleResolution(); 1266 AtomicString oldId = elementData()->idForStyleResolution();
1267 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode()); 1267 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
1268 if (newId != oldId) { 1268 if (newId != oldId) {
1269 if (!oldId.isEmpty() && featureSet.hasSelectorForId(oldId)) 1269 if (!oldId.isEmpty() && featureSet.hasSelectorForId(oldId))
1270 return true; 1270 return true;
1271 if (!newId.isEmpty() && featureSet.hasSelectorForId(newId)) 1271 if (!newId.isEmpty() && featureSet.hasSelectorForId(newId))
1272 return true; 1272 return true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 if (source != destination) 1323 if (source != destination)
1324 attributeVector[destination] = attributeVector[source]; 1324 attributeVector[destination] = attributeVector[source];
1325 1325
1326 ++destination; 1326 ++destination;
1327 } 1327 }
1328 attributeVector.shrink(destination); 1328 attributeVector.shrink(destination);
1329 } 1329 }
1330 1330
1331 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector) 1331 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector)
1332 { 1332 {
1333 ASSERT(!inShadowIncludingDocument()); 1333 DCHECK(!inShadowIncludingDocument());
1334 ASSERT(!parentNode()); 1334 DCHECK(!parentNode());
1335 ASSERT(!m_elementData); 1335 DCHECK(!m_elementData);
1336 1336
1337 if (!attributeVector.isEmpty()) { 1337 if (!attributeVector.isEmpty()) {
1338 if (document().elementDataCache()) 1338 if (document().elementDataCache())
1339 m_elementData = document().elementDataCache()->cachedShareableElemen tDataWithAttributes(attributeVector); 1339 m_elementData = document().elementDataCache()->cachedShareableElemen tDataWithAttributes(attributeVector);
1340 else 1340 else
1341 m_elementData = ShareableElementData::createWithAttributes(attribute Vector); 1341 m_elementData = ShareableElementData::createWithAttributes(attribute Vector);
1342 } 1342 }
1343 1343
1344 parserDidSetAttributes(); 1344 parserDidSetAttributes();
1345 1345
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 1400
1401 Node::InsertionNotificationRequest Element::insertedInto(ContainerNode* insertio nPoint) 1401 Node::InsertionNotificationRequest Element::insertedInto(ContainerNode* insertio nPoint)
1402 { 1402 {
1403 // need to do superclass processing first so inShadowIncludingDocument() is true 1403 // need to do superclass processing first so inShadowIncludingDocument() is true
1404 // by the time we reach updateId 1404 // by the time we reach updateId
1405 ContainerNode::insertedInto(insertionPoint); 1405 ContainerNode::insertedInto(insertionPoint);
1406 1406
1407 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement()) 1407 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement())
1408 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); 1408 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
1409 1409
1410 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); 1410 DCHECK(!hasRareData() || !elementRareData()->hasPseudoElements());
1411 1411
1412 if (!insertionPoint->isInTreeScope()) 1412 if (!insertionPoint->isInTreeScope())
1413 return InsertionDone; 1413 return InsertionDone;
1414 1414
1415 if (hasRareData()) { 1415 if (hasRareData()) {
1416 ElementRareData* rareData = elementRareData(); 1416 ElementRareData* rareData = elementRareData();
1417 rareData->clearClassListValueForQuirksMode(); 1417 rareData->clearClassListValueForQuirksMode();
1418 if (rareData->intersectionObserverData()) 1418 if (rareData->intersectionObserverData())
1419 rareData->intersectionObserverData()->activateValidIntersectionObser vers(*this); 1419 rareData->intersectionObserverData()->activateValidIntersectionObser vers(*this);
1420 } 1420 }
(...skipping 16 matching lines...) Expand all
1437 if (parentElement() && parentElement()->isInCanvasSubtree()) 1437 if (parentElement() && parentElement()->isInCanvasSubtree())
1438 setIsInCanvasSubtree(true); 1438 setIsInCanvasSubtree(true);
1439 1439
1440 return InsertionDone; 1440 return InsertionDone;
1441 } 1441 }
1442 1442
1443 void Element::removedFrom(ContainerNode* insertionPoint) 1443 void Element::removedFrom(ContainerNode* insertionPoint)
1444 { 1444 {
1445 bool wasInDocument = insertionPoint->inShadowIncludingDocument(); 1445 bool wasInDocument = insertionPoint->inShadowIncludingDocument();
1446 1446
1447 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); 1447 DCHECK(!hasRareData() || !elementRareData()->hasPseudoElements());
1448 1448
1449 if (Fullscreen::isActiveFullScreenElement(*this)) { 1449 if (Fullscreen::isActiveFullScreenElement(*this)) {
1450 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false); 1450 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
1451 if (insertionPoint->isElementNode()) { 1451 if (insertionPoint->isElementNode()) {
1452 toElement(insertionPoint)->setContainsFullScreenElement(false); 1452 toElement(insertionPoint)->setContainsFullScreenElement(false);
1453 toElement(insertionPoint)->setContainsFullScreenElementOnAncestorsCr ossingFrameBoundaries(false); 1453 toElement(insertionPoint)->setContainsFullScreenElementOnAncestorsCr ossingFrameBoundaries(false);
1454 } 1454 }
1455 } 1455 }
1456 1456
1457 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(document())) 1457 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(document()))
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 if (data->intersectionObserverData()) 1502 if (data->intersectionObserverData())
1503 data->intersectionObserverData()->deactivateAllIntersectionObservers (*this); 1503 data->intersectionObserverData()->deactivateAllIntersectionObservers (*this);
1504 } 1504 }
1505 1505
1506 if (document().frame()) 1506 if (document().frame())
1507 document().frame()->eventHandler().elementRemoved(this); 1507 document().frame()->eventHandler().elementRemoved(this);
1508 } 1508 }
1509 1509
1510 void Element::attach(const AttachContext& context) 1510 void Element::attach(const AttachContext& context)
1511 { 1511 {
1512 ASSERT(document().inStyleRecalc()); 1512 DCHECK(document().inStyleRecalc());
1513 1513
1514 // We've already been through detach when doing an attach, but we might 1514 // We've already been through detach when doing an attach, but we might
1515 // need to clear any state that's been added since then. 1515 // need to clear any state that's been added since then.
1516 if (hasRareData() && getStyleChangeType() == NeedsReattachStyleChange) { 1516 if (hasRareData() && getStyleChangeType() == NeedsReattachStyleChange) {
1517 ElementRareData* data = elementRareData(); 1517 ElementRareData* data = elementRareData();
1518 data->clearComputedStyle(); 1518 data->clearComputedStyle();
1519 } 1519 }
1520 1520
1521 if (!isSlotOrActiveInsertionPoint()) 1521 if (!isSlotOrActiveInsertionPoint())
1522 LayoutTreeBuilderForElement(*this, context.resolvedStyle).createLayoutOb jectIfNeeded(); 1522 LayoutTreeBuilderForElement(*this, context.resolvedStyle).createLayoutOb jectIfNeeded();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 document().activeChainNodeDetached(*this); 1591 document().activeChainNodeDetached(*this);
1592 document().userActionElements().didDetach(*this); 1592 document().userActionElements().didDetach(*this);
1593 } 1593 }
1594 1594
1595 if (context.clearInvalidation) 1595 if (context.clearInvalidation)
1596 document().styleEngine().styleInvalidator().clearInvalidation(*this); 1596 document().styleEngine().styleInvalidator().clearInvalidation(*this);
1597 1597
1598 if (svgFilterNeedsLayerUpdate()) 1598 if (svgFilterNeedsLayerUpdate())
1599 document().unscheduleSVGFilterLayerUpdateHack(*this); 1599 document().unscheduleSVGFilterLayerUpdateHack(*this);
1600 1600
1601 ASSERT(needsAttach()); 1601 DCHECK(needsAttach());
1602 } 1602 }
1603 1603
1604 bool Element::pseudoStyleCacheIsInvalid(const ComputedStyle* currentStyle, Compu tedStyle* newStyle) 1604 bool Element::pseudoStyleCacheIsInvalid(const ComputedStyle* currentStyle, Compu tedStyle* newStyle)
1605 { 1605 {
1606 ASSERT(currentStyle == computedStyle()); 1606 DCHECK_EQ(currentStyle, computedStyle());
1607 ASSERT(layoutObject()); 1607 DCHECK(layoutObject());
1608 1608
1609 if (!currentStyle) 1609 if (!currentStyle)
1610 return false; 1610 return false;
1611 1611
1612 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles( ); 1612 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles( );
1613 if (!pseudoStyleCache) 1613 if (!pseudoStyleCache)
1614 return false; 1614 return false;
1615 1615
1616 size_t cacheSize = pseudoStyleCache->size(); 1616 size_t cacheSize = pseudoStyleCache->size();
1617 for (size_t i = 0; i < cacheSize; ++i) { 1617 for (size_t i = 0; i < cacheSize; ++i) {
(...skipping 13 matching lines...) Expand all
1631 if (pseudoId == PseudoIdFirstLine || pseudoId == PseudoIdFirstLineIn herited) 1631 if (pseudoId == PseudoIdFirstLine || pseudoId == PseudoIdFirstLineIn herited)
1632 layoutObject()->firstLineStyleDidChange(*oldPseudoStyle, *newPse udoStyle); 1632 layoutObject()->firstLineStyleDidChange(*oldPseudoStyle, *newPse udoStyle);
1633 return true; 1633 return true;
1634 } 1634 }
1635 } 1635 }
1636 return false; 1636 return false;
1637 } 1637 }
1638 1638
1639 PassRefPtr<ComputedStyle> Element::styleForLayoutObject() 1639 PassRefPtr<ComputedStyle> Element::styleForLayoutObject()
1640 { 1640 {
1641 ASSERT(document().inStyleRecalc()); 1641 DCHECK(document().inStyleRecalc());
1642 1642
1643 RefPtr<ComputedStyle> style; 1643 RefPtr<ComputedStyle> style;
1644 1644
1645 // FIXME: Instead of clearing updates that may have been added from calls to styleForElement 1645 // FIXME: Instead of clearing updates that may have been added from calls to styleForElement
1646 // outside recalcStyle, we should just never set them if we're not inside re calcStyle. 1646 // outside recalcStyle, we should just never set them if we're not inside re calcStyle.
1647 if (ElementAnimations* elementAnimations = this->elementAnimations()) 1647 if (ElementAnimations* elementAnimations = this->elementAnimations())
1648 elementAnimations->cssAnimations().clearPendingUpdate(); 1648 elementAnimations->cssAnimations().clearPendingUpdate();
1649 1649
1650 if (hasCustomStyleCallbacks()) 1650 if (hasCustomStyleCallbacks())
1651 style = customStyleForLayoutObject(); 1651 style = customStyleForLayoutObject();
1652 if (!style) 1652 if (!style)
1653 style = originalStyleForLayoutObject(); 1653 style = originalStyleForLayoutObject();
1654 ASSERT(style); 1654 DCHECK(style);
1655 1655
1656 // styleForElement() might add active animations so we need to get it again. 1656 // styleForElement() might add active animations so we need to get it again.
1657 if (ElementAnimations* elementAnimations = this->elementAnimations()) { 1657 if (ElementAnimations* elementAnimations = this->elementAnimations()) {
1658 elementAnimations->cssAnimations().maybeApplyPendingUpdate(this); 1658 elementAnimations->cssAnimations().maybeApplyPendingUpdate(this);
1659 elementAnimations->updateAnimationFlags(*style); 1659 elementAnimations->updateAnimationFlags(*style);
1660 } 1660 }
1661 1661
1662 if (style->hasTransform()) { 1662 if (style->hasTransform()) {
1663 if (const StylePropertySet* inlineStyle = this->inlineStyle()) 1663 if (const StylePropertySet* inlineStyle = this->inlineStyle())
1664 style->setHasInlineTransform(inlineStyle->hasProperty(CSSPropertyTra nsform)); 1664 style->setHasInlineTransform(inlineStyle->hasProperty(CSSPropertyTra nsform));
1665 } 1665 }
1666 1666
1667 return style.release(); 1667 return style.release();
1668 } 1668 }
1669 1669
1670 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() 1670 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject()
1671 { 1671 {
1672 ASSERT(document().inStyleRecalc()); 1672 DCHECK(document().inStyleRecalc());
1673 return document().ensureStyleResolver().styleForElement(this); 1673 return document().ensureStyleResolver().styleForElement(this);
1674 } 1674 }
1675 1675
1676 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) 1676 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling)
1677 { 1677 {
1678 ASSERT(document().inStyleRecalc()); 1678 DCHECK(document().inStyleRecalc());
1679 ASSERT(!document().lifecycle().inDetach()); 1679 DCHECK(!document().lifecycle().inDetach());
1680 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); 1680 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
1681 ASSERT(inActiveDocument()); 1681 DCHECK(inActiveDocument());
1682 1682
1683 if (hasCustomStyleCallbacks()) 1683 if (hasCustomStyleCallbacks())
1684 willRecalcStyle(change); 1684 willRecalcStyle(change);
1685 1685
1686 if (change >= Inherit || needsStyleRecalc()) { 1686 if (change >= Inherit || needsStyleRecalc()) {
1687 if (hasRareData()) { 1687 if (hasRareData()) {
1688 ElementRareData* data = elementRareData(); 1688 ElementRareData* data = elementRareData();
1689 data->clearComputedStyle(); 1689 data->clearComputedStyle();
1690 1690
1691 if (change >= Inherit) { 1691 if (change >= Inherit) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 1727
1728 if (hasCustomStyleCallbacks()) 1728 if (hasCustomStyleCallbacks())
1729 didRecalcStyle(change); 1729 didRecalcStyle(change);
1730 1730
1731 if (change == Reattach) 1731 if (change == Reattach)
1732 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); 1732 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
1733 } 1733 }
1734 1734
1735 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) 1735 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change)
1736 { 1736 {
1737 ASSERT(document().inStyleRecalc()); 1737 DCHECK(document().inStyleRecalc());
1738 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); 1738 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
1739 ASSERT(change >= Inherit || needsStyleRecalc()); 1739 DCHECK(change >= Inherit || needsStyleRecalc());
1740 ASSERT(parentComputedStyle()); 1740 DCHECK(parentComputedStyle());
1741 1741
1742 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); 1742 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle();
1743 RefPtr<ComputedStyle> newStyle = styleForLayoutObject(); 1743 RefPtr<ComputedStyle> newStyle = styleForLayoutObject();
1744 ASSERT(newStyle); 1744 DCHECK(newStyle);
1745 1745
1746 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle .get(), newStyle.get()); 1746 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle .get(), newStyle.get());
1747 if (localChange == NoChange) { 1747 if (localChange == NoChange) {
1748 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); 1748 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1);
1749 } else { 1749 } else {
1750 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1 ); 1750 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1 );
1751 } 1751 }
1752 1752
1753 if (localChange == Reattach) { 1753 if (localChange == Reattach) {
1754 AttachContext reattachContext; 1754 AttachContext reattachContext;
1755 reattachContext.resolvedStyle = newStyle.get(); 1755 reattachContext.resolvedStyle = newStyle.get();
1756 bool layoutObjectWillChange = needsAttach() || layoutObject(); 1756 bool layoutObjectWillChange = needsAttach() || layoutObject();
1757 reattach(reattachContext); 1757 reattach(reattachContext);
1758 if (layoutObjectWillChange || layoutObject()) 1758 if (layoutObjectWillChange || layoutObject())
1759 return Reattach; 1759 return Reattach;
1760 return ReattachNoLayoutObject; 1760 return ReattachNoLayoutObject;
1761 } 1761 }
1762 1762
1763 ASSERT(oldStyle); 1763 DCHECK(oldStyle);
1764 1764
1765 if (localChange != NoChange) 1765 if (localChange != NoChange)
1766 updateCallbackSelectors(oldStyle.get(), newStyle.get()); 1766 updateCallbackSelectors(oldStyle.get(), newStyle.get());
1767 1767
1768 if (LayoutObject* layoutObject = this->layoutObject()) { 1768 if (LayoutObject* layoutObject = this->layoutObject()) {
1769 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) { 1769 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) {
1770 layoutObject->setStyle(newStyle.get()); 1770 layoutObject->setStyle(newStyle.get());
1771 } else { 1771 } else {
1772 // Although no change occurred, we use the new style so that the cou sin style sharing code won't get 1772 // Although no change occurred, we use the new style so that the cou sin style sharing code won't get
1773 // fooled into believing this style is the same. 1773 // fooled into believing this style is the same.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 layoutObject->layer()->setNeedsCompositingInputsUpdate(); 1877 layoutObject->layer()->setNeedsCompositingInputsUpdate();
1878 // Changes in the return value of requiresAcceleratedCompositing change if 1878 // Changes in the return value of requiresAcceleratedCompositing change if
1879 // the PaintLayer is self-painting. 1879 // the PaintLayer is self-painting.
1880 layoutObject->layer()->updateSelfPaintingLayer(); 1880 layoutObject->layer()->updateSelfPaintingLayer();
1881 } 1881 }
1882 1882
1883 void Element::setCustomElementDefinition(RawPtr<CustomElementDefinition> definit ion) 1883 void Element::setCustomElementDefinition(RawPtr<CustomElementDefinition> definit ion)
1884 { 1884 {
1885 if (!hasRareData() && !definition) 1885 if (!hasRareData() && !definition)
1886 return; 1886 return;
1887 ASSERT(!customElementDefinition()); 1887 DCHECK(!customElementDefinition());
1888 ensureElementRareData().setCustomElementDefinition(definition); 1888 ensureElementRareData().setCustomElementDefinition(definition);
1889 } 1889 }
1890 1890
1891 CustomElementDefinition* Element::customElementDefinition() const 1891 CustomElementDefinition* Element::customElementDefinition() const
1892 { 1892 {
1893 if (hasRareData()) 1893 if (hasRareData())
1894 return elementRareData()->customElementDefinition(); 1894 return elementRareData()->customElementDefinition();
1895 return nullptr; 1895 return nullptr;
1896 } 1896 }
1897 1897
(...skipping 10 matching lines...) Expand all
1908 return nullptr; 1908 return nullptr;
1909 } 1909 }
1910 } 1910 }
1911 document().styleEngine().setShadowCascadeOrder(ShadowCascadeOrder::ShadowCas cadeV0); 1911 document().styleEngine().setShadowCascadeOrder(ShadowCascadeOrder::ShadowCas cadeV0);
1912 1912
1913 return createShadowRootInternal(ShadowRootType::V0, exceptionState); 1913 return createShadowRootInternal(ShadowRootType::V0, exceptionState);
1914 } 1914 }
1915 1915
1916 RawPtr<ShadowRoot> Element::attachShadow(const ScriptState* scriptState, const S hadowRootInit& shadowRootInitDict, ExceptionState& exceptionState) 1916 RawPtr<ShadowRoot> Element::attachShadow(const ScriptState* scriptState, const S hadowRootInit& shadowRootInitDict, ExceptionState& exceptionState)
1917 { 1917 {
1918 ASSERT(RuntimeEnabledFeatures::shadowDOMV1Enabled()); 1918 DCHECK(RuntimeEnabledFeatures::shadowDOMV1Enabled());
1919 1919
1920 OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsi ngFeatures::Feature::ElementAttachShadow); 1920 OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsi ngFeatures::Feature::ElementAttachShadow);
1921 1921
1922 const AtomicString& tagName = localName(); 1922 const AtomicString& tagName = localName();
1923 bool tagNameIsSupported = isCustomElement() 1923 bool tagNameIsSupported = isCustomElement()
1924 || tagName == HTMLNames::articleTag 1924 || tagName == HTMLNames::articleTag
1925 || tagName == HTMLNames::asideTag 1925 || tagName == HTMLNames::asideTag
1926 || tagName == HTMLNames::blockquoteTag 1926 || tagName == HTMLNames::blockquoteTag
1927 || tagName == HTMLNames::bodyTag 1927 || tagName == HTMLNames::bodyTag
1928 || tagName == HTMLNames::divTag 1928 || tagName == HTMLNames::divTag
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 RawPtr<ShadowRoot> shadowRoot = createShadowRootInternal(type, exceptionStat e); 1962 RawPtr<ShadowRoot> shadowRoot = createShadowRootInternal(type, exceptionStat e);
1963 1963
1964 if (shadowRootInitDict.hasDelegatesFocus()) 1964 if (shadowRootInitDict.hasDelegatesFocus())
1965 shadowRoot->setDelegatesFocus(shadowRootInitDict.delegatesFocus()); 1965 shadowRoot->setDelegatesFocus(shadowRootInitDict.delegatesFocus());
1966 1966
1967 return shadowRoot.release(); 1967 return shadowRoot.release();
1968 } 1968 }
1969 1969
1970 RawPtr<ShadowRoot> Element::createShadowRootInternal(ShadowRootType type, Except ionState& exceptionState) 1970 RawPtr<ShadowRoot> Element::createShadowRootInternal(ShadowRootType type, Except ionState& exceptionState)
1971 { 1971 {
1972 ASSERT(!closedShadowRoot()); 1972 DCHECK(!closedShadowRoot());
1973 1973
1974 if (alwaysCreateUserAgentShadowRoot()) 1974 if (alwaysCreateUserAgentShadowRoot())
1975 ensureUserAgentShadowRoot(); 1975 ensureUserAgentShadowRoot();
1976 1976
1977 // Some elements make assumptions about what kind of layoutObjects they allo w 1977 // Some elements make assumptions about what kind of layoutObjects they allo w
1978 // as children so we can't allow author shadows on them for now. 1978 // as children so we can't allow author shadows on them for now.
1979 if (!areAuthorShadowsAllowed()) { 1979 if (!areAuthorShadowsAllowed()) {
1980 exceptionState.throwDOMException(HierarchyRequestError, "Author-created shadow roots are disabled for this element."); 1980 exceptionState.throwDOMException(HierarchyRequestError, "Author-created shadow roots are disabled for this element.");
1981 return nullptr; 1981 return nullptr;
1982 } 1982 }
(...skipping 30 matching lines...) Expand all
2013 ShadowRoot* root = shadowRoot(); 2013 ShadowRoot* root = shadowRoot();
2014 if (!root) 2014 if (!root)
2015 return nullptr; 2015 return nullptr;
2016 return root->type() != ShadowRootType::UserAgent ? root : nullptr; 2016 return root->type() != ShadowRootType::UserAgent ? root : nullptr;
2017 } 2017 }
2018 2018
2019 ShadowRoot* Element::userAgentShadowRoot() const 2019 ShadowRoot* Element::userAgentShadowRoot() const
2020 { 2020 {
2021 if (ElementShadow* elementShadow = shadow()) { 2021 if (ElementShadow* elementShadow = shadow()) {
2022 if (ShadowRoot* root = elementShadow->oldestShadowRoot()) { 2022 if (ShadowRoot* root = elementShadow->oldestShadowRoot()) {
2023 ASSERT(root->type() == ShadowRootType::UserAgent); 2023 DCHECK(root->type() == ShadowRootType::UserAgent);
2024 return root; 2024 return root;
2025 } 2025 }
2026 } 2026 }
2027 2027
2028 return nullptr; 2028 return nullptr;
2029 } 2029 }
2030 2030
2031 ShadowRoot& Element::ensureUserAgentShadowRoot() 2031 ShadowRoot& Element::ensureUserAgentShadowRoot()
2032 { 2032 {
2033 if (ShadowRoot* shadowRoot = userAgentShadowRoot()) 2033 if (ShadowRoot* shadowRoot = userAgentShadowRoot())
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 return hasRareData() ? elementRareData()->attrNodeList() : nullptr; 2119 return hasRareData() ? elementRareData()->attrNodeList() : nullptr;
2120 } 2120 }
2121 2121
2122 AttrNodeList& Element::ensureAttrNodeList() 2122 AttrNodeList& Element::ensureAttrNodeList()
2123 { 2123 {
2124 return ensureElementRareData().ensureAttrNodeList(); 2124 return ensureElementRareData().ensureAttrNodeList();
2125 } 2125 }
2126 2126
2127 void Element::removeAttrNodeList() 2127 void Element::removeAttrNodeList()
2128 { 2128 {
2129 ASSERT(attrNodeList()); 2129 DCHECK(attrNodeList());
2130 if (hasRareData()) 2130 if (hasRareData())
2131 elementRareData()->removeAttrNodeList(); 2131 elementRareData()->removeAttrNodeList();
2132 } 2132 }
2133 2133
2134 RawPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionState& exception State) 2134 RawPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionState& exception State)
2135 { 2135 {
2136 RawPtr<Attr> oldAttrNode = attrIfExists(attrNode->getQualifiedName()); 2136 RawPtr<Attr> oldAttrNode = attrIfExists(attrNode->getQualifiedName());
2137 if (oldAttrNode.get() == attrNode) 2137 if (oldAttrNode.get() == attrNode)
2138 return attrNode; // This Attr is already attached to the element. 2138 return attrNode; // This Attr is already attached to the element.
2139 2139
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 return setAttributeNode(attr, exceptionState); 2188 return setAttributeNode(attr, exceptionState);
2189 } 2189 }
2190 2190
2191 RawPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& exceptionS tate) 2191 RawPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& exceptionS tate)
2192 { 2192 {
2193 if (attr->ownerElement() != this) { 2193 if (attr->ownerElement() != this) {
2194 exceptionState.throwDOMException(NotFoundError, "The node provided is ow ned by another element."); 2194 exceptionState.throwDOMException(NotFoundError, "The node provided is ow ned by another element.");
2195 return nullptr; 2195 return nullptr;
2196 } 2196 }
2197 2197
2198 ASSERT(document() == attr->document()); 2198 DCHECK_EQ(document(), attr->document());
2199 2199
2200 synchronizeAttribute(attr->getQualifiedName()); 2200 synchronizeAttribute(attr->getQualifiedName());
2201 2201
2202 size_t index = elementData()->attributes().findIndex(attr->getQualifiedName( )); 2202 size_t index = elementData()->attributes().findIndex(attr->getQualifiedName( ));
2203 if (index == kNotFound) { 2203 if (index == kNotFound) {
2204 exceptionState.throwDOMException(NotFoundError, "The attribute was not f ound on this element."); 2204 exceptionState.throwDOMException(NotFoundError, "The attribute was not f ound on this element.");
2205 return nullptr; 2205 return nullptr;
2206 } 2206 }
2207 2207
2208 RawPtr<Attr> guard(attr); 2208 RawPtr<Attr> guard(attr);
(...skipping 19 matching lines...) Expand all
2228 } else if (name == XMLNames::langAttr) { 2228 } else if (name == XMLNames::langAttr) {
2229 pseudoStateChanged(CSSSelector::PseudoLang); 2229 pseudoStateChanged(CSSSelector::PseudoLang);
2230 } 2230 }
2231 } 2231 }
2232 2232
2233 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) 2233 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa ceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState)
2234 { 2234 {
2235 AtomicString prefix, localName; 2235 AtomicString prefix, localName;
2236 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio nState)) 2236 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio nState))
2237 return false; 2237 return false;
2238 ASSERT(!exceptionState.hadException()); 2238 DCHECK(!exceptionState.hadException());
2239 2239
2240 QualifiedName qName(prefix, localName, namespaceURI); 2240 QualifiedName qName(prefix, localName, namespaceURI);
2241 2241
2242 if (!Document::hasValidNamespaceForAttributes(qName)) { 2242 if (!Document::hasValidNamespaceForAttributes(qName)) {
2243 exceptionState.throwDOMException(NamespaceError, "'" + namespaceURI + "' is an invalid namespace for attributes."); 2243 exceptionState.throwDOMException(NamespaceError, "'" + namespaceURI + "' is an invalid namespace for attributes.");
2244 return false; 2244 return false;
2245 } 2245 }
2246 2246
2247 out = qName; 2247 out = qName;
2248 return true; 2248 return true;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 return (hasEventListeners(EventTypeNames::focus) 2457 return (hasEventListeners(EventTypeNames::focus)
2458 || hasEventListeners(EventTypeNames::blur) 2458 || hasEventListeners(EventTypeNames::blur)
2459 || hasEventListeners(EventTypeNames::focusin) 2459 || hasEventListeners(EventTypeNames::focusin)
2460 || hasEventListeners(EventTypeNames::focusout)); 2460 || hasEventListeners(EventTypeNames::focusout));
2461 } 2461 }
2462 2462
2463 bool Element::isFocusable() const 2463 bool Element::isFocusable() const
2464 { 2464 {
2465 // Style cannot be cleared out for non-active documents, so in that case the 2465 // Style cannot be cleared out for non-active documents, so in that case the
2466 // needsLayoutTreeUpdateForNode check is invalid. 2466 // needsLayoutTreeUpdateForNode check is invalid.
2467 ASSERT(!document().isActive() || !document().needsLayoutTreeUpdateForNode(*t his)); 2467 DCHECK(!document().isActive() || !document().needsLayoutTreeUpdateForNode(*t his));
2468 return inShadowIncludingDocument() && supportsFocus() && !isInert() && layou tObjectIsFocusable(); 2468 return inShadowIncludingDocument() && supportsFocus() && !isInert() && layou tObjectIsFocusable();
2469 } 2469 }
2470 2470
2471 bool Element::isKeyboardFocusable() const 2471 bool Element::isKeyboardFocusable() const
2472 { 2472 {
2473 return isFocusable() && tabIndex() >= 0; 2473 return isFocusable() && tabIndex() >= 0;
2474 } 2474 }
2475 2475
2476 bool Element::isMouseFocusable() const 2476 bool Element::isMouseFocusable() const
2477 { 2477 {
(...skipping 10 matching lines...) Expand all
2488 dispatchEvent(FocusEvent::create(EventTypeNames::focus, false, false, docume nt().domWindow(), 0, oldFocusedElement, sourceCapabilities)); 2488 dispatchEvent(FocusEvent::create(EventTypeNames::focus, false, false, docume nt().domWindow(), 0, oldFocusedElement, sourceCapabilities));
2489 } 2489 }
2490 2490
2491 void Element::dispatchBlurEvent(Element* newFocusedElement, WebFocusType type, I nputDeviceCapabilities* sourceCapabilities) 2491 void Element::dispatchBlurEvent(Element* newFocusedElement, WebFocusType type, I nputDeviceCapabilities* sourceCapabilities)
2492 { 2492 {
2493 dispatchEvent(FocusEvent::create(EventTypeNames::blur, false, false, documen t().domWindow(), 0, newFocusedElement, sourceCapabilities)); 2493 dispatchEvent(FocusEvent::create(EventTypeNames::blur, false, false, documen t().domWindow(), 0, newFocusedElement, sourceCapabilities));
2494 } 2494 }
2495 2495
2496 void Element::dispatchFocusInEvent(const AtomicString& eventType, Element* oldFo cusedElement, WebFocusType, InputDeviceCapabilities* sourceCapabilities) 2496 void Element::dispatchFocusInEvent(const AtomicString& eventType, Element* oldFo cusedElement, WebFocusType, InputDeviceCapabilities* sourceCapabilities)
2497 { 2497 {
2498 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 2498 #if DCHECK_IS_ON()
2499 ASSERT(eventType == EventTypeNames::focusin || eventType == EventTypeNames:: DOMFocusIn); 2499 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden());
2500 #endif
2501 DCHECK(eventType == EventTypeNames::focusin || eventType == EventTypeNames:: DOMFocusIn);
2500 dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().do mWindow(), 0, oldFocusedElement, sourceCapabilities)); 2502 dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().do mWindow(), 0, oldFocusedElement, sourceCapabilities));
2501 } 2503 }
2502 2504
2503 void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newF ocusedElement, InputDeviceCapabilities* sourceCapabilities) 2505 void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newF ocusedElement, InputDeviceCapabilities* sourceCapabilities)
2504 { 2506 {
2505 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 2507 #if DCHECK_IS_ON()
2506 ASSERT(eventType == EventTypeNames::focusout || eventType == EventTypeNames: :DOMFocusOut); 2508 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden());
2509 #endif
2510 DCHECK(eventType == EventTypeNames::focusout || eventType == EventTypeNames: :DOMFocusOut);
2507 dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().do mWindow(), 0, newFocusedElement, sourceCapabilities)); 2511 dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().do mWindow(), 0, newFocusedElement, sourceCapabilities));
2508 } 2512 }
2509 2513
2510 String Element::innerHTML() const 2514 String Element::innerHTML() const
2511 { 2515 {
2512 return createMarkup(this, ChildrenOnly); 2516 return createMarkup(this, ChildrenOnly);
2513 } 2517 }
2514 2518
2515 String Element::outerHTML() const 2519 String Element::outerHTML() const
2516 { 2520 {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 } 2727 }
2724 2728
2725 StringBuilder content; 2729 StringBuilder content;
2726 content.reserveCapacity(totalLength); 2730 content.reserveCapacity(totalLength);
2727 for (Node* child = firstTextNode; child; child = child->nextSibling()) { 2731 for (Node* child = firstTextNode; child; child = child->nextSibling()) {
2728 if (!child->isTextNode()) 2732 if (!child->isTextNode())
2729 continue; 2733 continue;
2730 content.append(toText(child)->data()); 2734 content.append(toText(child)->data());
2731 } 2735 }
2732 2736
2733 ASSERT(content.length() == totalLength); 2737 DCHECK_EQ(content.length(), totalLength);
2734 return content.toString(); 2738 return content.toString();
2735 } 2739 }
2736 2740
2737 const AtomicString& Element::shadowPseudoId() const 2741 const AtomicString& Element::shadowPseudoId() const
2738 { 2742 {
2739 if (ShadowRoot* root = containingShadowRoot()) { 2743 if (ShadowRoot* root = containingShadowRoot()) {
2740 if (root->type() == ShadowRootType::UserAgent) 2744 if (root->type() == ShadowRootType::UserAgent)
2741 return fastGetAttribute(pseudoAttr); 2745 return fastGetAttribute(pseudoAttr);
2742 } 2746 }
2743 return nullAtom; 2747 return nullAtom;
2744 } 2748 }
2745 2749
2746 void Element::setShadowPseudoId(const AtomicString& id) 2750 void Element::setShadowPseudoId(const AtomicString& id)
2747 { 2751 {
2748 ASSERT(CSSSelector::parsePseudoType(id, false) == CSSSelector::PseudoWebKitC ustomElement); 2752 DCHECK_EQ(CSSSelector::parsePseudoType(id, false), CSSSelector::PseudoWebKit CustomElement);
2749 setAttribute(pseudoAttr, id); 2753 setAttribute(pseudoAttr, id);
2750 } 2754 }
2751 2755
2752 bool Element::isInDescendantTreeOf(const Element* shadowHost) const 2756 bool Element::isInDescendantTreeOf(const Element* shadowHost) const
2753 { 2757 {
2754 ASSERT(shadowHost); 2758 DCHECK(shadowHost);
2755 ASSERT(isShadowHost(shadowHost)); 2759 DCHECK(isShadowHost(shadowHost));
2756 2760
2757 const ShadowRoot* shadowRoot = containingShadowRoot(); 2761 const ShadowRoot* shadowRoot = containingShadowRoot();
2758 while (shadowRoot) { 2762 while (shadowRoot) {
2759 const Element* ancestorShadowHost = shadowRoot->shadowHost(); 2763 const Element* ancestorShadowHost = shadowRoot->shadowHost();
2760 if (ancestorShadowHost == shadowHost) 2764 if (ancestorShadowHost == shadowHost)
2761 return true; 2765 return true;
2762 shadowRoot = ancestorShadowHost->containingShadowRoot(); 2766 shadowRoot = ancestorShadowHost->containingShadowRoot();
2763 } 2767 }
2764 return false; 2768 return false;
2765 } 2769 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2798 elementStyle = rareData.ensureComputedStyle(); 2802 elementStyle = rareData.ensureComputedStyle();
2799 } 2803 }
2800 2804
2801 if (!pseudoElementSpecifier) 2805 if (!pseudoElementSpecifier)
2802 return elementStyle; 2806 return elementStyle;
2803 2807
2804 if (ComputedStyle* pseudoElementStyle = elementStyle->getCachedPseudoStyle(p seudoElementSpecifier)) 2808 if (ComputedStyle* pseudoElementStyle = elementStyle->getCachedPseudoStyle(p seudoElementSpecifier))
2805 return pseudoElementStyle; 2809 return pseudoElementStyle;
2806 2810
2807 RefPtr<ComputedStyle> result = document().ensureStyleResolver().pseudoStyleF orElement(this, PseudoStyleRequest(pseudoElementSpecifier, PseudoStyleRequest::F orComputedStyle), elementStyle); 2811 RefPtr<ComputedStyle> result = document().ensureStyleResolver().pseudoStyleF orElement(this, PseudoStyleRequest(pseudoElementSpecifier, PseudoStyleRequest::F orComputedStyle), elementStyle);
2808 ASSERT(result); 2812 DCHECK(result);
2809 return elementStyle->addCachedPseudoStyle(result.release()); 2813 return elementStyle->addCachedPseudoStyle(result.release());
2810 } 2814 }
2811 2815
2812 AtomicString Element::computeInheritedLanguage() const 2816 AtomicString Element::computeInheritedLanguage() const
2813 { 2817 {
2814 const Node* n = this; 2818 const Node* n = this;
2815 AtomicString value; 2819 AtomicString value;
2816 // The language property is inherited, so we iterate over the parents to fin d the first language. 2820 // The language property is inherited, so we iterate over the parents to fin d the first language.
2817 do { 2821 do {
2818 if (n->isElementNode()) { 2822 if (n->isElementNode()) {
(...skipping 22 matching lines...) Expand all
2841 } 2845 }
2842 2846
2843 void Element::cancelFocusAppearanceUpdate() 2847 void Element::cancelFocusAppearanceUpdate()
2844 { 2848 {
2845 if (document().focusedElement() == this) 2849 if (document().focusedElement() == this)
2846 document().cancelFocusAppearanceUpdate(); 2850 document().cancelFocusAppearanceUpdate();
2847 } 2851 }
2848 2852
2849 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) 2853 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
2850 { 2854 {
2851 ASSERT(!needsStyleRecalc()); 2855 DCHECK(!needsStyleRecalc());
2852 PseudoElement* element = pseudoElement(pseudoId); 2856 PseudoElement* element = pseudoElement(pseudoId);
2853 2857
2854 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { 2858 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) {
2855 if (pseudoId == PseudoIdFirstLetter && updateFirstLetter(element)) 2859 if (pseudoId == PseudoIdFirstLetter && updateFirstLetter(element))
2856 return; 2860 return;
2857 2861
2858 // Need to clear the cached style if the PseudoElement wants a recalc so it 2862 // Need to clear the cached style if the PseudoElement wants a recalc so it
2859 // computes a new style. 2863 // computes a new style.
2860 if (element->needsStyleRecalc()) 2864 if (element->needsStyleRecalc())
2861 layoutObject()->mutableStyle()->removeCachedPseudoStyle(pseudoId); 2865 layoutObject()->mutableStyle()->removeCachedPseudoStyle(pseudoId);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2972 // <link> implement URLUtils? 2976 // <link> implement URLUtils?
2973 if (isHTMLAnchorElement(*this) || isHTMLAreaElement(*this) || isHTMLLinkElem ent(*this)) 2977 if (isHTMLAnchorElement(*this) || isHTMLAreaElement(*this) || isHTMLLinkElem ent(*this))
2974 return getURLAttribute(hrefAttr); 2978 return getURLAttribute(hrefAttr);
2975 if (isSVGAElement(*this)) 2979 if (isSVGAElement(*this))
2976 return toSVGAElement(*this).legacyHrefURL(document()); 2980 return toSVGAElement(*this).legacyHrefURL(document());
2977 return KURL(); 2981 return KURL();
2978 } 2982 }
2979 2983
2980 KURL Element::getURLAttribute(const QualifiedName& name) const 2984 KURL Element::getURLAttribute(const QualifiedName& name) const
2981 { 2985 {
2982 #if ENABLE(ASSERT) 2986 #if DCHECK_IS_ON()
2983 if (elementData()) { 2987 if (elementData()) {
2984 if (const Attribute* attribute = attributes().find(name)) 2988 if (const Attribute* attribute = attributes().find(name))
2985 ASSERT(isURLAttribute(*attribute)); 2989 DCHECK(isURLAttribute(*attribute));
2986 } 2990 }
2987 #endif 2991 #endif
2988 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute (name))); 2992 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute (name)));
2989 } 2993 }
2990 2994
2991 KURL Element::getNonEmptyURLAttribute(const QualifiedName& name) const 2995 KURL Element::getNonEmptyURLAttribute(const QualifiedName& name) const
2992 { 2996 {
2993 #if ENABLE(ASSERT) 2997 #if DCHECK_IS_ON()
2994 if (elementData()) { 2998 if (elementData()) {
2995 if (const Attribute* attribute = attributes().find(name)) 2999 if (const Attribute* attribute = attributes().find(name))
2996 ASSERT(isURLAttribute(*attribute)); 3000 DCHECK(isURLAttribute(*attribute));
2997 } 3001 }
2998 #endif 3002 #endif
2999 String value = stripLeadingAndTrailingHTMLSpaces(getAttribute(name)); 3003 String value = stripLeadingAndTrailingHTMLSpaces(getAttribute(name));
3000 if (value.isEmpty()) 3004 if (value.isEmpty())
3001 return KURL(); 3005 return KURL();
3002 return document().completeURL(value); 3006 return document().completeURL(value);
3003 } 3007 }
3004 3008
3005 int Element::getIntegralAttribute(const QualifiedName& attributeName) const 3009 int Element::getIntegralAttribute(const QualifiedName& attributeName) const
3006 { 3010 {
(...skipping 27 matching lines...) Expand all
3034 3038
3035 void Element::setContainsFullScreenElement(bool flag) 3039 void Element::setContainsFullScreenElement(bool flag)
3036 { 3040 {
3037 setElementFlag(ContainsFullScreenElement, flag); 3041 setElementFlag(ContainsFullScreenElement, flag);
3038 document().styleEngine().ensureFullscreenUAStyle(); 3042 document().styleEngine().ensureFullscreenUAStyle();
3039 pseudoStateChanged(CSSSelector::PseudoFullScreenAncestor); 3043 pseudoStateChanged(CSSSelector::PseudoFullScreenAncestor);
3040 } 3044 }
3041 3045
3042 static Element* parentCrossingFrameBoundaries(Element* element) 3046 static Element* parentCrossingFrameBoundaries(Element* element)
3043 { 3047 {
3044 ASSERT(element); 3048 DCHECK(element);
3045 return element->parentElement() ? element->parentElement() : element->docume nt().ownerElement(); 3049 return element->parentElement() ? element->parentElement() : element->docume nt().ownerElement();
3046 } 3050 }
3047 3051
3048 void Element::setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(boo l flag) 3052 void Element::setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(boo l flag)
3049 { 3053 {
3050 for (Element* element = parentCrossingFrameBoundaries(this); element; elemen t = parentCrossingFrameBoundaries(element)) 3054 for (Element* element = parentCrossingFrameBoundaries(this); element; elemen t = parentCrossingFrameBoundaries(element))
3051 element->setContainsFullScreenElement(flag); 3055 element->setContainsFullScreenElement(flag);
3052 } 3056 }
3053 3057
3054 void Element::setIsInTopLayer(bool inTopLayer) 3058 void Element::setIsInTopLayer(bool inTopLayer)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 case SpellcheckAttributeFalse: 3094 case SpellcheckAttributeFalse:
3091 return false; 3095 return false;
3092 case SpellcheckAttributeDefault: 3096 case SpellcheckAttributeDefault:
3093 break; 3097 break;
3094 } 3098 }
3095 } 3099 }
3096 3100
3097 return true; 3101 return true;
3098 } 3102 }
3099 3103
3100 #if ENABLE(ASSERT) 3104 #if DCHECK_IS_ON()
3101 bool Element::fastAttributeLookupAllowed(const QualifiedName& name) const 3105 bool Element::fastAttributeLookupAllowed(const QualifiedName& name) const
3102 { 3106 {
3103 if (name == HTMLNames::styleAttr) 3107 if (name == HTMLNames::styleAttr)
3104 return false; 3108 return false;
3105 3109
3106 if (isSVGElement()) 3110 if (isSVGElement())
3107 return !toSVGElement(this)->isAnimatableAttribute(name); 3111 return !toSVGElement(this)->isAnimatableAttribute(name);
3108 3112
3109 return true; 3113 return true;
3110 } 3114 }
(...skipping 24 matching lines...) Expand all
3135 return; 3139 return;
3136 3140
3137 if (oldId == newId) 3141 if (oldId == newId)
3138 return; 3142 return;
3139 3143
3140 updateId(treeScope(), oldId, newId); 3144 updateId(treeScope(), oldId, newId);
3141 } 3145 }
3142 3146
3143 inline void Element::updateId(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId) 3147 inline void Element::updateId(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId)
3144 { 3148 {
3145 ASSERT(isInTreeScope()); 3149 DCHECK(isInTreeScope());
3146 ASSERT(oldId != newId); 3150 DCHECK_NE(oldId, newId);
3147 3151
3148 if (!oldId.isEmpty()) 3152 if (!oldId.isEmpty())
3149 scope.removeElementById(oldId, this); 3153 scope.removeElementById(oldId, this);
3150 if (!newId.isEmpty()) 3154 if (!newId.isEmpty())
3151 scope.addElementById(newId, this); 3155 scope.addElementById(newId, this);
3152 3156
3153 if (shouldRegisterAsExtraNamedItem()) 3157 if (shouldRegisterAsExtraNamedItem())
3154 updateExtraNamedItemRegistration(oldId, newId); 3158 updateExtraNamedItemRegistration(oldId, newId);
3155 } 3159 }
3156 3160
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 if (!attrNode) { 3307 if (!attrNode) {
3304 attrNode = Attr::create(*this, name); 3308 attrNode = Attr::create(*this, name);
3305 treeScope().adoptIfNeeded(*attrNode); 3309 treeScope().adoptIfNeeded(*attrNode);
3306 ensureAttrNodeList().append(attrNode); 3310 ensureAttrNodeList().append(attrNode);
3307 } 3311 }
3308 return attrNode.release(); 3312 return attrNode.release();
3309 } 3313 }
3310 3314
3311 void Element::detachAttrNodeFromElementWithValue(Attr* attrNode, const AtomicStr ing& value) 3315 void Element::detachAttrNodeFromElementWithValue(Attr* attrNode, const AtomicStr ing& value)
3312 { 3316 {
3313 ASSERT(attrNodeList()); 3317 DCHECK(attrNodeList());
3314 attrNode->detachFromElementWithValue(value); 3318 attrNode->detachFromElementWithValue(value);
3315 3319
3316 AttrNodeList* list = attrNodeList(); 3320 AttrNodeList* list = attrNodeList();
3317 size_t index = list->find(attrNode); 3321 size_t index = list->find(attrNode);
3318 ASSERT(index != kNotFound); 3322 DCHECK_NE(index, kNotFound);
3319 list->remove(index); 3323 list->remove(index);
3320 if (list->isEmpty()) 3324 if (list->isEmpty())
3321 removeAttrNodeList(); 3325 removeAttrNodeList();
3322 } 3326 }
3323 3327
3324 void Element::detachAllAttrNodesFromElement() 3328 void Element::detachAllAttrNodesFromElement()
3325 { 3329 {
3326 AttrNodeList* list = this->attrNodeList(); 3330 AttrNodeList* list = this->attrNodeList();
3327 if (!list) 3331 if (!list)
3328 return; 3332 return;
3329 3333
3330 AttributeCollection attributes = elementData()->attributes(); 3334 AttributeCollection attributes = elementData()->attributes();
3331 for (const Attribute& attr : attributes) { 3335 for (const Attribute& attr : attributes) {
3332 if (RawPtr<Attr> attrNode = attrIfExists(attr.name())) 3336 if (RawPtr<Attr> attrNode = attrIfExists(attr.name()))
3333 attrNode->detachFromElementWithValue(attr.value()); 3337 attrNode->detachFromElementWithValue(attr.value());
3334 } 3338 }
3335 3339
3336 removeAttrNodeList(); 3340 removeAttrNodeList();
3337 } 3341 }
3338 3342
3339 void Element::willRecalcStyle(StyleRecalcChange) 3343 void Element::willRecalcStyle(StyleRecalcChange)
3340 { 3344 {
3341 ASSERT(hasCustomStyleCallbacks()); 3345 DCHECK(hasCustomStyleCallbacks());
3342 } 3346 }
3343 3347
3344 void Element::didRecalcStyle(StyleRecalcChange) 3348 void Element::didRecalcStyle(StyleRecalcChange)
3345 { 3349 {
3346 ASSERT(hasCustomStyleCallbacks()); 3350 DCHECK(hasCustomStyleCallbacks());
3347 } 3351 }
3348 3352
3349 3353
3350 PassRefPtr<ComputedStyle> Element::customStyleForLayoutObject() 3354 PassRefPtr<ComputedStyle> Element::customStyleForLayoutObject()
3351 { 3355 {
3352 ASSERT(hasCustomStyleCallbacks()); 3356 DCHECK(hasCustomStyleCallbacks());
3353 return nullptr; 3357 return nullptr;
3354 } 3358 }
3355 3359
3356 void Element::cloneAttributesFromElement(const Element& other) 3360 void Element::cloneAttributesFromElement(const Element& other)
3357 { 3361 {
3358 if (hasRareData()) 3362 if (hasRareData())
3359 detachAllAttrNodesFromElement(); 3363 detachAllAttrNodesFromElement();
3360 3364
3361 other.synchronizeAllAttributes(); 3365 other.synchronizeAllAttributes();
3362 if (!other.m_elementData) { 3366 if (!other.m_elementData) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3403 { 3407 {
3404 cloneAttributesFromElement(other); 3408 cloneAttributesFromElement(other);
3405 copyNonAttributePropertiesFromElement(other); 3409 copyNonAttributePropertiesFromElement(other);
3406 } 3410 }
3407 3411
3408 void Element::createUniqueElementData() 3412 void Element::createUniqueElementData()
3409 { 3413 {
3410 if (!m_elementData) { 3414 if (!m_elementData) {
3411 m_elementData = UniqueElementData::create(); 3415 m_elementData = UniqueElementData::create();
3412 } else { 3416 } else {
3413 ASSERT(!m_elementData->isUnique()); 3417 DCHECK(!m_elementData->isUnique());
3414 m_elementData = toShareableElementData(m_elementData)->makeUniqueCopy(); 3418 m_elementData = toShareableElementData(m_elementData)->makeUniqueCopy();
3415 } 3419 }
3416 } 3420 }
3417 3421
3418 void Element::synchronizeStyleAttributeInternal() const 3422 void Element::synchronizeStyleAttributeInternal() const
3419 { 3423 {
3420 ASSERT(isStyledElement()); 3424 DCHECK(isStyledElement());
3421 ASSERT(elementData()); 3425 DCHECK(elementData());
3422 ASSERT(elementData()->m_styleAttributeIsDirty); 3426 DCHECK(elementData()->m_styleAttributeIsDirty);
3423 elementData()->m_styleAttributeIsDirty = false; 3427 elementData()->m_styleAttributeIsDirty = false;
3424 const StylePropertySet* inlineStyle = this->inlineStyle(); 3428 const StylePropertySet* inlineStyle = this->inlineStyle();
3425 const_cast<Element*>(this)->setSynchronizedLazyAttribute(styleAttr, 3429 const_cast<Element*>(this)->setSynchronizedLazyAttribute(styleAttr,
3426 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom); 3430 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom);
3427 } 3431 }
3428 3432
3429 CSSStyleDeclaration* Element::style() 3433 CSSStyleDeclaration* Element::style()
3430 { 3434 {
3431 if (!isStyledElement()) 3435 if (!isStyledElement())
3432 return nullptr; 3436 return nullptr;
3433 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this); 3437 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
3434 } 3438 }
3435 3439
3436 MutableStylePropertySet& Element::ensureMutableInlineStyle() 3440 MutableStylePropertySet& Element::ensureMutableInlineStyle()
3437 { 3441 {
3438 ASSERT(isStyledElement()); 3442 DCHECK(isStyledElement());
3439 Member<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle; 3443 Member<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle;
3440 if (!inlineStyle) { 3444 if (!inlineStyle) {
3441 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode; 3445 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode;
3442 inlineStyle = MutableStylePropertySet::create(mode); 3446 inlineStyle = MutableStylePropertySet::create(mode);
3443 } else if (!inlineStyle->isMutable()) { 3447 } else if (!inlineStyle->isMutable()) {
3444 inlineStyle = inlineStyle->mutableCopy(); 3448 inlineStyle = inlineStyle->mutableCopy();
3445 } 3449 }
3446 return *toMutableStylePropertySet(inlineStyle); 3450 return *toMutableStylePropertySet(inlineStyle);
3447 } 3451 }
3448 3452
3449 void Element::clearMutableInlineStyleIfEmpty() 3453 void Element::clearMutableInlineStyleIfEmpty()
3450 { 3454 {
3451 if (ensureMutableInlineStyle().isEmpty()) { 3455 if (ensureMutableInlineStyle().isEmpty()) {
3452 ensureUniqueElementData().m_inlineStyle.clear(); 3456 ensureUniqueElementData().m_inlineStyle.clear();
3453 } 3457 }
3454 } 3458 }
3455 3459
3456 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString ) 3460 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString )
3457 { 3461 {
3458 ASSERT(isStyledElement()); 3462 DCHECK(isStyledElement());
3459 Member<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle; 3463 Member<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle;
3460 3464
3461 // Avoid redundant work if we're using shared attribute data with already pa rsed inline style. 3465 // Avoid redundant work if we're using shared attribute data with already pa rsed inline style.
3462 if (inlineStyle && !elementData()->isUnique()) 3466 if (inlineStyle && !elementData()->isUnique())
3463 return; 3467 return;
3464 3468
3465 // We reconstruct the property set instead of mutating if there is no CSSOM wrapper. 3469 // We reconstruct the property set instead of mutating if there is no CSSOM wrapper.
3466 // This makes wrapperless property sets immutable and so cacheable. 3470 // This makes wrapperless property sets immutable and so cacheable.
3467 if (inlineStyle && !inlineStyle->isMutable()) 3471 if (inlineStyle && !inlineStyle->isMutable())
3468 inlineStyle.clear(); 3472 inlineStyle.clear();
3469 3473
3470 if (!inlineStyle) { 3474 if (!inlineStyle) {
3471 inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, thi s); 3475 inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, thi s);
3472 } else { 3476 } else {
3473 ASSERT(inlineStyle->isMutable()); 3477 DCHECK(inlineStyle->isMutable());
3474 static_cast<MutableStylePropertySet*>(inlineStyle.get())->parseDeclarati onList(newStyleString, document().elementSheet().contents()); 3478 static_cast<MutableStylePropertySet*>(inlineStyle.get())->parseDeclarati onList(newStyleString, document().elementSheet().contents());
3475 } 3479 }
3476 } 3480 }
3477 3481
3478 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut eModificationReason modificationReason) 3482 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut eModificationReason modificationReason)
3479 { 3483 {
3480 ASSERT(isStyledElement()); 3484 DCHECK(isStyledElement());
3481 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); 3485 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst();
3482 if (document().scriptableDocumentParser() && !document().isInDocumentWrite() ) 3486 if (document().scriptableDocumentParser() && !document().isInDocumentWrite() )
3483 startLineNumber = document().scriptableDocumentParser()->lineNumber(); 3487 startLineNumber = document().scriptableDocumentParser()->lineNumber();
3484 3488
3485 if (newStyleString.isNull()) { 3489 if (newStyleString.isNull()) {
3486 ensureUniqueElementData().m_inlineStyle.clear(); 3490 ensureUniqueElementData().m_inlineStyle.clear();
3487 } else if (modificationReason == ModifiedByCloning || ContentSecurityPolicy: :shouldBypassMainWorld(&document()) || document().contentSecurityPolicy()->allow InlineStyle(document().url(), startLineNumber, newStyleString)) { 3491 } else if (modificationReason == ModifiedByCloning || ContentSecurityPolicy: :shouldBypassMainWorld(&document()) || document().contentSecurityPolicy()->allow InlineStyle(document().url(), startLineNumber, newStyleString)) {
3488 setInlineStyleFromString(newStyleString); 3492 setInlineStyleFromString(newStyleString);
3489 } 3493 }
3490 3494
3491 elementData()->m_styleAttributeIsDirty = false; 3495 elementData()->m_styleAttributeIsDirty = false;
3492 3496
3493 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::StyleSheetChange)); 3497 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::StyleSheetChange));
3494 InspectorInstrumentation::didInvalidateStyleAttr(this); 3498 InspectorInstrumentation::didInvalidateStyleAttr(this);
3495 } 3499 }
3496 3500
3497 void Element::inlineStyleChanged() 3501 void Element::inlineStyleChanged()
3498 { 3502 {
3499 ASSERT(isStyledElement()); 3503 DCHECK(isStyledElement());
3500 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::Inline)); 3504 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::Inline));
3501 ASSERT(elementData()); 3505 DCHECK(elementData());
3502 elementData()->m_styleAttributeIsDirty = true; 3506 elementData()->m_styleAttributeIsDirty = true;
3503 InspectorInstrumentation::didInvalidateStyleAttr(this); 3507 InspectorInstrumentation::didInvalidateStyleAttr(this);
3504 } 3508 }
3505 3509
3506 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important) 3510 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important)
3507 { 3511 {
3508 ASSERT(isStyledElement()); 3512 DCHECK(isStyledElement());
3509 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createIden tifierValue(identifier), important); 3513 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createIden tifierValue(identifier), important);
3510 inlineStyleChanged(); 3514 inlineStyleChanged();
3511 return true; 3515 return true;
3512 } 3516 }
3513 3517
3514 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitType unit, bool important) 3518 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitType unit, bool important)
3515 { 3519 {
3516 ASSERT(isStyledElement()); 3520 DCHECK(isStyledElement());
3517 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createValu e(value, unit), important); 3521 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createValu e(value, unit), important);
3518 inlineStyleChanged(); 3522 inlineStyleChanged();
3519 return true; 3523 return true;
3520 } 3524 }
3521 3525
3522 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important) 3526 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important)
3523 { 3527 {
3524 ASSERT(isStyledElement()); 3528 DCHECK(isStyledElement());
3525 bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, imp ortant, document().elementSheet().contents()); 3529 bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, imp ortant, document().elementSheet().contents());
3526 if (changes) 3530 if (changes)
3527 inlineStyleChanged(); 3531 inlineStyleChanged();
3528 return changes; 3532 return changes;
3529 } 3533 }
3530 3534
3531 bool Element::removeInlineStyleProperty(CSSPropertyID propertyID) 3535 bool Element::removeInlineStyleProperty(CSSPropertyID propertyID)
3532 { 3536 {
3533 ASSERT(isStyledElement()); 3537 DCHECK(isStyledElement());
3534 if (!inlineStyle()) 3538 if (!inlineStyle())
3535 return false; 3539 return false;
3536 bool changes = ensureMutableInlineStyle().removeProperty(propertyID); 3540 bool changes = ensureMutableInlineStyle().removeProperty(propertyID);
3537 if (changes) 3541 if (changes)
3538 inlineStyleChanged(); 3542 inlineStyleChanged();
3539 return changes; 3543 return changes;
3540 } 3544 }
3541 3545
3542 void Element::removeAllInlineStyleProperties() 3546 void Element::removeAllInlineStyleProperties()
3543 { 3547 {
3544 ASSERT(isStyledElement()); 3548 DCHECK(isStyledElement());
3545 if (!inlineStyle()) 3549 if (!inlineStyle())
3546 return; 3550 return;
3547 ensureMutableInlineStyle().clear(); 3551 ensureMutableInlineStyle().clear();
3548 inlineStyleChanged(); 3552 inlineStyleChanged();
3549 } 3553 }
3550 3554
3551 void Element::updatePresentationAttributeStyle() 3555 void Element::updatePresentationAttributeStyle()
3552 { 3556 {
3553 synchronizeAllAttributes(); 3557 synchronizeAllAttributes();
3554 // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData. 3558 // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData.
3555 UniqueElementData& elementData = ensureUniqueElementData(); 3559 UniqueElementData& elementData = ensureUniqueElementData();
3556 elementData.m_presentationAttributeStyleIsDirty = false; 3560 elementData.m_presentationAttributeStyleIsDirty = false;
3557 elementData.m_presentationAttributeStyle = computePresentationAttributeStyle (*this); 3561 elementData.m_presentationAttributeStyle = computePresentationAttributeStyle (*this);
3558 } 3562 }
3559 3563
3560 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, CSSValueID identifier) 3564 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, CSSValueID identifier)
3561 { 3565 {
3562 ASSERT(isStyledElement()); 3566 DCHECK(isStyledElement());
3563 style->setProperty(propertyID, cssValuePool().createIdentifierValue(identifi er)); 3567 style->setProperty(propertyID, cssValuePool().createIdentifierValue(identifi er));
3564 } 3568 }
3565 3569
3566 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType unit) 3570 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType unit)
3567 { 3571 {
3568 ASSERT(isStyledElement()); 3572 DCHECK(isStyledElement());
3569 style->setProperty(propertyID, cssValuePool().createValue(value, unit)); 3573 style->setProperty(propertyID, cssValuePool().createValue(value, unit));
3570 } 3574 }
3571 3575
3572 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, const String& value) 3576 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, const String& value)
3573 { 3577 {
3574 ASSERT(isStyledElement()); 3578 DCHECK(isStyledElement());
3575 style->setProperty(propertyID, value, false); 3579 style->setProperty(propertyID, value, false);
3576 } 3580 }
3577 3581
3578 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* style, CSSPropertyID propertyID, RawPtr<CSSValue> value) 3582 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* style, CSSPropertyID propertyID, RawPtr<CSSValue> value)
3579 { 3583 {
3580 ASSERT(isStyledElement()); 3584 DCHECK(isStyledElement());
3581 style->setProperty(propertyID, value); 3585 style->setProperty(propertyID, value);
3582 } 3586 }
3583 3587
3584 bool Element::supportsStyleSharing() const 3588 bool Element::supportsStyleSharing() const
3585 { 3589 {
3586 if (!isStyledElement() || !parentOrShadowHostElement()) 3590 if (!isStyledElement() || !parentOrShadowHostElement())
3587 return false; 3591 return false;
3588 // If the element has inline style it is probably unique. 3592 // If the element has inline style it is probably unique.
3589 if (inlineStyle()) 3593 if (inlineStyle())
3590 return false; 3594 return false;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3674 3678
3675 DEFINE_TRACE(Element) 3679 DEFINE_TRACE(Element)
3676 { 3680 {
3677 if (hasRareData()) 3681 if (hasRareData())
3678 visitor->trace(elementRareData()); 3682 visitor->trace(elementRareData());
3679 visitor->trace(m_elementData); 3683 visitor->trace(m_elementData);
3680 ContainerNode::trace(visitor); 3684 ContainerNode::trace(visitor);
3681 } 3685 }
3682 3686
3683 } // namespace blink 3687 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/ElementData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698