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