Bug 1964011 - part 2: Make the editor classes log text input r=m_kato
Depends on D248368 Differential Revision: https://phabricator.services.mozilla.com/D248369
This commit is contained in:
committed by
masayuki@d-toybox.com
parent
90e1f5ae9a
commit
8dd9d35fa1
@@ -150,6 +150,7 @@ using LeafNodeTypes = HTMLEditUtils::LeafNodeTypes;
|
|||||||
using WalkTreeOption = HTMLEditUtils::WalkTreeOption;
|
using WalkTreeOption = HTMLEditUtils::WalkTreeOption;
|
||||||
|
|
||||||
static LazyLogModule gEventLog("EditorEvent");
|
static LazyLogModule gEventLog("EditorEvent");
|
||||||
|
LazyLogModule gTextInputLog("EditorTextInput");
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* mozilla::EditorBase
|
* mozilla::EditorBase
|
||||||
@@ -4041,6 +4042,13 @@ bool EditorBase::EnsureComposition(WidgetCompositionEvent& aCompositionEvent) {
|
|||||||
|
|
||||||
nsresult EditorBase::OnCompositionStart(
|
nsresult EditorBase::OnCompositionStart(
|
||||||
WidgetCompositionEvent& aCompositionStartEvent) {
|
WidgetCompositionEvent& aCompositionStartEvent) {
|
||||||
|
MOZ_LOG(gTextInputLog, LogLevel::Info,
|
||||||
|
("%p %s::OnCompositionStart(aCompositionStartEvent={ mData=\"%s\"}), "
|
||||||
|
"mComposition=%p",
|
||||||
|
this, mIsHTMLEditorClass ? "HTMLEditor" : "TextEditor",
|
||||||
|
NS_ConvertUTF16toUTF8(aCompositionStartEvent.mData).get(),
|
||||||
|
mComposition.get()));
|
||||||
|
|
||||||
if (mComposition) {
|
if (mComposition) {
|
||||||
NS_WARNING("There was a composition at receiving compositionstart event");
|
NS_WARNING("There was a composition at receiving compositionstart event");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@@ -4062,6 +4070,15 @@ nsresult EditorBase::OnCompositionChange(
|
|||||||
MOZ_ASSERT(aCompositionChangeEvent.mMessage == eCompositionChange,
|
MOZ_ASSERT(aCompositionChangeEvent.mMessage == eCompositionChange,
|
||||||
"The event should be eCompositionChange");
|
"The event should be eCompositionChange");
|
||||||
|
|
||||||
|
MOZ_LOG(
|
||||||
|
gTextInputLog, LogLevel::Info,
|
||||||
|
("%p %s::OnCompositionChange(aCompositionChangeEvent={ mData=\"%s\", "
|
||||||
|
"IsFollowedByCompositionEnd()=%s }), mComposition=%p",
|
||||||
|
this, mIsHTMLEditorClass ? "HTMLEditor" : "TextEditor",
|
||||||
|
NS_ConvertUTF16toUTF8(aCompositionChangeEvent.mData).get(),
|
||||||
|
aCompositionChangeEvent.IsFollowedByCompositionEnd() ? "true" : "false",
|
||||||
|
mComposition.get()));
|
||||||
|
|
||||||
if (!mComposition) {
|
if (!mComposition) {
|
||||||
NS_WARNING(
|
NS_WARNING(
|
||||||
"There is no composition, but receiving compositionchange event");
|
"There is no composition, but receiving compositionchange event");
|
||||||
@@ -4208,6 +4225,13 @@ nsresult EditorBase::OnCompositionChange(
|
|||||||
|
|
||||||
void EditorBase::OnCompositionEnd(
|
void EditorBase::OnCompositionEnd(
|
||||||
WidgetCompositionEvent& aCompositionEndEvent) {
|
WidgetCompositionEvent& aCompositionEndEvent) {
|
||||||
|
MOZ_LOG(gTextInputLog, LogLevel::Info,
|
||||||
|
("%p %s::OnCompositionEnd(aCompositionEndEvent={ mData=\"%s\"}), "
|
||||||
|
"mComposition=%p",
|
||||||
|
this, mIsHTMLEditorClass ? "HTMLEditor" : "TextEditor",
|
||||||
|
NS_ConvertUTF16toUTF8(aCompositionEndEvent.mData).get(),
|
||||||
|
mComposition.get()));
|
||||||
|
|
||||||
if (!mComposition) {
|
if (!mComposition) {
|
||||||
NS_WARNING("There is no composition, but receiving compositionend event");
|
NS_WARNING("There is no composition, but receiving compositionend event");
|
||||||
return;
|
return;
|
||||||
@@ -5537,6 +5561,12 @@ nsresult EditorBase::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent) {
|
|||||||
nsresult EditorBase::OnInputText(const nsAString& aStringToInsert) {
|
nsresult EditorBase::OnInputText(const nsAString& aStringToInsert) {
|
||||||
AutoEditActionDataSetter editActionData(*this, EditAction::eInsertText);
|
AutoEditActionDataSetter editActionData(*this, EditAction::eInsertText);
|
||||||
MOZ_ASSERT(!aStringToInsert.IsVoid());
|
MOZ_ASSERT(!aStringToInsert.IsVoid());
|
||||||
|
|
||||||
|
MOZ_LOG(gTextInputLog, LogLevel::Info,
|
||||||
|
("%p %s::OnInputText(aStringToInsert=\"%s\")", this,
|
||||||
|
mIsHTMLEditorClass ? "HTMLEditor" : "TextEditor",
|
||||||
|
NS_ConvertUTF16toUTF8(aStringToInsert).get()));
|
||||||
|
|
||||||
editActionData.SetData(aStringToInsert);
|
editActionData.SetData(aStringToInsert);
|
||||||
// FYI: For conforming to current UI Events spec, we should dispatch
|
// FYI: For conforming to current UI Events spec, we should dispatch
|
||||||
// "beforeinput" event before "keypress" event, but here is in a
|
// "beforeinput" event before "keypress" event, but here is in a
|
||||||
|
|||||||
@@ -1729,6 +1729,22 @@ class EditorBase : public nsIEditor,
|
|||||||
CompositionEnd,
|
CompositionEnd,
|
||||||
CompositionStartAndEnd,
|
CompositionStartAndEnd,
|
||||||
};
|
};
|
||||||
|
friend inline std::ostream& operator<<(std::ostream& aStream,
|
||||||
|
const InsertTextFor& aPurpose) {
|
||||||
|
switch (aPurpose) {
|
||||||
|
case InsertTextFor::NormalText:
|
||||||
|
return aStream << "InsertTextFor::NormalText";
|
||||||
|
case InsertTextFor::CompositionStart:
|
||||||
|
return aStream << "InsertTextFor::CompositionStart";
|
||||||
|
case InsertTextFor::CompositionUpdate:
|
||||||
|
return aStream << "InsertTextFor::CompositionUpdate";
|
||||||
|
case InsertTextFor::CompositionEnd:
|
||||||
|
return aStream << "InsertTextFor::CompositionEnd";
|
||||||
|
case InsertTextFor::CompositionStartAndEnd:
|
||||||
|
return aStream << "InsertTextFor::CompositionStartAndEnd";
|
||||||
|
}
|
||||||
|
return aStream << "<illegal value>";
|
||||||
|
}
|
||||||
[[nodiscard]] static bool InsertingTextForComposition(
|
[[nodiscard]] static bool InsertingTextForComposition(
|
||||||
InsertTextFor aPurpose) {
|
InsertTextFor aPurpose) {
|
||||||
return aPurpose != InsertTextFor::NormalText;
|
return aPurpose != InsertTextFor::NormalText;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "mozilla/EditorForwards.h"
|
#include "mozilla/EditorForwards.h"
|
||||||
#include "mozilla/IntegerRange.h"
|
#include "mozilla/IntegerRange.h"
|
||||||
#include "mozilla/InternalMutationEvent.h"
|
#include "mozilla/InternalMutationEvent.h"
|
||||||
|
#include "mozilla/Logging.h"
|
||||||
#include "mozilla/MathAlgorithms.h"
|
#include "mozilla/MathAlgorithms.h"
|
||||||
#include "mozilla/Maybe.h"
|
#include "mozilla/Maybe.h"
|
||||||
#include "mozilla/OwningNonNull.h"
|
#include "mozilla/OwningNonNull.h"
|
||||||
@@ -73,6 +74,8 @@ class nsISupports;
|
|||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
extern LazyLogModule gTextInputLog; // Defined in EditorBase.cpp
|
||||||
|
|
||||||
using namespace dom;
|
using namespace dom;
|
||||||
using EmptyCheckOption = HTMLEditUtils::EmptyCheckOption;
|
using EmptyCheckOption = HTMLEditUtils::EmptyCheckOption;
|
||||||
using EmptyCheckOptions = HTMLEditUtils::EmptyCheckOptions;
|
using EmptyCheckOptions = HTMLEditUtils::EmptyCheckOptions;
|
||||||
@@ -1077,6 +1080,12 @@ Result<EditActionResult, nsresult> HTMLEditor::HandleInsertText(
|
|||||||
const nsAString& aInsertionString, InsertTextFor aPurpose) {
|
const nsAString& aInsertionString, InsertTextFor aPurpose) {
|
||||||
MOZ_ASSERT(IsTopLevelEditSubActionDataAvailable());
|
MOZ_ASSERT(IsTopLevelEditSubActionDataAvailable());
|
||||||
|
|
||||||
|
MOZ_LOG(
|
||||||
|
gTextInputLog, LogLevel::Info,
|
||||||
|
("%p HTMLEditor::HandleInsertText(aInsertionString=\"%s\", aPurpose=%s)",
|
||||||
|
this, NS_ConvertUTF16toUTF8(aInsertionString).get(),
|
||||||
|
ToString(aPurpose).c_str()));
|
||||||
|
|
||||||
{
|
{
|
||||||
Result<EditActionResult, nsresult> result = CanHandleHTMLEditSubAction();
|
Result<EditActionResult, nsresult> result = CanHandleHTMLEditSubAction();
|
||||||
if (MOZ_UNLIKELY(result.isErr())) {
|
if (MOZ_UNLIKELY(result.isErr())) {
|
||||||
@@ -1147,6 +1156,11 @@ Result<EditActionResult, nsresult> HTMLEditor::HandleInsertText(
|
|||||||
}
|
}
|
||||||
return GetFirstSelectionStartPoint<EditorDOMPoint>();
|
return GetFirstSelectionStartPoint<EditorDOMPoint>();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
MOZ_LOG(gTextInputLog, LogLevel::Info,
|
||||||
|
("%p HTMLEditor::HandleInsertText(), pointToInsert=%s", this,
|
||||||
|
ToString(pointToInsert).c_str()));
|
||||||
|
|
||||||
if (NS_WARN_IF(!pointToInsert.IsSet())) {
|
if (NS_WARN_IF(!pointToInsert.IsSet())) {
|
||||||
return Err(NS_ERROR_FAILURE);
|
return Err(NS_ERROR_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "HTMLEditor.h"
|
#include "HTMLEditor.h"
|
||||||
|
|
||||||
#include "mozilla/Assertions.h"
|
#include "mozilla/Assertions.h"
|
||||||
|
#include "mozilla/Logging.h"
|
||||||
#include "mozilla/LookAndFeel.h"
|
#include "mozilla/LookAndFeel.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "mozilla/StaticPrefs_editor.h"
|
#include "mozilla/StaticPrefs_editor.h"
|
||||||
@@ -44,6 +45,8 @@
|
|||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
extern LazyLogModule gTextInputLog; // Defined in EditorBase.cpp
|
||||||
|
|
||||||
using namespace dom;
|
using namespace dom;
|
||||||
|
|
||||||
#define CANCEL_OPERATION_AND_RETURN_EDIT_ACTION_RESULT_IF_READONLY \
|
#define CANCEL_OPERATION_AND_RETURN_EDIT_ACTION_RESULT_IF_READONLY \
|
||||||
@@ -346,6 +349,12 @@ Result<EditActionResult, nsresult> TextEditor::HandleInsertText(
|
|||||||
const nsAString& aInsertionString, InsertTextFor aPurpose) {
|
const nsAString& aInsertionString, InsertTextFor aPurpose) {
|
||||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||||
|
|
||||||
|
MOZ_LOG(
|
||||||
|
gTextInputLog, LogLevel::Info,
|
||||||
|
("%p TextEditor::HandleInsertText(aInsertionString=\"%s\", aPurpose=%s)",
|
||||||
|
this, NS_ConvertUTF16toUTF8(aInsertionString).get(),
|
||||||
|
ToString(aPurpose).c_str()));
|
||||||
|
|
||||||
UndefineCaretBidiLevel();
|
UndefineCaretBidiLevel();
|
||||||
|
|
||||||
nsAutoString insertionString(aInsertionString);
|
nsAutoString insertionString(aInsertionString);
|
||||||
|
|||||||
Reference in New Issue
Block a user