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

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

Issue 1858163002: Rename inDocument() to inShadowIncludingDocument() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name)); 1172 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name));
1173 } 1173 }
1174 } 1174 }
1175 1175
1176 invalidateNodeListCachesInAncestors(&name, this); 1176 invalidateNodeListCachesInAncestors(&name, this);
1177 1177
1178 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style. 1178 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style.
1179 if (!document().styleResolver()) 1179 if (!document().styleResolver())
1180 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name)); 1180 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name));
1181 1181
1182 if (inDocument()) { 1182 if (inShadowIncludingDocument()) {
1183 if (AXObjectCache* cache = document().existingAXObjectCache()) 1183 if (AXObjectCache* cache = document().existingAXObjectCache())
1184 cache->handleAttributeChanged(name, this); 1184 cache->handleAttributeChanged(name, this);
1185 } 1185 }
1186 } 1186 }
1187 1187
1188 bool Element::hasLegalLinkAttribute(const QualifiedName&) const 1188 bool Element::hasLegalLinkAttribute(const QualifiedName&) const
1189 { 1189 {
1190 return false; 1190 return false;
1191 } 1191 }
1192 1192
(...skipping 130 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(!inDocument()); 1333 ASSERT(!inShadowIncludingDocument());
1334 ASSERT(!parentNode()); 1334 ASSERT(!parentNode());
1335 ASSERT(!m_elementData); 1335 ASSERT(!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
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 return style.display() != NONE; 1393 return style.display() != NONE;
1394 } 1394 }
1395 1395
1396 LayoutObject* Element::createLayoutObject(const ComputedStyle& style) 1396 LayoutObject* Element::createLayoutObject(const ComputedStyle& style)
1397 { 1397 {
1398 return LayoutObject::createObject(this, style); 1398 return LayoutObject::createObject(this, style);
1399 } 1399 }
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 inDocument() 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 ASSERT(!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 }
1421 1421
1422 if (isUpgradedCustomElement() && inDocument()) 1422 if (isUpgradedCustomElement() && inShadowIncludingDocument())
1423 CustomElement::didAttach(this, document()); 1423 CustomElement::didAttach(this, document());
1424 1424
1425 TreeScope& scope = insertionPoint->treeScope(); 1425 TreeScope& scope = insertionPoint->treeScope();
1426 if (scope != treeScope()) 1426 if (scope != treeScope())
1427 return InsertionDone; 1427 return InsertionDone;
1428 1428
1429 const AtomicString& idValue = getIdAttribute(); 1429 const AtomicString& idValue = getIdAttribute();
1430 if (!idValue.isNull()) 1430 if (!idValue.isNull())
1431 updateId(scope, nullAtom, idValue); 1431 updateId(scope, nullAtom, idValue);
1432 1432
1433 const AtomicString& nameValue = getNameAttribute(); 1433 const AtomicString& nameValue = getNameAttribute();
1434 if (!nameValue.isNull()) 1434 if (!nameValue.isNull())
1435 updateName(nullAtom, nameValue); 1435 updateName(nullAtom, nameValue);
1436 1436
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->inDocument(); 1445 bool wasInDocument = insertionPoint->inShadowIncludingDocument();
1446 1446
1447 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); 1447 ASSERT(!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 }
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 { 2343 {
2344 if (!elementData()) 2344 if (!elementData())
2345 return false; 2345 return false;
2346 QualifiedName qName(nullAtom, localName, namespaceURI); 2346 QualifiedName qName(nullAtom, localName, namespaceURI);
2347 synchronizeAttribute(qName); 2347 synchronizeAttribute(qName);
2348 return elementData()->attributes().find(qName); 2348 return elementData()->attributes().find(qName);
2349 } 2349 }
2350 2350
2351 void Element::focus(const FocusParams& params) 2351 void Element::focus(const FocusParams& params)
2352 { 2352 {
2353 if (!inDocument()) 2353 if (!inShadowIncludingDocument())
2354 return; 2354 return;
2355 2355
2356 if (document().focusedElement() == this) 2356 if (document().focusedElement() == this)
2357 return; 2357 return;
2358 2358
2359 if (!document().isActive()) 2359 if (!document().isActive())
2360 return; 2360 return;
2361 2361
2362 document().updateLayoutIgnorePendingStylesheetsForNode(this); 2362 document().updateLayoutIgnorePendingStylesheetsForNode(this);
2363 if (!isFocusable()) 2363 if (!isFocusable())
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ASSERT(!document().isActive() || !document().needsLayoutTreeUpdateForNode(*t his));
2468 return inDocument() && supportsFocus() && !isInert() && layoutObjectIsFocusa ble(); 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 {
2478 return isFocusable(); 2478 return isFocusable();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 if (!fragment) 2642 if (!fragment)
2643 return; 2643 return;
2644 insertAdjacent(where, fragment.get(), exceptionState); 2644 insertAdjacent(where, fragment.get(), exceptionState);
2645 } 2645 }
2646 2646
2647 void Element::setPointerCapture(int pointerId, ExceptionState& exceptionState) 2647 void Element::setPointerCapture(int pointerId, ExceptionState& exceptionState)
2648 { 2648 {
2649 if (document().frame()) { 2649 if (document().frame()) {
2650 if (!document().frame()->eventHandler().isPointerEventActive(pointerId)) 2650 if (!document().frame()->eventHandler().isPointerEventActive(pointerId))
2651 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId "); 2651 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId ");
2652 else if (!inDocument()) 2652 else if (!inShadowIncludingDocument())
2653 exceptionState.throwDOMException(InvalidStateError, "InvalidStateErr or"); 2653 exceptionState.throwDOMException(InvalidStateError, "InvalidStateErr or");
2654 // TODO(crbug.com/579553): This next "else if" is a hack to notify JS th at we don't (yet) support 2654 // TODO(crbug.com/579553): This next "else if" is a hack to notify JS th at we don't (yet) support
2655 // explicit set/release of touch pointers (which are implicitly captured for performance reasons). 2655 // explicit set/release of touch pointers (which are implicitly captured for performance reasons).
2656 else if (document().frame()->eventHandler().getPointerEventType(pointerI d) == WebPointerProperties::PointerType::Touch) 2656 else if (document().frame()->eventHandler().getPointerEventType(pointerI d) == WebPointerProperties::PointerType::Touch)
2657 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId "); 2657 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId ");
2658 else 2658 else
2659 document().frame()->eventHandler().setPointerCapture(pointerId, this ); 2659 document().frame()->eventHandler().setPointerCapture(pointerId, this );
2660 } 2660 }
2661 } 2661 }
2662 2662
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
3113 3113
3114 #ifdef DUMP_NODE_STATISTICS 3114 #ifdef DUMP_NODE_STATISTICS
3115 bool Element::hasNamedNodeMap() const 3115 bool Element::hasNamedNodeMap() const
3116 { 3116 {
3117 return hasRareData() && elementRareData()->attributeMap(); 3117 return hasRareData() && elementRareData()->attributeMap();
3118 } 3118 }
3119 #endif 3119 #endif
3120 3120
3121 inline void Element::updateName(const AtomicString& oldName, const AtomicString& newName) 3121 inline void Element::updateName(const AtomicString& oldName, const AtomicString& newName)
3122 { 3122 {
3123 if (!inDocument() || isInShadowTree()) 3123 if (!inShadowIncludingDocument() || isInShadowTree())
3124 return; 3124 return;
3125 3125
3126 if (oldName == newName) 3126 if (oldName == newName)
3127 return; 3127 return;
3128 3128
3129 if (shouldRegisterAsNamedItem()) 3129 if (shouldRegisterAsNamedItem())
3130 updateNamedItemRegistration(oldName, newName); 3130 updateNamedItemRegistration(oldName, newName);
3131 } 3131 }
3132 3132
3133 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id) 3133 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id)
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
3611 return false; 3611 return false;
3612 if (hasAnimations()) 3612 if (hasAnimations())
3613 return false; 3613 return false;
3614 if (Fullscreen::isActiveFullScreenElement(*this)) 3614 if (Fullscreen::isActiveFullScreenElement(*this))
3615 return false; 3615 return false;
3616 return true; 3616 return true;
3617 } 3617 }
3618 3618
3619 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1) 3619 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1)
3620 { 3620 {
3621 if (!inDocument()) 3621 if (!inShadowIncludingDocument())
3622 return; 3622 return;
3623 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 3623 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
3624 if (!activityLogger) 3624 if (!activityLogger)
3625 return; 3625 return;
3626 Vector<String, 2> argv; 3626 Vector<String, 2> argv;
3627 argv.append(element); 3627 argv.append(element);
3628 argv.append(fastGetAttribute(attr1)); 3628 argv.append(fastGetAttribute(attr1));
3629 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data()); 3629 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data());
3630 } 3630 }
3631 3631
3632 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1, const QualifiedName& attr2) 3632 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1, const QualifiedName& attr2)
3633 { 3633 {
3634 if (!inDocument()) 3634 if (!inShadowIncludingDocument())
3635 return; 3635 return;
3636 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 3636 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
3637 if (!activityLogger) 3637 if (!activityLogger)
3638 return; 3638 return;
3639 Vector<String, 3> argv; 3639 Vector<String, 3> argv;
3640 argv.append(element); 3640 argv.append(element);
3641 argv.append(fastGetAttribute(attr1)); 3641 argv.append(fastGetAttribute(attr1));
3642 argv.append(fastGetAttribute(attr2)); 3642 argv.append(fastGetAttribute(attr2));
3643 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data()); 3643 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data());
3644 } 3644 }
3645 3645
3646 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1, const QualifiedName& attr2, const QualifiedName& attr3 ) 3646 void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], co nst QualifiedName& attr1, const QualifiedName& attr2, const QualifiedName& attr3 )
3647 { 3647 {
3648 if (!inDocument()) 3648 if (!inShadowIncludingDocument())
3649 return; 3649 return;
3650 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 3650 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
3651 if (!activityLogger) 3651 if (!activityLogger)
3652 return; 3652 return;
3653 Vector<String, 4> argv; 3653 Vector<String, 4> argv;
3654 argv.append(element); 3654 argv.append(element);
3655 argv.append(fastGetAttribute(attr1)); 3655 argv.append(fastGetAttribute(attr1));
3656 argv.append(fastGetAttribute(attr2)); 3656 argv.append(fastGetAttribute(attr2));
3657 argv.append(fastGetAttribute(attr3)); 3657 argv.append(fastGetAttribute(attr3));
3658 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data()); 3658 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data());
3659 } 3659 }
3660 3660
3661 void Element::logUpdateAttributeIfIsolatedWorldAndInDocument(const char element[ ], const QualifiedName& attributeName, const AtomicString& oldValue, const Atomi cString& newValue) 3661 void Element::logUpdateAttributeIfIsolatedWorldAndInDocument(const char element[ ], const QualifiedName& attributeName, const AtomicString& oldValue, const Atomi cString& newValue)
3662 { 3662 {
3663 if (!inDocument()) 3663 if (!inShadowIncludingDocument())
3664 return; 3664 return;
3665 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld(); 3665 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo ggerIfIsolatedWorld();
3666 if (!activityLogger) 3666 if (!activityLogger)
3667 return; 3667 return;
3668 Vector<String, 4> argv; 3668 Vector<String, 4> argv;
3669 argv.append(element); 3669 argv.append(element);
3670 argv.append(attributeName.toString()); 3670 argv.append(attributeName.toString());
3671 argv.append(oldValue); 3671 argv.append(oldValue);
3672 argv.append(newValue); 3672 argv.append(newValue);
3673 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data()); 3673 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data());
3674 } 3674 }
3675 3675
3676 DEFINE_TRACE(Element) 3676 DEFINE_TRACE(Element)
3677 { 3677 {
3678 if (hasRareData()) 3678 if (hasRareData())
3679 visitor->trace(elementRareData()); 3679 visitor->trace(elementRareData());
3680 visitor->trace(m_elementData); 3680 visitor->trace(m_elementData);
3681 ContainerNode::trace(visitor); 3681 ContainerNode::trace(visitor);
3682 } 3682 }
3683 3683
3684 } // namespace blink 3684 } // 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