Bug 237228 pref "layout.word_select.eat_space_to_next_word" can't be set by user in the profile's prefs.js
r=dbaron, sr=roc, patch=ginn.chen@sun.com
This commit is contained in:
@@ -788,10 +788,6 @@ protected:
|
||||
PRBool aGetTextDimensions/* true=get dimensions false = return length up to aDimensionsResult->width size*/);
|
||||
nsresult GetContentAndOffsetsForSelection(nsPresContext* aPresContext,nsIContent **aContent, PRInt32 *aOffset, PRInt32 *aLength);
|
||||
|
||||
// prefs used to configure the double-click word selection behavior
|
||||
static PRPackedBool sWordSelectPrefInited; // have we read the prefs yet?
|
||||
static PRPackedBool sWordSelectEatSpaceAfter; // should we include whitespace up to next word?
|
||||
|
||||
void AdjustSelectionPointsForBidi(SelectionDetails *sdptr,
|
||||
PRInt32 textLength,
|
||||
PRBool isRTLChars,
|
||||
@@ -817,10 +813,6 @@ NS_IMETHODIMP nsTextFrame::GetAccessible(nsIAccessible** aAccessible)
|
||||
#endif
|
||||
|
||||
|
||||
PRPackedBool nsTextFrame::sWordSelectPrefInited = PR_FALSE;
|
||||
PRPackedBool nsTextFrame::sWordSelectEatSpaceAfter = PR_TRUE;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsTextFrame::Destroy(nsPresContext* aPresContext)
|
||||
@@ -1317,13 +1309,6 @@ NS_NewContinuingTextFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
||||
|
||||
nsTextFrame::nsTextFrame()
|
||||
{
|
||||
// read in our global word selection prefs
|
||||
if ( !sWordSelectPrefInited ) {
|
||||
sWordSelectEatSpaceAfter =
|
||||
nsContentUtils::GetBoolPref("layout.word_select.eat_space_to_next_word");
|
||||
|
||||
sWordSelectPrefInited = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsTextFrame::~nsTextFrame()
|
||||
@@ -4124,7 +4109,7 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
||||
PRBool found = PR_FALSE;
|
||||
PRBool isWhitespace, wasTransformed;
|
||||
PRInt32 wordLen, contentLen;
|
||||
|
||||
PRBool wordSelectEatSpaceAfter = tx.GetWordSelectEatSpaceAfter();
|
||||
|
||||
PRBool selectable;
|
||||
PRUint8 selectStyle;
|
||||
@@ -4206,10 +4191,10 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
||||
|
||||
// On some platforms (mac, unix), we want the selection to end
|
||||
// at the end of the word (not the beginning of the next one).
|
||||
if ((sWordSelectEatSpaceAfter ? isWhitespace : !isWhitespace) || !aPos->mEatingWS) {
|
||||
if ((wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace) || !aPos->mEatingWS) {
|
||||
aPos->mContentOffset = aPos->mStartOffset + contentLen;
|
||||
keepSearching = PR_TRUE;
|
||||
aPos->mEatingWS = !sWordSelectEatSpaceAfter;
|
||||
aPos->mEatingWS = !wordSelectEatSpaceAfter;
|
||||
#ifdef IBMBIDI
|
||||
wordLen = (mState & NS_FRAME_IS_BIDI)
|
||||
? mContentOffset + mContentLength : -1;
|
||||
@@ -4218,7 +4203,7 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
if (sWordSelectEatSpaceAfter ? isWhitespace : !isWhitespace)
|
||||
if (wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
|
||||
@@ -55,14 +55,17 @@
|
||||
|
||||
|
||||
PRBool nsTextTransformer::sWordSelectListenerPrefChecked = PR_FALSE;
|
||||
PRBool nsTextTransformer::sWordSelectEatSpaceAfter = PR_FALSE;
|
||||
PRBool nsTextTransformer::sWordSelectStopAtPunctuation = PR_FALSE;
|
||||
static const char kWordSelectPref[] = "layout.word_select.stop_at_punctuation";
|
||||
static const char kWordSelectEatSpaceAfterPref[] = "layout.word_select.eat_space_to_next_word";
|
||||
static const char kWordSelectStopAtPunctuationPref[] = "layout.word_select.stop_at_punctuation";
|
||||
|
||||
// static
|
||||
int
|
||||
nsTextTransformer::WordSelectPrefCallback(const char* aPref, void* aClosure)
|
||||
{
|
||||
sWordSelectStopAtPunctuation = nsContentUtils::GetBoolPref(kWordSelectPref);
|
||||
sWordSelectEatSpaceAfter = nsContentUtils::GetBoolPref(kWordSelectEatSpaceAfterPref);
|
||||
sWordSelectStopAtPunctuation = nsContentUtils::GetBoolPref(kWordSelectStopAtPunctuationPref);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -122,10 +125,14 @@ nsTextTransformer::Initialize()
|
||||
if ( !sWordSelectListenerPrefChecked ) {
|
||||
sWordSelectListenerPrefChecked = PR_TRUE;
|
||||
|
||||
sWordSelectEatSpaceAfter =
|
||||
nsContentUtils::GetBoolPref(kWordSelectEatSpaceAfterPref);
|
||||
sWordSelectStopAtPunctuation =
|
||||
nsContentUtils::GetBoolPref(kWordSelectPref);
|
||||
nsContentUtils::GetBoolPref(kWordSelectStopAtPunctuationPref);
|
||||
|
||||
nsContentUtils::RegisterPrefCallback(kWordSelectPref,
|
||||
nsContentUtils::RegisterPrefCallback(kWordSelectEatSpaceAfterPref,
|
||||
WordSelectPrefCallback, nsnull);
|
||||
nsContentUtils::RegisterPrefCallback(kWordSelectStopAtPunctuationPref,
|
||||
WordSelectPrefCallback, nsnull);
|
||||
}
|
||||
|
||||
@@ -146,6 +153,11 @@ static nsresult EnsureCaseConv()
|
||||
void
|
||||
nsTextTransformer::Shutdown()
|
||||
{
|
||||
nsContentUtils::UnregisterPrefCallback(kWordSelectEatSpaceAfterPref,
|
||||
WordSelectPrefCallback, nsnull);
|
||||
nsContentUtils::UnregisterPrefCallback(kWordSelectStopAtPunctuationPref,
|
||||
WordSelectPrefCallback, nsnull);
|
||||
|
||||
if (gCaseConv) {
|
||||
nsServiceManager::ReleaseService(kUnicharUtilCID, gCaseConv);
|
||||
gCaseConv = nsnull;
|
||||
|
||||
@@ -269,6 +269,13 @@ public:
|
||||
return mTransformBuf.GetBufferLength();
|
||||
}
|
||||
|
||||
PRBool GetWordSelectEatSpaceAfter() {
|
||||
return sWordSelectEatSpaceAfter;
|
||||
}
|
||||
|
||||
PRBool GetWordSelectStopAtPunctuation() {
|
||||
return sWordSelectStopAtPunctuation;
|
||||
}
|
||||
|
||||
static nsresult Initialize();
|
||||
static void Shutdown();
|
||||
@@ -351,6 +358,7 @@ protected:
|
||||
// prefs used to configure the double-click word selection behavior
|
||||
static int WordSelectPrefCallback(const char* aPref, void* aClosure);
|
||||
static PRBool sWordSelectListenerPrefChecked; // have we read the prefs yet?
|
||||
static PRBool sWordSelectEatSpaceAfter; // should we include whitespace up to next word?
|
||||
static PRBool sWordSelectStopAtPunctuation; // should we stop at punctuation?
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -788,10 +788,6 @@ protected:
|
||||
PRBool aGetTextDimensions/* true=get dimensions false = return length up to aDimensionsResult->width size*/);
|
||||
nsresult GetContentAndOffsetsForSelection(nsPresContext* aPresContext,nsIContent **aContent, PRInt32 *aOffset, PRInt32 *aLength);
|
||||
|
||||
// prefs used to configure the double-click word selection behavior
|
||||
static PRPackedBool sWordSelectPrefInited; // have we read the prefs yet?
|
||||
static PRPackedBool sWordSelectEatSpaceAfter; // should we include whitespace up to next word?
|
||||
|
||||
void AdjustSelectionPointsForBidi(SelectionDetails *sdptr,
|
||||
PRInt32 textLength,
|
||||
PRBool isRTLChars,
|
||||
@@ -817,10 +813,6 @@ NS_IMETHODIMP nsTextFrame::GetAccessible(nsIAccessible** aAccessible)
|
||||
#endif
|
||||
|
||||
|
||||
PRPackedBool nsTextFrame::sWordSelectPrefInited = PR_FALSE;
|
||||
PRPackedBool nsTextFrame::sWordSelectEatSpaceAfter = PR_TRUE;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsTextFrame::Destroy(nsPresContext* aPresContext)
|
||||
@@ -1317,13 +1309,6 @@ NS_NewContinuingTextFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
||||
|
||||
nsTextFrame::nsTextFrame()
|
||||
{
|
||||
// read in our global word selection prefs
|
||||
if ( !sWordSelectPrefInited ) {
|
||||
sWordSelectEatSpaceAfter =
|
||||
nsContentUtils::GetBoolPref("layout.word_select.eat_space_to_next_word");
|
||||
|
||||
sWordSelectPrefInited = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsTextFrame::~nsTextFrame()
|
||||
@@ -4124,7 +4109,7 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
||||
PRBool found = PR_FALSE;
|
||||
PRBool isWhitespace, wasTransformed;
|
||||
PRInt32 wordLen, contentLen;
|
||||
|
||||
PRBool wordSelectEatSpaceAfter = tx.GetWordSelectEatSpaceAfter();
|
||||
|
||||
PRBool selectable;
|
||||
PRUint8 selectStyle;
|
||||
@@ -4206,10 +4191,10 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
||||
|
||||
// On some platforms (mac, unix), we want the selection to end
|
||||
// at the end of the word (not the beginning of the next one).
|
||||
if ((sWordSelectEatSpaceAfter ? isWhitespace : !isWhitespace) || !aPos->mEatingWS) {
|
||||
if ((wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace) || !aPos->mEatingWS) {
|
||||
aPos->mContentOffset = aPos->mStartOffset + contentLen;
|
||||
keepSearching = PR_TRUE;
|
||||
aPos->mEatingWS = !sWordSelectEatSpaceAfter;
|
||||
aPos->mEatingWS = !wordSelectEatSpaceAfter;
|
||||
#ifdef IBMBIDI
|
||||
wordLen = (mState & NS_FRAME_IS_BIDI)
|
||||
? mContentOffset + mContentLength : -1;
|
||||
@@ -4218,7 +4203,7 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
if (sWordSelectEatSpaceAfter ? isWhitespace : !isWhitespace)
|
||||
if (wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
|
||||
@@ -55,14 +55,17 @@
|
||||
|
||||
|
||||
PRBool nsTextTransformer::sWordSelectListenerPrefChecked = PR_FALSE;
|
||||
PRBool nsTextTransformer::sWordSelectEatSpaceAfter = PR_FALSE;
|
||||
PRBool nsTextTransformer::sWordSelectStopAtPunctuation = PR_FALSE;
|
||||
static const char kWordSelectPref[] = "layout.word_select.stop_at_punctuation";
|
||||
static const char kWordSelectEatSpaceAfterPref[] = "layout.word_select.eat_space_to_next_word";
|
||||
static const char kWordSelectStopAtPunctuationPref[] = "layout.word_select.stop_at_punctuation";
|
||||
|
||||
// static
|
||||
int
|
||||
nsTextTransformer::WordSelectPrefCallback(const char* aPref, void* aClosure)
|
||||
{
|
||||
sWordSelectStopAtPunctuation = nsContentUtils::GetBoolPref(kWordSelectPref);
|
||||
sWordSelectEatSpaceAfter = nsContentUtils::GetBoolPref(kWordSelectEatSpaceAfterPref);
|
||||
sWordSelectStopAtPunctuation = nsContentUtils::GetBoolPref(kWordSelectStopAtPunctuationPref);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -122,10 +125,14 @@ nsTextTransformer::Initialize()
|
||||
if ( !sWordSelectListenerPrefChecked ) {
|
||||
sWordSelectListenerPrefChecked = PR_TRUE;
|
||||
|
||||
sWordSelectEatSpaceAfter =
|
||||
nsContentUtils::GetBoolPref(kWordSelectEatSpaceAfterPref);
|
||||
sWordSelectStopAtPunctuation =
|
||||
nsContentUtils::GetBoolPref(kWordSelectPref);
|
||||
nsContentUtils::GetBoolPref(kWordSelectStopAtPunctuationPref);
|
||||
|
||||
nsContentUtils::RegisterPrefCallback(kWordSelectPref,
|
||||
nsContentUtils::RegisterPrefCallback(kWordSelectEatSpaceAfterPref,
|
||||
WordSelectPrefCallback, nsnull);
|
||||
nsContentUtils::RegisterPrefCallback(kWordSelectStopAtPunctuationPref,
|
||||
WordSelectPrefCallback, nsnull);
|
||||
}
|
||||
|
||||
@@ -146,6 +153,11 @@ static nsresult EnsureCaseConv()
|
||||
void
|
||||
nsTextTransformer::Shutdown()
|
||||
{
|
||||
nsContentUtils::UnregisterPrefCallback(kWordSelectEatSpaceAfterPref,
|
||||
WordSelectPrefCallback, nsnull);
|
||||
nsContentUtils::UnregisterPrefCallback(kWordSelectStopAtPunctuationPref,
|
||||
WordSelectPrefCallback, nsnull);
|
||||
|
||||
if (gCaseConv) {
|
||||
nsServiceManager::ReleaseService(kUnicharUtilCID, gCaseConv);
|
||||
gCaseConv = nsnull;
|
||||
|
||||
@@ -269,6 +269,13 @@ public:
|
||||
return mTransformBuf.GetBufferLength();
|
||||
}
|
||||
|
||||
PRBool GetWordSelectEatSpaceAfter() {
|
||||
return sWordSelectEatSpaceAfter;
|
||||
}
|
||||
|
||||
PRBool GetWordSelectStopAtPunctuation() {
|
||||
return sWordSelectStopAtPunctuation;
|
||||
}
|
||||
|
||||
static nsresult Initialize();
|
||||
static void Shutdown();
|
||||
@@ -351,6 +358,7 @@ protected:
|
||||
// prefs used to configure the double-click word selection behavior
|
||||
static int WordSelectPrefCallback(const char* aPref, void* aClosure);
|
||||
static PRBool sWordSelectListenerPrefChecked; // have we read the prefs yet?
|
||||
static PRBool sWordSelectEatSpaceAfter; // should we include whitespace up to next word?
|
||||
static PRBool sWordSelectStopAtPunctuation; // should we stop at punctuation?
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
Reference in New Issue
Block a user