Changeset 293497 in webkit


Ignore:
Timestamp:
Apr 26, 2022 10:30:42 PM (3 months ago)
Author:
Antti Koivisto
Message:

::first-letter does not work if used only in shadow content
https://bugs.webkit.org/show_bug.cgi?id=220650
<rdar://problem/73477161>

Reviewed by Alan Bujtas.

Source/WebCore:

Test: fast/shadow-dom/shadow-first-line-and-letter.html

We were not setting usesFirstLetter/LinesRules bits if those pseudo-elements were used
only in shadow trees.

Fix by removing the bits. They don't seem to allow any valuable optimizations.

  • rendering/LegacyRootInlineBox.cpp:

(WebCore::LegacyRootInlineBox::verticalPositionForBox):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::lineHeight const):
(WebCore::RenderBlock::getFirstLetter):

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::mayAffectLayout const):
(WebCore::RenderInline::lineHeight const):

  • rendering/RenderLineBreak.cpp:

(WebCore::RenderLineBreak::lineHeight const):

  • rendering/RenderView.h:
  • style/StyleTreeResolver.cpp:

(WebCore::Style::TreeResolver::createAnimatedElementUpdate):
(WebCore::Style::TreeResolver::resolve):

LayoutTests:

Test case by vb@bigdot.de.

  • fast/shadow-dom/shadow-first-line-and-letter-expected.html: Added.
  • fast/shadow-dom/shadow-first-line-and-letter.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r293490 r293497  
     12022-04-26  Antti Koivisto  <antti@apple.com>
     2
     3        ::first-letter does not work if used only in shadow content
     4        https://bugs.webkit.org/show_bug.cgi?id=220650
     5        <rdar://problem/73477161>
     6
     7        Reviewed by Alan Bujtas.
     8
     9        Test case by vb@bigdot.de.
     10
     11        * fast/shadow-dom/shadow-first-line-and-letter-expected.html: Added.
     12        * fast/shadow-dom/shadow-first-line-and-letter.html: Added.
     13
    1142022-04-26  Truitt Savell  <tsavell@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r293493 r293497  
     12022-04-26  Antti Koivisto  <antti@apple.com>
     2
     3        ::first-letter does not work if used only in shadow content
     4        https://bugs.webkit.org/show_bug.cgi?id=220650
     5        <rdar://problem/73477161>
     6
     7        Reviewed by Alan Bujtas.
     8
     9        Test: fast/shadow-dom/shadow-first-line-and-letter.html
     10
     11        We were not setting usesFirstLetter/LinesRules bits if those pseudo-elements were used
     12        only in shadow trees.
     13
     14        Fix by removing the bits. They don't seem to allow any valuable optimizations.
     15
     16        * rendering/LegacyRootInlineBox.cpp:
     17        (WebCore::LegacyRootInlineBox::verticalPositionForBox):
     18        * rendering/RenderBlock.cpp:
     19        (WebCore::RenderBlock::lineHeight const):
     20        (WebCore::RenderBlock::getFirstLetter):
     21        * rendering/RenderInline.cpp:
     22        (WebCore::RenderInline::mayAffectLayout const):
     23        (WebCore::RenderInline::lineHeight const):
     24        * rendering/RenderLineBreak.cpp:
     25        (WebCore::RenderLineBreak::lineHeight const):
     26        * rendering/RenderView.h:
     27        * style/StyleTreeResolver.cpp:
     28        (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
     29        (WebCore::Style::TreeResolver::resolve):
     30
    1312022-04-26  Oriol Brufau  <obrufau@igalia.com>
    232
  • trunk/Source/WebCore/rendering/LegacyRootInlineBox.cpp

    r292054 r293497  
    799799    // This method determines the vertical position for inline elements.
    800800    bool firstLine = isFirstLine();
    801     if (firstLine && !blockFlow().view().usesFirstLineRules())
    802         firstLine = false;
    803801
    804802    // Check the cache.
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r293326 r293497  
    24592459        return RenderBox::lineHeight(firstLine, direction, linePositionMode);
    24602460
    2461     if (firstLine && view().usesFirstLineRules()) {
    2462         auto& s = firstLineStyle();
    2463         if (&s != &style())
    2464             return s.computedLineHeight();
    2465     }
    2466    
    2467     return style().computedLineHeight();
     2461    auto& lineStyle = firstLine ? firstLineStyle() : style();
     2462    return lineStyle.computedLineHeight();
    24682463}
    24692464
     
    26182613    firstLetter = nullptr;
    26192614    firstLetterContainer = nullptr;
    2620 
    2621     if (!view().usesFirstLetterRules())
    2622         return;
    26232615
    26242616    // Don't recur
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r291992 r293497  
    216216        || hasHardLineBreakChildOnly;
    217217
    218     if (!mayAffectLayout && checkFonts && view().usesFirstLineRules()) {
     218    if (!mayAffectLayout && checkFonts) {
    219219        // Have to check the first line style as well.
    220220        parentStyle = &parent()->firstLineStyle();
     
    857857LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const
    858858{
    859     if (firstLine && view().usesFirstLineRules()) {
    860         const RenderStyle& firstLineStyle = this->firstLineStyle();
    861         if (&firstLineStyle != &style())
    862             return firstLineStyle.computedLineHeight();
    863     }
    864 
    865     return style().computedLineHeight();
     859    auto& lineStyle = firstLine ? firstLineStyle() : style();
     860    return lineStyle.computedLineHeight();
    866861}
    867862
  • trunk/Source/WebCore/rendering/RenderLineBreak.cpp

    r291548 r293497  
    6767LayoutUnit RenderLineBreak::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const
    6868{
    69     if (firstLine && view().usesFirstLineRules()) {
     69    if (firstLine) {
    7070        const RenderStyle& firstLineStyle = this->firstLineStyle();
    7171        if (&firstLineStyle != &style())
  • trunk/Source/WebCore/rendering/RenderView.h

    r291992 r293497  
    129129    WEBCORE_EXPORT bool usesCompositing() const;
    130130
    131     bool usesFirstLineRules() const { return m_usesFirstLineRules; }
    132     bool usesFirstLetterRules() const { return m_usesFirstLetterRules; }
    133     void setUsesFirstLineRules(bool value) { m_usesFirstLineRules = value; }
    134     void setUsesFirstLetterRules(bool value) { m_usesFirstLetterRules = value; }
    135 
    136131    WEBCORE_EXPORT IntRect unscaledDocumentRect() const;
    137132    LayoutRect unextendedBackgroundRect() const;
     
    266261
    267262    bool m_hasSoftwareFilters { false };
    268     bool m_usesFirstLineRules { false };
    269     bool m_usesFirstLetterRules { false };
    270263    bool m_needsRepaintHackAfterCompositingLayerUpdateForDebugOverlaysOnly { false };
    271264    bool m_needsEventRegionUpdateForNonCompositedFrame { false };
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r292592 r293497  
    4646#include "RenderElement.h"
    4747#include "RenderStyle.h"
    48 #include "RenderView.h"
    4948#include "RuntimeEnabledFeatures.h"
    5049#include "Settings.h"
     
    491490    // First, we need to make sure that any new CSS animation occuring on this element has a matching WebAnimation
    492491    // on the document timeline.
    493     if (document.backForwardCacheState() == Document::NotInBackForwardCache && !document.renderView()->printing()) {
     492    if (document.backForwardCacheState() == Document::NotInBackForwardCache && !document.printing()) {
    494493        if (oldStyle && (oldStyle->hasTransitions() || newStyle->hasTransitions()))
    495494            styleable.updateCSSTransitions(*oldStyle, *newStyle);
     
    788787std::unique_ptr<Update> TreeResolver::resolve()
    789788{
    790     auto& renderView = *m_document.renderView();
    791 
    792789    Element* documentElement = m_document.documentElement();
    793790    if (!documentElement) {
     
    810807    m_parentStack.append(Parent(m_document));
    811808
    812     auto rootResolver = scope().resolver;
    813 
    814     // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
    815     renderView.setUsesFirstLineRules(renderView.usesFirstLineRules() || rootResolver->usesFirstLineRules());
    816     renderView.setUsesFirstLetterRules(renderView.usesFirstLetterRules() || rootResolver->usesFirstLetterRules());
    817 
    818809    resolveComposedTree();
    819 
    820     renderView.setUsesFirstLineRules(rootResolver->usesFirstLineRules());
    821     renderView.setUsesFirstLetterRules(rootResolver->usesFirstLetterRules());
    822810
    823811    ASSERT(m_scopeStack.size() == 1);
Note: See TracChangeset for help on using the changeset viewer.