[Webkit-unassigned] [Bug 65277] Make functions to find word boundaries more flexible

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Aug 27 02:35:18 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=65277





--- Comment #53 from Van Lam <vanlam at google.com>  2011-08-27 02:35:18 PST ---
(In reply to comment #51)
> I'm having fairly hard time trying to understand what the new functions do.
> 
> Let's look at nextWordBoundaryBeforeWord() for a specific example. What will it return in each of the following cases (vertical line denoting starting position)?
> 
> te|st
> test te|st test
> test |test test
> test test| test
> test        |test test
> test   |     test test
> +1|0
> test +++++++|++++++ test
> U|.S.A.
> test "te|st" test

Hi Alexey,

nextWordBoundaryBeforeWord is based off the observation that in most cases, the next word boundary from a position somePosition that lies before a word is previousBoundary(nextBoundary(nextBoundary(somePosition, _), _), _); let the underscores be the appropriate search functions passed in (next/previousWordPositionBoundary). 

Example:

Given text "a|bc def ghi" where | indicates the starting position,

call nextBoundary: a|bc def ghi -> abc| def ghi
call nextBoundary: abc| def ghi -> abc def| ghi
call previousBoundary: abc def| ghi -> abc |def ghi

This doesn't work when 1) the current position is at the end of a word or 2) when nextBoundary returns the last word boundary in the block. In the latter case, VisiblePosition() is returned to indicate that the desired word break is not in the box of the starting position.

As for the cases:

te|st -> VisiblePosition()
test te|st test -> test test |test
test |test test -> test test |test
test        |test test -> test        test |test
+1|0 -> VisiblePosition()
test +++++++|++++++ test -> test ++++++++|+++++ test
U|.S.A. -> VisiblePosition()
test "te|st" test -> test "test" |test

These are the results in Safari on Mac; results may differ slightly on other platforms as the functions eventually delegate to findNextWordFromIndex in TextBoundaries.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list