Diff
Modified: trunk/Source/WebCore/ChangeLog (218506 => 218507)
--- trunk/Source/WebCore/ChangeLog 2017-06-19 20:54:14 UTC (rev 218506)
+++ trunk/Source/WebCore/ChangeLog 2017-06-19 21:01:19 UTC (rev 218507)
@@ -1,3 +1,19 @@
+2017-06-19 Sam Weinig <s...@webkit.org>
+
+ [WebIDL] Remove custom binding for Document.getCSSCanvasContext()
+ https://bugs.webkit.org/show_bug.cgi?id=173516
+
+ Reviewed by Chris Dumez.
+
+ * bindings/js/JSDocumentCustom.cpp:
+ (WebCore::JSDocument::visitAdditionalChildren):
+ (WebCore::JSDocument::getCSSCanvasContext): Deleted.
+ * dom/Document.cpp:
+ (WebCore::Document::getCSSCanvasContext):
+ * dom/Document.h:
+ * dom/Document.idl:
+ Use a Variant to pass the context and type to the bindings.
+
2017-06-19 Youenn Fablet <you...@apple.com>
[WebRTC] Prevent capturing at unconventional resolutions when using the SW encoder on Mac
Modified: trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp (218506 => 218507)
--- trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp 2017-06-19 20:54:14 UTC (rev 218506)
+++ trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp 2017-06-19 21:01:19 UTC (rev 218507)
@@ -20,33 +20,15 @@
#include "config.h"
#include "JSDocument.h"
-#include "ExceptionCode.h"
#include "Frame.h"
-#include "FrameLoader.h"
-#include "HTMLDocument.h"
-#include "JSCanvasRenderingContext2D.h"
-#include "JSDOMConvertNumbers.h"
#include "JSDOMWindowCustom.h"
#include "JSHTMLDocument.h"
-#include "JSLocation.h"
#include "JSXMLDocument.h"
#include "NodeTraversal.h"
#include "SVGDocument.h"
#include "ScriptController.h"
#include "XMLDocument.h"
-#include <wtf/GetPtr.h>
-#if ENABLE(WEBGL)
-#include "JSWebGLRenderingContext.h"
-#if ENABLE(WEBGL2)
-#include "JSWebGL2RenderingContext.h"
-#endif
-#endif
-
-#if ENABLE(WEBGPU)
-#include "JSWebGPURenderingContext.h"
-#endif
-
#if ENABLE(TOUCH_EVENTS)
#include "JSTouch.h"
#include "JSTouchList.h"
@@ -112,6 +94,11 @@
return toJSNewlyCreated(state, globalObject, Ref<Document>(document));
}
+void JSDocument::visitAdditionalChildren(SlotVisitor& visitor)
+{
+ visitor.addOpaqueRoot(static_cast<ScriptExecutionContext*>(&wrapped()));
+}
+
#if ENABLE(TOUCH_EVENTS)
JSValue JSDocument::createTouchList(ExecState& state)
{
@@ -131,45 +118,5 @@
}
#endif
-JSValue JSDocument::getCSSCanvasContext(JSC::ExecState& state)
-{
- VM& vm = state.vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- if (UNLIKELY(state.argumentCount() < 4))
- return throwException(&state, scope, createNotEnoughArgumentsError(&state));
- auto contextId = state.uncheckedArgument(0).toWTFString(&state);
- RETURN_IF_EXCEPTION(scope, JSValue());
- auto name = state.uncheckedArgument(1).toWTFString(&state);
- RETURN_IF_EXCEPTION(scope, JSValue());
- auto width = convert<IDLLong>(state, state.uncheckedArgument(2));
- RETURN_IF_EXCEPTION(scope, JSValue());
- auto height = convert<IDLLong>(state, state.uncheckedArgument(3));
- RETURN_IF_EXCEPTION(scope, JSValue());
-
- auto* context = wrapped().getCSSCanvasContext(WTFMove(contextId), WTFMove(name), WTFMove(width), WTFMove(height));
- if (!context)
- return jsNull();
-
-#if ENABLE(WEBGL)
- if (is<WebGLRenderingContext>(*context))
- return toJS(&state, globalObject(), downcast<WebGLRenderingContext>(*context));
-#if ENABLE(WEBGL2)
- if (is<WebGL2RenderingContext>(*context))
- return toJS(&state, globalObject(), downcast<WebGL2RenderingContext>(*context));
-#endif
-#endif
-#if ENABLE(WEBGPU)
- if (is<WebGPURenderingContext>(*context))
- return toJS(&state, globalObject(), downcast<WebGPURenderingContext>(*context));
-#endif
-
- return toJS(&state, globalObject(), downcast<CanvasRenderingContext2D>(*context));
-}
-
-void JSDocument::visitAdditionalChildren(SlotVisitor& visitor)
-{
- visitor.addOpaqueRoot(static_cast<ScriptExecutionContext*>(&wrapped()));
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Document.cpp (218506 => 218507)
--- trunk/Source/WebCore/dom/Document.cpp 2017-06-19 20:54:14 UTC (rev 218506)
+++ trunk/Source/WebCore/dom/Document.cpp 2017-06-19 21:01:19 UTC (rev 218507)
@@ -38,6 +38,7 @@
#include "CachedCSSStyleSheet.h"
#include "CachedFrame.h"
#include "CachedResourceLoader.h"
+#include "CanvasRenderingContext2D.h"
#include "Chrome.h"
#include "ChromeClient.h"
#include "Comment.h"
@@ -277,6 +278,17 @@
#include "MediaStreamRegistry.h"
#endif
+#if ENABLE(WEBGL)
+#include "WebGLRenderingContext.h"
+#endif
+#if ENABLE(WEBGL2)
+#include "WebGL2RenderingContext.h"
+#endif
+#if ENABLE(WEBGPU)
+#include "WebGPURenderingContext.h"
+#endif
+
+
using namespace WTF;
using namespace Unicode;
@@ -5450,13 +5462,30 @@
m_ranges.remove(range);
}
-CanvasRenderingContext* Document::getCSSCanvasContext(const String& type, const String& name, int width, int height)
+std::optional<RenderingContext> Document::getCSSCanvasContext(const String& type, const String& name, int width, int height)
{
HTMLCanvasElement* element = getCSSCanvasElement(name);
if (!element)
- return nullptr;
- element->setSize(IntSize(width, height));
- return element->getContext(type);
+ return std::nullopt;
+ element->setSize({ width, height });
+ auto context = element->getContext(type);
+ if (!context)
+ return std::nullopt;
+
+#if ENABLE(WEBGL)
+ if (is<WebGLRenderingContext>(*context))
+ return RenderingContext { RefPtr<WebGLRenderingContext> { &downcast<WebGLRenderingContext>(*context) } };
+#endif
+#if ENABLE(WEBGL2)
+ if (is<WebGL2RenderingContext>(*context))
+ return RenderingContext { RefPtr<WebGL2RenderingContext> { &downcast<WebGL2RenderingContext>(*context) } };
+#endif
+#if ENABLE(WEBGPU)
+ if (is<WebGPURenderingContext>(*context))
+ return RenderingContext { RefPtr<WebGPURenderingContext> { &downcast<WebGPURenderingContext>(*context) } };
+#endif
+
+ return RenderingContext { RefPtr<CanvasRenderingContext2D> { &downcast<CanvasRenderingContext2D>(*context) } };
}
HTMLCanvasElement* Document::getCSSCanvasElement(const String& name)
Modified: trunk/Source/WebCore/dom/Document.h (218506 => 218507)
--- trunk/Source/WebCore/dom/Document.h 2017-06-19 20:54:14 UTC (rev 218506)
+++ trunk/Source/WebCore/dom/Document.h 2017-06-19 21:01:19 UTC (rev 218507)
@@ -56,6 +56,8 @@
#include <wtf/Deque.h>
#include <wtf/HashCountedSet.h>
#include <wtf/HashSet.h>
+#include <wtf/Optional.h>
+#include <wtf/Variant.h>
#include <wtf/WeakPtr.h>
#include <wtf/text/AtomicStringHash.h>
@@ -81,7 +83,7 @@
class CachedFrameBase;
class CachedResourceLoader;
class CachedScript;
-class CanvasRenderingContext;
+class CanvasRenderingContext2D;
class CharacterData;
class Comment;
class ConstantPropertyMap;
@@ -167,6 +169,9 @@
class TreeWalker;
class VisibilityChangeClient;
class VisitedLinkState;
+class WebGL2RenderingContext;
+class WebGLRenderingContext;
+class WebGPURenderingContext;
class XPathEvaluator;
class XPathExpression;
class XPathNSResolver;
@@ -284,6 +289,18 @@
ConflictsWithStandardElementName
};
+using RenderingContext = Variant<
+#if ENABLE(WEBGL)
+ RefPtr<WebGLRenderingContext>,
+#endif
+#if ENABLE(WEBGL2)
+ RefPtr<WebGL2RenderingContext>,
+#endif
+#if ENABLE(WEBGPU)
+ RefPtr<WebGPURenderingContext>,
+#endif
+ RefPtr<CanvasRenderingContext2D>>;
+
class Document
: public ContainerNode
, public TreeScope
@@ -965,7 +982,7 @@
void cancelFocusAppearanceUpdate();
// Extension for manipulating canvas drawing contexts for use in CSS
- CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
+ std::optional<RenderingContext> getCSSCanvasContext(const String& type, const String& name, int width, int height);
HTMLCanvasElement* getCSSCanvasElement(const String& name);
bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
Modified: trunk/Source/WebCore/dom/Document.idl (218506 => 218507)
--- trunk/Source/WebCore/dom/Document.idl 2017-06-19 20:54:14 UTC (rev 218506)
+++ trunk/Source/WebCore/dom/Document.idl 2017-06-19 21:01:19 UTC (rev 218507)
@@ -18,6 +18,18 @@
* Boston, MA 02110-1301, USA.
*/
+typedef (
+#if defined(ENABLE_WEBGL) && ENABLE_WEBGL
+ WebGLRenderingContext or
+#endif
+#if defined(ENABLE_WEBGL2) && ENABLE_WEBGL2
+ WebGL2RenderingContext or
+#endif
+#if defined(ENABLE_WEBGPU) && ENABLE_WEBGPU
+ WebGPURenderingContext or
+#endif
+ CanvasRenderingContext2D) RenderingContext;
+
[
Constructor,
ConstructorCallWith=Document,
@@ -175,7 +187,7 @@
Range caretRangeFromPoint(optional long x = 0, optional long y = 0);
// FIXME: This is not standard and has been dropped from Blink already.
- [Custom] (CanvasRenderingContext2D or WebGLRenderingContextBase) getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
+ RenderingContext? getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
// Non standard (https://developer.apple.com/reference/webkitjs/document/1633863-webkitgetnamedflows).
[Conditional=CSS_REGIONS] DOMNamedFlowCollection webkitGetNamedFlows();