mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1713758 - Make everyone outside editor module use EditorBase
instead of TextEditor
if the instance can be an HTMLEditor
instance r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D117119
This commit is contained in:
parent
a07b257da5
commit
4bc0632c23
@ -41,11 +41,11 @@
|
||||
#include "nsTHashSet.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/HTMLEditor.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/StaticPrefs_accessibility.h"
|
||||
#include "mozilla/TextEditor.h"
|
||||
#include "mozilla/dom/AncestorIterator.h"
|
||||
#include "mozilla/dom/BrowserChild.h"
|
||||
#include "mozilla/dom/DocumentType.h"
|
||||
@ -239,8 +239,8 @@ uint64_t DocAccessible::NativeState() const {
|
||||
state |= states::INVISIBLE | states::OFFSCREEN;
|
||||
}
|
||||
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
state |= textEditor ? states::EDITABLE : states::READONLY;
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
state |= editorBase ? states::EDITABLE : states::READONLY;
|
||||
|
||||
return state;
|
||||
}
|
||||
@ -295,7 +295,7 @@ void DocAccessible::TakeFocus() const {
|
||||
}
|
||||
|
||||
// HyperTextAccessible method
|
||||
already_AddRefed<TextEditor> DocAccessible::GetEditor() const {
|
||||
already_AddRefed<EditorBase> DocAccessible::GetEditor() const {
|
||||
// Check if document is editable (designMode="on" case). Otherwise check if
|
||||
// the html:body (for HTML document case) or document element is editable.
|
||||
if (!mDocumentNode->HasFlag(NODE_IS_EDITABLE) &&
|
||||
|
@ -25,8 +25,8 @@ const uint32_t kDefaultCacheLength = 128;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class PresShell;
|
||||
class TextEditor;
|
||||
|
||||
namespace dom {
|
||||
class Document;
|
||||
@ -87,7 +87,7 @@ class DocAccessible : public HyperTextAccessibleWrap,
|
||||
virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const override;
|
||||
|
||||
// HyperTextAccessible
|
||||
virtual already_AddRefed<TextEditor> GetEditor() const override;
|
||||
virtual already_AddRefed<EditorBase> GetEditor() const override;
|
||||
|
||||
// DocAccessible
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsFrameSelection.h"
|
||||
|
||||
#include "mozilla/TextEditor.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
@ -53,58 +53,58 @@ inline void HyperTextAccessible::ReplaceText(const nsAString& aText) {
|
||||
|
||||
SetSelectionRange(0, CharacterCount());
|
||||
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
if (!textEditor) {
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
if (!editorBase) {
|
||||
return;
|
||||
}
|
||||
|
||||
DebugOnly<nsresult> rv = textEditor->InsertTextAsAction(aText);
|
||||
DebugOnly<nsresult> rv = editorBase->InsertTextAsAction(aText);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to insert the new text");
|
||||
}
|
||||
|
||||
inline void HyperTextAccessible::InsertText(const nsAString& aText,
|
||||
int32_t aPosition) {
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
if (textEditor) {
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
if (editorBase) {
|
||||
SetSelectionRange(aPosition, aPosition);
|
||||
DebugOnly<nsresult> rv = textEditor->InsertTextAsAction(aText);
|
||||
DebugOnly<nsresult> rv = editorBase->InsertTextAsAction(aText);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to insert the text");
|
||||
}
|
||||
}
|
||||
|
||||
inline void HyperTextAccessible::CopyText(int32_t aStartPos, int32_t aEndPos) {
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
if (textEditor) {
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
if (editorBase) {
|
||||
SetSelectionRange(aStartPos, aEndPos);
|
||||
textEditor->Copy();
|
||||
editorBase->Copy();
|
||||
}
|
||||
}
|
||||
|
||||
inline void HyperTextAccessible::CutText(int32_t aStartPos, int32_t aEndPos) {
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
if (textEditor) {
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
if (editorBase) {
|
||||
SetSelectionRange(aStartPos, aEndPos);
|
||||
textEditor->Cut();
|
||||
editorBase->Cut();
|
||||
}
|
||||
}
|
||||
|
||||
inline void HyperTextAccessible::DeleteText(int32_t aStartPos,
|
||||
int32_t aEndPos) {
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
if (!textEditor) {
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
if (!editorBase) {
|
||||
return;
|
||||
}
|
||||
SetSelectionRange(aStartPos, aEndPos);
|
||||
DebugOnly<nsresult> rv =
|
||||
textEditor->DeleteSelectionAsAction(nsIEditor::eNone, nsIEditor::eStrip);
|
||||
editorBase->DeleteSelectionAsAction(nsIEditor::eNone, nsIEditor::eStrip);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to delete text");
|
||||
}
|
||||
|
||||
inline void HyperTextAccessible::PasteText(int32_t aPosition) {
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
if (textEditor) {
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
if (editorBase) {
|
||||
SetSelectionRange(aPosition, aPosition);
|
||||
textEditor->PasteAsAction(nsIClipboard::kGlobalClipboard, true);
|
||||
editorBase->PasteAsAction(nsIClipboard::kGlobalClipboard, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,12 +36,12 @@
|
||||
#include "nsTextFragment.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/BinarySearch.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/HTMLEditor.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/TextEditor.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLBRElement.h"
|
||||
#include "mozilla/dom/HTMLHeadingElement.h"
|
||||
@ -445,10 +445,10 @@ DOMPoint HyperTextAccessible::OffsetToDOMPoint(int32_t aOffset) const {
|
||||
// 0 offset is valid even if no children. In this case the associated editor
|
||||
// is empty so return a DOM point for editor root element.
|
||||
if (aOffset == 0) {
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
if (textEditor) {
|
||||
if (textEditor->IsEmpty()) {
|
||||
return DOMPoint(textEditor->GetRoot(), 0);
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
if (editorBase) {
|
||||
if (editorBase->IsEmpty()) {
|
||||
return DOMPoint(editorBase->GetRoot(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1593,7 +1593,7 @@ nsIntRect HyperTextAccessible::TextBounds(int32_t aStartOffset,
|
||||
return bounds;
|
||||
}
|
||||
|
||||
already_AddRefed<TextEditor> HyperTextAccessible::GetEditor() const {
|
||||
already_AddRefed<EditorBase> HyperTextAccessible::GetEditor() const {
|
||||
if (!mContent->HasFlag(NODE_IS_EDITABLE)) {
|
||||
// If we're inside an editable container, then return that container's
|
||||
// editor
|
||||
@ -1635,7 +1635,7 @@ nsresult HyperTextAccessible::SetSelectionRange(int32_t aStartPos,
|
||||
// the selection we set here and leave the caret at the end of the text.
|
||||
// By calling GetEditor here, we ensure that editor initialization is
|
||||
// completed before we set the selection.
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
|
||||
bool isFocusable = InteractiveState() & states::FOCUSABLE;
|
||||
|
||||
@ -1852,9 +1852,9 @@ void HyperTextAccessible::GetSelectionDOMRanges(SelectionType aSelectionType,
|
||||
|
||||
nsINode* startNode = GetNode();
|
||||
|
||||
RefPtr<TextEditor> textEditor = GetEditor();
|
||||
if (textEditor) {
|
||||
startNode = textEditor->GetRoot();
|
||||
RefPtr<EditorBase> editorBase = GetEditor();
|
||||
if (editorBase) {
|
||||
startNode = editorBase->GetRoot();
|
||||
}
|
||||
|
||||
if (!startNode) return;
|
||||
|
@ -20,7 +20,7 @@ class nsRange;
|
||||
class nsIWidget;
|
||||
|
||||
namespace mozilla {
|
||||
class TextEditor;
|
||||
class EditorBase;
|
||||
namespace dom {
|
||||
class Selection;
|
||||
}
|
||||
@ -400,7 +400,7 @@ class HyperTextAccessible : public AccessibleWrap {
|
||||
* Return the editor associated with the accessible.
|
||||
* The result may be either TextEditor or HTMLEditor.
|
||||
*/
|
||||
virtual already_AddRefed<TextEditor> GetEditor() const;
|
||||
virtual already_AddRefed<EditorBase> GetEditor() const;
|
||||
|
||||
/**
|
||||
* Return DOM selection object for the accessible.
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -407,7 +408,7 @@ bool HTMLTextFieldAccessible::DoAction(uint8_t aIndex) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
already_AddRefed<TextEditor> HTMLTextFieldAccessible::GetEditor() const {
|
||||
already_AddRefed<EditorBase> HTMLTextFieldAccessible::GetEditor() const {
|
||||
RefPtr<TextControlElement> textControlElement =
|
||||
TextControlElement::FromNodeOrNull(mContent);
|
||||
if (!textControlElement) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "Relation.h"
|
||||
|
||||
namespace mozilla {
|
||||
class TextEditor;
|
||||
class EditorBase;
|
||||
namespace a11y {
|
||||
|
||||
/**
|
||||
@ -81,7 +81,7 @@ class HTMLTextFieldAccessible : public HyperTextAccessibleWrap {
|
||||
HyperTextAccessibleWrap)
|
||||
|
||||
// HyperTextAccessible
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual already_AddRefed<TextEditor> GetEditor()
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual already_AddRefed<EditorBase> GetEditor()
|
||||
const override;
|
||||
|
||||
// LocalAccessible
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/DocLoadingTimelineMarker.h"
|
||||
#include "mozilla/DocumentStyleRootIterator.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/EditorCommands.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
@ -5074,7 +5075,7 @@ Document::AutoEditorCommandTarget::AutoEditorCommandTarget(
|
||||
mHTMLEditor = nullptr;
|
||||
}
|
||||
|
||||
TextEditor* Document::AutoEditorCommandTarget::GetTargetEditor() const {
|
||||
EditorBase* Document::AutoEditorCommandTarget::GetTargetEditor() const {
|
||||
using CommandOnTextEditor = InternalCommandData::CommandOnTextEditor;
|
||||
switch (mCommandData.mCommandOnTextEditor) {
|
||||
case CommandOnTextEditor::Enabled:
|
||||
@ -5095,7 +5096,7 @@ bool Document::AutoEditorCommandTarget::IsEditable(Document* aDocument) const {
|
||||
// we're editable.
|
||||
doc->FlushPendingNotifications(FlushType::Frames);
|
||||
}
|
||||
TextEditor* targetEditor = GetTargetEditor();
|
||||
EditorBase* targetEditor = GetTargetEditor();
|
||||
if (targetEditor && targetEditor->IsTextEditor()) {
|
||||
// FYI: When `disabled` attribute is set, `TextEditor` treats it as
|
||||
// "readonly" too.
|
||||
@ -5105,7 +5106,7 @@ bool Document::AutoEditorCommandTarget::IsEditable(Document* aDocument) const {
|
||||
}
|
||||
|
||||
bool Document::AutoEditorCommandTarget::IsCommandEnabled() const {
|
||||
TextEditor* targetEditor = GetTargetEditor();
|
||||
EditorBase* targetEditor = GetTargetEditor();
|
||||
if (!targetEditor) {
|
||||
return false;
|
||||
}
|
||||
@ -5118,7 +5119,7 @@ nsresult Document::AutoEditorCommandTarget::DoCommand(
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
MOZ_ASSERT(!DoNothing());
|
||||
MOZ_ASSERT(mEditorCommand);
|
||||
TextEditor* targetEditor = GetTargetEditor();
|
||||
EditorBase* targetEditor = GetTargetEditor();
|
||||
if (!targetEditor) {
|
||||
return NS_SUCCESS_DOM_NO_OPERATION;
|
||||
}
|
||||
@ -5133,7 +5134,7 @@ nsresult Document::AutoEditorCommandTarget::DoCommandParam(
|
||||
const ParamType& aParam, nsIPrincipal* aPrincipal) const {
|
||||
MOZ_ASSERT(!DoNothing());
|
||||
MOZ_ASSERT(mEditorCommand);
|
||||
TextEditor* targetEditor = GetTargetEditor();
|
||||
EditorBase* targetEditor = GetTargetEditor();
|
||||
if (!targetEditor) {
|
||||
return NS_SUCCESS_DOM_NO_OPERATION;
|
||||
}
|
||||
@ -5146,7 +5147,7 @@ nsresult Document::AutoEditorCommandTarget::DoCommandParam(
|
||||
nsresult Document::AutoEditorCommandTarget::GetCommandStateParams(
|
||||
nsCommandParams& aParams) const {
|
||||
MOZ_ASSERT(mEditorCommand);
|
||||
TextEditor* targetEditor = GetTargetEditor();
|
||||
EditorBase* targetEditor = GetTargetEditor();
|
||||
if (!targetEditor) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -5732,8 +5733,7 @@ nsresult Document::TurnEditingOff() {
|
||||
if (nsFocusManager* fm = nsFocusManager::GetFocusManager()) {
|
||||
if (RefPtr<TextControlElement> textControlElement =
|
||||
TextControlElement::FromNodeOrNull(fm->GetFocusedElement())) {
|
||||
RefPtr<TextEditor> textEditor = textControlElement->GetTextEditor();
|
||||
if (textEditor) {
|
||||
if (RefPtr<TextEditor> textEditor = textControlElement->GetTextEditor()) {
|
||||
textEditor->ReinitializeSelection(*textControlElement);
|
||||
}
|
||||
}
|
||||
|
@ -187,6 +187,7 @@ struct nsFont;
|
||||
namespace mozilla {
|
||||
class AbstractThread;
|
||||
class StyleSheet;
|
||||
class EditorBase;
|
||||
class EditorCommand;
|
||||
class Encoding;
|
||||
class ErrorResult;
|
||||
@ -204,7 +205,6 @@ class SMILAnimationController;
|
||||
enum class StyleCursorKind : uint8_t;
|
||||
enum class StylePrefersColorScheme : uint8_t;
|
||||
enum class StyleRuleChangeKind : uint32_t;
|
||||
class TextEditor;
|
||||
template <typename>
|
||||
class OwningNonNull;
|
||||
struct URLExtraData;
|
||||
@ -4194,9 +4194,9 @@ class Document : public nsINode,
|
||||
|
||||
private:
|
||||
// The returned editor's life is guaranteed while this instance is alive.
|
||||
TextEditor* GetTargetEditor() const;
|
||||
EditorBase* GetTargetEditor() const;
|
||||
|
||||
RefPtr<TextEditor> mActiveEditor;
|
||||
RefPtr<EditorBase> mActiveEditor;
|
||||
RefPtr<HTMLEditor> mHTMLEditor;
|
||||
RefPtr<EditorCommand> mEditorCommand;
|
||||
const InternalCommandData& mCommandData;
|
||||
|
@ -4365,7 +4365,7 @@ nsresult nsContentUtils::DispatchInputEvent(Element* aEventTarget) {
|
||||
// static
|
||||
nsresult nsContentUtils::DispatchInputEvent(
|
||||
Element* aEventTargetElement, EventMessage aEventMessage,
|
||||
EditorInputType aEditorInputType, TextEditor* aTextEditor,
|
||||
EditorInputType aEditorInputType, EditorBase* aEditorBase,
|
||||
InputEventOptions&& aOptions, nsEventStatus* aEventStatus /* = nullptr */) {
|
||||
MOZ_ASSERT(aEventMessage == eEditorInput ||
|
||||
aEventMessage == eEditorBeforeInput);
|
||||
@ -4374,22 +4374,22 @@ nsresult nsContentUtils::DispatchInputEvent(
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// If this is called from editor, the instance should be set to aTextEditor.
|
||||
// If this is called from editor, the instance should be set to aEditorBase.
|
||||
// Otherwise, we need to look for an editor for aEventTargetElement.
|
||||
// However, we don't need to do it for HTMLEditor since nobody shouldn't
|
||||
// dispatch "beforeinput" nor "input" event for HTMLEditor except HTMLEditor
|
||||
// itself.
|
||||
bool useInputEvent = false;
|
||||
if (aTextEditor) {
|
||||
if (aEditorBase) {
|
||||
useInputEvent = true;
|
||||
} else if (HTMLTextAreaElement* textAreaElement =
|
||||
HTMLTextAreaElement::FromNode(aEventTargetElement)) {
|
||||
aTextEditor = textAreaElement->GetTextEditorWithoutCreation();
|
||||
aEditorBase = textAreaElement->GetTextEditorWithoutCreation();
|
||||
useInputEvent = true;
|
||||
} else if (HTMLInputElement* inputElement =
|
||||
HTMLInputElement::FromNode(aEventTargetElement)) {
|
||||
if (inputElement->IsInputEventTarget()) {
|
||||
aTextEditor = inputElement->GetTextEditorWithoutCreation();
|
||||
aEditorBase = inputElement->GetTextEditorWithoutCreation();
|
||||
useInputEvent = true;
|
||||
}
|
||||
}
|
||||
@ -4424,8 +4424,8 @@ nsresult nsContentUtils::DispatchInputEvent(
|
||||
aEditorInputType == EditorInputType::eInsertReplacementText);
|
||||
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
if (aTextEditor) {
|
||||
widget = aTextEditor->GetWidget();
|
||||
if (aEditorBase) {
|
||||
widget = aEditorBase->GetWidget();
|
||||
if (NS_WARN_IF(!widget)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -4467,9 +4467,9 @@ nsresult nsContentUtils::DispatchInputEvent(
|
||||
// Otherwise, i.e., editor hasn't been created for the element yet,
|
||||
// we should set isComposing to false since the element can never has
|
||||
// composition without editor.
|
||||
inputEvent.mIsComposing = aTextEditor && aTextEditor->GetComposition();
|
||||
inputEvent.mIsComposing = aEditorBase && aEditorBase->GetComposition();
|
||||
|
||||
if (!aTextEditor || !aTextEditor->AsHTMLEditor()) {
|
||||
if (!aEditorBase || aEditorBase->IsTextEditor()) {
|
||||
if (IsDataAvailableOnTextEditor(aEditorInputType)) {
|
||||
inputEvent.mData = std::move(aOptions.mData);
|
||||
MOZ_ASSERT(!inputEvent.mData.IsVoid(),
|
||||
@ -4484,7 +4484,7 @@ nsresult nsContentUtils::DispatchInputEvent(
|
||||
aOptions.mTargetRanges.IsEmpty(),
|
||||
"Target ranges for <input> and <textarea> should always be empty");
|
||||
} else {
|
||||
MOZ_ASSERT(aTextEditor->AsHTMLEditor());
|
||||
MOZ_ASSERT(aEditorBase->IsHTMLEditor());
|
||||
if (IsDataAvailableOnHTMLEditor(aEditorInputType)) {
|
||||
inputEvent.mData = std::move(aOptions.mData);
|
||||
MOZ_ASSERT(!inputEvent.mData.IsVoid(),
|
||||
@ -7094,7 +7094,7 @@ HTMLEditor* nsContentUtils::GetHTMLEditor(nsDocShell* aDocShell) {
|
||||
}
|
||||
|
||||
// static
|
||||
TextEditor* nsContentUtils::GetActiveEditor(nsPresContext* aPresContext) {
|
||||
EditorBase* nsContentUtils::GetActiveEditor(nsPresContext* aPresContext) {
|
||||
if (!aPresContext) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -7103,7 +7103,7 @@ TextEditor* nsContentUtils::GetActiveEditor(nsPresContext* aPresContext) {
|
||||
}
|
||||
|
||||
// static
|
||||
TextEditor* nsContentUtils::GetActiveEditor(nsPIDOMWindowOuter* aWindow) {
|
||||
EditorBase* nsContentUtils::GetActiveEditor(nsPIDOMWindowOuter* aWindow) {
|
||||
if (!aWindow || !aWindow->GetExtantDoc()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ class PropertyDescriptor;
|
||||
|
||||
namespace mozilla {
|
||||
class Dispatcher;
|
||||
class EditorBase;
|
||||
class ErrorResult;
|
||||
class EventListenerManager;
|
||||
class HTMLEditor;
|
||||
@ -1501,7 +1502,7 @@ class nsContentUtils {
|
||||
* @param aEditorInputType The inputType value of InputEvent.
|
||||
* If aEventTarget won't dispatch "input" event
|
||||
* with InputEvent, set EditorInputType::eUnknown.
|
||||
* @param aTextEditor Optional. If this is called by editor,
|
||||
* @param aEditorBase Optional. If this is called by editor,
|
||||
* editor should set this. Otherwise, leave
|
||||
* nullptr.
|
||||
* @param aOptions Optional. If aEditorInputType value requires
|
||||
@ -1518,7 +1519,7 @@ class nsContentUtils {
|
||||
MOZ_CAN_RUN_SCRIPT static nsresult DispatchInputEvent(
|
||||
Element* aEventTarget, mozilla::EventMessage aEventMessage,
|
||||
mozilla::EditorInputType aEditorInputType,
|
||||
mozilla::TextEditor* aTextEditor, mozilla::InputEventOptions&& aOptions,
|
||||
mozilla::EditorBase* aEditorBase, mozilla::InputEventOptions&& aOptions,
|
||||
nsEventStatus* aEventStatus = nullptr);
|
||||
|
||||
/**
|
||||
@ -2714,8 +2715,8 @@ class nsContentUtils {
|
||||
* even if there is no active editing host.
|
||||
* Note that this does not return editor in descendant documents.
|
||||
*/
|
||||
static mozilla::TextEditor* GetActiveEditor(nsPresContext* aPresContext);
|
||||
static mozilla::TextEditor* GetActiveEditor(nsPIDOMWindowOuter* aWindow);
|
||||
static mozilla::EditorBase* GetActiveEditor(nsPresContext* aPresContext);
|
||||
static mozilla::EditorBase* GetActiveEditor(nsPIDOMWindowOuter* aWindow);
|
||||
|
||||
/**
|
||||
* Returns `TextEditor` which manages `aAnonymousContent` if there is.
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
@ -5269,7 +5270,7 @@ nsresult EventStateManager::DispatchClickEvents(
|
||||
|
||||
nsresult EventStateManager::HandleMiddleClickPaste(
|
||||
PresShell* aPresShell, WidgetMouseEvent* aMouseEvent,
|
||||
nsEventStatus* aStatus, TextEditor* aTextEditor) {
|
||||
nsEventStatus* aStatus, EditorBase* aEditorBase) {
|
||||
MOZ_ASSERT(aPresShell);
|
||||
MOZ_ASSERT(aMouseEvent);
|
||||
MOZ_ASSERT((aMouseEvent->mMessage == eMouseAuxClick &&
|
||||
@ -5287,8 +5288,8 @@ nsresult EventStateManager::HandleMiddleClickPaste(
|
||||
aMouseEvent->mFlags.mMultipleActionsPrevented = true;
|
||||
|
||||
RefPtr<Selection> selection;
|
||||
if (aTextEditor) {
|
||||
selection = aTextEditor->GetSelection();
|
||||
if (aEditorBase) {
|
||||
selection = aEditorBase->GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -5329,12 +5330,12 @@ nsresult EventStateManager::HandleMiddleClickPaste(
|
||||
|
||||
// Although we've fired "paste" event, there is no editor to accept the
|
||||
// clipboard content.
|
||||
if (!aTextEditor) {
|
||||
if (!aEditorBase) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check if the editor is still the good target to paste.
|
||||
if (aTextEditor->Destroyed() || aTextEditor->IsReadonly()) {
|
||||
if (aEditorBase->Destroyed() || aEditorBase->IsReadonly()) {
|
||||
// XXX Should we consume the event when the editor is readonly and/or
|
||||
// disabled?
|
||||
return NS_OK;
|
||||
@ -5349,7 +5350,7 @@ nsresult EventStateManager::HandleMiddleClickPaste(
|
||||
WidgetMouseEvent mouseEvent(*aMouseEvent);
|
||||
mouseEvent.mOriginalTarget = range->GetStartContainer();
|
||||
if (NS_WARN_IF(!mouseEvent.mOriginalTarget) ||
|
||||
!aTextEditor->IsAcceptableInputEvent(&mouseEvent)) {
|
||||
!aEditorBase->IsAcceptableInputEvent(&mouseEvent)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -5357,10 +5358,10 @@ nsresult EventStateManager::HandleMiddleClickPaste(
|
||||
// quotation. Otherwise, paste it as is.
|
||||
if (aMouseEvent->IsControl()) {
|
||||
DebugOnly<nsresult> rv =
|
||||
aTextEditor->PasteAsQuotationAsAction(clipboardType, false);
|
||||
aEditorBase->PasteAsQuotationAsAction(clipboardType, false);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to paste as quotation");
|
||||
} else {
|
||||
DebugOnly<nsresult> rv = aTextEditor->PasteAsAction(clipboardType, false);
|
||||
DebugOnly<nsresult> rv = aEditorBase->PasteAsAction(clipboardType, false);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to paste");
|
||||
}
|
||||
*aStatus = nsEventStatus_eConsumeNoDefault;
|
||||
@ -5950,7 +5951,7 @@ nsresult EventStateManager::DoContentCommandInsertTextEvent(
|
||||
|
||||
// If there is no active editor in this process, we should treat the command
|
||||
// is disabled.
|
||||
RefPtr<TextEditor> activeEditor =
|
||||
RefPtr<EditorBase> activeEditor =
|
||||
nsContentUtils::GetActiveEditor(mPresContext);
|
||||
if (!activeEditor) {
|
||||
aEvent->mSucceeded = true;
|
||||
|
@ -35,11 +35,11 @@ class nsPresContext;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class EnterLeaveDispatcher;
|
||||
class EventStates;
|
||||
class IMEContentObserver;
|
||||
class ScrollbarsForWheel;
|
||||
class TextEditor;
|
||||
class WheelTransaction;
|
||||
|
||||
namespace dom {
|
||||
@ -326,7 +326,7 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
|
||||
|
||||
/**
|
||||
* HandleMiddleClickPaste() handles middle mouse button event as pasting
|
||||
* clipboard text. Note that if aTextEditor is nullptr, this only
|
||||
* clipboard text. Note that if aEditorBase is nullptr, this only
|
||||
* dispatches ePaste event because it's necessary for some web apps which
|
||||
* want to implement their own editor and supports middle click paste.
|
||||
*
|
||||
@ -335,7 +335,7 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
|
||||
* @param aMouseEvent The eMouseClick event which caused the
|
||||
* paste.
|
||||
* @param aStatus The event status of aMouseEvent.
|
||||
* @param aTextEditor TextEditor which may be pasted the
|
||||
* @param aEditorBase EditorBase which may be pasted the
|
||||
* clipboard text by the middle click.
|
||||
* If there is no editor for aMouseEvent,
|
||||
* set nullptr.
|
||||
@ -344,7 +344,7 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
|
||||
nsresult HandleMiddleClickPaste(PresShell* aPresShell,
|
||||
WidgetMouseEvent* aMouseEvent,
|
||||
nsEventStatus* aStatus,
|
||||
TextEditor* aTextEditor);
|
||||
EditorBase* aEditorBase);
|
||||
|
||||
protected:
|
||||
/*
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "HTMLBodyElement.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/HTMLBodyElementBinding.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/MappedDeclarations.h"
|
||||
#include "mozilla/HTMLEditor.h"
|
||||
#include "mozilla/TextEditor.h"
|
||||
@ -251,11 +252,8 @@ HTMLBodyElement::IsAttributeMapped(const nsAtom* aAttribute) const {
|
||||
return FindAttributeDependence(aAttribute, map);
|
||||
}
|
||||
|
||||
already_AddRefed<TextEditor> HTMLBodyElement::GetAssociatedEditor() {
|
||||
RefPtr<TextEditor> textEditor = GetTextEditorInternal();
|
||||
if (textEditor) {
|
||||
return textEditor.forget();
|
||||
}
|
||||
already_AddRefed<EditorBase> HTMLBodyElement::GetAssociatedEditor() {
|
||||
MOZ_ASSERT(!GetTextEditorInternal());
|
||||
|
||||
// Make sure this is the actual body of the document
|
||||
if (this != OwnerDoc()->GetBodyElement()) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class TextEditor;
|
||||
class EditorBase;
|
||||
|
||||
namespace dom {
|
||||
|
||||
@ -95,7 +95,7 @@ class HTMLBodyElement final : public nsGenericHTMLElement {
|
||||
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction()
|
||||
const override;
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
|
||||
virtual already_AddRefed<TextEditor> GetAssociatedEditor() override;
|
||||
virtual already_AddRefed<EditorBase> GetAssociatedEditor() override;
|
||||
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
||||
|
||||
virtual bool IsEventAttributeNameInternal(nsAtom* aName) override;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/DeclarationBlock.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
@ -2496,7 +2497,7 @@ nsresult nsGenericHTMLElement::DispatchSimulatedClick(
|
||||
return EventDispatcher::Dispatch(ToSupports(aElement), aPresContext, &event);
|
||||
}
|
||||
|
||||
already_AddRefed<TextEditor> nsGenericHTMLElement::GetAssociatedEditor() {
|
||||
already_AddRefed<EditorBase> nsGenericHTMLElement::GetAssociatedEditor() {
|
||||
// If contenteditable is ever implemented, it might need to do something
|
||||
// different here?
|
||||
|
||||
@ -2509,9 +2510,8 @@ void nsGenericHTMLElement::SyncEditorsOnSubtree(nsIContent* content) {
|
||||
/* Sync this node */
|
||||
nsGenericHTMLElement* element = FromNode(content);
|
||||
if (element) {
|
||||
RefPtr<TextEditor> textEditor = element->GetAssociatedEditor();
|
||||
if (textEditor) {
|
||||
textEditor->SyncRealTimeSpell();
|
||||
if (RefPtr<EditorBase> editorBase = element->GetAssociatedEditor()) {
|
||||
editorBase->SyncRealTimeSpell();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,13 +26,13 @@ class nsIURI;
|
||||
struct nsSize;
|
||||
|
||||
namespace mozilla {
|
||||
class EditorBase;
|
||||
class ErrorResult;
|
||||
class EventChainPostVisitor;
|
||||
class EventChainPreVisitor;
|
||||
class EventChainVisitor;
|
||||
class EventListenerManager;
|
||||
class EventStates;
|
||||
class TextEditor;
|
||||
class PresState;
|
||||
namespace dom {
|
||||
class ElementInternals;
|
||||
@ -836,14 +836,14 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates the TextEditor associated with this node. In general this is
|
||||
* Locates the EditorBase associated with this node. In general this is
|
||||
* equivalent to GetEditorInternal(), but for designmode or contenteditable,
|
||||
* this may need to get an editor that's not actually on this element's
|
||||
* associated TextControlFrame. This is used by the spellchecking routines
|
||||
* to get the editor affected by changing the spellcheck attribute on this
|
||||
* node.
|
||||
*/
|
||||
virtual already_AddRefed<mozilla::TextEditor> GetAssociatedEditor();
|
||||
virtual already_AddRefed<mozilla::EditorBase> GetAssociatedEditor();
|
||||
|
||||
/**
|
||||
* Get the frame's offset information for offsetTop/Left/Width/Height.
|
||||
|
Loading…
Reference in New Issue
Block a user