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

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

Issue 1885453002: Rename Node::treeScope() to Node::treeScopeOrDocument() Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased 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 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 if (hasRareData()) { 1424 if (hasRareData()) {
1425 ElementRareData* rareData = elementRareData(); 1425 ElementRareData* rareData = elementRareData();
1426 rareData->clearClassListValueForQuirksMode(); 1426 rareData->clearClassListValueForQuirksMode();
1427 if (rareData->intersectionObserverData()) 1427 if (rareData->intersectionObserverData())
1428 rareData->intersectionObserverData()->activateValidIntersectionObser vers(*this); 1428 rareData->intersectionObserverData()->activateValidIntersectionObser vers(*this);
1429 } 1429 }
1430 1430
1431 if (isUpgradedCustomElement() && inShadowIncludingDocument()) 1431 if (isUpgradedCustomElement() && inShadowIncludingDocument())
1432 CustomElement::didAttach(this, document()); 1432 CustomElement::didAttach(this, document());
1433 1433
1434 TreeScope& scope = insertionPoint->treeScope(); 1434 TreeScope& scope = insertionPoint->treeScopeOrDocument();
1435 if (scope != treeScope()) 1435 if (scope != treeScopeOrDocument())
1436 return InsertionDone; 1436 return InsertionDone;
1437 1437
1438 const AtomicString& idValue = getIdAttribute(); 1438 const AtomicString& idValue = getIdAttribute();
1439 if (!idValue.isNull()) 1439 if (!idValue.isNull())
1440 updateId(scope, nullAtom, idValue); 1440 updateId(scope, nullAtom, idValue);
1441 1441
1442 const AtomicString& nameValue = getNameAttribute(); 1442 const AtomicString& nameValue = getNameAttribute();
1443 if (!nameValue.isNull()) 1443 if (!nameValue.isNull())
1444 updateName(nullAtom, nameValue); 1444 updateName(nullAtom, nameValue);
1445 1445
(...skipping 18 matching lines...) Expand all
1464 } 1464 }
1465 1465
1466 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(document())) 1466 if (Fullscreen* fullscreen = Fullscreen::fromIfExists(document()))
1467 fullscreen->elementRemoved(*this); 1467 fullscreen->elementRemoved(*this);
1468 1468
1469 if (document().page()) 1469 if (document().page())
1470 document().page()->pointerLockController().elementRemoved(this); 1470 document().page()->pointerLockController().elementRemoved(this);
1471 1471
1472 setSavedLayerScrollOffset(IntSize()); 1472 setSavedLayerScrollOffset(IntSize());
1473 1473
1474 if (insertionPoint->isInTreeScope() && treeScope() == document()) { 1474 if (insertionPoint->isInTreeScope() && treeScopeOrDocument() == document()) {
1475 const AtomicString& idValue = getIdAttribute(); 1475 const AtomicString& idValue = getIdAttribute();
1476 if (!idValue.isNull()) 1476 if (!idValue.isNull())
1477 updateId(insertionPoint->treeScope(), idValue, nullAtom); 1477 updateId(insertionPoint->treeScopeOrDocument(), idValue, nullAtom);
1478 1478
1479 const AtomicString& nameValue = getNameAttribute(); 1479 const AtomicString& nameValue = getNameAttribute();
1480 if (!nameValue.isNull()) 1480 if (!nameValue.isNull())
1481 updateName(nameValue, nullAtom); 1481 updateName(nameValue, nullAtom);
1482 } 1482 }
1483 1483
1484 ContainerNode::removedFrom(insertionPoint); 1484 ContainerNode::removedFrom(insertionPoint);
1485 if (wasInDocument) { 1485 if (wasInDocument) {
1486 if (this == document().cssTarget()) 1486 if (this == document().cssTarget())
1487 document().setCSSTarget(nullptr); 1487 document().setCSSTarget(nullptr);
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 // Attribute's for the replaced Attr is compatible with 2179 // Attribute's for the replaced Attr is compatible with
2180 // all but Gecko (and, arguably, the DOM Level1 spec text.) 2180 // all but Gecko (and, arguably, the DOM Level1 spec text.)
2181 // Consider switching. 2181 // Consider switching.
2182 oldAttrNode = Attr::create(document(), attrNode->getQualifiedName(), attr.value()); 2182 oldAttrNode = Attr::create(document(), attrNode->getQualifiedName(), attr.value());
2183 } 2183 }
2184 } 2184 }
2185 2185
2186 setAttributeInternal(index, attrNode->getQualifiedName(), attrNode->value(), NotInSynchronizationOfLazyAttribute); 2186 setAttributeInternal(index, attrNode->getQualifiedName(), attrNode->value(), NotInSynchronizationOfLazyAttribute);
2187 2187
2188 attrNode->attachToElement(this, localName); 2188 attrNode->attachToElement(this, localName);
2189 treeScope().adoptIfNeeded(*attrNode); 2189 treeScopeOrDocument().adoptIfNeeded(*attrNode);
2190 ensureAttrNodeList().append(attrNode); 2190 ensureAttrNodeList().append(attrNode);
2191 2191
2192 return oldAttrNode; 2192 return oldAttrNode;
2193 } 2193 }
2194 2194
2195 Attr* Element::setAttributeNodeNS(Attr* attr, ExceptionState& exceptionState) 2195 Attr* Element::setAttributeNodeNS(Attr* attr, ExceptionState& exceptionState)
2196 { 2196 {
2197 return setAttributeNode(attr, exceptionState); 2197 return setAttributeNode(attr, exceptionState);
2198 } 2198 }
2199 2199
(...skipping 17 matching lines...) Expand all
2217 detachAttrNodeAtIndex(attr, index); 2217 detachAttrNodeAtIndex(attr, index);
2218 return attr; 2218 return attr;
2219 } 2219 }
2220 2220
2221 void Element::parseAttribute(const QualifiedName& name, const AtomicString&, con st AtomicString& value) 2221 void Element::parseAttribute(const QualifiedName& name, const AtomicString&, con st AtomicString& value)
2222 { 2222 {
2223 if (name == tabindexAttr) { 2223 if (name == tabindexAttr) {
2224 int tabindex = 0; 2224 int tabindex = 0;
2225 if (value.isEmpty()) { 2225 if (value.isEmpty()) {
2226 clearTabIndexExplicitlyIfNeeded(); 2226 clearTabIndexExplicitlyIfNeeded();
2227 if (treeScope().adjustedFocusedElement() == this) { 2227 if (treeScopeOrDocument().adjustedFocusedElement() == this) {
2228 // We might want to call blur(), but it's dangerous to dispatch 2228 // We might want to call blur(), but it's dangerous to dispatch
2229 // events here. 2229 // events here.
2230 document().setNeedsFocusedElementCheck(); 2230 document().setNeedsFocusedElementCheck();
2231 } 2231 }
2232 } else if (parseHTMLInteger(value, tabindex)) { 2232 } else if (parseHTMLInteger(value, tabindex)) {
2233 // Clamp tabindex to the range of 'short' to match Firefox's behavio r. 2233 // Clamp tabindex to the range of 'short' to match Firefox's behavio r.
2234 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short >::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max() )))); 2234 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short >::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max() ))));
2235 } 2235 }
2236 } else if (name == XMLNames::langAttr) { 2236 } else if (name == XMLNames::langAttr) {
2237 pseudoStateChanged(CSSSelector::PseudoLang); 2237 pseudoStateChanged(CSSSelector::PseudoLang);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); 2415 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus);
2416 frame->selection().revealSelection(); 2416 frame->selection().revealSelection();
2417 } else if (layoutObject() && !layoutObject()->isLayoutPart()) { 2417 } else if (layoutObject() && !layoutObject()->isLayoutPart()) {
2418 layoutObject()->scrollRectToVisible(boundingBox()); 2418 layoutObject()->scrollRectToVisible(boundingBox());
2419 } 2419 }
2420 } 2420 }
2421 2421
2422 void Element::blur() 2422 void Element::blur()
2423 { 2423 {
2424 cancelFocusAppearanceUpdate(); 2424 cancelFocusAppearanceUpdate();
2425 if (treeScope().adjustedFocusedElement() == this) { 2425 if (treeScopeOrDocument().adjustedFocusedElement() == this) {
2426 Document& doc = document(); 2426 Document& doc = document();
2427 if (doc.page()) 2427 if (doc.page())
2428 doc.page()->focusController().setFocusedElement(0, doc.frame()); 2428 doc.page()->focusController().setFocusedElement(0, doc.frame());
2429 else 2429 else
2430 doc.clearFocusedElement(); 2430 doc.clearFocusedElement();
2431 } 2431 }
2432 } 2432 }
2433 2433
2434 bool Element::supportsFocus() const 2434 bool Element::supportsFocus() const
2435 { 2435 {
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
3137 } 3137 }
3138 3138
3139 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id) 3139 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id)
3140 { 3140 {
3141 if (!isInTreeScope()) 3141 if (!isInTreeScope())
3142 return; 3142 return;
3143 3143
3144 if (oldId == newId) 3144 if (oldId == newId)
3145 return; 3145 return;
3146 3146
3147 updateId(treeScope(), oldId, newId); 3147 updateId(treeScopeOrDocument(), oldId, newId);
3148 } 3148 }
3149 3149
3150 inline void Element::updateId(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId) 3150 inline void Element::updateId(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId)
3151 { 3151 {
3152 DCHECK(isInTreeScope()); 3152 DCHECK(isInTreeScope());
3153 DCHECK_NE(oldId, newId); 3153 DCHECK_NE(oldId, newId);
3154 3154
3155 if (!oldId.isEmpty()) 3155 if (!oldId.isEmpty())
3156 scope.removeElementById(oldId, this); 3156 scope.removeElementById(oldId, this);
3157 if (!newId.isEmpty()) 3157 if (!newId.isEmpty())
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
3302 } 3302 }
3303 } 3303 }
3304 return nullptr; 3304 return nullptr;
3305 } 3305 }
3306 3306
3307 Attr* Element::ensureAttr(const QualifiedName& name) 3307 Attr* Element::ensureAttr(const QualifiedName& name)
3308 { 3308 {
3309 Attr* attrNode = attrIfExists(name); 3309 Attr* attrNode = attrIfExists(name);
3310 if (!attrNode) { 3310 if (!attrNode) {
3311 attrNode = Attr::create(*this, name); 3311 attrNode = Attr::create(*this, name);
3312 treeScope().adoptIfNeeded(*attrNode); 3312 treeScopeOrDocument().adoptIfNeeded(*attrNode);
3313 ensureAttrNodeList().append(attrNode); 3313 ensureAttrNodeList().append(attrNode);
3314 } 3314 }
3315 return attrNode; 3315 return attrNode;
3316 } 3316 }
3317 3317
3318 void Element::detachAttrNodeFromElementWithValue(Attr* attrNode, const AtomicStr ing& value) 3318 void Element::detachAttrNodeFromElementWithValue(Attr* attrNode, const AtomicStr ing& value)
3319 { 3319 {
3320 DCHECK(attrNodeList()); 3320 DCHECK(attrNodeList());
3321 attrNode->detachFromElementWithValue(value); 3321 attrNode->detachFromElementWithValue(value);
3322 3322
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
3689 3689
3690 DEFINE_TRACE(Element) 3690 DEFINE_TRACE(Element)
3691 { 3691 {
3692 if (hasRareData()) 3692 if (hasRareData())
3693 visitor->trace(elementRareData()); 3693 visitor->trace(elementRareData());
3694 visitor->trace(m_elementData); 3694 visitor->trace(m_elementData);
3695 ContainerNode::trace(visitor); 3695 ContainerNode::trace(visitor);
3696 } 3696 }
3697 3697
3698 } // namespace blink 3698 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/LiveNodeListBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698