mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
Bug 1409975 - Implement node distribution for shadow tree slots
* Implementation for assignedNodes * Include slots in the flat tree * Fix event get-the-parent algorithm for a node * Update and add reftests for Shadow DOM v1 * Update web platform tests expectations Tag #1375
This commit is contained in:
parent
a7ba34c672
commit
cab78760e5
49 changed files with 775 additions and 429 deletions
|
|
@ -1,8 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body>
|
||||
<div>
|
||||
<div style="border: 10px solid green">Hello</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function tweak() {
|
||||
// div with style "border: 10px solid green"
|
||||
var shadowDiv = document.createElement("div");
|
||||
shadowDiv.style.border = "10px solid green";
|
||||
|
||||
var insertionPoint = document.createElement("content");
|
||||
shadowDiv.appendChild(insertionPoint);
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
shadowRoot.appendChild(shadowDiv);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="tweak()">
|
||||
<div id="outer">Hello</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body>
|
||||
<div>
|
||||
<div style="border: 10px solid green">
|
||||
<span style="background-color: purple">Hello</span>
|
||||
<span style="background-color: orange">World</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function tweak() {
|
||||
// div with style "border: 10px solid green"
|
||||
var shadowDiv = document.createElement("div");
|
||||
shadowDiv.style.border = "10px solid green";
|
||||
|
||||
var insertionPoint = document.createElement("content");
|
||||
shadowDiv.appendChild(insertionPoint);
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
shadowRoot.appendChild(shadowDiv);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="tweak()">
|
||||
<div id="outer">
|
||||
<span style="background-color: purple">Hello</span>
|
||||
<span style="background-color: orange">World</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
shadowDiv.style.height = "100px";
|
||||
shadowDiv.style.backgroundColor = "green";
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
var shadowRoot = document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(shadowDiv);
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
var shadowDiv = document.createElement("div");
|
||||
shadowDiv.style.border = "10px solid green";
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
var shadowRoot = document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(shadowDiv);
|
||||
|
||||
var orangeDiv = document.createElement("div");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
var shadowDiv = document.createElement("div");
|
||||
shadowDiv.style.border = "10px solid green";
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
var shadowRoot = document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(shadowDiv);
|
||||
|
||||
var orangeDiv = document.createElement("div");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
var shadowDiv = document.createElement("div");
|
||||
shadowDiv.style.border = "10px solid green";
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
var shadowRoot = document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(shadowDiv);
|
||||
|
||||
var orangeDiv = document.createElement("div");
|
||||
|
|
|
|||
11
layout/reftests/webcomponents/basic-slot-1-ref.html
Normal file
11
layout/reftests/webcomponents/basic-slot-1-ref.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body { color: green; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
This text should be green
|
||||
</body>
|
||||
</html>
|
||||
6
layout/reftests/webcomponents/basic-slot-1.html
Normal file
6
layout/reftests/webcomponents/basic-slot-1.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body>
|
||||
<slot style="color: green">This text should be green</slot>
|
||||
</body>
|
||||
</html>
|
||||
16
layout/reftests/webcomponents/basic-slot-2-ref.html
Normal file
16
layout/reftests/webcomponents/basic-slot-2-ref.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
div {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background: green;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>There should be a green box below.</p>
|
||||
<div></div>
|
||||
</body>
|
||||
</html>
|
||||
7
layout/reftests/webcomponents/basic-slot-2.html
Normal file
7
layout/reftests/webcomponents/basic-slot-2.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body>
|
||||
<p>There should be a green box below.</p>
|
||||
<slot style="display: block; width: 100px; height: 100px; background: green;"></slot>
|
||||
</body>
|
||||
</html>
|
||||
8
layout/reftests/webcomponents/basic-slot-3-ref.html
Normal file
8
layout/reftests/webcomponents/basic-slot-3-ref.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body>
|
||||
<div>
|
||||
<div style="color: green">This text should be green</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
18
layout/reftests/webcomponents/basic-slot-3.html
Normal file
18
layout/reftests/webcomponents/basic-slot-3.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function tweak() {
|
||||
var slot = document.createElement("slot");
|
||||
slot.style.color = "green";
|
||||
|
||||
var shadowRoot =
|
||||
document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(slot);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="tweak()">
|
||||
<div id="outer">This text should be green</div>
|
||||
</body>
|
||||
</html>
|
||||
20
layout/reftests/webcomponents/basic-slot-4.html
Normal file
20
layout/reftests/webcomponents/basic-slot-4.html
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function tweak() {
|
||||
var slot = document.createElement("slot");
|
||||
// The border shouldn't be visible, due to display: contents.
|
||||
slot.style.border = "1px solid red";
|
||||
slot.style.color = "green";
|
||||
|
||||
var shadowRoot =
|
||||
document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(slot);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="tweak()">
|
||||
<div id="outer">This text should be green</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -5,9 +5,11 @@
|
|||
<body>
|
||||
<div id="host"></div>
|
||||
<script>
|
||||
var host = document.getElementById("host");
|
||||
var root = host.createShadowRoot();
|
||||
root.innerHTML = 'a <content></content> c';
|
||||
var host, root;
|
||||
|
||||
host = document.getElementById("host");
|
||||
root = host.attachShadow({mode: 'open'});
|
||||
root.innerHTML = 'a <slot></slot> c';
|
||||
|
||||
function tweak() {
|
||||
var span = document.createElement("span");
|
||||
|
|
@ -19,7 +21,7 @@
|
|||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
|
||||
window.addEventListener("MozReftestInvalidate", tweak, false);
|
||||
window.addEventListener("MozReftestInvalidate", tweak);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@
|
|||
<body>
|
||||
<div id="host"></div>
|
||||
<script>
|
||||
var host = document.getElementById("host");
|
||||
var root = host.createShadowRoot();
|
||||
var host, root;
|
||||
|
||||
host = document.getElementById("host");
|
||||
root = host.attachShadow({mode: 'open'});
|
||||
root.innerHTML = "<span>a</span>";
|
||||
|
||||
function tweak() {
|
||||
|
|
@ -20,7 +22,7 @@
|
|||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
|
||||
window.addEventListener("MozReftestInvalidate", tweak, false);
|
||||
window.addEventListener("MozReftestInvalidate", tweak);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<div style="background-color: green"><span>Hello</span><span> </span><span>World</span></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function tweak() {
|
||||
var oldestShadow = document.getElementById('outer').createShadowRoot();
|
||||
oldestShadow.innerHTML = 'Hello';
|
||||
|
||||
var olderShadow = document.getElementById('outer').createShadowRoot();
|
||||
|
||||
var youngerShadow = document.getElementById('outer').createShadowRoot();
|
||||
youngerShadow.innerHTML = '<div style="background-color:green"><shadow></shadow></div>';
|
||||
|
||||
olderShadow.innerHTML = '<shadow></shadow> World';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="tweak()">
|
||||
<div id="outer">
|
||||
<div style="width:300px; height:100px; background-color:red;"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -8,13 +8,13 @@
|
|||
shadowDiv.style.border = "10px solid green";
|
||||
|
||||
// Insertion point will match nothing and use fallback content.
|
||||
var insertionPoint = document.createElement("content");
|
||||
shadowDiv.appendChild(insertionPoint);
|
||||
var slot = document.createElement("slot");
|
||||
shadowDiv.appendChild(slot);
|
||||
|
||||
// Append three nodes as children to use as fallback content.
|
||||
insertionPoint.innerHTML = '<span style="background-color: orange">Hello</span> <span style="background-color: green">World</span>';
|
||||
slot.innerHTML = '<span style="background-color: orange">Hello</span> <span style="background-color: green">World</span>';
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
var shadowRoot = document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(shadowDiv);
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -5,19 +5,21 @@
|
|||
<body>
|
||||
<div id="host"></div>
|
||||
<script>
|
||||
var host = document.getElementById("host");
|
||||
var root = host.createShadowRoot();
|
||||
var host, root;
|
||||
|
||||
host = document.getElementById("host");
|
||||
root = host.attachShadow({mode: 'open'});
|
||||
root.innerHTML = '<style>input ~ div { background: red; transition: background 100ms; } input:checked ~ div { background: green; }</style><input id="one" type="checkbox"><div style="height: 50px; width: 50px;"></div>';
|
||||
|
||||
function tweak() {
|
||||
var el = root.getElementById("one");
|
||||
el.checked = true;
|
||||
el.nextSibling.addEventListener("transitionend", function() {
|
||||
document.documentElement.removeAttribute("class");
|
||||
}, false);
|
||||
var el = root.getElementById("one");
|
||||
el.checked = true;
|
||||
el.nextSibling.addEventListener("transitionend", function() {
|
||||
setTimeout(()=>{document.documentElement.removeAttribute("class")}, 1000); // wait for the checkbox SVG image to load on Android
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("MozReftestInvalidate", tweak, false);
|
||||
window.addEventListener("MozReftestInvalidate", tweak);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -7,19 +7,20 @@
|
|||
var outerShadow = document.createElement("div");
|
||||
outerShadow.style.border = "10px solid green";
|
||||
|
||||
var outerInsertionPoint = document.createElement("content");
|
||||
var outerInsertionPoint = document.createElement("slot");
|
||||
outerShadow.appendChild(outerInsertionPoint);
|
||||
|
||||
// div with style "border: 10px solid orange"
|
||||
var innerShadow = document.createElement("div");
|
||||
innerShadow.style.border = "10px solid orange";
|
||||
|
||||
var innerInsertionPoint = document.createElement("content");
|
||||
innerShadow.appendChild(innerInsertionPoint);
|
||||
var slot = document.createElement("slot");
|
||||
innerShadow.appendChild(slot);
|
||||
|
||||
outerShadow.createShadowRoot().appendChild(innerShadow);
|
||||
outerShadow.attachShadow({mode: 'open'}).appendChild(innerShadow);
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
var shadowRoot =
|
||||
document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(outerShadow);
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
16
layout/reftests/webcomponents/reframe-shadow-child-1.html
Normal file
16
layout/reftests/webcomponents/reframe-shadow-child-1.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<template id="tmpl">
|
||||
<div style="display: table">
|
||||
Some text
|
||||
<span style="display: table-cell">something</span>
|
||||
More text
|
||||
</div>
|
||||
</template>
|
||||
<div id="host"></div>
|
||||
<script>
|
||||
let shadowRoot = document.getElementById("host").attachShadow({mode: 'open'});
|
||||
let tmpl = document.getElementById("tmpl");
|
||||
shadowRoot.appendChild(document.importNode(tmpl.content, true));
|
||||
document.body.offsetTop;
|
||||
shadowRoot.firstElementChild.querySelector("span").remove();
|
||||
</script>
|
||||
15
layout/reftests/webcomponents/reframe-shadow-child-2.html
Normal file
15
layout/reftests/webcomponents/reframe-shadow-child-2.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<template id="tmpl">
|
||||
<div style="display: block">
|
||||
Some text
|
||||
More text
|
||||
</div>
|
||||
</template>
|
||||
<div id="host"></div>
|
||||
<script>
|
||||
let shadowRoot = document.getElementById("host").attachShadow({mode: 'open'});
|
||||
let tmpl = document.getElementById("tmpl");
|
||||
shadowRoot.appendChild(document.importNode(tmpl.content, true));
|
||||
document.body.offsetTop;
|
||||
shadowRoot.firstElementChild.style.display = "table";
|
||||
</script>
|
||||
|
|
@ -3,8 +3,6 @@ pref(dom.webcomponents.enabled,true) == basic-shadow-1.html basic-shadow-1-ref.h
|
|||
pref(dom.webcomponents.enabled,true) == basic-shadow-2.html basic-shadow-2-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == basic-shadow-3.html basic-shadow-3-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == basic-shadow-4.html basic-shadow-4-ref.html
|
||||
#bug 1421542 pref(dom.webcomponents.enabled,true) == basic-insertion-point-1.html basic-insertion-point-1-ref.html
|
||||
#bug 1421542 pref(dom.webcomponents.enabled,true) == basic-insertion-point-2.html basic-insertion-point-2-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == fallback-content-1.html fallback-content-1-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == remove-insertion-point-1.html remove-insertion-point-1-ref.html
|
||||
#bug 1421542 pref(dom.webcomponents.enabled,true) == nested-insertion-point-1.html nested-insertion-point-1-ref.html
|
||||
|
|
@ -13,3 +11,9 @@ pref(dom.webcomponents.enabled,true) == input-transition-1.html input-transition
|
|||
#bug 1421542 pref(dom.webcomponents.enabled,true) == dynamic-insertion-point-distribution-1.html dynamic-insertion-point-distribution-1-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == dynamic-insertion-point-distribution-2.html dynamic-insertion-point-distribution-2-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == remove-append-shadow-host-1.html remove-append-shadow-host-1-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == basic-slot-1.html basic-slot-1-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == basic-slot-2.html basic-slot-2-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == basic-slot-3.html basic-slot-3-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == basic-slot-4.html basic-slot-3-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == basic-slot-5.html basic-slot-5-ref.html
|
||||
pref(dom.webcomponents.enabled,true) == basic-slot-6.html basic-slot-6-ref.html
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<div id="container"><div id="host"></div></div>
|
||||
<script>
|
||||
var host = document.getElementById("host");
|
||||
var root = host.createShadowRoot();
|
||||
var root = host.attachShadow({mode: 'open'});
|
||||
root.innerHTML = 'inside shadow DOM';
|
||||
|
||||
var container = document.getElementById("container");
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@
|
|||
shadowDiv.style.border = "10px solid green";
|
||||
|
||||
// Insertion point will match nothing and use fallback content.
|
||||
var insertionPoint = document.createElement("content");
|
||||
shadowDiv.appendChild(insertionPoint);
|
||||
var slot = document.createElement("slot");
|
||||
shadowDiv.appendChild(slot);
|
||||
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
var shadowRoot = document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.appendChild(shadowDiv);
|
||||
|
||||
// Remove the insertion point from the ShadowRoot, "Hello" should no
|
||||
// longer be rendered.
|
||||
shadowDiv.removeChild(insertionPoint);
|
||||
shadowDiv.removeChild(slot);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
<!doctype html>
|
||||
<style>
|
||||
div { display: contents }
|
||||
</style>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<script>
|
||||
let divs = document.querySelectorAll('div');
|
||||
divs[0].attachShadow({mode: 'open'}).innerHTML = `
|
||||
<style>
|
||||
* { color: green; }
|
||||
</style>
|
||||
<span>Should be green</span>
|
||||
`;
|
||||
divs[1].attachShadow({mode: 'open'}).innerHTML = `
|
||||
<style>
|
||||
* { color: initial; }
|
||||
[foo] { }
|
||||
</style>
|
||||
<span>Should not be green</span>
|
||||
`;
|
||||
</script>
|
||||
14
layout/reftests/webcomponents/style-sharing.html
Normal file
14
layout/reftests/webcomponents/style-sharing.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<div id="host"></div>
|
||||
<script>
|
||||
let root = host.attachShadow({mode: 'open'});
|
||||
root.innerHTML = `
|
||||
<style>
|
||||
#test {
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
<span id="test">Should be green</span>
|
||||
<span id="test2">Should not be green</span>
|
||||
`;
|
||||
</script>
|
||||
|
|
@ -5,17 +5,18 @@
|
|||
<body>
|
||||
<div id="outer"><span id="distnode">text</span></div>
|
||||
<script>
|
||||
var shadowRoot = document.getElementById('outer').createShadowRoot();
|
||||
shadowRoot.innerHTML = '<div><content></content></div>';
|
||||
|
||||
function tweak() {
|
||||
var distNode = document.getElementById("distnode");
|
||||
distNode.textContent = "Hello World";
|
||||
var shadowRoot = document.getElementById('outer').attachShadow({mode: 'open'});
|
||||
shadowRoot.innerHTML = '<div><slot></slot></div>';
|
||||
|
||||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
function tweak() {
|
||||
var distNode = document.getElementById("distnode");
|
||||
distNode.textContent = "Hello World";
|
||||
|
||||
window.addEventListener("MozReftestInvalidate", tweak);
|
||||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
|
||||
window.addEventListener("MozReftestInvalidate", tweak);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue