mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1425864 - Ensure printing documents which have ShadowDOM works, r=mrbkap,emilio
This commit is contained in:
parent
6042a9738b
commit
3faf40c897
@ -94,6 +94,24 @@ ShadowRoot::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||||||
return mozilla::dom::ShadowRootBinding::Wrap(aCx, this, 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->IsApplicable()) {
|
||||||
|
RefPtr<StyleSheet> clonedSheet =
|
||||||
|
sheet->Clone(nullptr, nullptr, nullptr, nullptr);
|
||||||
|
if (clonedSheet) {
|
||||||
|
AppendStyleSheet(*clonedSheet.get());
|
||||||
|
Servo_AuthorStyles_AppendStyleSheet(mServoStyles.get(),
|
||||||
|
clonedSheet->AsServo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadowRoot::AddSlot(HTMLSlotElement* aSlot)
|
ShadowRoot::AddSlot(HTMLSlotElement* aSlot)
|
||||||
{
|
{
|
||||||
|
@ -89,6 +89,10 @@ public:
|
|||||||
return &DocumentOrShadowRoot::EnsureDOMStyleSheets();
|
return &DocumentOrShadowRoot::EnsureDOMStyleSheets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones internal state, for example stylesheets, of aOther to 'this'.
|
||||||
|
*/
|
||||||
|
void CloneInternalDataFrom(ShadowRoot* aOther);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -657,14 +657,42 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aDeep && !aClone && aNode->IsElement()) {
|
if (aDeep && aNode->IsElement()) {
|
||||||
if (ShadowRoot* shadowRoot = aNode->AsElement()->GetShadowRoot()) {
|
if (aClone) {
|
||||||
nsCOMPtr<nsINode> child =
|
if (clone->OwnerDoc()->IsStaticDocument()) {
|
||||||
CloneAndAdopt(shadowRoot, aClone, aDeep, nodeInfoManager,
|
ShadowRoot* originalShadowRoot = aNode->AsElement()->GetShadowRoot();
|
||||||
aReparentScope, aNodesWithProperties, clone,
|
if (originalShadowRoot) {
|
||||||
aError);
|
ShadowRootInit init;
|
||||||
if (NS_WARN_IF(aError.Failed())) {
|
init.mMode = originalShadowRoot->Mode();
|
||||||
return nullptr;
|
RefPtr<ShadowRoot> newShadowRoot =
|
||||||
|
clone->AsElement()->AttachShadow(init, aError);
|
||||||
|
if (NS_WARN_IF(aError.Failed())) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
newShadowRoot->CloneInternalDataFrom(originalShadowRoot);
|
||||||
|
for (nsIContent* origChild = originalShadowRoot->GetFirstChild();
|
||||||
|
origChild;
|
||||||
|
origChild = origChild->GetNextSibling()) {
|
||||||
|
nsCOMPtr<nsINode> child =
|
||||||
|
CloneAndAdopt(origChild, aClone, aDeep, nodeInfoManager,
|
||||||
|
aReparentScope, aNodesWithProperties, newShadowRoot,
|
||||||
|
aError);
|
||||||
|
if (NS_WARN_IF(aError.Failed())) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ShadowRoot* shadowRoot = aNode->AsElement()->GetShadowRoot()) {
|
||||||
|
nsCOMPtr<nsINode> child =
|
||||||
|
CloneAndAdopt(shadowRoot, aClone, aDeep, nodeInfoManager,
|
||||||
|
aReparentScope, aNodesWithProperties, clone,
|
||||||
|
aError);
|
||||||
|
if (NS_WARN_IF(aError.Failed())) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user