Bug 1449564 - part 4: Make users can show Gecko specific editing UIs with new prefs r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 16 Aug 2018 13:51:36 +0900
changeset 487407 541fbb29f21d262d88d0ae08776606db0b62d8f6
parent 487406 e93a23a4741c7760d76e33c3515e9b6ee2f5e26d
child 487408 a592b4286d6fa94ecf434e2c5d0f9bac74e3bda9
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1449564
milestone63.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 1449564 - part 4: Make users can show Gecko specific editing UIs with new prefs r=m_kato Even after we disable Gecko specific editing UIs by default, web apps can enable them with execCommand. However, until such web apps change their behavior, users cannot use Gecko specific UIs. At least for now, we should make users can enable them by default. MozReview-Commit-ID: AuAdw4FQ4He
editor/libeditor/HTMLEditor.cpp
modules/libpref/init/all.js
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -95,44 +95,93 @@ IsLinkTag(const nsAtom& aTagName)
 }
 
 static bool
 IsNamedAnchorTag(const nsAtom& aTagName)
 {
   return &aTagName == nsGkAtoms::anchor;
 }
 
+class HTMLEditorPrefs final
+{
+public:
+  static bool IsResizingUIEnabledByDefault()
+  {
+    EnsurePrefValues();
+    return sUserWantsToEnableResizingUIByDefault;
+  }
+  static bool IsInlineTableEditingUIEnabledByDefault()
+  {
+    EnsurePrefValues();
+    return sUserWantsToEnableInlineTableEditingUIByDefault;
+  }
+  static bool IsAbsolutePositioningUIEnabledByDefault()
+  {
+    EnsurePrefValues();
+    return sUserWantsToEnableAbsolutePositioningUIByDefault;
+  }
+
+private:
+  static bool sUserWantsToEnableResizingUIByDefault;
+  static bool sUserWantsToEnableInlineTableEditingUIByDefault;
+  static bool sUserWantsToEnableAbsolutePositioningUIByDefault;
+
+  static void EnsurePrefValues()
+  {
+    static bool sInitialized = false;
+    if (sInitialized) {
+      return;
+    }
+    Preferences::AddBoolVarCache(
+                   &sUserWantsToEnableResizingUIByDefault,
+                   "editor.resizing.enabled_by_default");
+    Preferences::AddBoolVarCache(
+                   &sUserWantsToEnableInlineTableEditingUIByDefault,
+                   "editor.inline_table_editing.enabled_by_default");
+    Preferences::AddBoolVarCache(
+                   &sUserWantsToEnableAbsolutePositioningUIByDefault,
+                   "editor.positioning.enabled_by_default");
+    sInitialized = true;
+  }
+};
+
+bool HTMLEditorPrefs::sUserWantsToEnableResizingUIByDefault = false;
+bool HTMLEditorPrefs::sUserWantsToEnableInlineTableEditingUIByDefault = false;
+bool HTMLEditorPrefs::sUserWantsToEnableAbsolutePositioningUIByDefault = false;
+
 template EditorDOMPoint
 HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
               nsIContent& aNode,
               const EditorDOMPoint& aPointToInsert,
               SplitAtEdges aSplitAtEdges);
 template EditorDOMPoint
 HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
               nsIContent& aNode,
               const EditorRawDOMPoint& aPointToInsert,
               SplitAtEdges aSplitAtEdges);
 
 HTMLEditor::HTMLEditor()
   : mCRInParagraphCreatesParagraph(false)
   , mCSSAware(false)
   , mSelectedCellIndex(0)
   , mHasShownResizers(false)
-  , mIsObjectResizingEnabled(false)
+  , mIsObjectResizingEnabled(HTMLEditorPrefs::IsResizingUIEnabledByDefault())
   , mIsResizing(false)
   , mPreserveRatio(false)
   , mResizedObjectIsAnImage(false)
-  , mIsAbsolutelyPositioningEnabled(false)
+  , mIsAbsolutelyPositioningEnabled(
+      HTMLEditorPrefs::IsAbsolutePositioningUIEnabledByDefault())
   , mResizedObjectIsAbsolutelyPositioned(false)
   , mHasShownGrabber(false)
   , mGrabberClicked(false)
   , mIsMoving(false)
   , mSnapToGridEnabled(false)
   , mHasShownInlineTableEditor(false)
-  , mIsInlineTableEditingEnabled(false)
+  , mIsInlineTableEditingEnabled(
+      HTMLEditorPrefs::IsInlineTableEditingUIEnabledByDefault())
   , mOriginalX(0)
   , mOriginalY(0)
   , mResizedObjectX(0)
   , mResizedObjectY(0)
   , mResizedObjectWidth(0)
   , mResizedObjectHeight(0)
   , mResizedObjectMarginLeft(0)
   , mResizedObjectMarginTop(0)
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1190,26 +1190,43 @@ pref("print.print_via_parent", false);
 // paths instead of using font embedding.
 pref("print.font-variations-as-paths", true);
 
 // Pref used by the spellchecker extension to control the
 // maximum number of misspelled words that will be underlined
 // in a document.
 pref("extensions.spellcheck.inline.max-misspellings", 500);
 
-// Prefs used by libeditor. Prefs specific to seamonkey composer
-// belong in comm-central/editor/ui/composer.js
-
+// General prefs for editor.
+// Whether Gecko specific editing UI is enabled by default.
+// Those UIs are not impelemnted by any other browsers.  So, only Firefox users
+// can change some styles with them.  This means that only Firefox users may
+// get unexpected result of some web apps if they assume that users cannot
+// change such styles.
+#ifdef EARLY_BETA_OR_EARLIER
+pref("editor.resizing.enabled_by_default", false);
+pref("editor.inline_table_editing.enabled_by_default", false);
+pref("editor.positioning.enabled_by_default", false);
+#else
+pref("editor.resizing.enabled_by_default", true);
+pref("editor.inline_table_editing.enabled_by_default", true);
+pref("editor.positioning.enabled_by_default", true);
+#endif
+// Whether inserting <div> when typing Enter in a block element which can
+// contain <div>.  If false, inserts <br> instead.
+pref("editor.use_div_for_default_newlines",  true);
+
+// Prefs specific to seamonkey composer belong in
+// comm-central/editor/ui/composer.js
 pref("editor.use_custom_colors", false);
 pref("editor.singleLine.pasteNewlines",      2);
 pref("editor.use_css",                       false);
 pref("editor.css.default_length_unit",       "px");
 pref("editor.resizing.preserve_ratio",       true);
 pref("editor.positioning.offset",            0);
-pref("editor.use_div_for_default_newlines",  true);
 
 // Scripts & Windows prefs
 pref("dom.disable_beforeunload",            false);
 pref("dom.disable_window_flip",             false);
 pref("dom.disable_window_move_resize",      false);
 
 pref("dom.disable_window_open_feature.titlebar",    false);
 pref("dom.disable_window_open_feature.close",       false);