2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-12-28 21:11:06 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef nsDOMCaretPosition_h
|
|
|
|
#define nsDOMCaretPosition_h
|
|
|
|
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsINode.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2013-08-14 10:56:21 +04:00
|
|
|
|
2013-09-20 14:21:03 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class DOMRect;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-12-28 21:11:06 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of a DOM Caret Position, which is a node and offset within
|
|
|
|
* that node, in the DOM tree.
|
|
|
|
*
|
|
|
|
* http://www.w3.org/TR/cssom-view/#dom-documentview-caretrangefrompoint
|
|
|
|
*
|
|
|
|
* @see Document::caretPositionFromPoint(float x, float y)
|
|
|
|
*/
|
|
|
|
class nsDOMCaretPosition : public nsISupports,
|
|
|
|
public nsWrapperCache
|
|
|
|
{
|
2013-09-20 14:21:03 +04:00
|
|
|
typedef mozilla::dom::DOMRect DOMRect;
|
|
|
|
|
2012-12-28 21:11:06 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMCaretPosition)
|
|
|
|
|
|
|
|
nsDOMCaretPosition(nsINode* aNode, uint32_t aOffset);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the offset (character position within the DOM node) of the
|
|
|
|
* CaretPosition.
|
|
|
|
*
|
|
|
|
* @returns The offset within the DOM node.
|
|
|
|
*/
|
|
|
|
uint32_t Offset() const { return mOffset; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the DOM node with which this CaretPosition was established.
|
|
|
|
* Normally, this will be created from a point, so it will be the DOM
|
|
|
|
* node that lies at the point specified.
|
|
|
|
*
|
|
|
|
* @returns The DOM node of the CaretPosition.
|
|
|
|
*
|
|
|
|
* @see Document::caretPositionFromPoint(float x, float y)
|
|
|
|
*/
|
|
|
|
nsINode* GetOffsetNode() const;
|
|
|
|
|
2013-04-17 01:12:03 +04:00
|
|
|
/**
|
|
|
|
* Retrieve the bounding rectangle of this CaretPosition object.
|
|
|
|
*
|
|
|
|
* @returns An nsClientRect representing the bounding rectangle of this
|
|
|
|
* CaretPosition, if one can be successfully determined, otherwise
|
|
|
|
* nullptr.
|
|
|
|
*/
|
2013-09-20 14:21:03 +04:00
|
|
|
already_AddRefed<DOMRect> GetClientRect() const;
|
2013-04-17 01:12:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the anonymous content node that is the actual parent of this
|
|
|
|
* CaretPosition object. In situations where the DOM node for a CaretPosition
|
|
|
|
* actually lies within an anonymous content node (e.g. a textarea), the
|
|
|
|
* actual parent is not set as the offset node. This is used to get the
|
|
|
|
* correct bounding box of a CaretPosition object that lies within a textarea
|
|
|
|
* or input element.
|
|
|
|
*
|
|
|
|
* @param aNode A pointer to an nsINode object that is the actual element
|
|
|
|
* within which this CaretPosition lies, but is an anonymous content
|
|
|
|
* node.
|
|
|
|
*/
|
|
|
|
void SetAnonymousContentNode(nsINode* aNode)
|
|
|
|
{
|
|
|
|
mAnonymousContentNode = aNode;
|
|
|
|
}
|
|
|
|
|
2012-12-28 21:11:06 +04:00
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOffsetNode();
|
|
|
|
}
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2015-03-21 19:28:04 +03:00
|
|
|
override final;
|
2012-12-28 21:11:06 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsDOMCaretPosition();
|
2013-04-17 01:12:03 +04:00
|
|
|
|
2012-12-28 21:11:06 +04:00
|
|
|
uint32_t mOffset;
|
|
|
|
nsCOMPtr<nsINode> mOffsetNode;
|
2013-04-17 01:12:03 +04:00
|
|
|
nsCOMPtr<nsINode> mAnonymousContentNode;
|
2012-12-28 21:11:06 +04:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|