adding a couple of prefs to make word selection better on mac. doesn't eat whitespace to next word and stops at punctuation. r=mjudge/sr=sfraser. bug# 98546
This commit is contained in:
Родитель
735e3c118a
Коммит
4d06bf2721
|
@ -783,6 +783,10 @@ protected:
|
|||
PRBool aGetTextDimensions/* true=get dimensions false = return length up to aDimensionsResult->width size*/);
|
||||
nsresult GetContentAndOffsetsForSelection(nsIPresContext* 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?
|
||||
|
||||
#ifdef IBMBIDI
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
|
@ -806,6 +810,11 @@ NS_IMETHODIMP nsTextFrame::GetAccessible(nsIAccessible** aAccessible)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
PRPackedBool nsTextFrame::sWordSelectPrefInited = PR_FALSE;
|
||||
PRPackedBool nsTextFrame::sWordSelectEatSpaceAfter = PR_TRUE;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsTextFrame::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
|
@ -1251,6 +1260,16 @@ NS_NewContinuingTextFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
|||
|
||||
nsTextFrame::nsTextFrame()
|
||||
{
|
||||
// read in our global word selection prefs
|
||||
if ( !sWordSelectPrefInited ) {
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
PRBool temp = PR_FALSE;
|
||||
prefService->GetBoolPref("layout.word_select.eat_space_to_next_word", &temp);
|
||||
sWordSelectEatSpaceAfter = temp;
|
||||
}
|
||||
sWordSelectPrefInited = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsTextFrame::~nsTextFrame()
|
||||
|
@ -4055,37 +4074,44 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
|||
|
||||
if ((aPos->mEatingWS && isWhitespace) || !aPos->mEatingWS){
|
||||
aPos->mContentOffset = aPos->mStartOffset + contentLen;
|
||||
//check for whitespace next.
|
||||
keepSearching = PR_TRUE;
|
||||
aPos->mEatingWS = PR_TRUE;
|
||||
if (!isWhitespace){
|
||||
while (tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE))
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
if (isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
}
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else //we just need to jump the space, done here
|
||||
{
|
||||
while(tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE))
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
// check for whitespace next. On some platforms (mac), we want the selection to end
|
||||
// at the end of the word (not the beginning of the next one), so don't slurp up any extra whitespace.
|
||||
if ( sWordSelectEatSpaceAfter ) {
|
||||
keepSearching = PR_TRUE;
|
||||
aPos->mEatingWS = PR_TRUE;
|
||||
if (!isWhitespace){
|
||||
while (tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE))
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
if (isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
}
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else //we just need to jump the space, done here
|
||||
{
|
||||
while(tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE))
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
|
||||
if (isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
}
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
if (isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
}
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
} // if we should eat space to the next word
|
||||
else {
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else if (aPos->mEatingWS)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,12 @@
|
|||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsICaseConversion.h"
|
||||
#include "prenv.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
|
||||
PRPackedBool nsTextTransformer::sWordSelectPrefInited = PR_FALSE;
|
||||
PRPackedBool nsTextTransformer::sWordSelectStopAtPunctuation = PR_FALSE;
|
||||
|
||||
|
||||
nsAutoTextBuffer::nsAutoTextBuffer()
|
||||
: mBuffer(mAutoBuffer),
|
||||
|
@ -102,6 +108,18 @@ nsresult
|
|||
nsTextTransformer::Initialize()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// read in our global word selection prefs
|
||||
if ( !sWordSelectPrefInited ) {
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
PRBool temp = PR_FALSE;
|
||||
prefService->GetBoolPref("layout.word_select.stop_at_punctuation", &temp);
|
||||
sWordSelectStopAtPunctuation = temp;
|
||||
}
|
||||
sWordSelectPrefInited = PR_TRUE;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
static nsresult EnsureCaseConv()
|
||||
|
@ -377,6 +395,10 @@ nsTextTransformer::ScanNormalAsciiText_F_ForWordBreak(PRInt32* aWordLen,
|
|||
else if (XP_IS_SPACE(ch)) {
|
||||
break;
|
||||
}
|
||||
else if (sWordSelectStopAtPunctuation && !isalnum(ch)) {
|
||||
// on some platforms, punctuation breaks words too.
|
||||
break;
|
||||
}
|
||||
else if (IS_DISCARDED(ch)) {
|
||||
// Strip discarded characters from the transformed output
|
||||
continue;
|
||||
|
|
|
@ -275,6 +275,10 @@ protected:
|
|||
// Flag for controling mLeaveAsAscii, mHasMultibyte, mTransformedTextIsAscii
|
||||
PRUint8 mFlags;
|
||||
|
||||
// prefs used to configure the double-click word selection behavior
|
||||
static PRPackedBool sWordSelectPrefInited; // have we read the prefs yet?
|
||||
static PRPackedBool sWordSelectStopAtPunctuation; // should we stop at punctuation?
|
||||
|
||||
#ifdef DEBUG
|
||||
static void SelfTest(nsILineBreaker* aLineBreaker,
|
||||
nsIWordBreaker* aWordBreaker,
|
||||
|
|
|
@ -783,6 +783,10 @@ protected:
|
|||
PRBool aGetTextDimensions/* true=get dimensions false = return length up to aDimensionsResult->width size*/);
|
||||
nsresult GetContentAndOffsetsForSelection(nsIPresContext* 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?
|
||||
|
||||
#ifdef IBMBIDI
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
|
@ -806,6 +810,11 @@ NS_IMETHODIMP nsTextFrame::GetAccessible(nsIAccessible** aAccessible)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
PRPackedBool nsTextFrame::sWordSelectPrefInited = PR_FALSE;
|
||||
PRPackedBool nsTextFrame::sWordSelectEatSpaceAfter = PR_TRUE;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsTextFrame::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
|
@ -1251,6 +1260,16 @@ NS_NewContinuingTextFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
|||
|
||||
nsTextFrame::nsTextFrame()
|
||||
{
|
||||
// read in our global word selection prefs
|
||||
if ( !sWordSelectPrefInited ) {
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
PRBool temp = PR_FALSE;
|
||||
prefService->GetBoolPref("layout.word_select.eat_space_to_next_word", &temp);
|
||||
sWordSelectEatSpaceAfter = temp;
|
||||
}
|
||||
sWordSelectPrefInited = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsTextFrame::~nsTextFrame()
|
||||
|
@ -4055,37 +4074,44 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
|||
|
||||
if ((aPos->mEatingWS && isWhitespace) || !aPos->mEatingWS){
|
||||
aPos->mContentOffset = aPos->mStartOffset + contentLen;
|
||||
//check for whitespace next.
|
||||
keepSearching = PR_TRUE;
|
||||
aPos->mEatingWS = PR_TRUE;
|
||||
if (!isWhitespace){
|
||||
while (tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE))
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
if (isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
}
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else //we just need to jump the space, done here
|
||||
{
|
||||
while(tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE))
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
// check for whitespace next. On some platforms (mac), we want the selection to end
|
||||
// at the end of the word (not the beginning of the next one), so don't slurp up any extra whitespace.
|
||||
if ( sWordSelectEatSpaceAfter ) {
|
||||
keepSearching = PR_TRUE;
|
||||
aPos->mEatingWS = PR_TRUE;
|
||||
if (!isWhitespace){
|
||||
while (tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE))
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
if (isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
}
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else //we just need to jump the space, done here
|
||||
{
|
||||
while(tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE))
|
||||
{
|
||||
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
|
||||
goto TryNextFrame;
|
||||
|
||||
if (isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
}
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
if (isWhitespace)
|
||||
aPos->mContentOffset += contentLen;
|
||||
else
|
||||
break;
|
||||
}
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
} // if we should eat space to the next word
|
||||
else {
|
||||
keepSearching = PR_FALSE;
|
||||
found = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else if (aPos->mEatingWS)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,12 @@
|
|||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsICaseConversion.h"
|
||||
#include "prenv.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
|
||||
PRPackedBool nsTextTransformer::sWordSelectPrefInited = PR_FALSE;
|
||||
PRPackedBool nsTextTransformer::sWordSelectStopAtPunctuation = PR_FALSE;
|
||||
|
||||
|
||||
nsAutoTextBuffer::nsAutoTextBuffer()
|
||||
: mBuffer(mAutoBuffer),
|
||||
|
@ -102,6 +108,18 @@ nsresult
|
|||
nsTextTransformer::Initialize()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// read in our global word selection prefs
|
||||
if ( !sWordSelectPrefInited ) {
|
||||
nsCOMPtr<nsIPref> prefService ( do_GetService(NS_PREF_CONTRACTID) );
|
||||
if ( prefService ) {
|
||||
PRBool temp = PR_FALSE;
|
||||
prefService->GetBoolPref("layout.word_select.stop_at_punctuation", &temp);
|
||||
sWordSelectStopAtPunctuation = temp;
|
||||
}
|
||||
sWordSelectPrefInited = PR_TRUE;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
static nsresult EnsureCaseConv()
|
||||
|
@ -377,6 +395,10 @@ nsTextTransformer::ScanNormalAsciiText_F_ForWordBreak(PRInt32* aWordLen,
|
|||
else if (XP_IS_SPACE(ch)) {
|
||||
break;
|
||||
}
|
||||
else if (sWordSelectStopAtPunctuation && !isalnum(ch)) {
|
||||
// on some platforms, punctuation breaks words too.
|
||||
break;
|
||||
}
|
||||
else if (IS_DISCARDED(ch)) {
|
||||
// Strip discarded characters from the transformed output
|
||||
continue;
|
||||
|
|
|
@ -275,6 +275,10 @@ protected:
|
|||
// Flag for controling mLeaveAsAscii, mHasMultibyte, mTransformedTextIsAscii
|
||||
PRUint8 mFlags;
|
||||
|
||||
// prefs used to configure the double-click word selection behavior
|
||||
static PRPackedBool sWordSelectPrefInited; // have we read the prefs yet?
|
||||
static PRPackedBool sWordSelectStopAtPunctuation; // should we stop at punctuation?
|
||||
|
||||
#ifdef DEBUG
|
||||
static void SelfTest(nsILineBreaker* aLineBreaker,
|
||||
nsIWordBreaker* aWordBreaker,
|
||||
|
|
|
@ -580,3 +580,7 @@ pref("bidi.characterset", 1);
|
|||
|
||||
|
||||
pref("browser.throbber.url","chrome://navigator-region/locale/region.properties");
|
||||
|
||||
// used for double-click word selection behavior. Mac will override.
|
||||
pref("layout.word_select.eat_space_to_next_word", true);
|
||||
pref("layout.word_select.stop_at_punctuation", false);
|
||||
|
|
|
@ -44,6 +44,13 @@ pref("ui.key.saveLink.shift", false); // true = shift, false = meta
|
|||
pref("editor.use_html_editor", false);
|
||||
pref("editor.use_image_editor", false);
|
||||
|
||||
// override double-click word selection behavior.
|
||||
pref("layout.word_select.eat_space_to_next_word", false);
|
||||
pref("layout.word_select.stop_at_punctuation", true);
|
||||
|
||||
// should a GURL event open a new window or re-use (4.x compat)
|
||||
pref("browser.always_reuse_window", false);
|
||||
|
||||
pref("mail.notification.sound", "");
|
||||
pref("mail.close_message_window.on_delete", true);
|
||||
pref("mail.close_message_window.on_file", true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче