Bug 1529909 - Cache eIntID_CaretBlinkTime in GTK widget, r=dao
authorMartin Stransky <stransky@redhat.com>
Tue, 30 Apr 2019 08:24:16 +0000
changeset 530741 f5e9c49cc66d70714077c772900a71fad0d837ff
parent 530740 eb532b01e59209fdbd14b37baa2ab65317bd3e0a
child 530742 9b011be3928562d0ae27acd5680dd215bc9ab2f3
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1529909
milestone68.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 1529909 - Cache eIntID_CaretBlinkTime in GTK widget, r=dao Differential Revision: https://phabricator.services.mozilla.com/D29256
widget/gtk/nsLookAndFeel.cpp
widget/gtk/nsLookAndFeel.h
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -507,31 +507,20 @@ nsresult nsLookAndFeel::GetIntImpl(IntID
   res = NS_OK;
 
   // We use delayed initialization by EnsureInit() here
   // to make sure mozilla::Preferences is available (Bug 115807).
   // eIntID_UseAccessibilityTheme is requested before user preferences
   // are read, and so EnsureInit(), which depends on preference values,
   // is deliberately delayed until required.
   switch (aID) {
-    case eIntID_CaretBlinkTime: {
-      GtkSettings* settings;
-      gint blink_time;
-      gboolean blink;
-
-      settings = gtk_settings_get_default();
-      g_object_get(settings, "gtk-cursor-blink-time", &blink_time,
-                   "gtk-cursor-blink", &blink, nullptr);
-
-      if (blink)
-        aResult = (int32_t)blink_time;
-      else
-        aResult = 0;
+    case eIntID_CaretBlinkTime:
+      EnsureInit();
+      aResult = mCaretBlinkTime;
       break;
-    }
     case eIntID_CaretWidth:
       aResult = 1;
       break;
     case eIntID_ShowCaretDuringSelection:
       aResult = 0;
       break;
     case eIntID_SelectTextfieldsOnKeyFocus: {
       GtkWidget* entry;
@@ -1120,16 +1109,22 @@ void nsLookAndFeel::EnsureInit() {
   // invisible character styles
   guint value;
   g_object_get(entry, "invisible-char", &value, nullptr);
   mInvisibleCharacter = char16_t(value);
 
   // caret styles
   gtk_widget_style_get(entry, "cursor-aspect-ratio", &mCaretRatio, nullptr);
 
+  gint blink_time;
+  gboolean blink;
+  g_object_get(settings, "gtk-cursor-blink-time", &blink_time,
+               "gtk-cursor-blink", &blink, nullptr);
+  mCaretBlinkTime = blink ? (int32_t)blink_time : 0;
+
   GetSystemFontInfo(gtk_widget_get_style_context(entry), &mFieldFontName,
                     &mFieldFontStyle);
 
   gtk_widget_destroy(window);
   g_object_unref(labelWidget);
 
   mCSDAvailable =
       nsWindow::GetSystemCSDSupportLevel() != nsWindow::CSD_SUPPORT_NONE;
--- a/widget/gtk/nsLookAndFeel.h
+++ b/widget/gtk/nsLookAndFeel.h
@@ -81,16 +81,17 @@ class nsLookAndFeel final : public nsXPL
   nscolor mMozCellHighlightBackground = kWhite;
   nscolor mMozCellHighlightText = kBlack;
   nscolor mTextSelectedText = kBlack;
   nscolor mTextSelectedBackground = kWhite;
   nscolor mMozScrollbar = kWhite;
   nscolor mInfoBarText = kBlack;
   char16_t mInvisibleCharacter = 0;
   float mCaretRatio = 0.0f;
+  int32_t mCaretBlinkTime = 0;
   bool mMenuSupportsDrag = false;
   bool mCSDAvailable = false;
   bool mCSDHideTitlebarByDefault = false;
   bool mCSDMaximizeButton = false;
   bool mCSDMinimizeButton = false;
   bool mCSDCloseButton = false;
   bool mCSDReversedPlacement = false;
   bool mInitialized = false;