Changeset 121079 in webkit
- Timestamp:
- Jun 22, 2012 5:31:02 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r121077 r121079 1 2012-06-22 Hayato Ito <hayato@chromium.org> 2 3 [Shadow] ShadowRoot.activeElement should use the result of re-targeting algorithm. 4 https://bugs.webkit.org/show_bug.cgi?id=89763 5 6 Reviewed by Dimitri Glazkov. 7 8 * fast/dom/shadow/shadow-root-activeElement-expected.txt: 9 * fast/dom/shadow/shadow-root-activeElement.html: 10 1 11 2012-06-22 Kenneth Russell <kbr@google.com> 2 12 -
trunk/LayoutTests/fast/dom/shadow/shadow-root-activeElement-expected.txt
r110810 r121079 4 4 5 5 6 7 PASS shadowRoot.activeElement is defined. 8 PASS shadowRootInside.activeElement is defined. 9 PASS childInBody.focus();document.activeElement is childInBody 10 PASS childInBody.focus();shadowRoot.activeElement is null 11 PASS childInBody.focus();shadowRootInside.activeElement is null 12 PASS childInTreeOne.focus();document.activeElement is shadowHost 13 PASS childInTreeOne.focus();shadowRoot.activeElement is childInTreeOne 14 PASS childInTreeOne.focus();shadowRootInside.activeElement is null 15 PASS childInTreeTwo.focus();document.activeElement is shadowHost 16 PASS childInTreeTwo.focus();shadowRoot.activeElement is shadowHostInside 17 PASS childInTreeTwo.focus();shadowRootInside.activeElement is childInTreeTwo 18 childInTreeTwo.blur(); 6 PASS shadowRoot1.activeElement is defined. 7 PASS shadowRoot2.activeElement is defined. 8 PASS nodeInDocument.focus(); document.activeElement is nodeInDocument 9 PASS nodeInDocument.focus(); shadowRoot1.activeElement is null 10 PASS nodeInDocument.focus(); shadowRoot2.activeElement is null 11 PASS distributedLightChild.focus(); document.activeElement is distributedLightChild 12 PASS distributedLightChild.focus(); shadowRoot1.activeElement is distributedLightChild 13 PASS distributedLightChild.focus(); shadowRoot2.activeElement is null 14 PASS childInShadowRoot1.focus(); document.activeElement is shadowHost1 15 PASS childInShadowRoot1.focus(); shadowRoot1.activeElement is childInShadowRoot1 16 PASS childInShadowRoot1.focus(); shadowRoot2.activeElement is null 17 PASS childInShadowRoot2.focus(); document.activeElement is shadowHost1 18 PASS childInShadowRoot2.focus(); shadowRoot1.activeElement is shadowHost2 19 PASS childInShadowRoot2.focus(); shadowRoot2.activeElement is childInShadowRoot2 20 childInShadowRoot2.blur(); 19 21 PASS document.activeElement is document.body 20 PASS shadowRoot .activeElement is null21 PASS shadowRoot Inside.activeElement is null22 PASS shadowRoot1.activeElement is null 23 PASS shadowRoot2.activeElement is null 22 24 PASS successfullyParsed is true 23 25 -
trunk/LayoutTests/fast/dom/shadow/shadow-root-activeElement.html
r120792 r121079 3 3 <head> 4 4 <script src="../../js/resources/js-test-pre.js"></script> 5 <script src="resources/shadow-dom.js"></script> 5 6 </head> 6 7 <body> 7 <div id="console"> 8 <div id="console"></div> 9 <div id="sandbox"> 8 10 </div> 9 11 <script> … … 16 18 testRunner.dumpAsText(); 17 19 18 var childInBody = document.createElement("p"); 19 childInBody.tabIndex = "1"; 20 document.body.appendChild(childInBody); 20 document.getElementById('sandbox').appendChild( 21 createDOM('div', {}, 22 createDOM('div', {'id': 'node-in-document', 'tabindex': 1}), 23 createDOM('div', {'id': 'shadow-host-1'}, 24 createShadowRoot( 25 createDOM('div', {'id': 'shadow-host-2'}, 26 createShadowRoot( 27 createDOM('div', {'id': 'child-in-shadow-root-2', 'tabindex': 1}))), 28 createDOM('div', {'id': 'child-in-shadow-root-1', 'tabindex': 1}), 29 createDOM('content', {'select': '#distributed-light-child'})), 30 createDOM('div', {'id': 'distributed-light-child', 'tabindex': 1})))); 21 31 22 // First ShodowHost 23 var shadowHost = document.createElement("div");24 document.body.appendChild(shadowHost);25 var shadowRoot = new WebKitShadowRoot(shadowHost);32 var shadowHost1 = getNodeInShadowTreeStack('shadow-host-1'); 33 var shadowHost2 = getNodeInShadowTreeStack('shadow-host-1/shadow-host-2'); 34 var shadowRoot1 = getNodeInShadowTreeStack('shadow-host-1/'); 35 var shadowRoot2 = getNodeInShadowTreeStack('shadow-host-1/shadow-host-2/'); 26 36 27 // Second ShadowHost 28 shadowHostInside = document.createElement("div");29 shadowRoot.appendChild(shadowHostInside);30 var shadowRootInside = new WebKitShadowRoot(shadowHostInside);37 var nodeInDocument = document.getElementById('node-in-document'); 38 var distributedLightChild = document.getElementById('distributed-light-child'); 39 var childInShadowRoot1 = getNodeInShadowTreeStack('shadow-host-1/child-in-shadow-root-1'); 40 var childInShadowRoot2 = getNodeInShadowTreeStack('shadow-host-1/shadow-host-2/child-in-shadow-root-2'); 31 41 32 // Add a child inside first Shadow host 33 var childInTreeOne = document.createElement("p"); 34 childInTreeOne.setAttribute("id", "childInTreeOne"); 35 childInTreeOne.tabIndex = "1"; 36 shadowRoot.appendChild(childInTreeOne); 42 shouldBeDefined("shadowRoot1.activeElement"); 43 shouldBeDefined("shadowRoot2.activeElement"); 37 44 38 // Add a child inside second shadow host 39 var childInTreeTwo = document.createElement("p"); 40 childInTreeTwo.setAttribute("id", "childInTreeTwo"); 41 childInTreeTwo.tabIndex = "1"; 42 shadowRootInside.appendChild(childInTreeTwo); 45 shouldBe("nodeInDocument.focus(); document.activeElement", "nodeInDocument"); 46 shouldBe("nodeInDocument.focus(); shadowRoot1.activeElement", "null"); 47 shouldBe("nodeInDocument.focus(); shadowRoot2.activeElement", "null"); 43 48 44 shouldBeDefined("shadowRoot.activeElement"); 45 shouldBeDefined("shadowRootInside.activeElement"); 49 shouldBe("distributedLightChild.focus(); document.activeElement", "distributedLightChild"); 50 shouldBe("distributedLightChild.focus(); shadowRoot1.activeElement", "distributedLightChild"); 51 shouldBe("distributedLightChild.focus(); shadowRoot2.activeElement", "null"); 46 52 47 shouldBe("childIn Body.focus();document.activeElement", "childInBody");48 shouldBe("childIn Body.focus();shadowRoot.activeElement", "null");49 shouldBe("childIn Body.focus();shadowRootInside.activeElement", "null");53 shouldBe("childInShadowRoot1.focus(); document.activeElement", "shadowHost1"); 54 shouldBe("childInShadowRoot1.focus(); shadowRoot1.activeElement", "childInShadowRoot1"); 55 shouldBe("childInShadowRoot1.focus(); shadowRoot2.activeElement", "null"); 50 56 51 shouldBe("childIn TreeOne.focus();document.activeElement", "shadowHost");52 shouldBe("childIn TreeOne.focus();shadowRoot.activeElement", "childInTreeOne");53 shouldBe("childIn TreeOne.focus();shadowRootInside.activeElement", "null");57 shouldBe("childInShadowRoot2.focus(); document.activeElement", "shadowHost1"); 58 shouldBe("childInShadowRoot2.focus(); shadowRoot1.activeElement", "shadowHost2"); 59 shouldBe("childInShadowRoot2.focus(); shadowRoot2.activeElement", "childInShadowRoot2"); 54 60 55 shouldBe("childInTreeTwo.focus();document.activeElement", "shadowHost"); 56 shouldBe("childInTreeTwo.focus();shadowRoot.activeElement", "shadowHostInside"); 57 shouldBe("childInTreeTwo.focus();shadowRootInside.activeElement", "childInTreeTwo"); 58 59 evalAndLog("childInTreeTwo.blur();"); 61 evalAndLog("childInShadowRoot2.blur();"); 60 62 shouldBe("document.activeElement", "document.body"); 61 shouldBe("shadowRoot .activeElement", "null");62 shouldBe("shadowRoot Inside.activeElement", "null");63 shouldBe("shadowRoot1.activeElement", "null"); 64 shouldBe("shadowRoot2.activeElement", "null"); 63 65 64 66 var successfullyParsed = true; -
trunk/Source/WebCore/ChangeLog
r121076 r121079 1 2012-06-22 Hayato Ito <hayato@chromium.org> 2 3 [Shadow] ShadowRoot.activeElement should use the result of re-targeting algorithm. 4 https://bugs.webkit.org/show_bug.cgi?id=89763 5 6 Reviewed by Dimitri Glazkov. 7 8 Use the result of the re-targeting algorithm in calculating 9 shadow root's activeElement so that ShadowRoot.activeElement returns 10 a focused distributed node correctly as the algorithm says. 11 12 The spec is: 13 https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#active-element 14 15 Tests: fast/dom/shadow/shadow-root-activeElement.html 16 17 * dom/EventDispatcher.cpp: 18 (WebCore): 19 (WebCore::EventRelatedTargetAdjuster::adjust): 20 (WebCore::EventDispatcher::ensureEventAncestors): 21 * dom/TreeScope.cpp: 22 (WebCore::TreeScope::focusedNode): 23 * html/shadow/InsertionPoint.h: 24 (WebCore::InsertionPoint::contains): 25 1 26 2012-06-22 James Robinson <jamesr@chromium.org> 2 27 -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r121040 r121079 52 52 static HashSet<Node*>* gNodesDispatchingSimulatedClicks = 0; 53 53 54 static inline bool isAssignedTo(const Node* node, const InsertionPoint* insertionPoint)55 {56 ASSERT(insertionPoint);57 return node && (insertionPoint->contains(node) || (node->isShadowRoot() && toShadowRoot(node)->assignedTo() == insertionPoint));58 }59 60 54 EventRelatedTargetAdjuster::EventRelatedTargetAdjuster(PassRefPtr<Node> node, PassRefPtr<Node> relatedTarget) 61 55 : m_node(node) … … 75 69 if (relatedTargetStack.isEmpty()) 76 70 relatedTargetStack.append(node); 77 else if (isInsertionPoint(node) && isAssignedTo(lastNode, toInsertionPoint(node)))71 else if (isInsertionPoint(node) && toInsertionPoint(node)->contains(lastNode)) 78 72 relatedTargetStack.append(relatedTargetStack.last()); 79 73 TreeScope* scope = node->treeScope(); … … 227 221 if (targetStack.isEmpty()) 228 222 targetStack.append(eventTargetRespectingSVGTargetRules(node)); 229 else if (isInsertionPoint(node) && isAssignedTo(last, toInsertionPoint(node)))223 else if (isInsertionPoint(node) && toInsertionPoint(node)->contains(last)) 230 224 targetStack.append(targetStack.last()); 231 225 m_ancestors.append(EventContext(node, eventTargetRespectingSVGTargetRules(node), targetStack.last())); -
trunk/Source/WebCore/dom/TreeScope.cpp
r120168 r121079 27 27 #include "TreeScope.h" 28 28 29 #include "ComposedShadowTreeWalker.h" 29 30 #include "ContainerNode.h" 30 31 #include "ContextFeatures.h" … … 39 40 #include "HTMLMapElement.h" 40 41 #include "HTMLNames.h" 42 #include "InsertionPoint.h" 41 43 #include "Page.h" 42 44 #include "ShadowRoot.h" … … 225 227 if (!node) 226 228 return 0; 227 228 TreeScope* treeScope = node->treeScope(); 229 230 while (treeScope != this && treeScope != document) { 231 node = toShadowRoot(treeScope->rootNode())->host(); 232 treeScope = node->treeScope(); 233 } 234 if (this != treeScope) 235 return 0; 236 237 return node; 229 Vector<Node*> targetStack; 230 Node* last = 0; 231 for (ComposedShadowTreeParentWalker walker(node); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) { 232 Node* node = walker.get(); 233 if (targetStack.isEmpty()) 234 targetStack.append(node); 235 else if (isInsertionPoint(node) && toInsertionPoint(node)->contains(last)) 236 targetStack.append(targetStack.last()); 237 if (node == rootNode()) 238 return targetStack.last(); 239 last = node; 240 if (node->isShadowRoot()) { 241 ASSERT(!targetStack.isEmpty()); 242 targetStack.removeLast(); 243 } 244 } 245 return 0; 238 246 } 239 247 -
trunk/Source/WebCore/html/shadow/InsertionPoint.h
r120754 r121079 35 35 #include "HTMLElement.h" 36 36 #include "HTMLNames.h" 37 #include "ShadowRoot.h" 37 38 #include <wtf/Forward.h> 38 39 … … 58 59 59 60 size_t indexOf(Node* node) const { return m_distribution.find(node); } 60 bool contains(const Node* node) const { return m_distribution.contains(const_cast<Node*>(node)) ; }61 bool contains(const Node* node) const { return m_distribution.contains(const_cast<Node*>(node)) || (node->isShadowRoot() && toShadowRoot(node)->assignedTo() == this); } 61 62 size_t size() const { return m_distribution.size(); } 62 63 Node* at(size_t index) const { return m_distribution.at(index).get(); }
Note: See TracChangeset
for help on using the changeset viewer.