зеркало из https://github.com/mozilla/gecko-dev.git
Bug 193316. Caret not visible in readonly fields (HTML or XUL). r=mrbkap, sr=smfr
This commit is contained in:
Родитель
06fd81dff0
Коммит
fd97041e21
|
@ -1043,10 +1043,9 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
|
|||
editor->GetSelectionController(getter_AddRefs(selCon));
|
||||
if (selCon)
|
||||
{
|
||||
if (! (flags & nsIPlaintextEditor::eEditorReadonlyMask)) {
|
||||
selCon->SetCaretEnabled(PR_TRUE);
|
||||
}
|
||||
|
||||
const PRBool kIsReadonly = (flags & nsIPlaintextEditor::eEditorReadonlyMask) != 0;
|
||||
selCon->SetCaretReadOnly(kIsReadonly);
|
||||
selCon->SetCaretEnabled(PR_TRUE);
|
||||
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
#ifdef USE_HACK_REPAINT
|
||||
// begin hack repaint
|
||||
|
|
|
@ -378,10 +378,32 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsCaret::DrawCaretAfterBriefDelay()
|
||||
{
|
||||
// Make sure readonly caret gets drawn again if it needs to be
|
||||
if (!mBlinkTimer) {
|
||||
nsresult err;
|
||||
mBlinkTimer = do_CreateInstance("@mozilla.org/timer;1", &err);
|
||||
if (NS_FAILED(err))
|
||||
return;
|
||||
}
|
||||
|
||||
mBlinkTimer->InitWithFuncCallback(CaretBlinkCallback, this, 0,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaret::EraseCaret()
|
||||
{
|
||||
if (mDrawn)
|
||||
if (mDrawn) {
|
||||
DrawCaret();
|
||||
if (mReadOnly) {
|
||||
// If readonly we don't have a blink timer set, so caret won't
|
||||
// be redrawn automatically. We need to force the caret to get
|
||||
// redrawn right after the paint
|
||||
DrawCaretAfterBriefDelay();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -474,6 +496,12 @@ nsresult nsCaret::PrimeTimer()
|
|||
//-----------------------------------------------------------------------------
|
||||
nsresult nsCaret::StartBlinking()
|
||||
{
|
||||
if (mReadOnly) {
|
||||
// Make sure the one draw command we use for a readonly caret isn't
|
||||
// done until the selection is set
|
||||
DrawCaretAfterBriefDelay();
|
||||
return NS_OK;
|
||||
}
|
||||
PrimeTimer();
|
||||
|
||||
//NS_ASSERTION(!mDrawn, "Caret should not be drawn here");
|
||||
|
|
|
@ -95,6 +95,7 @@ class nsCaret : public nsICaret,
|
|||
PRBool DrawAtPositionWithHint(nsIDOMNode* aNode, PRInt32 aOffset, nsIFrameSelection::HINT aFrameHint);
|
||||
PRBool MustDrawCaret();
|
||||
void DrawCaret();
|
||||
void DrawCaretAfterBriefDelay();
|
||||
void GetCaretRectAndInvert(nsIFrame* aFrame, PRInt32 aFrameOffset);
|
||||
void ToggleDrawnStatus() { mDrawn = !mDrawn; }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче