Changeset 150733 in webkit
- Timestamp:
- May 26, 2013 7:07:54 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150731 r150733 1 2013-05-26 Andreas Kling <akling@apple.com> 2 3 Turn TreeScope::focusedNode() into focusedElement(). 4 <http://webkit.org/b/116802> 5 6 Reviewed by Darin Adler. 7 8 For the hundredth time, only Elements can be focused! 9 10 This change mostly reverts r121079 since that made things unnecessarily complicated 11 just to tweak the behavior of ShadowRoot.activeElement, an API that we don't expose. 12 Finding a TreeScope's focused element now does a simple walk up the parent chain instead 13 of running the full Shadow DOM re-targeting algorithm. 14 15 (WebCore::TreeScope::focusedElement): 16 17 Simplify and return Element* instead of Node*. 18 19 * dom/TreeScope.h: 20 * dom/TreeScope.cpp: 21 (WebCore::focusedFrameOwnerElement): 22 23 Make this return Element* as the name already suggested. 24 25 * dom/Document.cpp: 26 (WebCore::Document::removeFocusedNodeOfSubtree): 27 * dom/Element.cpp: 28 (WebCore::Element::blur): 29 * dom/ShadowRoot.h: 30 (WebCore::ShadowRoot::activeElement): 31 * html/HTMLDocument.cpp: 32 (WebCore::HTMLDocument::activeElement): 33 34 Simplified call sites that were paranoid about getting a non-Element focused node. 35 1 36 2013-05-26 Dean Jackson <dino@apple.com> 2 37 -
trunk/Source/WebCore/dom/Document.cpp
r150722 r150733 3270 3270 return; 3271 3271 3272 Node* focusedNode = node->treeScope()->focusedNode();3273 if (!focused Node)3272 Element* focusedElement = node->treeScope()->focusedElement(); 3273 if (!focusedElement) 3274 3274 return; 3275 3275 3276 3276 bool nodeInSubtree = false; 3277 3277 if (amongChildrenOnly) 3278 nodeInSubtree = focused Node->isDescendantOf(node);3278 nodeInSubtree = focusedElement->isDescendantOf(node); 3279 3279 else 3280 nodeInSubtree = (focused Node == node) || focusedNode->isDescendantOf(node);3280 nodeInSubtree = (focusedElement == node) || focusedElement->isDescendantOf(node); 3281 3281 3282 3282 if (nodeInSubtree) -
trunk/Source/WebCore/dom/Element.cpp
r150722 r150733 2151 2151 cancelFocusAppearanceUpdate(); 2152 2152 Document* doc = document(); 2153 if (treeScope()->focused Node() == this) {2153 if (treeScope()->focusedElement() == this) { 2154 2154 if (doc->frame()) 2155 2155 doc->frame()->page()->focusController()->setFocusedElement(0, doc->frame()); -
trunk/Source/WebCore/dom/ShadowRoot.h
r150480 r150733 102 102 inline Element* ShadowRoot::activeElement() const 103 103 { 104 if (Node* node = treeScope()->focusedNode()) 105 return node->isElementNode() ? toElement(node) : 0; 106 return 0; 104 return treeScope()->focusedElement(); 107 105 } 108 106 -
trunk/Source/WebCore/dom/TreeScope.cpp
r150187 r150733 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.3 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "Document.h" 34 34 #include "Element.h" 35 #include "EventPathWalker.h"36 35 #include "FocusController.h" 37 36 #include "Frame.h" … … 44 43 #include "HitTestResult.h" 45 44 #include "IdTargetObserverRegistry.h" 46 #include "InsertionPoint.h"47 45 #include "NodeTraversal.h" 48 46 #include "Page.h" … … 383 381 } 384 382 385 static Node* focusedFrameOwnerElement(Frame* focusedFrame, Frame* currentFrame)383 static Element* focusedFrameOwnerElement(Frame* focusedFrame, Frame* currentFrame) 386 384 { 387 385 for (; focusedFrame; focusedFrame = focusedFrame->tree()->parent()) { … … 392 390 } 393 391 394 Node* TreeScope::focusedNode()392 Element* TreeScope::focusedElement() 395 393 { 396 394 Document* document = rootNode()->document(); 397 395 Node* node = document->focusedNode(); 398 if (!node && document->page()) 399 node = focusedFrameOwnerElement(document->page()->focusController()->focusedFrame(), document->frame()); 400 if (!node) 401 return 0; 402 Vector<Node*> targetStack; 403 for (EventPathWalker walker(node); walker.node(); walker.moveToParent()) { 404 Node* node = walker.node(); 405 if (targetStack.isEmpty()) 406 targetStack.append(node); 407 else if (walker.isVisitingInsertionPointInReprojection()) 408 targetStack.append(targetStack.last()); 409 if (node == rootNode()) 410 return targetStack.last(); 411 if (node->isShadowRoot()) { 412 ASSERT(!targetStack.isEmpty()); 413 targetStack.removeLast(); 414 } 415 } 416 return 0; 396 397 ASSERT(!node || node->isElementNode()); 398 Element* element = toElement(node); 399 400 if (!element && document->page()) 401 element = focusedFrameOwnerElement(document->page()->focusController()->focusedFrame(), document->frame()); 402 if (!element) 403 return 0; 404 TreeScope* treeScope = element->treeScope(); 405 while (treeScope != this && treeScope != document) { 406 element = toShadowRoot(treeScope->rootNode())->host(); 407 treeScope = element->treeScope(); 408 } 409 if (this != treeScope) 410 return 0; 411 return element; 417 412 } 418 413 -
trunk/Source/WebCore/dom/TreeScope.h
r150713 r150733 55 55 void setParentTreeScope(TreeScope*); 56 56 57 Node* focusedNode();57 Element* focusedElement(); 58 58 Element* getElementById(const AtomicString&) const; 59 59 const Vector<Element*>* getAllElementsById(const AtomicString&) const; -
trunk/Source/WebCore/html/HTMLDocument.cpp
r149705 r150733 140 140 Element* HTMLDocument::activeElement() 141 141 { 142 if ( Node* node = treeScope()->focusedNode())143 return node->isElementNode() ? toElement(node) : body();142 if (Element* element = treeScope()->focusedElement()) 143 return element; 144 144 return body(); 145 145 }
Note: See TracChangeset
for help on using the changeset viewer.