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/. */
|
|
|
|
|
|
|
|
#include "nsDOMCaretPosition.h"
|
2013-08-14 10:56:21 +04:00
|
|
|
|
2012-12-28 21:11:06 +04:00
|
|
|
#include "mozilla/dom/CaretPositionBinding.h"
|
2013-09-20 14:21:03 +04:00
|
|
|
#include "mozilla/dom/DOMRect.h"
|
2020-04-29 12:02:05 +03:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2013-08-14 10:56:21 +04:00
|
|
|
#include "nsRange.h"
|
2012-12-28 21:11:06 +04:00
|
|
|
|
2013-09-20 14:21:03 +04:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2012-12-28 21:11:06 +04:00
|
|
|
nsDOMCaretPosition::nsDOMCaretPosition(nsINode* aNode, uint32_t aOffset)
|
2013-04-17 01:12:03 +04:00
|
|
|
: mOffset(aOffset), mOffsetNode(aNode), mAnonymousContentNode(nullptr) {}
|
2012-12-28 21:11:06 +04:00
|
|
|
|
2020-02-21 13:41:47 +03:00
|
|
|
nsDOMCaretPosition::~nsDOMCaretPosition() = default;
|
2012-12-28 21:11:06 +04:00
|
|
|
|
|
|
|
nsINode* nsDOMCaretPosition::GetOffsetNode() const { return mOffsetNode; }
|
|
|
|
|
2013-04-17 01:12:03 +04:00
|
|
|
already_AddRefed<DOMRect> nsDOMCaretPosition::GetClientRect() const {
|
|
|
|
if (!mOffsetNode) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsINode> node;
|
|
|
|
if (mAnonymousContentNode) {
|
|
|
|
node = mAnonymousContentNode;
|
|
|
|
} else {
|
|
|
|
node = mOffsetNode;
|
|
|
|
}
|
|
|
|
|
2019-06-28 10:47:29 +03:00
|
|
|
RefPtr<nsRange> range =
|
2020-04-29 12:02:05 +03:00
|
|
|
nsRange::Create(node, mOffset, node, mOffset, mozilla::IgnoreErrors());
|
2019-06-28 10:47:29 +03:00
|
|
|
if (!range) {
|
2013-04-17 01:12:03 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2019-06-28 10:47:29 +03:00
|
|
|
RefPtr<DOMRect> rect = range->GetBoundingClientRect(false);
|
2013-04-17 01:12:03 +04:00
|
|
|
return rect.forget();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
JSObject* nsDOMCaretPosition::WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return mozilla::dom::CaretPosition_Binding::Wrap(aCx, this, aGivenProto);
|
2012-12-28 21:11:06 +04:00
|
|
|
}
|
|
|
|
|
2014-04-29 12:57:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCaretPosition, mOffsetNode,
|
|
|
|
mAnonymousContentNode)
|
2012-12-28 21:11:06 +04: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
|