Changeset 245752 in webkit


Ignore:
Timestamp:
May 24, 2019 2:41:00 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

Plumb dark appearance down to GraphicsContext.
https://bugs.webkit.org/show_bug.cgi?id=198224
rdar://problem/51068494

Reviewed by Dean Jackson.

No test yet, as it is not testable until this gets used.

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContextStateChange::changesFromState const):
(WebCore::GraphicsContextStateChange::accumulate):
(WebCore::GraphicsContextStateChange::apply const):
(WebCore::GraphicsContextStateChange::dump const):
(WebCore::GraphicsContext::setUseDarkAppearance):

  • platform/graphics/GraphicsContext.h:

(WebCore::GraphicsContext::useDarkAppearance const):

  • rendering/TextPaintStyle.cpp:

(WebCore::TextPaintStyle::operator== const):
(WebCore::computeTextPaintStyle):
(WebCore::updateGraphicsContext):

  • rendering/TextPaintStyle.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r245748 r245752  
     12019-05-24  Timothy Hatcher  <timothy@apple.com>
     2
     3        Plumb dark appearance down to GraphicsContext.
     4        https://bugs.webkit.org/show_bug.cgi?id=198224
     5        rdar://problem/51068494
     6
     7        Reviewed by Dean Jackson.
     8
     9        No test yet, as it is not testable until this gets used.
     10
     11        * platform/graphics/GraphicsContext.cpp:
     12        (WebCore::GraphicsContextStateChange::changesFromState const):
     13        (WebCore::GraphicsContextStateChange::accumulate):
     14        (WebCore::GraphicsContextStateChange::apply const):
     15        (WebCore::GraphicsContextStateChange::dump const):
     16        (WebCore::GraphicsContext::setUseDarkAppearance):
     17        * platform/graphics/GraphicsContext.h:
     18        (WebCore::GraphicsContext::useDarkAppearance const):
     19        * rendering/TextPaintStyle.cpp:
     20        (WebCore::TextPaintStyle::operator== const):
     21        (WebCore::computeTextPaintStyle):
     22        (WebCore::updateGraphicsContext):
     23        * rendering/TextPaintStyle.h:
     24
    1252019-05-24  Youenn Fablet  <youenn@apple.com>
    226
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r243163 r245752  
    110110    CHECK_FOR_CHANGED_PROPERTY(ImageInterpolationQualityChange, imageInterpolationQuality);
    111111
     112#if HAVE(OS_DARK_MODE_SUPPORT)
     113    CHECK_FOR_CHANGED_PROPERTY(UseDarkAppearanceChange, useDarkAppearance);
     114#endif
     115
    112116    return changeFlags;
    113117}
     
    178182    if (flags & GraphicsContextState::ImageInterpolationQualityChange)
    179183        m_state.imageInterpolationQuality = state.imageInterpolationQuality;
    180    
     184
     185#if HAVE(OS_DARK_MODE_SUPPORT)
     186    if (flags & GraphicsContextState::UseDarkAppearanceChange)
     187        m_state.useDarkAppearance = state.useDarkAppearance;
     188#endif
     189
    181190    m_changeFlags |= flags;
    182191}
     
    246255    if (m_changeFlags & GraphicsContextState::ImageInterpolationQualityChange)
    247256        context.setImageInterpolationQuality(m_state.imageInterpolationQuality);
     257
     258#if HAVE(OS_DARK_MODE_SUPPORT)
     259    if (m_changeFlags & GraphicsContextState::UseDarkAppearanceChange)
     260        context.setUseDarkAppearance(m_state.useDarkAppearance);
     261#endif
    248262}
    249263
     
    313327    if (m_changeFlags & GraphicsContextState::DrawLuminanceMaskChange)
    314328        ts.dumpProperty("draw-luminance-mask", m_state.drawLuminanceMask);
     329
     330#if HAVE(OS_DARK_MODE_SUPPORT)
     331    if (m_changeFlags & GraphicsContextState::UseDarkAppearanceChange)
     332        ts.dumpProperty("use-dark-appearance", m_state.useDarkAppearance);
     333#endif
    315334}
    316335
     
    939958        m_impl->updateState(m_state, GraphicsContextState::DrawLuminanceMaskChange);
    940959}
     960
     961#if HAVE(OS_DARK_MODE_SUPPORT)
     962void GraphicsContext::setUseDarkAppearance(bool useDarkAppearance)
     963{
     964    m_state.useDarkAppearance = useDarkAppearance;
     965    if (m_impl)
     966        m_impl->updateState(m_state, GraphicsContextState::UseDarkAppearanceChange);
     967}
     968#endif
    941969
    942970#if !USE(CG) && !USE(DIRECT2D)
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r241271 r245752  
    164164        DrawLuminanceMaskChange                 = 1 << 20,
    165165        ImageInterpolationQualityChange         = 1 << 21,
     166#if HAVE(OS_DARK_MODE_SUPPORT)
     167        UseDarkAppearanceChange                 = 1 << 22,
     168#endif
    166169    };
    167170    typedef uint32_t StateChangeFlags;
     
    200203#endif
    201204    bool drawLuminanceMask : 1;
     205#if HAVE(OS_DARK_MODE_SUPPORT)
     206    bool useDarkAppearance : 1;
     207#endif
    202208};
    203209
     
    410416    void setTextDrawingMode(TextDrawingModeFlags);
    411417    TextDrawingModeFlags textDrawingMode() const { return m_state.textDrawingMode; }
     418
     419#if HAVE(OS_DARK_MODE_SUPPORT)
     420    void setUseDarkAppearance(bool);
     421    bool useDarkAppearance() const { return m_state.useDarkAppearance; }
     422#endif
    412423
    413424    float drawText(const FontCascade&, const TextRun&, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt);
  • trunk/Source/WebCore/rendering/TextPaintStyle.cpp

    r239427 r245752  
    5353        && useLetterpressEffect == other.useLetterpressEffect
    5454#endif
     55#if HAVE(OS_DARK_MODE_SUPPORT)
     56        && useDarkAppearance == other.useDarkAppearance
     57#endif
    5558        && lineCap == other.lineCap && miterLimit == other.miterLimit;
    5659}
     
    8285    paintStyle.useLetterpressEffect = lineStyle.textDecorationsInEffect().contains(TextDecoration::Letterpress);
    8386#endif
     87
     88#if HAVE(OS_DARK_MODE_SUPPORT)
     89    paintStyle.useDarkAppearance = frame.document() ? frame.document()->useDarkAppearance(&lineStyle) : false;
     90#endif
     91
    8492    auto viewportSize = frame.view() ? frame.view()->size() : IntSize();
    8593    paintStyle.strokeWidth = lineStyle.computedStrokeWidth(viewportSize);
     
    187195    }
    188196
     197#if HAVE(OS_DARK_MODE_SUPPORT)
     198    context.setUseDarkAppearance(paintStyle.useDarkAppearance);
     199#endif
     200
    189201    Color fillColor = fillColorType == UseEmphasisMarkColor ? paintStyle.emphasisMarkColor : paintStyle.fillColor;
    190202    if (mode & TextModeFill && (fillColor != context.fillColor()))
  • trunk/Source/WebCore/rendering/TextPaintStyle.h

    r239427 r245752  
    5353    bool useLetterpressEffect { false };
    5454#endif
     55#if HAVE(OS_DARK_MODE_SUPPORT)
     56    bool useDarkAppearance { false };
     57#endif
    5558    PaintOrder paintOrder { PaintOrder::Normal };
    5659    LineJoin lineJoin { MiterJoin };
Note: See TracChangeset for help on using the changeset viewer.