Bug 1714884 - Replace custom IME Rect struct with LayoutDeviceIntRect. r=masayuki

Depends on D116946

Differential Revision: https://phabricator.services.mozilla.com/D116947
This commit is contained in:
Kartikaya Gupta 2021-06-07 01:01:09 +00:00
parent 0597e15653
commit ce72d968ba
5 changed files with 10 additions and 46 deletions

View File

@ -719,8 +719,8 @@ bool IMEContentObserver::OnMouseButtonEvent(nsPresContext* aPresContext,
queryCharAtPointEvent.mReply->StartOffset();
notification.mMouseButtonEventData.mCursorPos =
queryCharAtPointEvent.mRefPoint;
notification.mMouseButtonEventData.mCharRect.Set(
queryCharAtPointEvent.mReply->mRect.ToUnknownRect());
notification.mMouseButtonEventData.mCharRect =
queryCharAtPointEvent.mReply->mRect;
notification.mMouseButtonEventData.mButton = aMouseEvent->mButton;
notification.mMouseButtonEventData.mButtons = aMouseEvent->mButtons;
notification.mMouseButtonEventData.mModifiers = aMouseEvent->mModifiers;

View File

@ -638,7 +638,7 @@ struct IMENotification final {
mMouseButtonEventData.mEventMessage = eVoidEvent;
mMouseButtonEventData.mOffset = UINT32_MAX;
mMouseButtonEventData.mCursorPos.MoveTo(0, 0);
mMouseButtonEventData.mCharRect.Set(nsIntRect(0, 0, 0, 0));
mMouseButtonEventData.mCharRect.SetRect(0, 0, 0, 0);
mMouseButtonEventData.mButton = -1;
mMouseButtonEventData.mButtons = 0;
mMouseButtonEventData.mModifiers = 0;
@ -714,18 +714,6 @@ struct IMENotification final {
IMEMessage mMessage;
struct Rect {
int32_t mX;
int32_t mY;
int32_t mWidth;
int32_t mHeight;
void Set(const nsIntRect& aRect) {
aRect.GetRect(&mX, &mY, &mWidth, &mHeight);
}
nsIntRect AsIntRect() const { return nsIntRect(mX, mY, mWidth, mHeight); }
};
// NOTIFY_IME_OF_SELECTION_CHANGE specific data
struct SelectionChangeDataBase {
// Selection range.
@ -914,7 +902,7 @@ struct IMENotification final {
// Cursor position in pixels relative to the widget
LayoutDeviceIntPoint mCursorPos;
// Character rect in pixels under the cursor relative to the widget
Rect mCharRect;
LayoutDeviceIntRect mCharRect;
// The value of WidgetMouseEventBase::button and buttons
int16_t mButton;
int16_t mButtons;

View File

@ -694,26 +694,6 @@ struct ParamTraits<mozilla::widget::NativeIMEContext> {
}
};
template <>
struct ParamTraits<mozilla::widget::IMENotification::Rect> {
typedef mozilla::widget::IMENotification::Rect paramType;
static void Write(Message* aMsg, const paramType& aParam) {
WriteParam(aMsg, aParam.mX);
WriteParam(aMsg, aParam.mY);
WriteParam(aMsg, aParam.mWidth);
WriteParam(aMsg, aParam.mHeight);
}
static bool Read(const Message* aMsg, PickleIterator* aIter,
paramType* aResult) {
return ReadParam(aMsg, aIter, &aResult->mX) &&
ReadParam(aMsg, aIter, &aResult->mY) &&
ReadParam(aMsg, aIter, &aResult->mWidth) &&
ReadParam(aMsg, aIter, &aResult->mHeight);
}
};
template <>
struct ParamTraits<mozilla::widget::IMENotification::SelectionChangeDataBase> {
typedef mozilla::widget::IMENotification::SelectionChangeDataBase paramType;

View File

@ -2230,8 +2230,8 @@ nsresult IMMHandler::OnMouseButtonEvent(
// positioning: 2301 2301 2301
LayoutDeviceIntPoint cursorPos =
aIMENotification.mMouseButtonEventData.mCursorPos;
nsIntRect charRect =
aIMENotification.mMouseButtonEventData.mCharRect.AsIntRect();
LayoutDeviceIntRect charRect =
aIMENotification.mMouseButtonEventData.mCharRect;
int32_t cursorXInChar = cursorPos.x - charRect.X();
// The event might hit to zero-width character, see bug 694913.
// The reason might be:

View File

@ -6305,15 +6305,11 @@ nsresult TSFTextStore::OnMouseButtonEventInternal(
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("0x%p TSFTextStore::OnMouseButtonEventInternal("
"aIMENotification={ mEventMessage=%s, mOffset=%u, mCursorPos=%s, "
"mCharRect={ mX=%d, mY=%d, mWidth=%d, mHeight=%d }, "
"mButton=%s, mButtons=%s, mModifiers=%s })",
"mCharRect=%s, mButton=%s, mButtons=%s, mModifiers=%s })",
this, ToChar(aIMENotification.mMouseButtonEventData.mEventMessage),
aIMENotification.mMouseButtonEventData.mOffset,
ToString(aIMENotification.mMouseButtonEventData.mCursorPos).c_str(),
aIMENotification.mMouseButtonEventData.mCharRect.mX,
aIMENotification.mMouseButtonEventData.mCharRect.mY,
aIMENotification.mMouseButtonEventData.mCharRect.mWidth,
aIMENotification.mMouseButtonEventData.mCharRect.mHeight,
ToString(aIMENotification.mMouseButtonEventData.mCharRect).c_str(),
GetMouseButtonName(aIMENotification.mMouseButtonEventData.mButton),
GetMouseButtonsName(aIMENotification.mMouseButtonEventData.mButtons)
.get(),
@ -6324,8 +6320,8 @@ nsresult TSFTextStore::OnMouseButtonEventInternal(
if (offset > static_cast<uint32_t>(LONG_MAX)) {
return NS_OK;
}
nsIntRect charRect =
aIMENotification.mMouseButtonEventData.mCharRect.AsIntRect();
LayoutDeviceIntRect charRect =
aIMENotification.mMouseButtonEventData.mCharRect;
LayoutDeviceIntPoint cursorPos =
aIMENotification.mMouseButtonEventData.mCursorPos;
ULONG quadrant = 1;