Bug 179812 - Incorrect computed style in pseudo-elements with display: contents
Summary: Incorrect computed style in pseudo-elements with display: contents
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-16 21:57 PST by Emilio Cobos Álvarez (:emilio)
Modified: 2017-11-20 04:33 PST (History)
5 users (show)

See Also:


Attachments
Patch (11.37 KB, patch)
2017-11-16 22:14 PST, Emilio Cobos Álvarez (:emilio)
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 (2.56 MB, application/zip)
2017-11-17 00:02 PST, EWS Watchlist
no flags Details
Patch (9.88 KB, patch)
2017-11-17 11:11 PST, Emilio Cobos Álvarez (:emilio)
no flags Details | Formatted Diff | Diff
Patch for landing (9.87 KB, patch)
2017-11-20 03:59 PST, Emilio Cobos Álvarez (:emilio)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Emilio Cobos Álvarez (:emilio) 2017-11-16 21:57:55 PST
Bug 178513 gave them an anon renderer as the main renderer. Unfortunately, the style of that box is exposed via getComputedStyle, so that needs to be handled somehow.
Comment 1 Emilio Cobos Álvarez (:emilio) 2017-11-16 22:14:06 PST
Created attachment 327151 [details]
Patch
Comment 2 EWS Watchlist 2017-11-17 00:02:49 PST
Comment on attachment 327151 [details]
Patch

Attachment 327151 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/5270189

New failing tests:
http/tests/appcache/resource-redirect-2.html
Comment 3 EWS Watchlist 2017-11-17 00:02:50 PST
Created attachment 327152 [details]
Archive of layout-test-results from ews105 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 4 Emilio Cobos Álvarez (:emilio) 2017-11-17 05:12:08 PST
Those look flaky and completely unrelated to this.

Antti or Ryosuke, mind reviewing? Thanks!

Please don't land this directly yet, I'll ensure the test change is upstreamed first.
Comment 5 Antti Koivisto 2017-11-17 07:12:37 PST
Comment on attachment 327151 [details]
Patch

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

> Source/WebCore/dom/PseudoElement.h:48
> +    bool hasDisplayContents() const { return m_hasDisplayContents; }
> +    void setHasDisplayContents(bool has) { m_hasDisplayContents = has; }

Instead of adding this bit and the element special cases, could we just put the original display:contents style to m_computedStyle in pseudoelement rare data?
Comment 6 Emilio Cobos Álvarez (:emilio) 2017-11-17 07:50:06 PST
(In reply to Antti Koivisto from comment #5)
> Instead of adding this bit and the element special cases, could we just put
> the original display:contents style to m_computedStyle in pseudoelement rare
> data?

You'd still need the element special cases to avoid using the renderStyle() or the renderer() unfortunately. I'm not in love with this patch either, but seemed the less-bad approach.

We can also regigger the hasDisplayContents / existingComputedStyle logic a bit more using the pseudo rare data, I guess, but that didn't sound particularly preferable to me.
Comment 7 Antti Koivisto 2017-11-17 08:42:27 PST
> You'd still need the element special cases to avoid using the renderStyle()
> or the renderer() unfortunately. I'm not in love with this patch either, but
> seemed the less-bad approach.
> 
> We can also regigger the hasDisplayContents / existingComputedStyle logic a
> bit more using the pseudo rare data, I guess, but that didn't sound
> particularly preferable to me.

Ok, we can go with this for now but I think there is too much special casing here. 

Longer term we should formalise the idea that style used for rendering and style used for getComputedStyle are two different things and we need to keep both around.
Comment 8 Antti Koivisto 2017-11-17 08:43:24 PST
I do like that this moves the display:contents special case from style resolution to render tree building.
Comment 9 Emilio Cobos Álvarez (:emilio) 2017-11-17 11:11:53 PST
Created attachment 327199 [details]
Patch
Comment 10 Emilio Cobos Álvarez (:emilio) 2017-11-17 11:12:34 PST
(In reply to Antti Koivisto from comment #7)
> Ok, we can go with this for now but I think there is too much special casing
> here. 
> 
> Longer term we should formalise the idea that style used for rendering and
> style used for getComputedStyle are two different things and we need to keep
> both around.

Actually you're right, I felt bad about the patch. I uploaded one that should be simpler and nicer :)
Comment 11 Antti Koivisto 2017-11-17 11:23:54 PST
Comment on attachment 327199 [details]
Patch

Much better! r=me
Comment 12 Emilio Cobos Álvarez (:emilio) 2017-11-20 03:59:23 PST
Created attachment 327357 [details]
Patch for landing
Comment 13 WebKit Commit Bot 2017-11-20 04:32:11 PST
Comment on attachment 327357 [details]
Patch for landing

Clearing flags on attachment: 327357

Committed r225049: <https://trac.webkit.org/changeset/225049>
Comment 14 WebKit Commit Bot 2017-11-20 04:32:13 PST
All reviewed patches have been landed.  Closing bug.
Comment 15 Radar WebKit Bug Importer 2017-11-20 04:33:37 PST
<rdar://problem/35644571>