Created
May 30, 2012 19:02
-
-
Save jviereck/2838310 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/home/jviereck/dev/hg_mc_callback/content/html/content/src/nsHTMLCanvasElement.cpp: In member function ‘virtual nsresult nsCanvasPrintState::cycleCollection::Unlink(void*)’: | |
/home/jviereck/dev/hg_mc_callback/content/html/content/src/nsHTMLCanvasElement.cpp:115:33: error: invalid use of non-static data member ‘nsCanvasPrintState::mCanvas’ | |
/home/jviereck/dev/hg_mc_callback/content/html/content/src/nsHTMLCanvasElement.cpp:143:54: error: from this location | |
/home/jviereck/dev/hg_mc_callback/content/html/content/src/nsHTMLCanvasElement.cpp:143:86: error: expected primary-expression before ‘)’ token | |
/home/jviereck/dev/hg_mc_callback/content/html/content/src/nsHTMLCanvasElement.cpp:143:86: error: ‘NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR_AMBIGUOUS’ was not declared in this scope | |
/home/jviereck/dev/hg_mc_callback/content/html/content/src/nsHTMLCanvasElement.cpp:144:3: error: expected ‘;’ before ‘tmp’ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -*- Mode: C++; 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 "nsHTMLCanvasElement.h" | |
#include "mozilla/Base64.h" | |
#include "mozilla/CheckedInt.h" | |
#include "nsNetUtil.h" | |
#include "prmem.h" | |
#include "nsDOMFile.h" | |
#include "nsIScriptSecurityManager.h" | |
#include "nsIXPConnect.h" | |
#include "jsapi.h" | |
#include "nsContentUtils.h" | |
#include "nsJSUtils.h" | |
#include "nsMathUtils.h" | |
#include "nsStreamUtils.h" | |
#include "mozilla/Preferences.h" | |
#include "mozilla/Telemetry.h" | |
#include "nsFrameManager.h" | |
#include "nsDisplayList.h" | |
#include "ImageLayers.h" | |
#include "BasicLayers.h" | |
#include "imgIEncoder.h" | |
#include "nsITimer.h" | |
#include "nsAsyncDOMEvent.h" | |
#include "nsIWritablePropertyBag2.h" | |
#include "nsIDOMHTMLCanvasElement.h" | |
#define DEFAULT_CANVAS_WIDTH 300 | |
#define DEFAULT_CANVAS_HEIGHT 150 | |
using namespace mozilla; | |
using namespace mozilla::dom; | |
using namespace mozilla::layers; | |
#define NS_ICANVASPRINTSTATE_IID \ | |
{0x8d5fb8a0, 0x7782, 0x11e1, { 0xb0, 0xc4, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x67 }} | |
class nsCanvasPrintState : public nsICanvasPrintState | |
{ | |
public: | |
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASPRINTSTATE_IID) | |
nsCanvasPrintState( | |
nsHTMLCanvasElement *aCanvas, | |
nsICanvasRenderingContextInternal *aContext, | |
nsITimerCallback *aCallback) | |
: mIsDone(false), mIsAborted(false), | |
mCanvas(aCanvas), mContext(aContext), mCallback(aCallback) { | |
} | |
NS_IMETHOD GetContext(nsISupports **context) | |
{ | |
printf("=== GetContext2\n"); | |
NS_ADDREF(*context = mContext); | |
return NS_OK; | |
} | |
NS_IMETHOD Done() | |
{ | |
printf("CPS::Done\n"); | |
Finalize(false); | |
return NS_OK; | |
} | |
NS_IMETHOD Abort() | |
{ | |
printf("CPS::Abort\n"); | |
Finalize(true); | |
(new nsAsyncDOMEvent( | |
mCanvas->GetDocument(), NS_LITERAL_STRING("printCanvasAbort"), true, true) | |
)->RunDOMEventWhenSafe(); | |
return NS_OK; | |
} | |
void Finalize(bool aAborted) | |
{ | |
if (!mIsDone) { | |
mIsDone = true; | |
mIsAborted = aAborted; | |
if (mCallback) { | |
mCallback->Notify(nsnull); | |
} | |
Reset(); | |
} | |
} | |
void Reset() | |
{ | |
printf("=== nsCanvasPrintState::Reset()\n"); | |
mContext = nsnull; | |
mCallback = nsnull; | |
} | |
bool mIsDone; | |
bool mIsAborted; | |
// CC | |
NS_DECL_CYCLE_COLLECTING_ISUPPORTS | |
NS_DECL_CYCLE_COLLECTION_CLASS(nsCanvasPrintState) | |
private: | |
~nsCanvasPrintState() | |
{ | |
printf("--- nsCanvasPrintState::Destory\n"); | |
} | |
nsRefPtr<nsHTMLCanvasElement> mCanvas; | |
nsCOMPtr<nsICanvasRenderingContextInternal> mContext; | |
nsCOMPtr<nsITimerCallback> mCallback; | |
protected: | |
/* additional members */ | |
}; | |
NS_DEFINE_STATIC_IID_ACCESSOR(nsCanvasPrintState, NS_ICANVASPRINTSTATE_IID) | |
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCanvasPrintState) | |
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCanvasPrintState) | |
DOMCI_DATA(CanvasPrintState, nsCanvasPrintState) | |
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCanvasPrintState) | |
NS_INTERFACE_MAP_ENTRY(nsISupports) | |
NS_INTERFACE_MAP_ENTRY(nsICanvasPrintState) | |
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CanvasPrintState) | |
NS_INTERFACE_MAP_END | |
NS_IMPL_CYCLE_COLLECTION_CLASS(nsCanvasPrintState) | |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCanvasPrintState) | |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mCanvas, nsIDOMHTMLCanvasElement) | |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContext) | |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCallback) | |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END | |
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCanvasPrintState); | |
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR_AMBIGUOUS(mCanvas, nsIDOMHTMLCanvasElement) | |
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContext) | |
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCallback) | |
NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment