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

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

Issue 2149893003: Rename Node::inShadowIncludingDocument() to Node::isConnected() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Created 4 years, 5 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 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name)); 1187 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name));
1188 } 1188 }
1189 } 1189 }
1190 1190
1191 invalidateNodeListCachesInAncestors(&name, this); 1191 invalidateNodeListCachesInAncestors(&name, this);
1192 1192
1193 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style. 1193 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style.
1194 if (!document().styleResolver()) 1194 if (!document().styleResolver())
1195 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name)); 1195 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name));
1196 1196
1197 if (inShadowIncludingDocument()) { 1197 if (isConnected()) {
1198 if (AXObjectCache* cache = document().existingAXObjectCache()) 1198 if (AXObjectCache* cache = document().existingAXObjectCache())
1199 cache->handleAttributeChanged(name, this); 1199 cache->handleAttributeChanged(name, this);
1200 } 1200 }
1201 } 1201 }
1202 1202
1203 bool Element::hasLegalLinkAttribute(const QualifiedName&) const 1203 bool Element::hasLegalLinkAttribute(const QualifiedName&) const
1204 { 1204 {
1205 return false; 1205 return false;
1206 } 1206 }
1207 1207
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 if (source != destination) 1338 if (source != destination)
1339 attributeVector[destination] = attributeVector[source]; 1339 attributeVector[destination] = attributeVector[source];
1340 1340
1341 ++destination; 1341 ++destination;
1342 } 1342 }
1343 attributeVector.shrink(destination); 1343 attributeVector.shrink(destination);
1344 } 1344 }
1345 1345
1346 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector) 1346 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector)
1347 { 1347 {
1348 DCHECK(!inShadowIncludingDocument()); 1348 DCHECK(!isConnected());
1349 DCHECK(!parentNode()); 1349 DCHECK(!parentNode());
1350 DCHECK(!m_elementData); 1350 DCHECK(!m_elementData);
1351 1351
1352 if (!attributeVector.isEmpty()) { 1352 if (!attributeVector.isEmpty()) {
1353 if (document().elementDataCache()) 1353 if (document().elementDataCache())
1354 m_elementData = document().elementDataCache()->cachedShareableElemen tDataWithAttributes(attributeVector); 1354 m_elementData = document().elementDataCache()->cachedShareableElemen tDataWithAttributes(attributeVector);
1355 else 1355 else
1356 m_elementData = ShareableElementData::createWithAttributes(attribute Vector); 1356 m_elementData = ShareableElementData::createWithAttributes(attribute Vector);
1357 } 1357 }
1358 1358
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 return style.display() != NONE; 1408 return style.display() != NONE;
1409 } 1409 }
1410 1410
1411 LayoutObject* Element::createLayoutObject(const ComputedStyle& style) 1411 LayoutObject* Element::createLayoutObject(const ComputedStyle& style)
1412 { 1412 {
1413 return LayoutObject::createObject(this, style); 1413 return LayoutObject::createObject(this, style);
1414 } 1414 }
1415 1415
1416 Node::InsertionNotificationRequest Element::insertedInto(ContainerNode* insertio nPoint) 1416 Node::InsertionNotificationRequest Element::insertedInto(ContainerNode* insertio nPoint)
1417 { 1417 {
1418 // need to do superclass processing first so inShadowIncludingDocument() is true 1418 // need to do superclass processing first so isConnected() is true
1419 // by the time we reach updateId 1419 // by the time we reach updateId
1420 ContainerNode::insertedInto(insertionPoint); 1420 ContainerNode::insertedInto(insertionPoint);
1421 1421
1422 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement()) 1422 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement())
1423 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); 1423 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
1424 1424
1425 DCHECK(!hasRareData() || !elementRareData()->hasPseudoElements()); 1425 DCHECK(!hasRareData() || !elementRareData()->hasPseudoElements());
1426 1426
1427 if (!insertionPoint->isInTreeScope()) 1427 if (!insertionPoint->isInTreeScope())
1428 return InsertionDone; 1428 return InsertionDone;
1429 1429
1430 if (hasRareData()) { 1430 if (hasRareData()) {
1431 ElementRareData* rareData = elementRareData(); 1431 ElementRareData* rareData = elementRareData();
1432 rareData->clearClassListValueForQuirksMode(); 1432 rareData->clearClassListValueForQuirksMode();
1433 if (rareData->intersectionObserverData()) 1433 if (rareData->intersectionObserverData())
1434 rareData->intersectionObserverData()->activateValidIntersectionObser vers(*this); 1434 rareData->intersectionObserverData()->activateValidIntersectionObser vers(*this);
1435 } 1435 }
1436 1436
1437 if (inShadowIncludingDocument()) { 1437 if (isConnected()) {
1438 if (getCustomElementState() == CustomElementState::Custom) 1438 if (getCustomElementState() == CustomElementState::Custom)
1439 CustomElement::enqueueConnectedCallback(this); 1439 CustomElement::enqueueConnectedCallback(this);
1440 else if (isUpgradedV0CustomElement()) 1440 else if (isUpgradedV0CustomElement())
1441 V0CustomElement::didAttach(this, document()); 1441 V0CustomElement::didAttach(this, document());
1442 else if (getCustomElementState() == CustomElementState::Undefined) 1442 else if (getCustomElementState() == CustomElementState::Undefined)
1443 CustomElement::tryToUpgrade(this); 1443 CustomElement::tryToUpgrade(this);
1444 } 1444 }
1445 1445
1446 TreeScope& scope = insertionPoint->treeScope(); 1446 TreeScope& scope = insertionPoint->treeScope();
1447 if (scope != treeScope()) 1447 if (scope != treeScope())
1448 return InsertionDone; 1448 return InsertionDone;
1449 1449
1450 const AtomicString& idValue = getIdAttribute(); 1450 const AtomicString& idValue = getIdAttribute();
1451 if (!idValue.isNull()) 1451 if (!idValue.isNull())
1452 updateId(scope, nullAtom, idValue); 1452 updateId(scope, nullAtom, idValue);
1453 1453
1454 const AtomicString& nameValue = getNameAttribute(); 1454 const AtomicString& nameValue = getNameAttribute();
1455 if (!nameValue.isNull()) 1455 if (!nameValue.isNull())
1456 updateName(nullAtom, nameValue); 1456 updateName(nullAtom, nameValue);
1457 1457
1458 if (parentElement() && parentElement()->isInCanvasSubtree()) 1458 if (parentElement() && parentElement()->isInCanvasSubtree())
1459 setIsInCanvasSubtree(true); 1459 setIsInCanvasSubtree(true);
1460 1460
1461 return InsertionDone; 1461 return InsertionDone;
1462 } 1462 }
1463 1463
1464 void Element::removedFrom(ContainerNode* insertionPoint) 1464 void Element::removedFrom(ContainerNode* insertionPoint)
1465 { 1465 {
1466 bool wasInDocument = insertionPoint->inShadowIncludingDocument(); 1466 bool wasInDocument = insertionPoint->isConnected();
1467 1467
1468 DCHECK(!hasRareData() || !elementRareData()->hasPseudoElements()); 1468 DCHECK(!hasRareData() || !elementRareData()->hasPseudoElements());
1469 1469
1470 if (Fullscreen::isActiveFullScreenElement(*this)) { 1470 if (Fullscreen::isActiveFullScreenElement(*this)) {
1471 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false); 1471 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
1472 if (insertionPoint->isElementNode()) { 1472 if (insertionPoint->isElementNode()) {
1473 toElement(insertionPoint)->setContainsFullScreenElement(false); 1473 toElement(insertionPoint)->setContainsFullScreenElement(false);
1474 toElement(insertionPoint)->setContainsFullScreenElementOnAncestorsCr ossingFrameBoundaries(false); 1474 toElement(insertionPoint)->setContainsFullScreenElementOnAncestorsCr ossingFrameBoundaries(false);
1475 } 1475 }
1476 } 1476 }
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 { 2382 {
2383 if (!elementData()) 2383 if (!elementData())
2384 return false; 2384 return false;
2385 QualifiedName qName(nullAtom, localName, namespaceURI); 2385 QualifiedName qName(nullAtom, localName, namespaceURI);
2386 synchronizeAttribute(qName); 2386 synchronizeAttribute(qName);
2387 return elementData()->attributes().find(qName); 2387 return elementData()->attributes().find(qName);
2388 } 2388 }
2389 2389
2390 void Element::focus(const FocusParams& params) 2390 void Element::focus(const FocusParams& params)
2391 { 2391 {
2392 if (!inShadowIncludingDocument()) 2392 if (!isConnected())
2393 return; 2393 return;
2394 2394
2395 if (document().focusedElement() == this) 2395 if (document().focusedElement() == this)
2396 return; 2396 return;
2397 2397
2398 if (!document().isActive()) 2398 if (!document().isActive())
2399 return; 2399 return;
2400 2400
2401 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 2401 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
2402 if (!isFocusable()) 2402 if (!isFocusable())
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 || hasEventListeners(EventTypeNames::blur) 2495 || hasEventListeners(EventTypeNames::blur)
2496 || hasEventListeners(EventTypeNames::focusin) 2496 || hasEventListeners(EventTypeNames::focusin)
2497 || hasEventListeners(EventTypeNames::focusout)); 2497 || hasEventListeners(EventTypeNames::focusout));
2498 } 2498 }
2499 2499
2500 bool Element::isFocusable() const 2500 bool Element::isFocusable() const
2501 { 2501 {
2502 // Style cannot be cleared out for non-active documents, so in that case the 2502 // Style cannot be cleared out for non-active documents, so in that case the
2503 // needsLayoutTreeUpdateForNode check is invalid. 2503 // needsLayoutTreeUpdateForNode check is invalid.
2504 DCHECK(!document().isActive() || !document().needsLayoutTreeUpdateForNode(*t his)); 2504 DCHECK(!document().isActive() || !document().needsLayoutTreeUpdateForNode(*t his));
2505 return inShadowIncludingDocument() && supportsFocus() && !isInert() && layou tObjectIsFocusable(); 2505 return isConnected() && supportsFocus() && !isInert() && layoutObjectIsFocus able();
2506 } 2506 }
2507 2507
2508 bool Element::isKeyboardFocusable() const 2508 bool Element::isKeyboardFocusable() const
2509 { 2509 {
2510 return isFocusable() && tabIndex() >= 0; 2510 return isFocusable() && tabIndex() >= 0;
2511 } 2511 }
2512 2512
2513 bool Element::isMouseFocusable() const 2513 bool Element::isMouseFocusable() const
2514 { 2514 {
2515 return isFocusable(); 2515 return isFocusable();
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 if (!fragment) 2687 if (!fragment)
2688 return; 2688 return;
2689 insertAdjacent(where, fragment, exceptionState); 2689 insertAdjacent(where, fragment, exceptionState);
2690 } 2690 }
2691 2691
2692 void Element::setPointerCapture(int pointerId, ExceptionState& exceptionState) 2692 void Element::setPointerCapture(int pointerId, ExceptionState& exceptionState)
2693 { 2693 {
2694 if (document().frame()) { 2694 if (document().frame()) {
2695 if (!document().frame()->eventHandler().isPointerEventActive(pointerId)) 2695 if (!document().frame()->eventHandler().isPointerEventActive(pointerId))
2696 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId "); 2696 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId ");
2697 else if (!inShadowIncludingDocument()) 2697 else if (!isConnected())
2698 exceptionState.throwDOMException(InvalidStateError, "InvalidStateErr or"); 2698 exceptionState.throwDOMException(InvalidStateError, "InvalidStateErr or");
2699 else 2699 else
2700 document().frame()->eventHandler().setPointerCapture(pointerId, this ); 2700 document().frame()->eventHandler().setPointerCapture(pointerId, this );
2701 } 2701 }
2702 } 2702 }
2703 2703
2704 void Element::releasePointerCapture(int pointerId, ExceptionState& exceptionStat e) 2704 void Element::releasePointerCapture(int pointerId, ExceptionState& exceptionStat e)
2705 { 2705 {
2706 if (document().frame()) { 2706 if (document().frame()) {
2707 if (!document().frame()->eventHandler().isPointerEventActive(pointerId)) 2707 if (!document().frame()->eventHandler().isPointerEventActive(pointerId))
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 3163
3164 #ifdef DUMP_NODE_STATISTICS 3164 #ifdef DUMP_NODE_STATISTICS
3165 bool Element::hasNamedNodeMap() const 3165 bool Element::hasNamedNodeMap() const
3166 { 3166 {
3167 return hasRareData() && elementRareData()->attributeMap(); 3167 return hasRareData() && elementRareData()->attributeMap();
3168 } 3168 }
3169 #endif 3169 #endif
3170 3170
3171 inline void Element::updateName(const AtomicString& oldName, const AtomicString& newName) 3171 inline void Element::updateName(const AtomicString& oldName, const AtomicString& newName)
3172 { 3172 {
3173 if (!inShadowIncludingDocument() || isInShadowTree()) 3173 if (!isConnected() || isInShadowTree())
3174 return; 3174 return;
3175 3175
3176 if (oldName == newName) 3176 if (oldName == newName)
3177 return; 3177 return;
3178 3178
3179 if (shouldRegisterAsNamedItem()) 3179 if (shouldRegisterAsNamedItem())
3180 updateNamedItemRegistration(oldName, newName); 3180 updateNamedItemRegistration(oldName, newName);
3181 } 3181 }
3182 3182
3183 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id) 3183 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id)
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
3671 return false; 3671 return false;
3672 if (hasAnimations()) 3672 if (hasAnimations())
3673 return false; 3673 return false;
3674 if (Fullscreen::isActiveFullScreenElement(*this)) 3674 if (Fullscreen::isActiveFullScreenElement(*this))
3675 return false; 3675 return false;
3676 return true; 3676 return true;
3677 } 3677 }
3678 3678
3679 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1) 3679 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1)
3680 { 3680 {
3681 if (!inShadowIncludingDocument()) 3681 if (!isConnected())
3682 return; 3682 return;
3683 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 3683 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
3684 if (!activityLogger) 3684 if (!activityLogger)
3685 return; 3685 return;
3686 Vector<String, 2> argv; 3686 Vector<String, 2> argv;
3687 argv.append(element); 3687 argv.append(element);
3688 argv.append(fastGetAttribute(attr1)); 3688 argv.append(fastGetAttribute(attr1));
3689 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data()); 3689 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data());
3690 } 3690 }
3691 3691
3692 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1, const QualifiedName& attr2) 3692 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1, const QualifiedName& attr2)
3693 { 3693 {
3694 if (!inShadowIncludingDocument()) 3694 if (!isConnected())
3695 return; 3695 return;
3696 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 3696 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
3697 if (!activityLogger) 3697 if (!activityLogger)
3698 return; 3698 return;
3699 Vector<String, 3> argv; 3699 Vector<String, 3> argv;
3700 argv.append(element); 3700 argv.append(element);
3701 argv.append(fastGetAttribute(attr1)); 3701 argv.append(fastGetAttribute(attr1));
3702 argv.append(fastGetAttribute(attr2)); 3702 argv.append(fastGetAttribute(attr2));
3703 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data()); 3703 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data());
3704 } 3704 }
3705 3705
3706 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1, const QualifiedName& attr2, const QualifiedName& attr3 ) 3706 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1, const QualifiedName& attr2, const QualifiedName& attr3 )
3707 { 3707 {
3708 if (!inShadowIncludingDocument()) 3708 if (!isConnected())
3709 return; 3709 return;
3710 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 3710 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
3711 if (!activityLogger) 3711 if (!activityLogger)
3712 return; 3712 return;
3713 Vector<String, 4> argv; 3713 Vector<String, 4> argv;
3714 argv.append(element); 3714 argv.append(element);
3715 argv.append(fastGetAttribute(attr1)); 3715 argv.append(fastGetAttribute(attr1));
3716 argv.append(fastGetAttribute(attr2)); 3716 argv.append(fastGetAttribute(attr2));
3717 argv.append(fastGetAttribute(attr3)); 3717 argv.append(fastGetAttribute(attr3));
3718 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data()); 3718 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data());
3719 } 3719 }
3720 3720
3721 void Element::logUpdateAttributeIfIsolatedWorldAndInDocument(const char element[ ], const QualifiedName& attributeName, const AtomicString& oldValue, const Atomi cString& newValue) 3721 void Element::logUpdateAttributeIfIsolatedWorldAndInDocument(const char element[ ], const QualifiedName& attributeName, const AtomicString& oldValue, const Atomi cString& newValue)
3722 { 3722 {
3723 if (!inShadowIncludingDocument()) 3723 if (!isConnected())
3724 return; 3724 return;
3725 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 3725 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
3726 if (!activityLogger) 3726 if (!activityLogger)
3727 return; 3727 return;
3728 Vector<String, 4> argv; 3728 Vector<String, 4> argv;
3729 argv.append(element); 3729 argv.append(element);
3730 argv.append(attributeName.toString()); 3730 argv.append(attributeName.toString());
3731 argv.append(oldValue); 3731 argv.append(oldValue);
3732 argv.append(newValue); 3732 argv.append(newValue);
3733 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data()); 3733 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data());
3734 } 3734 }
3735 3735
3736 DEFINE_TRACE(Element) 3736 DEFINE_TRACE(Element)
3737 { 3737 {
3738 if (hasRareData()) 3738 if (hasRareData())
3739 visitor->trace(elementRareData()); 3739 visitor->trace(elementRareData());
3740 visitor->trace(m_elementData); 3740 visitor->trace(m_elementData);
3741 ContainerNode::trace(visitor); 3741 ContainerNode::trace(visitor);
3742 } 3742 }
3743 3743
3744 DEFINE_TRACE_WRAPPERS(Element) 3744 DEFINE_TRACE_WRAPPERS(Element)
3745 { 3745 {
3746 if (hasRareData()) { 3746 if (hasRareData()) {
3747 visitor->traceWrappers(elementRareData()); 3747 visitor->traceWrappers(elementRareData());
3748 } 3748 }
3749 ContainerNode::traceWrappers(visitor); 3749 ContainerNode::traceWrappers(visitor);
3750 } 3750 }
3751 3751
3752 } // namespace blink 3752 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/Fullscreen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698