Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Issue 2727853002: [css-display] Support display: contents pseudo-elements.

Created:
3 years, 9 months ago by emilio
Modified:
3 years, 8 months ago
Reviewers:
rune
CC:
chromium-reviews, pdr+renderingwatchlist_chromium.org, szager+layoutwatch_chromium.org, blink-reviews-style_chromium.org, zoltan1, blink-reviews-css, sof, eae+blinkwatch, leviw+renderwatch, blink-reviews-dom_chromium.org, dglazkov+blink, apavlov+blink_chromium.org, jchaffraix+rendering, darktears, blink-reviews, blink-reviews-layout_chromium.org, rwlbuis
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

[css-display] Support display: contents pseudo-elements. This commit moves part of the pseudo-element caching logic to Element, in order to support PseudoIdBefore and PseudoIdAfter for display: contents. BUG=657748 Signed-off-by: Emilio Cobos Álvarez <ecobos@igalia.com>;

Patch Set 1 #

Patch Set 2 : [css-display] Support display: contents pseudo-elements. #

Patch Set 3 : [css-display] Support display: contents pseudo-elements. #

Patch Set 4 : [css-display] Support display: contents pseudo-elements. #

Patch Set 5 : [css-display] Support display: contents pseudo-elements. #

Total comments: 16

Patch Set 6 : Proper display: contents for pseudos, instead of inline #

Patch Set 7 : Added missing include that made some builds fail #

Patch Set 8 : Don't assume we only do style recalcs for ::before and ::after #

Patch Set 9 : WIP: Pseudo in m_node. #

Patch Set 10 : Now without debugging code #

Patch Set 11 : Kill the (hopefully latest) remaining uses of "document to a text node means anonymous object". #

Patch Set 12 : Kill the (hopefully latest) remaining uses of "document to a text node means anonymous object". #

Patch Set 13 : Add missing nullcheck (whoops). #

Total comments: 9

