Diff
Modified: trunk/Source/WebCore/ChangeLog (172109 => 172110)
--- trunk/Source/WebCore/ChangeLog 2014-08-05 23:39:44 UTC (rev 172109)
+++ trunk/Source/WebCore/ChangeLog 2014-08-05 23:40:24 UTC (rev 172110)
@@ -1,3 +1,37 @@
+2014-08-05 Peyton Randolph <prando...@apple.com>
+
+ Add the ability to force text to render in white, not just black
+ https://bugs.webkit.org/show_bug.cgi?id=135625
+
+ 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.
+
2014-08-05 Alex Christensen <achristen...@webkit.org>
More work on CMake.
Modified: trunk/Source/WebCore/rendering/EllipsisBox.cpp (172109 => 172110)
--- trunk/Source/WebCore/rendering/EllipsisBox.cpp 2014-08-05 23:39:44 UTC (rev 172109)
+++ trunk/Source/WebCore/rendering/EllipsisBox.cpp 2014-08-05 23:40:24 UTC (rev 172110)
@@ -59,7 +59,7 @@
paintSelection(context, paintOffset, lineStyle, font);
// Select the correct color for painting the text.
- Color foreground = paintInfo.forceBlackText() ? Color::black : blockFlow().selectionForegroundColor();
+ Color foreground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : blockFlow().selectionForegroundColor();
if (foreground.isValid() && foreground != textColor)
context->setFillColor(foreground, lineStyle.colorSpace());
}
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (172109 => 172110)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2014-08-05 23:39:44 UTC (rev 172109)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2014-08-05 23:40:24 UTC (rev 172110)
@@ -628,7 +628,7 @@
if (!emphasisMark.isEmpty())
emphasisMarkOffset = emphasisMarkAbove ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark);
- const ShadowData* textShadow = paintInfo.forceBlackText() ? 0 : lineStyle.textShadow();
+ const ShadowData* textShadow = (paintInfo.forceTextColor()) ? nullptr : lineStyle.textShadow();
FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
if (combinedText)
Modified: trunk/Source/WebCore/rendering/PaintInfo.h (172109 => 172110)
--- trunk/Source/WebCore/rendering/PaintInfo.h 2014-08-05 23:39:44 UTC (rev 172109)
+++ trunk/Source/WebCore/rendering/PaintInfo.h 2014-08-05 23:40:24 UTC (rev 172110)
@@ -80,7 +80,10 @@
return !subtreePaintRoot || subtreePaintRoot == &renderer;
}
+ bool forceTextColor() const { return forceBlackText() || forceWhiteText(); }
bool forceBlackText() const { return paintBehavior & PaintBehaviorForceBlackText; }
+ bool forceWhiteText() const { return paintBehavior & PaintBehaviorForceWhiteText; }
+ Color forcedTextColor() const { return (forceBlackText()) ? Color::black : Color::white; }
bool skipRootBackground() const { return paintBehavior & PaintBehaviorSkipRootBackground; }
bool paintRootBackgroundOnly() const { return paintBehavior & PaintBehaviorRootBackgroundOnly; }
Modified: trunk/Source/WebCore/rendering/PaintPhase.h (172109 => 172110)
--- trunk/Source/WebCore/rendering/PaintPhase.h 2014-08-05 23:39:44 UTC (rev 172109)
+++ trunk/Source/WebCore/rendering/PaintPhase.h 2014-08-05 23:40:24 UTC (rev 172110)
@@ -56,10 +56,11 @@
PaintBehaviorNormal = 0,
PaintBehaviorSelectionOnly = 1 << 0,
PaintBehaviorForceBlackText = 1 << 1,
- PaintBehaviorFlattenCompositingLayers = 1 << 2,
- PaintBehaviorRenderingSVGMask = 1 << 3,
- PaintBehaviorSkipRootBackground = 1 << 4,
- PaintBehaviorRootBackgroundOnly = 1 << 5
+ PaintBehaviorForceWhiteText = 1 << 2,
+ PaintBehaviorFlattenCompositingLayers = 1 << 3,
+ PaintBehaviorRenderingSVGMask = 1 << 4,
+ PaintBehaviorSkipRootBackground = 1 << 5,
+ PaintBehaviorRootBackgroundOnly = 1 << 6,
};
typedef unsigned PaintBehavior;
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (172109 => 172110)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-08-05 23:39:44 UTC (rev 172109)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-08-05 23:40:24 UTC (rev 172110)
@@ -4047,7 +4047,6 @@
if (localPaintingInfo.overlapTestRequests && isSelfPaintingLayer)
performOverlapTests(*localPaintingInfo.overlapTestRequests, localPaintingInfo.rootLayer, this);
- bool forceBlackText = localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText;
bool selectionOnly = localPaintingInfo.paintBehavior & PaintBehaviorSelectionOnly;
PaintBehavior paintBehavior = PaintBehaviorNormal;
@@ -4087,7 +4086,7 @@
if (isPaintingCompositedForeground) {
if (shouldPaintContent)
paintForegroundForFragments(layerFragments, context, transparencyLayerContext, paintingInfo.paintDirtyRect, haveTransparency,
- localPaintingInfo, paintBehavior, subtreePaintRootForRenderer, selectionOnly, forceBlackText);
+ localPaintingInfo, paintBehavior, subtreePaintRootForRenderer, selectionOnly);
}
if (shouldPaintOutline)
@@ -4428,7 +4427,7 @@
void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragments, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
- RenderObject* subtreePaintRootForRenderer, bool selectionOnly, bool forceBlackText)
+ RenderObject* subtreePaintRootForRenderer, bool selectionOnly)
{
// Begin transparency if we have something to paint.
if (haveTransparency) {
@@ -4440,9 +4439,15 @@
}
}
}
-
- PaintBehavior localPaintBehavior = forceBlackText ? (PaintBehavior)PaintBehaviorForceBlackText : paintBehavior;
+ PaintBehavior localPaintBehavior;
+ if (localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText)
+ localPaintBehavior = PaintBehaviorForceBlackText;
+ else if (localPaintingInfo.paintBehavior & PaintBehaviorForceWhiteText)
+ localPaintBehavior = PaintBehaviorForceWhiteText;
+ else
+ localPaintBehavior = paintBehavior;
+
// Optimize clipping for the single fragment case.
bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && layerFragments[0].shouldPaintContent && !layerFragments[0].foregroundRect.isEmpty();
ClipRect clippedRect;
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (172109 => 172110)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2014-08-05 23:39:44 UTC (rev 172109)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2014-08-05 23:40:24 UTC (rev 172110)
@@ -1004,7 +1004,7 @@
const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
void paintForegroundForFragments(const LayerFragments&, GraphicsContext*, GraphicsContext* transparencyLayerContext,
const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer,
- bool selectionOnly, bool forceBlackText);
+ bool selectionOnly);
void paintForegroundForFragmentsWithPhase(PaintPhase, const LayerFragments&, GraphicsContext*, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
void paintOutlineForFragments(const LayerFragments&, GraphicsContext*, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
void paintOverflowControlsForFragments(const LayerFragments&, GraphicsContext*, const LayerPaintingInfo&);
Modified: trunk/Source/WebCore/rendering/TextPaintStyle.cpp (172109 => 172110)
--- trunk/Source/WebCore/rendering/TextPaintStyle.cpp 2014-08-05 23:39:44 UTC (rev 172109)
+++ trunk/Source/WebCore/rendering/TextPaintStyle.cpp 2014-08-05 23:40:24 UTC (rev 172110)
@@ -80,10 +80,10 @@
#endif
paintStyle.strokeWidth = lineStyle.textStrokeWidth();
- if (paintInfo.forceBlackText()) {
- paintStyle.fillColor = Color::black;
- paintStyle.strokeColor = Color::black;
- paintStyle.emphasisMarkColor = Color::black;
+ if (paintInfo.forceTextColor()) {
+ paintStyle.fillColor = paintInfo.forcedTextColor();
+ paintStyle.strokeColor = paintInfo.forcedTextColor();
+ paintStyle.emphasisMarkColor = paintInfo.forcedTextColor();
return paintStyle;
}
paintStyle.fillColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextFillColor);
@@ -119,19 +119,19 @@
{
paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection);
paintSelectedTextSeparately = false;
- selectionShadow = paintInfo.forceBlackText() ? nullptr : lineStyle.textShadow();
+ selectionShadow = (paintInfo.forceTextColor()) ? nullptr : lineStyle.textShadow();
TextPaintStyle selectionPaintStyle = textPaintStyle;
#if ENABLE(TEXT_SELECTION)
- Color foreground = paintInfo.forceBlackText() ? Color::black : renderer.selectionForegroundColor();
+ Color foreground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : renderer.selectionForegroundColor();
if (foreground.isValid() && foreground != selectionPaintStyle.fillColor) {
if (!paintSelectedTextOnly)
paintSelectedTextSeparately = true;
selectionPaintStyle.fillColor = foreground;
}
- Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black : renderer.selectionEmphasisMarkColor();
+ Color emphasisMarkForeground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : renderer.selectionEmphasisMarkColor();
if (emphasisMarkForeground.isValid() && emphasisMarkForeground != selectionPaintStyle.emphasisMarkColor) {
if (!paintSelectedTextOnly)
paintSelectedTextSeparately = true;
@@ -139,7 +139,7 @@
}
if (RenderStyle* pseudoStyle = renderer.getCachedPseudoStyle(SELECTION)) {
- const ShadowData* shadow = paintInfo.forceBlackText() ? 0 : pseudoStyle->textShadow();
+ const ShadowData* shadow = paintInfo.forceTextColor() ? nullptr : pseudoStyle->textShadow();
if (shadow != selectionShadow) {
if (!paintSelectedTextOnly)
paintSelectedTextSeparately = true;
@@ -153,7 +153,7 @@
selectionPaintStyle.strokeWidth = strokeWidth;
}
- Color stroke = paintInfo.forceBlackText() ? Color::black : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
+ Color stroke = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
if (stroke != selectionPaintStyle.strokeColor) {
if (!paintSelectedTextOnly)
paintSelectedTextSeparately = true;