# HG changeset patch # User Robert O'Callahan # Date 1394586699 -28800 # Wed Mar 12 09:11:39 2014 +0800 # Node ID 4c92f5d5a08f316630e03d63c8dcd2ba3373b5c8 # Parent 68f04b4cc7deab8b749fcd55816d236787c5897c Bug 918189. Part 1.5: Implement GeometryUtils.convertPointFromNode, convertRectFromNode, and convertQuadFromNode. r=jst 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 @@ -58,22 +58,27 @@ namespace dom { inline bool IsSpaceCharacter(char16_t aChar) { 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'; } +struct BoxQuadOptions; +struct ConvertCoordinateOptions; +class DOMPoint; +class DOMQuad; +class DOMRectReadOnly; class Element; -struct BoxQuadOptions; -class DOMQuad; class EventHandlerNonNull; class OnErrorEventHandlerNonNull; template class Optional; +class TextOrElementOrDocument; +struct DOMPointInit; } // namespace dom } // namespace mozilla #define NODE_FLAG_BIT(n_) (1U << (WRAPPER_CACHE_FLAGS_BITS_USED + (n_))) enum { // This bit will be set if the node has a listener manager. NODE_HAS_LISTENERMANAGER = NODE_FLAG_BIT(0), @@ -275,17 +280,22 @@ 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::ConvertCoordinateOptions ConvertCoordinateOptions; + typedef mozilla::dom::DOMPoint DOMPoint; + typedef mozilla::dom::DOMPointInit DOMPointInit; typedef mozilla::dom::DOMQuad DOMQuad; + typedef mozilla::dom::DOMRectReadOnly DOMRectReadOnly; + typedef mozilla::dom::TextOrElementOrDocument TextOrElementOrDocument; 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 @@ -1613,16 +1623,29 @@ public: // ParentNode methods mozilla::dom::Element* GetFirstElementChild() const; mozilla::dom::Element* GetLastElementChild() const; void GetBoxQuads(const BoxQuadOptions& aOptions, nsTArray >& aResult, mozilla::ErrorResult& aRv); + already_AddRefed ConvertQuadFromNode(DOMQuad& aQuad, + const TextOrElementOrDocument& aFrom, + const ConvertCoordinateOptions& aOptions, + ErrorResult& aRv); + already_AddRefed ConvertRectFromNode(DOMRectReadOnly& aRect, + const TextOrElementOrDocument& aFrom, + const ConvertCoordinateOptions& aOptions, + ErrorResult& aRv); + already_AddRefed ConvertPointFromNode(const DOMPointInit& aPoint, + const TextOrElementOrDocument& aFrom, + const ConvertCoordinateOptions& aOptions, + 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 @@ -1144,16 +1144,43 @@ nsINode::PreHandleEvent(nsEventChainPreV void nsINode::GetBoxQuads(const BoxQuadOptions& aOptions, nsTArray >& aResult, mozilla::ErrorResult& aRv) { mozilla::GetBoxQuads(this, aOptions, aResult, aRv); } +already_AddRefed +nsINode::ConvertQuadFromNode(DOMQuad& aQuad, + const GeometryNode& aFrom, + const ConvertCoordinateOptions& aOptions, + ErrorResult& aRv) +{ + return mozilla::ConvertQuadFromNode(this, aQuad, aFrom, aOptions, aRv); +} + +already_AddRefed +nsINode::ConvertRectFromNode(DOMRectReadOnly& aRect, + const GeometryNode& aFrom, + const ConvertCoordinateOptions& aOptions, + ErrorResult& aRv) +{ + return mozilla::ConvertRectFromNode(this, aRect, aFrom, aOptions, aRv); +} + +already_AddRefed +nsINode::ConvertPointFromNode(const DOMPointInit& aPoint, + const GeometryNode& aFrom, + const ConvertCoordinateOptions& aOptions, + ErrorResult& aRv) +{ + return mozilla::ConvertPointFromNode(this, aPoint, aFrom, aOptions, 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 --- a/dom/webidl/GeometryUtils.webidl +++ b/dom/webidl/GeometryUtils.webidl @@ -20,19 +20,22 @@ 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); + [Throws, Pref="layout.css.convertFromNode.enabled"] + DOMQuad convertQuadFromNode(DOMQuad quad, GeometryNode from, optional ConvertCoordinateOptions options); + [Throws, Pref="layout.css.convertFromNode.enabled"] + DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options); + [Throws, Pref="layout.css.convertFromNode.enabled"] + 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/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -2927,17 +2927,17 @@ nsHTMLEditRules::JoinBlocks(nsIDOMNode * * int32_t aRightOffset offset in aRightBlock to move content from */ nsresult nsHTMLEditRules::MoveBlock(nsIDOMNode *aLeftBlock, nsIDOMNode *aRightBlock, int32_t aLeftOffset, int32_t aRightOffset) { nsCOMArray arrayOfNodes; nsCOMPtr isupports; // GetNodesFromPoint is the workhorse that figures out what we wnat to move. - nsresult res = GetNodesFromPoint(DOMPoint(aRightBlock,aRightOffset), + nsresult res = GetNodesFromPoint(::DOMPoint(aRightBlock,aRightOffset), EditAction::makeList, arrayOfNodes, true); NS_ENSURE_SUCCESS(res, res); int32_t listCount = arrayOfNodes.Count(); int32_t i; for (i=0; i &arrayOfNodes, bool dontTouchContent) { nsresult res; // get our point nsCOMPtr node; diff --git a/layout/base/tests/test_getBoxQuads_convertPointRectQuad.html b/layout/base/tests/test_getBoxQuads_convertPointRectQuad.html --- a/layout/base/tests/test_getBoxQuads_convertPointRectQuad.html +++ b/layout/base/tests/test_getBoxQuads_convertPointRectQuad.html @@ -211,17 +211,18 @@ TextTextTextTextTextTextTextTextTextText