mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
Bug 1159263 - Add support to nsCaret to stop blinking after a set of cycles r=roc r=snorp
This commit is contained in:
parent
4cc5102174
commit
ea1ba80c9b
@ -120,6 +120,7 @@ IsBidiUI()
|
||||
nsCaret::nsCaret()
|
||||
: mOverrideOffset(0)
|
||||
, mIsBlinkOn(false)
|
||||
, mBlinkCount(-1)
|
||||
, mVisible(false)
|
||||
, mReadOnly(false)
|
||||
, mShowDuringSelection(false)
|
||||
@ -594,6 +595,7 @@ void nsCaret::ResetBlinking()
|
||||
uint32_t blinkRate = static_cast<uint32_t>(
|
||||
LookAndFeel::GetInt(LookAndFeel::eIntID_CaretBlinkTime, 500));
|
||||
if (blinkRate > 0) {
|
||||
mBlinkCount = Preferences::GetInt("ui.caretBlinkCount", -1);
|
||||
mBlinkTimer->InitWithFuncCallback(CaretBlinkCallback, this, blinkRate,
|
||||
nsITimer::TYPE_REPEATING_SLACK);
|
||||
}
|
||||
@ -913,6 +915,19 @@ void nsCaret::CaretBlinkCallback(nsITimer* aTimer, void* aClosure)
|
||||
}
|
||||
theCaret->mIsBlinkOn = !theCaret->mIsBlinkOn;
|
||||
theCaret->SchedulePaint();
|
||||
|
||||
// mBlinkCount of -1 means blink count is not enabled.
|
||||
if (theCaret->mBlinkCount == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Track the blink count, but only at end of a blink cycle.
|
||||
if (!theCaret->mIsBlinkOn) {
|
||||
// If we exceeded the blink count, stop the timer.
|
||||
if (--theCaret->mBlinkCount <= 0) {
|
||||
theCaret->StopBlinking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -205,6 +205,12 @@ protected:
|
||||
* mIsBlinkOn is true when we're in a blink cycle where the caret is on.
|
||||
*/
|
||||
bool mIsBlinkOn;
|
||||
/**
|
||||
* mBlinkCount is used to control the number of times to blink the caret
|
||||
* before stopping the blink. This is reset each time we reset the
|
||||
* blinking.
|
||||
*/
|
||||
int32_t mBlinkCount;
|
||||
/**
|
||||
* mIsVisible is true when SetVisible was last called with 'true'.
|
||||
*/
|
||||
|
@ -47,6 +47,9 @@ pref("browser.viewport.defaultZoom", -1);
|
||||
/* allow scrollbars to float above chrome ui */
|
||||
pref("ui.scrollbarsCanOverlapContent", 1);
|
||||
|
||||
/* turn off the caret blink after 10 cycles */
|
||||
pref("ui.caretBlinkCount", 10);
|
||||
|
||||
/* cache prefs */
|
||||
pref("browser.cache.disk.enable", true);
|
||||
pref("browser.cache.disk.capacity", 20480); // kilobytes
|
||||
|
Loading…
x
Reference in New Issue
Block a user