diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 2197944975ca..cfeee19de9ed 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -92,12 +92,7 @@ PuppetWidget::PuppetWidget(TabChild* aTabChild) , 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; diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index e456a1d20f20..c615860076b6 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -392,11 +392,6 @@ private: int32_t mRounding; double mDefaultScale; - // Precomputed answers for ExecuteNativeKeyBinding - InfallibleTArray mSingleLineCommands; - InfallibleTArray mMultiLineCommands; - InfallibleTArray mRichTextCommands; - nsCOMPtr mCustomCursor; uint32_t mCursorHotspotX, mCursorHotspotY; @@ -410,52 +405,6 @@ protected: 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& aSingleLineCommands, - const InfallibleTArray& aMultiLineCommands, - const InfallibleTArray& 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 mSavedSingleLine; - InfallibleTArray mSavedMultiLine; - InfallibleTArray mSavedRichText; }; class PuppetScreen : public nsBaseScreen diff --git a/widget/android/GeckoEditableSupport.cpp b/widget/android/GeckoEditableSupport.cpp index 075e53fc2bdb..2b67d35f0837 100644 --- a/widget/android/GeckoEditableSupport.cpp +++ b/widget/android/GeckoEditableSupport.cpp @@ -463,10 +463,8 @@ GeckoEditableSupport::OnKeyEvent(int32_t aAction, int32_t aKeyCode, mIMEKeyEvents.AppendElement( UniquePtr(pressEvent.Duplicate())); } else if (nsIWidget::UsePuppetWidgets()) { - AutoCacheNativeKeyCommands autoCache( - static_cast(widget.get())); // Don't use native key bindings. - autoCache.CacheNoCommands(); + pressEvent.PreventNativeKeyBindings(); dispatcher->MaybeDispatchKeypressEvents(pressEvent, status); } else { dispatcher->MaybeDispatchKeypressEvents(pressEvent, status); @@ -801,10 +799,8 @@ GeckoEditableSupport::OnImeReplaceText(int32_t aStart, int32_t aEnd, mDispatcher->DispatchKeyboardEvent( event->mMessage, *event, status); } else if (nsIWidget::UsePuppetWidgets()) { - AutoCacheNativeKeyCommands autoCache( - static_cast(widget.get())); // Don't use native key bindings. - autoCache.CacheNoCommands(); + event->PreventNativeKeyBindings(); mDispatcher->MaybeDispatchKeypressEvents(*event, status); } else { mDispatcher->MaybeDispatchKeypressEvents(*event, status);