зеркало из https://github.com/mozilla/gecko-dev.git
Bug 682611 - Part 1: Merge nsIDOMRange and nsIDOMNSRange; r=Ms2ger r=smaug
This commit is contained in:
Родитель
3b93d37fa9
Коммит
36d49f44a6
|
@ -50,7 +50,6 @@
|
|||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIEditingSession.h"
|
||||
#include "nsIEditor.h"
|
||||
|
@ -2355,11 +2354,10 @@ nsHyperTextAccessible::GetSpellTextAttribute(nsIDOMNode *aNode,
|
|||
|
||||
for (PRInt32 index = 0; index < rangeCount; index++) {
|
||||
nsCOMPtr<nsIDOMRange> range = ranges[index];
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange(do_QueryInterface(range));
|
||||
NS_ENSURE_STATE(nsrange);
|
||||
NS_ENSURE_STATE(range);
|
||||
|
||||
PRInt16 result;
|
||||
nsresult rv = nsrange->ComparePoint(aNode, aNodeOffset, &result);
|
||||
nsresult rv = range->ComparePoint(aNode, aNodeOffset, &result);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// ComparePoint checks boundary points, but we need to check that
|
||||
// text at aNodeOffset is inside the range.
|
||||
|
|
|
@ -336,7 +336,6 @@ DOMCI_DATA(Range, nsRange)
|
|||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsRange)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMRange)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRange)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSRange)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRange)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Range)
|
||||
|
@ -665,9 +664,9 @@ nsRange::ParentChainChanged(nsIContent *aContent)
|
|||
DoSetRange(mStartParent, mStartOffset, mEndParent, mEndOffset, newRoot);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* Utilities for comparing points: API from nsIDOMNSRange
|
||||
********************************************************/
|
||||
/******************************************************
|
||||
* Utilities for comparing points: API from nsIDOMRange
|
||||
******************************************************/
|
||||
NS_IMETHODIMP
|
||||
nsRange::IsPointInRange(nsIDOMNode* aParent, PRInt32 aOffset, bool* aResult)
|
||||
{
|
||||
|
@ -2377,7 +2376,6 @@ nsRange::Detach()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIDOMNSRange interface
|
||||
NS_IMETHODIMP
|
||||
nsRange::CreateContextualFragment(const nsAString& aFragment,
|
||||
nsIDOMDocumentFragment** aReturn)
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "nsIRange.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIRangeUtils.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -73,7 +72,6 @@ public:
|
|||
// -------------------------------------------------------------------------------
|
||||
|
||||
class nsRange : public nsIRange,
|
||||
public nsIDOMNSRange,
|
||||
public nsStubMutationObserver
|
||||
{
|
||||
public:
|
||||
|
@ -85,9 +83,6 @@ public:
|
|||
|
||||
// nsIDOMRange interface
|
||||
NS_DECL_NSIDOMRANGE
|
||||
|
||||
// nsIDOMNSRange interface
|
||||
NS_DECL_NSIDOMNSRANGE
|
||||
|
||||
// nsIRange interface
|
||||
virtual nsINode* GetCommonAncestor() const;
|
||||
|
|
|
@ -30,8 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=451376
|
|||
aInRangeNode, aInRangeOffset,
|
||||
aAfterRangeNode, aAfterRangeOffset)
|
||||
{
|
||||
var range = document.createRange().
|
||||
QueryInterface(Components.interfaces.nsIDOMNSRange);
|
||||
var range = document.createRange();
|
||||
|
||||
range.setStart(aStartNode, aStartOffset);
|
||||
range.setEnd(aEndNode, aEndOffset);
|
||||
|
|
|
@ -503,7 +503,6 @@ function run_miscellaneous_tests() {
|
|||
|
||||
/*
|
||||
// XXX ajvincent if rv == WRONG_DOCUMENT_ERR, return false?
|
||||
do_check_true(baseRange instanceof C_i.nsIDOMNSRange);
|
||||
do_check_false(baseRange.isPointInRange(startContainer, startOffset));
|
||||
do_check_false(baseRange.isPointInRange(startContainer, startOffset + 1));
|
||||
do_check_false(baseRange.isPointInRange(endContainer, endOffset));
|
||||
|
|
|
@ -329,7 +329,6 @@
|
|||
#include "nsIDOMDeviceOrientationEvent.h"
|
||||
#include "nsIDOMDeviceMotionEvent.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDOMRangeException.h"
|
||||
#include "nsIDOMNodeIterator.h"
|
||||
#include "nsIDOMTreeWalker.h"
|
||||
|
@ -2955,7 +2954,6 @@ nsDOMClassInfo::Init()
|
|||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Range, nsIDOMRange)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMRange)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSRange)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(NodeIterator, nsIDOMNodeIterator)
|
||||
|
|
|
@ -46,12 +46,11 @@ MODULE = dom
|
|||
XPIDL_MODULE = dom_range
|
||||
GRE_MODULE = 1
|
||||
|
||||
SDK_XPIDLSRCS = \
|
||||
nsIDOMRange.idl \
|
||||
SDK_XPIDLSRCS = \
|
||||
nsIDOMRange.idl \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIDOMNSRange.idl \
|
||||
XPIDLSRCS = \
|
||||
nsIDOMRangeException.idl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao <vidur@netscape.com> (original author)
|
||||
* Johnny Stenback <jst@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(fed93d11-f24d-41d8-ae55-4197927999bb)]
|
||||
interface nsIDOMNSRange : nsISupports
|
||||
{
|
||||
nsIDOMDocumentFragment createContextualFragment(in DOMString fragment);
|
||||
|
||||
// This returns true if parent+offset equals either
|
||||
// of the boundary points or is between them.
|
||||
boolean isPointInRange(in nsIDOMNode parent,
|
||||
in long offset);
|
||||
|
||||
// comparePoint returns
|
||||
// -1 if point is before the start boundary point,
|
||||
// 0 if point is either of the boundary points or between them,
|
||||
// 1 if point is after the end boundary point.
|
||||
// Sort of a strcmp for ranges.
|
||||
short comparePoint(in nsIDOMNode parent, in long offset);
|
||||
|
||||
nsIDOMClientRectList getClientRects();
|
||||
nsIDOMClientRect getBoundingClientRect();
|
||||
};
|
|
@ -46,7 +46,7 @@
|
|||
* http://www.w3.org/TR/DOM-Level-2-Traversal-Range/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(a6cf90ce-15b3-11d2-932e-00805f8add32)]
|
||||
[scriptable, uuid(a059eea8-fece-4c14-93d3-7f50a944ae43)]
|
||||
interface nsIDOMRange : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMNode startContainer;
|
||||
|
@ -110,4 +110,25 @@ interface nsIDOMRange : nsISupports
|
|||
DOMString toString()
|
||||
raises(DOMException);
|
||||
void detach();
|
||||
|
||||
// This method comes from
|
||||
// http://html5.org/specs/dom-parsing.html#extensions-to-the-range-interface
|
||||
nsIDOMDocumentFragment createContextualFragment(in DOMString fragment);
|
||||
|
||||
// This returns true if parent+offset equals either
|
||||
// of the boundary points or is between them.
|
||||
boolean isPointInRange(in nsIDOMNode parent,
|
||||
in long offset);
|
||||
|
||||
// comparePoint returns
|
||||
// -1 if point is before the start boundary point,
|
||||
// 0 if point is either of the boundary points or between them,
|
||||
// 1 if point is after the end boundary point.
|
||||
// Sort of a strcmp for ranges.
|
||||
short comparePoint(in nsIDOMNode parent, in long offset);
|
||||
|
||||
// These methods come from
|
||||
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface
|
||||
nsIDOMClientRectList getClientRects();
|
||||
nsIDOMClientRect getBoundingClientRect();
|
||||
};
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
#include "nsIDragSession.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsEditorUtils.h"
|
||||
#include "nsISelectionPrivate.h"
|
||||
#include "nsIDOMDragEvent.h"
|
||||
|
@ -886,12 +886,11 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
|||
{
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
rv = selection->GetRangeAt(i, getter_AddRefs(range));
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange(do_QueryInterface(range));
|
||||
if (NS_FAILED(rv) || !nsrange)
|
||||
if (NS_FAILED(rv) || !range)
|
||||
continue; //don't bail yet, iterate through them all
|
||||
|
||||
bool inRange = true;
|
||||
(void)nsrange->IsPointInRange(parent, offset, &inRange);
|
||||
(void)range->IsPointInRange(parent, offset, &inRange);
|
||||
if (inRange)
|
||||
return false; //okay, now you can bail, we are over the orginal selection
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIURL.h"
|
||||
|
@ -212,13 +211,11 @@ NS_IMETHODIMP nsHTMLEditor::LoadHTML(const nsAString & aInputString)
|
|||
res = selection->GetRangeAt(0, getter_AddRefs(range));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange (do_QueryInterface(range));
|
||||
NS_ENSURE_TRUE(nsrange, NS_ERROR_NO_INTERFACE);
|
||||
|
||||
// create fragment for pasted html
|
||||
nsCOMPtr<nsIDOMDocumentFragment> docfrag;
|
||||
{
|
||||
res = nsrange->CreateContextualFragment(aInputString, getter_AddRefs(docfrag));
|
||||
res = range->CreateContextualFragment(aInputString, getter_AddRefs(docfrag));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
// put the fragment into the document
|
||||
|
@ -1564,11 +1561,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
|||
if (NS_FAILED(rv) || !range)
|
||||
continue;//don't bail yet, iterate through them all
|
||||
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange(do_QueryInterface(range));
|
||||
if (NS_FAILED(rv) || !nsrange)
|
||||
continue;//don't bail yet, iterate through them all
|
||||
|
||||
rv = nsrange->IsPointInRange(newSelectionParent, newSelectionOffset, &cursorIsInSelection);
|
||||
rv = range->IsPointInRange(newSelectionParent, newSelectionOffset, &cursorIsInSelection);
|
||||
if(cursorIsInSelection)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#include "nsISelectionPrivate.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIRangeUtils.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIEnumerator.h"
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIRangeUtils.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -1603,11 +1602,9 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
|
|||
res = selection->GetRangeAt(0, getter_AddRefs(range));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange (do_QueryInterface(range));
|
||||
NS_ENSURE_TRUE(nsrange, NS_ERROR_NO_INTERFACE);
|
||||
nsCOMPtr<nsIDOMDocumentFragment> docfrag;
|
||||
res = nsrange->CreateContextualFragment(inputString,
|
||||
getter_AddRefs(docfrag));
|
||||
res = range->CreateContextualFragment(inputString,
|
||||
getter_AddRefs(docfrag));
|
||||
|
||||
//XXXX BUG 50965: This is not returning the text between <title> ... </title>
|
||||
// Special code is needed in JS to handle title anyway, so it really doesn't matter!
|
||||
|
@ -1769,11 +1766,8 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
|
|||
res = selection->GetRangeAt(0, getter_AddRefs(range));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange (do_QueryInterface(range));
|
||||
NS_ENSURE_TRUE(nsrange, NS_ERROR_NO_INTERFACE);
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentFragment> docfrag;
|
||||
res = nsrange->CreateContextualFragment(bodyTag, getter_AddRefs(docfrag));
|
||||
res = range->CreateContextualFragment(bodyTag, getter_AddRefs(docfrag));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> fragmentAsNode (do_QueryInterface(docfrag));
|
||||
|
|
|
@ -74,7 +74,6 @@
|
|||
|
||||
class nsIDOMKeyEvent;
|
||||
class nsITransferable;
|
||||
class nsIDOMNSRange;
|
||||
class nsIDocumentEncoder;
|
||||
class nsIClipboard;
|
||||
class TypeInState;
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsISelection.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMHTMLTableElement.h"
|
||||
#include "nsIDOMHTMLTableCellElement.h"
|
||||
|
@ -178,11 +177,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
|||
if (NS_FAILED(res) || !range)
|
||||
continue;//don't bail yet, iterate through them all
|
||||
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange(do_QueryInterface(range));
|
||||
if (NS_FAILED(res) || !nsrange)
|
||||
continue;//don't bail yet, iterate through them all
|
||||
|
||||
res = nsrange->IsPointInRange(parent, offset, &nodeIsInSelection);
|
||||
res = range->IsPointInRange(parent, offset, &nodeIsInSelection);
|
||||
|
||||
// Done when we find a range that we are in
|
||||
if (nodeIsInSelection)
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
||||
|
@ -233,11 +232,10 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
|||
{
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
rv = selection->GetRangeAt(j, getter_AddRefs(range));
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange(do_QueryInterface(range));
|
||||
if (NS_FAILED(rv) || !nsrange)
|
||||
if (NS_FAILED(rv) || !range)
|
||||
continue; // don't bail yet, iterate through them all
|
||||
|
||||
rv = nsrange->IsPointInRange(newSelectionParent, newSelectionOffset, &cursorIsInSelection);
|
||||
rv = range->IsPointInRange(newSelectionParent, newSelectionOffset, &cursorIsInSelection);
|
||||
if (cursorIsInSelection)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "nsISelectionPrivate.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
|
|
|
@ -278,13 +278,10 @@ ContentIsInTraversalRange(nsIContent *aContent, bool aIsPreMode,
|
|||
}
|
||||
|
||||
static bool
|
||||
ContentIsInTraversalRange(nsIDOMNSRange *aRange, nsIDOMNode* aNextNode, bool aIsPreMode)
|
||||
ContentIsInTraversalRange(nsIDOMRange *aRange, nsIDOMNode* aNextNode, bool aIsPreMode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNextNode));
|
||||
nsCOMPtr<nsIDOMRange> range(do_QueryInterface(aRange));
|
||||
NS_ENSURE_TRUE(content && range, false);
|
||||
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNextNode));
|
||||
NS_ENSURE_TRUE(content && aRange, false);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> sNode;
|
||||
nsCOMPtr<nsIDOMNode> eNode;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsITextServicesFilter.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIRangeUtils.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
|
@ -97,7 +97,7 @@ protected:
|
|||
nsCOMPtr<nsIAtom> mMapAtom;
|
||||
|
||||
nsCOMPtr<nsITextServicesFilter> mFilter;
|
||||
nsCOMPtr<nsIDOMNSRange> mRange;
|
||||
nsCOMPtr<nsIDOMRange> mRange;
|
||||
bool mDidSkip;
|
||||
bool mIsOutOfRange;
|
||||
eDirectionType mDirection;
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIPlaintextEditor.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
@ -169,10 +168,8 @@ mozInlineSpellStatus::InitForEditorChange(
|
|||
mRange = new nsRange();
|
||||
|
||||
// ...we need to put the start and end in the correct order
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange = do_QueryInterface(mAnchorRange, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
PRInt16 cmpResult;
|
||||
rv = nsrange->ComparePoint(aPreviousNode, aPreviousOffset, &cmpResult);
|
||||
rv = mAnchorRange->ComparePoint(aPreviousNode, aPreviousOffset, &cmpResult);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cmpResult < 0) {
|
||||
// previous anchor node is before the current anchor
|
||||
|
@ -194,17 +191,14 @@ mozInlineSpellStatus::InitForEditorChange(
|
|||
|
||||
// if we were given a range, we need to expand our range to encompass it
|
||||
if (aStartNode && aEndNode) {
|
||||
nsrange = do_QueryInterface(mRange, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = nsrange->ComparePoint(aStartNode, aStartOffset, &cmpResult);
|
||||
rv = mRange->ComparePoint(aStartNode, aStartOffset, &cmpResult);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cmpResult < 0) { // given range starts before
|
||||
rv = mRange->SetStart(aStartNode, aStartOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = nsrange->ComparePoint(aEndNode, aEndOffset, &cmpResult);
|
||||
rv = mRange->ComparePoint(aEndNode, aEndOffset, &cmpResult);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cmpResult > 0) { // given range ends after
|
||||
rv = mRange->SetEnd(aEndNode, aEndOffset);
|
||||
|
@ -385,9 +379,6 @@ mozInlineSpellStatus::FinishNavigationEvent(mozInlineSpellWordUtil& aWordUtil)
|
|||
if (! editor)
|
||||
return NS_ERROR_FAILURE; // editor is gone
|
||||
|
||||
nsCOMPtr<nsIDOMNSRange> oldWordNS = do_QueryInterface(oldWord, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get the DOM position of the new caret, the range should be collapsed
|
||||
rv = mAnchorRange->GetStartContainer(getter_AddRefs(newAnchorNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -397,9 +388,9 @@ mozInlineSpellStatus::FinishNavigationEvent(mozInlineSpellWordUtil& aWordUtil)
|
|||
// see if the new cursor position is in the word of the old cursor position
|
||||
bool isInRange = false;
|
||||
if (! mForceNavigationWordCheck) {
|
||||
rv = oldWordNS->IsPointInRange(newAnchorNode,
|
||||
newAnchorOffset + mNewNavigationPositionOffset,
|
||||
&isInRange);
|
||||
rv = oldWord->IsPointInRange(newAnchorNode,
|
||||
newAnchorOffset + mNewNavigationPositionOffset,
|
||||
&isInRange);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -1351,13 +1342,6 @@ nsresult mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil& aWordUtil,
|
|||
editor = do_QueryReferent(mEditor);
|
||||
if (! editor)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// we need to use IsPointInRange which is on a more specific interface
|
||||
nsCOMPtr<nsIDOMNSRange> noCheckRange, createdRange;
|
||||
if (aStatus->mNoCheckRange)
|
||||
noCheckRange = do_QueryInterface(aStatus->mNoCheckRange);
|
||||
if (aStatus->mCreatedRange)
|
||||
createdRange = do_QueryInterface(aStatus->mCreatedRange);
|
||||
|
||||
PRInt32 wordsSinceTimeCheck = 0;
|
||||
PRTime beginTime = PR_Now();
|
||||
|
@ -1394,8 +1378,8 @@ nsresult mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil& aWordUtil,
|
|||
if (originalRangeCount > 0) {
|
||||
// likewise, if this word is inside new text, we won't bother testing
|
||||
bool inCreatedRange = false;
|
||||
if (createdRange)
|
||||
createdRange->IsPointInRange(beginNode, beginOffset, &inCreatedRange);
|
||||
if (aStatus->mCreatedRange)
|
||||
aStatus->mCreatedRange->IsPointInRange(beginNode, beginOffset, &inCreatedRange);
|
||||
if (! inCreatedRange) {
|
||||
nsCOMArray<nsIDOMRange> ranges;
|
||||
rv = privSel->GetRangesForIntervalCOMArray(beginNode, beginOffset,
|
||||
|
@ -1425,9 +1409,10 @@ nsresult mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil& aWordUtil,
|
|||
// We do a simple check to see if the beginning of our word is in the
|
||||
// exclusion range. Because the exclusion range is a multiple of a word,
|
||||
// this is sufficient.
|
||||
if (noCheckRange) {
|
||||
if (aStatus->mNoCheckRange) {
|
||||
bool inExclusion = false;
|
||||
noCheckRange->IsPointInRange(beginNode, beginOffset, &inExclusion);
|
||||
aStatus->mNoCheckRange->IsPointInRange(beginNode, beginOffset,
|
||||
&inExclusion);
|
||||
if (inExclusion)
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
|
|
@ -1454,7 +1454,7 @@ var SelectionHandler = {
|
|||
if (selection.rangeCount == 0)
|
||||
return;
|
||||
|
||||
let range = selection.getRangeAt(0).QueryInterface(Ci.nsIDOMNSRange);
|
||||
let range = selection.getRangeAt(0);
|
||||
if (!range)
|
||||
return;
|
||||
|
||||
|
@ -1534,7 +1534,7 @@ var SelectionHandler = {
|
|||
this.selectedText = selection.toString().trim();
|
||||
|
||||
// Update the rect we use to test when finishing the clipboard operation
|
||||
let range = selection.getRangeAt(0).QueryInterface(Ci.nsIDOMNSRange);
|
||||
let range = selection.getRangeAt(0)
|
||||
this.cache.rect = this._extractFromRange(range, this.cache.offset).rect;
|
||||
break;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче