# HG changeset patch # User Jet Villegas # Date 1363255221 25200 # Node ID 0f69bf18b6f638118b7d3165fcd257c51b3a0997 # Parent 092fcca11bdb6279bcb18e22da93643275f6f2df Implement WebKitPoint diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -968,16 +968,22 @@ DOMInterfaces = { }, 'WebGLUniformLocation': { 'nativeType': 'mozilla::WebGLUniformLocation', 'headerFile': 'WebGLUniformLocation.h', 'wrapperCache': False }, +'WebKitPoint': { + 'nativeOwnership': 'refcounted', + 'nativeType': 'mozilla::dom::WebKitPoint', + 'headerFile': 'WebKitPoint.h' +}, + 'WebSocket': { 'headerFile': 'WebSocket.h', 'implicitJSContext': [ 'constructor' ] }, 'XMLHttpRequest': [ { 'nativeType': 'nsXMLHttpRequest', diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -224,16 +224,17 @@ webidl_files = \ Text.webidl \ TextDecoder.webidl \ TextEncoder.webidl \ TimeRanges.webidl \ TreeWalker.webidl \ URL.webidl \ ValidityState.webidl \ WebComponents.webidl \ + WebKitPoint.webidl \ WebSocket.webidl \ UndoManager.webidl \ URLUtils.webidl \ USSDReceivedEvent.webidl \ XMLHttpRequest.webidl \ XMLHttpRequestEventTarget.webidl \ XMLHttpRequestUpload.webidl \ XMLSerializer.webidl \ diff --git a/dom/webidl/WebKitPoint.webidl b/dom/webidl/WebKitPoint.webidl new file mode 100644 --- /dev/null +++ b/dom/webidl/WebKitPoint.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; 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/. + */ + + +[Constructor(optional float x = 0, optional float y = 0)] +interface WebKitPoint { + + attribute float x; + attribute float y; + +}; + diff --git a/layout/style/Makefile.in b/layout/style/Makefile.in --- a/layout/style/Makefile.in +++ b/layout/style/Makefile.in @@ -129,16 +129,17 @@ CPPSRCS = \ nsStyleContext.cpp \ nsStyleCoord.cpp \ nsStyleSet.cpp \ nsStyleStruct.cpp \ nsStyleTransformMatrix.cpp \ nsStyleUtil.cpp \ nsTransitionManager.cpp \ StyleRule.cpp \ + WebKitPoint.cpp \ $(NULL) FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk include $(topsrcdir)/ipc/chromium/chromium-config.mk diff --git a/layout/style/WebKitPoint.cpp b/layout/style/WebKitPoint.cpp new file mode 100644 --- /dev/null +++ b/layout/style/WebKitPoint.cpp @@ -0,0 +1,45 @@ +/* -*- 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/. */ + +/* DOM object representing color values in DOM computed style */ + +#include "WebKitPoint.h" +#include "nsContentUtils.h" +#include "mozilla/dom/WebKitPointBinding.h" + +using namespace mozilla::dom; + +/* static */ already_AddRefed +WebKitPoint::Constructor(const GlobalObject& aGlobal, float aX, float aY, ErrorResult& aError) +{ + nsCOMPtr window = do_QueryInterface(aGlobal.Get()); + if (!window) { + aError.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + + nsRefPtr pt = new WebKitPoint(aX, aY); + return pt.forget(); +} + +WebKitPoint::WebKitPoint(float aX, float aY) +: mX(aX), mY(aY) +{ + SetIsDOMBinding(); +} + +WebKitPoint::~WebKitPoint(void) +{ +} + +JSObject* +WebKitPoint::WrapObject(JSContext *aCx, JSObject *aScope) +{ + return dom::WebKitPointBinding::Wrap(aCx, aScope, this); +} + +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebKitPoint) + +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebKitPoint, AddRef) +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebKitPoint, Release) \ No newline at end of file diff --git a/layout/style/WebKitPoint.h b/layout/style/WebKitPoint.h new file mode 100644 --- /dev/null +++ b/layout/style/WebKitPoint.h @@ -0,0 +1,84 @@ +/* -*- 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/. */ + +/* DOM object representing color values in DOM computed style */ + +#ifndef WebKitPoint_h__ +#define WebKitPoint_h__ + +#include "mozilla/Attributes.h" +#include "nsAutoPtr.h" +#include "nsWrapperCache.h" + +// 3900c55f-5a66-42e7-a8e2-0a6dca9b9dae +#define MOZILLA_WEBKITPOINT_IID \ +{ 0x3900c55f, 0x5a66, 0x42e7, \ + { 0xa8, 0xe2, 0x0a, 0x6d, 0xca, 0x9b, 0x9d, 0xae } } + +namespace mozilla { + +class ErrorResult; + +namespace dom { + +class GlobalObject; + +class WebKitPoint MOZ_FINAL : public nsWrapperCache +{ +public: + + static already_AddRefed + Constructor(const GlobalObject& aGlobal, float aX, float aY, ErrorResult& aError); + + WebKitPoint(float aX, float aY); + + virtual ~WebKitPoint(void); + + NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_WEBKITPOINT_IID) + + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebKitPoint) + + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebKitPoint) + + + // WebKitPoint webidl interface + void SetX(float aX) // to-do: add error handling here + { + mX = aX; + } + + void SetY(float aY) + { + mY = aY; + } + + float X() + { + return mX; + } + + float Y() + { + return mY; + } + + nsISupports* GetParentObject() const + { + return nullptr; + } + + JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE MOZ_FINAL; + +private: + float mX; // to_do: move this to a real internal point struct + float mY; +}; + + +NS_DEFINE_STATIC_IID_ACCESSOR(WebKitPoint, MOZILLA_WEBKITPOINT_IID) +} // namespace dom +} // namespace mozilla + +#endif // WebKitPoint_h__