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

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: renamed Created 4 years, 6 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 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 detachAttrNodeAtIndex(attr, index); 2216 detachAttrNodeAtIndex(attr, index);
2217 return attr; 2217 return attr;
2218 } 2218 }
2219 2219
2220 void Element::parseAttribute(const QualifiedName& name, const AtomicString&, con st AtomicString& value) 2220 void Element::parseAttribute(const QualifiedName& name, const AtomicString&, con st AtomicString& value)
2221 { 2221 {
2222 if (name == tabindexAttr) { 2222 if (name == tabindexAttr) {
2223 int tabindex = 0; 2223 int tabindex = 0;
2224 if (value.isEmpty()) { 2224 if (value.isEmpty()) {
2225 clearTabIndexExplicitlyIfNeeded(); 2225 clearTabIndexExplicitlyIfNeeded();
2226 if (treeScope().adjustedFocusedElement() == this) { 2226 if (adjustedFocusedElementInTreeScope() == this) {
2227 // We might want to call blur(), but it's dangerous to dispatch 2227 // We might want to call blur(), but it's dangerous to dispatch
2228 // events here. 2228 // events here.
2229 document().setNeedsFocusedElementCheck(); 2229 document().setNeedsFocusedElementCheck();
2230 } 2230 }
2231 } else if (parseHTMLInteger(value, tabindex)) { 2231 } else if (parseHTMLInteger(value, tabindex)) {
2232 // Clamp tabindex to the range of 'short' to match Firefox's behavio r. 2232 // Clamp tabindex to the range of 'short' to match Firefox's behavio r.
2233 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short >::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max() )))); 2233 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short >::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max() ))));
2234 } 2234 }
2235 } else if (name == XMLNames::langAttr) { 2235 } else if (name == XMLNames::langAttr) {
2236 pseudoStateChanged(CSSSelector::PseudoLang); 2236 pseudoStateChanged(CSSSelector::PseudoLang);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); 2414 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus);
2415 frame->selection().revealSelection(); 2415 frame->selection().revealSelection();
2416 } else if (layoutObject() && !layoutObject()->isLayoutPart()) { 2416 } else if (layoutObject() && !layoutObject()->isLayoutPart()) {
2417 layoutObject()->scrollRectToVisible(boundingBox()); 2417 layoutObject()->scrollRectToVisible(boundingBox());
2418 } 2418 }
2419 } 2419 }
2420 2420
2421 void Element::blur() 2421 void Element::blur()
2422 { 2422 {
2423 cancelFocusAppearanceUpdate(); 2423 cancelFocusAppearanceUpdate();
2424 if (treeScope().adjustedFocusedElement() == this) { 2424 if (adjustedFocusedElementInTreeScope() == this) {
2425 Document& doc = document(); 2425 Document& doc = document();
2426 if (doc.page()) 2426 if (doc.page())
2427 doc.page()->focusController().setFocusedElement(0, doc.frame()); 2427 doc.page()->focusController().setFocusedElement(0, doc.frame());
2428 else 2428 else
2429 doc.clearFocusedElement(); 2429 doc.clearFocusedElement();
2430 } 2430 }
2431 } 2431 }
2432 2432
2433 bool Element::supportsFocus() const 2433 bool Element::supportsFocus() const
2434 { 2434 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 bool Element::isMouseFocusable() const 2481 bool Element::isMouseFocusable() const
2482 { 2482 {
2483 return isFocusable(); 2483 return isFocusable();
2484 } 2484 }
2485 2485
2486 bool Element::isFocusedElementInDocument() const 2486 bool Element::isFocusedElementInDocument() const
2487 { 2487 {
2488 return this == document().focusedElement(); 2488 return this == document().focusedElement();
2489 } 2489 }
2490 2490
2491 Element* Element::adjustedFocusedElementInTreeScope() const
2492 {
2493 return isInTreeScope() ? containingTreeScope().adjustedFocusedElement() : nu llptr;
2494 }
2495
2491 void Element::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type, InputDeviceCapabilities* sourceCapabilities) 2496 void Element::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type, InputDeviceCapabilities* sourceCapabilities)
2492 { 2497 {
2493 dispatchEvent(FocusEvent::create(EventTypeNames::focus, false, false, docume nt().domWindow(), 0, oldFocusedElement, sourceCapabilities)); 2498 dispatchEvent(FocusEvent::create(EventTypeNames::focus, false, false, docume nt().domWindow(), 0, oldFocusedElement, sourceCapabilities));
2494 } 2499 }
2495 2500
2496 void Element::dispatchBlurEvent(Element* newFocusedElement, WebFocusType type, I nputDeviceCapabilities* sourceCapabilities) 2501 void Element::dispatchBlurEvent(Element* newFocusedElement, WebFocusType type, I nputDeviceCapabilities* sourceCapabilities)
2497 { 2502 {
2498 dispatchEvent(FocusEvent::create(EventTypeNames::blur, false, false, documen t().domWindow(), 0, newFocusedElement, sourceCapabilities)); 2503 dispatchEvent(FocusEvent::create(EventTypeNames::blur, false, false, documen t().domWindow(), 0, newFocusedElement, sourceCapabilities));
2499 } 2504 }
2500 2505
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
3144 } 3149 }
3145 3150
3146 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id) 3151 inline void Element::updateId(const AtomicString& oldId, const AtomicString& new Id)
3147 { 3152 {
3148 if (!isInTreeScope()) 3153 if (!isInTreeScope())
3149 return; 3154 return;
3150 3155
3151 if (oldId == newId) 3156 if (oldId == newId)
3152 return; 3157 return;
3153 3158
3154 updateId(treeScope(), oldId, newId); 3159 updateId(containingTreeScope(), oldId, newId);
3155 } 3160 }
3156 3161
3157 inline void Element::updateId(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId) 3162 inline void Element::updateId(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId)
3158 { 3163 {
3159 DCHECK(isInTreeScope()); 3164 DCHECK(isInTreeScope());
3160 DCHECK_NE(oldId, newId); 3165 DCHECK_NE(oldId, newId);
3161 3166
3162 if (!oldId.isEmpty()) 3167 if (!oldId.isEmpty())
3163 scope.removeElementById(oldId, this); 3168 scope.removeElementById(oldId, this);
3164 if (!newId.isEmpty()) 3169 if (!newId.isEmpty())
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 3709
3705 DEFINE_TRACE_WRAPPERS(Element) 3710 DEFINE_TRACE_WRAPPERS(Element)
3706 { 3711 {
3707 if (hasRareData()) { 3712 if (hasRareData()) {
3708 visitor->traceWrappers(elementRareData()); 3713 visitor->traceWrappers(elementRareData());
3709 } 3714 }
3710 ContainerNode::traceWrappers(visitor); 3715 ContainerNode::traceWrappers(visitor);
3711 } 3716 }
3712 3717
3713 } // namespace blink 3718 } // 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