Patch Set 14 : [css-display] Support display: contents pseudos. #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+141 lines, -42 lines) Patch
M third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +15 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Element.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Element.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 4 chunks +33 lines, -13 lines 2 comments Download
M third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -1 line 2 comments Download
M third_party/WebKit/Source/core/dom/PseudoElement.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +63 lines, -21 lines 4 comments Download
M third_party/WebKit/Source/core/layout/LayoutCounter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutImage.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutObject.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +13 lines, -0 lines 6 comments Download
M third_party/WebKit/Source/core/layout/LayoutObject.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +6 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutQuote.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutQuote.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutTextFragment.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 74 (59 generated)
emilio
Hi rune, if you had the time and could review this, that'd be great :) ...
3 years, 9 months ago (2017-03-02 14:04:25 UTC) #20
rune
https://codereview.chromium.org/2727853002/diff/80001/third_party/WebKit/Source/core/dom/Element.cpp File third_party/WebKit/Source/core/dom/Element.cpp (right): https://codereview.chromium.org/2727853002/diff/80001/third_party/WebKit/Source/core/dom/Element.cpp#newcode1581 third_party/WebKit/Source/core/dom/Element.cpp:1581: return isPseudoElement(); Why? Pseudo elements on which display applies ...
3 years, 9 months ago (2017-03-06 10:13:33 UTC) #23
emilio
https://codereview.chromium.org/2727853002/diff/80001/third_party/WebKit/Source/core/dom/Element.cpp File third_party/WebKit/Source/core/dom/Element.cpp (right): https://codereview.chromium.org/2727853002/diff/80001/third_party/WebKit/Source/core/dom/Element.cpp#newcode1581 third_party/WebKit/Source/core/dom/Element.cpp:1581: return isPseudoElement(); On 2017/03/06 10:13:33, rune wrote: > Why? ...
3 years, 9 months ago (2017-03-06 16:52:09 UTC) #24
emilio
Sorry, forgot to reply to this one. https://codereview.chromium.org/2727853002/diff/80001/third_party/WebKit/Source/core/dom/Element.cpp File third_party/WebKit/Source/core/dom/Element.cpp (right): https://codereview.chromium.org/2727853002/diff/80001/third_party/WebKit/Source/core/dom/Element.cpp#newcode2075 third_party/WebKit/Source/core/dom/Element.cpp:2075: elementRareData()->clearComputedStyle(); On ...
3 years, 9 months ago (2017-03-06 17:03:47 UTC) #25
rune
https://codereview.chromium.org/2727853002/diff/80001/third_party/WebKit/Source/core/dom/Element.cpp File third_party/WebKit/Source/core/dom/Element.cpp (right): https://codereview.chromium.org/2727853002/diff/80001/third_party/WebKit/Source/core/dom/Element.cpp#newcode1581 third_party/WebKit/Source/core/dom/Element.cpp:1581: return isPseudoElement(); On 2017/03/06 16:52:09, emilio wrote: > On ...
3 years, 9 months ago (2017-03-07 13:46:02 UTC) #26
emilio
I've made display: contents work for pseudos instead of doing the same as Gecko (haven't ...
3 years, 9 months ago (2017-03-07 22:07:10 UTC) #29
emilio
On 2017/03/07 22:07:10, emilio wrote: > I've made display: contents work for pseudos instead of ...
3 years, 9 months ago (2017-03-08 14:22:59 UTC) #40
emilio
On 2017/03/08 14:22:59, emilio wrote: > On 2017/03/07 22:07:10, emilio wrote: > > I've made ...
3 years, 9 months ago (2017-03-08 15:45:50 UTC) #42
emilio
This is green now and should be landable modulo the first-letter TODO (and a lot ...
3 years, 9 months ago (2017-03-09 22:33:03 UTC) #64
rune
Generally, looks sane to me. You should be able to split out a few CLs ...
3 years, 9 months ago (2017-03-13 10:29:50 UTC) #65
rune
https://codereview.chromium.org/2727853002/diff/230001/third_party/WebKit/Source/core/layout/LayoutQuote.h File third_party/WebKit/Source/core/layout/LayoutQuote.h (right): https://codereview.chromium.org/2727853002/diff/230001/third_party/WebKit/Source/core/layout/LayoutQuote.h#newcode96 third_party/WebKit/Source/core/layout/LayoutQuote.h:96: // Livedness is the same as m_node, so this ...
3 years, 9 months ago (2017-03-13 10:36:00 UTC) #66
emilio
On 2017/03/13 10:29:50, rune wrote: > Generally, looks sane to me. You should be able ...
3 years, 9 months ago (2017-03-13 13:28:02 UTC) #67
emilio
https://codereview.chromium.org/2727853002/diff/230001/third_party/WebKit/Source/core/dom/Element.cpp File third_party/WebKit/Source/core/dom/Element.cpp (right): https://codereview.chromium.org/2727853002/diff/230001/third_party/WebKit/Source/core/dom/Element.cpp#newcode1581 third_party/WebKit/Source/core/dom/Element.cpp:1581: return isPseudoElement(); On 2017/03/13 10:29:50, rune wrote: > What ...
3 years, 9 months ago (2017-03-13 13:28:31 UTC) #68
rune
https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Source/core/dom/Element.cpp File third_party/WebKit/Source/core/dom/Element.cpp (right): https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Source/core/dom/Element.cpp#newcode3422 third_party/WebKit/Source/core/dom/Element.cpp:3422: bool Element::canHaveGeneratedPseudo(PseudoId pseudoId) const { canHavePseudoElement() or canGeneratePseudoElement() sounds ...
3 years, 8 months ago (2017-04-04 14:23:41 UTC) #73
emilio
3 years, 8 months ago (2017-04-04 15:09:18 UTC) #74
https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
File third_party/WebKit/Source/core/dom/Element.cpp (right):

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/dom/Element.cpp:3422: bool
Element::canHaveGeneratedPseudo(PseudoId pseudoId) const {
On 2017/04/04 14:23:41, rune wrote:
> canHavePseudoElement() or canGeneratePseudoElement() sounds better to me.

Acknowledged.

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
File third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp (right):

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp:306:
remainingLength);
On 2017/04/04 14:23:41, rune wrote:
> I don't understand this. What is an ownerPseudoElement? Is it something
specific
> to first-letter?

So this is specific to first-letter because first-letter does this hacky thing
where it splits a text fragment into two. If that fragment happens to be
generated content inside a display: contents pseudo-element, we lost track of
the only hint that allows us to find them.

Perhaps I can take advantage of generated content always creating a text
fragment and mutate it instead, which may be cleaner and remove a bunch of
complexity. Let me try that.

Also, if we can guarantee that those LayoutObjects don't go away, we could just
track generated content in a std::vector<LayoutObject*> inside the
pseudo-element when it's a display: contents pseudo, but that sounds flacky.

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
File third_party/WebKit/Source/core/dom/PseudoElement.cpp (right):

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/dom/PseudoElement.cpp:154: static bool
isGeneratedContentLike(LayoutObject* layoutObject) {
On 2017/04/04 14:23:41, rune wrote:
> Why not call it isGeneratedContent?

Sounds good to me, yeah.

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/dom/PseudoElement.cpp:202: :
child->previousInPreOrder(layoutParent);
On 2017/04/04 14:23:41, rune wrote:
> Why do you need to to walk descendants here?
> 
> In general, this code is hard to follow. I think it needs some documentation.
> Are anonymous table layout objects handled here? How do you know the
difference
> between an anonymous table wrapper for generated content and one for normal
dom
> nodes? Are they marked as being generated for the pseudo element as well?

The idea is to handle them, yeah. Right now I don't think they're marked as
such, let me add tests for those.

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
File third_party/WebKit/Source/core/layout/LayoutObject.h (right):

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/layout/LayoutObject.h:548: // NB: This also
handles anonymous generated content for a given
On 2017/04/04 14:23:41, rune wrote:
> What is anonymous generated content?

It's my ability to badly word comments. I meant anonymous layout objects for
generated ::before or after (that's why we look directly at m_node and not
node()). Will reword if this ends up being needed.

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/layout/LayoutObject.h:553: bool
isPseudoElementGeneratedContentFor(const PseudoElement&) const;
On 2017/04/04 14:23:41, rune wrote:
> This name is incomprehensible. It means that this layout object is generated
> content for the passed in pseudo element (::before or ::after)?

Yeah, that's the idea. I'm terrible at naming, so I'll try to find a better name
if I can't do the ::first-line simplification for ::before and ::after.

https://codereview.chromium.org/2727853002/diff/250001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/layout/LayoutObject.h:2075: void
setPseudoForAnonymous(PseudoElement& pseudo) {
On 2017/04/04 14:23:41, rune wrote:
> This also needs a better name if possible.

Acknowledged.

Powered by Google App Engine
This is Rietveld 408576698