Bug 1339543 part 5 Remove unnecessary stuff from PuppetWidget r?smaug
MozReview-Commit-ID: 17dbDG1Fqwb
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -87,22 +87,17 @@ NS_IMPL_ISUPPORTS_INHERITED(PuppetWidget
PuppetWidget::PuppetWidget(TabChild* aTabChild)
: mTabChild(aTabChild)
, mMemoryPressureObserver(nullptr)
, mDPI(-1)
, mRounding(-1)
, mDefaultScale(-1)
, mCursorHotspotX(0)
, mCursorHotspotY(0)
- , mNativeKeyCommandsValid(false)
{
- mSingleLineCommands.SetCapacity(4);
- mMultiLineCommands.SetCapacity(4);
- mRichTextCommands.SetCapacity(4);
-
// Setting 'Unknown' means "not yet cached".
mInputContext.mIMEState.mEnabled = IMEState::UNKNOWN;
if (!gRemoteDesktopBehaviorInitialized) {
Preferences::AddBoolVarCache(&gRemoteDesktopBehaviorEnabled, "browser.tabs.remote.desktopbehavior", false);
gRemoteDesktopBehaviorInitialized = true;
}
}
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -387,80 +387,29 @@ private:
NativeIMEContext mNativeIMEContext;
ContentCacheInChild mContentCache;
// The DPI of the screen corresponding to this widget
float mDPI;
int32_t mRounding;
double mDefaultScale;
- // Precomputed answers for ExecuteNativeKeyBinding
- InfallibleTArray<mozilla::CommandInt> mSingleLineCommands;
- InfallibleTArray<mozilla::CommandInt> mMultiLineCommands;
- InfallibleTArray<mozilla::CommandInt> mRichTextCommands;
-
nsCOMPtr<imgIContainer> mCustomCursor;
uint32_t mCursorHotspotX, mCursorHotspotY;
nsCOMArray<nsIKeyEventInPluginCallback> mKeyEventInPluginCallbacks;
RefPtr<TextEventDispatcherListener> mNativeTextEventDispatcherListener;
protected:
bool mEnabled;
bool mVisible;
private:
bool mNeedIMEStateInit;
- bool mNativeKeyCommandsValid;
-};
-
-struct AutoCacheNativeKeyCommands
-{
- explicit AutoCacheNativeKeyCommands(PuppetWidget* aWidget)
- : mWidget(aWidget)
- {
- mSavedValid = mWidget->mNativeKeyCommandsValid;
- mSavedSingleLine = mWidget->mSingleLineCommands;
- mSavedMultiLine = mWidget->mMultiLineCommands;
- mSavedRichText = mWidget->mRichTextCommands;
- }
-
- void Cache(const InfallibleTArray<mozilla::CommandInt>& aSingleLineCommands,
- const InfallibleTArray<mozilla::CommandInt>& aMultiLineCommands,
- const InfallibleTArray<mozilla::CommandInt>& aRichTextCommands)
- {
- mWidget->mNativeKeyCommandsValid = true;
- mWidget->mSingleLineCommands = aSingleLineCommands;
- mWidget->mMultiLineCommands = aMultiLineCommands;
- mWidget->mRichTextCommands = aRichTextCommands;
- }
-
- void CacheNoCommands()
- {
- mWidget->mNativeKeyCommandsValid = true;
- mWidget->mSingleLineCommands.Clear();
- mWidget->mMultiLineCommands.Clear();
- mWidget->mRichTextCommands.Clear();
- }
-
- ~AutoCacheNativeKeyCommands()
- {
- mWidget->mNativeKeyCommandsValid = mSavedValid;
- mWidget->mSingleLineCommands = mSavedSingleLine;
- mWidget->mMultiLineCommands = mSavedMultiLine;
- mWidget->mRichTextCommands = mSavedRichText;
- }
-
-private:
- PuppetWidget* mWidget;
- bool mSavedValid;
- InfallibleTArray<mozilla::CommandInt> mSavedSingleLine;
- InfallibleTArray<mozilla::CommandInt> mSavedMultiLine;
- InfallibleTArray<mozilla::CommandInt> mSavedRichText;
};
class PuppetScreen : public nsBaseScreen
{
public:
explicit PuppetScreen(void* nativeScreen);
~PuppetScreen();
--- a/widget/android/GeckoEditableSupport.cpp
+++ b/widget/android/GeckoEditableSupport.cpp
@@ -458,20 +458,18 @@ GeckoEditableSupport::OnKeyEvent(int32_t
WidgetKeyboardEvent pressEvent(true, eKeyPress, widget);
InitKeyEvent(pressEvent, aAction, aKeyCode, aScanCode, aKeyPressMetaState,
aTime, aDomPrintableKeyValue, aRepeatCount, aFlags);
if (aIsSynthesizedImeKey) {
mIMEKeyEvents.AppendElement(
UniquePtr<WidgetEvent>(pressEvent.Duplicate()));
} else if (nsIWidget::UsePuppetWidgets()) {
- AutoCacheNativeKeyCommands autoCache(
- static_cast<PuppetWidget*>(widget.get()));
// Don't use native key bindings.
- autoCache.CacheNoCommands();
+ pressEvent.PreventNativeKeyBindings();
dispatcher->MaybeDispatchKeypressEvents(pressEvent, status);
} else {
dispatcher->MaybeDispatchKeypressEvents(pressEvent, status);
}
}
/*
* Send dummy key events for pages that are unaware of input events,
@@ -796,20 +794,18 @@ GeckoEditableSupport::OnImeReplaceText(i
const auto event = mIMEKeyEvents[i]->AsKeyboardEvent();
// widget for duplicated events is initially nullptr.
event->mWidget = widget;
if (event->mMessage != eKeyPress) {
mDispatcher->DispatchKeyboardEvent(
event->mMessage, *event, status);
} else if (nsIWidget::UsePuppetWidgets()) {
- AutoCacheNativeKeyCommands autoCache(
- static_cast<PuppetWidget*>(widget.get()));
// Don't use native key bindings.
- autoCache.CacheNoCommands();
+ event->PreventNativeKeyBindings();
mDispatcher->MaybeDispatchKeypressEvents(*event, status);
} else {
mDispatcher->MaybeDispatchKeypressEvents(*event, status);
}
if (!mDispatcher || widget->Destroyed()) {
break;
}
}