Bug 1403819 - Remove nsIDOMHTMLCanvasElement; r=bz

Removes the XPCOM interface for nsIDOMHTMLCanvasElement, replacing it
with binding class usage.

MozReview-Commit-ID: DQJhqGlY8U6
This commit is contained in:
Kyle Machulis 2017-09-28 12:17:07 -07:00
parent bb9e1eadc9
commit 6a4d37f8bb
9 changed files with 24 additions and 67 deletions

View File

@ -50,7 +50,6 @@
#include "nsViewManager.h"
#include "nsIDOMHTMLCanvasElement.h"
#include "nsLayoutUtils.h"
#include "nsComputedDOMStyle.h"
#include "nsIPresShell.h"
@ -106,6 +105,7 @@
#include "nsNetUtil.h"
#include "nsDocument.h"
#include "HTMLImageElement.h"
#include "HTMLCanvasElement.h"
#include "mozilla/css/ImageLoader.h"
#include "mozilla/layers/APZCTreeManager.h" // for layers::ZoomToRectBehavior
#include "mozilla/dom/Promise.h"
@ -1624,26 +1624,19 @@ nsDOMWindowUtils::GetTranslationNodes(nsIDOMNode* aRoot,
}
static already_AddRefed<DataSourceSurface>
CanvasToDataSourceSurface(nsIDOMHTMLCanvasElement* aCanvas)
CanvasToDataSourceSurface(HTMLCanvasElement* aCanvas)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aCanvas);
if (!node) {
return nullptr;
}
MOZ_ASSERT(node->IsElement(),
"An nsINode that implements nsIDOMHTMLCanvasElement should "
"be an element.");
MOZ_ASSERT(aCanvas);
nsLayoutUtils::SurfaceFromElementResult result =
nsLayoutUtils::SurfaceFromElement(node->AsElement());
nsLayoutUtils::SurfaceFromElement(aCanvas);
MOZ_ASSERT(result.GetSourceSurface());
return result.GetSourceSurface()->GetDataSurface();
}
NS_IMETHODIMP
nsDOMWindowUtils::CompareCanvases(nsIDOMHTMLCanvasElement *aCanvas1,
nsIDOMHTMLCanvasElement *aCanvas2,
nsDOMWindowUtils::CompareCanvases(nsISupports *aCanvas1,
nsISupports *aCanvas2,
uint32_t* aMaxDifference,
uint32_t* retVal)
{
@ -1652,8 +1645,17 @@ nsDOMWindowUtils::CompareCanvases(nsIDOMHTMLCanvasElement *aCanvas1,
retVal == nullptr)
return NS_ERROR_FAILURE;
RefPtr<DataSourceSurface> img1 = CanvasToDataSourceSurface(aCanvas1);
RefPtr<DataSourceSurface> img2 = CanvasToDataSourceSurface(aCanvas2);
nsCOMPtr<nsIContent> contentCanvas1 = do_QueryInterface(aCanvas1);
nsCOMPtr<nsIContent> contentCanvas2 = do_QueryInterface(aCanvas2);
auto canvas1 = HTMLCanvasElement::FromContentOrNull(contentCanvas1);
auto canvas2 = HTMLCanvasElement::FromContentOrNull(contentCanvas2);
if (!canvas1 || !canvas2) {
return NS_ERROR_FAILURE;
}
RefPtr<DataSourceSurface> img1 = CanvasToDataSourceSurface(canvas1);
RefPtr<DataSourceSurface> img2 = CanvasToDataSourceSurface(canvas2);
DataSourceSurface::ScopedMap map1(img1, DataSourceSurface::READ);
DataSourceSurface::ScopedMap map2(img2, DataSourceSurface::READ);

View File

@ -1819,7 +1819,7 @@ WebGLContext::UpdateContextLossStatus()
if (mCanvasElement) {
nsContentUtils::DispatchTrustedEvent(
mCanvasElement->OwnerDoc(),
static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement),
static_cast<nsIContent*>(mCanvasElement),
kEventName,
kCanBubble,
kIsCancelable,
@ -1887,7 +1887,7 @@ WebGLContext::UpdateContextLossStatus()
if (mCanvasElement) {
nsContentUtils::DispatchTrustedEvent(
mCanvasElement->OwnerDoc(),
static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement),
static_cast<nsIContent*>(mCanvasElement),
NS_LITERAL_STRING("webglcontextrestored"),
true,
true);

View File

@ -403,9 +403,7 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLCanvasElement, nsGenericHTMLElement,
mPrintState, mOriginalCanvas,
mOffscreenCanvas)
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLCanvasElement,
nsGenericHTMLElement,
nsIDOMHTMLCanvasElement)
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLCanvasElement, nsGenericHTMLElement)
NS_IMPL_ELEMENT_CLONE(HTMLCanvasElement)
@ -459,10 +457,6 @@ HTMLCanvasElement::GetWidthHeight()
return size;
}
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(HTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(HTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
NS_IMPL_BOOL_ATTR(HTMLCanvasElement, MozOpaque, moz_opaque)
nsresult
HTMLCanvasElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue,

View File

@ -9,7 +9,6 @@
#include "mozilla/Attributes.h"
#include "mozilla/WeakPtr.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMHTMLCanvasElement.h"
#include "nsIObserver.h"
#include "nsGenericHTMLElement.h"
#include "nsGkAtoms.h"
@ -116,7 +115,6 @@ protected:
};
class HTMLCanvasElement final : public nsGenericHTMLElement,
public nsIDOMHTMLCanvasElement,
public CanvasRenderingContextHelper
{
enum {
@ -138,9 +136,6 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMHTMLCanvasElement
NS_DECL_NSIDOMHTMLCANVASELEMENT
// CC
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLCanvasElement,
nsGenericHTMLElement)

View File

@ -34,7 +34,6 @@ interface nsICycleCollectorListener;
interface nsIDOMNode;
interface nsIDOMNodeList;
interface nsIDOMElement;
interface nsIDOMHTMLCanvasElement;
interface nsIDOMEvent;
interface nsIPreloadedStyleSheet;
interface nsITransferable;
@ -928,8 +927,8 @@ interface nsIDOMWindowUtils : nsISupports {
*
* This method requires chrome privileges.
*/
uint32_t compareCanvases(in nsIDOMHTMLCanvasElement aCanvas1,
in nsIDOMHTMLCanvasElement aCanvas2,
uint32_t compareCanvases(in nsISupports aCanvas1,
in nsISupports aCanvas2,
out unsigned long aMaxDifference);
/**

View File

@ -9,7 +9,6 @@ with Files("**"):
XPIDL_SOURCES += [
'nsIDOMHTMLBaseElement.idl',
'nsIDOMHTMLCanvasElement.idl',
'nsIDOMHTMLCollection.idl',
'nsIDOMHTMLDocument.idl',
'nsIDOMHTMLElement.idl',

View File

@ -1,29 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMHTMLElement.idl"
/**
* The nsIDOMHTMLCanvasElement interface is the interface to a HTML
* <canvas> element.
*
* For more information on this interface, please see
* http://www.whatwg.org/specs/web-apps/current-work/#graphics
*
* @status UNDER_DEVELOPMENT
*/
interface nsIDOMBlob;
interface nsIVariant;
interface nsIInputStreamCallback;
[uuid(4e8f1316-b601-471d-8f44-3c650d91ee9b)]
interface nsIDOMHTMLCanvasElement : nsISupports
{
attribute unsigned long width;
attribute unsigned long height;
attribute boolean mozOpaque;
};

View File

@ -347,8 +347,8 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMHTMLCanvasElement> domcanvas(do_QueryInterface(aCanvas));
dom::HTMLCanvasElement * canvas = ((dom::HTMLCanvasElement*)domcanvas.get());
nsCOMPtr<nsIContent> content(do_QueryInterface(aCanvas));
auto canvas = dom::HTMLCanvasElement::FromContentOrNull(content);
if (!canvas) {
return NS_ERROR_FAILURE;
}

View File

@ -46,7 +46,6 @@
#include "nsIDOMGeoPositionError.h"
#include "nsIDOMHistory.h"
#include "nsIDOMHTMLBaseElement.h"
#include "nsIDOMHTMLCanvasElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLElement.h"
@ -154,7 +153,6 @@
#include "mozilla/dom/HTMLAreaElementBinding.h"
#include "mozilla/dom/HTMLBaseElementBinding.h"
#include "mozilla/dom/HTMLButtonElementBinding.h"
#include "mozilla/dom/HTMLCanvasElementBinding.h"
#include "mozilla/dom/HTMLCollectionBinding.h"
#include "mozilla/dom/HTMLDocumentBinding.h"
#include "mozilla/dom/HTMLElementBinding.h"
@ -317,7 +315,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMGeoPositionError, PositionError),
DEFINE_SHIM(History),
DEFINE_SHIM(HTMLBaseElement),
DEFINE_SHIM(HTMLCanvasElement),
DEFINE_SHIM(HTMLCollection),
DEFINE_SHIM(HTMLDocument),
DEFINE_SHIM(HTMLElement),