Bug 169869 - Teach TextIndicator to estimate the background color of the given Range
Summary: Teach TextIndicator to estimate the background color of the given Range
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-03-19 17:43 PDT by Wenson Hsieh
Modified: 2017-03-21 15:04 PDT (History)
4 users (show)

See Also:


Attachments
Patch (14.94 KB, patch)
2017-03-19 18:10 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Rebased on master (14.92 KB, patch)
2017-03-20 13:49 PDT, Wenson Hsieh
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2017-03-19 17:43:23 PDT
Teach TextIndicator to give a best guess at the background color of the Range being snapshotted, falling back to a default (e.g. the document color) if the background is an image.
Comment 1 Wenson Hsieh 2017-03-19 17:44:32 PDT
<rdar://problem/31127272>
Comment 2 Wenson Hsieh 2017-03-19 18:10:17 PDT
Created attachment 304909 [details]
Patch

`wekbit-patch upload` is failing for me; attempting to upload manually.
Comment 3 Wenson Hsieh 2017-03-20 13:49:46 PDT
Created attachment 304946 [details]
Rebased on master

Rebased on master
Comment 4 Simon Fraser (smfr) 2017-03-21 13:52:03 PDT
Comment on attachment 304946 [details]
Rebased on master

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

> Source/WebCore/page/TextIndicator.cpp:232
> +    auto boundingRectForRange = IntRect(range.absoluteBoundingRect());

Maybe you want enclosingIntRect()?

> Source/WebCore/page/TextIndicator.cpp:244
> +        if (style.hasBackground() && style.backgroundColor() != Color::transparent)
> +            parentRendererBackgroundColors.append(style.backgroundColor());

Should this logic use visitedDependentColor to avoid leaking history state?
Comment 5 Wenson Hsieh 2017-03-21 14:02:17 PDT
Comment on attachment 304946 [details]
Rebased on master

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

>> Source/WebCore/page/TextIndicator.cpp:232
>> +    auto boundingRectForRange = IntRect(range.absoluteBoundingRect());
> 
> Maybe you want enclosingIntRect()?

Oh, yes, that's right. On closer inspection, simply flooring the values (by using the IntRect constructor) is wrong here.

>> Source/WebCore/page/TextIndicator.cpp:244
>> +            parentRendererBackgroundColors.append(style.backgroundColor());
> 
> Should this logic use visitedDependentColor to avoid leaking history state?

Good catch! Fixed.
Comment 6 Wenson Hsieh 2017-03-21 15:04:57 PDT
Landed in <https://trac.webkit.org/changeset/214231>