Backed out changeset f91e5fbb9520 (bug 1557983) as requested by dev.

This commit is contained in:
Butkovits Atila 2020-07-11 12:11:20 +03:00
Родитель 91e46d309f
Коммит 222d260b21
2 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@ -381,6 +381,37 @@ static nsresult EnsureSettingsHasPrinterNameSet(
#endif
}
static bool DocHasPrintCallbackCanvas(Document& aDoc) {
Element* root = aDoc.GetRootElement();
if (!root) {
return false;
}
// FIXME(emilio): This doesn't account for shadow dom and it's unnecessarily
// inefficient. Though I guess it doesn't really matter.
RefPtr<nsContentList> canvases =
NS_GetContentList(root, kNameSpaceID_XHTML, u"canvas"_ns);
uint32_t canvasCount = canvases->Length(true);
for (uint32_t i = 0; i < canvasCount; ++i) {
auto* canvas = HTMLCanvasElement::FromNodeOrNull(canvases->Item(i, false));
if (canvas && canvas->GetMozPrintCallback()) {
return true;
}
}
bool result = false;
auto checkSubDoc = [&result](Document& aSubDoc) {
if (DocHasPrintCallbackCanvas(aSubDoc)) {
result = true;
return CallState::Stop;
}
return CallState::Continue;
};
aDoc.EnumerateSubDocuments(checkSubDoc);
return result;
}
//-------------------------------------------------------
NS_IMPL_ISUPPORTS(nsPrintJob, nsIWebProgressListener, nsISupportsWeakReference,
@ -450,6 +481,8 @@ nsresult nsPrintJob::Initialize(nsIDocumentViewerPrint* aDocViewerPrint,
}
}
mHasMozPrintCallback = DocHasPrintCallbackCanvas(*aOriginalDoc);
return NS_OK;
}

Просмотреть файл

@ -131,6 +131,12 @@ class nsPrintJob final : public nsIObserver,
void TurnScriptingOn(bool aDoTurnOn);
/**
* Checks to see if the document this print engine is associated with has any
* canvases that have a mozPrintCallback.
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement#Properties
*/
bool HasPrintCallbackCanvas() { return mHasMozPrintCallback; }
bool PrePrintPage();
bool PrintPage(nsPrintObject* aPOect, bool& aInRange);
bool DonePrintingPages(nsPrintObject* aPO, nsresult aResult);