Backed out changeset 29ed3c34af5e (bug 997014)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 17 Apr 2014 08:43:40 +0200
changeset 197452 f5b8418508dd9499225db408128283723e54b55c
parent 197451 72dd3220abbee756db6af6ec9c3f0fa6cc6971ad
child 197453 a7c93f92a08ac0c61b4c806d72b60d869ed5e24c
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs997014
milestone31.0a1
backs out29ed3c34af5ec9cce68ab94694dcc4f23858c8f1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 29ed3c34af5e (bug 997014)
content/canvas/public/moz.build
content/canvas/public/nsICanvasElementExternal.h
content/html/content/public/HTMLCanvasElement.h
content/html/content/src/HTMLCanvasElement.cpp
--- a/content/canvas/public/moz.build
+++ b/content/canvas/public/moz.build
@@ -6,16 +6,17 @@
 
 XPIDL_SOURCES += [
     'nsICanvasGLPrivate.idl',
 ]
 
 XPIDL_MODULE = 'content_canvas'
 
 EXPORTS += [
+    'nsICanvasElementExternal.h',
     'nsICanvasRenderingContextInternal.h',
 ]
 
 EXPORTS.mozilla.ipc += [
     'DocumentRendererChild.h',
     'DocumentRendererParent.h',
 ]
 
new file mode 100644
--- /dev/null
+++ b/content/canvas/public/nsICanvasElementExternal.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 40; 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/. */
+
+#ifndef nsICanvasElementExternal_h___
+#define nsICanvasElementExternal_h___
+
+#include "nsISupports.h"
+#include "GraphicsFilter.h"
+
+class gfxContext;
+class nsIFrame;
+struct gfxRect;
+
+#define NS_ICANVASELEMENTEXTERNAL_IID \
+  { 0x51870f54, 0x6c4c, 0x469a, {0xad, 0x46, 0xf0, 0xa9, 0x8e, 0x32, 0xa7, 0xe2 } }
+
+class nsRenderingContext;
+class nsICanvasRenderingContextInternal;
+
+struct _cairo_surface;
+
+/*
+ * This interface contains methods that are needed outside of the content/layout
+ * modules, specifically widget.  It should eventually go away when we support
+ * libxul builds, and HTMLCanvasElement be used directly.
+ *
+ * Code internal to content/layout should /never/ use this interface; if the
+ * same functionality is needed in both places, two separate methods should be
+ * used.
+ */
+
+class nsICanvasElementExternal : public nsISupports {
+public:
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASELEMENTEXTERNAL_IID)
+
+  enum {
+    RenderFlagPremultAlpha = 0x1
+  };
+
+  /**
+   * Get the size in pixels of this canvas element
+   */
+  NS_IMETHOD_(nsIntSize) GetSizeExternal() = 0;
+
+  /*
+   * Ask the canvas element to tell the contexts to render themselves
+   * to the given gfxContext at the origin of its coordinate space.
+   */
+  NS_IMETHOD RenderContextsExternal(gfxContext *ctx,
+                                    GraphicsFilter aFilter,
+                                    uint32_t aFlags = RenderFlagPremultAlpha) = 0;
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasElementExternal, NS_ICANVASELEMENTEXTERNAL_IID)
+
+#endif /* nsICanvasElementExternal_h___ */
--- a/content/html/content/public/HTMLCanvasElement.h
+++ b/content/html/content/public/HTMLCanvasElement.h
@@ -8,16 +8,17 @@
 
 #include "mozilla/Attributes.h"
 #include "nsIDOMHTMLCanvasElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsSize.h"
 #include "nsError.h"
 
+#include "nsICanvasElementExternal.h"
 #include "mozilla/gfx/Rect.h"
 
 class nsICanvasRenderingContextInternal;
 class nsIDOMFile;
 class nsITimerCallback;
 
 namespace mozilla {
 
@@ -31,16 +32,17 @@ class SourceSurface;
 
 namespace dom {
 
 class FileCallback;
 class HTMLCanvasPrintState;
 class PrintCallback;
 
 class HTMLCanvasElement MOZ_FINAL : public nsGenericHTMLElement,
+                                    public nsICanvasElementExternal,
                                     public nsIDOMHTMLCanvasElement
 {
   enum {
     DEFAULT_CANVAS_WIDTH = 300,
     DEFAULT_CANVAS_HEIGHT = 150
   };
 
   typedef layers::CanvasLayer CanvasLayer;
@@ -155,16 +157,23 @@ public:
   nsICanvasRenderingContextInternal *GetContextAtIndex (int32_t index);
 
   /*
    * Returns true if the canvas context content is guaranteed to be opaque
    * across its entire area.
    */
   bool GetIsOpaque();
 
+  /*
+   * nsICanvasElementExternal -- for use outside of content/layout
+   */
+  NS_IMETHOD_(nsIntSize) GetSizeExternal() MOZ_OVERRIDE;
+  NS_IMETHOD RenderContextsExternal(gfxContext *aContext,
+                                    GraphicsFilter aFilter,
+                                    uint32_t aFlags = RenderFlagPremultAlpha) MOZ_OVERRIDE;
   virtual TemporaryRef<gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr);
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult) MOZ_OVERRIDE;
   nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, int32_t aModType) const MOZ_OVERRIDE;
 
--- a/content/html/content/src/HTMLCanvasElement.cpp
+++ b/content/html/content/src/HTMLCanvasElement.cpp
@@ -126,17 +126,19 @@ HTMLCanvasElement::~HTMLCanvasElement()
 NS_IMPL_CYCLE_COLLECTION_INHERITED_4(HTMLCanvasElement, nsGenericHTMLElement,
                                      mCurrentContext, mPrintCallback,
                                      mPrintState, mOriginalCanvas)
 
 NS_IMPL_ADDREF_INHERITED(HTMLCanvasElement, Element)
 NS_IMPL_RELEASE_INHERITED(HTMLCanvasElement, Element)
 
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLCanvasElement)
-  NS_INTERFACE_TABLE_INHERITED1(HTMLCanvasElement, nsIDOMHTMLCanvasElement)
+  NS_INTERFACE_TABLE_INHERITED2(HTMLCanvasElement,
+                                nsIDOMHTMLCanvasElement,
+                                nsICanvasElementExternal)
 NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLElement)
 
 NS_IMPL_ELEMENT_CLONE(HTMLCanvasElement)
 
 /* virtual */ JSObject*
 HTMLCanvasElement::WrapNode(JSContext* aCx)
 {
   return HTMLCanvasElementBinding::Wrap(aCx, this);
@@ -928,16 +930,31 @@ void
 HTMLCanvasElement::MarkContextClean()
 {
   if (!mCurrentContext)
     return;
 
   mCurrentContext->MarkContextClean();
 }
 
+NS_IMETHODIMP_(nsIntSize)
+HTMLCanvasElement::GetSizeExternal()
+{
+  return GetWidthHeight();
+}
+
+NS_IMETHODIMP
+HTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, GraphicsFilter aFilter, uint32_t aFlags)
+{
+  if (!mCurrentContext)
+    return NS_OK;
+
+  return mCurrentContext->Render(aContext, aFilter, aFlags);
+}
+
 TemporaryRef<SourceSurface>
 HTMLCanvasElement::GetSurfaceSnapshot(bool* aPremultAlpha)
 {
   if (!mCurrentContext)
     return nullptr;
 
   return mCurrentContext->GetSurfaceSnapshot(aPremultAlpha);
 }