Commit 173c1ffd authored by hayato@chromium.org's avatar hayato@chromium.org
Browse files

Add support for getting an element in shadow root by its id into a window.internals object.

https://bugs.webkit.org/show_bug.cgi?id=64587

Reviewed by Hajime Morita.

.:

* Source/autotools/symbols.filter:

Source/WebCore:

Test: fast/dom/shadow/get-element-by-id-in-shadow-root.html

* WebCore.exp.in:
* testing/Internals.cpp:
(WebCore::Internals::getElementByIdInShadowRoot):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

* win/WebKit2.def:
* win/WebKit2CFLite.def:

LayoutTests:

* fast/dom/shadow/get-element-by-id-in-shadow-root-expected.txt: Added.
* fast/dom/shadow/get-element-by-id-in-shadow-root.html: Added.
* fast/dom/shadow/resources/create-dom.js: Added.
(createShadow):
(createDom):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@92124 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 345f77e5
2011-08-01 Hayato Ito <hayato@chromium.org>
Add support for getting an element in shadow root by its id into a window.internals object.
https://bugs.webkit.org/show_bug.cgi?id=64587
Reviewed by Hajime Morita.
* Source/autotools/symbols.filter:
2011-08-01 Neil Roberts <neil@linux.intel.com>
 
build: Fix finding the headers for GStreamer
......
2011-08-01 Hayato Ito <hayato@chromium.org>
Add support for getting an element in shadow root by its id into a window.internals object.
https://bugs.webkit.org/show_bug.cgi?id=64587
Reviewed by Hajime Morita.
* fast/dom/shadow/get-element-by-id-in-shadow-root-expected.txt: Added.
* fast/dom/shadow/get-element-by-id-in-shadow-root.html: Added.
* fast/dom/shadow/resources/create-dom.js: Added.
(createShadow):
(createDom):
2011-08-01 Yury Semikhatsky <yurys@chromium.org>
 
Web Inspector: typing an expression in an iframe leads to multiple "Unsafe JavaScript attempt to access frame..." errors
Tests to ensure that internals.getElementByIdInTreeScope can get an element in TreeScope by its id. Can only run within DRT
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS getElementInShadow('divA/inputB').id is "inputB"
PASS getElementInShadow('divA/divC').id is "divC"
PASS getElementInShadow('divA/divC/inputD').id is "inputD"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/create-dom.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests to ensure that internals.getElementByIdInTreeScope can get an element in TreeScope by its id. Can only run within DRT");
function getElementInShadow(path)
{
var ids = path.split('/');
var element = document.getElementById(ids[0]);
for (var i = 1; element != null && i < ids.length; ++i) {
var shadowRoot = internals.shadowRoot(element);
element = internals.getElementByIdInShadowRoot(shadowRoot, ids[i]);
}
return element;
}
function prepareDomTree(parent)
{
parent.appendChild(
createShadow('div', {'id': 'divA'},
createDom('input', {'id': 'inputB'}),
createShadow('div', {'id': 'divC'},
createDom('input', {'id': 'inputD'}))));
}
function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
prepareDomTree(document.body);
shouldBeEqualToString("getElementInShadow('divA/inputB').id", 'inputB');
shouldBeEqualToString("getElementInShadow('divA/divC').id", 'divC');
shouldBeEqualToString("getElementInShadow('divA/divC/inputD').id", 'inputD');
}
test();
var successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
// This function can take optional child elements as arguments[2:].
function createShadow(tagName, attributes)
{
var element = document.createElement(tagName);
for (var name in attributes)
element.setAttribute(name, attributes[name]);
var shadow = internals.ensureShadowRoot(element);
var childElements = Array.prototype.slice.call(arguments, 2);
for (var i = 0; i < childElements.length; ++i)
shadow.appendChild(childElements[i]);
return element;
}
// This function can take optional child elements as arguments[2:].
function createDom(tagName, attributes)
{
var element = document.createElement(tagName);
for (var name in attributes)
element.setAttribute(name, attributes[name]);
var childElements = Array.prototype.slice.call(arguments, 2);
for (var i = 0; i < childElements.length; ++i)
element.appendChild(childElements[i]);
return element;
}
2011-08-01 Hayato Ito <hayato@chromium.org>
Add support for getting an element in shadow root by its id into a window.internals object.
https://bugs.webkit.org/show_bug.cgi?id=64587
Reviewed by Hajime Morita.
Test: fast/dom/shadow/get-element-by-id-in-shadow-root.html
* WebCore.exp.in:
* testing/Internals.cpp:
(WebCore::Internals::getElementByIdInShadowRoot):
* testing/Internals.h:
* testing/Internals.idl:
2011-07-15 Hayato Ito <hayato@chromium.org>
Add support for retrieving an element in TreeScope by id to window.internals object.
https://bugs.webkit.org/show_bug.cgi?id=64587
Reviewed by Hajime Morita.
Test: fast/dom/shadow/get-element-by-id-in-shadow.html
* WebCore.exp.in:
* testing/Internals.cpp:
(WebCore::Internals::getElementByIdInTreeScope):
* testing/Internals.h:
* testing/Internals.idl:
2011-08-01 Yury Semikhatsky <yurys@chromium.org>
 
