зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1436285 - Part 1. Don't use nsIDOMNode version of GetStartNodeAndOffset and GetEndNodeAndOffset. r=masayuki
To get a rid of some methods, I would like to replace nsIDOMNode usages with nsINode. MozReview-Commit-ID: B0FVczayND0 --HG-- extra : rebase_source : ede058089332202ba0c05ddb61e0f119cbf52fcb
This commit is contained in:
Родитель
4a44620118
Коммит
d89148b69b
|
@ -2203,7 +2203,7 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
|||
}
|
||||
|
||||
// Test for distance between caret and text that will be deleted
|
||||
rv = CheckBidiLevelForDeletion(aSelection, GetAsDOMNode(startNode),
|
||||
rv = CheckBidiLevelForDeletion(aSelection, startNode,
|
||||
startOffset, aAction, aCancel);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (*aCancel) {
|
||||
|
@ -7993,7 +7993,7 @@ nsresult
|
|||
HTMLEditRules::AdjustWhitespace(Selection* aSelection)
|
||||
{
|
||||
// get selection point
|
||||
nsCOMPtr<nsIDOMNode> selNode;
|
||||
nsCOMPtr<nsINode> selNode;
|
||||
int32_t selOffset;
|
||||
nsresult rv =
|
||||
EditorBase::GetStartNodeAndOffset(aSelection,
|
||||
|
@ -8018,18 +8018,21 @@ HTMLEditRules::PinSelectionToNewBlock(Selection* aSelection)
|
|||
}
|
||||
|
||||
// get the (collapsed) selection location
|
||||
nsCOMPtr<nsIDOMNode> selNode;
|
||||
nsCOMPtr<nsINode> selNode;
|
||||
int32_t selOffset;
|
||||
nsresult rv =
|
||||
EditorBase::GetStartNodeAndOffset(aSelection,
|
||||
getter_AddRefs(selNode), &selOffset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
if (NS_WARN_IF(!selNode)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// use ranges and sRangeHelper to compare sel point to new block
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(selNode);
|
||||
NS_ENSURE_STATE(node);
|
||||
RefPtr<nsRange> range = new nsRange(node);
|
||||
rv = range->CollapseTo(node, selOffset);
|
||||
RefPtr<nsRange> range = new nsRange(selNode);
|
||||
rv = range->CollapseTo(selNode, selOffset);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
|||
aTrustedInput);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> targetNode;
|
||||
nsCOMPtr<nsINode> targetNode;
|
||||
int32_t targetOffset=0;
|
||||
|
||||
if (!aDestNode) {
|
||||
|
@ -239,7 +239,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
targetNode = aDestNode;
|
||||
targetNode = do_QueryInterface(aDestNode);
|
||||
targetOffset = aDestOffset;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIPlaintextEditor.h"
|
||||
|
@ -1033,7 +1032,7 @@ TextEditRules::WillDeleteSelection(Selection* aSelection,
|
|||
mPasswordText.Cut(start, end-start);
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMNode> startNode;
|
||||
nsCOMPtr<nsINode> startNode;
|
||||
int32_t startOffset;
|
||||
nsresult rv =
|
||||
EditorBase::GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode),
|
||||
|
|
|
@ -262,7 +262,7 @@ protected:
|
|||
void UndefineCaretBidiLevel(Selection* aSelection);
|
||||
|
||||
nsresult CheckBidiLevelForDeletion(Selection* aSelection,
|
||||
nsIDOMNode* aSelNode,
|
||||
nsINode* aSelNode,
|
||||
int32_t aSelOffset,
|
||||
nsIEditor::EDirection aAction,
|
||||
bool* aCancel);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "nsError.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
@ -26,7 +25,7 @@ using namespace dom;
|
|||
// Test for distance between caret and text that will be deleted
|
||||
nsresult
|
||||
TextEditRules::CheckBidiLevelForDeletion(Selection* aSelection,
|
||||
nsIDOMNode* aSelNode,
|
||||
nsINode* aSelNode,
|
||||
int32_t aSelOffset,
|
||||
nsIEditor::EDirection aAction,
|
||||
bool* aCancel)
|
||||
|
@ -44,8 +43,10 @@ TextEditRules::CheckBidiLevelForDeletion(Selection* aSelection,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aSelNode);
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_NULL_POINTER);
|
||||
if (!aSelNode || !aSelNode->IsContent()) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsCOMPtr<nsIContent> content = aSelNode->AsContent();
|
||||
|
||||
nsBidiLevel levelBefore;
|
||||
nsBidiLevel levelAfter;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "nsAString.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsISupportsBase.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
@ -91,9 +91,8 @@ TypeInState::OnSelectionChange(Selection& aSelection)
|
|||
// XXX: This code temporarily fixes the problem where clicking the mouse in
|
||||
// XXX: the same location clears the type-in-state.
|
||||
|
||||
// TODO: We can make this use nsINode instead of nsIDOMNode.
|
||||
if (aSelection.IsCollapsed() && aSelection.RangeCount()) {
|
||||
nsCOMPtr<nsIDOMNode> selNode;
|
||||
nsCOMPtr<nsINode> selNode;
|
||||
int32_t selOffset = 0;
|
||||
|
||||
nsresult rv =
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#endif
|
||||
|
||||
class nsAtom;
|
||||
class nsIDOMNode;
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -97,7 +97,7 @@ protected:
|
|||
nsTArray<PropItem*> mSetArray;
|
||||
nsTArray<PropItem*> mClearedArray;
|
||||
int32_t mRelativeFontSize;
|
||||
nsCOMPtr<nsIDOMNode> mLastSelectionContainer;
|
||||
nsCOMPtr<nsINode> mLastSelectionContainer;
|
||||
int32_t mLastSelectionOffset;
|
||||
|
||||
friend class HTMLEditRules;
|
||||
|
|
Загрузка…
Ссылка в новой задаче