Changeset 256360 in webkit


Ignore:
Timestamp:
Feb 11, 2020 1:53:01 PM (4 years ago)
Author:
Megan Gardner
Message:

Draw underlines when specified in highlights
https://bugs.webkit.org/show_bug.cgi?id=207319

Reviewed by Simon Fraser.

Source/WebCore:

Test: http/wpt/css/css-highlight-api/highlight-text-decorations.html

When determining if we have any text decorations, currently we were only looking at the lineStyle,
but since highlights can have text decorations, they need to be considered in these calculations.

  • dom/Document.cpp:

(WebCore::Document::updateHighlightPositions):

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::collectMarkedTextsForHighlights const):
(WebCore::InlineTextBox::paintMarkedTextDecoration):

  • rendering/TextDecorationPainter.cpp:

(WebCore::TextDecorationPainter::textDecorationsInEffectForStyle):

  • rendering/TextDecorationPainter.h:

LayoutTests:

  • http/wpt/css/css-highlight-api/highlight-text-decorations-expected.html: Copied from LayoutTests/http/wpt/css/css-highlight-api/highlight-text-expected.html.
  • http/wpt/css/css-highlight-api/highlight-text-decorations.html: Added.
  • http/wpt/css/css-highlight-api/highlight-text-expected.html:
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r256353 r256360  
     12020-02-11  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Draw underlines when specified in highlights
     4        https://bugs.webkit.org/show_bug.cgi?id=207319
     5
     6        Reviewed by Simon Fraser.
     7
     8        * http/wpt/css/css-highlight-api/highlight-text-decorations-expected.html: Copied from LayoutTests/http/wpt/css/css-highlight-api/highlight-text-expected.html.
     9        * http/wpt/css/css-highlight-api/highlight-text-decorations.html: Added.
     10        * http/wpt/css/css-highlight-api/highlight-text-expected.html:
     11
    1122020-02-11  Eric Carlson  <eric.carlson@apple.com>
    213
  • trunk/LayoutTests/platform/win/TestExpectations

    r256209 r256360  
    406406# highlight API
    407407highlight/ [ Skip ]
     408http/wpt/css/css-highlight-api/ [ Skip ]
    408409
    409410# Pre-HMTL5 parser quirks only apply to the mac port for now.
     
    45204521webkit.org/b/206282 fast/text/stale-TextLayout-from-first-line.html [ ImageOnlyFailure ]
    45214522
    4522 webkit.org/b/205855 http/wpt/css/css-highlight-api/highlight-text-across-elements.html [ ImageOnlyFailure ]
    4523 webkit.org/b/205855 http/wpt/css/css-highlight-api/highlight-text-cascade.html [ ImageOnlyFailure ]
    4524 webkit.org/b/205855 http/wpt/css/css-highlight-api/highlight-text-replace.html [ ImageOnlyFailure ]
    4525 webkit.org/b/205855 http/wpt/css/css-highlight-api/highlight-text.html [ ImageOnlyFailure ]
    4526 
    45274523webkit.org/b/205856 storage/indexeddb/IDBTransaction-page-cache.html [ Pass Timeout ]
    45284524
  • trunk/Source/WebCore/ChangeLog

    r256353 r256360  
     12020-02-11  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Draw underlines when specified in highlights
     4        https://bugs.webkit.org/show_bug.cgi?id=207319
     5
     6        Reviewed by Simon Fraser.
     7
     8        Test: http/wpt/css/css-highlight-api/highlight-text-decorations.html
     9
     10        When determining if we have any text decorations, currently we were only looking at the lineStyle,
     11        but since highlights can have text decorations, they need to be considered in these calculations.
     12
     13        * dom/Document.cpp:
     14        (WebCore::Document::updateHighlightPositions):
     15        * rendering/InlineTextBox.cpp:
     16        (WebCore::InlineTextBox::paint):
     17        (WebCore::InlineTextBox::collectMarkedTextsForHighlights const):
     18        (WebCore::InlineTextBox::paintMarkedTextDecoration):
     19        * rendering/TextDecorationPainter.cpp:
     20        (WebCore::TextDecorationPainter::textDecorationsInEffectForStyle):
     21        * rendering/TextDecorationPainter.h:
     22
    1232020-02-11  Eric Carlson  <eric.carlson@apple.com>
    224
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r256196 r256360  
    623623    // Paint decorations
    624624    auto textDecorations = lineStyle.textDecorationsInEffect();
    625     if (!textDecorations.isEmpty() && paintInfo.phase != PaintPhase::Selection) {
     625    bool highlightDecorations = !collectMarkedTextsForHighlights(TextPaintPhase::Decoration).isEmpty();
     626    bool lineDecorations = !textDecorations.isEmpty();
     627    if ((lineDecorations || highlightDecorations) && paintInfo.phase != PaintPhase::Selection) {
    626628        TextRun textRun = createTextRun();
    627629        unsigned length = textRun.length();
     
    10451047        if (!renderStyle)
    10461048            continue;
     1049        if (renderStyle->textDecorationsInEffect().isEmpty() && phase == TextPaintPhase::Decoration)
     1050            continue;
    10471051        for (auto& rangeData : highlight.value->rangesData()) {
    10481052            if (rangeData->startPosition && rangeData->endPosition) {
     
    11971201
    11981202    // 2. Paint
    1199     TextDecorationPainter decorationPainter { context, lineStyle().textDecorationsInEffect(), renderer(), isFirstLine(), lineFont(), markedText.style.textDecorationStyles };
     1203    auto textDecorations = lineStyle().textDecorationsInEffect();
     1204    textDecorations.add(TextDecorationPainter::textDecorationsInEffectForStyle(markedText.style.textDecorationStyles));
     1205    TextDecorationPainter decorationPainter { context, textDecorations, renderer(), isFirstLine(), lineFont(), markedText.style.textDecorationStyles };
    12001206    decorationPainter.setInlineTextBox(this);
    12011207    decorationPainter.setWidth(snappedSelectionRect.width());
  • trunk/Source/WebCore/rendering/TextDecorationPainter.cpp

    r244115 r256360  
    388388}
    389389
     390OptionSet<TextDecoration> TextDecorationPainter::textDecorationsInEffectForStyle(const TextDecorationPainter::Styles& style)
     391{
     392    OptionSet<TextDecoration> decorations;
     393    if (style.underlineColor.isValid())
     394        decorations.add(TextDecoration::Underline);
     395    if (style.overlineColor.isValid())
     396        decorations.add(TextDecoration::Overline);
     397    if (style.linethroughColor.isValid())
     398        decorations.add(TextDecoration::LineThrough);
     399    return decorations;
     400};
     401
    390402auto TextDecorationPainter::stylesForRenderer(const RenderObject& renderer, OptionSet<TextDecoration> requestedDecorations, bool firstLineStyle, PseudoId pseudoId) -> Styles
    391403{
  • trunk/Source/WebCore/rendering/TextDecorationPainter.h

    r244115 r256360  
    6565        TextDecorationStyle linethroughStyle;
    6666    };
     67    static OptionSet<TextDecoration> textDecorationsInEffectForStyle(const Styles&);
    6768    static Styles stylesForRenderer(const RenderObject&, OptionSet<TextDecoration> requestedDecorations, bool firstLineStyle = false, PseudoId = PseudoId::None);
    6869
Note: See TracChangeset for help on using the changeset viewer.