Bug #278312 --> layout and selection changes to support inline spell checking for Thunderbird

Includes changes to draw spell check selection as a red dotted line instead of a solid underline.

r/sr=dbaron
This commit is contained in:
scott%scott-macgregor.org 2005-01-31 17:57:35 +00:00
Родитель 61cd2b1f4d
Коммит 203c40b9da
3 изменённых файлов: 94 добавлений и 43 удалений

Просмотреть файл

@ -1426,9 +1426,11 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
//
// If the user clicked inside a selection, then just
// return without doing anything. We will handle placing
// the caret later on when the mouse is released.
// the caret later on when the mouse is released. We ignore
// the spellcheck selection.
//
if (curDetail->mStart <= startOffset && endOffset <= curDetail->mEnd)
if (curDetail->mType != nsISelectionController::SELECTION_SPELLCHECK &&
curDetail->mStart <= startOffset && endOffset <= curDetail->mEnd)
{
delete details;
rv = frameselection->SetMouseDownState( PR_FALSE );

Просмотреть файл

@ -2620,7 +2620,22 @@ nsSelection::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt
*aReturnDetails = nsnull;
// if any of the additional selections are set, always do a slow check. The
// issue is that the NS_FRAME_SELECTED_CONTENT bit is set when any of the
// selections are used, and the 'non-slow' code assumes that this means that
// there exists something selected for all selection types.
PRInt8 j;
for (j = (PRInt8) 1; j < (PRInt8)nsISelectionController::NUM_SELECTIONTYPES; j++){
if (mDomSelections[j]){
PRBool iscollapsed;
mDomSelections[j]->GetIsCollapsed(&iscollapsed);
if (!iscollapsed){
aSlowCheck = PR_TRUE;
}
}
}
for (j = (PRInt8) 0; j < (PRInt8)nsISelectionController::NUM_SELECTIONTYPES; j++){
if (mDomSelections[j])
mDomSelections[j]->LookUpSelection(aContent, aContentOffset, aContentLength, aReturnDetails, (SelectionType)(1<<j), aSlowCheck);

Просмотреть файл

@ -27,6 +27,7 @@
* Tomi Leppikangas <tomi.leppikangas@oulu.fi>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
* Daniel Glazman <glazman@netscape.com>
* Neil Deakin <neil@mozdevgroup.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -733,6 +734,7 @@ public:
PRBool& aDisplayingSelection,
PRBool& aIsPaginated,
PRBool& aIsSelected,
PRBool& aHideStandardSelection,
PRInt16& aSelectionValue,
nsILineBreaker** aLineBreaker);
@ -1214,7 +1216,7 @@ DrawSelectionIterator::CurrentForeGroundColor()
colorSet = PR_TRUE;
}
}
else if (mTypes[mCurrentIdx] | nsISelectionController::SELECTION_NORMAL)//Find color based on mTypes[mCurrentIdx];
else if (mTypes[mCurrentIdx] & nsISelectionController::SELECTION_NORMAL)//Find color based on mTypes[mCurrentIdx];
{
foreColor = mOldStyle.mSelectionTextColor;
colorSet = PR_TRUE;
@ -1234,7 +1236,7 @@ DrawSelectionIterator::CurrentBackGroundColor(nscolor &aColor, PRBool *aIsTransp
{
//Find color based on mTypes[mCurrentIdx];
*aIsTransparent = PR_FALSE;
if (mTypes? (mTypes[mCurrentIdx] | nsISelectionController::SELECTION_NORMAL): (mCurrentIdx == (PRUint32)mDetails->mStart)) {
if (mTypes? (mTypes[mCurrentIdx] & nsISelectionController::SELECTION_NORMAL): (mCurrentIdx == (PRUint32)mDetails->mStart)) {
aColor = mOldStyle.mSelectionBGColor;
if (mSelectionPseudoStyle) {
aColor = mSelectionPseudoBGcolor;
@ -1967,8 +1969,9 @@ nsTextFrame::PaintTextDecorations(nsIRenderingContext& aRenderingContext,
break;
case nsISelectionController::SELECTION_SPELLCHECK:{
aTextStyle.mNormalFont->GetUnderline(offset, size);
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
aRenderingContext.SetColor(NS_RGB(255,0,0));
aRenderingContext.FillRect(aX + startOffset, aY + baseline - offset, textWidth, size);
aRenderingContext.DrawLine(aX + startOffset, aY + baseline - offset, aX + startOffset + textWidth, aY + baseline - offset);
}break;
case nsISelectionController::SELECTION_IME_SELECTEDRAWTEXT:{
#ifdef USE_INVERT_FOR_SELECTION
@ -2078,6 +2081,7 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsPresContext* aPresContex
PRBool& aDisplayingSelection,
PRBool& aIsPaginated,
PRBool& aIsSelected,
PRBool& aHideStandardSelection,
PRInt16& aSelectionValue,
nsILineBreaker** aLineBreaker)
{
@ -2112,6 +2116,20 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsPresContext* aPresContex
if (!(textSel & nsISelectionDisplay::DISPLAY_TEXT))
aDisplayingSelection = PR_FALSE;
// the spellcheck selection should be visible all the time
aHideStandardSelection = !aDisplayingSelection;
if (!aDisplayingSelection){
nsCOMPtr<nsISelection> spellcheckSelection;
(*aSelectionController)->GetSelection(nsISelectionController::SELECTION_SPELLCHECK,
getter_AddRefs(spellcheckSelection));
if (spellcheckSelection){
PRBool iscollapsed = PR_FALSE;
spellcheckSelection->GetIsCollapsed(&iscollapsed);
if (!iscollapsed)
aDisplayingSelection = PR_TRUE;
}
}
// Transform text from content into renderable form
// XXX If the text fragment is already Unicode and the text wasn't
// transformed when we formatted it, then there's no need to do all
@ -2137,6 +2155,7 @@ nsTextFrame::IsTextInSelection(nsPresContext* aPresContext,
PRBool displaySelection;
PRBool isPaginated;
PRBool isSelected;
PRBool hideStandardSelection;
PRInt16 selectionValue;
nsCOMPtr<nsILineBreaker> lb;
if (NS_FAILED(GetTextInfoForPainting(aPresContext,
@ -2146,6 +2165,7 @@ nsTextFrame::IsTextInSelection(nsPresContext* aPresContext,
displaySelection,
isPaginated,
isSelected,
hideStandardSelection,
selectionValue,
getter_AddRefs(lb)))) {
return PR_FALSE;
@ -2270,6 +2290,7 @@ nsTextFrame::PaintUnicodeText(nsPresContext* aPresContext,
PRBool displaySelection,canDarkenColor=PR_FALSE;
PRBool isPaginated;
PRBool isSelected;
PRBool hideStandardSelection;
PRInt16 selectionValue;
nsCOMPtr<nsILineBreaker> lb;
#ifdef IBMBIDI
@ -2284,6 +2305,7 @@ nsTextFrame::PaintUnicodeText(nsPresContext* aPresContext,
displaySelection,
isPaginated,
isSelected,
hideStandardSelection,
selectionValue,
getter_AddRefs(lb)))) {
return;
@ -2425,6 +2447,7 @@ nsTextFrame::PaintUnicodeText(nsPresContext* aPresContext,
#endif
sdptr = sdptr->mNext;
}
if (!hideStandardSelection) {
//while we have substrings...
//PRBool drawn = PR_FALSE;
DrawSelectionIterator iter(content, details,text,(PRUint32)textLength,aTextStyle, selectionValue, aPresContext, mStyleContext);
@ -2491,6 +2514,7 @@ nsTextFrame::PaintUnicodeText(nsPresContext* aPresContext,
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
}
}
PaintTextDecorations(aRenderingContext, aStyleContext, aPresContext,
aTextStyle, dx, dy, width, text, details, 0,
(PRUint32)textLength);
@ -3000,6 +3024,7 @@ nsTextFrame::PaintTextSlowly(nsPresContext* aPresContext,
PRBool displaySelection;
PRBool isPaginated,canDarkenColor=PR_FALSE;
PRBool isSelected;
PRBool hideStandardSelection;
PRInt16 selectionValue;
nsCOMPtr<nsILineBreaker> lb;
if (NS_FAILED(GetTextInfoForPainting(aPresContext,
@ -3009,6 +3034,7 @@ nsTextFrame::PaintTextSlowly(nsPresContext* aPresContext,
displaySelection,
isPaginated,
isSelected,
hideStandardSelection,
selectionValue,
getter_AddRefs(lb)))) {
return;
@ -3179,6 +3205,7 @@ nsTextFrame::PaintAsciiText(nsPresContext* aPresContext,
PRBool displaySelection,canDarkenColor=PR_FALSE;
PRBool isPaginated;
PRBool isSelected;
PRBool hideStandardSelection;
PRInt16 selectionValue;
nsCOMPtr<nsILineBreaker> lb;
if (NS_FAILED(GetTextInfoForPainting(aPresContext,
@ -3188,6 +3215,7 @@ nsTextFrame::PaintAsciiText(nsPresContext* aPresContext,
displaySelection,
isPaginated,
isSelected,
hideStandardSelection,
selectionValue,
getter_AddRefs(lb)))) {
return;
@ -3322,7 +3350,11 @@ nsTextFrame::PaintAsciiText(nsPresContext* aPresContext,
sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset;
sdptr = sdptr->mNext;
}
DrawSelectionIterator iter(content, details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle, selectionValue, aPresContext, mStyleContext); //ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION
if (!hideStandardSelection) {
//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION
DrawSelectionIterator iter(content, details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle,
selectionValue, aPresContext, mStyleContext);
if (!iter.IsDone() && iter.First())
{
nscoord currentX = dx;
@ -3367,6 +3399,8 @@ nsTextFrame::PaintAsciiText(nsPresContext* aPresContext,
aRenderingContext.SetColor(nsCSSRendering::TransformColor(aTextStyle.mColor->mColor,canDarkenColor));
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy + mAscent);
}
}
PaintTextDecorations(aRenderingContext, aStyleContext, aPresContext,
aTextStyle, dx, dy, width,
unicodePaintBuffer.mBuffer,