mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 825341 - convert range to webidl r=bz, smaug
This commit is contained in:
parent
02e533d20b
commit
39ae246957
@ -1824,7 +1824,7 @@ HyperTextAccessible::SetSelectionBounds(int32_t aSelectionNum,
|
||||
|
||||
nsRefPtr<nsRange> range;
|
||||
if (aSelectionNum == rangeCount)
|
||||
range = new nsRange();
|
||||
range = new nsRange(mContent);
|
||||
else
|
||||
range = domSel->GetRangeAt(aSelectionNum);
|
||||
|
||||
@ -1886,7 +1886,7 @@ HyperTextAccessible::ScrollSubstringTo(int32_t aStartIndex, int32_t aEndIndex,
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(mContent);
|
||||
nsresult rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex, range);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -1910,7 +1910,7 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartIndex,
|
||||
nsIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
|
||||
this);
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(mContent);
|
||||
nsresult rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex, range);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -158,7 +158,7 @@ TextLeafAccessibleWrap::scrollToSubstring(
|
||||
if (IsDefunct())
|
||||
return E_FAIL;
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(mContent);
|
||||
if (NS_FAILED(range->SetStart(mContent, aStartIndex)))
|
||||
return E_FAIL;
|
||||
|
||||
|
@ -112,6 +112,7 @@ namespace layers {
|
||||
} // namespace layers
|
||||
|
||||
namespace dom {
|
||||
class DocumentFragment;
|
||||
class Element;
|
||||
} // namespace dom
|
||||
|
||||
@ -366,6 +367,7 @@ public:
|
||||
|
||||
// Check if the (JS) caller can access aNode.
|
||||
static bool CanCallerAccess(nsIDOMNode *aNode);
|
||||
static bool CanCallerAccess(nsINode* aNode);
|
||||
|
||||
// Check if the (JS) caller can access aWindow.
|
||||
// aWindow can be either outer or inner window.
|
||||
@ -1084,6 +1086,10 @@ public:
|
||||
const nsAString& aFragment,
|
||||
bool aPreventScriptExecution,
|
||||
nsIDOMDocumentFragment** aReturn);
|
||||
static already_AddRefed<mozilla::dom::DocumentFragment>
|
||||
CreateContextualFragment(nsINode* aContextNode, const nsAString& aFragment,
|
||||
bool aPreventScriptExecution,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
/**
|
||||
* Invoke the fragment parsing algorithm (innerHTML) using the HTML parser.
|
||||
|
@ -2472,6 +2472,10 @@ nsresult
|
||||
NS_NewVideoDocument(nsIDocument** aInstancePtrResult);
|
||||
#endif
|
||||
|
||||
already_AddRefed<mozilla::dom::DocumentFragment>
|
||||
NS_NewDocumentFragment(nsNodeInfoManager* aNodeInfoManager,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager);
|
||||
|
@ -21,21 +21,34 @@
|
||||
nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager)
|
||||
{
|
||||
mozilla::ErrorResult rv;
|
||||
*aInstancePtrResult = NS_NewDocumentFragment(aNodeInfoManager, rv).get();
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::DocumentFragment>
|
||||
NS_NewDocumentFragment(nsNodeInfoManager* aNodeInfoManager,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_ENSURE_ARG(aNodeInfoManager);
|
||||
if (!aNodeInfoManager) {
|
||||
aRv.Throw(NS_ERROR_INVALID_ARG);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentFragmentNodeName,
|
||||
nullptr, kNameSpaceID_None,
|
||||
nsIDOMNode::DOCUMENT_FRAGMENT_NODE);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo =
|
||||
aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentFragmentNodeName,
|
||||
nullptr, kNameSpaceID_None,
|
||||
nsIDOMNode::DOCUMENT_FRAGMENT_NODE);
|
||||
if (!nodeInfo) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DocumentFragment *it = new DocumentFragment(nodeInfo.forget());
|
||||
NS_ADDREF(*aInstancePtrResult = it);
|
||||
|
||||
return NS_OK;
|
||||
nsRefPtr<DocumentFragment> it = new DocumentFragment(nodeInfo.forget());
|
||||
return it.forget();
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -168,6 +168,7 @@
|
||||
#include "nsSVGFeatures.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "DecoderTraits.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "nsViewportInfo.h"
|
||||
@ -1588,6 +1589,15 @@ nsContentUtils::CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::CanCallerAccess(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, false);
|
||||
return CanCallerAccess(node);
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::CanCallerAccess(nsINode* aNode)
|
||||
{
|
||||
// XXXbz why not check the IsCapabilityEnabled thing up front, and not bother
|
||||
// with the system principal games? But really, there should be a simpler
|
||||
@ -1602,10 +1612,7 @@ nsContentUtils::CanCallerAccess(nsIDOMNode *aNode)
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, false);
|
||||
|
||||
return CanCallerAccess(subjectPrincipal, node->NodePrincipal());
|
||||
return CanCallerAccess(subjectPrincipal, aNode->NodePrincipal());
|
||||
}
|
||||
|
||||
// static
|
||||
@ -4045,8 +4052,22 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
bool aPreventScriptExecution,
|
||||
nsIDOMDocumentFragment** aReturn)
|
||||
{
|
||||
*aReturn = nullptr;
|
||||
NS_ENSURE_ARG(aContextNode);
|
||||
ErrorResult rv;
|
||||
*aReturn = CreateContextualFragment(aContextNode, aFragment,
|
||||
aPreventScriptExecution, rv).get();
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<DocumentFragment>
|
||||
nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
const nsAString& aFragment,
|
||||
bool aPreventScriptExecution,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!aContextNode) {
|
||||
aRv.Throw(NS_ERROR_INVALID_ARG);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If we don't have a document here, we can't get the right security context
|
||||
// for compiling event handlers... so just bail out.
|
||||
@ -4058,8 +4079,8 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
#endif
|
||||
|
||||
if (isHTML) {
|
||||
nsCOMPtr<nsIDOMDocumentFragment> frag;
|
||||
NS_NewDocumentFragment(getter_AddRefs(frag), document->NodeInfoManager());
|
||||
nsRefPtr<DocumentFragment> frag =
|
||||
NS_NewDocumentFragment(document->NodeInfoManager(), aRv);
|
||||
|
||||
nsCOMPtr<nsIContent> contextAsContent = do_QueryInterface(aContextNode);
|
||||
if (contextAsContent && !contextAsContent->IsElement()) {
|
||||
@ -4070,28 +4091,23 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> fragment = do_QueryInterface(frag);
|
||||
if (contextAsContent && !contextAsContent->IsHTML(nsGkAtoms::html)) {
|
||||
rv = ParseFragmentHTML(aFragment,
|
||||
fragment,
|
||||
contextAsContent->Tag(),
|
||||
contextAsContent->GetNameSpaceID(),
|
||||
(document->GetCompatibilityMode() ==
|
||||
aRv = ParseFragmentHTML(aFragment, frag,
|
||||
contextAsContent->Tag(),
|
||||
contextAsContent->GetNameSpaceID(),
|
||||
(document->GetCompatibilityMode() ==
|
||||
eCompatibility_NavQuirks),
|
||||
aPreventScriptExecution);
|
||||
aPreventScriptExecution);
|
||||
} else {
|
||||
rv = ParseFragmentHTML(aFragment,
|
||||
fragment,
|
||||
nsGkAtoms::body,
|
||||
kNameSpaceID_XHTML,
|
||||
(document->GetCompatibilityMode() ==
|
||||
aRv = ParseFragmentHTML(aFragment, frag,
|
||||
nsGkAtoms::body,
|
||||
kNameSpaceID_XHTML,
|
||||
(document->GetCompatibilityMode() ==
|
||||
eCompatibility_NavQuirks),
|
||||
aPreventScriptExecution);
|
||||
aPreventScriptExecution);
|
||||
}
|
||||
|
||||
frag.forget(aReturn);
|
||||
return rv;
|
||||
return frag.forget();
|
||||
}
|
||||
|
||||
nsAutoTArray<nsString, 32> tagStack;
|
||||
@ -4103,7 +4119,10 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
|
||||
while (content && content->IsElement()) {
|
||||
nsString& tagName = *tagStack.AppendElement();
|
||||
NS_ENSURE_TRUE(&tagName, NS_ERROR_OUT_OF_MEMORY);
|
||||
if (!&tagName) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tagName = content->NodeInfo()->QualifiedName();
|
||||
|
||||
@ -4149,11 +4168,10 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
content = content->GetParent();
|
||||
}
|
||||
|
||||
return ParseFragmentXML(aFragment,
|
||||
document,
|
||||
tagStack,
|
||||
aPreventScriptExecution,
|
||||
aReturn);
|
||||
nsCOMPtr<nsIDOMDocumentFragment> frag;
|
||||
aRv = ParseFragmentXML(aFragment, document, tagStack,
|
||||
aPreventScriptExecution, getter_AddRefs(frag));
|
||||
return static_cast<DocumentFragment*>(frag.forget().get());
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -294,7 +294,7 @@ nsCopySupport::GetTransferableForNode(nsINode* aNode,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(aNode);
|
||||
rv = range->SelectNode(node);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = selection->AddRange(range);
|
||||
|
@ -5573,7 +5573,7 @@ nsDocument::CreateRange(nsIDOMRange** aReturn)
|
||||
already_AddRefed<nsRange>
|
||||
nsIDocument::CreateRange(ErrorResult& rv)
|
||||
{
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(this);
|
||||
nsresult res = range->Set(this, 0, this, 0);
|
||||
if (NS_FAILED(res)) {
|
||||
rv.Throw(res);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,17 +12,32 @@
|
||||
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "prmon.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsRange : public nsIDOMRange,
|
||||
public nsStubMutationObserver
|
||||
class nsClientRectList;
|
||||
class nsIDOMDocumentFragment;
|
||||
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
namespace dom {
|
||||
class DocumentFragment;
|
||||
}
|
||||
}
|
||||
|
||||
class nsRange MOZ_FINAL : public nsIDOMRange,
|
||||
public nsStubMutationObserver,
|
||||
public nsWrapperCache
|
||||
{
|
||||
typedef mozilla::ErrorResult ErrorResult;
|
||||
|
||||
public:
|
||||
nsRange()
|
||||
nsRange(nsINode* aNode)
|
||||
: mRoot(nullptr)
|
||||
, mStartOffset(0)
|
||||
, mEndOffset(0)
|
||||
@ -36,7 +51,11 @@ public:
|
||||
, mAssertNextInsertOrAppendIndex(-1)
|
||||
, mAssertNextInsertOrAppendNode(nullptr)
|
||||
#endif
|
||||
{}
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
MOZ_ASSERT(aNode, "range isn't in a document!");
|
||||
mOwner = aNode->OwnerDoc();
|
||||
}
|
||||
virtual ~nsRange();
|
||||
|
||||
static nsresult CreateRange(nsIDOMNode* aStartParent, int32_t aStartOffset,
|
||||
@ -47,7 +66,7 @@ public:
|
||||
nsIDOMRange** aRange);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsRange, nsIDOMRange)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsRange, nsIDOMRange)
|
||||
|
||||
// nsIDOMRange interface
|
||||
NS_DECL_NSIDOMRANGE
|
||||
@ -82,12 +101,6 @@ public:
|
||||
return mIsPositioned;
|
||||
}
|
||||
|
||||
bool Collapsed() const
|
||||
{
|
||||
return mIsPositioned && mStartParent == mEndParent &&
|
||||
mStartOffset == mEndOffset;
|
||||
}
|
||||
|
||||
void SetMaySpanAnonymousSubtrees(bool aMaySpanAnonymousSubtrees)
|
||||
{
|
||||
mMaySpanAnonymousSubtrees = aMaySpanAnonymousSubtrees;
|
||||
@ -146,6 +159,46 @@ public:
|
||||
NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
||||
|
||||
// WebIDL
|
||||
bool Collapsed() const
|
||||
{
|
||||
return mIsPositioned && mStartParent == mEndParent &&
|
||||
mStartOffset == mEndOffset;
|
||||
}
|
||||
already_AddRefed<mozilla::dom::DocumentFragment>
|
||||
CreateContextualFragment(const nsAString& aString, ErrorResult& aError);
|
||||
already_AddRefed<mozilla::dom::DocumentFragment>
|
||||
CloneContents(ErrorResult& aErr);
|
||||
int16_t CompareBoundaryPoints(uint16_t aHow, nsRange& aOther,
|
||||
ErrorResult& aErr);
|
||||
int16_t ComparePoint(nsINode& aParent, uint32_t aOffset, ErrorResult& aErr);
|
||||
void DeleteContents(ErrorResult& aRv);
|
||||
already_AddRefed<mozilla::dom::DocumentFragment>
|
||||
ExtractContents(ErrorResult& aErr);
|
||||
nsINode* GetCommonAncestorContainer(ErrorResult& aRv) const;
|
||||
nsINode* GetStartContainer(ErrorResult& aRv) const;
|
||||
uint32_t GetStartOffset(ErrorResult& aRv) const;
|
||||
nsINode* GetEndContainer(ErrorResult& aRv) const;
|
||||
uint32_t GetEndOffset(ErrorResult& aRv) const;
|
||||
void InsertNode(nsINode& aNode, ErrorResult& aErr);
|
||||
bool IntersectsNode(nsINode& aNode, ErrorResult& aRv);
|
||||
bool IsPointInRange(nsINode& aParent, uint32_t aOffset, ErrorResult& aErr);
|
||||
void SelectNode(nsINode& aNode, ErrorResult& aErr);
|
||||
void SelectNodeContents(nsINode& aNode, ErrorResult& aErr);
|
||||
void SetEnd(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr);
|
||||
void SetEndAfter(nsINode& aNode, ErrorResult& aErr);
|
||||
void SetEndBefore(nsINode& aNode, ErrorResult& aErr);
|
||||
void SetStart(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr);
|
||||
void SetStartAfter(nsINode& aNode, ErrorResult& aErr);
|
||||
void SetStartBefore(nsINode& aNode, ErrorResult& aErr);
|
||||
void SurroundContents(nsINode& aNode, ErrorResult& aErr);
|
||||
already_AddRefed<nsIDOMClientRect> GetBoundingClientRect();
|
||||
already_AddRefed<nsClientRectList> GetClientRects(ErrorResult& aErr);
|
||||
|
||||
nsINode* GetParentObject() const { return mOwner; }
|
||||
virtual JSObject* WrapObject(JSContext* cx, JSObject* scope, bool* tried)
|
||||
MOZ_OVERRIDE MOZ_FINAL;
|
||||
|
||||
private:
|
||||
// no copy's or assigns
|
||||
nsRange(const nsRange&);
|
||||
@ -157,7 +210,7 @@ private:
|
||||
* @param aFragment nsIDOMDocumentFragment containing the nodes.
|
||||
* May be null to indicate the caller doesn't want a fragment.
|
||||
*/
|
||||
nsresult CutContents(nsIDOMDocumentFragment** frag);
|
||||
nsresult CutContents(mozilla::dom::DocumentFragment** frag);
|
||||
|
||||
static nsresult CloneParentsBetween(nsIDOMNode *aAncestor,
|
||||
nsIDOMNode *aNode,
|
||||
@ -224,7 +277,8 @@ protected:
|
||||
#endif
|
||||
static bool mIsNested;
|
||||
};
|
||||
|
||||
|
||||
nsCOMPtr<nsIDocument> mOwner;
|
||||
nsCOMPtr<nsINode> mRoot;
|
||||
nsCOMPtr<nsINode> mStartParent;
|
||||
nsCOMPtr<nsINode> mEndParent;
|
||||
|
@ -515,7 +515,7 @@ nsContentEventHandler::OnQueryTextContent(nsQueryContentEvent* aEvent)
|
||||
NS_ASSERTION(aEvent->mReply.mString.IsEmpty(),
|
||||
"The reply string must be empty");
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(mRootContent);
|
||||
rv = SetRangeFromFlatTextOffset(range, aEvent->mInput.mOffset,
|
||||
aEvent->mInput.mLength, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -572,7 +572,7 @@ nsContentEventHandler::OnQueryTextRect(nsQueryContentEvent* aEvent)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(mRootContent);
|
||||
rv = SetRangeFromFlatTextOffset(range, aEvent->mInput.mOffset,
|
||||
aEvent->mInput.mLength, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -716,7 +716,7 @@ nsContentEventHandler::OnQueryCaretRect(nsQueryContentEvent* aEvent)
|
||||
}
|
||||
|
||||
// Otherwise, we should set the guessed caret rect.
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(mRootContent);
|
||||
rv = SetRangeFromFlatTextOffset(range, aEvent->mInput.mOffset, 0, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -899,9 +899,10 @@ nsContentEventHandler::GetFlatTextOffsetOfRange(nsIContent* aRootContent,
|
||||
int32_t aNodeOffset,
|
||||
uint32_t* aNativeOffset)
|
||||
{
|
||||
NS_ENSURE_STATE(aRootContent);
|
||||
NS_ASSERTION(aNativeOffset, "param is invalid");
|
||||
|
||||
nsRefPtr<nsRange> prev = new nsRange();
|
||||
nsRefPtr<nsRange> prev = new nsRange(aRootContent);
|
||||
nsCOMPtr<nsIDOMNode> rootDOMNode(do_QueryInterface(aRootContent));
|
||||
prev->SetStart(rootDOMNode, 0);
|
||||
|
||||
@ -1033,7 +1034,7 @@ nsContentEventHandler::OnSelectionEvent(nsSelectionEvent* aEvent)
|
||||
}
|
||||
|
||||
// Get range from offset and length
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(mRootContent);
|
||||
NS_ENSURE_TRUE(range, NS_ERROR_OUT_OF_MEMORY);
|
||||
rv = SetRangeFromFlatTextOffset(range, aEvent->mOffset, aEvent->mLength,
|
||||
aEvent->mExpandToClusterBoundary);
|
||||
|
@ -3161,7 +3161,7 @@ nsIContent* nsHTMLMediaElement::GetNextSource()
|
||||
nsresult rv = NS_OK;
|
||||
if (!mSourcePointer) {
|
||||
// First time this has been run, create a selection to cover children.
|
||||
mSourcePointer = new nsRange();
|
||||
mSourcePointer = new nsRange(this);
|
||||
|
||||
rv = mSourcePointer->SelectNodeContents(thisDomNode);
|
||||
if (NS_FAILED(rv)) return nullptr;
|
||||
|
@ -2605,7 +2605,7 @@ nsHTMLDocument::DeferredContentEditableCountChange(nsIContent *aElement)
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
docshell->GetEditor(getter_AddRefs(editor));
|
||||
if (editor) {
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(aElement);
|
||||
rv = range->SelectNode(node);
|
||||
if (NS_FAILED(rv)) {
|
||||
// The node might be detached from the document at this point,
|
||||
|
@ -363,7 +363,7 @@ function run_miscellaneous_tests() {
|
||||
baseRange.setStart(null, 0);
|
||||
do_throw("Should have thrown NOT_OBJECT_ERR!");
|
||||
} catch (e) {
|
||||
do_check_eq(e.name, "NS_ERROR_DOM_NOT_OBJECT_ERR");
|
||||
do_check_eq(e instanceof TypeError, true);
|
||||
}
|
||||
|
||||
// Invalid start node
|
||||
@ -371,7 +371,7 @@ function run_miscellaneous_tests() {
|
||||
baseRange.setStart({}, 0);
|
||||
do_throw("Should have thrown SecurityError!");
|
||||
} catch (e) {
|
||||
do_check_eq(e.name, "SecurityError");
|
||||
do_check_true(e instanceof TypeError);
|
||||
}
|
||||
|
||||
// Invalid index
|
||||
|
@ -572,6 +572,14 @@ DOMInterfaces = {
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
},
|
||||
|
||||
'Range': {
|
||||
'nativeType': 'nsRange',
|
||||
'resultNotAddRefed': [ 'startContainer', 'endContainer', 'commonAncestorContainer' ],
|
||||
'binaryNames': {
|
||||
'__stringifier': 'ToString'
|
||||
}
|
||||
},
|
||||
|
||||
'Rect': {
|
||||
'nativeType': 'nsDOMCSSRect',
|
||||
'resultNotAddRefed': [ 'top', 'right', 'bottom', 'left' ]
|
||||
@ -1226,7 +1234,6 @@ addExternalIface('OutputStream', nativeType='nsIOutputStream',
|
||||
notflattened=True)
|
||||
addExternalIface('Principal', nativeType='nsIPrincipal',
|
||||
headerFile='nsIPrincipal.h', notflattened=True)
|
||||
addExternalIface('Range', nativeType='nsRange')
|
||||
addExternalIface('Selection', nativeType='nsISelection')
|
||||
addExternalIface('StyleSheet', nativeType='nsIStyleSheet')
|
||||
addExternalIface('StyleSheetList')
|
||||
|
@ -75,45 +75,6 @@
|
||||
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"remove\" with the proper type (7)": true,
|
||||
"CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"remove\" with the proper type (7)": true,
|
||||
"CharacterData interface: document.createComment(\"abc\") must inherit property \"remove\" with the proper type (7)": true,
|
||||
"Range interface: existence and properties of interface object": true,
|
||||
"Range interface: existence and properties of interface prototype object": true,
|
||||
"Range interface: existence and properties of interface prototype object's \"constructor\" property": true,
|
||||
"Range interface: attribute startContainer": true,
|
||||
"Range interface: attribute startOffset": true,
|
||||
"Range interface: attribute endContainer": true,
|
||||
"Range interface: attribute endOffset": true,
|
||||
"Range interface: attribute collapsed": true,
|
||||
"Range interface: attribute commonAncestorContainer": true,
|
||||
"Range interface: calling setStart(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setEnd(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setStartBefore(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setStartAfter(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setEndBefore(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setEndAfter(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling collapse(boolean) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling selectNode(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling selectNodeContents(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling compareBoundaryPoints(unsigned short,Range) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling insertNode(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling surroundContents(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling isPointInRange(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling comparePoint(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling intersectsNode(Node) on document.createRange() with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setStart(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setEnd(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setStartBefore(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setStartAfter(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setEndBefore(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling setEndAfter(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling collapse(boolean) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling selectNode(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling selectNodeContents(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling compareBoundaryPoints(unsigned short,Range) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling insertNode(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling surroundContents(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling isPointInRange(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling comparePoint(Node,unsigned long) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"Range interface: calling intersectsNode(Node) on detachedRange with too few arguments must throw TypeError": true,
|
||||
"NodeFilter interface: existence and properties of interface object": true,
|
||||
"NodeFilter interface: existence and properties of interface prototype object": true,
|
||||
"NodeFilter interface: existence and properties of interface prototype object's \"constructor\" property": true,
|
||||
|
@ -25,7 +25,6 @@ MOCHITEST_FILES := \
|
||||
test_Range-commonAncestorContainer.html.json \
|
||||
test_Range-comparePoint.html.json \
|
||||
test_Range-detach.html.json \
|
||||
test_Range-intersectsNode-binding.html.json \
|
||||
test_attributes.html.json \
|
||||
test_case.html.json \
|
||||
test_historical.html.json \
|
||||
|
@ -1,4 +1,3 @@
|
||||
{
|
||||
"Range.comparePoint": true,
|
||||
"Range.comparePoint 1": true
|
||||
"Range.comparePoint": true
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"Calling intersectsNode without an argument or with an invalid argument should throw a TypeError.": true
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(b098fc8f-9ef4-4de8-bbd0-4a0fc712dd6e)]
|
||||
[scriptable, builtinclass, uuid(b098fc8f-9ef4-4de8-bbd0-4a0fc712dd6e)]
|
||||
interface nsIDOMDocumentFragment : nsIDOMNode
|
||||
{
|
||||
};
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
interface Attr;
|
||||
interface Comment;
|
||||
interface Range;
|
||||
interface StyleSheetList;
|
||||
interface Touch;
|
||||
interface TouchList;
|
||||
|
@ -4,49 +4,87 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.w3.org/TR/2012/WD-dom-20120105/
|
||||
* http://dom.spec.whatwg.org/#range
|
||||
* http://domparsing.spec.whatwg.org/#dom-range-createcontextualfragment
|
||||
* http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html#extensions-to-the-range-interface
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
interface ClientRect;
|
||||
|
||||
interface Range {
|
||||
[Throws]
|
||||
readonly attribute Node startContainer;
|
||||
[Throws]
|
||||
readonly attribute unsigned long startOffset;
|
||||
[Throws]
|
||||
readonly attribute Node endContainer;
|
||||
[Throws]
|
||||
readonly attribute unsigned long endOffset;
|
||||
readonly attribute boolean collapsed;
|
||||
[Throws]
|
||||
readonly attribute Node commonAncestorContainer;
|
||||
|
||||
[Throws]
|
||||
void setStart(Node refNode, unsigned long offset);
|
||||
[Throws]
|
||||
void setEnd(Node refNode, unsigned long offset);
|
||||
[Throws]
|
||||
void setStartBefore(Node refNode);
|
||||
[Throws]
|
||||
void setStartAfter(Node refNode);
|
||||
[Throws]
|
||||
void setEndBefore(Node refNode);
|
||||
[Throws]
|
||||
void setEndAfter(Node refNode);
|
||||
void collapse(boolean toStart);
|
||||
[Throws]
|
||||
void selectNode(Node refNode);
|
||||
[Throws]
|
||||
void selectNodeContents(Node refNode);
|
||||
|
||||
const unsigned short START_TO_START = 0;
|
||||
const unsigned short START_TO_END = 1;
|
||||
const unsigned short END_TO_END = 2;
|
||||
const unsigned short END_TO_START = 3;
|
||||
[Throws]
|
||||
short compareBoundaryPoints(unsigned short how, Range sourceRange);
|
||||
|
||||
[Throws]
|
||||
void deleteContents();
|
||||
[Throws]
|
||||
DocumentFragment extractContents();
|
||||
[Throws]
|
||||
DocumentFragment cloneContents();
|
||||
[Throws]
|
||||
void insertNode(Node node);
|
||||
[Throws]
|
||||
void surroundContents(Node newParent);
|
||||
|
||||
Range cloneRange();
|
||||
void detach();
|
||||
|
||||
[Throws]
|
||||
boolean isPointInRange(Node node, unsigned long offset);
|
||||
[Throws]
|
||||
short comparePoint(Node node, unsigned long offset);
|
||||
|
||||
[Throws]
|
||||
boolean intersectsNode(Node node);
|
||||
|
||||
stringifier;
|
||||
};
|
||||
|
||||
// http://domparsing.spec.whatwg.org/#dom-range-createcontextualfragment
|
||||
partial interface Range {
|
||||
[Throws]
|
||||
DocumentFragment createContextualFragment(DOMString fragment);
|
||||
};
|
||||
|
||||
// http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html#extensions-to-the-range-interface
|
||||
partial interface Range {
|
||||
[Throws]
|
||||
ClientRectList getClientRects();
|
||||
ClientRect getBoundingClientRect();
|
||||
};
|
||||
|
@ -133,6 +133,7 @@ webidl_files = \
|
||||
PerformanceNavigation.webidl \
|
||||
PerformanceTiming.webidl \
|
||||
ProcessingInstruction.webidl \
|
||||
Range.webidl \
|
||||
Rect.webidl \
|
||||
RGBColor.webidl \
|
||||
RTCConfiguration.webidl \
|
||||
|
@ -314,8 +314,13 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void)
|
||||
if(NS_FAILED(result))
|
||||
break;
|
||||
|
||||
nsRefPtr<nsRange> newRange = new nsRange();
|
||||
result = newRange->SetStart(mElement,mOffset+selectionStart);
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mElement);
|
||||
if (!content) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsRefPtr<nsRange> newRange = new nsRange(content);
|
||||
result = newRange->SetStart(content, mOffset+selectionStart);
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "Cannot SetStart");
|
||||
if(NS_FAILED(result))
|
||||
break;
|
||||
|
@ -247,20 +247,26 @@ nsHTMLEditRules::Init(nsPlaintextEditor *aEditor)
|
||||
mReturnInEmptyLIKillsList = !returnInEmptyLIKillsList.EqualsLiteral("false");
|
||||
|
||||
// make a utility range for use by the listenter
|
||||
mUtilRange = new nsRange();
|
||||
nsCOMPtr<nsINode> node = mHTMLEditor->GetRoot();
|
||||
if (!node) {
|
||||
node = mHTMLEditor->GetDocument();
|
||||
}
|
||||
|
||||
NS_ENSURE_STATE(node);
|
||||
|
||||
mUtilRange = new nsRange(node);
|
||||
|
||||
// set up mDocChangeRange to be whole doc
|
||||
nsCOMPtr<nsIDOMElement> rootElem = do_QueryInterface(mHTMLEditor->GetRoot());
|
||||
if (rootElem)
|
||||
{
|
||||
// temporarily turn off rules sniffing
|
||||
nsAutoLockRulesSniffing lockIt((nsTextEditRules*)this);
|
||||
if (!mDocChangeRange)
|
||||
{
|
||||
mDocChangeRange = new nsRange();
|
||||
}
|
||||
mDocChangeRange->SelectNode(rootElem);
|
||||
res = AdjustSpecialBreaks();
|
||||
// temporarily turn off rules sniffing
|
||||
nsAutoLockRulesSniffing lockIt((nsTextEditRules*)this);
|
||||
if (!mDocChangeRange) {
|
||||
mDocChangeRange = new nsRange(node);
|
||||
}
|
||||
|
||||
if (node->IsElement()) {
|
||||
ErrorResult rv;
|
||||
mDocChangeRange->SelectNode(*node, rv);
|
||||
res = AdjustSpecialBreaks(node);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
|
||||
@ -1440,7 +1446,9 @@ nsHTMLEditRules::WillInsertText(EditAction aAction,
|
||||
// the correct portion of the document.
|
||||
if (!mDocChangeRange)
|
||||
{
|
||||
mDocChangeRange = new nsRange();
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(selNode);
|
||||
NS_ENSURE_STATE(node);
|
||||
mDocChangeRange = new nsRange(node);
|
||||
}
|
||||
res = mDocChangeRange->SetStart(selNode, selOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@ -5069,7 +5077,9 @@ nsHTMLEditRules::ExpandSelectionForDeletion(nsISelection *aSelection)
|
||||
bool nodeBefore=false, nodeAfter=false;
|
||||
|
||||
// create a range that represents expanded selection
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(selStartNode);
|
||||
NS_ENSURE_STATE(node);
|
||||
nsRefPtr<nsRange> range = new nsRange(node);
|
||||
res = range->SetStart(selStartNode, selStartOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = range->SetEnd(selEndNode, selEndOffset);
|
||||
@ -6116,7 +6126,9 @@ nsHTMLEditRules::GetNodesFromPoint(DOMPoint point,
|
||||
point.GetPoint(node, offset);
|
||||
|
||||
// use it to make a range
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsCOMPtr<nsINode> nativeNode = do_QueryInterface(node);
|
||||
NS_ENSURE_STATE(nativeNode);
|
||||
nsRefPtr<nsRange> range = new nsRange(nativeNode);
|
||||
res = range->SetStart(node, offset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
/* SetStart() will also set the end for this new range
|
||||
@ -7296,7 +7308,9 @@ nsHTMLEditRules::PinSelectionToNewBlock(nsISelection *aSelection)
|
||||
temp = selNode;
|
||||
|
||||
// use ranges and sRangeHelper to compare sel point to new block
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(selNode);
|
||||
NS_ENSURE_STATE(node);
|
||||
nsRefPtr<nsRange> range = new nsRange(node);
|
||||
res = range->SetStart(selNode, selOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = range->SetEnd(selNode, selOffset);
|
||||
|
@ -3253,7 +3253,7 @@ nsHTMLEditor::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
|
||||
// Update spellcheck for only the newly-inserted node (bug 743819)
|
||||
if (mInlineSpellChecker) {
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(aChild);
|
||||
nsresult res = range->Set(aContainer, aIndexInContainer,
|
||||
aContainer, aIndexInContainer + 1);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
|
@ -1484,8 +1484,10 @@ nsWSRunObject::DeleteChars(nsIDOMNode *aStartNode, int32_t aStartOffset,
|
||||
{
|
||||
if (!range)
|
||||
{
|
||||
range = new nsRange();
|
||||
res = range->SetStart(aStartNode, aStartOffset);
|
||||
nsCOMPtr<nsINode> startNode = do_QueryInterface(aStartNode);
|
||||
NS_ENSURE_STATE(startNode);
|
||||
range = new nsRange(startNode);
|
||||
res = range->SetStart(startNode, aStartOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = range->SetEnd(aEndNode, aEndOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
@ -26,10 +26,12 @@ function command(aName)
|
||||
{
|
||||
var frame = document.getElementsByTagName('iframe')[0];
|
||||
|
||||
is(frame.contentDocument.designMode, "on", "design mode should be on!");
|
||||
var caught = false;
|
||||
try {
|
||||
frame.contentDocument.execCommand(aName, false, null);
|
||||
} catch (e) {
|
||||
ok(false, "exception " + e + " was thrown");
|
||||
caught = true;
|
||||
}
|
||||
|
||||
|
@ -57,13 +57,14 @@ NS_IMPL_CYCLE_COLLECTION_5(nsFilteredContentIterator,
|
||||
nsresult
|
||||
nsFilteredContentIterator::Init(nsINode* aRoot)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRoot);
|
||||
NS_ENSURE_TRUE(mPreIterator, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mIterator, NS_ERROR_FAILURE);
|
||||
mIsOutOfRange = false;
|
||||
mDirection = eForward;
|
||||
mCurrentIterator = mPreIterator;
|
||||
|
||||
mRange = new nsRange();
|
||||
mRange = new nsRange(aRoot);
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(aRoot));
|
||||
if (domNode) {
|
||||
mRange->SelectNode(domNode);
|
||||
|
@ -2070,7 +2070,10 @@ nsTextServicesDocument::CreateDocumentContentRange(nsIDOMRange **aRange)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsCOMPtr<nsINode> nativeNode = do_QueryInterface(node);
|
||||
NS_ENSURE_STATE(nativeNode);
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange(nativeNode);
|
||||
|
||||
rv = range->SelectNodeContents(node);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -147,6 +147,8 @@ nsresult
|
||||
nsFindContentIterator::Init(nsIDOMNode* aStartNode, int32_t aStartOffset,
|
||||
nsIDOMNode* aEndNode, int32_t aEndOffset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStartNode);
|
||||
NS_ENSURE_ARG_POINTER(aEndNode);
|
||||
if (!mOuterIterator) {
|
||||
if (mFindBackward) {
|
||||
// Use post-order in the reverse case, so we get parents
|
||||
@ -274,7 +276,10 @@ nsFindContentIterator::Reset()
|
||||
// Note: OK to just set up the outer iterator here; if our range has a native
|
||||
// anonymous endpoint we'll end up setting up an inner iterator, and
|
||||
// reset the outer one in the process.
|
||||
nsCOMPtr<nsIDOMRange> range = nsFind::CreateRange();
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(mStartNode);
|
||||
NS_ENSURE_TRUE_VOID(node);
|
||||
|
||||
nsCOMPtr<nsIDOMRange> range = nsFind::CreateRange(node);
|
||||
range->SetStart(mStartNode, mStartOffset);
|
||||
range->SetEnd(mEndNode, mEndOffset);
|
||||
mOuterIterator->Init(range);
|
||||
@ -366,10 +371,9 @@ nsFindContentIterator::SetupInnerIterator(nsIContent* aContent)
|
||||
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
editor->GetRootElement(getter_AddRefs(rootElement));
|
||||
nsCOMPtr<nsIContent> rootContent(do_QueryInterface(rootElement));
|
||||
|
||||
nsCOMPtr<nsIDOMRange> innerRange = nsFind::CreateRange();
|
||||
nsCOMPtr<nsIDOMRange> outerRange = nsFind::CreateRange();
|
||||
nsCOMPtr<nsIDOMRange> innerRange = nsFind::CreateRange(aContent);
|
||||
nsCOMPtr<nsIDOMRange> outerRange = nsFind::CreateRange(aContent);
|
||||
if (!innerRange || !outerRange) {
|
||||
return;
|
||||
}
|
||||
@ -1141,7 +1145,7 @@ nsFind::Find(const PRUnichar *aPatText, nsIDOMRange* aSearchRange,
|
||||
// Make the range:
|
||||
nsCOMPtr<nsIDOMNode> startParent;
|
||||
nsCOMPtr<nsIDOMNode> endParent;
|
||||
nsCOMPtr<nsIDOMRange> range = CreateRange();
|
||||
nsCOMPtr<nsIDOMRange> range = CreateRange(tc);
|
||||
if (range)
|
||||
{
|
||||
int32_t matchStartOffset, matchEndOffset;
|
||||
@ -1255,9 +1259,9 @@ nsFind::Find(const PRUnichar *aPatText, nsIDOMRange* aSearchRange,
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsIDOMRange>
|
||||
nsFind::CreateRange()
|
||||
nsFind::CreateRange(nsINode* aNode)
|
||||
{
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(aNode);
|
||||
range->SetMaySpanAnonymousSubtrees(true);
|
||||
return range.forget();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
nsFind();
|
||||
virtual ~nsFind();
|
||||
|
||||
static already_AddRefed<nsIDOMRange> CreateRange();
|
||||
static already_AddRefed<nsIDOMRange> CreateRange(nsINode* aNode);
|
||||
|
||||
protected:
|
||||
// Parameters set from the interface:
|
||||
|
@ -727,11 +727,11 @@ nsresult nsWebBrowserFind::SearchInFrame(nsIDOMWindow* aWindow,
|
||||
GetFrameSelection(aWindow, getter_AddRefs(sel));
|
||||
NS_ENSURE_ARG_POINTER(sel);
|
||||
|
||||
nsCOMPtr<nsIDOMRange> searchRange = nsFind::CreateRange();
|
||||
nsCOMPtr<nsIDOMRange> searchRange = nsFind::CreateRange(theDoc);
|
||||
NS_ENSURE_ARG_POINTER(searchRange);
|
||||
nsCOMPtr<nsIDOMRange> startPt = nsFind::CreateRange();
|
||||
nsCOMPtr<nsIDOMRange> startPt = nsFind::CreateRange(theDoc);
|
||||
NS_ENSURE_ARG_POINTER(startPt);
|
||||
nsCOMPtr<nsIDOMRange> endPt = nsFind::CreateRange();
|
||||
nsCOMPtr<nsIDOMRange> endPt = nsFind::CreateRange(theDoc);
|
||||
NS_ENSURE_ARG_POINTER(endPt);
|
||||
|
||||
nsCOMPtr<nsIDOMRange> foundRange;
|
||||
|
@ -132,7 +132,10 @@ mozInlineSpellStatus::InitForEditorChange(
|
||||
mOp = eOpChange;
|
||||
|
||||
// range to check
|
||||
mRange = new nsRange();
|
||||
nsCOMPtr<nsINode> prevNode = do_QueryInterface(aPreviousNode);
|
||||
NS_ENSURE_STATE(prevNode);
|
||||
|
||||
mRange = new nsRange(prevNode);
|
||||
|
||||
// ...we need to put the start and end in the correct order
|
||||
int16_t cmpResult;
|
||||
|
@ -317,10 +317,11 @@ nsresult
|
||||
mozInlineSpellWordUtil::MakeRange(NodeOffset aBegin, NodeOffset aEnd,
|
||||
nsRange** aRange)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aBegin.mNode);
|
||||
if (!mDOMDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(aBegin.mNode);
|
||||
nsresult rv = range->Set(aBegin.mNode, aBegin.mOffset,
|
||||
aEnd.mNode, aEnd.mOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -2914,7 +2914,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll)
|
||||
// Even if select anchor pref is false, we must still move the
|
||||
// caret there. That way tabbing will start from the new
|
||||
// location
|
||||
nsRefPtr<nsIDOMRange> jumpToRange = new nsRange();
|
||||
nsRefPtr<nsIDOMRange> jumpToRange = new nsRange(mDocument);
|
||||
while (content && content->GetFirstChild()) {
|
||||
content = content->GetFirstChild();
|
||||
}
|
||||
@ -4816,7 +4816,7 @@ PresShell::RenderNode(nsIDOMNode* aNode,
|
||||
if (!node->IsInDoc())
|
||||
return nullptr;
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(node);
|
||||
if (NS_FAILED(range->SelectNode(aNode)))
|
||||
return nullptr;
|
||||
|
||||
|
@ -778,7 +778,7 @@ nsTextControlFrame::SetSelectionInternal(nsIDOMNode *aStartNode,
|
||||
// Note that we use a new range to avoid having to do
|
||||
// isIncreasing checks to avoid possible errors.
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(mContent);
|
||||
nsresult rv = range->SetStart(aStartNode, aStartOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -1466,7 +1466,7 @@ nsFrameSelection::TakeFocus(nsIContent *aNewFocus,
|
||||
// non-anchor/focus collapsed ranges.
|
||||
mDomSelections[index]->RemoveCollapsedRanges();
|
||||
|
||||
nsRefPtr<nsRange> newRange = new nsRange();
|
||||
nsRefPtr<nsRange> newRange = new nsRange(aNewFocus);
|
||||
|
||||
newRange->SetStart(aNewFocus, aContentOffset);
|
||||
newRange->SetEnd(aNewFocus, aContentOffset);
|
||||
@ -2866,7 +2866,7 @@ nsFrameSelection::CreateAndAddRange(nsINode *aParentNode, int32_t aOffset)
|
||||
{
|
||||
if (!aParentNode) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(aParentNode);
|
||||
|
||||
// Set range around child at given offset
|
||||
nsresult result = range->SetStart(aParentNode, aOffset);
|
||||
@ -3276,7 +3276,7 @@ Selection::SubtractRange(RangeData* aRange, nsRange* aSubtract,
|
||||
if (cmp2 > 0) {
|
||||
// We need to add a new RangeData to the output, running from
|
||||
// the end of aSubtract to the end of range
|
||||
nsRefPtr<nsRange> postOverlap = new nsRange();
|
||||
nsRefPtr<nsRange> postOverlap = new nsRange(aSubtract->GetEndParent());
|
||||
|
||||
rv =
|
||||
postOverlap->SetStart(aSubtract->GetEndParent(), aSubtract->EndOffset());
|
||||
@ -3294,7 +3294,7 @@ Selection::SubtractRange(RangeData* aRange, nsRange* aSubtract,
|
||||
if (cmp < 0) {
|
||||
// We need to add a new RangeData to the output, running from
|
||||
// the start of the range to the start of aSubtract
|
||||
nsRefPtr<nsRange> preOverlap = new nsRange();
|
||||
nsRefPtr<nsRange> preOverlap = new nsRange(range->GetStartParent());
|
||||
|
||||
nsresult rv =
|
||||
preOverlap->SetStart(range->GetStartParent(), range->StartOffset());
|
||||
@ -4398,7 +4398,7 @@ Selection::Collapse(nsINode* aParentNode, int32_t aOffset)
|
||||
// Turn off signal for table selection
|
||||
mFrameSelection->ClearTableCellSelection();
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsRefPtr<nsRange> range = new nsRange(aParentNode);
|
||||
result = range->SetEnd(aParentNode, aOffset);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
@ -4654,7 +4654,7 @@ Selection::Extend(nsINode* aParentNode, int32_t aOffset)
|
||||
&disconnected);
|
||||
|
||||
nsRefPtr<nsPresContext> presContext = GetPresContext();
|
||||
nsRefPtr<nsRange> difRange = new nsRange();
|
||||
nsRefPtr<nsRange> difRange = new nsRange(aParentNode);
|
||||
if ((result1 == 0 && result3 < 0) || (result1 <= 0 && result2 < 0)){//a1,2 a,1,2
|
||||
//select from 1 to 2 unless they are collapsed
|
||||
res = range->SetEnd(aParentNode, aOffset);
|
||||
|
@ -2430,8 +2430,11 @@ CloneRangeToSelection(nsRange* aRange, nsIDocument* aDoc,
|
||||
nsCOMPtr<nsIDOMNode> newEnd = GetEqualNodeInCloneTree(endContainer, aDoc);
|
||||
NS_ENSURE_TRUE_VOID(newStart && newEnd);
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange();
|
||||
nsresult rv = range->SetStart(newStart, startOffset);
|
||||
nsCOMPtr<nsINode> newStartNode = do_QueryInterface(newStart);
|
||||
NS_ENSURE_TRUE_VOID(newStartNode);
|
||||
|
||||
nsRefPtr<nsRange> range = new nsRange(newStartNode);
|
||||
nsresult rv = range->SetStart(newStartNode, startOffset);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
rv = range->SetEnd(newEnd, endOffset);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
@ -94,9 +94,12 @@ nsresult
|
||||
nsTypeAheadFind::Init(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefInternal(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
mSearchRange = new nsRange();
|
||||
mStartPointRange = new nsRange();
|
||||
mEndPointRange = new nsRange();
|
||||
nsIPresShell* presShell = aDocShell->GetPresShell();
|
||||
NS_ENSURE_STATE(presShell);
|
||||
|
||||
mSearchRange = nullptr;
|
||||
mStartPointRange = nullptr;
|
||||
mEndPointRange = nullptr;
|
||||
if (!prefInternal || !EnsureFind())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -166,12 +169,12 @@ nsTypeAheadFind::SetDocShell(nsIDocShell* aDocShell)
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
presShell = aDocShell->GetPresShell();
|
||||
mPresShell = do_GetWeakReference(presShell);
|
||||
mPresShell = do_GetWeakReference(presShell);
|
||||
|
||||
mStartFindRange = nullptr;
|
||||
mStartPointRange = new nsRange();
|
||||
mSearchRange = new nsRange();
|
||||
mEndPointRange = new nsRange();
|
||||
mStartPointRange = nullptr;
|
||||
mSearchRange = nullptr;
|
||||
mEndPointRange = nullptr;
|
||||
|
||||
mFoundLink = nullptr;
|
||||
mFoundEditable = nullptr;
|
||||
@ -361,6 +364,10 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
|
||||
}
|
||||
|
||||
int16_t rangeCompareResult = 0;
|
||||
if (!mStartPointRange) {
|
||||
mStartPointRange = new nsRange(presShell->GetDocument());
|
||||
}
|
||||
|
||||
mStartPointRange->CompareBoundaryPoints(nsIDOMRange::START_TO_START, mSearchRange, &rangeCompareResult);
|
||||
// No need to wrap find in doc if starting at beginning
|
||||
bool hasWrapped = (rangeCompareResult < 0);
|
||||
@ -621,6 +628,10 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
|
||||
// at end of document and go to beginning
|
||||
nsCOMPtr<nsIDOMRange> tempRange;
|
||||
mStartPointRange->CloneRange(getter_AddRefs(tempRange));
|
||||
if (!mEndPointRange) {
|
||||
mEndPointRange = new nsRange(presShell->GetDocument());
|
||||
}
|
||||
|
||||
mStartPointRange = mEndPointRange;
|
||||
mEndPointRange = tempRange;
|
||||
}
|
||||
@ -719,6 +730,14 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
|
||||
|
||||
uint32_t childCount = rootContent->GetChildCount();
|
||||
|
||||
if (!mSearchRange) {
|
||||
mSearchRange = new nsRange(rootContent);
|
||||
}
|
||||
|
||||
if (!mEndPointRange) {
|
||||
mEndPointRange = new nsRange(rootContent);
|
||||
}
|
||||
|
||||
mSearchRange->SelectNodeContents(rootNode);
|
||||
|
||||
mEndPointRange->SetEnd(rootNode, childCount);
|
||||
@ -736,6 +755,10 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
|
||||
selection->GetRangeAt(0, getter_AddRefs(currentSelectionRange));
|
||||
}
|
||||
|
||||
if (!mStartPointRange) {
|
||||
mStartPointRange = new nsRange(doc);
|
||||
}
|
||||
|
||||
if (!currentSelectionRange) {
|
||||
// Ensure visible range, move forward if necessary
|
||||
// This uses ignores the return value, but usese the side effect of
|
||||
|
Loading…
Reference in New Issue
Block a user