⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 274398 in webkit


Ignore:
Timestamp:
Mar 14, 2021, 7:46:34 AM (5 years ago)
Author:
Alan Bujtas
Message:

RenderLineBreak should stay inline level box even when display property says otherwise.
https://bugs.webkit.org/show_bug.cgi?id=223151
<rdar://74339837>

Reviewed by Antti Koivisto.

In this patch we make sure that the RenderLineBreak object always stays inline.

While the display property applies to all elements (https://drafts.csswg.org/css-display/#the-display-properties), the line
break element (<br>) seems to be an exception and all browsers handle <br style="display: block"> still as an inline level element.

Renderers can (and do see RenderSVGInline::updateFromStyle) diverge from this computed display value and say they always want to
be inline level boxes. This is ensured by RenderObject::setInline/isInline function pair.

Initially there were 2 setInline() calls:
One in RenderObject::setStyle(). It dealt with "block to inline" transition and
one call in RenderBox::setStyle().
In these functions we simply set the renderer's "inInline" bit to the computed style value (setInline(style.isDisplayInlineType)).
However derived renderer classes were able to override it by implementing the ::setStyle function and
explicitly set the "isInline" bit to true/false.

Over the years the second (RenderBox::setStyle) call transitioned to RenderBoxModelObject::updateFromStyle()
and the first (RenderObject::setStyle) call got moved to normalizeTreeAfterStyleChange() and their order got flipped.

Derived renderer classes can still explicitly set the "isInline" bit by implementing the ::updateFromStyle() function
(this is similar to what we had with ::setStyle).
However since the order is flipped, the "setInline()" call in normalizeTreeAfterStyleChange() now runs after
updateFromStyle() and it may re-reset the "isInline" bit back to the computed value (hence the FIXME).

The "setInline" call in normalizeTreeAfterStyleChange() is not needed anymore since the "isInline" bit is already updated by
the time we get here (as opposed to when it was initially introduced in RenderObject::setStyle, see above).

  • rendering/RenderLineBreak.cpp:

(WebCore::RenderLineBreak::updateFromStyle):

  • rendering/updating/RenderTreeBuilder.cpp:

(WebCore::RenderTreeBuilder::normalizeTreeAfterStyleChange):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r274396 r274398  
     12021-03-14  Zalan Bujtas  <zalan@apple.com>
     2
     3        RenderLineBreak should stay inline level box even when display property says otherwise.
     4        https://bugs.webkit.org/show_bug.cgi?id=223151
     5        <rdar://74339837>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        In this patch we make sure that the RenderLineBreak object always stays inline.
     10
     11        While the display property applies to all elements (https://drafts.csswg.org/css-display/#the-display-properties), the line
     12        break element (<br>) seems to be an exception and all browsers handle <br style="display: block"> still as an inline level element.
     13
     14        Renderers can (and do see RenderSVGInline::updateFromStyle) diverge from this computed display value and say they always want to
     15        be inline level boxes. This is ensured by RenderObject::setInline/isInline function pair.
     16
     17        Initially there were 2 setInline() calls:
     18        One in RenderObject::setStyle(). It dealt with "block to inline" transition and
     19        one call in RenderBox::setStyle().
     20        In these functions we simply set the renderer's "inInline" bit to the computed style value (setInline(style.isDisplayInlineType)).
     21        However derived renderer classes were able to override it by implementing the ::setStyle function and
     22        explicitly set the "isInline" bit to true/false.
     23
     24        Over the years the second (RenderBox::setStyle) call transitioned to RenderBoxModelObject::updateFromStyle()
     25        and the first (RenderObject::setStyle) call got moved to normalizeTreeAfterStyleChange() and their order got flipped.
     26
     27        Derived renderer classes can still explicitly set the "isInline" bit by implementing the ::updateFromStyle() function
     28        (this is similar to what we had with ::setStyle).
     29        However since the order is flipped, the "setInline()" call in normalizeTreeAfterStyleChange() now runs after
     30        updateFromStyle() and it may re-reset the "isInline" bit back to the computed value (hence the FIXME).
     31
     32        The "setInline" call in normalizeTreeAfterStyleChange() is not needed anymore since the "isInline" bit is already updated by
     33        the time we get here (as opposed to when it was initially introduced in RenderObject::setStyle, see above).
     34
     35        * rendering/RenderLineBreak.cpp:
     36        (WebCore::RenderLineBreak::updateFromStyle):
     37        * rendering/updating/RenderTreeBuilder.cpp:
     38        (WebCore::RenderTreeBuilder::normalizeTreeAfterStyleChange):
     39
    1402021-03-13  Wenson Hsieh  <wenson_hsieh@apple.com>
    241
  • trunk/Source/WebCore/rendering/RenderLineBreak.cpp

    r271349 r274398  
    175175{
    176176    m_cachedLineHeight = invalidLineHeight;
     177    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isInline());
    177178}
    178179
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp

    r274278 r274398  
    579579        // having an impact. See if there is a mismatch between the parent flow's
    580580        // childrenInline() state and our state.
    581         // FIXME(186894): startsAffectingParent has clearly nothing to do with resetting the inline state.
    582         if (!is<RenderSVGInline>(renderer))
    583             renderer.setInline(renderer.style().isDisplayInlineType());
    584581        if (renderer.isInline() != renderer.parent()->childrenInline())
    585582            childFlowStateChangesAndAffectsParentBlock(renderer);
Note: See TracChangeset for help on using the changeset viewer.