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
--- 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
@@ -1188,26 +1188,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);