2015-05-03 19:32:37 +00: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 17:11:06 +00: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/. */
|
|
|
|
|
|
|
|
#include "nsDOMCaretPosition.h"
|
2013-08-14 06:56:21 +00:00
|
|
|
|
2012-12-28 17:11:06 +00:00
|
|
|
#include "mozilla/dom/CaretPositionBinding.h"
|
2013-09-20 10:21:03 +00:00
|
|
|
#include "mozilla/dom/DOMRect.h"
|
2013-08-14 06:56:21 +00:00
|
|
|
#include "nsRange.h"
|
2012-12-28 17:11:06 +00:00
|
|
|
|
2013-09-20 10:21:03 +00:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2012-12-28 17:11:06 +00:00
|
|
|
nsDOMCaretPosition::nsDOMCaretPosition(nsINode* aNode, uint32_t aOffset)
|
2013-04-16 21:12:03 +00:00
|
|
|
: mOffset(aOffset), mOffsetNode(aNode), mAnonymousContentNode(nullptr)
|
2012-12-28 17:11:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMCaretPosition::~nsDOMCaretPosition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsINode* nsDOMCaretPosition::GetOffsetNode() const
|
|
|
|
{
|
|
|
|
return mOffsetNode;
|
|
|
|
}
|
|
|
|
|
2013-09-20 10:21:03 +00:00
|
|
|
already_AddRefed<DOMRect>
|
2013-04-16 21:12:03 +00:00
|
|
|
nsDOMCaretPosition::GetClientRect() const
|
|
|
|
{
|
|
|
|
if (!mOffsetNode) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<DOMRect> rect;
|
|
|
|
RefPtr<nsRange> domRange;
|
2013-04-16 21:12:03 +00:00
|
|
|
nsCOMPtr<nsINode> node;
|
|
|
|
|
|
|
|
if (mAnonymousContentNode) {
|
|
|
|
node = mAnonymousContentNode;
|
|
|
|
} else {
|
|
|
|
node = mOffsetNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult creationRv = nsRange::CreateRange(node, mOffset, node,
|
|
|
|
mOffset,
|
|
|
|
getter_AddRefs<nsRange>(domRange));
|
|
|
|
if (!NS_SUCCEEDED(creationRv)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(domRange, "unable to retrieve valid dom range from CaretPosition");
|
|
|
|
|
2014-06-27 20:58:57 +00:00
|
|
|
rect = domRange->GetBoundingClientRect(false);
|
2013-04-16 21:12:03 +00:00
|
|
|
|
|
|
|
return rect.forget();
|
|
|
|
}
|
|
|
|
|
2012-12-28 17:11:06 +00:00
|
|
|
JSObject*
|
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 14:13:33 +00:00
|
|
|
nsDOMCaretPosition::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-28 17:11:06 +00:00
|
|
|
{
|
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 14:13:33 +00:00
|
|
|
return mozilla::dom::CaretPositionBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-28 17:11:06 +00:00
|
|
|
}
|
|
|
|
|
2014-04-29 08:57:00 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCaretPosition,
|
|
|
|
mOffsetNode, mAnonymousContentNode)
|
2012-12-28 17:11:06 +00:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCaretPosition)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCaretPosition)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCaretPosition)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|