author | Mark Capella <markcapella@twcny.rr.com> |
Thu, 14 May 2015 22:06:13 -0400 | |
changeset 244022 | 952cc0d3db08a103dd41f1399b64b4e43c742c84 |
parent 244021 | 3831026c1c8a7c6dfcaee73110dddd77e5e9eb93 |
child 244023 | 0f3dc51af81675c0cc43a54671a19d497d933bb2 |
push id | 59820 |
push user | cbook@mozilla.com |
push date | Fri, 15 May 2015 15:41:47 +0000 |
treeherder | mozilla-inbound@5943d32f3515 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ehsan |
bugs | 988143 |
milestone | 41.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
|
--- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -41,16 +41,19 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::gfx; // The bidi indicator hangs off the caret to one side, to show which // direction the typing is in. It needs to be at least 2x2 to avoid looking like // an insignificant dot static const int32_t kMinBidiIndicatorPixels = 2; +/*static*/ bool nsCaret::sSelectionCaretEnabled = false; +/*static*/ bool nsCaret::sSelectionCaretsAffectCaret = false; + /** * Find the first frame in an in-order traversal of the frame subtree rooted * at aFrame which is either a text frame logically at the end of a line, * or which is aStopAtFrame. Return null if no such frame is found. We don't * descend into the children of non-eLineParticipant frames. */ static nsIFrame* CheckForTrailingTextFrameRecursive(nsIFrame* aFrame, nsIFrame* aStopAtFrame) @@ -139,16 +142,25 @@ nsresult nsCaret::Init(nsIPresShell *inP mPresShell = do_GetWeakReference(inPresShell); // the presshell owns us, so no addref NS_ASSERTION(mPresShell, "Hey, pres shell should support weak refs"); mShowDuringSelection = LookAndFeel::GetInt(LookAndFeel::eIntID_ShowCaretDuringSelection, mShowDuringSelection ? 1 : 0) != 0; + static bool addedCaretPref = false; + if (!addedCaretPref) { + Preferences::AddBoolVarCache(&sSelectionCaretEnabled, + "selectioncaret.enabled"); + Preferences::AddBoolVarCache(&sSelectionCaretsAffectCaret, + "selectioncaret.visibility.affectscaret"); + addedCaretPref = true; + } + // get the selection from the pres shell, and set ourselves up as a selection // listener nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShell); if (!selCon) return NS_ERROR_FAILURE; nsCOMPtr<nsISelection> domSelection; @@ -248,27 +260,42 @@ void nsCaret::SetVisible(bool inMakeVisi } bool nsCaret::IsVisible() { if (!mVisible) { return false; } - if (!mShowDuringSelection) { + if (!mShowDuringSelection && + !(sSelectionCaretEnabled && sSelectionCaretsAffectCaret)) { Selection* selection = GetSelectionInternal(); if (!selection) { return false; } bool isCollapsed; if (NS_FAILED(selection->GetIsCollapsed(&isCollapsed)) || !isCollapsed) { return false; } } + // The Android IME can have a visible caret when there is a composition + // selection, due to auto-suggest/auto-correct styling (underlining), + // but never when the SelectionCarets are visible. + if (sSelectionCaretEnabled && sSelectionCaretsAffectCaret) { + nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShell); + if (selCon) { + bool visible = false; + selCon->GetSelectionCaretsVisibility(&visible); + if (visible) { + return false; + } + } + } + if (IsMenuPopupHidingCaret()) { return false; } return true; } void nsCaret::SetCaretReadOnly(bool inMakeReadonly)
--- a/layout/base/nsCaret.h +++ b/layout/base/nsCaret.h @@ -225,11 +225,15 @@ protected: * the selection is not collapsed. */ bool mShowDuringSelection; /** * mIgnoreUserModify is true when the caret should be shown even when * it's in non-user-modifiable content. */ bool mIgnoreUserModify; + + // Preference + static bool sSelectionCaretEnabled; + static bool sSelectionCaretsAffectCaret; }; #endif //nsCaret_h__
--- a/mobile/android/app/mobile.js +++ b/mobile/android/app/mobile.js @@ -874,8 +874,11 @@ pref("reader.toolbar.vertical", false); pref("browser.readinglist.enabled", true); // Telemetry settings. // Whether to use the unified telemetry behavior, requires a restart. pref("toolkit.telemetry.unified", false); // Selection carets never fall-back to internal LongTap detector. pref("selectioncaret.detects.longtap", false); + +// Selection carets override caret visibility. +pref("selectioncaret.visibility.affectscaret", true);
--- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4555,16 +4555,19 @@ pref("selectioncaret.enabled", false); // This will inflate size of selection caret frame when we checking if // user click on selection caret or not. In app units. pref("selectioncaret.inflatesize.threshold", 40); // Selection carets will fall-back to internal LongTap detector. pref("selectioncaret.detects.longtap", true); +// Selection carets do not affect caret visibility. +pref("selectioncaret.visibility.affectscaret", false); + // New implementation to unify touch-caret and selection-carets. pref("layout.accessiblecaret.enabled", false); // Timeout in milliseconds to hide the accessiblecaret under cursor mode while // no one touches it. Set the value to 0 to disable this feature. pref("layout.accessiblecaret.timeout_ms", 3000); // Wakelock is disabled by default.