Bug 1339543 part 5 Remove unnecessary stuff from PuppetWidget r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 17 May 2017 20:46:47 +0900
changeset 359319 8d32e150bf7fe9b0db1c37174c70b352ce34812e
parent 359318 b75c111837a802ceb953dba50a3c5a193d53ca22
child 359320 bf71ece03a290119c947cb3f93d311c34a6d4a78
push id90494
push userkwierso@gmail.com
push dateFri, 19 May 2017 22:19:13 +0000
treeherdermozilla-inbound@cd9b1ab819e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1339543
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1339543 part 5 Remove unnecessary stuff from PuppetWidget r=smaug MozReview-Commit-ID: 17dbDG1Fqwb
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/android/GeckoEditableSupport.cpp
--- 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;
                 }
             }