[webkit-dev] possible wrong implementation visible_units.cpp at logicalStartOfLine

Ryosuke Niwa rniwa at google.com
Fri Jul 10 12:36:37 PDT 2009


>
> trying to understand this part of the webcore code, I faced a possibly
> wrong impl:
>
> (...)
> VisiblePosition logicalStartOfLine(const VisiblePosition& c)
> {
>    VisiblePosition visPos = logicalStartPositionForLine(c);
>
>    if (visPos.isNull())
>        return c.honorEditableBoundaryAtOrAfter(visPos);
>
>    return c.honorEditableBoundaryAtOrAfter(visPos);
> }
> (...)
>
> note that  "c.honorEditableBoundaryAtOrAfter(visPos);"  will be
> executed regardless visPos being null or not. thoughts ?
>

honorEditableBoundaryAtOrAfter does check whether the visPos is null or not,
and if it's null, then it returns the original visible position, so it's
harmless (i.e. does not crash or has a side-effect).  But I'm not sure what
the caller of logicalStartOfLine is expecting; maybe we're supposed to do
something in the case visible position was null.  But assuming that the
original is correct, we don't need that if statement at all.

Did you file a bug for it?

Ryosuke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090710/725a1155/attachment.html>


More information about the webkit-dev mailing list