Bug 168565 - Simple line layout: Implement positionForPoint.
Summary: Simple line layout: Implement positionForPoint.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-18 16:22 PST by zalan
Modified: 2017-02-19 08:26 PST (History)
12 users (show)

See Also:


Attachments
Patch (12.81 KB, patch)
2017-02-18 16:43 PST, zalan
no flags Details | Formatted Diff | Diff
Patch (12.90 KB, patch)
2017-02-18 17:09 PST, zalan
no flags Details | Formatted Diff | Diff
Patch (13.02 KB, patch)
2017-02-19 07:31 PST, zalan
no flags Details | Formatted Diff | Diff
Patch (13.01 KB, patch)
2017-02-19 08:07 PST, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zalan 2017-02-18 16:22:28 PST
for single RenderText only at this point.
Comment 1 Radar WebKit Bug Importer 2017-02-18 16:23:01 PST
<rdar://problem/30593370>
Comment 2 zalan 2017-02-18 16:43:29 PST
Created attachment 302061 [details]
Patch
Comment 3 zalan 2017-02-18 16:46:01 PST
Comment on attachment 302061 [details]
Patch

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

> Source/WebCore/rendering/SimpleLineLayoutResolver.cpp:217
> +    if (it.lineIndex() > lineIndex)
> +        return --it;
> +    // Now we have a candidate run.
> +    // Find the last run that still contains this point (taking overlapping runs with odd word spacing values into account).
> +    while (it != end() && (*it).logicalLeft() <= x && lineIndex == it.lineIndex())

The if condition could be eliminated by changing the while to this
while (it != end() && lineIndex == it.lineIndex() && (*it).logicalLeft() <= x)
but this way it's a bit more implicit. I don't really have a preference on this.
Comment 4 zalan 2017-02-18 17:09:12 PST
Created attachment 302062 [details]
Patch
Comment 5 Antti Koivisto 2017-02-19 00:47:36 PST
Comment on attachment 302062 [details]
Patch

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

> Source/WebCore/rendering/RenderBlockFlow.cpp:3553
> +    if (!simpleLineLayout() || firstChild() != lastChild() || !is<RenderText>(firstChild()))

It might be good to have a comment explaining the tests (beyond just having !simpleLineLayout()).

> Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp:220
> +unsigned positionForPoint(const LayoutPoint& point, const RenderText& renderer, const Layout& layout)

Might be better to call this something else since it doesn't return a Position object (unlike the RenderText version). Maybe textOffsetForPoint or similar?

> Source/WebCore/rendering/SimpleLineLayoutResolver.cpp:204
> +    auto it = Iterator(begin());

Can't this just be 

auto it = begin();

?
Comment 6 zalan 2017-02-19 07:31:37 PST
Created attachment 302076 [details]
Patch
Comment 7 Antti Koivisto 2017-02-19 08:04:00 PST
Comment on attachment 302076 [details]
Patch

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

> Source/WebCore/rendering/SimpleLineLayoutResolver.cpp:201
> +        return Iterator(end());

return end()?
Comment 8 zalan 2017-02-19 08:07:06 PST
Created attachment 302078 [details]
Patch
Comment 9 WebKit Commit Bot 2017-02-19 08:26:04 PST
Comment on attachment 302078 [details]
Patch

Clearing flags on attachment: 302078

Committed r212615: <http://trac.webkit.org/changeset/212615>
Comment 10 WebKit Commit Bot 2017-02-19 08:26:11 PST
All reviewed patches have been landed.  Closing bug.