From 05840e5f323cefbabf76eb66a3ebbbb3684b7e2f Mon Sep 17 00:00:00 2001 From: "anthonyd%netscape.com" Date: Thu, 20 Apr 2000 23:11:41 +0000 Subject: [PATCH] drawing selection as tri-state. on-off-disabled. hardcoded disable color to grey right now. r=mjudge --- content/base/public/nsIDocument.h | 6 +++-- content/base/src/nsDocument.cpp | 4 ++-- content/base/src/nsDocument.h | 6 ++--- content/html/document/src/nsHTMLDocument.cpp | 2 +- content/xul/document/src/nsXULDocument.cpp | 6 ++--- content/xul/document/src/nsXULDocument.h | 6 ++--- editor/base/nsEditorEventListeners.cpp | 21 +++++----------- .../libeditor/text/nsEditorEventListeners.cpp | 21 +++++----------- layout/base/nsPresShell.cpp | 2 +- layout/base/public/nsIDocument.h | 6 +++-- layout/base/src/nsDocument.cpp | 4 ++-- layout/base/src/nsDocument.h | 6 ++--- layout/generic/nsFrame.cpp | 2 +- layout/generic/nsTextFrame.cpp | 24 ++++++++++++------- layout/html/base/src/nsFrame.cpp | 2 +- layout/html/base/src/nsPresShell.cpp | 2 +- layout/html/base/src/nsTextFrame.cpp | 24 ++++++++++++------- layout/html/document/src/nsHTMLDocument.cpp | 2 +- .../html/forms/src/nsGfxTextControlFrame.cpp | 6 ++--- rdf/content/src/nsXULDocument.cpp | 6 ++--- rdf/content/src/nsXULDocument.h | 6 ++--- webshell/tests/viewer/nsBrowserWindow.cpp | 2 +- 22 files changed, 84 insertions(+), 82 deletions(-) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index ae4c708091b..9a3af5e0148 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -314,8 +314,10 @@ public: virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const = 0; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const = 0; virtual nsIContent* GetNextContent(const nsIContent *aContent) const = 0; - virtual void SetDisplaySelection(PRBool aToggle) = 0; - virtual PRBool GetDisplaySelection() const = 0; + + enum{SELECTION_OFF = 0, SELECTION_ON = 1, SELECTION_DISABLED = 2 }; + virtual void SetDisplaySelection(PRInt8 aToggle) = 0; + virtual PRInt8 GetDisplaySelection() const = 0; NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index d93d1b577c1..2c7bc8e5129 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3382,12 +3382,12 @@ nsIContent* nsDocument::GetNextContent(const nsIContent *aContent) const return result; } -void nsDocument::SetDisplaySelection(PRBool aToggle) +void nsDocument::SetDisplaySelection(PRInt8 aToggle) { mDisplaySelection = aToggle; } -PRBool nsDocument::GetDisplaySelection() const +PRInt8 nsDocument::GetDisplaySelection() const { return mDisplaySelection; } diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 1fe0bb09448..2d8343a8434 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -394,8 +394,8 @@ public: virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const; virtual nsIContent* GetNextContent(const nsIContent *aContent) const; - virtual void SetDisplaySelection(PRBool aToggle); - virtual PRBool GetDisplaySelection() const; + virtual void SetDisplaySelection(PRInt8 aToggle); + virtual PRInt8 GetDisplaySelection() const; // nsIJSScriptObject interface virtual PRBool AddProperty(JSContext *aContext, JSObject *aObj, @@ -469,7 +469,7 @@ protected: void* mScriptObject; nsCOMPtr mScriptGlobalObject; nsIEventListenerManager* mListenerManager; - PRBool mDisplaySelection; + PRInt8 mDisplaySelection; PRBool mInDestructor; nsDOMStyleSheetCollection *mDOMStyleSheets; nsINameSpaceManager* mNameSpaceManager; diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index a390447c5b6..7ea2496dfa9 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -3553,7 +3553,7 @@ NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatch NS_IF_RELEASE(start); NS_IF_RELEASE(end); - SetDisplaySelection(PR_TRUE); + SetDisplaySelection(nsIDocument::SELECTION_ON); if (aIsFound && doReplace) { diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 4c9dc175f2a..953274c8e4e 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -1742,7 +1742,7 @@ nsXULDocument::SelectAll() startPnt->SetPoint(start, -1, PR_TRUE); endPnt->SetPoint(end, -1, PR_FALSE); #endif - SetDisplaySelection(PR_TRUE); + SetDisplaySelection(nsIDocument::SELECTION_ON); return NS_OK; } @@ -1929,12 +1929,12 @@ nsXULDocument::GetNextContent(const nsIContent *aContent) const } void -nsXULDocument::SetDisplaySelection(PRBool aToggle) +nsXULDocument::SetDisplaySelection(PRInt8 aToggle) { mDisplaySelection = aToggle; } -PRBool +PRInt8 nsXULDocument::GetDisplaySelection() const { return mDisplaySelection; diff --git a/content/xul/document/src/nsXULDocument.h b/content/xul/document/src/nsXULDocument.h index 4a1d3515947..b684535f1cb 100644 --- a/content/xul/document/src/nsXULDocument.h +++ b/content/xul/document/src/nsXULDocument.h @@ -268,9 +268,9 @@ public: virtual nsIContent* GetNextContent(const nsIContent *aContent) const; - virtual void SetDisplaySelection(PRBool aToggle); + virtual void SetDisplaySelection(PRInt8 aToggle); - virtual PRBool GetDisplaySelection() const; + virtual PRInt8 GetDisplaySelection() const; NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, @@ -529,7 +529,7 @@ protected: nsString mCharSetID; nsVoidArray mStyleSheets; nsCOMPtr mSelection; // [OWNER] - PRBool mDisplaySelection; + PRInt8 mDisplaySelection; PRBool mIsKeyBindingDoc; nsVoidArray mPresShells; nsCOMPtr mListenerManager; // [OWNER] diff --git a/editor/base/nsEditorEventListeners.cpp b/editor/base/nsEditorEventListeners.cpp index 76b0412ae9f..f799acf0efb 100644 --- a/editor/base/nsEditorEventListeners.cpp +++ b/editor/base/nsEditorEventListeners.cpp @@ -1145,7 +1145,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent) nsCOMPtrdoc = do_QueryInterface(domDoc); if (doc) { - doc->SetDisplaySelection(PR_TRUE); + doc->SetDisplaySelection(nsIDocument::SELECTION_ON); } } #ifdef USE_HACK_REPAINT @@ -1191,20 +1191,11 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent) editor->GetDocument(getter_AddRefs(domDoc)); if (domDoc) { - if ((flags & nsIHTMLEditor::eEditorPlaintextMask) || - (flags & nsIHTMLEditor::eEditorSingleLineMask) || - (flags & nsIHTMLEditor::eEditorPasswordMask) || - (flags & nsIHTMLEditor::eEditorReadonlyMask) || - (flags & nsIHTMLEditor::eEditorDisabledMask) || - (flags & nsIHTMLEditor::eEditorFilterInputMask) || - (flags & nsIHTMLEditor::eEditorMailMask)) - {//HACK UNTIL UNFOCUSED SELECTION DRAWS CORRECTLY - nsCOMPtrdoc = do_QueryInterface(domDoc); - if (doc) - { - doc->SetDisplaySelection(PR_FALSE); - } - }//END HACK + nsCOMPtrdoc = do_QueryInterface(domDoc); + if (doc) + { + doc->SetDisplaySelection(nsIDocument::SELECTION_DISABLED); + } } #ifdef USE_HACK_REPAINT // begin hack repaint diff --git a/editor/libeditor/text/nsEditorEventListeners.cpp b/editor/libeditor/text/nsEditorEventListeners.cpp index 76b0412ae9f..f799acf0efb 100644 --- a/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/editor/libeditor/text/nsEditorEventListeners.cpp @@ -1145,7 +1145,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent) nsCOMPtrdoc = do_QueryInterface(domDoc); if (doc) { - doc->SetDisplaySelection(PR_TRUE); + doc->SetDisplaySelection(nsIDocument::SELECTION_ON); } } #ifdef USE_HACK_REPAINT @@ -1191,20 +1191,11 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent) editor->GetDocument(getter_AddRefs(domDoc)); if (domDoc) { - if ((flags & nsIHTMLEditor::eEditorPlaintextMask) || - (flags & nsIHTMLEditor::eEditorSingleLineMask) || - (flags & nsIHTMLEditor::eEditorPasswordMask) || - (flags & nsIHTMLEditor::eEditorReadonlyMask) || - (flags & nsIHTMLEditor::eEditorDisabledMask) || - (flags & nsIHTMLEditor::eEditorFilterInputMask) || - (flags & nsIHTMLEditor::eEditorMailMask)) - {//HACK UNTIL UNFOCUSED SELECTION DRAWS CORRECTLY - nsCOMPtrdoc = do_QueryInterface(domDoc); - if (doc) - { - doc->SetDisplaySelection(PR_FALSE); - } - }//END HACK + nsCOMPtrdoc = do_QueryInterface(domDoc); + if (doc) + { + doc->SetDisplaySelection(nsIDocument::SELECTION_DISABLED); + } } #ifdef USE_HACK_REPAINT // begin hack repaint diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 3fa2bd8c49c..99c420660a7 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -995,7 +995,7 @@ PresShell::Init(nsIDocument* aDocument, result = docShell->GetItemType(&docShellType); if (NS_SUCCEEDED(result)){ if (nsIDocShellTreeItem::typeContent == docShellType){ - mDocument->SetDisplaySelection(PR_TRUE); + mDocument->SetDisplaySelection(nsIDocument::SELECTION_ON); } } } diff --git a/layout/base/public/nsIDocument.h b/layout/base/public/nsIDocument.h index ae4c708091b..9a3af5e0148 100644 --- a/layout/base/public/nsIDocument.h +++ b/layout/base/public/nsIDocument.h @@ -314,8 +314,10 @@ public: virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const = 0; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const = 0; virtual nsIContent* GetNextContent(const nsIContent *aContent) const = 0; - virtual void SetDisplaySelection(PRBool aToggle) = 0; - virtual PRBool GetDisplaySelection() const = 0; + + enum{SELECTION_OFF = 0, SELECTION_ON = 1, SELECTION_DISABLED = 2 }; + virtual void SetDisplaySelection(PRInt8 aToggle) = 0; + virtual PRInt8 GetDisplaySelection() const = 0; NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, diff --git a/layout/base/src/nsDocument.cpp b/layout/base/src/nsDocument.cpp index d93d1b577c1..2c7bc8e5129 100644 --- a/layout/base/src/nsDocument.cpp +++ b/layout/base/src/nsDocument.cpp @@ -3382,12 +3382,12 @@ nsIContent* nsDocument::GetNextContent(const nsIContent *aContent) const return result; } -void nsDocument::SetDisplaySelection(PRBool aToggle) +void nsDocument::SetDisplaySelection(PRInt8 aToggle) { mDisplaySelection = aToggle; } -PRBool nsDocument::GetDisplaySelection() const +PRInt8 nsDocument::GetDisplaySelection() const { return mDisplaySelection; } diff --git a/layout/base/src/nsDocument.h b/layout/base/src/nsDocument.h index 1fe0bb09448..2d8343a8434 100644 --- a/layout/base/src/nsDocument.h +++ b/layout/base/src/nsDocument.h @@ -394,8 +394,8 @@ public: virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const; virtual nsIContent* GetNextContent(const nsIContent *aContent) const; - virtual void SetDisplaySelection(PRBool aToggle); - virtual PRBool GetDisplaySelection() const; + virtual void SetDisplaySelection(PRInt8 aToggle); + virtual PRInt8 GetDisplaySelection() const; // nsIJSScriptObject interface virtual PRBool AddProperty(JSContext *aContext, JSObject *aObj, @@ -469,7 +469,7 @@ protected: void* mScriptObject; nsCOMPtr mScriptGlobalObject; nsIEventListenerManager* mListenerManager; - PRBool mDisplaySelection; + PRInt8 mDisplaySelection; PRBool mInDestructor; nsDOMStyleSheetCollection *mDOMStyleSheets; nsINameSpaceManager* mNameSpaceManager; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index a5158cafb1c..9ed6a5961a1 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -606,7 +606,7 @@ nsFrame::DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn) } } if (isOkToTurnOn && !result) { - doc->SetDisplaySelection(PR_TRUE); + doc->SetDisplaySelection(nsIDocument::SELECTION_ON); result = PR_TRUE; } } diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 886c84e3eaf..a536703fd6e 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -780,9 +780,12 @@ inline nscolor EnsureDifferentColors(nscolor colorA, nscolor colorB) //helper class for drawing multiply selected text class DrawSelectionIterator { + enum {DISABLED_COLOR = NS_RGB(176,176,176)}; enum {SELECTION_TYPES_WE_CARE_ABOUT=SELECTION_NONE+SELECTION_NORMAL}; public: - DrawSelectionIterator(const SelectionDetails *aSelDetails, PRUnichar *aText,PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle); + DrawSelectionIterator(const SelectionDetails *aSelDetails, PRUnichar *aText, + PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle, + PRInt8 aSelectionStatus); ~DrawSelectionIterator(); PRBool First(); PRBool Next(); @@ -807,12 +810,14 @@ private: PRBool mDone; PRUint8 * mTypes; PRBool mInit; + PRInt8 mSelectionStatus;//see nsIDocument.h SetDisplaySelection() + nscolor mDisabledColor; //private methods void FillCurrentData(); }; DrawSelectionIterator::DrawSelectionIterator(const SelectionDetails *aSelDetails, PRUnichar *aText, - PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle) + PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle, PRInt8 aSelectionStatus) :mOldStyle(aTextStyle) { mDetails = aSelDetails; @@ -821,6 +826,9 @@ DrawSelectionIterator::DrawSelectionIterator(const SelectionDetails *aSelDetails mLength = aTextLength; mTypes = nsnull; mInit = PR_FALSE; + mSelectionStatus = aSelectionStatus; + mDisabledColor = EnsureDifferentColors(DISABLED_COLOR, mOldStyle.mSelectionBGColor); + if (!aSelDetails) { mDone = PR_TRUE; @@ -1009,13 +1017,13 @@ DrawSelectionIterator::CurrentBackGroundColor(nscolor &aColor) { if (mCurrentIdx == (PRUint32)mDetails->mStart) { - aColor = mOldStyle.mSelectionBGColor; + aColor = (mSelectionStatus==nsIDocument::SELECTION_ON)?mOldStyle.mSelectionBGColor:mDisabledColor; return PR_TRUE; } } else if (mTypes[mCurrentIdx] | SELECTION_NORMAL) { - aColor = mOldStyle.mSelectionBGColor; + aColor = (mSelectionStatus==nsIDocument::SELECTION_ON)?mOldStyle.mSelectionBGColor:mDisabledColor; return PR_TRUE; } return PR_FALSE; @@ -1723,7 +1731,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, { nsCOMPtr doc(getter_AddRefs(GetDocument(aPresContext))); - PRBool displaySelection; + PRInt8 displaySelection; displaySelection = doc->GetDisplaySelection(); // Make enough space to transform @@ -1796,7 +1804,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, } //while we have substrings... PRBool drawn = PR_FALSE; - DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle); + DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle, displaySelection); if (!iter.IsDone() && iter.First()) { nscoord currentX = dx; @@ -2295,7 +2303,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, sdptr = sdptr->mNext; } - DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle); + DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle, displaySelection); if (!iter.IsDone() && iter.First()) { nscoord currentX = dx; @@ -2482,7 +2490,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext, sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; sdptr = sdptr->mNext; } - DrawSelectionIterator iter(details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle);//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION + DrawSelectionIterator iter(details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle, displaySelection);//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION if (!iter.IsDone() && iter.First()) { nscoord currentX = dx; diff --git a/layout/html/base/src/nsFrame.cpp b/layout/html/base/src/nsFrame.cpp index a5158cafb1c..9ed6a5961a1 100644 --- a/layout/html/base/src/nsFrame.cpp +++ b/layout/html/base/src/nsFrame.cpp @@ -606,7 +606,7 @@ nsFrame::DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn) } } if (isOkToTurnOn && !result) { - doc->SetDisplaySelection(PR_TRUE); + doc->SetDisplaySelection(nsIDocument::SELECTION_ON); result = PR_TRUE; } } diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index 3fa2bd8c49c..99c420660a7 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -995,7 +995,7 @@ PresShell::Init(nsIDocument* aDocument, result = docShell->GetItemType(&docShellType); if (NS_SUCCEEDED(result)){ if (nsIDocShellTreeItem::typeContent == docShellType){ - mDocument->SetDisplaySelection(PR_TRUE); + mDocument->SetDisplaySelection(nsIDocument::SELECTION_ON); } } } diff --git a/layout/html/base/src/nsTextFrame.cpp b/layout/html/base/src/nsTextFrame.cpp index 886c84e3eaf..a536703fd6e 100644 --- a/layout/html/base/src/nsTextFrame.cpp +++ b/layout/html/base/src/nsTextFrame.cpp @@ -780,9 +780,12 @@ inline nscolor EnsureDifferentColors(nscolor colorA, nscolor colorB) //helper class for drawing multiply selected text class DrawSelectionIterator { + enum {DISABLED_COLOR = NS_RGB(176,176,176)}; enum {SELECTION_TYPES_WE_CARE_ABOUT=SELECTION_NONE+SELECTION_NORMAL}; public: - DrawSelectionIterator(const SelectionDetails *aSelDetails, PRUnichar *aText,PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle); + DrawSelectionIterator(const SelectionDetails *aSelDetails, PRUnichar *aText, + PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle, + PRInt8 aSelectionStatus); ~DrawSelectionIterator(); PRBool First(); PRBool Next(); @@ -807,12 +810,14 @@ private: PRBool mDone; PRUint8 * mTypes; PRBool mInit; + PRInt8 mSelectionStatus;//see nsIDocument.h SetDisplaySelection() + nscolor mDisabledColor; //private methods void FillCurrentData(); }; DrawSelectionIterator::DrawSelectionIterator(const SelectionDetails *aSelDetails, PRUnichar *aText, - PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle) + PRUint32 aTextLength, nsTextFrame::TextStyle &aTextStyle, PRInt8 aSelectionStatus) :mOldStyle(aTextStyle) { mDetails = aSelDetails; @@ -821,6 +826,9 @@ DrawSelectionIterator::DrawSelectionIterator(const SelectionDetails *aSelDetails mLength = aTextLength; mTypes = nsnull; mInit = PR_FALSE; + mSelectionStatus = aSelectionStatus; + mDisabledColor = EnsureDifferentColors(DISABLED_COLOR, mOldStyle.mSelectionBGColor); + if (!aSelDetails) { mDone = PR_TRUE; @@ -1009,13 +1017,13 @@ DrawSelectionIterator::CurrentBackGroundColor(nscolor &aColor) { if (mCurrentIdx == (PRUint32)mDetails->mStart) { - aColor = mOldStyle.mSelectionBGColor; + aColor = (mSelectionStatus==nsIDocument::SELECTION_ON)?mOldStyle.mSelectionBGColor:mDisabledColor; return PR_TRUE; } } else if (mTypes[mCurrentIdx] | SELECTION_NORMAL) { - aColor = mOldStyle.mSelectionBGColor; + aColor = (mSelectionStatus==nsIDocument::SELECTION_ON)?mOldStyle.mSelectionBGColor:mDisabledColor; return PR_TRUE; } return PR_FALSE; @@ -1723,7 +1731,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, { nsCOMPtr doc(getter_AddRefs(GetDocument(aPresContext))); - PRBool displaySelection; + PRInt8 displaySelection; displaySelection = doc->GetDisplaySelection(); // Make enough space to transform @@ -1796,7 +1804,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, } //while we have substrings... PRBool drawn = PR_FALSE; - DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle); + DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle, displaySelection); if (!iter.IsDone() && iter.First()) { nscoord currentX = dx; @@ -2295,7 +2303,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, sdptr = sdptr->mNext; } - DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle); + DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle, displaySelection); if (!iter.IsDone() && iter.First()) { nscoord currentX = dx; @@ -2482,7 +2490,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext, sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; sdptr = sdptr->mNext; } - DrawSelectionIterator iter(details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle);//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION + DrawSelectionIterator iter(details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle, displaySelection);//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION if (!iter.IsDone() && iter.First()) { nscoord currentX = dx; diff --git a/layout/html/document/src/nsHTMLDocument.cpp b/layout/html/document/src/nsHTMLDocument.cpp index a390447c5b6..7ea2496dfa9 100644 --- a/layout/html/document/src/nsHTMLDocument.cpp +++ b/layout/html/document/src/nsHTMLDocument.cpp @@ -3553,7 +3553,7 @@ NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatch NS_IF_RELEASE(start); NS_IF_RELEASE(end); - SetDisplaySelection(PR_TRUE); + SetDisplaySelection(nsIDocument::SELECTION_ON); if (aIsFound && doReplace) { diff --git a/layout/html/forms/src/nsGfxTextControlFrame.cpp b/layout/html/forms/src/nsGfxTextControlFrame.cpp index 61dcbfb35c3..f68b7cb683b 100644 --- a/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -1223,7 +1223,7 @@ nsGfxTextControlFrame::AttributeChanged(nsIPresContext* aPresContext, presShell->GetDocument(getter_AddRefs(doc)); NS_ASSERTION(doc, "null document"); if (!doc) { return NS_ERROR_NULL_POINTER; } - doc->SetDisplaySelection(PR_FALSE); + doc->SetDisplaySelection(nsIDocument::SELECTION_OFF); } else { // unset readonly @@ -1233,7 +1233,7 @@ nsGfxTextControlFrame::AttributeChanged(nsIPresContext* aPresContext, presShell->GetDocument(getter_AddRefs(doc)); NS_ASSERTION(doc, "null document"); if (!doc) { return NS_ERROR_NULL_POINTER; } - doc->SetDisplaySelection(PR_TRUE); + doc->SetDisplaySelection(nsIDocument::SELECTION_ON); } mEditor->SetFlags(flags); } @@ -3417,7 +3417,7 @@ nsGfxTextControlFrame::InitializeTextControl(nsIPresShell *aPresShell, nsIDOMDoc aPresShell->SetCaretEnabled(PR_FALSE); nsCOMPtrdoc = do_QueryInterface(aDoc); if (doc) { - doc->SetDisplaySelection(PR_FALSE); + doc->SetDisplaySelection(nsIDocument::SELECTION_OFF); } } } diff --git a/rdf/content/src/nsXULDocument.cpp b/rdf/content/src/nsXULDocument.cpp index 4c9dc175f2a..953274c8e4e 100644 --- a/rdf/content/src/nsXULDocument.cpp +++ b/rdf/content/src/nsXULDocument.cpp @@ -1742,7 +1742,7 @@ nsXULDocument::SelectAll() startPnt->SetPoint(start, -1, PR_TRUE); endPnt->SetPoint(end, -1, PR_FALSE); #endif - SetDisplaySelection(PR_TRUE); + SetDisplaySelection(nsIDocument::SELECTION_ON); return NS_OK; } @@ -1929,12 +1929,12 @@ nsXULDocument::GetNextContent(const nsIContent *aContent) const } void -nsXULDocument::SetDisplaySelection(PRBool aToggle) +nsXULDocument::SetDisplaySelection(PRInt8 aToggle) { mDisplaySelection = aToggle; } -PRBool +PRInt8 nsXULDocument::GetDisplaySelection() const { return mDisplaySelection; diff --git a/rdf/content/src/nsXULDocument.h b/rdf/content/src/nsXULDocument.h index 4a1d3515947..b684535f1cb 100644 --- a/rdf/content/src/nsXULDocument.h +++ b/rdf/content/src/nsXULDocument.h @@ -268,9 +268,9 @@ public: virtual nsIContent* GetNextContent(const nsIContent *aContent) const; - virtual void SetDisplaySelection(PRBool aToggle); + virtual void SetDisplaySelection(PRInt8 aToggle); - virtual PRBool GetDisplaySelection() const; + virtual PRInt8 GetDisplaySelection() const; NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, @@ -529,7 +529,7 @@ protected: nsString mCharSetID; nsVoidArray mStyleSheets; nsCOMPtr mSelection; // [OWNER] - PRBool mDisplaySelection; + PRInt8 mDisplaySelection; PRBool mIsKeyBindingDoc; nsVoidArray mPresShells; nsCOMPtr mListenerManager; // [OWNER] diff --git a/webshell/tests/viewer/nsBrowserWindow.cpp b/webshell/tests/viewer/nsBrowserWindow.cpp index a2355d2610c..61a6690f7d8 100644 --- a/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/webshell/tests/viewer/nsBrowserWindow.cpp @@ -3355,7 +3355,7 @@ nsBrowserWindow::DoToggleSelection() nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); if (doc) { - PRBool current = doc->GetDisplaySelection(); + PRInt8 current = doc->GetDisplaySelection(); doc->SetDisplaySelection(!current); ForceRefresh(); }