Web Inspector: typing an expression in an iframe leads to multiple "Unsafe JavaScript attempt to access frame..." errors
......@@ -1342,6 +1342,7 @@ __ZNK7WebCore9FrameView23documentBackgroundColorEv
__ZNK7WebCore9FrameView28isEnclosedInCompositingLayerEv
__ZNK7WebCore9PageCache10frameCountEv
__ZNK7WebCore9PageCache21autoreleasedPageCountEv
__ZNK7WebCore9TreeScope14getElementByIdERKN3WTF12AtomicStringE
__ZTVN7WebCore12ChromeClientE
__ZTVN7WebCore12JSDOMWrapperE
__ZTVN7WebCore16IconDatabaseBaseE
......
......@@ -72,6 +72,15 @@ PassRefPtr<Element> Internals::createShadowContentElement(Document* document, Ex
return ShadowContentElement::create(document);
}
Element* Internals::getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode& ec)
{
if (!shadowRoot || !shadowRoot->isShadowRoot()) {
ec = INVALID_ACCESS_ERR;
return 0;
}
return toShadowRoot(shadowRoot)->getElementById(id);
}
String Internals::elementRenderTreeAsText(Element* element, ExceptionCode& ec)
{
if (!element) {
......
......@@ -54,6 +54,7 @@ public:
Element* includerFor(Node*, ExceptionCode&);
String shadowPseudoId(Element*, ExceptionCode&);
PassRefPtr<Element> createShadowContentElement(Document*, ExceptionCode&);
Element* getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode&);
#if ENABLE(INSPECTOR)
void setInspectorResourcesDataSizeLimits(Document*, int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode&);
......
......@@ -36,6 +36,7 @@ module window {
void removeShadowRoot(in Element host) raises (DOMException);
DOMString shadowPseudoId(in Element element) raises (DOMException);
Element createShadowContentElement(in Document document) raises(DOMException);
Element getElementByIdInShadowRoot(in Node shadowRoot, in DOMString id) raises(DOMException);
void setInspectorResourcesDataSizeLimits(in Document document, in long maximumResourcesContentSize, in long maximumSingleResourceContentSize) raises(DOMException);
......
2011-08-01 Hayato Ito <hayato@chromium.org>
Add support for getting an element in shadow root by its id into a window.internals object.
https://bugs.webkit.org/show_bug.cgi?id=64587
Reviewed by Hajime Morita.
* win/WebKit2.def:
* win/WebKit2CFLite.def:
2011-08-01 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r92108.
......
......@@ -151,6 +151,7 @@ EXPORTS
?ensureShadowRoot@Element@WebCore@@QAEPAVShadowRoot@2@XZ
?externalRepresentation@WebCore@@YA?AVString@WTF@@PAVElement@1@I@Z
?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z
?getElementById@TreeScope@WebCore@@QBEPAVElement@2@ABVAtomicString@WTF@@@Z
?isPreloaded@CachedResourceLoader@WebCore@@QBE_NABVString@WTF@@@Z
?jsStringSlowCase@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@AAV?$HashMap@PAVStringImpl@WTF@@V?$Weak@VJSString@JSC@@@JSC@@UStringHash@2@U?$HashTraits@PAVStringImpl@WTF@@@2@U?$HashTraits@V?$Weak@VJSString@JSC@@@JSC@@@2@@WTF@@PAVStringImpl@6@@Z
?page@Document@WebCore@@QBEPAVPage@2@XZ
......
......@@ -143,6 +143,7 @@ EXPORTS
?ensureShadowRoot@Element@WebCore@@QAEPAVShadowRoot@2@XZ
?externalRepresentation@WebCore@@YA?AVString@WTF@@PAVElement@1@I@Z
?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z
?getElementById@TreeScope@WebCore@@QBEPAVElement@2@ABVAtomicString@WTF@@@Z
?isPreloaded@CachedResourceLoader@WebCore@@QBE_NABVString@WTF@@@Z
?toJS@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVClientRect@1@@Z
?updateLayoutIgnorePendingStylesheets@Document@WebCore@@QAEXXZ
......
......@@ -60,6 +60,7 @@ _ZNK7WebCore20CachedResourceLoader11isPreloadedERKN3WTF6StringE;
_ZNK7WebCore6JSNode21pushEventHandlerScopeEPN3JSC9ExecStateEPNS1_14ScopeChainNodeE;
_ZNK7WebCore7Element10shadowRootEv;
_ZNK7WebCore8Document4pageEv;
_ZNK7WebCore9TreeScope14getElementByIdERKN3WTF12AtomicStringE;
local:
_Z*;
cti*;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment