Changeset 172110 in webkit


Ignore:
Timestamp:
Aug 5, 2014 4:40:24 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Add the ability to force text to render in white, not just black
https://bugs.webkit.org/show_bug.cgi?id=135625

Patch by Peyton Randolph <prandolph@apple.com> on 2014-08-05
Reviewed by Beth Dakin.

This patch introduces PaintBehaviorForceWhiteText, a complement to PaintBehaviorForceBlackText. If
a client specifies both PaintBehaviorForceWhiteText and PaintBehaviorForceBlackText, the text will be
painted black.

No new tests.

  • rendering/EllipsisBox.cpp:

(WebCore::EllipsisBox::paint): Use the forced text color to paint the text if requested.

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::paint): Disable the text shadow if a text color has been forced.

  • rendering/PaintInfo.h:

(WebCore::PaintInfo::forceTextColor):
Return true iff the client has requested to force a black or white text color.
(WebCore::PaintInfo::forceWhiteText):
Return true iff forcing white text has been requested.
(WebCore::PaintInfo::forcedTextColor):
Return the forced text color. Currently only white and black are supported.

  • rendering/PaintPhase.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::paintLayerContents): Remove the forceBlackText-related code as it is redundant.
(WebCore::RenderLayer::paintForegroundForFragments):
Remove forceBlackText parameter and infer the correct behavior from the given paint behavior.

  • rendering/RenderLayer.h:
  • rendering/TextPaintStyle.cpp:

(WebCore::computeTextPaintStyle): Use the forced text color if available.
(WebCore::computeTextSelectionPaintStyle): Use the forced text color if available.

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r172093 r172110  
     12014-08-05  Peyton Randolph  <prandolph@apple.com>
     2
     3        Add the ability to force text to render in white, not just black
     4        https://bugs.webkit.org/show_bug.cgi?id=135625
     5
     6        Reviewed by Beth Dakin.
     7
     8        This patch introduces PaintBehaviorForceWhiteText, a complement to PaintBehaviorForceBlackText. If
     9        a client specifies both PaintBehaviorForceWhiteText and PaintBehaviorForceBlackText, the text will be
     10        painted black.
     11
     12        No new tests.
     13
     14        * rendering/EllipsisBox.cpp:
     15        (WebCore::EllipsisBox::paint): Use the forced text color to paint the text if requested.
     16        * rendering/InlineTextBox.cpp:
     17        (WebCore::InlineTextBox::paint): Disable the text shadow if a text color has been forced.
     18        * rendering/PaintInfo.h:
     19        (WebCore::PaintInfo::forceTextColor):
     20        Return true iff the client has requested to force a black or white text color.
     21        (WebCore::PaintInfo::forceWhiteText):
     22        Return true iff forcing white text has been requested.
     23        (WebCore::PaintInfo::forcedTextColor):
     24        Return the forced text color. Currently only white and black are supported.
     25        * rendering/PaintPhase.h:
     26        * rendering/RenderLayer.cpp:
     27        (WebCore::RenderLayer::paintLayerContents): Remove the forceBlackText-related code as it is redundant.
     28        (WebCore::RenderLayer::paintForegroundForFragments):
     29        Remove forceBlackText parameter and infer the correct behavior from the given paint behavior.
     30        * rendering/RenderLayer.h:
     31        * rendering/TextPaintStyle.cpp:
     32        (WebCore::computeTextPaintStyle): Use the forced text color if available.
     33        (WebCore::computeTextSelectionPaintStyle): Use the forced text color if available.
     34
    1352014-08-05  Alex Christensen  <achristensen@webkit.org>
    236
  • trunk/Source/WebCore/rendering/EllipsisBox.cpp

    r168528 r172110  
    6060
    6161        // Select the correct color for painting the text.
    62         Color foreground = paintInfo.forceBlackText() ? Color::black : blockFlow().selectionForegroundColor();
     62        Color foreground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : blockFlow().selectionForegroundColor();
    6363        if (foreground.isValid() && foreground != textColor)
    6464            context->setFillColor(foreground, lineStyle.colorSpace());
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r172008 r172110  
    629629        emphasisMarkOffset = emphasisMarkAbove ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark);
    630630
    631     const ShadowData* textShadow = paintInfo.forceBlackText() ? 0 : lineStyle.textShadow();
     631    const ShadowData* textShadow = (paintInfo.forceTextColor()) ? nullptr : lineStyle.textShadow();
    632632
    633633    FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
  • trunk/Source/WebCore/rendering/PaintInfo.h

    r168967 r172110  
    8181    }
    8282
     83    bool forceTextColor() const { return forceBlackText() || forceWhiteText(); }
    8384    bool forceBlackText() const { return paintBehavior & PaintBehaviorForceBlackText; }
     85    bool forceWhiteText() const { return paintBehavior & PaintBehaviorForceWhiteText; }
     86    Color forcedTextColor() const { return (forceBlackText()) ? Color::black : Color::white; }
    8487
    8588    bool skipRootBackground() const { return paintBehavior & PaintBehaviorSkipRootBackground; }
  • trunk/Source/WebCore/rendering/PaintPhase.h

    r140068 r172110  
    5757    PaintBehaviorSelectionOnly = 1 << 0,
    5858    PaintBehaviorForceBlackText = 1 << 1,
    59     PaintBehaviorFlattenCompositingLayers = 1 << 2,
    60     PaintBehaviorRenderingSVGMask = 1 << 3,
    61     PaintBehaviorSkipRootBackground = 1 << 4,
    62     PaintBehaviorRootBackgroundOnly = 1 << 5
     59    PaintBehaviorForceWhiteText = 1 << 2,
     60    PaintBehaviorFlattenCompositingLayers = 1 << 3,
     61    PaintBehaviorRenderingSVGMask = 1 << 4,
     62    PaintBehaviorSkipRootBackground = 1 << 5,
     63    PaintBehaviorRootBackgroundOnly = 1 << 6,
    6364};
    6465
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r172008 r172110  
    40484048        performOverlapTests(*localPaintingInfo.overlapTestRequests, localPaintingInfo.rootLayer, this);
    40494049
    4050     bool forceBlackText = localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText;
    40514050    bool selectionOnly  = localPaintingInfo.paintBehavior & PaintBehaviorSelectionOnly;
    40524051   
     
    40884087        if (shouldPaintContent)
    40894088            paintForegroundForFragments(layerFragments, context, transparencyLayerContext, paintingInfo.paintDirtyRect, haveTransparency,
    4090                 localPaintingInfo, paintBehavior, subtreePaintRootForRenderer, selectionOnly, forceBlackText);
     4089                localPaintingInfo, paintBehavior, subtreePaintRootForRenderer, selectionOnly);
    40914090    }
    40924091
     
    44294428void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragments, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
    44304429    const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
    4431     RenderObject* subtreePaintRootForRenderer, bool selectionOnly, bool forceBlackText)
     4430    RenderObject* subtreePaintRootForRenderer, bool selectionOnly)
    44324431{
    44334432    // Begin transparency if we have something to paint.
     
    44414440        }
    44424441    }
    4443    
    4444     PaintBehavior localPaintBehavior = forceBlackText ? (PaintBehavior)PaintBehaviorForceBlackText : paintBehavior;
     4442
     4443    PaintBehavior localPaintBehavior;
     4444    if (localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText)
     4445        localPaintBehavior = PaintBehaviorForceBlackText;
     4446    else if (localPaintingInfo.paintBehavior & PaintBehaviorForceWhiteText)
     4447        localPaintBehavior = PaintBehaviorForceWhiteText;
     4448    else
     4449        localPaintBehavior = paintBehavior;
    44454450
    44464451    // Optimize clipping for the single fragment case.
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r171896 r172110  
    10051005    void paintForegroundForFragments(const LayerFragments&, GraphicsContext*, GraphicsContext* transparencyLayerContext,
    10061006        const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer,
    1007         bool selectionOnly, bool forceBlackText);
     1007        bool selectionOnly);
    10081008    void paintForegroundForFragmentsWithPhase(PaintPhase, const LayerFragments&, GraphicsContext*, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
    10091009    void paintOutlineForFragments(const LayerFragments&, GraphicsContext*, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
  • trunk/Source/WebCore/rendering/TextPaintStyle.cpp

    r158803 r172110  
    8181    paintStyle.strokeWidth = lineStyle.textStrokeWidth();
    8282
    83     if (paintInfo.forceBlackText()) {
    84         paintStyle.fillColor = Color::black;
    85         paintStyle.strokeColor = Color::black;
    86         paintStyle.emphasisMarkColor = Color::black;
     83    if (paintInfo.forceTextColor()) {
     84        paintStyle.fillColor = paintInfo.forcedTextColor();
     85        paintStyle.strokeColor = paintInfo.forcedTextColor();
     86        paintStyle.emphasisMarkColor = paintInfo.forcedTextColor();
    8787        return paintStyle;
    8888    }
     
    120120    paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection);
    121121    paintSelectedTextSeparately = false;
    122     selectionShadow = paintInfo.forceBlackText() ? nullptr : lineStyle.textShadow();
     122    selectionShadow = (paintInfo.forceTextColor()) ? nullptr : lineStyle.textShadow();
    123123
    124124    TextPaintStyle selectionPaintStyle = textPaintStyle;
    125125
    126126#if ENABLE(TEXT_SELECTION)
    127     Color foreground = paintInfo.forceBlackText() ? Color::black : renderer.selectionForegroundColor();
     127    Color foreground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : renderer.selectionForegroundColor();
    128128    if (foreground.isValid() && foreground != selectionPaintStyle.fillColor) {
    129129        if (!paintSelectedTextOnly)
     
    132132    }
    133133
    134     Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black : renderer.selectionEmphasisMarkColor();
     134    Color emphasisMarkForeground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : renderer.selectionEmphasisMarkColor();
    135135    if (emphasisMarkForeground.isValid() && emphasisMarkForeground != selectionPaintStyle.emphasisMarkColor) {
    136136        if (!paintSelectedTextOnly)
     
    140140
    141141    if (RenderStyle* pseudoStyle = renderer.getCachedPseudoStyle(SELECTION)) {
    142         const ShadowData* shadow = paintInfo.forceBlackText() ? 0 : pseudoStyle->textShadow();
     142        const ShadowData* shadow = paintInfo.forceTextColor() ? nullptr : pseudoStyle->textShadow();
    143143        if (shadow != selectionShadow) {
    144144            if (!paintSelectedTextOnly)
     
    154154        }
    155155
    156         Color stroke = paintInfo.forceBlackText() ? Color::black : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
     156        Color stroke = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
    157157        if (stroke != selectionPaintStyle.strokeColor) {
    158158            if (!paintSelectedTextOnly)
Note: See TracChangeset for help on using the changeset viewer.