Skip to content

Commit

Permalink
Bug 1557983. Remove nsPrintJob::HasPrintCallbackCanvas.
Browse files Browse the repository at this point in the history
After refactoring the 'beforeprint'/'afterprint' code, this method is not used
any more.

Differential Revision: https://phabricator.services.mozilla.com/D34281
  • Loading branch information
jwatt committed Jul 11, 2020
1 parent a90be56 commit 3f66c3c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
33 changes: 0 additions & 33 deletions layout/printing/nsPrintJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,37 +401,6 @@ 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,
Expand Down Expand Up @@ -501,8 +470,6 @@ nsresult nsPrintJob::Initialize(nsIDocumentViewerPrint* aDocViewerPrint,
}
}

mHasMozPrintCallback = DocHasPrintCallbackCanvas(*aOriginalDoc);

return NS_OK;
}

Expand Down
6 changes: 0 additions & 6 deletions layout/printing/nsPrintJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ 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);
Expand Down

0 comments on commit 3f66c3c

Please sign in to comment.