Bug 988143 - Enable Gecko Touch in Fennec, Android specific nsCaret mods, r=ehsan

This commit is contained in:
Mark Capella 2015-05-14 22:06:13 -04:00
parent b470913851
commit 27ef7c7715
4 changed files with 38 additions and 1 deletions

View File

@ -46,6 +46,9 @@ using namespace mozilla::gfx;
// 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,
@ -144,6 +147,15 @@ nsresult nsCaret::Init(nsIPresShell *inPresShell)
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
@ -253,7 +265,8 @@ bool nsCaret::IsVisible()
return false;
}
if (!mShowDuringSelection) {
if (!mShowDuringSelection &&
!(sSelectionCaretEnabled && sSelectionCaretsAffectCaret)) {
Selection* selection = GetSelectionInternal();
if (!selection) {
return false;
@ -264,6 +277,20 @@ bool nsCaret::IsVisible()
}
}
// 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;
}

View File

@ -230,6 +230,10 @@ protected:
* it's in non-user-modifiable content.
*/
bool mIgnoreUserModify;
// Preference
static bool sSelectionCaretEnabled;
static bool sSelectionCaretsAffectCaret;
};
#endif //nsCaret_h__

View File

@ -879,3 +879,6 @@ 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);

View File

@ -4560,6 +4560,9 @@ 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);