mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1260651 part.59 Rename nsEditor to mozilla::EditorBase (and also their file names) r=mccr8
This patch also renames: EditorInputEventDispatcher -> mozilla::EditorInputEventDispatcher And some variable names are renamed from aEditor or mEditor to aEditorBase or mEditorBase for making their types clearer. MozReview-Commit-ID: 2FCXWpLMn8e --HG-- rename : editor/libeditor/nsEditor.cpp => editor/libeditor/EditorBase.cpp rename : editor/libeditor/nsEditor.h => editor/libeditor/EditorBase.h
This commit is contained in:
parent
a4ac19d311
commit
f382711dc3
@ -160,7 +160,7 @@ ContentEventHandler::InitRootContent(Selection* aNormalSelection)
|
||||
|
||||
// If there is a selection, we should retrieve the selection root from
|
||||
// the range since when the window is inactivated, the ancestor limiter
|
||||
// of selection was cleared by blur event handler of nsEditor but the
|
||||
// of selection was cleared by blur event handler of EditorBase but the
|
||||
// selection range still keeps storing the nodes. If the active element of
|
||||
// the deactive window is <input> or <textarea>, we can compute the
|
||||
// selection root from them.
|
||||
@ -2054,7 +2054,7 @@ ContentEventHandler::AdjustCollapsedRangeMaybeIntoTextNode(nsRange* aRange)
|
||||
|
||||
// If the parent is not a text node but it has a text node at the offset,
|
||||
// we should adjust the range into the text node.
|
||||
// NOTE: This is emulating similar situation of nsEditor.
|
||||
// NOTE: This is emulating similar situation of EditorBase.
|
||||
nsINode* childNode = nullptr;
|
||||
int32_t offsetInChildNode = -1;
|
||||
if (!offsetInParentNode && parentNode->HasChildren()) {
|
||||
|
@ -719,7 +719,7 @@ NON_IDL_EVENT(speakerforcedchange,
|
||||
|
||||
// Events that only have on* attributes on XUL elements
|
||||
|
||||
// "text" event is legacy event for modifying composition string in nsEditor.
|
||||
// "text" event is legacy event for modifying composition string in EditorBase.
|
||||
// This shouldn't be used by web/xul apps. "compositionupdate" should be
|
||||
// used instead.
|
||||
NON_IDL_EVENT(text,
|
||||
|
@ -641,7 +641,7 @@ IMEContentObserver::IsEditorComposing() const
|
||||
// Note that don't use TextComposition here. The important thing is,
|
||||
// whether the editor already started to handle composition because
|
||||
// web contents can change selection, text content and/or something from
|
||||
// compositionstart event listener which is run before nsEditor handles it.
|
||||
// compositionstart event listener which is run before EditorBase handles it.
|
||||
nsCOMPtr<nsIEditorIMESupport> editorIMESupport = do_QueryInterface(mEditor);
|
||||
if (NS_WARN_IF(!editorIMESupport)) {
|
||||
return false;
|
||||
|
@ -880,8 +880,8 @@ IMEStateManager::GetNewIMEState(nsPresContext* aPresContext,
|
||||
}
|
||||
|
||||
// nsIContent::GetDesiredIMEState() may cause a call of UpdateIMEState()
|
||||
// from nsEditor::PostCreate() because GetDesiredIMEState() needs to retrieve
|
||||
// an editor instance for the element if it's editable element.
|
||||
// from EditorBase::PostCreate() because GetDesiredIMEState() needs to
|
||||
// retrieve an editor instance for the element if it's editable element.
|
||||
// For avoiding such nested IME state updates, we should set
|
||||
// sIsGettingNewIMEState here and UpdateIMEState() should check it.
|
||||
GettingNewIMEStateBlocker blocker;
|
||||
|
@ -5,11 +5,11 @@
|
||||
|
||||
#include "CompositionTransaction.h"
|
||||
|
||||
#include "mozilla/EditorBase.h" // mEditorBase
|
||||
#include "mozilla/dom/Selection.h" // local var
|
||||
#include "mozilla/dom/Text.h" // mTextNode
|
||||
#include "nsAString.h" // params
|
||||
#include "nsDebug.h" // for NS_ASSERTION, etc
|
||||
#include "nsEditor.h" // mEditor
|
||||
#include "nsError.h" // for NS_SUCCEEDED, NS_FAILED, etc
|
||||
#include "nsIPresShell.h" // nsISelectionController constants
|
||||
#include "nsRange.h" // local var
|
||||
@ -25,13 +25,13 @@ CompositionTransaction::CompositionTransaction(
|
||||
uint32_t aReplaceLength,
|
||||
TextRangeArray* aTextRangeArray,
|
||||
const nsAString& aStringToInsert,
|
||||
nsEditor& aEditor)
|
||||
EditorBase& aEditorBase)
|
||||
: mTextNode(&aTextNode)
|
||||
, mOffset(aOffset)
|
||||
, mReplaceLength(aReplaceLength)
|
||||
, mRanges(aTextRangeArray)
|
||||
, mStringToInsert(aStringToInsert)
|
||||
, mEditor(aEditor)
|
||||
, mEditorBase(aEditorBase)
|
||||
, mFixed(false)
|
||||
{
|
||||
}
|
||||
@ -58,7 +58,7 @@ CompositionTransaction::DoTransaction()
|
||||
{
|
||||
// Fail before making any changes if there's no selection controller
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
mEditor.GetSelectionController(getter_AddRefs(selCon));
|
||||
mEditorBase.GetSelectionController(getter_AddRefs(selCon));
|
||||
NS_ENSURE_TRUE(selCon, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// Advance caret: This requires the presentation shell to get the selection.
|
||||
@ -81,7 +81,7 @@ CompositionTransaction::UndoTransaction()
|
||||
{
|
||||
// Get the selection first so we'll fail before making any changes if we
|
||||
// can't get it
|
||||
RefPtr<Selection> selection = mEditor.GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase.GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsresult res = mTextNode->DeleteData(mOffset, mStringToInsert.Length());
|
||||
@ -142,19 +142,19 @@ CompositionTransaction::GetTxnDescription(nsAString& aString)
|
||||
nsresult
|
||||
CompositionTransaction::SetSelectionForRanges()
|
||||
{
|
||||
return SetIMESelection(mEditor, mTextNode, mOffset,
|
||||
return SetIMESelection(mEditorBase, mTextNode, mOffset,
|
||||
mStringToInsert.Length(), mRanges);
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
CompositionTransaction::SetIMESelection(nsEditor& aEditor,
|
||||
CompositionTransaction::SetIMESelection(EditorBase& aEditorBase,
|
||||
Text* aTextNode,
|
||||
uint32_t aOffsetInNode,
|
||||
uint32_t aLengthOfCompositionString,
|
||||
const TextRangeArray* aRanges)
|
||||
{
|
||||
RefPtr<Selection> selection = aEditor.GetSelection();
|
||||
RefPtr<Selection> selection = aEditorBase.GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsresult rv = selection->StartBatchChanges();
|
||||
@ -169,7 +169,7 @@ CompositionTransaction::SetIMESelection(nsEditor& aEditor,
|
||||
};
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
aEditor.GetSelectionController(getter_AddRefs(selCon));
|
||||
aEditorBase.GetSelectionController(getter_AddRefs(selCon));
|
||||
NS_ENSURE_TRUE(selCon, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
for (uint32_t i = 0; i < ArrayLength(kIMESelections); ++i) {
|
||||
@ -202,7 +202,8 @@ CompositionTransaction::SetIMESelection(nsEditor& aEditor,
|
||||
// specified explicitly, we need to handle it ourselves later.
|
||||
if (textRange.mRangeType == TextRangeType::eCaret) {
|
||||
NS_ASSERTION(!setCaret, "The ranges already has caret position");
|
||||
NS_ASSERTION(!textRange.Length(), "nsEditor doesn't support wide caret");
|
||||
NS_ASSERTION(!textRange.Length(),
|
||||
"EditorBase doesn't support wide caret");
|
||||
int32_t caretOffset = static_cast<int32_t>(
|
||||
aOffsetInNode +
|
||||
std::min(textRange.mStartOffset, aLengthOfCompositionString));
|
||||
@ -215,7 +216,7 @@ CompositionTransaction::SetIMESelection(nsEditor& aEditor,
|
||||
}
|
||||
// If caret range is specified explicitly, we should show the caret if
|
||||
// it should be so.
|
||||
aEditor.HideCaret(false);
|
||||
aEditorBase.HideCaret(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -287,7 +288,7 @@ CompositionTransaction::SetIMESelection(nsEditor& aEditor,
|
||||
|
||||
// If caret range isn't specified explicitly, we should hide the caret.
|
||||
// Hiding the caret benefits a Windows build (see bug 555642 comment #6).
|
||||
aEditor.HideCaret(true);
|
||||
aEditorBase.HideCaret(true);
|
||||
}
|
||||
|
||||
rv = selection->EndBatchChangesInternal();
|
||||
|
@ -10,14 +10,13 @@
|
||||
#include "nsCycleCollectionParticipant.h" // various macros
|
||||
#include "nsString.h" // mStringToInsert
|
||||
|
||||
class nsEditor;
|
||||
|
||||
#define NS_IMETEXTTXN_IID \
|
||||
{ 0xb391355d, 0x346c, 0x43d1, \
|
||||
{ 0x85, 0xed, 0x9e, 0x65, 0xbe, 0xe7, 0x7e, 0x48 } }
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class TextRangeArray;
|
||||
|
||||
namespace dom {
|
||||
@ -43,13 +42,13 @@ public:
|
||||
* @param aTextRangeArray Clauses and/or caret information. This may be
|
||||
* null.
|
||||
* @param aString The new text to insert.
|
||||
* @param aEditor Used to get and set the selection.
|
||||
* @param aEditorBase Used to get and set the selection.
|
||||
*/
|
||||
CompositionTransaction(dom::Text& aTextNode,
|
||||
uint32_t aOffset, uint32_t aReplaceLength,
|
||||
TextRangeArray* aTextRangeArray,
|
||||
const nsAString& aString,
|
||||
nsEditor& aEditor);
|
||||
EditorBase& aEditorBase);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CompositionTransaction,
|
||||
EditTransactionBase)
|
||||
@ -62,7 +61,7 @@ public:
|
||||
|
||||
void MarkFixed();
|
||||
|
||||
static nsresult SetIMESelection(nsEditor& aEditor,
|
||||
static nsresult SetIMESelection(EditorBase& aEditorBase,
|
||||
dom::Text* aTextNode,
|
||||
uint32_t aOffsetInNode,
|
||||
uint32_t aLengthOfCompositionString,
|
||||
@ -88,7 +87,7 @@ private:
|
||||
nsString mStringToInsert;
|
||||
|
||||
// The editor, which is used to get the selection controller.
|
||||
nsEditor& mEditor;
|
||||
EditorBase& mEditorBase;
|
||||
|
||||
bool mFixed;
|
||||
};
|
||||
|
@ -12,11 +12,11 @@
|
||||
#include "mozilla/dom/Selection.h"
|
||||
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
@ -32,12 +32,12 @@ namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
CreateElementTransaction::CreateElementTransaction(nsEditor& aEditor,
|
||||
CreateElementTransaction::CreateElementTransaction(EditorBase& aEditorBase,
|
||||
nsIAtom& aTag,
|
||||
nsINode& aParent,
|
||||
int32_t aOffsetInParent)
|
||||
: EditTransactionBase()
|
||||
, mEditor(&aEditor)
|
||||
, mEditorBase(&aEditorBase)
|
||||
, mTag(&aTag)
|
||||
, mParent(&aParent)
|
||||
, mOffsetInParent(aOffsetInParent)
|
||||
@ -63,13 +63,13 @@ NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
|
||||
NS_IMETHODIMP
|
||||
CreateElementTransaction::DoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mEditor && mTag && mParent);
|
||||
MOZ_ASSERT(mEditorBase && mTag && mParent);
|
||||
|
||||
mNewNode = mEditor->CreateHTMLContent(mTag);
|
||||
mNewNode = mEditorBase->CreateHTMLContent(mTag);
|
||||
NS_ENSURE_STATE(mNewNode);
|
||||
|
||||
// Try to insert formatting whitespace for the new node:
|
||||
mEditor->MarkNodeDirty(GetAsDOMNode(mNewNode));
|
||||
mEditorBase->MarkNodeDirty(GetAsDOMNode(mNewNode));
|
||||
|
||||
// Insert the new node
|
||||
ErrorResult rv;
|
||||
@ -88,12 +88,12 @@ CreateElementTransaction::DoTransaction()
|
||||
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
|
||||
|
||||
// Only set selection to insertion point if editor gives permission
|
||||
if (!mEditor->GetShouldTxnSetSelection()) {
|
||||
if (!mEditorBase->GetShouldTxnSetSelection()) {
|
||||
// Do nothing - DOM range gravity will adjust selection
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<Selection> selection = mEditor->GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
rv = selection->CollapseNative(mParent, mParent->IndexOf(mNewNode) + 1);
|
||||
@ -105,7 +105,7 @@ CreateElementTransaction::DoTransaction()
|
||||
NS_IMETHODIMP
|
||||
CreateElementTransaction::UndoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mEditor && mParent);
|
||||
MOZ_ASSERT(mEditorBase && mParent);
|
||||
|
||||
ErrorResult rv;
|
||||
mParent->RemoveChild(*mNewNode, rv);
|
||||
@ -116,7 +116,7 @@ CreateElementTransaction::UndoTransaction()
|
||||
NS_IMETHODIMP
|
||||
CreateElementTransaction::RedoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mEditor && mParent);
|
||||
MOZ_ASSERT(mEditorBase && mParent);
|
||||
|
||||
// First, reset mNewNode so it has no attributes or content
|
||||
// XXX We never actually did this, we only cleared mNewNode's contents if it
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
class nsEditor;
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsINode;
|
||||
@ -21,6 +20,7 @@ class nsINode;
|
||||
*/
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
@ -30,7 +30,7 @@ class CreateElementTransaction final : public EditTransactionBase
|
||||
public:
|
||||
/**
|
||||
* Initialize the transaction.
|
||||
* @param aEditor The provider of basic editing functionality.
|
||||
* @param aEditorBase The provider of basic editing functionality.
|
||||
* @param aTag The tag (P, HR, TABLE, etc.) for the new element.
|
||||
* @param aParent The node into which the new element will be
|
||||
* inserted.
|
||||
@ -38,7 +38,7 @@ public:
|
||||
* If eAppend, the new element is appended as the last
|
||||
* child.
|
||||
*/
|
||||
CreateElementTransaction(nsEditor& aEditor,
|
||||
CreateElementTransaction(EditorBase& aEditorBase,
|
||||
nsIAtom& aTag,
|
||||
nsINode& aParent,
|
||||
int32_t aOffsetInParent);
|
||||
@ -57,7 +57,7 @@ protected:
|
||||
virtual ~CreateElementTransaction();
|
||||
|
||||
// The document into which the new node will be inserted.
|
||||
nsEditor* mEditor;
|
||||
EditorBase* mEditorBase;
|
||||
|
||||
// The tag (mapping to object type) for the new element.
|
||||
nsCOMPtr<nsIAtom> mTag;
|
||||
|
@ -4,16 +4,16 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DeleteNodeTransaction.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/SelectionState.h" // RangeUpdater
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
DeleteNodeTransaction::DeleteNodeTransaction()
|
||||
: mEditor(nullptr)
|
||||
: mEditorBase(nullptr)
|
||||
, mRangeUpdater(nullptr)
|
||||
{
|
||||
}
|
||||
@ -33,17 +33,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeleteNodeTransaction)
|
||||
NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
|
||||
|
||||
nsresult
|
||||
DeleteNodeTransaction::Init(nsEditor* aEditor,
|
||||
DeleteNodeTransaction::Init(EditorBase* aEditorBase,
|
||||
nsINode* aNode,
|
||||
RangeUpdater* aRangeUpdater)
|
||||
{
|
||||
NS_ENSURE_TRUE(aEditor && aNode, NS_ERROR_NULL_POINTER);
|
||||
mEditor = aEditor;
|
||||
NS_ENSURE_TRUE(aEditorBase && aNode, NS_ERROR_NULL_POINTER);
|
||||
mEditorBase = aEditorBase;
|
||||
mNode = aNode;
|
||||
mParent = aNode->GetParentNode();
|
||||
|
||||
// do nothing if the node has a parent and it's read-only
|
||||
NS_ENSURE_TRUE(!mParent || mEditor->IsModifiableNode(mParent),
|
||||
NS_ENSURE_TRUE(!mParent || mEditorBase->IsModifiableNode(mParent),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
mRangeUpdater = aRangeUpdater;
|
||||
|
@ -14,10 +14,9 @@
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsEditor;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class RangeUpdater;
|
||||
|
||||
/**
|
||||
@ -30,7 +29,7 @@ public:
|
||||
* Initialize the transaction.
|
||||
* @param aElement The node to delete.
|
||||
*/
|
||||
nsresult Init(nsEditor* aEditor, nsINode* aNode,
|
||||
nsresult Init(EditorBase* aEditorBase, nsINode* aNode,
|
||||
RangeUpdater* aRangeUpdater);
|
||||
|
||||
DeleteNodeTransaction();
|
||||
@ -56,7 +55,7 @@ protected:
|
||||
nsCOMPtr<nsIContent> mRefNode;
|
||||
|
||||
// The editor for this transaction.
|
||||
nsEditor* mEditor;
|
||||
EditorBase* mEditorBase;
|
||||
|
||||
// Range updater object.
|
||||
RangeUpdater* mRangeUpdater;
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include "DeleteNodeTransaction.h"
|
||||
#include "DeleteTextTransaction.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
@ -24,9 +24,9 @@ namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
// note that aEditor is not refcounted
|
||||
// note that aEditorBase is not refcounted
|
||||
DeleteRangeTransaction::DeleteRangeTransaction()
|
||||
: mEditor(nullptr)
|
||||
: mEditorBase(nullptr)
|
||||
, mRangeUpdater(nullptr)
|
||||
{
|
||||
}
|
||||
@ -39,21 +39,21 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeleteRangeTransaction)
|
||||
NS_INTERFACE_MAP_END_INHERITING(EditAggregateTransaction)
|
||||
|
||||
nsresult
|
||||
DeleteRangeTransaction::Init(nsEditor* aEditor,
|
||||
DeleteRangeTransaction::Init(EditorBase* aEditorBase,
|
||||
nsRange* aRange,
|
||||
RangeUpdater* aRangeUpdater)
|
||||
{
|
||||
MOZ_ASSERT(aEditor && aRange);
|
||||
MOZ_ASSERT(aEditorBase && aRange);
|
||||
|
||||
mEditor = aEditor;
|
||||
mEditorBase = aEditorBase;
|
||||
mRange = aRange->CloneRange();
|
||||
mRangeUpdater = aRangeUpdater;
|
||||
|
||||
NS_ENSURE_TRUE(mEditor->IsModifiableNode(mRange->GetStartParent()),
|
||||
NS_ENSURE_TRUE(mEditorBase->IsModifiableNode(mRange->GetStartParent()),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mEditor->IsModifiableNode(mRange->GetEndParent()),
|
||||
NS_ENSURE_TRUE(mEditorBase->IsModifiableNode(mRange->GetEndParent()),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mEditor->IsModifiableNode(mRange->GetCommonAncestor()),
|
||||
NS_ENSURE_TRUE(mEditorBase->IsModifiableNode(mRange->GetCommonAncestor()),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
@ -62,7 +62,7 @@ DeleteRangeTransaction::Init(nsEditor* aEditor,
|
||||
NS_IMETHODIMP
|
||||
DeleteRangeTransaction::DoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mRange && mEditor);
|
||||
MOZ_ASSERT(mRange && mEditorBase);
|
||||
nsresult res;
|
||||
|
||||
// build the child transactions
|
||||
@ -95,9 +95,9 @@ DeleteRangeTransaction::DoTransaction()
|
||||
|
||||
// only set selection to deletion point if editor gives permission
|
||||
bool bAdjustSelection;
|
||||
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
|
||||
mEditorBase->ShouldTxnSetSelection(&bAdjustSelection);
|
||||
if (bAdjustSelection) {
|
||||
RefPtr<Selection> selection = mEditor->GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
res = selection->Collapse(startParent, startOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@ -110,7 +110,7 @@ DeleteRangeTransaction::DoTransaction()
|
||||
NS_IMETHODIMP
|
||||
DeleteRangeTransaction::UndoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mRange && mEditor);
|
||||
MOZ_ASSERT(mRange && mEditorBase);
|
||||
|
||||
return EditAggregateTransaction::UndoTransaction();
|
||||
}
|
||||
@ -118,7 +118,7 @@ DeleteRangeTransaction::UndoTransaction()
|
||||
NS_IMETHODIMP
|
||||
DeleteRangeTransaction::RedoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mRange && mEditor);
|
||||
MOZ_ASSERT(mRange && mEditorBase);
|
||||
|
||||
return EditAggregateTransaction::RedoTransaction();
|
||||
}
|
||||
@ -149,8 +149,8 @@ DeleteRangeTransaction::CreateTxnsToDeleteBetween(nsINode* aNode,
|
||||
static_cast<nsGenericDOMDataNode*>(aNode);
|
||||
|
||||
RefPtr<DeleteTextTransaction> transaction =
|
||||
new DeleteTextTransaction(*mEditor, *charDataNode, aStartOffset, numToDel,
|
||||
mRangeUpdater);
|
||||
new DeleteTextTransaction(*mEditorBase, *charDataNode, aStartOffset,
|
||||
numToDel, mRangeUpdater);
|
||||
|
||||
nsresult res = transaction->Init();
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@ -165,7 +165,7 @@ DeleteRangeTransaction::CreateTxnsToDeleteBetween(nsINode* aNode,
|
||||
nsresult res = NS_OK;
|
||||
for (int32_t i = aStartOffset; i < aEndOffset; ++i) {
|
||||
RefPtr<DeleteNodeTransaction> transaction = new DeleteNodeTransaction();
|
||||
res = transaction->Init(mEditor, child, mRangeUpdater);
|
||||
res = transaction->Init(mEditorBase, child, mRangeUpdater);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
AppendChild(transaction);
|
||||
}
|
||||
@ -198,7 +198,7 @@ DeleteRangeTransaction::CreateTxnsToDeleteContent(nsINode* aNode,
|
||||
RefPtr<nsGenericDOMDataNode> dataNode =
|
||||
static_cast<nsGenericDOMDataNode*>(aNode);
|
||||
RefPtr<DeleteTextTransaction> transaction =
|
||||
new DeleteTextTransaction(*mEditor, *dataNode, start, numToDelete,
|
||||
new DeleteTextTransaction(*mEditorBase, *dataNode, start, numToDelete,
|
||||
mRangeUpdater);
|
||||
|
||||
nsresult res = transaction->Init();
|
||||
@ -224,7 +224,7 @@ DeleteRangeTransaction::CreateTxnsToDeleteNodesBetween()
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
|
||||
RefPtr<DeleteNodeTransaction> transaction = new DeleteNodeTransaction();
|
||||
res = transaction->Init(mEditor, node, mRangeUpdater);
|
||||
res = transaction->Init(mEditorBase, node, mRangeUpdater);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
AppendChild(transaction);
|
||||
|
||||
|
@ -14,11 +14,11 @@
|
||||
#include "nsRange.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsEditor;
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class RangeUpdater;
|
||||
|
||||
/**
|
||||
@ -29,10 +29,10 @@ class DeleteRangeTransaction final : public EditAggregateTransaction
|
||||
public:
|
||||
/**
|
||||
* Initialize the transaction.
|
||||
* @param aEditor The object providing basic editing operations.
|
||||
* @param aEditorBase The object providing basic editing operations.
|
||||
* @param aRange The range to delete.
|
||||
*/
|
||||
nsresult Init(nsEditor* aEditor,
|
||||
nsresult Init(EditorBase* aEditorBase,
|
||||
nsRange* aRange,
|
||||
RangeUpdater* aRangeUpdater);
|
||||
|
||||
@ -67,7 +67,7 @@ protected:
|
||||
RefPtr<nsRange> mRange;
|
||||
|
||||
// The editor for this transaction.
|
||||
nsEditor* mEditor;
|
||||
EditorBase* mEditorBase;
|
||||
|
||||
// Range updater object.
|
||||
RangeUpdater* mRangeUpdater;
|
||||
|
@ -4,11 +4,12 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DeleteTextTransaction.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/SelectionState.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
@ -19,12 +20,12 @@ namespace mozilla {
|
||||
using namespace dom;
|
||||
|
||||
DeleteTextTransaction::DeleteTextTransaction(
|
||||
nsEditor& aEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
uint32_t aOffset,
|
||||
uint32_t aNumCharsToDelete,
|
||||
RangeUpdater* aRangeUpdater)
|
||||
: mEditor(aEditor)
|
||||
: mEditorBase(aEditorBase)
|
||||
, mCharData(&aCharData)
|
||||
, mOffset(aOffset)
|
||||
, mNumCharsToDelete(aNumCharsToDelete)
|
||||
@ -44,7 +45,7 @@ nsresult
|
||||
DeleteTextTransaction::Init()
|
||||
{
|
||||
// Do nothing if the node is read-only
|
||||
if (!mEditor.IsModifiableNode(mCharData)) {
|
||||
if (!mEditorBase.IsModifiableNode(mCharData)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -68,8 +69,8 @@ DeleteTextTransaction::DoTransaction()
|
||||
}
|
||||
|
||||
// Only set selection to deletion point if editor gives permission
|
||||
if (mEditor.GetShouldTxnSetSelection()) {
|
||||
RefPtr<Selection> selection = mEditor.GetSelection();
|
||||
if (mEditorBase.GetShouldTxnSetSelection()) {
|
||||
RefPtr<Selection> selection = mEditorBase.GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
res = selection->Collapse(mCharData, mOffset);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res),
|
||||
|
@ -14,10 +14,9 @@
|
||||
#include "nsString.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsEditor;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class RangeUpdater;
|
||||
|
||||
/**
|
||||
@ -28,13 +27,13 @@ class DeleteTextTransaction final : public EditTransactionBase
|
||||
public:
|
||||
/**
|
||||
* Initialize the transaction.
|
||||
* @param aEditor The provider of basic editing operations.
|
||||
* @param aEditorBase The provider of basic editing operations.
|
||||
* @param aElement The content node to remove text from.
|
||||
* @param aOffset The location in aElement to begin the deletion.
|
||||
* @param aNumCharsToDelete The number of characters to delete. Not the
|
||||
* number of bytes!
|
||||
*/
|
||||
DeleteTextTransaction(nsEditor& aEditor,
|
||||
DeleteTextTransaction(EditorBase& aEditorBase,
|
||||
nsGenericDOMDataNode& aCharData,
|
||||
uint32_t aOffset,
|
||||
uint32_t aNumCharsToDelete,
|
||||
@ -54,7 +53,7 @@ public:
|
||||
|
||||
protected:
|
||||
// The provider of basic editing operations.
|
||||
nsEditor& mEditor;
|
||||
EditorBase& mEditorBase;
|
||||
|
||||
// The CharacterData node to operate upon.
|
||||
RefPtr<nsGenericDOMDataNode> mCharData;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,7 @@
|
||||
#include "EditorEventListener.h"
|
||||
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/EditorBase.h" // for EditorBase, etc
|
||||
#include "mozilla/EventListenerManager.h" // for EventListenerManager
|
||||
#include "mozilla/IMEStateManager.h" // for IMEStateManager
|
||||
#include "mozilla/Preferences.h" // for Preferences
|
||||
@ -18,7 +19,6 @@
|
||||
#include "nsAString.h"
|
||||
#include "nsCaret.h" // for nsCaret
|
||||
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
|
||||
#include "nsEditor.h" // for nsEditor, etc
|
||||
#include "nsFocusManager.h" // for nsFocusManager
|
||||
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::input
|
||||
#include "nsIClipboard.h" // for nsIClipboard, etc
|
||||
@ -36,7 +36,7 @@
|
||||
#include "nsIDOMMouseEvent.h" // for nsIDOMMouseEvent
|
||||
#include "nsIDOMNode.h" // for nsIDOMNode
|
||||
#include "nsIDocument.h" // for nsIDocument
|
||||
#include "nsIEditor.h" // for nsEditor::GetSelection, etc
|
||||
#include "nsIEditor.h" // for EditorBase::GetSelection, etc
|
||||
#include "nsIEditorIMESupport.h"
|
||||
#include "nsIEditorMailSupport.h" // for nsIEditorMailSupport
|
||||
#include "nsIFocusManager.h" // for nsIFocusManager
|
||||
@ -98,7 +98,7 @@ DoCommandCallback(Command aCommand, void* aData)
|
||||
}
|
||||
|
||||
EditorEventListener::EditorEventListener()
|
||||
: mEditor(nullptr)
|
||||
: mEditorBase(nullptr)
|
||||
, mCommitText(false)
|
||||
, mInTransaction(false)
|
||||
, mMouseDownOrUpConsumedByIME(false)
|
||||
@ -112,16 +112,16 @@ EditorEventListener::EditorEventListener()
|
||||
|
||||
EditorEventListener::~EditorEventListener()
|
||||
{
|
||||
if (mEditor) {
|
||||
if (mEditorBase) {
|
||||
NS_WARNING("We're not uninstalled");
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
EditorEventListener::Connect(nsEditor* aEditor)
|
||||
EditorEventListener::Connect(EditorBase* aEditorBase)
|
||||
{
|
||||
NS_ENSURE_ARG(aEditor);
|
||||
NS_ENSURE_ARG(aEditorBase);
|
||||
|
||||
#ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
|
||||
nsIBidiKeyboard* bidiKeyboard = nsContentUtils::GetBidiKeyboard();
|
||||
@ -132,7 +132,7 @@ EditorEventListener::Connect(nsEditor* aEditor)
|
||||
}
|
||||
#endif
|
||||
|
||||
mEditor = aEditor;
|
||||
mEditorBase = aEditorBase;
|
||||
|
||||
nsresult rv = InstallToEditor();
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -144,9 +144,9 @@ EditorEventListener::Connect(nsEditor* aEditor)
|
||||
nsresult
|
||||
EditorEventListener::InstallToEditor()
|
||||
{
|
||||
NS_PRECONDITION(mEditor, "The caller must set mEditor");
|
||||
NS_PRECONDITION(mEditorBase, "The caller must set mEditorBase");
|
||||
|
||||
nsCOMPtr<EventTarget> piTarget = mEditor->GetDOMEventTarget();
|
||||
nsCOMPtr<EventTarget> piTarget = mEditorBase->GetDOMEventTarget();
|
||||
NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
|
||||
|
||||
// register the event listeners with the listener manager
|
||||
@ -214,7 +214,7 @@ EditorEventListener::InstallToEditor()
|
||||
void
|
||||
EditorEventListener::Disconnect()
|
||||
{
|
||||
if (!mEditor) {
|
||||
if (!mEditorBase) {
|
||||
return;
|
||||
}
|
||||
UninstallFromEditor();
|
||||
@ -224,22 +224,22 @@ EditorEventListener::Disconnect()
|
||||
nsCOMPtr<nsIDOMElement> domFocus;
|
||||
fm->GetFocusedElement(getter_AddRefs(domFocus));
|
||||
nsCOMPtr<nsINode> focusedElement = do_QueryInterface(domFocus);
|
||||
mozilla::dom::Element* root = mEditor->GetRoot();
|
||||
mozilla::dom::Element* root = mEditorBase->GetRoot();
|
||||
if (focusedElement && root &&
|
||||
nsContentUtils::ContentIsDescendantOf(focusedElement, root)) {
|
||||
// Reset the Selection ancestor limiter and SelectionController state
|
||||
// that nsEditor::InitializeSelection set up.
|
||||
mEditor->FinalizeSelection();
|
||||
// that EditorBase::InitializeSelection set up.
|
||||
mEditorBase->FinalizeSelection();
|
||||
}
|
||||
}
|
||||
|
||||
mEditor = nullptr;
|
||||
mEditorBase = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
EditorEventListener::UninstallFromEditor()
|
||||
{
|
||||
nsCOMPtr<EventTarget> piTarget = mEditor->GetDOMEventTarget();
|
||||
nsCOMPtr<EventTarget> piTarget = mEditorBase->GetDOMEventTarget();
|
||||
if (!piTarget) {
|
||||
return;
|
||||
}
|
||||
@ -301,9 +301,9 @@ EditorEventListener::UninstallFromEditor()
|
||||
already_AddRefed<nsIPresShell>
|
||||
EditorEventListener::GetPresShell()
|
||||
{
|
||||
NS_PRECONDITION(mEditor,
|
||||
NS_PRECONDITION(mEditorBase,
|
||||
"The caller must check whether this is connected to an editor");
|
||||
return mEditor->GetPresShell();
|
||||
return mEditorBase->GetPresShell();
|
||||
}
|
||||
|
||||
nsPresContext*
|
||||
@ -316,9 +316,9 @@ EditorEventListener::GetPresContext()
|
||||
nsIContent*
|
||||
EditorEventListener::GetFocusedRootContent()
|
||||
{
|
||||
NS_ENSURE_TRUE(mEditor, nullptr);
|
||||
NS_ENSURE_TRUE(mEditorBase, nullptr);
|
||||
|
||||
nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContent();
|
||||
nsCOMPtr<nsIContent> focusedContent = mEditorBase->GetFocusedContent();
|
||||
if (!focusedContent) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -336,9 +336,9 @@ EditorEventListener::GetFocusedRootContent()
|
||||
bool
|
||||
EditorEventListener::EditorHasFocus()
|
||||
{
|
||||
NS_PRECONDITION(mEditor,
|
||||
NS_PRECONDITION(mEditorBase,
|
||||
"The caller must check whether this is connected to an editor");
|
||||
nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContent();
|
||||
nsCOMPtr<nsIContent> focusedContent = mEditorBase->GetFocusedContent();
|
||||
if (!focusedContent) {
|
||||
return false;
|
||||
}
|
||||
@ -351,9 +351,9 @@ NS_IMPL_ISUPPORTS(EditorEventListener, nsIDOMEventListener)
|
||||
NS_IMETHODIMP
|
||||
EditorEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
NS_ENSURE_TRUE(mEditor, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mEditorBase, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIEditor> kungFuDeathGrip = mEditor;
|
||||
nsCOMPtr<nsIEditor> kungFuDeathGrip = mEditorBase;
|
||||
|
||||
WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
|
||||
|
||||
@ -550,8 +550,8 @@ EditorEventListener::KeyUp(nsIDOMKeyEvent* aKeyEvent)
|
||||
aKeyEvent->GetKeyCode(&keyCode);
|
||||
if ((keyCode == nsIDOMKeyEvent::DOM_VK_SHIFT ||
|
||||
keyCode == nsIDOMKeyEvent::DOM_VK_CONTROL) &&
|
||||
mShouldSwitchTextDirection && mEditor->IsPlaintextEditor()) {
|
||||
mEditor->SwitchTextDirectionTo(mSwitchToRTL ?
|
||||
mShouldSwitchTextDirection && mEditorBase->IsPlaintextEditor()) {
|
||||
mEditorBase->SwitchTextDirectionTo(mSwitchToRTL ?
|
||||
nsIPlaintextEditor::eEditorRightToLeft :
|
||||
nsIPlaintextEditor::eEditorLeftToRight);
|
||||
mShouldSwitchTextDirection = false;
|
||||
@ -589,7 +589,7 @@ EditorEventListener::KeyPress(nsIDOMKeyEvent* aKeyEvent)
|
||||
{
|
||||
NS_ENSURE_TRUE(aKeyEvent, NS_OK);
|
||||
|
||||
if (!mEditor->IsAcceptableInputEvent(aKeyEvent->AsEvent())) {
|
||||
if (!mEditorBase->IsAcceptableInputEvent(aKeyEvent->AsEvent())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -605,7 +605,7 @@ EditorEventListener::KeyPress(nsIDOMKeyEvent* aKeyEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = mEditor->HandleKeyPressEvent(aKeyEvent);
|
||||
nsresult rv = mEditorBase->HandleKeyPressEvent(aKeyEvent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aKeyEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
|
||||
@ -631,7 +631,7 @@ EditorEventListener::KeyPress(nsIDOMKeyEvent* aKeyEvent)
|
||||
NS_ENSURE_TRUE(widget, NS_OK);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mEditor->GetDocument();
|
||||
nsCOMPtr<nsIDocument> doc = mEditorBase->GetDocument();
|
||||
bool handled = widget->ExecuteNativeKeyBinding(
|
||||
nsIWidget::NativeKeyBindingsForRichTextEditor,
|
||||
*keyEvent, DoCommandCallback, doc);
|
||||
@ -645,8 +645,8 @@ nsresult
|
||||
EditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
|
||||
{
|
||||
// nothing to do if editor isn't editable or clicked on out of the editor.
|
||||
if (mEditor->IsReadonly() || mEditor->IsDisabled() ||
|
||||
!mEditor->IsAcceptableInputEvent(aMouseEvent->AsEvent())) {
|
||||
if (mEditorBase->IsReadonly() || mEditorBase->IsDisabled() ||
|
||||
!mEditorBase->IsAcceptableInputEvent(aMouseEvent->AsEvent())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -669,7 +669,7 @@ EditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
|
||||
|
||||
// If we got a mouse down inside the editing area, we should force the
|
||||
// IME to commit before we change the cursor position
|
||||
mEditor->ForceCompositionEnd();
|
||||
mEditorBase->ForceCompositionEnd();
|
||||
|
||||
int16_t button = -1;
|
||||
aMouseEvent->GetButton(&button);
|
||||
@ -697,7 +697,7 @@ EditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
RefPtr<Selection> selection = mEditor->GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
if (selection) {
|
||||
selection->Collapse(parent, offset);
|
||||
}
|
||||
@ -709,7 +709,7 @@ EditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
|
||||
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor;
|
||||
if (ctrlKey) {
|
||||
mailEditor = do_QueryObject(mEditor);
|
||||
mailEditor = do_QueryObject(mEditorBase);
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
@ -727,7 +727,7 @@ EditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
|
||||
if (mailEditor) {
|
||||
mailEditor->PasteAsQuotation(clipboard);
|
||||
} else {
|
||||
mEditor->Paste(clipboard);
|
||||
mEditorBase->Paste(clipboard);
|
||||
}
|
||||
|
||||
// Prevent the event from propagating up to be possibly handled
|
||||
@ -765,23 +765,23 @@ EditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
|
||||
{
|
||||
// FYI: This may be called by HTMLEditorEventListener::MouseDown() even
|
||||
// when the event is not acceptable for committing composition.
|
||||
mEditor->ForceCompositionEnd();
|
||||
mEditorBase->ForceCompositionEnd();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
|
||||
{
|
||||
if (!mEditor->IsAcceptableInputEvent(aTextEvent)) {
|
||||
if (!mEditorBase->IsAcceptableInputEvent(aTextEvent)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if we are readonly or disabled, then do nothing.
|
||||
if (mEditor->IsReadonly() || mEditor->IsDisabled()) {
|
||||
if (mEditorBase->IsReadonly() || mEditorBase->IsDisabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mEditor->UpdateIMEComposition(aTextEvent);
|
||||
return mEditorBase->UpdateIMEComposition(aTextEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -904,7 +904,7 @@ EditorEventListener::Drop(nsIDOMDragEvent* aDragEvent)
|
||||
|
||||
if (!dropParent->IsEditable() || !CanDrop(aDragEvent)) {
|
||||
// was it because we're read-only?
|
||||
if ((mEditor->IsReadonly() || mEditor->IsDisabled()) &&
|
||||
if ((mEditorBase->IsReadonly() || mEditorBase->IsDisabled()) &&
|
||||
!IsFileControlTextBox()) {
|
||||
// it was decided to "eat" the event as this is the "least surprise"
|
||||
// since someone else handling it might be unintentional and the
|
||||
@ -917,14 +917,14 @@ EditorEventListener::Drop(nsIDOMDragEvent* aDragEvent)
|
||||
|
||||
aDragEvent->AsEvent()->StopPropagation();
|
||||
aDragEvent->AsEvent()->PreventDefault();
|
||||
return mEditor->InsertFromDrop(aDragEvent->AsEvent());
|
||||
return mEditorBase->InsertFromDrop(aDragEvent->AsEvent());
|
||||
}
|
||||
|
||||
bool
|
||||
EditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||
{
|
||||
// if the target doc is read-only, we can't drop
|
||||
if (mEditor->IsReadonly() || mEditor->IsDisabled()) {
|
||||
if (mEditorBase->IsReadonly() || mEditorBase->IsDisabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -943,7 +943,7 @@ EditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||
// can be dropped as well.
|
||||
if (!types->Contains(NS_LITERAL_STRING(kTextMime)) &&
|
||||
!types->Contains(NS_LITERAL_STRING(kMozTextInternal)) &&
|
||||
(mEditor->IsPlaintextEditor() ||
|
||||
(mEditorBase->IsPlaintextEditor() ||
|
||||
(!types->Contains(NS_LITERAL_STRING(kHTMLMime)) &&
|
||||
!types->Contains(NS_LITERAL_STRING(kFileMime))))) {
|
||||
return false;
|
||||
@ -961,7 +961,7 @@ EditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||
// There is a source node, so compare the source documents and this document.
|
||||
// Disallow drops on the same document.
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc = mEditor->GetDOMDocument();
|
||||
nsCOMPtr<nsIDOMDocument> domdoc = mEditorBase->GetDOMDocument();
|
||||
NS_ENSURE_TRUE(domdoc, false);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> sourceDoc;
|
||||
@ -981,7 +981,7 @@ EditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||
return true;
|
||||
}
|
||||
|
||||
RefPtr<Selection> selection = mEditor->GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
if (!selection) {
|
||||
return false;
|
||||
}
|
||||
@ -1025,22 +1025,22 @@ EditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||
nsresult
|
||||
EditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
|
||||
{
|
||||
if (!mEditor->IsAcceptableInputEvent(aCompositionEvent)) {
|
||||
if (!mEditorBase->IsAcceptableInputEvent(aCompositionEvent)) {
|
||||
return NS_OK;
|
||||
}
|
||||
WidgetCompositionEvent* compositionStart =
|
||||
aCompositionEvent->WidgetEventPtr()->AsCompositionEvent();
|
||||
return mEditor->BeginIMEComposition(compositionStart);
|
||||
return mEditorBase->BeginIMEComposition(compositionStart);
|
||||
}
|
||||
|
||||
void
|
||||
EditorEventListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
|
||||
{
|
||||
if (!mEditor->IsAcceptableInputEvent(aCompositionEvent)) {
|
||||
if (!mEditorBase->IsAcceptableInputEvent(aCompositionEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mEditor->EndIMEComposition();
|
||||
mEditorBase->EndIMEComposition();
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1049,13 +1049,13 @@ EditorEventListener::Focus(nsIDOMEvent* aEvent)
|
||||
NS_ENSURE_TRUE(aEvent, NS_OK);
|
||||
|
||||
// Don't turn on selection and caret when the editor is disabled.
|
||||
if (mEditor->IsDisabled()) {
|
||||
if (mEditorBase->IsDisabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Spell check a textarea the first time that it is focused.
|
||||
SpellCheckIfNeeded();
|
||||
if (!mEditor) {
|
||||
if (!mEditorBase) {
|
||||
// In e10s, this can cause us to flush notifications, which can destroy
|
||||
// the node we're about to focus.
|
||||
return NS_OK;
|
||||
@ -1080,7 +1080,7 @@ EditorEventListener::Focus(nsIDOMEvent* aEvent)
|
||||
// contenteditable editor. So, the editableRoot value is invalid for
|
||||
// the plain text editor, and it will be set to the wrong limiter of
|
||||
// the selection. However, fortunately, actual bugs are not found yet.
|
||||
nsCOMPtr<nsIContent> editableRoot = mEditor->FindSelectionRoot(node);
|
||||
nsCOMPtr<nsIContent> editableRoot = mEditorBase->FindSelectionRoot(node);
|
||||
|
||||
// make sure that the element is really focused in case an earlier
|
||||
// listener in the chain changed the focus.
|
||||
@ -1096,13 +1096,13 @@ EditorEventListener::Focus(nsIDOMEvent* aEvent)
|
||||
}
|
||||
}
|
||||
|
||||
mEditor->OnFocus(target);
|
||||
mEditorBase->OnFocus(target);
|
||||
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
NS_ENSURE_TRUE(ps, NS_OK);
|
||||
nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContentForIME();
|
||||
nsCOMPtr<nsIContent> focusedContent = mEditorBase->GetFocusedContentForIME();
|
||||
IMEStateManager::OnFocusInEditor(ps->GetPresContext(), focusedContent,
|
||||
mEditor);
|
||||
mEditorBase);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1120,7 +1120,7 @@ EditorEventListener::Blur(nsIDOMEvent* aEvent)
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
fm->GetFocusedElement(getter_AddRefs(element));
|
||||
if (!element) {
|
||||
mEditor->FinalizeSelection();
|
||||
mEditorBase->FinalizeSelection();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1131,17 +1131,17 @@ EditorEventListener::SpellCheckIfNeeded()
|
||||
// If the spell check skip flag is still enabled from creation time,
|
||||
// disable it because focused editors are allowed to spell check.
|
||||
uint32_t currentFlags = 0;
|
||||
mEditor->GetFlags(¤tFlags);
|
||||
mEditorBase->GetFlags(¤tFlags);
|
||||
if(currentFlags & nsIPlaintextEditor::eEditorSkipSpellCheck) {
|
||||
currentFlags ^= nsIPlaintextEditor::eEditorSkipSpellCheck;
|
||||
mEditor->SetFlags(currentFlags);
|
||||
mEditorBase->SetFlags(currentFlags);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
EditorEventListener::IsFileControlTextBox()
|
||||
{
|
||||
dom::Element* root = mEditor->GetRoot();
|
||||
Element* root = mEditorBase->GetRoot();
|
||||
if (!root || !root->ChromeOnlyAccess()) {
|
||||
return false;
|
||||
}
|
||||
@ -1172,12 +1172,12 @@ EditorEventListener::ShouldHandleNativeKeyBindings(nsIDOMKeyEvent* aKeyEvent)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor =
|
||||
do_QueryInterface(static_cast<nsIEditor*>(mEditor));
|
||||
do_QueryInterface(static_cast<nsIEditor*>(mEditorBase));
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = mEditor->GetDocument();
|
||||
nsCOMPtr<nsIDocument> doc = mEditorBase->GetDocument();
|
||||
if (doc->HasFlag(NODE_IS_EDITABLE)) {
|
||||
// Don't need to perform any checks in designMode documents.
|
||||
return true;
|
||||
|
@ -19,7 +19,6 @@ class nsIDOMEvent;
|
||||
class nsIDOMKeyEvent;
|
||||
class nsIDOMMouseEvent;
|
||||
class nsIPresShell;
|
||||
class nsEditor;
|
||||
class nsPresContext;
|
||||
|
||||
// X.h defines KeyPress
|
||||
@ -34,12 +33,14 @@ class nsPresContext;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
|
||||
class EditorEventListener : public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
EditorEventListener();
|
||||
|
||||
virtual nsresult Connect(nsEditor* aEditor);
|
||||
virtual nsresult Connect(EditorBase* aEditorBase);
|
||||
|
||||
void Disconnect();
|
||||
|
||||
@ -85,7 +86,7 @@ protected:
|
||||
bool ShouldHandleNativeKeyBindings(nsIDOMKeyEvent* aKeyEvent);
|
||||
nsresult HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent);
|
||||
|
||||
nsEditor* mEditor; // weak
|
||||
EditorBase* mEditorBase; // weak
|
||||
RefPtr<nsCaret> mCaret;
|
||||
bool mCommitText;
|
||||
bool mInTransaction;
|
||||
|
@ -34,40 +34,40 @@ using namespace dom;
|
||||
|
||||
AutoSelectionRestorer::AutoSelectionRestorer(
|
||||
Selection* aSelection,
|
||||
nsEditor* aEditor
|
||||
EditorBase* aEditorBase
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
: mEditor(nullptr)
|
||||
: mEditorBase(nullptr)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
if (NS_WARN_IF(!aSelection) || NS_WARN_IF(!aEditor)) {
|
||||
if (NS_WARN_IF(!aSelection) || NS_WARN_IF(!aEditorBase)) {
|
||||
return;
|
||||
}
|
||||
if (aEditor->ArePreservingSelection()) {
|
||||
if (aEditorBase->ArePreservingSelection()) {
|
||||
// We already have initialized mSavedSel, so this must be nested call.
|
||||
return;
|
||||
}
|
||||
mSelection = aSelection;
|
||||
mEditor = aEditor;
|
||||
mEditor->PreserveSelectionAcrossActions(mSelection);
|
||||
mEditorBase = aEditorBase;
|
||||
mEditorBase->PreserveSelectionAcrossActions(mSelection);
|
||||
}
|
||||
|
||||
AutoSelectionRestorer::~AutoSelectionRestorer()
|
||||
{
|
||||
NS_ASSERTION(!mSelection || mEditor,
|
||||
"mEditor should be non-null when mSelection is");
|
||||
NS_ASSERTION(!mSelection || mEditorBase,
|
||||
"mEditorBase should be non-null when mSelection is");
|
||||
// mSelection will be null if this was nested call.
|
||||
if (mSelection && mEditor->ArePreservingSelection()) {
|
||||
mEditor->RestorePreservedSelection(mSelection);
|
||||
if (mSelection && mEditorBase->ArePreservingSelection()) {
|
||||
mEditorBase->RestorePreservedSelection(mSelection);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AutoSelectionRestorer::Abort()
|
||||
{
|
||||
NS_ASSERTION(!mSelection || mEditor,
|
||||
"mEditor should be non-null when mSelection is");
|
||||
NS_ASSERTION(!mSelection || mEditorBase,
|
||||
"mEditorBase should be non-null when mSelection is");
|
||||
if (mSelection) {
|
||||
mEditor->StopPreservingSelection();
|
||||
mEditorBase->StopPreservingSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,13 @@
|
||||
#ifndef EditorUtils_h
|
||||
#define EditorUtils_h
|
||||
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nscore.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContentIterator;
|
||||
@ -88,7 +88,7 @@ class MOZ_RAII AutoSelectionRestorer final
|
||||
private:
|
||||
// Ref-counted reference to the selection that we are supposed to restore.
|
||||
RefPtr<dom::Selection> mSelection;
|
||||
nsEditor* mEditor; // Non-owning ref to nsEditor.
|
||||
EditorBase* mEditorBase; // Non-owning ref to EditorBase.
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
|
||||
public:
|
||||
@ -97,7 +97,7 @@ public:
|
||||
* aSelection.
|
||||
*/
|
||||
AutoSelectionRestorer(dom::Selection* aSelection,
|
||||
nsEditor* aEditor
|
||||
EditorBase* aEditorBase
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
|
||||
/**
|
||||
@ -117,16 +117,16 @@ public:
|
||||
class MOZ_RAII AutoRules final
|
||||
{
|
||||
public:
|
||||
AutoRules(nsEditor* aEditor, EditAction aAction,
|
||||
AutoRules(EditorBase* aEditorBase, EditAction aAction,
|
||||
nsIEditor::EDirection aDirection
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mEditor(aEditor)
|
||||
: mEditorBase(aEditorBase)
|
||||
, mDoNothing(false)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
// mAction will already be set if this is nested call
|
||||
if (mEditor && !mEditor->mAction) {
|
||||
mEditor->StartOperation(aAction, aDirection);
|
||||
if (mEditorBase && !mEditorBase->mAction) {
|
||||
mEditorBase->StartOperation(aAction, aDirection);
|
||||
} else {
|
||||
mDoNothing = true; // nested calls will end up here
|
||||
}
|
||||
@ -134,13 +134,13 @@ public:
|
||||
|
||||
~AutoRules()
|
||||
{
|
||||
if (mEditor && !mDoNothing) {
|
||||
mEditor->EndOperation();
|
||||
if (mEditorBase && !mDoNothing) {
|
||||
mEditorBase->EndOperation();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
nsEditor* mEditor;
|
||||
EditorBase* mEditorBase;
|
||||
bool mDoNothing;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
@ -152,27 +152,27 @@ protected:
|
||||
class MOZ_RAII AutoTransactionsConserveSelection final
|
||||
{
|
||||
public:
|
||||
explicit AutoTransactionsConserveSelection(nsEditor* aEditor
|
||||
explicit AutoTransactionsConserveSelection(EditorBase* aEditorBase
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mEditor(aEditor)
|
||||
: mEditorBase(aEditorBase)
|
||||
, mOldState(true)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
if (mEditor) {
|
||||
mOldState = mEditor->GetShouldTxnSetSelection();
|
||||
mEditor->SetShouldTxnSetSelection(false);
|
||||
if (mEditorBase) {
|
||||
mOldState = mEditorBase->GetShouldTxnSetSelection();
|
||||
mEditorBase->SetShouldTxnSetSelection(false);
|
||||
}
|
||||
}
|
||||
|
||||
~AutoTransactionsConserveSelection()
|
||||
{
|
||||
if (mEditor) {
|
||||
mEditor->SetShouldTxnSetSelection(mOldState);
|
||||
if (mEditorBase) {
|
||||
mEditorBase->SetShouldTxnSetSelection(mOldState);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
nsEditor* mEditor;
|
||||
EditorBase* mEditorBase;
|
||||
bool mOldState;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
@ -183,27 +183,27 @@ protected:
|
||||
class MOZ_RAII AutoUpdateViewBatch final
|
||||
{
|
||||
public:
|
||||
explicit AutoUpdateViewBatch(nsEditor* aEditor
|
||||
explicit AutoUpdateViewBatch(EditorBase* aEditorBase
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mEditor(aEditor)
|
||||
: mEditorBase(aEditorBase)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
NS_ASSERTION(mEditor, "null mEditor pointer!");
|
||||
NS_ASSERTION(mEditorBase, "null mEditorBase pointer!");
|
||||
|
||||
if (mEditor) {
|
||||
mEditor->BeginUpdateViewBatch();
|
||||
if (mEditorBase) {
|
||||
mEditorBase->BeginUpdateViewBatch();
|
||||
}
|
||||
}
|
||||
|
||||
~AutoUpdateViewBatch()
|
||||
{
|
||||
if (mEditor) {
|
||||
mEditor->EndUpdateViewBatch();
|
||||
if (mEditorBase) {
|
||||
mEditorBase->EndUpdateViewBatch();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
nsEditor* mEditor;
|
||||
EditorBase* mEditorBase;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIAtom.h"
|
||||
@ -1155,7 +1154,7 @@ HTMLEditRules::GetFormatString(nsIDOMNode* aNode,
|
||||
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (HTMLEditUtils::IsFormatNode(aNode)) {
|
||||
nsCOMPtr<nsIAtom> atom = nsEditor::GetTag(aNode);
|
||||
nsCOMPtr<nsIAtom> atom = EditorBase::GetTag(aNode);
|
||||
atom->ToString(outFormat);
|
||||
}
|
||||
else
|
||||
@ -2927,7 +2926,7 @@ HTMLEditRules::DidDeleteSelection(Selection* aSelection,
|
||||
if (isEmpty)
|
||||
{
|
||||
int32_t offset;
|
||||
nsCOMPtr<nsINode> parent = nsEditor::GetNodeLocation(citeNode, &offset);
|
||||
nsCOMPtr<nsINode> parent = EditorBase::GetNodeLocation(citeNode, &offset);
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
res = mHTMLEditor->DeleteNode(citeNode);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@ -3069,7 +3068,7 @@ HTMLEditRules::WillMakeList(Selection* aSelection,
|
||||
NS_ENSURE_STATE(arrayOfNodes[i]->IsContent());
|
||||
OwningNonNull<nsIContent> curNode = *arrayOfNodes[i]->AsContent();
|
||||
int32_t offset;
|
||||
curParent = nsEditor::GetNodeLocation(curNode, &offset);
|
||||
curParent = EditorBase::GetNodeLocation(curNode, &offset);
|
||||
|
||||
// make sure we don't assemble content that is in different table cells
|
||||
// into the same list. respect table cell boundaries when listifying.
|
||||
@ -3133,8 +3132,8 @@ HTMLEditRules::WillMakeList(Selection* aSelection,
|
||||
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
|
||||
newBlock = splitNode ? splitNode->AsElement() : nullptr;
|
||||
int32_t offset;
|
||||
nsCOMPtr<nsINode> parent = nsEditor::GetNodeLocation(curParent,
|
||||
&offset);
|
||||
nsCOMPtr<nsINode> parent = EditorBase::GetNodeLocation(curParent,
|
||||
&offset);
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
curList = mHTMLEditor->CreateNode(listType, parent, offset);
|
||||
NS_ENSURE_STATE(curList);
|
||||
@ -5138,7 +5137,7 @@ HTMLEditRules::NormalizeSelection(Selection* inSelection)
|
||||
true));
|
||||
if (child)
|
||||
{
|
||||
newEndNode = nsEditor::GetNodeLocation(child, &newEndOffset);
|
||||
newEndNode = EditorBase::GetNodeLocation(child, &newEndOffset);
|
||||
++newEndOffset; // offset *after* child
|
||||
}
|
||||
// else block is empty - we can leave selection alone here, i think.
|
||||
@ -5149,14 +5148,15 @@ HTMLEditRules::NormalizeSelection(Selection* inSelection)
|
||||
res = mHTMLEditor->GetPriorHTMLNode(endNode, endOffset, address_of(child));
|
||||
if (child)
|
||||
{
|
||||
newEndNode = nsEditor::GetNodeLocation(child, &newEndOffset);
|
||||
newEndNode = EditorBase::GetNodeLocation(child, &newEndOffset);
|
||||
++newEndOffset; // offset *after* child
|
||||
}
|
||||
// else block is empty - we can leave selection alone here, i think.
|
||||
} else if (wsEndObj.mStartReason == WSType::br) {
|
||||
// endpoint is just after break. lets adjust it to before it.
|
||||
newEndNode = nsEditor::GetNodeLocation(GetAsDOMNode(wsEndObj.mStartReasonNode),
|
||||
&newEndOffset);
|
||||
newEndNode =
|
||||
EditorBase::GetNodeLocation(GetAsDOMNode(wsEndObj.mStartReasonNode),
|
||||
&newEndOffset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5178,7 +5178,7 @@ HTMLEditRules::NormalizeSelection(Selection* inSelection)
|
||||
true));
|
||||
if (child)
|
||||
{
|
||||
newStartNode = nsEditor::GetNodeLocation(child, &newStartOffset);
|
||||
newStartNode = EditorBase::GetNodeLocation(child, &newStartOffset);
|
||||
}
|
||||
// else block is empty - we can leave selection alone here, i think.
|
||||
} else if (wsStartObj.mEndReason == WSType::thisBlock) {
|
||||
@ -5188,13 +5188,14 @@ HTMLEditRules::NormalizeSelection(Selection* inSelection)
|
||||
res = mHTMLEditor->GetNextHTMLNode(startNode, startOffset, address_of(child));
|
||||
if (child)
|
||||
{
|
||||
newStartNode = nsEditor::GetNodeLocation(child, &newStartOffset);
|
||||
newStartNode = EditorBase::GetNodeLocation(child, &newStartOffset);
|
||||
}
|
||||
// else block is empty - we can leave selection alone here, i think.
|
||||
} else if (wsStartObj.mEndReason == WSType::br) {
|
||||
// startpoint is just before a break. lets adjust it to after it.
|
||||
newStartNode = nsEditor::GetNodeLocation(GetAsDOMNode(wsStartObj.mEndReasonNode),
|
||||
&newStartOffset);
|
||||
newStartNode =
|
||||
EditorBase::GetNodeLocation(GetAsDOMNode(wsStartObj.mEndReasonNode),
|
||||
&newStartOffset);
|
||||
++newStartOffset; // offset *after* break
|
||||
}
|
||||
}
|
||||
@ -5516,9 +5517,9 @@ HTMLEditRules::PromoteRange(nsRange& aRange,
|
||||
|
||||
// Make sure that the new range ends up to be in the editable section.
|
||||
if (!mHTMLEditor->IsDescendantOfEditorRoot(
|
||||
nsEditor::GetNodeAtRangeOffsetPoint(opStartNode, opStartOffset)) ||
|
||||
EditorBase::GetNodeAtRangeOffsetPoint(opStartNode, opStartOffset)) ||
|
||||
!mHTMLEditor->IsDescendantOfEditorRoot(
|
||||
nsEditor::GetNodeAtRangeOffsetPoint(opEndNode, opEndOffset - 1))) {
|
||||
EditorBase::GetNodeAtRangeOffsetPoint(opEndNode, opEndOffset - 1))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5912,7 +5913,7 @@ HTMLEditRules::BustUpInlinesAtRangeEndpoints(RangeItem& item)
|
||||
int32_t resultEndOffset =
|
||||
mHTMLEditor->SplitNodeDeep(*endInline, *item.endNode->AsContent(),
|
||||
item.endOffset,
|
||||
nsEditor::EmptyContainers::no);
|
||||
EditorBase::EmptyContainers::no);
|
||||
NS_ENSURE_TRUE(resultEndOffset != -1, NS_ERROR_FAILURE);
|
||||
// reset range
|
||||
item.endNode = resultEndNode;
|
||||
@ -5928,7 +5929,7 @@ HTMLEditRules::BustUpInlinesAtRangeEndpoints(RangeItem& item)
|
||||
int32_t resultStartOffset =
|
||||
mHTMLEditor->SplitNodeDeep(*startInline, *item.startNode->AsContent(),
|
||||
item.startOffset,
|
||||
nsEditor::EmptyContainers::no);
|
||||
EditorBase::EmptyContainers::no);
|
||||
NS_ENSURE_TRUE(resultStartOffset != -1, NS_ERROR_FAILURE);
|
||||
// reset range
|
||||
item.startNode = resultStartNode;
|
||||
@ -6218,7 +6219,7 @@ HTMLEditRules::ReturnInParagraph(Selection* aSelection,
|
||||
nsresult res;
|
||||
|
||||
int32_t offset;
|
||||
nsCOMPtr<nsINode> parent = nsEditor::GetNodeLocation(node, &offset);
|
||||
nsCOMPtr<nsINode> parent = EditorBase::GetNodeLocation(node, &offset);
|
||||
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
bool doesCRCreateNewP = mHTMLEditor->GetReturnInParagraphCreatesNewParagraph();
|
||||
@ -6379,7 +6380,7 @@ HTMLEditRules::SplitParagraph(nsIDOMNode *aPara,
|
||||
else
|
||||
{
|
||||
int32_t offset;
|
||||
nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(child, &offset);
|
||||
nsCOMPtr<nsIDOMNode> parent = EditorBase::GetNodeLocation(child, &offset);
|
||||
aSelection->Collapse(parent,offset);
|
||||
}
|
||||
return res;
|
||||
@ -6740,7 +6741,7 @@ HTMLEditRules::ApplyBlockStyle(nsTArray<OwningNonNull<nsINode>>& aNodeArray,
|
||||
curBlock = nullptr;
|
||||
newBlock = mHTMLEditor->ReplaceContainer(curNode->AsElement(),
|
||||
&aBlockTag, nullptr, nullptr,
|
||||
nsEditor::eCloneAttributes);
|
||||
EditorBase::eCloneAttributes);
|
||||
NS_ENSURE_STATE(newBlock);
|
||||
} else if (HTMLEditUtils::IsTable(curNode) ||
|
||||
HTMLEditUtils::IsList(curNode) ||
|
||||
@ -7163,12 +7164,12 @@ HTMLEditRules::PinSelectionToNewBlock(Selection* aSelection)
|
||||
if (mHTMLEditor->IsTextNode(tmp) ||
|
||||
mHTMLEditor->IsContainer(tmp))
|
||||
{
|
||||
res = nsEditor::GetLengthOfDOMNode(tmp, endPoint);
|
||||
res = EditorBase::GetLengthOfDOMNode(tmp, endPoint);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = nsEditor::GetNodeLocation(tmp, (int32_t*)&endPoint);
|
||||
tmp = EditorBase::GetNodeLocation(tmp, (int32_t*)&endPoint);
|
||||
endPoint++; // want to be after this node
|
||||
}
|
||||
return aSelection->Collapse(tmp, (int32_t)endPoint);
|
||||
@ -7183,7 +7184,7 @@ HTMLEditRules::PinSelectionToNewBlock(Selection* aSelection)
|
||||
if (mHTMLEditor->IsTextNode(tmp) ||
|
||||
mHTMLEditor->IsContainer(tmp))
|
||||
{
|
||||
tmp = nsEditor::GetNodeLocation(tmp, &offset);
|
||||
tmp = EditorBase::GetNodeLocation(tmp, &offset);
|
||||
}
|
||||
return aSelection->Collapse(tmp, 0);
|
||||
}
|
||||
@ -7256,7 +7257,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
while (!mHTMLEditor->IsEditable(selNode))
|
||||
{
|
||||
// scan up the tree until we find an editable place to be
|
||||
selNode = nsEditor::GetNodeLocation(temp, &selOffset);
|
||||
selNode = EditorBase::GetNodeLocation(temp, &selOffset);
|
||||
NS_ENSURE_TRUE(selNode, NS_ERROR_FAILURE);
|
||||
temp = selNode;
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
@ -7323,7 +7324,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
getter_AddRefs(brNode));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsCOMPtr<nsIDOMNode> brParent =
|
||||
nsEditor::GetNodeLocation(brNode, &selOffset);
|
||||
EditorBase::GetNodeLocation(brNode, &selOffset);
|
||||
// selection stays *before* moz-br, sticking to it
|
||||
aSelection->SetInterlinePosition(true);
|
||||
res = aSelection->Collapse(brParent, selOffset);
|
||||
@ -7348,7 +7349,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
nearNode = mHTMLEditor->GetPriorHTMLNode(selNode, selOffset, true);
|
||||
if (nearNode && (TextEditUtils::IsBreak(nearNode) ||
|
||||
nsEditor::IsTextNode(nearNode) ||
|
||||
EditorBase::IsTextNode(nearNode) ||
|
||||
HTMLEditUtils::IsImage(nearNode) ||
|
||||
nearNode->IsHTMLElement(nsGkAtoms::hr))) {
|
||||
// this is a good place for the caret to be
|
||||
@ -7357,7 +7358,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
nearNode = mHTMLEditor->GetNextHTMLNode(selNode, selOffset, true);
|
||||
if (nearNode && (TextEditUtils::IsBreak(nearNode) ||
|
||||
nsEditor::IsTextNode(nearNode) ||
|
||||
EditorBase::IsTextNode(nearNode) ||
|
||||
nearNode->IsAnyOfHTMLElements(nsGkAtoms::img,
|
||||
nsGkAtoms::hr))) {
|
||||
return NS_OK; // this is a good place for the caret to be
|
||||
@ -7385,7 +7386,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
|
||||
}
|
||||
else // must be break or image
|
||||
{
|
||||
selNode = nsEditor::GetNodeLocation(nearNode, &selOffset);
|
||||
selNode = EditorBase::GetNodeLocation(nearNode, &selOffset);
|
||||
if (aAction == nsIEditor::ePrevious) selOffset++; // want to be beyond it if we backed up to it
|
||||
res = aSelection->Collapse(selNode, selOffset);
|
||||
}
|
||||
@ -8065,7 +8066,7 @@ HTMLEditRules::WillJoinNodes(nsIDOMNode* aLeftNode,
|
||||
return NS_OK;
|
||||
}
|
||||
// remember split point
|
||||
nsresult res = nsEditor::GetLengthOfDOMNode(aLeftNode, mJoinOffset);
|
||||
nsresult res = EditorBase::GetLengthOfDOMNode(aLeftNode, mJoinOffset);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -8217,7 +8218,7 @@ HTMLEditRules::RemoveAlignment(nsIDOMNode* aNode,
|
||||
res = mHTMLEditor->NodeIsBlockStatic(child, &isBlock);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
if (nsEditor::NodeIsType(child, nsGkAtoms::center)) {
|
||||
if (EditorBase::NodeIsType(child, nsGkAtoms::center)) {
|
||||
// the current node is a CENTER element
|
||||
// first remove children's alignment
|
||||
res = RemoveAlignment(child, aAlignType, true);
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "mozilla/SelectionState.h"
|
||||
#include "mozilla/TextEditRules.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIEditActionListener.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
|
@ -8,12 +8,12 @@
|
||||
#include "TextEditUtils.h" // for TextEditUtils
|
||||
#include "mozilla/ArrayUtils.h" // for ArrayLength
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
||||
#include "mozilla/EditorBase.h" // for EditorBase
|
||||
#include "mozilla/dom/Element.h" // for Element, nsINode
|
||||
#include "nsAString.h" // for nsAString_internal::IsEmpty
|
||||
#include "nsCOMPtr.h" // for nsCOMPtr, operator==, etc
|
||||
#include "nsCaseTreatment.h"
|
||||
#include "nsDebug.h" // for NS_PRECONDITION, etc
|
||||
#include "nsEditor.h" // for nsEditor
|
||||
#include "nsError.h" // for NS_SUCCEEDED
|
||||
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::a, etc
|
||||
#include "nsHTMLTags.h"
|
||||
@ -88,7 +88,7 @@ bool
|
||||
HTMLEditUtils::IsNodeThatCanOutdent(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(aNode);
|
||||
nsCOMPtr<nsIAtom> nodeAtom = EditorBase::GetTag(aNode);
|
||||
return (nodeAtom == nsGkAtoms::ul)
|
||||
|| (nodeAtom == nsGkAtoms::ol)
|
||||
|| (nodeAtom == nsGkAtoms::dl)
|
||||
@ -127,7 +127,7 @@ HTMLEditUtils::IsHeader(nsIDOMNode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsParagraph(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::p);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::p);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,7 +136,7 @@ HTMLEditUtils::IsParagraph(nsIDOMNode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsHR(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::hr);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::hr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,7 +215,7 @@ HTMLEditUtils::IsTableElementButNotTable(nsINode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsTable(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::table);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::table);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -230,7 +230,7 @@ HTMLEditUtils::IsTable(nsINode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsTableRow(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::tr);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::tr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -287,7 +287,7 @@ HTMLEditUtils::IsList(nsINode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsOrderedList(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::ol);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::ol);
|
||||
}
|
||||
|
||||
|
||||
@ -297,7 +297,7 @@ HTMLEditUtils::IsOrderedList(nsIDOMNode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsUnorderedList(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::ul);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::ul);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,7 +306,7 @@ HTMLEditUtils::IsUnorderedList(nsIDOMNode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsBlockquote(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::blockquote);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::blockquote);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -315,7 +315,7 @@ HTMLEditUtils::IsBlockquote(nsIDOMNode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsPre(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::pre);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::pre);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +330,7 @@ HTMLEditUtils::IsImage(nsINode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsImage(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::img);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::img);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -382,7 +382,7 @@ HTMLEditUtils::IsNamedAnchor(nsINode* aNode)
|
||||
bool
|
||||
HTMLEditUtils::IsDiv(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::div);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::div);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -466,7 +466,7 @@ bool
|
||||
HTMLEditUtils::SupportsAlignAttr(nsIDOMNode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(aNode);
|
||||
nsCOMPtr<nsIAtom> nodeAtom = EditorBase::GetTag(aNode);
|
||||
return (nodeAtom == nsGkAtoms::hr)
|
||||
|| (nodeAtom == nsGkAtoms::table)
|
||||
|| (nodeAtom == nsGkAtoms::tbody)
|
||||
|
@ -234,8 +234,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLEditor, TextEditor)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAddRowAfterButton)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(HTMLEditor, nsEditor)
|
||||
NS_IMPL_RELEASE_INHERITED(HTMLEditor, nsEditor)
|
||||
NS_IMPL_ADDREF_INHERITED(HTMLEditor, EditorBase)
|
||||
NS_IMPL_RELEASE_INHERITED(HTMLEditor, EditorBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLEditor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHTMLEditor)
|
||||
@ -355,7 +355,7 @@ HTMLEditor::GetRootElement(nsIDOMElement** aRootElement)
|
||||
NS_ENSURE_ARG_POINTER(aRootElement);
|
||||
|
||||
if (mRootElement) {
|
||||
return nsEditor::GetRootElement(aRootElement);
|
||||
return EditorBase::GetRootElement(aRootElement);
|
||||
}
|
||||
|
||||
*aRootElement = nullptr;
|
||||
@ -608,9 +608,9 @@ HTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
|
||||
// * editor/libeditor/tests/test_htmleditor_keyevent_handling.html
|
||||
|
||||
if (IsReadonly() || IsDisabled()) {
|
||||
// When we're not editable, the events are handled on nsEditor, so, we can
|
||||
// When we're not editable, the events are handled on EditorBase, so, we can
|
||||
// bypass TextEditor.
|
||||
return nsEditor::HandleKeyPressEvent(aKeyEvent);
|
||||
return EditorBase::HandleKeyPressEvent(aKeyEvent);
|
||||
}
|
||||
|
||||
WidgetKeyboardEvent* nativeKeyEvent =
|
||||
@ -627,9 +627,9 @@ HTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
|
||||
case NS_VK_ALT:
|
||||
case NS_VK_BACK:
|
||||
case NS_VK_DELETE:
|
||||
// These keys are handled on nsEditor, so, we can bypass
|
||||
// These keys are handled on EditorBase, so, we can bypass
|
||||
// TextEditor.
|
||||
return nsEditor::HandleKeyPressEvent(aKeyEvent);
|
||||
return EditorBase::HandleKeyPressEvent(aKeyEvent);
|
||||
case NS_VK_TAB: {
|
||||
if (IsPlaintextEditor()) {
|
||||
// If this works as plain text editor, e.g., mail editor for plain
|
||||
@ -830,7 +830,7 @@ HTMLEditor::SetDocumentTitle(const nsAString& aTitle)
|
||||
|
||||
//Don't let Rules System change the selection
|
||||
AutoTransactionsConserveSelection dontChangeSelection(this);
|
||||
return nsEditor::DoTransaction(transaction);
|
||||
return EditorBase::DoTransaction(transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3109,7 +3109,7 @@ HTMLEditor::DeleteSelectionImpl(EDirection aAction,
|
||||
{
|
||||
MOZ_ASSERT(aStripWrappers == eStrip || aStripWrappers == eNoStrip);
|
||||
|
||||
nsresult res = nsEditor::DeleteSelectionImpl(aAction, aStripWrappers);
|
||||
nsresult res = EditorBase::DeleteSelectionImpl(aAction, aStripWrappers);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// If we weren't asked to strip any wrappers, we're done.
|
||||
@ -3174,7 +3174,7 @@ HTMLEditor::DeleteNode(nsIDOMNode* aNode)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return nsEditor::DeleteNode(aNode);
|
||||
return EditorBase::DeleteNode(aNode);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -3187,7 +3187,7 @@ HTMLEditor::DeleteText(nsGenericDOMDataNode& aCharData,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return nsEditor::DeleteText(aCharData, aOffset, aLength);
|
||||
return EditorBase::DeleteText(aCharData, aOffset, aLength);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -3201,8 +3201,8 @@ HTMLEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return nsEditor::InsertTextImpl(aStringToInsert, aInOutNode, aInOutOffset,
|
||||
aDoc);
|
||||
return EditorBase::InsertTextImpl(aStringToInsert, aInOutNode, aInOutOffset,
|
||||
aDoc);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3472,7 +3472,7 @@ HTMLEditor::StartOperation(EditAction opID,
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
nsEditor::StartOperation(opID, aDirection); // will set mAction, mDirection
|
||||
EditorBase::StartOperation(opID, aDirection); // will set mAction, mDirection
|
||||
if (mRules) return mRules->BeforeEdit(mAction, mDirection);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3490,7 +3490,7 @@ HTMLEditor::EndOperation()
|
||||
// post processing
|
||||
nsresult res = NS_OK;
|
||||
if (mRules) res = mRules->AfterEdit(mAction, mDirection);
|
||||
nsEditor::EndOperation(); // will clear mAction, mDirection
|
||||
EditorBase::EndOperation(); // will clear mAction, mDirection
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -3562,7 +3562,7 @@ HTMLEditor::SelectEntireDocument(Selection* aSelection)
|
||||
return aSelection->Collapse(rootElement, 0);
|
||||
}
|
||||
|
||||
return nsEditor::SelectEntireDocument(aSelection);
|
||||
return EditorBase::SelectEntireDocument(aSelection);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -3741,7 +3741,7 @@ HTMLEditor::GetEnclosingTable(nsIDOMNode* aNode)
|
||||
* This method scans the selection for adjacent text nodes
|
||||
* and collapses them into a single text node.
|
||||
* "adjacent" means literally adjacent siblings of the same parent.
|
||||
* Uses nsEditor::JoinNodes so action is undoable.
|
||||
* Uses EditorBase::JoinNodes so action is undoable.
|
||||
* Should be called within the context of a batch transaction.
|
||||
*/
|
||||
nsresult
|
||||
@ -4371,7 +4371,7 @@ HTMLEditor::IsEmptyNodeImpl(nsINode* aNode,
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
// Is the child editable and non-empty? if so, return false
|
||||
if (nsEditor::IsEditable(child)) {
|
||||
if (EditorBase::IsEditable(child)) {
|
||||
if (child->NodeType() == nsIDOMNode::TEXT_NODE) {
|
||||
nsresult rv = IsVisTextNode(child, outIsEmptyNode, aSafeToAskFrames);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -4826,7 +4826,7 @@ HTMLEditor::GetElementOrigin(nsIDOMElement* aElement,
|
||||
nsresult
|
||||
HTMLEditor::EndUpdateViewBatch()
|
||||
{
|
||||
nsresult res = nsEditor::EndUpdateViewBatch();
|
||||
nsresult res = EditorBase::EndUpdateViewBatch();
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// We may need to show resizing handles or update existing ones after
|
||||
@ -5178,7 +5178,7 @@ HTMLEditor::OurWindowHasFocus()
|
||||
bool
|
||||
HTMLEditor::IsAcceptableInputEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (!nsEditor::IsAcceptableInputEvent(aEvent)) {
|
||||
if (!EditorBase::IsAcceptableInputEvent(aEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ public:
|
||||
virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent) override;
|
||||
virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override;
|
||||
virtual bool IsEditable(nsINode* aNode) override;
|
||||
using nsEditor::IsEditable;
|
||||
using EditorBase::IsEditable;
|
||||
|
||||
// nsStubMutationObserver overrides
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
||||
@ -248,7 +248,7 @@ public:
|
||||
nsresult SetCSSBackgroundColor(const nsAString& aColor);
|
||||
nsresult SetHTMLBackgroundColor(const nsAString& aColor);
|
||||
|
||||
// Block methods moved from nsEditor
|
||||
// Block methods moved from EditorBase
|
||||
static Element* GetBlockNodeParent(nsINode* aNode);
|
||||
static nsIDOMNode* GetBlockNodeParent(nsIDOMNode* aNode);
|
||||
static Element* GetBlock(nsINode& aNode);
|
||||
@ -266,7 +266,7 @@ public:
|
||||
nsIContent** outNode = nullptr,
|
||||
int32_t* outOffset = 0);
|
||||
|
||||
// Overrides of nsEditor interface methods
|
||||
// Overrides of EditorBase interface methods
|
||||
nsresult EndUpdateViewBatch() override;
|
||||
|
||||
NS_IMETHOD Init(nsIDOMDocument* aDoc, nsIContent* aRoot,
|
||||
@ -283,7 +283,7 @@ public:
|
||||
protected:
|
||||
virtual ~HTMLEditor();
|
||||
|
||||
using nsEditor::IsBlockNode;
|
||||
using EditorBase::IsBlockNode;
|
||||
virtual bool IsBlockNode(nsINode *aNode) override;
|
||||
|
||||
public:
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsDependentSubstring.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIClipboard.h"
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
@ -32,14 +31,14 @@ using namespace dom;
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult
|
||||
HTMLEditorEventListener::Connect(nsEditor* aEditor)
|
||||
HTMLEditorEventListener::Connect(EditorBase* aEditorBase)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryObject(aEditor);
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryObject(aEditorBase);
|
||||
nsCOMPtr<nsIHTMLInlineTableEditor> htmlInlineTableEditor =
|
||||
do_QueryObject(aEditor);
|
||||
do_QueryObject(aEditorBase);
|
||||
NS_PRECONDITION(htmlEditor && htmlInlineTableEditor,
|
||||
"Set HTMLEditor or its sub class");
|
||||
return EditorEventListener::Connect(aEditor);
|
||||
return EditorEventListener::Connect(aEditorBase);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -47,7 +46,7 @@ HTMLEditor*
|
||||
HTMLEditorEventListener::GetHTMLEditor()
|
||||
{
|
||||
// mEditor must be HTMLEditor or its subclass.
|
||||
return static_cast<HTMLEditor*>(mEditor);
|
||||
return static_cast<HTMLEditor*>(mEditorBase);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -104,7 +103,7 @@ HTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
||||
|
||||
if (isContextClick || (buttonNumber == 0 && clickCount == 2)) {
|
||||
RefPtr<Selection> selection = mEditor->GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_OK);
|
||||
|
||||
// Get location of mouse within target node
|
||||
|
@ -9,10 +9,9 @@
|
||||
#include "EditorEventListener.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsEditor;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class HTMLEditor;
|
||||
|
||||
class HTMLEditorEventListener final : public EditorEventListener
|
||||
@ -28,7 +27,7 @@ public:
|
||||
|
||||
#ifdef DEBUG
|
||||
// WARNING: You must be use HTMLEditor or its sub class for this class.
|
||||
virtual nsresult Connect(nsEditor* aEditor) override;
|
||||
virtual nsresult Connect(EditorBase* aEditorBase) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "nsCaseTreatment.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIAtom.h"
|
||||
@ -52,7 +51,7 @@ static bool
|
||||
IsEmptyTextNode(HTMLEditor* aThis, nsINode* aNode)
|
||||
{
|
||||
bool isEmptyTextNode = false;
|
||||
return nsEditor::IsTextNode(aNode) &&
|
||||
return EditorBase::IsTextNode(aNode) &&
|
||||
NS_SUCCEEDED(aThis->IsEmptyNode(aNode, &isEmptyTextNode)) &&
|
||||
isEmptyTextNode;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIAtom.h"
|
||||
@ -1978,13 +1977,13 @@ HTMLEditor::SwitchTableCellHeaderType(nsIDOMElement* aSourceCell,
|
||||
AutoSelectionRestorer selectionRestorer(selection, this);
|
||||
|
||||
// Set to the opposite of current type
|
||||
nsCOMPtr<nsIAtom> atom = nsEditor::GetTag(aSourceCell);
|
||||
nsCOMPtr<nsIAtom> atom = EditorBase::GetTag(aSourceCell);
|
||||
nsIAtom* newCellType = atom == nsGkAtoms::td ? nsGkAtoms::th : nsGkAtoms::td;
|
||||
|
||||
// This creates new node, moves children, copies attributes (true)
|
||||
// and manages the selection!
|
||||
nsCOMPtr<Element> newNode = ReplaceContainer(sourceCell, newCellType,
|
||||
nullptr, nullptr, nsEditor::eCloneAttributes);
|
||||
nullptr, nullptr, EditorBase::eCloneAttributes);
|
||||
NS_ENSURE_TRUE(newNode, NS_ERROR_FAILURE);
|
||||
|
||||
// Return the new cell
|
||||
@ -3251,7 +3250,7 @@ HTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIAtom> atom = nsEditor::GetTag(selectedNode);
|
||||
nsCOMPtr<nsIAtom> atom = EditorBase::GetTag(selectedNode);
|
||||
|
||||
if (atom == nsGkAtoms::td) {
|
||||
tableOrCellElement = do_QueryInterface(selectedNode);
|
||||
|
@ -5,11 +5,12 @@
|
||||
|
||||
#include "InsertNodeTransaction.h"
|
||||
|
||||
#include "mozilla/EditorBase.h" // for EditorBase
|
||||
|
||||
#include "mozilla/dom/Selection.h" // for Selection
|
||||
|
||||
#include "nsAString.h"
|
||||
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
|
||||
#include "nsEditor.h" // for nsEditor
|
||||
#include "nsError.h" // for NS_ERROR_NULL_POINTER, etc
|
||||
#include "nsIContent.h" // for nsIContent
|
||||
#include "nsMemory.h" // for nsMemory
|
||||
@ -23,11 +24,11 @@ using namespace dom;
|
||||
InsertNodeTransaction::InsertNodeTransaction(nsIContent& aNode,
|
||||
nsINode& aParent,
|
||||
int32_t aOffset,
|
||||
nsEditor& aEditor)
|
||||
EditorBase& aEditorBase)
|
||||
: mNode(&aNode)
|
||||
, mParent(&aParent)
|
||||
, mOffset(aOffset)
|
||||
, mEditor(aEditor)
|
||||
, mEditorBase(aEditorBase)
|
||||
{
|
||||
}
|
||||
|
||||
@ -58,15 +59,15 @@ InsertNodeTransaction::DoTransaction()
|
||||
// Note, it's ok for ref to be null. That means append.
|
||||
nsCOMPtr<nsIContent> ref = mParent->GetChildAt(mOffset);
|
||||
|
||||
mEditor.MarkNodeDirty(GetAsDOMNode(mNode));
|
||||
mEditorBase.MarkNodeDirty(GetAsDOMNode(mNode));
|
||||
|
||||
ErrorResult rv;
|
||||
mParent->InsertBefore(*mNode, ref, rv);
|
||||
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
|
||||
|
||||
// Only set selection to insertion point if editor gives permission
|
||||
if (mEditor.GetShouldTxnSetSelection()) {
|
||||
RefPtr<Selection> selection = mEditor.GetSelection();
|
||||
if (mEditorBase.GetShouldTxnSetSelection()) {
|
||||
RefPtr<Selection> selection = mEditorBase.GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
// Place the selection just after the inserted element
|
||||
selection->Collapse(mParent, mOffset + 1);
|
||||
|
@ -12,10 +12,10 @@
|
||||
#include "nsIContent.h" // for nsIContent
|
||||
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
class nsEditor;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
|
||||
/**
|
||||
* A transaction that inserts a single element
|
||||
*/
|
||||
@ -29,7 +29,7 @@ public:
|
||||
* @param aOffset The offset in aParent to insert aNode.
|
||||
*/
|
||||
InsertNodeTransaction(nsIContent& aNode, nsINode& aParent, int32_t aOffset,
|
||||
nsEditor& aEditor);
|
||||
EditorBase& aEditorBase);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertNodeTransaction,
|
||||
@ -50,7 +50,7 @@ protected:
|
||||
int32_t mOffset;
|
||||
|
||||
// The editor for this transaction.
|
||||
nsEditor& mEditor;
|
||||
EditorBase& mEditorBase;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -5,11 +5,11 @@
|
||||
|
||||
#include "InsertTextTransaction.h"
|
||||
|
||||
#include "mozilla/EditorBase.h" // mEditorBase
|
||||
#include "mozilla/dom/Selection.h" // Selection local var
|
||||
#include "mozilla/dom/Text.h" // mTextNode
|
||||
#include "nsAString.h" // nsAString parameter
|
||||
#include "nsDebug.h" // for NS_ASSERTION, etc
|
||||
#include "nsEditor.h" // mEditor
|
||||
#include "nsError.h" // for NS_OK, etc
|
||||
#include "nsQueryObject.h" // for do_QueryObject
|
||||
|
||||
@ -20,11 +20,11 @@ using namespace dom;
|
||||
InsertTextTransaction::InsertTextTransaction(Text& aTextNode,
|
||||
uint32_t aOffset,
|
||||
const nsAString& aStringToInsert,
|
||||
nsEditor& aEditor)
|
||||
EditorBase& aEditorBase)
|
||||
: mTextNode(&aTextNode)
|
||||
, mOffset(aOffset)
|
||||
, mStringToInsert(aStringToInsert)
|
||||
, mEditor(aEditor)
|
||||
, mEditorBase(aEditorBase)
|
||||
{
|
||||
}
|
||||
|
||||
@ -51,8 +51,8 @@ InsertTextTransaction::DoTransaction()
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// Only set selection to insertion point if editor gives permission
|
||||
if (mEditor.GetShouldTxnSetSelection()) {
|
||||
RefPtr<Selection> selection = mEditor.GetSelection();
|
||||
if (mEditorBase.GetShouldTxnSetSelection()) {
|
||||
RefPtr<Selection> selection = mEditorBase.GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
res = selection->Collapse(mTextNode,
|
||||
mOffset + mStringToInsert.Length());
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "nsString.h" // nsString members
|
||||
#include "nscore.h" // NS_IMETHOD, nsAString
|
||||
|
||||
class nsEditor;
|
||||
class nsITransaction;
|
||||
|
||||
#define NS_INSERTTEXTTXN_IID \
|
||||
@ -22,6 +21,7 @@ class nsITransaction;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
namespace dom {
|
||||
class Text;
|
||||
} // namespace dom
|
||||
@ -41,7 +41,7 @@ public:
|
||||
* @param aPresShell Used to get and set the selection.
|
||||
*/
|
||||
InsertTextTransaction(dom::Text& aTextNode, uint32_t aOffset,
|
||||
const nsAString& aString, nsEditor& aEditor);
|
||||
const nsAString& aString, EditorBase& aEditorBase);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertTextTransaction,
|
||||
@ -72,7 +72,7 @@ private:
|
||||
nsString mStringToInsert;
|
||||
|
||||
// The editor, which we'll need to get the selection.
|
||||
nsEditor& mEditor;
|
||||
EditorBase& mEditorBase;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(InsertTextTransaction, NS_INSERTTEXTTXN_IID)
|
||||
|
@ -4,23 +4,24 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "JoinNodeTransaction.h"
|
||||
|
||||
#include "mozilla/EditorBase.h" // for EditorBase
|
||||
#include "nsAString.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION, etc
|
||||
#include "nsEditor.h" // for nsEditor
|
||||
#include "nsError.h" // for NS_ERROR_NULL_POINTER, etc
|
||||
#include "nsIContent.h" // for nsIContent
|
||||
#include "nsIDOMCharacterData.h" // for nsIDOMCharacterData
|
||||
#include "nsIEditor.h" // for nsEditor::IsModifiableNode
|
||||
#include "nsIEditor.h" // for EditorBase::IsModifiableNode
|
||||
#include "nsISupportsImpl.h" // for QueryInterface, etc
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
JoinNodeTransaction::JoinNodeTransaction(nsEditor& aEditor,
|
||||
JoinNodeTransaction::JoinNodeTransaction(EditorBase& aEditorBase,
|
||||
nsINode& aLeftNode,
|
||||
nsINode& aRightNode)
|
||||
: mEditor(aEditor)
|
||||
: mEditorBase(aEditorBase)
|
||||
, mLeftNode(&aLeftNode)
|
||||
, mRightNode(&aRightNode)
|
||||
, mOffset(0)
|
||||
@ -38,7 +39,7 @@ NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
|
||||
nsresult
|
||||
JoinNodeTransaction::CheckValidity()
|
||||
{
|
||||
if (!mEditor.IsModifiableNode(mLeftNode->GetParentNode())) {
|
||||
if (!mEditorBase.IsModifiableNode(mLeftNode->GetParentNode())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
@ -64,7 +65,7 @@ JoinNodeTransaction::DoTransaction()
|
||||
mParent = leftParent;
|
||||
mOffset = mLeftNode->Length();
|
||||
|
||||
return mEditor.JoinNodesImpl(mRightNode, mLeftNode, mParent);
|
||||
return mEditorBase.JoinNodesImpl(mRightNode, mLeftNode, mParent);
|
||||
}
|
||||
|
||||
//XXX: What if instead of split, we just deleted the unneeded children of
|
||||
|
@ -12,11 +12,12 @@
|
||||
#include "nsID.h" // for REFNSIID
|
||||
#include "nscore.h" // for NS_IMETHOD
|
||||
|
||||
class nsEditor;
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
|
||||
/**
|
||||
* A transaction that joins two nodes E1 (left node) and E2 (right node) into a
|
||||
* single node E. The children of E are the children of E1 followed by the
|
||||
@ -27,11 +28,11 @@ class JoinNodeTransaction final : public EditTransactionBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param aEditor The provider of core editing operations.
|
||||
* @param aEditorBase The provider of core editing operations.
|
||||
* @param aLeftNode The first of two nodes to join.
|
||||
* @param aRightNode The second of two nodes to join.
|
||||
*/
|
||||
JoinNodeTransaction(nsEditor& aEditor,
|
||||
JoinNodeTransaction(EditorBase& aEditorBase,
|
||||
nsINode& aLeftNode, nsINode& aRightNode);
|
||||
|
||||
/**
|
||||
@ -46,7 +47,7 @@ public:
|
||||
NS_DECL_EDITTRANSACTIONBASE
|
||||
|
||||
protected:
|
||||
nsEditor& mEditor;
|
||||
EditorBase& mEditorBase;
|
||||
|
||||
// The nodes to operate upon. After the merge, mRightNode remains and
|
||||
// mLeftNode is removed from the content tree.
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include "PlaceholderTransaction.h"
|
||||
|
||||
#include "CompositionTransaction.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsQueryObject.h"
|
||||
|
||||
@ -20,7 +20,7 @@ PlaceholderTransaction::PlaceholderTransaction()
|
||||
, mForwarding(nullptr)
|
||||
, mCompositionTransaction(nullptr)
|
||||
, mCommitted(false)
|
||||
, mEditor(nullptr)
|
||||
, mEditorBase(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -57,13 +57,13 @@ NS_IMPL_RELEASE_INHERITED(PlaceholderTransaction, EditAggregateTransaction)
|
||||
NS_IMETHODIMP
|
||||
PlaceholderTransaction::Init(nsIAtom* aName,
|
||||
SelectionState* aSelState,
|
||||
nsEditor* aEditor)
|
||||
EditorBase* aEditorBase)
|
||||
{
|
||||
NS_ENSURE_TRUE(aEditor && aSelState, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(aEditorBase && aSelState, NS_ERROR_NULL_POINTER);
|
||||
|
||||
mName = aName;
|
||||
mStartSel = aSelState;
|
||||
mEditor = aEditor;
|
||||
mEditorBase = aEditorBase;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ PlaceholderTransaction::UndoTransaction()
|
||||
NS_ENSURE_TRUE(mStartSel, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// now restore selection
|
||||
RefPtr<Selection> selection = mEditor->GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
return mStartSel->RestoreSelection(selection);
|
||||
}
|
||||
@ -96,7 +96,7 @@ PlaceholderTransaction::RedoTransaction()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// now restore selection
|
||||
RefPtr<Selection> selection = mEditor->GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
return mEndSel.RestoreSelection(selection);
|
||||
}
|
||||
@ -265,7 +265,7 @@ PlaceholderTransaction::Commit()
|
||||
nsresult
|
||||
PlaceholderTransaction::RememberEndingSelection()
|
||||
{
|
||||
RefPtr<Selection> selection = mEditor->GetSelection();
|
||||
RefPtr<Selection> selection = mEditorBase->GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
mEndSel.SaveSelection(selection);
|
||||
return NS_OK;
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
// ------------ nsIAbsorbingTransaction -----------------------
|
||||
|
||||
NS_IMETHOD Init(nsIAtom* aName, SelectionState* aSelState,
|
||||
nsEditor* aEditor) override;
|
||||
EditorBase* aEditorBase) override;
|
||||
|
||||
NS_IMETHOD GetTxnName(nsIAtom** aName) override;
|
||||
|
||||
@ -84,7 +84,7 @@ protected:
|
||||
SelectionState mEndSel;
|
||||
|
||||
// The editor for this transaction.
|
||||
nsEditor* mEditor;
|
||||
EditorBase* mEditorBase;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsAString.h" // for nsAString_internal::Length
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
|
||||
#include "nsEditor.h" // for nsEditor
|
||||
#include "nsError.h" // for NS_OK, etc
|
||||
#include "nsIContent.h" // for nsIContent
|
||||
#include "nsIDOMCharacterData.h" // for nsIDOMCharacterData
|
||||
|
@ -5,10 +5,10 @@
|
||||
|
||||
#include "SplitNodeTransaction.h"
|
||||
|
||||
#include "mozilla/EditorBase.h" // for EditorBase
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION, etc
|
||||
#include "nsEditor.h" // for nsEditor
|
||||
#include "nsError.h" // for NS_ERROR_NOT_INITIALIZED, etc
|
||||
#include "nsIContent.h" // for nsIContent
|
||||
|
||||
@ -16,10 +16,10 @@ namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
||||
SplitNodeTransaction::SplitNodeTransaction(nsEditor& aEditor,
|
||||
SplitNodeTransaction::SplitNodeTransaction(EditorBase& aEditorBase,
|
||||
nsIContent& aNode,
|
||||
int32_t aOffset)
|
||||
: mEditor(aEditor)
|
||||
: mEditorBase(aEditorBase)
|
||||
, mExistingRightNode(&aNode)
|
||||
, mOffset(aOffset)
|
||||
{
|
||||
@ -48,16 +48,16 @@ SplitNodeTransaction::DoTransaction()
|
||||
NS_ASSERTION(!rv.Failed() && clone, "Could not create clone");
|
||||
NS_ENSURE_TRUE(!rv.Failed() && clone, rv.StealNSResult());
|
||||
mNewLeftNode = dont_AddRef(clone.forget().take()->AsContent());
|
||||
mEditor.MarkNodeDirty(mExistingRightNode->AsDOMNode());
|
||||
mEditorBase.MarkNodeDirty(mExistingRightNode->AsDOMNode());
|
||||
|
||||
// Get the parent node
|
||||
mParent = mExistingRightNode->GetParentNode();
|
||||
NS_ENSURE_TRUE(mParent, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// Insert the new node
|
||||
rv = mEditor.SplitNodeImpl(*mExistingRightNode, mOffset, *mNewLeftNode);
|
||||
if (mEditor.GetShouldTxnSetSelection()) {
|
||||
RefPtr<Selection> selection = mEditor.GetSelection();
|
||||
rv = mEditorBase.SplitNodeImpl(*mExistingRightNode, mOffset, *mNewLeftNode);
|
||||
if (mEditorBase.GetShouldTxnSetSelection()) {
|
||||
RefPtr<Selection> selection = mEditorBase.GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
rv = selection->Collapse(mNewLeftNode, mOffset);
|
||||
}
|
||||
@ -70,7 +70,7 @@ SplitNodeTransaction::UndoTransaction()
|
||||
MOZ_ASSERT(mNewLeftNode && mParent);
|
||||
|
||||
// This assumes Do inserted the new node in front of the prior existing node
|
||||
return mEditor.JoinNodesImpl(mExistingRightNode, mNewLeftNode, mParent);
|
||||
return mEditorBase.JoinNodesImpl(mExistingRightNode, mNewLeftNode, mParent);
|
||||
}
|
||||
|
||||
/* Redo cannot simply resplit the right node, because subsequent transactions
|
||||
|
@ -12,12 +12,13 @@
|
||||
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
|
||||
#include "nscore.h" // for NS_IMETHOD
|
||||
|
||||
class nsEditor;
|
||||
class nsIContent;
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
|
||||
/**
|
||||
* A transaction that splits a node into two identical nodes, with the children
|
||||
* divided between the new nodes.
|
||||
@ -26,13 +27,14 @@ class SplitNodeTransaction final : public EditTransactionBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param aEditor The provider of core editing operations
|
||||
* @param aNode The node to split
|
||||
* @param aOffset The location within aNode to do the split. aOffset may
|
||||
* refer to children of aNode, or content of aNode. The left
|
||||
* node will have child|content 0..aOffset-1.
|
||||
* @param aEditorBase The provider of core editing operations
|
||||
* @param aNode The node to split
|
||||
* @param aOffset The location within aNode to do the split. aOffset may
|
||||
* refer to children of aNode, or content of aNode. The
|
||||
* left node will have child|content 0..aOffset-1.
|
||||
*/
|
||||
SplitNodeTransaction(nsEditor& aEditor, nsIContent& aNode, int32_t aOffset);
|
||||
SplitNodeTransaction(EditorBase& aEditorBase, nsIContent& aNode,
|
||||
int32_t aOffset);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitNodeTransaction,
|
||||
@ -47,7 +49,7 @@ public:
|
||||
protected:
|
||||
virtual ~SplitNodeTransaction();
|
||||
|
||||
nsEditor& mEditor;
|
||||
EditorBase& mEditorBase;
|
||||
|
||||
// The node to operate upon.
|
||||
nsCOMPtr<nsIContent> mExistingRightNode;
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIContent.h"
|
||||
@ -461,7 +460,8 @@ TextEditRules::CollapseSelectionToTrailingBRIfNeeded(Selection* aSelection)
|
||||
return NS_OK;
|
||||
|
||||
int32_t parentOffset;
|
||||
nsCOMPtr<nsIDOMNode> parentNode = nsEditor::GetNodeLocation(selNode, &parentOffset);
|
||||
nsCOMPtr<nsIDOMNode> parentNode =
|
||||
EditorBase::GetNodeLocation(selNode, &parentOffset);
|
||||
|
||||
NS_ENSURE_STATE(mTextEditor);
|
||||
nsCOMPtr<nsIDOMNode> root = do_QueryInterface(mTextEditor->GetRoot());
|
||||
@ -478,7 +478,9 @@ TextEditRules::CollapseSelectionToTrailingBRIfNeeded(Selection* aSelection)
|
||||
}
|
||||
|
||||
static inline already_AddRefed<nsIDOMNode>
|
||||
GetTextNode(Selection* selection, nsEditor* editor) {
|
||||
GetTextNode(Selection* selection,
|
||||
EditorBase* editor)
|
||||
{
|
||||
int32_t selOffset;
|
||||
nsCOMPtr<nsIDOMNode> selNode;
|
||||
nsresult res = editor->GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
||||
|
@ -6,9 +6,9 @@
|
||||
#ifndef mozilla_TextEditRules_h
|
||||
#define mozilla_TextEditRules_h
|
||||
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIEditRules.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCaseTreatment.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@ -33,7 +32,7 @@ namespace mozilla {
|
||||
bool
|
||||
TextEditUtils::IsBody(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::body);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::body);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,7 +41,7 @@ TextEditUtils::IsBody(nsIDOMNode* aNode)
|
||||
bool
|
||||
TextEditUtils::IsBreak(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::br);
|
||||
return EditorBase::NodeIsType(aNode, nsGkAtoms::br);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -94,23 +94,23 @@ TextEditor::~TextEditor()
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(TextEditor)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(TextEditor, nsEditor)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(TextEditor, EditorBase)
|
||||
if (tmp->mRules)
|
||||
tmp->mRules->DetachEditor();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRules)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(TextEditor, nsEditor)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(TextEditor, EditorBase)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRules)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(TextEditor, nsEditor)
|
||||
NS_IMPL_RELEASE_INHERITED(TextEditor, nsEditor)
|
||||
NS_IMPL_ADDREF_INHERITED(TextEditor, EditorBase)
|
||||
NS_IMPL_RELEASE_INHERITED(TextEditor, EditorBase)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TextEditor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPlaintextEditor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEditorMailSupport)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsEditor)
|
||||
NS_INTERFACE_MAP_END_INHERITING(EditorBase)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -133,7 +133,7 @@ TextEditor::Init(nsIDOMDocument* aDoc,
|
||||
AutoEditInitRulesTrigger rulesTrigger(this, rulesRes);
|
||||
|
||||
// Init the base editor
|
||||
res = nsEditor::Init(aDoc, aRoot, aSelCon, aFlags, aInitialValue);
|
||||
res = EditorBase::Init(aDoc, aRoot, aSelCon, aFlags, aInitialValue);
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rulesRes, rulesRes);
|
||||
@ -215,7 +215,7 @@ TextEditor::EndEditorInit()
|
||||
NS_IMETHODIMP
|
||||
TextEditor::SetDocumentCharacterSet(const nsACString& characterSet)
|
||||
{
|
||||
nsresult rv = nsEditor::SetDocumentCharacterSet(characterSet);
|
||||
nsresult rv = EditorBase::SetDocumentCharacterSet(characterSet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Update META charset element.
|
||||
@ -309,10 +309,10 @@ TextEditor::UpdateMetaCharset(nsIDOMDocument* aDocument,
|
||||
// set attribute to <original prefix> charset=text/html
|
||||
nsCOMPtr<nsIDOMElement> metaElement = do_QueryInterface(metaNode);
|
||||
MOZ_ASSERT(metaElement);
|
||||
rv = nsEditor::SetAttribute(metaElement, NS_LITERAL_STRING("content"),
|
||||
Substring(originalStart, start) +
|
||||
charsetEquals +
|
||||
NS_ConvertASCIItoUTF16(aCharacterSet));
|
||||
rv = EditorBase::SetAttribute(metaElement, NS_LITERAL_STRING("content"),
|
||||
Substring(originalStart, start) +
|
||||
charsetEquals +
|
||||
NS_ConvertASCIItoUTF16(aCharacterSet));
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
return false;
|
||||
@ -357,8 +357,8 @@ TextEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
|
||||
// HandleKeyPressEvent()'s switch statement.
|
||||
|
||||
if (IsReadonly() || IsDisabled()) {
|
||||
// When we're not editable, the events handled on nsEditor.
|
||||
return nsEditor::HandleKeyPressEvent(aKeyEvent);
|
||||
// When we're not editable, the events handled on EditorBase.
|
||||
return EditorBase::HandleKeyPressEvent(aKeyEvent);
|
||||
}
|
||||
|
||||
WidgetKeyboardEvent* nativeKeyEvent =
|
||||
@ -375,8 +375,8 @@ TextEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
|
||||
case NS_VK_ALT:
|
||||
case NS_VK_BACK:
|
||||
case NS_VK_DELETE:
|
||||
// These keys are handled on nsEditor
|
||||
return nsEditor::HandleKeyPressEvent(aKeyEvent);
|
||||
// These keys are handled on EditorBase
|
||||
return EditorBase::HandleKeyPressEvent(aKeyEvent);
|
||||
case NS_VK_TAB: {
|
||||
if (IsTabbable()) {
|
||||
return NS_OK; // let it be used for focus switching
|
||||
@ -844,7 +844,7 @@ TextEditor::BeginIMEComposition(WidgetCompositionEvent* aEvent)
|
||||
textEditRules->ResetIMETextPWBuf();
|
||||
}
|
||||
|
||||
return nsEditor::BeginIMEComposition(aEvent);
|
||||
return EditorBase::BeginIMEComposition(aEvent);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1104,7 +1104,7 @@ TextEditor::Undo(uint32_t aCount)
|
||||
|
||||
if (!cancel && NS_SUCCEEDED(result))
|
||||
{
|
||||
result = nsEditor::Undo(aCount);
|
||||
result = EditorBase::Undo(aCount);
|
||||
result = mRules->DidDoAction(selection, &ruleInfo, result);
|
||||
}
|
||||
|
||||
@ -1133,7 +1133,7 @@ TextEditor::Redo(uint32_t aCount)
|
||||
|
||||
if (!cancel && NS_SUCCEEDED(result))
|
||||
{
|
||||
result = nsEditor::Redo(aCount);
|
||||
result = EditorBase::Redo(aCount);
|
||||
result = mRules->DidDoAction(selection, &ruleInfo, result);
|
||||
}
|
||||
|
||||
@ -1552,7 +1552,7 @@ TextEditor::StartOperation(EditAction opID,
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
nsEditor::StartOperation(opID, aDirection); // will set mAction, mDirection
|
||||
EditorBase::StartOperation(opID, aDirection); // will set mAction, mDirection
|
||||
if (mRules) return mRules->BeforeEdit(mAction, mDirection);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1570,7 +1570,7 @@ TextEditor::EndOperation()
|
||||
// post processing
|
||||
nsresult res = NS_OK;
|
||||
if (mRules) res = mRules->AfterEdit(mAction, mDirection);
|
||||
nsEditor::EndOperation(); // will clear mAction, mDirection
|
||||
EditorBase::EndOperation(); // will clear mAction, mDirection
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1595,7 +1595,7 @@ TextEditor::SelectEntireDocument(Selection* aSelection)
|
||||
}
|
||||
|
||||
SelectionBatcher selectionBatcher(aSelection);
|
||||
nsresult rv = nsEditor::SelectEntireDocument(aSelection);
|
||||
nsresult rv = EditorBase::SelectEntireDocument(aSelection);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Don't select the trailing BR node if we have one
|
||||
@ -1630,7 +1630,7 @@ TextEditor::SetAttributeOrEquivalent(nsIDOMElement* aElement,
|
||||
const nsAString& aValue,
|
||||
bool aSuppressTransaction)
|
||||
{
|
||||
return nsEditor::SetAttribute(aElement, aAttribute, aValue);
|
||||
return EditorBase::SetAttribute(aElement, aAttribute, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1638,7 +1638,7 @@ TextEditor::RemoveAttributeOrEquivalent(nsIDOMElement* aElement,
|
||||
const nsAString& aAttribute,
|
||||
bool aSuppressTransaction)
|
||||
{
|
||||
return nsEditor::RemoveAttribute(aElement, aAttribute);
|
||||
return EditorBase::RemoveAttribute(aElement, aAttribute);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -6,9 +6,9 @@
|
||||
#ifndef mozilla_TextEditor_h
|
||||
#define mozilla_TextEditor_h
|
||||
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIEditorMailSupport.h"
|
||||
#include "nsIPlaintextEditor.h"
|
||||
@ -40,13 +40,13 @@ class Selection;
|
||||
* The text editor implementation.
|
||||
* Use to edit text document represented as a DOM tree.
|
||||
*/
|
||||
class TextEditor : public nsEditor
|
||||
class TextEditor : public EditorBase
|
||||
, public nsIPlaintextEditor
|
||||
, public nsIEditorMailSupport
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextEditor, nsEditor)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextEditor, EditorBase)
|
||||
|
||||
enum ETypingAction
|
||||
{
|
||||
@ -63,7 +63,7 @@ public:
|
||||
// nsIEditorMailSupport overrides
|
||||
NS_DECL_NSIEDITORMAILSUPPORT
|
||||
|
||||
// Overrides of nsEditor interface methods
|
||||
// Overrides of EditorBase interface methods
|
||||
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement* aElement,
|
||||
const nsAString& aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsError.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsISupportsBase.h"
|
||||
@ -63,7 +63,9 @@ TypeInState::UpdateSelState(Selection* aSelection)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsEditor::GetStartNodeAndOffset(aSelection, getter_AddRefs(mLastSelectionContainer), &mLastSelectionOffset);
|
||||
return EditorBase::GetStartNodeAndOffset(
|
||||
aSelection, getter_AddRefs(mLastSelectionContainer),
|
||||
&mLastSelectionOffset);
|
||||
}
|
||||
|
||||
|
||||
@ -92,8 +94,8 @@ TypeInState::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
|
||||
int32_t selOffset = 0;
|
||||
|
||||
nsresult result =
|
||||
nsEditor::GetStartNodeAndOffset(selection, getter_AddRefs(selNode),
|
||||
&selOffset);
|
||||
EditorBase::GetStartNodeAndOffset(selection, getter_AddRefs(selNode),
|
||||
&selOffset);
|
||||
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
|
@ -14,11 +14,11 @@ MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
|
||||
BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
|
||||
|
||||
EXPORTS += [
|
||||
'nsEditor.h',
|
||||
'nsIEditRules.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'EditorBase.h',
|
||||
'EditorController.h',
|
||||
'HTMLEditor.h',
|
||||
'SelectionState.h',
|
||||
@ -36,6 +36,7 @@ UNIFIED_SOURCES += [
|
||||
'DeleteRangeTransaction.cpp',
|
||||
'DeleteTextTransaction.cpp',
|
||||
'EditAggregateTransaction.cpp',
|
||||
'EditorBase.cpp',
|
||||
'EditorCommands.cpp',
|
||||
'EditorController.cpp',
|
||||
'EditorEventListener.cpp',
|
||||
@ -57,7 +58,6 @@ UNIFIED_SOURCES += [
|
||||
'InsertTextTransaction.cpp',
|
||||
'InternetCiter.cpp',
|
||||
'JoinNodeTransaction.cpp',
|
||||
'nsEditor.cpp',
|
||||
'PlaceholderTransaction.cpp',
|
||||
'SelectionState.cpp',
|
||||
'SetDocumentTitleTransaction.cpp',
|
||||
|
@ -22,6 +22,7 @@ Transaction interface to outside world
|
||||
class nsIAtom;
|
||||
|
||||
namespace mozilla {
|
||||
class EditorBase;
|
||||
class SelectionState;
|
||||
} // namespace mozilla
|
||||
|
||||
@ -35,7 +36,7 @@ public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IABSORBINGTRANSACTION_IID)
|
||||
|
||||
NS_IMETHOD Init(nsIAtom* aName, mozilla::SelectionState* aSelState,
|
||||
nsEditor* aEditor) = 0;
|
||||
mozilla::EditorBase* aEditorBase) = 0;
|
||||
|
||||
NS_IMETHOD EndPlaceHolderBatch()=0;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
{ 0x3836386d, 0x806a, 0x488d, \
|
||||
{ 0x8b, 0xab, 0xaf, 0x42, 0xbb, 0x4c, 0x90, 0x66 } }
|
||||
|
||||
#include "nsEditor.h" // for EditAction enum
|
||||
#include "mozilla/EditorBase.h" // for EditAction enum
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "EditorUtils.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozInlineSpellChecker.h"
|
||||
@ -66,7 +67,6 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsITextControlElement.h"
|
||||
#include "prtime.h"
|
||||
|
@ -6,13 +6,13 @@
|
||||
#ifndef __mozinlinespellchecker_h__
|
||||
#define __mozinlinespellchecker_h__
|
||||
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsIEditorSpellCheck.h"
|
||||
#include "nsIEditActionListener.h"
|
||||
#include "nsIInlineSpellChecker.h"
|
||||
#include "nsIDOMTreeWalker.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "mozISpellI18NUtil.h"
|
||||
|
@ -7616,7 +7616,7 @@ nsLayoutUtils::GetEditableRootContentByContentEditable(nsIDocument* aDocument)
|
||||
// contenteditable only works with HTML document.
|
||||
// Note: Use nsIDOMHTMLDocument rather than nsIHTMLDocument for getting the
|
||||
// body node because nsIDOMHTMLDocument::GetBody() does something
|
||||
// additional work for some cases and nsEditor uses them.
|
||||
// additional work for some cases and EditorBase uses them.
|
||||
nsCOMPtr<nsIDOMHTMLDocument> domHTMLDoc = do_QueryInterface(aDocument);
|
||||
if (!domHTMLDoc) {
|
||||
return nullptr;
|
||||
|
@ -136,7 +136,6 @@ using mozilla::dom::AudioChannelAgent;
|
||||
|
||||
// Editor stuff
|
||||
#include "nsEditorCID.h"
|
||||
#include "nsEditor.h"
|
||||
#include "mozilla/EditorController.h" //CID
|
||||
#include "mozilla/HTMLEditor.h"
|
||||
|
||||
|
@ -257,8 +257,8 @@ ModifierKeyState::Unset(Modifiers aRemovingModifiers)
|
||||
{
|
||||
mModifiers &= ~aRemovingModifiers;
|
||||
// Note that we don't need to unset AltGr flag here automatically.
|
||||
// For nsEditor, we need to remove Alt and Control flags but AltGr isn't
|
||||
// checked in nsEditor, so, it can be kept.
|
||||
// For EditorBase, we need to remove Alt and Control flags but AltGr isn't
|
||||
// checked in EditorBase, so, it can be kept.
|
||||
}
|
||||
|
||||
void
|
||||
@ -583,7 +583,7 @@ VirtualKey::GetUniChars(ShiftState aShiftState) const
|
||||
// Even if the shifted chars and the unshifted chars are same, we
|
||||
// should consume the Alt key state and the Ctrl key state when
|
||||
// AltGr key is pressed. Because if we don't consume them, the input
|
||||
// events are ignored on nsEditor. (I.e., Users cannot input the
|
||||
// events are ignored on EditorBase. (I.e., Users cannot input the
|
||||
// characters with this key combination.)
|
||||
Modifiers finalModifiers = ShiftStateToModifiers(aShiftState);
|
||||
finalModifiers &= ~(MODIFIER_ALT | MODIFIER_CONTROL);
|
||||
@ -1699,7 +1699,7 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg,
|
||||
}
|
||||
|
||||
// When AltGr (Alt+Ctrl) is pressed, that causes normal text input.
|
||||
// At this time, if either alt or ctrl flag is set, nsEditor ignores the
|
||||
// At this time, if either alt or ctrl flag is set, EditorBase ignores the
|
||||
// keypress event. For avoiding this issue, we should remove ctrl and alt
|
||||
// flags.
|
||||
ModifierKeyState modKeyState(mModKeyState);
|
||||
|
Loading…
Reference in New Issue
Block a user