summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/html/HTMLCanvasElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/HTMLCanvasElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLCanvasElement.cpp60
1 files changed, 55 insertions, 5 deletions
diff --git a/Source/WebCore/html/HTMLCanvasElement.cpp b/Source/WebCore/html/HTMLCanvasElement.cpp
index e67cbf9..35ce549 100644
--- a/Source/WebCore/html/HTMLCanvasElement.cpp
+++ b/Source/WebCore/html/HTMLCanvasElement.cpp
@@ -2,6 +2,9 @@
* Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
* Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
+ * Copyright (c) 2012, The Linux Foundation All rights reserved.
+ * Copyright (C) 2011, 2012 Sony Ericsson Mobile Communications AB
+ * Copyright (C) 2012 Sony Mobile Communications AB
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -114,6 +117,11 @@ HTMLCanvasElement::~HTMLCanvasElement()
HashSet<CanvasObserver*>::iterator end = m_observers.end();
for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end; ++it)
(*it)->canvasDestroyed(this);
+
+#if ENABLE(WEBGL)
+ document()->unregisterForDocumentActivationCallbacks(this);
+ document()->unregisterForDocumentSuspendCallbacks(this);
+#endif
}
void HTMLCanvasElement::parseMappedAttribute(Attribute* attr)
@@ -203,6 +211,11 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
if (m_context) {
// Need to make sure a RenderLayer and compositing layer get created for the Canvas
setNeedsStyleRecalc(SyntheticStyleChange);
+#if PLATFORM(ANDROID)
+ document()->registerForDocumentActivationCallbacks(this);
+ document()->registerForDocumentSuspendCallbacks(this);
+ document()->setContainsWebGLContent(true);
+#endif
}
}
return m_context.get();
@@ -308,6 +321,11 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
if (is3D())
static_cast<WebGLRenderingContext*>(m_context.get())->markLayerComposited();
#endif
+#if ENABLE(DASHBOARD_SUPPORT)
+ Settings* settings = document()->settings();
+ if (settings && settings->usesDashboardBackwardCompatibilityMode())
+ setIeForbidsInsertHTML();
+#endif
}
#if ENABLE(WEBGL)
@@ -315,6 +333,40 @@ bool HTMLCanvasElement::is3D() const
{
return m_context && m_context->is3d();
}
+
+#if PLATFORM(ANDROID)
+void HTMLCanvasElement::documentDidBecomeActive()
+{
+ if (m_context && m_context->is3d()) {
+ WebGLRenderingContext* context3D = static_cast<WebGLRenderingContext*>(m_context.get());
+ context3D->recreateSurface();
+ }
+}
+
+void HTMLCanvasElement::documentWillBecomeInactive()
+{
+ if (m_context && m_context->is3d()) {
+ WebGLRenderingContext* context3D = static_cast<WebGLRenderingContext*>(m_context.get());
+ context3D->releaseSurface();
+ }
+}
+
+void HTMLCanvasElement::documentWasSuspended()
+{
+ if (m_context && m_context->is3d()) {
+ WebGLRenderingContext* context3D = static_cast<WebGLRenderingContext*>(m_context.get());
+ context3D->releaseSurface();
+ }
+}
+
+void HTMLCanvasElement::documentWillResume()
+{
+ if (m_context && m_context->is3d()) {
+ WebGLRenderingContext* context3D = static_cast<WebGLRenderingContext*>(m_context.get());
+ context3D->recreateSurface();
+ }
+}
+#endif
#endif
void HTMLCanvasElement::makeRenderingResultsAvailable()
@@ -360,9 +412,7 @@ String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit
if (mimeType.isNull() || !MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(lowercaseMimeType))
lowercaseMimeType = "image/png";
-#if USE(CG) || (USE(SKIA) && !PLATFORM(ANDROID))
- // FIXME: Consider using this code path on Android. http://b/4572024
- // Try to get ImageData first, as that may avoid lossy conversions.
+#if USE(CG) || (USE(SKIA) || PLATFORM(ANDROID))
RefPtr<ImageData> imageData = getImageData();
if (imageData)
@@ -423,9 +473,9 @@ IntSize HTMLCanvasElement::convertToValidDeviceSize(float width, float height) c
return IntSize(width, height);
}
-const SecurityOrigin& HTMLCanvasElement::securityOrigin() const
+SecurityOrigin* HTMLCanvasElement::securityOrigin() const
{
- return *document()->securityOrigin();
+ return document()->securityOrigin();
}
CSSStyleSelector* HTMLCanvasElement::styleSelector()