mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1083587 - Add host and olderShadowRoot properties to ShadowRoot interface. r=smaug
This commit is contained in:
parent
2c68e442bb
commit
01e16b1aa3
@ -2954,6 +2954,6 @@ FragmentOrElement::SetIsElementInStyleScopeFlagOnShadowTree(bool aInStyleScope)
|
||||
ShadowRoot* shadowRoot = GetShadowRoot();
|
||||
while (shadowRoot) {
|
||||
shadowRoot->SetIsElementInStyleScopeFlagOnSubtree(aInStyleScope);
|
||||
shadowRoot = shadowRoot->GetOlderShadow();
|
||||
shadowRoot = shadowRoot->GetOlderShadowRoot();
|
||||
}
|
||||
}
|
||||
|
@ -481,6 +481,16 @@ ShadowRoot::SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError)
|
||||
SetInnerHTMLInternal(aInnerHTML, aError);
|
||||
}
|
||||
|
||||
Element*
|
||||
ShadowRoot::Host()
|
||||
{
|
||||
nsIContent* host = GetHost();
|
||||
MOZ_ASSERT(host && host->IsElement(),
|
||||
"ShadowRoot host should always be an element, "
|
||||
"how else did we create this ShadowRoot?");
|
||||
return host->AsElement();
|
||||
}
|
||||
|
||||
bool
|
||||
ShadowRoot::ApplyAuthorStyles()
|
||||
{
|
||||
|
@ -93,8 +93,7 @@ public:
|
||||
void RemoveInsertionPoint(HTMLContentElement* aInsertionPoint);
|
||||
|
||||
void SetYoungerShadow(ShadowRoot* aYoungerShadow);
|
||||
ShadowRoot* GetOlderShadow() { return mOlderShadow; }
|
||||
ShadowRoot* GetYoungerShadow() { return mYoungerShadow; }
|
||||
ShadowRoot* GetYoungerShadowRoot() { return mYoungerShadow; }
|
||||
void SetInsertionPointChanged() { mInsertionPointChanged = true; }
|
||||
|
||||
void SetAssociatedBinding(nsXBLBinding* aBinding) { mAssociatedBinding = aBinding; }
|
||||
@ -125,6 +124,8 @@ public:
|
||||
GetElementsByClassName(const nsAString& aClasses);
|
||||
void GetInnerHTML(nsAString& aInnerHTML);
|
||||
void SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError);
|
||||
Element* Host();
|
||||
ShadowRoot* GetOlderShadowRoot() { return mOlderShadow; }
|
||||
void StyleSheetChanged();
|
||||
protected:
|
||||
virtual ~ShadowRoot();
|
||||
|
@ -6816,7 +6816,7 @@ nsContentUtils::HasDistributedChildren(nsIContent* aContent)
|
||||
if (shadow) {
|
||||
// Children of a shadow root are distributed to
|
||||
// the shadow insertion point of the younger shadow root.
|
||||
return shadow->GetYoungerShadow();
|
||||
return shadow->GetYoungerShadowRoot();
|
||||
}
|
||||
|
||||
HTMLShadowElement* shadowEl = HTMLShadowElement::FromContent(aContent);
|
||||
|
@ -144,7 +144,7 @@ HTMLShadowElement::BindToTree(nsIDocument* aDocument,
|
||||
|
||||
if (mIsInsertionPoint && containingShadow) {
|
||||
// Propagate BindToTree calls to projected shadow root children.
|
||||
ShadowRoot* projectedShadow = containingShadow->GetOlderShadow();
|
||||
ShadowRoot* projectedShadow = containingShadow->GetOlderShadowRoot();
|
||||
if (projectedShadow) {
|
||||
for (nsIContent* child = projectedShadow->GetFirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
@ -167,7 +167,7 @@ HTMLShadowElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
if (mIsInsertionPoint && oldContainingShadow) {
|
||||
// Propagate UnbindFromTree call to previous projected shadow
|
||||
// root children.
|
||||
ShadowRoot* projectedShadow = oldContainingShadow->GetOlderShadow();
|
||||
ShadowRoot* projectedShadow = oldContainingShadow->GetOlderShadowRoot();
|
||||
if (projectedShadow) {
|
||||
for (nsIContent* child = projectedShadow->GetFirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
@ -220,7 +220,7 @@ HTMLShadowElement::DistributeSingleNode(nsIContent* aContent)
|
||||
// Handle the case where the parent of this shadow element is a ShadowRoot
|
||||
// that is projected into a shadow insertion point in the younger ShadowRoot.
|
||||
ShadowRoot* containingShadow = GetContainingShadow();
|
||||
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadow();
|
||||
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadowRoot();
|
||||
if (youngerShadow && GetParent() == containingShadow) {
|
||||
HTMLShadowElement* youngerShadowElement = youngerShadow->GetShadowElement();
|
||||
if (youngerShadowElement) {
|
||||
@ -247,7 +247,7 @@ HTMLShadowElement::RemoveDistributedNode(nsIContent* aContent)
|
||||
// Handle the case where the parent of this shadow element is a ShadowRoot
|
||||
// that is projected into a shadow insertion point in the younger ShadowRoot.
|
||||
ShadowRoot* containingShadow = GetContainingShadow();
|
||||
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadow();
|
||||
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadowRoot();
|
||||
if (youngerShadow && GetParent() == containingShadow) {
|
||||
HTMLShadowElement* youngerShadowElement = youngerShadow->GetShadowElement();
|
||||
if (youngerShadowElement) {
|
||||
@ -263,7 +263,7 @@ HTMLShadowElement::DistributeAllNodes()
|
||||
// into this shadow insertion point so update the destination insertion
|
||||
// points.
|
||||
ShadowRoot* containingShadow = GetContainingShadow();
|
||||
ShadowRoot* olderShadow = containingShadow->GetOlderShadow();
|
||||
ShadowRoot* olderShadow = containingShadow->GetOlderShadowRoot();
|
||||
if (olderShadow) {
|
||||
ExplicitChildIterator childIterator(olderShadow);
|
||||
for (nsIContent* content = childIterator.GetNextChild();
|
||||
@ -286,7 +286,7 @@ HTMLShadowElement::DistributeAllNodes()
|
||||
|
||||
// Handle the case where the parent of this shadow element is a ShadowRoot
|
||||
// that is projected into a shadow insertion point in the younger ShadowRoot.
|
||||
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadow();
|
||||
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadowRoot();
|
||||
if (youngerShadow && GetParent() == containingShadow) {
|
||||
HTMLShadowElement* youngerShadowElement = youngerShadow->GetShadowElement();
|
||||
if (youngerShadowElement) {
|
||||
|
@ -24,7 +24,9 @@ support-files =
|
||||
[test_template_xhtml.html]
|
||||
[test_shadowroot.html]
|
||||
[test_shadowroot_inert_element.html]
|
||||
[test_shadowroot_host.html]
|
||||
[test_shadowroot_style.html]
|
||||
[test_shadowroot_style_multiple_shadow.html]
|
||||
[test_shadowroot_style_order.html]
|
||||
[test_shadowroot_youngershadowroot.html]
|
||||
[test_style_fallback_content.html]
|
||||
|
41
dom/tests/mochitest/webcomponents/test_shadowroot_host.html
Normal file
41
dom/tests/mochitest/webcomponents/test_shadowroot_host.html
Normal file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1083587
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1083587</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1083587">Mozilla Bug 1083587</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<div id="host"></div>
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1083587 **/
|
||||
var hostInDoc = document.getElementById("host");
|
||||
var shadowOne = hostInDoc.createShadowRoot();
|
||||
is(shadowOne.host, hostInDoc);
|
||||
|
||||
var shadowTwo = hostInDoc.createShadowRoot();
|
||||
is(shadowOne.host, hostInDoc);
|
||||
is(shadowTwo.host, hostInDoc);
|
||||
|
||||
var hostNotInDoc = document.createElement("div");
|
||||
var shadowThree = hostNotInDoc.createShadowRoot();
|
||||
is(shadowThree.host, hostNotInDoc);
|
||||
|
||||
var shadowFour = hostNotInDoc.createShadowRoot();
|
||||
is(shadowThree.host, hostNotInDoc);
|
||||
is(shadowFour.host, hostNotInDoc);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1083587
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1083587</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1083587">Mozilla Bug 1083587</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<div id="host"></div>
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1083587 **/
|
||||
var hostInDoc = document.getElementById("host");
|
||||
var shadowOne = hostInDoc.createShadowRoot();
|
||||
is(shadowOne.olderShadowRoot, null);
|
||||
|
||||
var shadowTwo = hostInDoc.createShadowRoot();
|
||||
is(shadowOne.olderShadowRoot, null);
|
||||
is(shadowTwo.olderShadowRoot, shadowOne);
|
||||
|
||||
var hostNotInDoc = document.createElement("div");
|
||||
var shadowThree = hostNotInDoc.createShadowRoot();
|
||||
is(shadowThree.olderShadowRoot, null);
|
||||
|
||||
var shadowFour = hostNotInDoc.createShadowRoot();
|
||||
is(shadowThree.olderShadowRoot, null);
|
||||
is(shadowFour.olderShadowRoot, shadowThree);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -19,6 +19,8 @@ interface ShadowRoot : DocumentFragment
|
||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
||||
[SetterThrows,TreatNullAs=EmptyString]
|
||||
attribute DOMString innerHTML;
|
||||
readonly attribute Element host;
|
||||
readonly attribute ShadowRoot? olderShadowRoot;
|
||||
attribute boolean applyAuthorStyles;
|
||||
readonly attribute StyleSheetList styleSheets;
|
||||
};
|
||||
|
@ -1,5 +0,0 @@
|
||||
[test-014.html]
|
||||
type: testharness
|
||||
[ShadowRoot.olderShadowRoot_T01]
|
||||
expected: FAIL
|
||||
|
Loading…
Reference in New Issue
Block a user