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

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

Issue 1883083002: Introduce Node::containingTreeScope(), which asserts that the node's root is a tree scope (Closed) 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 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 detachAttrNodeAtIndex(attr, index); 2202 detachAttrNodeAtIndex(attr, index);
2203 return attr; 2203 return attr;
2204 } 2204 }
2205 2205
2206 void Element::parseAttribute(const QualifiedName& name, const AtomicString&, con st AtomicString& value) 2206 void Element::parseAttribute(const QualifiedName& name, const AtomicString&, con st AtomicString& value)
2207 { 2207 {
2208 if (name == tabindexAttr) { 2208 if (name == tabindexAttr) {
2209 int tabindex = 0; 2209 int tabindex = 0;
2210 if (value.isEmpty()) { 2210 if (value.isEmpty()) {
2211 clearTabIndexExplicitlyIfNeeded(); 2211 clearTabIndexExplicitlyIfNeeded();
2212 if (treeScope().adjustedFocusedElement() == this) { 2212 if (isInTreeScope() && rootTreeScope().adjustedFocusedElement() == t his) {
esprehn 2016/04/27 07:52:23 Why do we need to add the check here? We do adjust
hayato 2016/05/23 06:22:09 Done. Yeah, TreeScope::adjustedFocusedElement() c
2213 // We might want to call blur(), but it's dangerous to dispatch 2213 // We might want to call blur(), but it's dangerous to dispatch
2214 // events here. 2214 // events here.
2215 document().setNeedsFocusedElementCheck(); 2215 document().setNeedsFocusedElementCheck();
2216 } 2216 }
2217 } else if (parseHTMLInteger(value, tabindex)) { 2217 } else if (parseHTMLInteger(value, tabindex)) {
2218 // Clamp tabindex to the range of 'short' to match Firefox's behavio r. 2218 // Clamp tabindex to the range of 'short' to match Firefox's behavio r.
2219 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short >::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max() )))); 2219 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short >::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max() ))));
2220 } 2220 }
2221 } else if (name == XMLNames::langAttr) { 2221 } else if (name == XMLNames::langAttr) {
2222 pseudoStateChanged(CSSSelector::PseudoLang); 2222 pseudoStateChanged(CSSSelector::PseudoLang);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); 2400 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus);
2401 frame->selection().revealSelection(); 2401 frame->selection().revealSelection();
2402 } else if (layoutObject() && !layoutObject()->isLayoutPart()) { 2402 } else if (layoutObject() && !layoutObject()->isLayoutPart()) {
2403 layoutObject()->scrollRectToVisible(boundingBox()); 2403 layoutObject()->scrollRectToVisible(boundingBox());
2404 } 2404 }
2405 } 2405 }
2406 2406
2407 void Element::blur() 2407 void Element::blur()
2408 { 2408 {
2409 cancelFocusAppearanceUpdate(); 2409 cancelFocusAppearanceUpdate();
2410 if (treeScope().adjustedFocusedElement() == this) { 2410 if (isInTreeScope() && rootTreeScope().adjustedFocusedElement() == this) {
2411 Document& doc = document(); 2411 Document& doc = document();
2412 if (doc.page()) 2412 if (doc.page())
2413 doc.page()->focusController().setFocusedElement(0, doc.frame()); 2413 doc.page()->focusController().setFocusedElement(0, doc.frame());
2414 else 2414 else
2415 doc.clearFocusedElement(); 2415 doc.clearFocusedElement();
2416 } 2416 }
2417 } 2417 }
2418 2418
2419 bool Element::supportsFocus() const 2419 bool Element::supportsFocus() const
2420 { 2420 {
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
3122 } 3122 }
3123 3123
3124 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id) 3124 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id)
3125 { 3125 {
3126 if (!isInTreeScope()) 3126 if (!isInTreeScope())
3127 return; 3127 return;
3128 3128
3129 if (oldId == newId) 3129 if (oldId == newId)
3130 return; 3130 return;
3131 3131
3132 updateId(treeScope(), oldId, newId); 3132 updateId(rootTreeScope(), oldId, newId);
3133 } 3133 }
3134 3134
3135 inline void Element::updateId(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId) 3135 inline void Element::updateId(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId)
3136 { 3136 {
3137 DCHECK(isInTreeScope()); 3137 DCHECK(isInTreeScope());
3138 DCHECK_NE(oldId, newId); 3138 DCHECK_NE(oldId, newId);
3139 3139
3140 if (!oldId.isEmpty()) 3140 if (!oldId.isEmpty())
3141 scope.removeElementById(oldId, this); 3141 scope.removeElementById(oldId, this);
3142 if (!newId.isEmpty()) 3142 if (!newId.isEmpty())
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
3674 3674
3675 DEFINE_TRACE(Element) 3675 DEFINE_TRACE(Element)
3676 { 3676 {
3677 if (hasRareData()) 3677 if (hasRareData())
3678 visitor->trace(elementRareData()); 3678 visitor->trace(elementRareData());
3679 visitor->trace(m_elementData); 3679 visitor->trace(m_elementData);
3680 ContainerNode::trace(visitor); 3680 ContainerNode::trace(visitor);
3681 } 3681 }
3682 3682
3683 } // namespace blink 3683 } // 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