зеркало из https://github.com/mozilla/pjs.git
Flag nsCaret::mPendingDraw if the on-cycle draw was suppressed; update the caret when the pres shell tells us that painting is unsuppressed. b=520720 r=roc
This commit is contained in:
Родитель
6e153eff78
Коммит
d9caa85a1c
|
@ -91,6 +91,7 @@ nsCaret::nsCaret()
|
|||
, mBlinkRate(500)
|
||||
, mVisible(PR_FALSE)
|
||||
, mDrawn(PR_FALSE)
|
||||
, mPendingDraw(PR_FALSE)
|
||||
, mReadOnly(PR_FALSE)
|
||||
, mShowDuringSelection(PR_FALSE)
|
||||
, mIgnoreUserModify(PR_TRUE)
|
||||
|
@ -961,11 +962,19 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame,
|
|||
*outRenderingView = returnView;
|
||||
}
|
||||
|
||||
nsresult nsCaret::CheckCaretDrawingState()
|
||||
nsresult nsCaret::CheckCaretDrawingState()
|
||||
{
|
||||
// If the caret's drawn when it shouldn't be, erase it.
|
||||
if (mDrawn && (!mVisible || !MustDrawCaret(PR_TRUE)))
|
||||
EraseCaret();
|
||||
if (mDrawn) {
|
||||
// The caret is drawn; if it shouldn't be, erase it.
|
||||
if (!mVisible || !MustDrawCaret(PR_TRUE))
|
||||
EraseCaret();
|
||||
}
|
||||
else
|
||||
{
|
||||
// The caret is not drawn; if it should be, draw it.
|
||||
if (mPendingDraw && (mVisible && MustDrawCaret(PR_TRUE)))
|
||||
DrawCaret(PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -983,22 +992,14 @@ nsresult nsCaret::CheckCaretDrawingState()
|
|||
----------------------------------------------------------------------------- */
|
||||
PRBool nsCaret::MustDrawCaret(PRBool aIgnoreDrawnState)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (presShell) {
|
||||
PRBool isPaintingSuppressed;
|
||||
presShell->IsPaintingSuppressed(&isPaintingSuppressed);
|
||||
if (isPaintingSuppressed)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (!aIgnoreDrawnState && mDrawn)
|
||||
return PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsISelection> domSelection = do_QueryReferent(mDomSelectionWeak);
|
||||
if (!domSelection)
|
||||
return PR_FALSE;
|
||||
PRBool isCollapsed;
|
||||
|
||||
PRBool isCollapsed;
|
||||
if (NS_FAILED(domSelection->GetIsCollapsed(&isCollapsed)))
|
||||
return PR_FALSE;
|
||||
|
||||
|
@ -1059,18 +1060,29 @@ PRBool nsCaret::IsMenuPopupHidingCaret()
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
DrawCaret
|
||||
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
void nsCaret::DrawCaret(PRBool aInvalidate)
|
||||
{
|
||||
// do we need to draw the caret at all?
|
||||
// Do we need to draw the caret at all?
|
||||
if (!MustDrawCaret(PR_FALSE))
|
||||
return;
|
||||
|
||||
// Can we draw the caret now?
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
NS_ENSURE_TRUE(presShell, /**/);
|
||||
{
|
||||
PRBool isPaintingSuppressed;
|
||||
presShell->IsPaintingSuppressed(&isPaintingSuppressed);
|
||||
if (isPaintingSuppressed)
|
||||
{
|
||||
if (!mDrawn)
|
||||
mPendingDraw = PR_TRUE;
|
||||
|
||||
// PresShell::UnsuppressAndInvalidate() will call CheckCaretDrawingState()
|
||||
// to get us drawn.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
PRInt32 offset;
|
||||
nsFrameSelection::HINT hint;
|
||||
|
@ -1102,7 +1114,9 @@ void nsCaret::DrawCaret(PRBool aInvalidate)
|
|||
nsCOMPtr<nsFrameSelection> frameSelection = GetFrameSelection();
|
||||
if (!frameSelection)
|
||||
return;
|
||||
|
||||
bidiLevel = frameSelection->GetCaretBidiLevel();
|
||||
mPendingDraw = PR_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -281,13 +281,14 @@ protected:
|
|||
|
||||
// XXX these fields should go away and the values be acquired as needed,
|
||||
// probably by ComputeMetrics.
|
||||
PRUint32 mBlinkRate; // time for one cyle (off then on), in milliseconds
|
||||
PRUint32 mBlinkRate; // time for one cyle (on then off), in milliseconds
|
||||
nscoord mCaretWidthCSSPx; // caret width in CSS pixels
|
||||
float mCaretAspectRatio; // caret width/height aspect ratio
|
||||
|
||||
PRPackedBool mVisible; // is the caret blinking
|
||||
|
||||
PRPackedBool mDrawn; // Denotes when the caret is physically drawn on the screen.
|
||||
PRPackedBool mPendingDraw; // True when the last on-state draw was suppressed.
|
||||
|
||||
PRPackedBool mReadOnly; // it the caret in readonly state (draws differently)
|
||||
PRPackedBool mShowDuringSelection; // show when text is selected
|
||||
|
|
|
@ -4641,6 +4641,10 @@ PresShell::UnsuppressAndInvalidate()
|
|||
nsRect rect(nsPoint(0, 0), rootFrame->GetSize());
|
||||
rootFrame->Invalidate(rect);
|
||||
|
||||
if (mCaretEnabled && mCaret) {
|
||||
mCaret->CheckCaretDrawingState();
|
||||
}
|
||||
|
||||
mPresContext->RootPresContext()->UpdatePluginGeometry(rootFrame);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче