Closed Bug 256252 Opened 20 years ago Closed 20 years ago

ctrl+right arrow sometimes skip a word

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: ginnchen+exoracle, Assigned: ginnchen+exoracle)

References

Details

(Keywords: access)

Attachments

(4 files, 3 obsolete files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a3) Gecko/20040818
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a3) Gecko/20040818

go to http://www.mozilla.org/start/1.7/
turn on caret browsing
put caret in "Getting" of "Getting Started"
Press ctrl+right, caret move to end of word "Getting".
Press ctrl+right again, caret goes to next line


Reproducible: Always
Steps to Reproduce:
Attached file test case
simple test case
Blocks: caretnav
Keywords: access, sec508
Maybe, this bug would dissapear, if Ctrl+right would be stoping at beginings of
words (not at ends) (I wrote about this in discussion to bug 142120). But this
is only my suggestion.
(In reply to comment #2)
> Maybe, this bug would dissapear, if Ctrl+right would be stoping at beginings 
of
> words (not at ends) (I wrote about this in discussion to bug 142120). But this
> is only my suggestion.

Yes, it would disappear, but it's not linux style, try gedit, emacs.
Attached patch patch (obsolete) — Splinter Review
"aPos->mEatingWS = isWhitespace;" is overwriting "aPos->mEatingWS =
!sWordSelectEatSpaceAfter;"
so I move it into else-clause.
Assignee: aaronleventhal → ginn.chen
Status: NEW → ASSIGNED
Comment on attachment 157138 [details] [diff] [review]
patch

Aaron, would you please test it on Windows to make sure I'm not breaking?
Thanks.
Attachment #157138 - Flags: review?(aaronleventhal)
Can't you test it by changing the work breaking preference,
layout.word_select.stop_at_punctuation?
(In reply to comment #6)
> Can't you test it by changing the work breaking preference,
> layout.word_select.stop_at_punctuation?

It doesn't work well for me.
Maybe bug 193025.
(In reply to comment #7)
>(In reply to comment #6)
>>Can't you test it by changing the work breaking preference,
>>layout.word_select.stop_at_punctuation?
>It doesn't work well for me.
>Maybe bug 193025.
Ah, I see what you mean, the preference only seems to work for ctrl+left, not
ctrl+right. Perhaps another manifestation of the same bug?
In fact, neither my windows or linux nightlies ctrl+right correctly. Not only do
they both show this bug, neither of them respects the word select preference.

ctrl+left is fine on both platforms, both preference settings.
OS: Linux → All
Summary: [linux]ctrl+right arrow sometimes skip a word → ctrl+right arrow sometimes skip a word
Comment on attachment 157138 [details] [diff] [review]
patch

* I can't reproduce the original bug on Windows
* I can't see any bad effects from the patch on Windows, with either
punctuation setting
* There is a different problem on Windows. Ctrl+right stops twice before the
first character of every line. However, that seems to happen with or without
this patch. Do we have a bug filed for that?
Attachment #157138 - Flags: review?(aaronleventhal) → review?(neil.parkwaycc.co.uk)
Ctrl+right still has some problem even with this patch. I'm on Linux now.
1) It will stop at first letter of next line.
2) If there's some   ctrl+right will stop several times.
Attached patch patch v2 (obsolete) — Splinter Review
This patch works quite fine for me on Linux.
The other 2 problems are solved.
But I don't know if it works on Windows, and RTL language.
I'll try to test it tommrrow.

I really don't know why eSelectWord + eDirNext need set Amount to NoAmount.
It will cause a stop at line beginning.
Attachment #157138 - Attachment is obsolete: true
Attachment #157138 - Flags: review?(neil.parkwaycc.co.uk)
Hmm... this patch does seem to help on Linux, but not on Windows.

CC'ing someone who worked on this before to see if they can shed any light.
http://bugzilla.mozilla.org/attachment.cgi?id=146241&action=view
This test case still fails... blank <B></B> causes trouble.
I'm afraid to fix it will cause regression.
I'm trying to fix windows.
It seems that GetPrevWord/GetNextWord are not symmetry with win style.
I'm trying to simplify nsTextFrame::PeekOffset's eSelectWord section.
It needn't to be as complex as current.

But because we couldn't get information about where there's a punctuation at
begin/end of a frame, we don't know whether we need stop.
Example:
abc+abc+<b>efg</b>
abc+abc<b>efg</b>
are always having same stoppings.
This is boring.

Because the word is crossing nsFrames, and in PeekOffset() we go to next nsFrame
by recursion, nsTextTransformer is treating them as 2 words.

On linux, we usually set "stop_at_punctuation" to false, we don't have this
issue, we just care about white_space.

What's your thoughts, Neil?
Attached patch patch v3 (obsolete) — Splinter Review
this patch works for me on both Windows and Linux;
because of bug 237228, user can't switch to stop at beginning of next word or
end of this word now.
for abc+abc+<b>efg></b>, abc+abc<b>efg></b> issue, I just follow current
behaviour of ctrl+left.
Attachment #157407 - Attachment is obsolete: true
Comment on attachment 158293 [details] [diff] [review]
patch v3

review? roc
Attachment #158293 - Flags: review?(roc)
I'm lost. Can you carefully explain what was wrong with the logic in the
existing code and how you've fixed it?
Attached file linux/unix test cases
linux/unix test cases
(set layout.word_select.eat_space_to_next_word to false)
Attached file windows test cases
windows test cases
(set layout.word_select.eat_space_to_next_word to true)
roc,
I've created test cases to show what's the problems with exsiting code.
I'll explain my patch later.

But without getting bug 237228 fixed.
We need to test it on windows/linux separately.
So I suggest to get bug 237228 fixed before this one.
(and the patches have conflicts)

BTW: I found a regression of my last patch with www.nytimes.com.
caret get stuck before a certain image when pressing ctrl+right.
It is caused by removing aPos->mAmount = eSelectNoAmount; in
nsFrame::GetFrameFromDirection.
I've a workaround in nsFrame::PeekOffset.
I'll post it later.
get roc in.

patch v3 didn't solve Case 6:empty block "<b></b>" in word
I'll fix it later.
Comment on attachment 158293 [details] [diff] [review]
patch v3

Minusing to get it off my queue until it gets fixed
Attachment #158293 - Flags: review?(roc) → review-
Attached patch patch v4Splinter Review
after apply this patch, all test cases work well on both linux and windows.
Attachment #158293 - Attachment is obsolete: true
description of my patch,

Part1 nsFrame::PeekOffset
aPos->mAmount equals to eSelectCharcter or eSelectWord.
Here is the logic, caret enters non-textframe after leaving a textframe.
The non-textframe usually is an image or blankblock(<b></b>, <b><i></i></b>).
I removed the comparision between newOffset and aPos->mStartOffset,
And bring the else-clause ahead.
Because newOffset is index of mContent in its parent.
    nsIContent* newContent = mContent->GetParent();
    PRInt32 newOffset = newContent->IndexOf(mContent);
It doesn't make sense to compare it with aPos->mStartOffset.
We should just assign it to aPos->mContentOffset according to mDirection.

FYI:
In bug 240665, I added return NS_OK; into else-clause.
Sometimes, just press arrowkey again, caret may get through.
(the runpath is get aPos->mContentOffset assigned by else-clause,
 next time it will go into then-caluse)
But it's not the approach. We still have bug 259984.
After this patch, bug 259984 will gone.

Part2 nsFrame::GetFrameFromDirection
Because we've fixed Part1, we don't need set aPos->mAmount to eSelectNoAmount 
now.

Part3: nsTextFrame::PeekOffset
The most complexe part. I wish I can help you understand the code.
We've 2 styles,
style 1) wordSelectEatSpaceAfter is true, we'll stop at beginning of next word.
style 2) wordSelectEatSpaceAfter is false, we'll stop at end of word.
aPos->mEatingWS is a mark of we're eating space after a word.
The logic for style 1), 
go ahead to find whitespace, then set aPos->mEatingWS to true.
if aPos->mEatingWS is true, and we find !isWhitespace, stop immediately.
The logic for style 2),
go ahead to find !isWhitespace, then set aPos->mEatingWS to true.
(we think we've already eaten enough spaces)
if aPos->mEatingWS is true, and we find space agian, stop immediately.
Attachment #159703 - Flags: review?(roc)
Comment on attachment 159703 [details] [diff] [review]
patch v4

I have to say I don't really understand this code. Maybe you're the only one
who does :-). But as far as I understand it, it looks OK.
Attachment #159703 - Flags: superreview+
Attachment #159703 - Flags: review?(roc)
Attachment #159703 - Flags: review+
Fixed.

Checking in nsFrame.cpp;
/cvsroot/mozilla/layout/html/base/src/nsFrame.cpp,v  <--  nsFrame.cpp
new revision: 3.521; previous revision: 3.520
done
Checking in nsTextFrame.cpp;
/cvsroot/mozilla/layout/html/base/src/nsTextFrame.cpp,v  <--  nsTextFrame.cpp
new revision: 1.479; previous revision: 1.478
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Blocks: 248860
Blocks: 229867
*** Bug 259984 has been marked as a duplicate of this bug. ***
Blocks: 274857
This caused bug 304891.
*** Bug 211032 has been marked as a duplicate of this bug. ***
*** Bug 311358 has been marked as a duplicate of this bug. ***
*** Bug 236042 has been marked as a duplicate of this bug. ***
Blocks: word-select
Depends on: 346445
Component: Keyboard: Navigation → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: