mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 23:08:39 +09:00
Issue #2135 - Bug 1425864: Ensure printing documents which have shadow DOM works
This commit is contained in:
parent
9f0fb9c16e
commit
015148fcc3
3 changed files with 47 additions and 2 deletions
|
|
@ -101,6 +101,23 @@ ShadowRoot::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
return mozilla::dom::ShadowRootBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
ShadowRoot::CloneInternalDataFrom(ShadowRoot* aOther)
|
||||
{
|
||||
size_t sheetCount = aOther->SheetCount();
|
||||
for (size_t i = 0; i < sheetCount; ++i) {
|
||||
StyleSheet* sheet = aOther->SheetAt(i);
|
||||
if (sheet && sheet->IsApplicable()) {
|
||||
// TODO: Remove AsGecko() call once Stylo is removed.
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->AsGecko()->Clone(nullptr, nullptr, nullptr, nullptr);
|
||||
if (clonedSheet) {
|
||||
AppendStyleSheet(*clonedSheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShadowRoot*
|
||||
ShadowRoot::FromNode(nsINode* aNode)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,6 +64,11 @@ public:
|
|||
return &DocumentOrShadowRoot::EnsureDOMStyleSheets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones internal state, for example stylesheets, of aOther to 'this'.
|
||||
*/
|
||||
void CloneInternalDataFrom(ShadowRoot* aOther);
|
||||
|
||||
/**
|
||||
* Distributes all the explicit children of the pool host to the content
|
||||
* insertion points in this ShadowRoot.
|
||||
|
|
|
|||
|
|
@ -653,8 +653,31 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
|||
}
|
||||
}
|
||||
|
||||
if (aDeep && !aClone && aNode->IsElement()) {
|
||||
if (ShadowRoot* shadowRoot = aNode->AsElement()->GetShadowRoot()) {
|
||||
if (aDeep && aNode->IsElement()) {
|
||||
ShadowRoot* shadowRoot = aNode->AsElement()->GetShadowRoot();
|
||||
if (!shadowRoot) {
|
||||
// Nothing to do here.
|
||||
} else if (aClone && clone->OwnerDoc()->IsStaticDocument()) {
|
||||
ShadowRootInit init;
|
||||
init.mMode = shadowRoot->Mode();
|
||||
RefPtr<ShadowRoot> newShadowRoot =
|
||||
clone->AsElement()->AttachShadow(init, aError);
|
||||
if (NS_WARN_IF(aError.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
newShadowRoot->CloneInternalDataFrom(shadowRoot);
|
||||
for (nsIContent* originalChild = shadowRoot->GetFirstChild();
|
||||
originalChild;
|
||||
originalChild = originalChild->GetNextSibling()) {
|
||||
nsCOMPtr<nsINode> child = CloneAndAdopt(originalChild, aClone, aDeep, nodeInfoManager,
|
||||
aReparentScope, aNodesWithProperties, newShadowRoot,
|
||||
aError);
|
||||
if (NS_WARN_IF(aError.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
} else if (!aClone) {
|
||||
nsCOMPtr<nsINode> child = CloneAndAdopt(shadowRoot, aClone, aDeep, nodeInfoManager,
|
||||
aReparentScope, aNodesWithProperties, clone,
|
||||
aError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue