Bug 1683226 - part 9: Get rid of nsIWidget::PluginHasFocus() r=m_kato

It's used only by IMM and keyboard handlers on Windows.

Differential Revision: https://phabricator.services.mozilla.com/D100121
This commit is contained in:
Masayuki Nakano 2020-12-21 06:30:07 +00:00
parent c1e0f526a1
commit ff0e3ef67e
6 changed files with 4 additions and 112 deletions

View File

@ -1861,13 +1861,6 @@ class nsIWidget : public nsISupports {
*/
virtual void SetPluginFocused(bool& aFocused) = 0;
/*
* Tell the plugin has focus. It is unnecessary to use IPC
*/
bool PluginHasFocus() {
return GetInputContext().mIMEState.mEnabled == IMEEnabled::Plugin;
}
/*
* Enable or Disable IME by windowless plugin.
*/

View File

@ -487,10 +487,6 @@ void IMMHandler::OnUpdateComposition(nsWindow* aWindow) {
return;
}
if (aWindow->PluginHasFocus()) {
return;
}
IMEContext context(aWindow);
gIMMHandler->SetIMERelatedWindowsPos(aWindow, context);
}
@ -2168,8 +2164,7 @@ void IMMHandler::AdjustCompositionFont(nsWindow* aWindow,
logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logFont.lfPitchAndFamily = DEFAULT_PITCH;
if (!aWindow->PluginHasFocus() && aWritingMode.IsVertical() &&
IsVerticalWritingSupported()) {
if (aWritingMode.IsVertical() && IsVerticalWritingSupported()) {
SetVerticalFontToLogFont(IsJapanist2003Active()
? sCompositionFontForJapanist2003
: sCompositionFont,

View File

@ -2532,7 +2532,7 @@ bool NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const {
// message is processed by us, so, nobody shouldn't process it.
HWND focusedWnd = ::GetFocus();
if (!defaultPrevented && !mFakeCharMsgs && !IsKeyMessageOnPlugin() &&
focusedWnd && !mWidget->PluginHasFocus() && !isIMEEnabled &&
focusedWnd && !isIMEEnabled &&
WinUtils::IsIMEEnabled(mWidget->GetInputContext())) {
RedirectedKeyDownMessageManager::RemoveNextCharMessage(focusedWnd);
@ -2598,7 +2598,6 @@ bool NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const {
("%p NativeKey::HandleKeyDownMessage(), not dispatching keypress "
"event because preceding keydown event was consumed",
this));
MaybeDispatchPluginEventsForRemovedCharMessages();
return true;
}
@ -2623,8 +2622,7 @@ bool NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const {
("%p NativeKey::HandleKeyDownMessage(), tries to be dispatching "
"keypress events...",
this));
return (MaybeDispatchPluginEventsForRemovedCharMessages() ||
DispatchKeyPressEventsWithoutCharMessage());
return DispatchKeyPressEventsWithoutCharMessage();
}
// If WM_KEYDOWN of VK_PACKET isn't followed by WM_CHAR, we don't need to
@ -3403,71 +3401,6 @@ bool NativeKey::GetFollowingCharMessage(MSG& aCharMsg) {
return false;
}
bool NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages() const {
MOZ_ASSERT(IsKeyDownMessage());
MOZ_ASSERT(!IsKeyMessageOnPlugin());
for (size_t i = 0;
i < mFollowingCharMsgs.Length() && mWidget->ShouldDispatchPluginEvent();
++i) {
MOZ_LOG(
sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"dispatching %uth plugin event for %s...",
this, i + 1, ToString(mFollowingCharMsgs[i]).get()));
MOZ_RELEASE_ASSERT(
!mWidget->Destroyed(),
"NativeKey tries to dispatch a plugin event on destroyed widget");
mWidget->DispatchPluginEvent(mFollowingCharMsgs[i]);
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
MOZ_LOG(
sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"%uth plugin event caused %s",
this, i + 1,
mWidget->Destroyed() ? "destroying the widget" : "focus change"));
return true;
}
MOZ_LOG(
sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"dispatched %uth plugin event",
this, i + 1));
}
// Dispatch odd char messages which are caused by ATOK or WXG (both of them
// are Japanese IME) and removed by RemoveFollowingOddCharMessages().
for (size_t i = 0;
i < mRemovedOddCharMsgs.Length() && mWidget->ShouldDispatchPluginEvent();
++i) {
MOZ_LOG(
sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"dispatching %uth plugin event for odd char message, %s...",
this, i + 1, ToString(mFollowingCharMsgs[i]).get()));
MOZ_RELEASE_ASSERT(
!mWidget->Destroyed(),
"NativeKey tries to dispatch a plugin event on destroyed widget");
mWidget->DispatchPluginEvent(mRemovedOddCharMsgs[i]);
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
MOZ_LOG(
sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"%uth plugin event for odd char message caused %s",
this, i + 1,
mWidget->Destroyed() ? "destroying the widget" : "focus change"));
return true;
}
MOZ_LOG(
sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"dispatched %uth plugin event for odd char message",
this, i + 1));
}
return false;
}
void NativeKey::ComputeInputtingStringWithKeyboardLayout() {
KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance();

View File

@ -753,14 +753,6 @@ class MOZ_STACK_CLASS NativeKey final {
*/
bool DispatchKeyPressEventsWithoutCharMessage() const;
/**
* MaybeDispatchPluginEventsForRemovedCharMessages() dispatches plugin events
* for removed char messages when a windowless plugin has focus.
* Returns true if the widget is destroyed or blurred during dispatching a
* plugin event.
*/
bool MaybeDispatchPluginEventsForRemovedCharMessages() const;
/**
* Checkes whether the key event down message is handled without following
* WM_CHAR messages. For example, if following WM_CHAR message indicates

View File

@ -19,23 +19,7 @@ static const wchar_t kUser32LibName[] = L"user32.dll";
bool nsWindowBase::sTouchInjectInitialized = false;
InjectTouchInputPtr nsWindowBase::sInjectTouchFuncPtr;
bool nsWindowBase::DispatchPluginEvent(const MSG& aMsg) {
if (!ShouldDispatchPluginEvent()) {
return false;
}
WidgetPluginEvent pluginEvent(true, ePluginInputEvent, this);
LayoutDeviceIntPoint point(0, 0);
InitEvent(pluginEvent, &point);
NPEvent npEvent;
npEvent.event = aMsg.message;
npEvent.wParam = aMsg.wParam;
npEvent.lParam = aMsg.lParam;
pluginEvent.mPluginEvent.Copy(npEvent);
pluginEvent.mRetargetToFocusedDocument = true;
return DispatchWindowEvent(&pluginEvent);
}
bool nsWindowBase::ShouldDispatchPluginEvent() { return PluginHasFocus(); }
bool nsWindowBase::DispatchPluginEvent(const MSG& aMsg) { return false; }
// static
bool nsWindowBase::InitTouchInjection() {

View File

@ -85,11 +85,6 @@ class nsWindowBase : public nsBaseWidget {
*/
virtual bool DispatchPluginEvent(const MSG& aMsg);
/*
* Returns true if this should dispatch a plugin event.
*/
bool ShouldDispatchPluginEvent();
/*
* Touch input injection apis
*/