Bug 223781 - Allow some image overlay content to render in fully transparent image elements
Summary: Allow some image overlay content to render in fully transparent image elements
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-03-25 21:53 PDT by Wenson Hsieh
Modified: 2021-03-26 14:23 PDT (History)
9 users (show)

See Also:


Attachments
Patch (28.38 KB, patch)
2021-03-26 08:06 PDT, Wenson Hsieh
thorton: review+
Details | Formatted Diff | Diff
Patch for landing (28.62 KB, patch)
2021-03-26 12:53 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2021-03-25 21:53:54 PDT
.
Comment 1 Wenson Hsieh 2021-03-26 08:06:31 PDT
Created attachment 424356 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2021-03-26 08:06:38 PDT
<rdar://problem/75886351>
Comment 3 Tim Horton 2021-03-26 12:14:59 PDT
Comment on attachment 424356 [details]
Patch

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

> Source/WebCore/page/ImageOverlayController.cpp:86
> +        if (overlayHostRenderer->style().opacity() > 0.01)
> +            return nullptr;

This is sneakily hidden, and I almost missed it. Maybe possible to make it obvious that this is all inert in the "normal" case?
Comment 4 Chris Dumez 2021-03-26 12:19:28 PDT
Comment on attachment 424356 [details]
Patch

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

> Source/WebCore/dom/Document.cpp:2624
>      if (auto* page = this->page()) {

Can we merge with this block?

> Source/WebCore/page/ImageOverlayController.cpp:54
> +ImageOverlayController::~ImageOverlayController() = default;

Why do we need this destructor?

> Source/WebCore/page/ImageOverlayController.h:46
> +    ImageOverlayController(Page&);

explicit?

> Source/WebCore/page/ImageOverlayController.h:53
> +    void willMoveToPage(PageOverlay&, Page*) override;

final

> Source/WebCore/page/ImageOverlayController.h:54
> +    void didMoveToPage(PageOverlay&, Page*) override { }

final

> Source/WebCore/page/ImageOverlayController.h:55
> +    void drawRect(PageOverlay&, GraphicsContext&, const IntRect& dirtyRect) override;

final
Comment 5 Wenson Hsieh 2021-03-26 12:30:47 PDT
Comment on attachment 424356 [details]
Patch

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

>> Source/WebCore/dom/Document.cpp:2624
>>      if (auto* page = this->page()) {
> 
> Can we merge with this block?

Yes — done!

>> Source/WebCore/page/ImageOverlayController.cpp:54
>> +ImageOverlayController::~ImageOverlayController() = default;
> 
> Why do we need this destructor?

Whoops, we don't! Good catch.

>> Source/WebCore/page/ImageOverlayController.cpp:86
>> +            return nullptr;
> 
> This is sneakily hidden, and I almost missed it. Maybe possible to make it obvious that this is all inert in the "normal" case?

Yeah, that's a good point. I'm planning to split this bit out into a helper method, with a brief comment:

```
bool ImageOverlayController::shouldUsePageOverlayToPaintSelection(const RenderElement& renderer)
{
    // If the selection is already painted (with nonzero opacity) in the overlay host's renderer,
    // then we don't need to fall back to a page overlay to paint the selection.
    return renderer.style().opacity() <= 0.01;
}
```

>> Source/WebCore/page/ImageOverlayController.h:46
>> +    ImageOverlayController(Page&);
> 
> explicit?

👍🏻

>> Source/WebCore/page/ImageOverlayController.h:53
>> +    void willMoveToPage(PageOverlay&, Page*) override;
> 
> final

👍🏻

>> Source/WebCore/page/ImageOverlayController.h:54
>> +    void didMoveToPage(PageOverlay&, Page*) override { }
> 
> final

👍🏻

>> Source/WebCore/page/ImageOverlayController.h:55
>> +    void drawRect(PageOverlay&, GraphicsContext&, const IntRect& dirtyRect) override;
> 
> final

👍🏻
Comment 6 Wenson Hsieh 2021-03-26 12:53:03 PDT
Created attachment 424393 [details]
Patch for landing
Comment 7 EWS 2021-03-26 14:23:24 PDT
Committed r275112: <https://commits.webkit.org/r275112>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 424393 [details].