From: Robert O'Callahan Bug 917755. Part 5.5: Implement getBoxQuads DOM API. r=mrbkap diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -59,16 +59,18 @@ inline bool IsSpaceCharacter(char16_t aC return aChar == ' ' || aChar == '\t' || aChar == '\n' || aChar == '\r' || aChar == '\f'; } inline bool IsSpaceCharacter(char aChar) { return aChar == ' ' || aChar == '\t' || aChar == '\n' || aChar == '\r' || aChar == '\f'; } class Element; +class BoxQuadOptions; +class DOMQuad; class EventHandlerNonNull; class OnErrorEventHandlerNonNull; template class Optional; } // namespace dom } // namespace mozilla #define NODE_FLAG_BIT(n_) (1U << (WRAPPER_CACHE_FLAGS_BITS_USED + (n_))) @@ -272,16 +274,20 @@ private: /** * An internal interface that abstracts some DOMNode-related parts that both * nsIContent and nsIDocument share. An instance of this interface has a list * of nsIContent children and provides access to them. */ class nsINode : public mozilla::dom::EventTarget { public: + typedef mozilla::dom::BoxQuadOptions BoxQuadOptions; + typedef mozilla::dom::DOMQuad DOMQuad; + typedef mozilla::ErrorResult ErrorResult; + NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID) // Among the sub-classes that inherit (directly or indirectly) from nsINode, // measurement of the following members may be added later if DMD finds it is // worthwhile: // - nsGenericHTMLElement: mForm, mFieldSet // - nsGenericHTMLFrameElement: mFrameLoader (bug 672539) // - HTMLBodyElement: mContentStyleRule @@ -1603,16 +1609,20 @@ public: * Remove this node from its parent, if any. */ void Remove(); // ParentNode methods mozilla::dom::Element* GetFirstElementChild() const; mozilla::dom::Element* GetLastElementChild() const; + void GetBoxQuads(const BoxQuadOptions& aOptions, + nsTArray >& aResult, + mozilla::ErrorResult& aRv); + protected: // Override this function to create a custom slots class. // Must not return null. virtual nsINode::nsSlots* CreateSlots(); bool HasSlots() const { diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -98,16 +98,17 @@ #include "nsCSSParser.h" #include "HTMLLegendElement.h" #include "nsWrapperCacheInlines.h" #include "WrapperFactory.h" #include "DocumentType.h" #include #include "nsGlobalWindow.h" #include "nsDOMMutationObserver.h" +#include "GeometryUtils.h" using namespace mozilla; using namespace mozilla::dom; nsINode::nsSlots::~nsSlots() { if (mChildNodes) { mChildNodes->DropReference(); @@ -1135,16 +1136,24 @@ NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsI nsresult nsINode::PreHandleEvent(nsEventChainPreVisitor& aVisitor) { // This is only here so that we can use the NS_DECL_NSIDOMTARGET macro NS_ABORT(); return NS_ERROR_NOT_IMPLEMENTED; } +void +nsINode::GetBoxQuads(const BoxQuadOptions& aOptions, + nsTArray >& aResult, + mozilla::ErrorResult& aRv) +{ + mozilla::GetBoxQuads(this, aOptions, aResult, aRv); +} + nsresult nsINode::DispatchEvent(nsIDOMEvent *aEvent, bool* aRetVal) { // XXX sXBL/XBL2 issue -- do we really want the owner here? What // if that's the XBL document? Would we want its presshell? Or what? nsCOMPtr document = OwnerDoc(); // Do nothing if the element does not belong to a document diff --git a/dom/webidl/GeometryUtils.webidl b/dom/webidl/GeometryUtils.webidl new file mode 100644 --- /dev/null +++ b/dom/webidl/GeometryUtils.webidl @@ -0,0 +1,38 @@ +/* -*- 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/. + * + * The origin of this IDL file is + * http://dev.w3.org/csswg/cssom-view/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +enum CSSBoxType { "margin", "border", "padding", "content" }; +dictionary BoxQuadOptions { + CSSBoxType box = "border"; + GeometryNode relativeTo; +}; + +dictionary ConvertCoordinateOptions { + CSSBoxType fromBox = "border"; + CSSBoxType toBox = "border"; +}; + +[NoInterfaceObject] +interface GeometryUtils { + [Throws, Pref="layout.css.getBoxQuads.enabled"] + sequence getBoxQuads(optional BoxQuadOptions options); +// DOMQuad convertQuadFromNode(DOMQuad quad, GeometryNode from, optional ConvertCoordinateOptions options); +// DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options); +// DOMPoint convertPointFromNode(DOMPointInit point, GeometryNode from, optional ConvertCoordinateOptions options); +}; + +Text implements GeometryUtils; +Element implements GeometryUtils; +// PseudoElement implements GeometryUtils; +Document implements GeometryUtils; + +typedef (Text or Element /* or PseudoElement */ or Document) GeometryNode; \ No newline at end of file diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -110,16 +110,17 @@ WEBIDL_FILES = [ 'FileReader.webidl', 'FileReaderSync.webidl', 'FileRequest.webidl', 'FocusEvent.webidl', 'FormData.webidl', 'Function.webidl', 'GainNode.webidl', 'Geolocation.webidl', + 'GeometryUtils.webidl', 'GetUserMediaRequest.webidl', 'History.webidl', 'HTMLAnchorElement.webidl', 'HTMLAppletElement.webidl', 'HTMLAreaElement.webidl', 'HTMLAudioElement.webidl', 'HTMLBaseElement.webidl', 'HTMLBodyElement.webidl', diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -1789,16 +1789,23 @@ pref("layout.css.sticky.enabled", true); pref("layout.css.will-change.enabled", false); // Is support for DOMPoint enabled? pref("layout.css.DOMPoint.enabled", true); // Is support for DOMQuad enabled? pref("layout.css.DOMQuad.enabled", true); +// Is support for GeometryUtils.getBoxQuads enabled? +#ifdef RELEASE_BUILD +pref("layout.css.getBoxQuads.enabled", false); +#else +pref("layout.css.getBoxQuads.enabled", true); +#endif + // Is support for CSS "text-align: true X" enabled? pref("layout.css.text-align-true-value.enabled", false); // Is support for the CSS4 image-orientation property enabled? pref("layout.css.image-orientation.enabled", true); // Is support for CSS3 Fonts features enabled? // (includes font-variant-*, font-kerning, font-synthesis