Bug 65723 - A few purely stylistic modifications to visible_units.cpp
Summary: A few purely stylistic modifications to visible_units.cpp
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-04 15:09 PDT by Van Lam
Modified: 2011-08-05 11:01 PDT (History)
3 users (show)

See Also:


Attachments
Proposed fix (5.77 KB, patch)
2011-08-04 15:17 PDT, Van Lam
no flags Details | Formatted Diff | Diff
Revised fix (5.77 KB, patch)
2011-08-04 15:24 PDT, Van Lam
rniwa: review+
rniwa: commit-queue-
Details | Formatted Diff | Diff
Revised fix (5.78 KB, patch)
2011-08-04 15:30 PDT, Van Lam
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Van Lam 2011-08-04 15:09:53 PDT
See title
Comment 1 Van Lam 2011-08-04 15:17:01 PDT
Created attachment 102988 [details]
Proposed fix

Renamed greatestValueUnder to greatestOffsetUnder, positionIsInsideBox to positionIsInBoxButNotOnBoundary (to avoid confusion with positionIsInBox, which is just a getInlineBoxAndOffset check).
Removed use of invalidOffset as an error value in greatestOffsetUnder and smallestOffsetAbove since semantically it should only be used to check if it makes sense to compare offsets in a single box.
Comment 2 Ryosuke Niwa 2011-08-04 15:18:13 PDT
Comment on attachment 102988 [details]
Proposed fix

View in context: https://bugs.webkit.org/attachment.cgi?id=102988&action=review

> Source/WebCore/editing/visible_units.cpp:1644
> +    if (index != -1)

Probably better to check index < 0.

> Source/WebCore/editing/visible_units.cpp:1681
> +    if (index != -1)

Ditto.
Comment 3 Van Lam 2011-08-04 15:24:49 PDT
Created attachment 102991 [details]
Revised fix

Changed comparison index != -1 to index >= 0.
Comment 4 Ryosuke Niwa 2011-08-04 15:27:30 PDT
Comment on attachment 102991 [details]
Revised fix

View in context: https://bugs.webkit.org/attachment.cgi?id=102991&action=review

> Source/WebCore/editing/visible_units.cpp:1643
> +    : smallestOffsetAbove(offset, blockDirection == RTL, orderedWordBoundaries);

Oops, cq- because you forgot to indent here.
Comment 5 Van Lam 2011-08-04 15:30:49 PDT
Created attachment 102992 [details]
Revised fix

Indented. Nice catch :)
Comment 6 WebKit Review Bot 2011-08-04 16:56:37 PDT
Comment on attachment 102992 [details]
Revised fix

Clearing flags on attachment: 102992

Committed r92431: <http://trac.webkit.org/changeset/92431>
Comment 7 WebKit Review Bot 2011-08-04 16:56:41 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Darin Adler 2011-08-05 10:56:27 PDT
Comment on attachment 102992 [details]
Revised fix

View in context: https://bugs.webkit.org/attachment.cgi?id=102992&action=review

> Source/WebCore/editing/visible_units.cpp:1450
> -        return invalidOffset;
> +        return -1;

Replacing a name constant with a magic value of -1 does not seem like a style improvement to me.
Comment 9 Ryosuke Niwa 2011-08-05 11:01:38 PDT
Comment on attachment 102992 [details]
Revised fix

View in context: https://bugs.webkit.org/attachment.cgi?id=102992&action=review

>> Source/WebCore/editing/visible_units.cpp:1450
>> +        return -1;
> 
> Replacing a name constant with a magic value of -1 does not seem like a style improvement to me.

invalidOffset was supposed to be used only for offsets in inline boxes.  So this was misused here.  We can introduce new const like NotFound instead.