Bug 1159263 - Add support to nsCaret to stop blinking after a set of cycles r=roc r=snorp

This commit is contained in:
Mark Finkle 2015-04-29 10:23:19 -04:00
parent 4cc5102174
commit ea1ba80c9b
3 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -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'.
*/

View File

@ -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