| OLD | NEW |
| 1 function createShadowRoot() | 1 function createShadowRoot() |
| 2 { | 2 { |
| 3 var children = Array.prototype.slice.call(arguments); | 3 var children = Array.prototype.slice.call(arguments); |
| 4 if ((children[0] instanceof Object) && !(children[0] instanceof Node)) | 4 if ((children[0] instanceof Object) && !(children[0] instanceof Node)) |
| 5 return attachShadow.apply(null, children); | 5 return attachShadow.apply(null, children); |
| 6 return {'isShadowRoot': true, | 6 return {'isShadowRoot': true, |
| 7 'children': children}; | 7 'children': children}; |
| 8 } | 8 } |
| 9 | 9 |
| 10 // TODO(kochi): This is not pure attachShadow wrapper, but also handles createSh
adowRoot() | 10 // TODO(kochi): This is not pure attachShadow wrapper, but also handles createSh
adowRoot() |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return node instanceof window.ShadowRoot; | 117 return node instanceof window.ShadowRoot; |
| 118 } | 118 } |
| 119 | 119 |
| 120 function isIframeElement(element) | 120 function isIframeElement(element) |
| 121 { | 121 { |
| 122 return element && element.nodeName == 'IFRAME'; | 122 return element && element.nodeName == 'IFRAME'; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // You can spefify youngerShadowRoot by consecutive slashes. | 125 // You can spefify youngerShadowRoot by consecutive slashes. |
| 126 // See LayoutTests/fast/dom/shadow/get-element-by-id-in-shadow-root.html for act
ual usages. | 126 // See LayoutTests/fast/dom/shadow/get-element-by-id-in-shadow-root.html for act
ual usages. |
| 127 function getNodeInTreeOfTrees(path) | 127 function getNodeInComposedTree(path) |
| 128 { | 128 { |
| 129 var ids = path.split('/'); | 129 var ids = path.split('/'); |
| 130 var node = document.getElementById(ids[0]); | 130 var node = document.getElementById(ids[0]); |
| 131 for (var i = 1; node != null && i < ids.length; ++i) { | 131 for (var i = 1; node != null && i < ids.length; ++i) { |
| 132 if (isIframeElement(node)) { | 132 if (isIframeElement(node)) { |
| 133 node = node.contentDocument.getElementById(ids[i]); | 133 node = node.contentDocument.getElementById(ids[i]); |
| 134 continue; | 134 continue; |
| 135 } | 135 } |
| 136 if (isShadowRoot(node)) | 136 if (isShadowRoot(node)) |
| 137 node = internals.youngerShadowRoot(node); | 137 node = internals.youngerShadowRoot(node); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (shadowRoot.activeElement) | 188 if (shadowRoot.activeElement) |
| 189 return innermostActiveElement(shadowRoot.activeElement); | 189 return innermostActiveElement(shadowRoot.activeElement); |
| 190 shadowRoot = window.internals.youngerShadowRoot(shadowRoot); | 190 shadowRoot = window.internals.youngerShadowRoot(shadowRoot); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 return element; | 193 return element; |
| 194 } | 194 } |
| 195 | 195 |
| 196 function isInnermostActiveElement(id) | 196 function isInnermostActiveElement(id) |
| 197 { | 197 { |
| 198 var element = getNodeInTreeOfTrees(id); | 198 var element = getNodeInComposedTree(id); |
| 199 if (!element) { | 199 if (!element) { |
| 200 debug('FAIL: There is no such element with id: '+ from); | 200 debug('FAIL: There is no such element with id: '+ from); |
| 201 return false; | 201 return false; |
| 202 } | 202 } |
| 203 if (element == innermostActiveElement()) | 203 if (element == innermostActiveElement()) |
| 204 return true; | 204 return true; |
| 205 debug('Expected innermost activeElement is ' + id + ', but actual innermost
activeElement is ' + dumpNode(innermostActiveElement())); | 205 debug('Expected innermost activeElement is ' + id + ', but actual innermost
activeElement is ' + dumpNode(innermostActiveElement())); |
| 206 return false; | 206 return false; |
| 207 } | 207 } |
| 208 | 208 |
| 209 function shouldNavigateFocus(from, to, direction) | 209 function shouldNavigateFocus(from, to, direction) |
| 210 { | 210 { |
| 211 debug('Should move from ' + from + ' to ' + to + ' in ' + direction); | 211 debug('Should move from ' + from + ' to ' + to + ' in ' + direction); |
| 212 var fromElement = getNodeInTreeOfTrees(from); | 212 var fromElement = getNodeInComposedTree(from); |
| 213 if (!fromElement) { | 213 if (!fromElement) { |
| 214 debug('FAIL: There is no such element with id: '+ from); | 214 debug('FAIL: There is no such element with id: '+ from); |
| 215 return; | 215 return; |
| 216 } | 216 } |
| 217 fromElement.focus(); | 217 fromElement.focus(); |
| 218 if (!isInnermostActiveElement(from)) { | 218 if (!isInnermostActiveElement(from)) { |
| 219 debug('FAIL: Can not be focused: '+ from); | 219 debug('FAIL: Can not be focused: '+ from); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 if (direction == 'forward') | 222 if (direction == 'forward') |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 307 } |
| 308 | 308 |
| 309 function showNextNode(node) | 309 function showNextNode(node) |
| 310 { | 310 { |
| 311 var next = internals.nextInFlatTree(node); | 311 var next = internals.nextInFlatTree(node); |
| 312 debug('Next node of [' + dumpNode(node) + '] is [' + dumpNode(next) + ']'); | 312 debug('Next node of [' + dumpNode(node) + '] is [' + dumpNode(next) + ']'); |
| 313 } | 313 } |
| 314 | 314 |
| 315 function backgroundColorOf(selector) | 315 function backgroundColorOf(selector) |
| 316 { | 316 { |
| 317 return window.getComputedStyle(getNodeInTreeOfTrees(selector)).backgroundCol
or; | 317 return window.getComputedStyle(getNodeInComposedTree(selector)).backgroundCo
lor; |
| 318 } | 318 } |
| 319 | 319 |
| 320 function backgroundColorShouldBe(selector, expected) | 320 function backgroundColorShouldBe(selector, expected) |
| 321 { | 321 { |
| 322 shouldBeEqualToString('backgroundColorOf(\'' + selector + '\')', expected); | 322 shouldBeEqualToString('backgroundColorOf(\'' + selector + '\')', expected); |
| 323 } | 323 } |
| 324 | 324 |
| 325 function backgroundColorShouldNotBe(selector, color) | 325 function backgroundColorShouldNotBe(selector, color) |
| 326 { | 326 { |
| 327 var text = 'backgroundColorOf(\'' + selector + '\')'; | 327 var text = 'backgroundColorOf(\'' + selector + '\')'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 354 return node; | 354 return node; |
| 355 } | 355 } |
| 356 | 356 |
| 357 return null; | 357 return null; |
| 358 }; | 358 }; |
| 359 | 359 |
| 360 if (!window.internals) | 360 if (!window.internals) |
| 361 return null; | 361 return null; |
| 362 return iter(root, id); | 362 return iter(root, id); |
| 363 } | 363 } |
| OLD | NEW |