зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1746104 - part 6-1: Make `IMENotification::SelectionChangeDataBase` and `WidgetQueryContentEvent::Reply` have `AnchorOffset` and `FocusOffset` r=m_kato,geckoview-reviewers
`StartOffset` and `EndOffset` of `IMENotification::SelectionChangeDataBase` depend on whether the range is reversed or not. Therefore, their actual meaning is "anchor offset" and "focus offset" in the DOM selection terms. Similarly, `SelectionStartOffset` and `SelectionEndOffset` of `WidgetQueryContentEvent::Reply` are exactly same ones. Therefore, they should be renamed to `AnchorOffset` and `FocusOffset` for making what they return clearer. Differential Revision: https://phabricator.services.mozilla.com/D137427
This commit is contained in:
Родитель
d19b353c60
Коммит
e3a9c1271d
|
@ -489,7 +489,7 @@ uint32_t TextComposition::GetSelectionStartOffset() {
|
||||||
if (NS_WARN_IF(querySelectedTextEvent.DidNotFindSelection())) {
|
if (NS_WARN_IF(querySelectedTextEvent.DidNotFindSelection())) {
|
||||||
return 0; // XXX Is this okay?
|
return 0; // XXX Is this okay?
|
||||||
}
|
}
|
||||||
return querySelectedTextEvent.mReply->SelectionStartOffset();
|
return querySelectedTextEvent.mReply->AnchorOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextComposition::OnCompositionEventDispatched(
|
void TextComposition::OnCompositionEventDispatched(
|
||||||
|
|
|
@ -767,11 +767,11 @@ struct IMENotification final {
|
||||||
void SetWritingMode(const WritingMode& aWritingMode);
|
void SetWritingMode(const WritingMode& aWritingMode);
|
||||||
WritingMode GetWritingMode() const;
|
WritingMode GetWritingMode() const;
|
||||||
|
|
||||||
uint32_t StartOffset() const {
|
uint32_t AnchorOffset() const {
|
||||||
MOZ_ASSERT(mHasRange);
|
MOZ_ASSERT(mHasRange);
|
||||||
return mOffset + (mReversed ? Length() : 0);
|
return mOffset + (mReversed ? Length() : 0);
|
||||||
}
|
}
|
||||||
uint32_t EndOffset() const {
|
uint32_t FocusOffset() const {
|
||||||
MOZ_ASSERT(mHasRange);
|
MOZ_ASSERT(mHasRange);
|
||||||
return mOffset + (mReversed ? 0 : Length());
|
return mOffset + (mReversed ? 0 : Length());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1203,13 +1203,13 @@ class WidgetQueryContentEvent : public WidgetGUIEvent {
|
||||||
mEventMessage == eQuerySelectedText);
|
mEventMessage == eQuerySelectedText);
|
||||||
return mOffsetAndData.isSome() ? mOffsetAndData->Length() : 0;
|
return mOffsetAndData.isSome() ? mOffsetAndData->Length() : 0;
|
||||||
}
|
}
|
||||||
MOZ_NEVER_INLINE_DEBUG uint32_t SelectionStartOffset() const {
|
MOZ_NEVER_INLINE_DEBUG uint32_t AnchorOffset() const {
|
||||||
MOZ_ASSERT(mEventMessage == eQuerySelectedText);
|
MOZ_ASSERT(mEventMessage == eQuerySelectedText);
|
||||||
MOZ_ASSERT(mOffsetAndData.isSome());
|
MOZ_ASSERT(mOffsetAndData.isSome());
|
||||||
return StartOffset() + (mReversed ? DataLength() : 0);
|
return StartOffset() + (mReversed ? DataLength() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_NEVER_INLINE_DEBUG uint32_t SelectionEndOffset() const {
|
MOZ_NEVER_INLINE_DEBUG uint32_t FocusOffset() const {
|
||||||
MOZ_ASSERT(mEventMessage == eQuerySelectedText);
|
MOZ_ASSERT(mEventMessage == eQuerySelectedText);
|
||||||
MOZ_ASSERT(mOffsetAndData.isSome());
|
MOZ_ASSERT(mOffsetAndData.isSome());
|
||||||
return StartOffset() + (mReversed ? 0 : DataLength());
|
return StartOffset() + (mReversed ? 0 : DataLength());
|
||||||
|
|
|
@ -701,10 +701,10 @@ void GeckoEditableSupport::FlushIMEChanges(FlushChangesFlag aFlags) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selStart = static_cast<int32_t>(
|
selStart =
|
||||||
querySelectedTextEvent.mReply->SelectionStartOffset());
|
static_cast<int32_t>(querySelectedTextEvent.mReply->AnchorOffset());
|
||||||
selEnd = static_cast<int32_t>(
|
selEnd =
|
||||||
querySelectedTextEvent.mReply->SelectionEndOffset());
|
static_cast<int32_t>(querySelectedTextEvent.mReply->FocusOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aFlags == FLUSH_FLAG_RECOVER && textTransaction.IsValid()) {
|
if (aFlags == FLUSH_FLAG_RECOVER && textTransaction.IsValid()) {
|
||||||
|
@ -1342,10 +1342,10 @@ nsresult GeckoEditableSupport::NotifyIME(
|
||||||
ToString(aNotification.mSelectionChangeData).c_str());
|
ToString(aNotification.mSelectionChangeData).c_str());
|
||||||
|
|
||||||
if (aNotification.mSelectionChangeData.HasRange()) {
|
if (aNotification.mSelectionChangeData.HasRange()) {
|
||||||
mCachedSelection.mStartOffset =
|
mCachedSelection.mStartOffset = static_cast<int32_t>(
|
||||||
aNotification.mSelectionChangeData.StartOffset();
|
aNotification.mSelectionChangeData.AnchorOffset());
|
||||||
mCachedSelection.mEndOffset =
|
mCachedSelection.mEndOffset = static_cast<int32_t>(
|
||||||
aNotification.mSelectionChangeData.EndOffset();
|
aNotification.mSelectionChangeData.FocusOffset());
|
||||||
} else {
|
} else {
|
||||||
mCachedSelection.Reset();
|
mCachedSelection.Reset();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче