Permalink
Browse files

Bug 800556; remove nsIDOMCanvasRenderingContext2D; r=Ms2ger,sr=bz

--HG--
extra : rebase_source : 461ff127a453116f3364f4ba1e414cc527f195bd
  • Loading branch information...
1 parent fb89426 commit c18ca9977a84b9fbd4dddb55dae64c94a4bef07d @nrc nrc committed Nov 14, 2012
Oops, something went wrong.
@@ -11,9 +11,8 @@
#include "mozilla/RefPtr.h"
#include "nsColor.h"
#include "nsHTMLCanvasElement.h"
-#include "CanvasUtils.h"
-#include "nsHTMLImageElement.h"
#include "nsHTMLVideoElement.h"
+#include "CanvasUtils.h"
#include "gfxFont.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/ImageData.h"
@@ -24,6 +23,8 @@
#define NS_CANVASPATTERNAZURE_PRIVATE_IID \
{0xc9bacc25, 0x28da, 0x421e, {0x9a, 0x4b, 0xbb, 0xd6, 0x93, 0x05, 0x12, 0xbc}}
+class nsIDOMXULElement;
+
namespace mozilla {
namespace gfx {
struct Rect;
@@ -127,7 +128,6 @@ class CanvasRenderingContext2DUserData;
** CanvasRenderingContext2D
**/
class CanvasRenderingContext2D :
- public nsIDOMCanvasRenderingContext2D,
public nsICanvasRenderingContextInternal,
public nsWrapperCache
{
@@ -428,8 +428,7 @@ typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
{
return CurrentState().dashOffset;
}
-
- void SetMozDashOffset(double mozDashOffset, mozilla::ErrorResult& error);
+ void SetMozDashOffset(double mozDashOffset);
void GetMozTextStyle(nsAString& mozTextStyle)
{
@@ -496,11 +495,13 @@ typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
// nsISupports interface + CC
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(CanvasRenderingContext2D,
- nsIDOMCanvasRenderingContext2D)
+ NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(CanvasRenderingContext2D)
- // nsIDOMCanvasRenderingContext2D interface
- NS_DECL_NSIDOMCANVASRENDERINGCONTEXT2D
+ enum CanvasMultiGetterType {
+ CMG_STYLE_STRING = 0,
+ CMG_STYLE_PATTERN = 1,
+ CMG_STYLE_GRADIENT = 2
+ };
enum Style {
STYLE_STROKE = 0,
@@ -543,6 +544,11 @@ typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
uint32_t aWidth, uint32_t aHeight,
JSObject** aRetval);
+ nsresult PutImageData_explicit(int32_t x, int32_t y, uint32_t w, uint32_t h,
+ unsigned char *aData, uint32_t aDataLen,
+ bool hasDirtyRect, int32_t dirtyX, int32_t dirtyY,
+ int32_t dirtyWidth, int32_t dirtyHeight);
+
/**
* Internal method to complete initialisation, expects mTarget to have been set
*/
@@ -583,7 +589,6 @@ typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
CurrentState().SetPatternStyle(whichStyle, pattern);
}
- void SetStyleFromStringOrInterface(const nsAString& aStr, nsISupports *aInterface, Style aWhichStyle);
nsISupports* GetStyleAsStringOrInterface(nsAString& aStr, CanvasMultiGetterType& aType, Style aWhichStyle);
// Returns whether a color was successfully parsed.
@@ -664,32 +669,6 @@ typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
return CurrentState().font;
}
- static bool
- ToHTMLImageOrCanvasOrVideoElement(nsIDOMElement* html,
- HTMLImageOrCanvasOrVideoElement& element)
- {
- nsCOMPtr<nsIContent> content = do_QueryInterface(html);
- if (content) {
- if (content->IsHTML(nsGkAtoms::canvas)) {
- element.SetAsHTMLCanvasElement() =
- static_cast<nsHTMLCanvasElement*>(html);
- return true;
- }
- if (content->IsHTML(nsGkAtoms::img)) {
- element.SetAsHTMLImageElement() =
- static_cast<nsHTMLImageElement*>(html);
- return true;
- }
- if (content->IsHTML(nsGkAtoms::video)) {
- element.SetAsHTMLVideoElement() =
- static_cast<nsHTMLVideoElement*>(html);
- return true;
- }
- }
-
- return false;
- }
-
// Member vars
int32_t mWidth, mHeight;
@@ -19,6 +19,7 @@ LIBXUL_LIBRARY = 1
EXPORTS_NAMESPACES = mozilla/dom
EXPORTS_mozilla/dom = \
+ CanvasUtils.h \
CanvasRenderingContext2D.h \
ImageData.h \
$(NULL)
@@ -14,8 +14,7 @@
#include "nsNetUtil.h"
#include "nsDOMFile.h"
-#include "nsICanvasRenderingContextInternal.h"
-#include "nsIDOMCanvasRenderingContext2D.h"
+#include "mozilla/dom/CanvasRenderingContext2D.h"
#include "nsIScriptSecurityManager.h"
#include "nsIXPConnect.h"
#include "jsapi.h"
@@ -43,6 +42,9 @@ using namespace mozilla::layers;
namespace {
+typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
+HTMLImageOrCanvasOrVideoElement;
+
class ToBlobRunnable : public nsRunnable
{
public:
@@ -311,7 +313,6 @@ nsHTMLCanvasElement::GetOriginalCanvas()
return mOriginalCanvas ? mOriginalCanvas.get() : this;
}
-
nsresult
nsHTMLCanvasElement::CopyInnerTo(nsGenericElement* aDest)
{
@@ -322,12 +323,17 @@ nsHTMLCanvasElement::CopyInnerTo(nsGenericElement* aDest)
nsHTMLCanvasElement* self = const_cast<nsHTMLCanvasElement*>(this);
dest->mOriginalCanvas = self;
+ HTMLImageOrCanvasOrVideoElement element;
+ element.SetAsHTMLCanvasElement() = this;
nsCOMPtr<nsISupports> cxt;
dest->GetContext(NS_LITERAL_STRING("2d"), JSVAL_VOID, getter_AddRefs(cxt));
- nsCOMPtr<nsIDOMCanvasRenderingContext2D> context2d = do_QueryInterface(cxt);
+ nsRefPtr<CanvasRenderingContext2D> context2d =
+ static_cast<CanvasRenderingContext2D*>(cxt.get());
if (context2d && !self->mPrintCallback) {
- context2d->DrawImage(self,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
+ ErrorResult err;
+ context2d->DrawImage(element,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, err);
+ rv = err.ErrorCode();
}
}
return rv;
@@ -691,6 +697,16 @@ nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
{
NS_ENSURE_ARG(aContext);
+ if (aContextId.EqualsLiteral("2d")) {
+ Telemetry::Accumulate(Telemetry::CANVAS_2D_USED, 1);
+ nsRefPtr<CanvasRenderingContext2D> ctx =
+ new CanvasRenderingContext2D();
+
+ ctx->SetCanvasElement(this);
+ ctx.forget(aContext);
+ return NS_OK;
+ }
+
NS_ConvertUTF16toUTF8 ctxId(aContextId);
// check that ctxId is clamped to A-Za-z0-9_-
Oops, something went wrong.

0 comments on commit c18ca99

Please sign in to comment.