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;
|
||||
|
||||
static LazyLogModule gEventLog("EditorEvent");
|
||||
LazyLogModule gTextInputLog("EditorTextInput");
|
||||
|
||||
/*****************************************************************************
|
||||
* mozilla::EditorBase
|
||||
@@ -4041,6 +4042,13 @@ bool EditorBase::EnsureComposition(WidgetCompositionEvent& aCompositionEvent) {
|
||||
|
||||
nsresult EditorBase::OnCompositionStart(
|
||||
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) {
|
||||
NS_WARNING("There was a composition at receiving compositionstart event");
|
||||
return NS_OK;
|
||||
@@ -4062,6 +4070,15 @@ nsresult EditorBase::OnCompositionChange(
|
||||
MOZ_ASSERT(aCompositionChangeEvent.mMessage == 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) {
|
||||
NS_WARNING(
|
||||
"There is no composition, but receiving compositionchange event");
|
||||
@@ -4208,6 +4225,13 @@ nsresult EditorBase::OnCompositionChange(
|
||||
|
||||
void EditorBase::OnCompositionEnd(
|
||||
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) {
|
||||
NS_WARNING("There is no composition, but receiving compositionend event");
|
||||
return;
|
||||
@@ -5537,6 +5561,12 @@ nsresult EditorBase::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent) {
|
||||
nsresult EditorBase::OnInputText(const nsAString& aStringToInsert) {
|
||||
AutoEditActionDataSetter editActionData(*this, EditAction::eInsertText);
|
||||
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);
|
||||
// FYI: For conforming to current UI Events spec, we should dispatch
|
||||
// "beforeinput" event before "keypress" event, but here is in a
|
||||
|
||||
@@ -1729,6 +1729,22 @@ class EditorBase : public nsIEditor,
|
||||
CompositionEnd,
|
||||
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(
|
||||
InsertTextFor aPurpose) {
|
||||
return aPurpose != InsertTextFor::NormalText;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "mozilla/EditorForwards.h"
|
||||
#include "mozilla/IntegerRange.h"
|
||||
#include "mozilla/InternalMutationEvent.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/OwningNonNull.h"
|
||||
@@ -73,6 +74,8 @@ class nsISupports;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern LazyLogModule gTextInputLog; // Defined in EditorBase.cpp
|
||||
|
||||
using namespace dom;
|
||||
using EmptyCheckOption = HTMLEditUtils::EmptyCheckOption;
|
||||
using EmptyCheckOptions = HTMLEditUtils::EmptyCheckOptions;
|
||||
@@ -1077,6 +1080,12 @@ Result<EditActionResult, nsresult> HTMLEditor::HandleInsertText(
|
||||
const nsAString& aInsertionString, InsertTextFor aPurpose) {
|
||||
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();
|
||||
if (MOZ_UNLIKELY(result.isErr())) {
|
||||
@@ -1147,6 +1156,11 @@ Result<EditActionResult, nsresult> HTMLEditor::HandleInsertText(
|
||||
}
|
||||
return GetFirstSelectionStartPoint<EditorDOMPoint>();
|
||||
}();
|
||||
|
||||
MOZ_LOG(gTextInputLog, LogLevel::Info,
|
||||
("%p HTMLEditor::HandleInsertText(), pointToInsert=%s", this,
|
||||
ToString(pointToInsert).c_str()));
|
||||
|
||||
if (NS_WARN_IF(!pointToInsert.IsSet())) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "HTMLEditor.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs_editor.h"
|
||||
@@ -44,6 +45,8 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern LazyLogModule gTextInputLog; // Defined in EditorBase.cpp
|
||||
|
||||
using namespace dom;
|
||||
|
||||
#define CANCEL_OPERATION_AND_RETURN_EDIT_ACTION_RESULT_IF_READONLY \
|
||||
@@ -346,6 +349,12 @@ Result<EditActionResult, nsresult> TextEditor::HandleInsertText(
|
||||
const nsAString& aInsertionString, InsertTextFor aPurpose) {
|
||||
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();
|
||||
|
||||
nsAutoString insertionString(aInsertionString);
|
||||
|
||||
Reference in New Issue
Block a user