- Revision
- 245752
- Author
- timothy_hor...@apple.com
- Date
- 2019-05-24 14:41:00 -0700 (Fri, 24 May 2019)
Log 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:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (245751 => 245752)
--- trunk/Source/WebCore/ChangeLog 2019-05-24 19:49:57 UTC (rev 245751)
+++ trunk/Source/WebCore/ChangeLog 2019-05-24 21:41:00 UTC (rev 245752)
@@ -1,3 +1,27 @@
+2019-05-24 Timothy Hatcher <timo...@apple.com>
+
+ 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:
+
2019-05-24 Youenn Fablet <you...@apple.com>
Make sure completion handler is always called in SWServer::startSuspension
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (245751 => 245752)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2019-05-24 19:49:57 UTC (rev 245751)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2019-05-24 21:41:00 UTC (rev 245752)
@@ -109,6 +109,10 @@
CHECK_FOR_CHANGED_PROPERTY(DrawLuminanceMaskChange, drawLuminanceMask);
CHECK_FOR_CHANGED_PROPERTY(ImageInterpolationQualityChange, imageInterpolationQuality);
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ CHECK_FOR_CHANGED_PROPERTY(UseDarkAppearanceChange, useDarkAppearance);
+#endif
+
return changeFlags;
}
@@ -177,7 +181,12 @@
if (flags & GraphicsContextState::ImageInterpolationQualityChange)
m_state.imageInterpolationQuality = state.imageInterpolationQuality;
-
+
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ if (flags & GraphicsContextState::UseDarkAppearanceChange)
+ m_state.useDarkAppearance = state.useDarkAppearance;
+#endif
+
m_changeFlags |= flags;
}
@@ -245,6 +254,11 @@
if (m_changeFlags & GraphicsContextState::ImageInterpolationQualityChange)
context.setImageInterpolationQuality(m_state.imageInterpolationQuality);
+
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ if (m_changeFlags & GraphicsContextState::UseDarkAppearanceChange)
+ context.setUseDarkAppearance(m_state.useDarkAppearance);
+#endif
}
void GraphicsContextStateChange::dump(TextStream& ts) const
@@ -312,6 +326,11 @@
if (m_changeFlags & GraphicsContextState::DrawLuminanceMaskChange)
ts.dumpProperty("draw-luminance-mask", m_state.drawLuminanceMask);
+
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ if (m_changeFlags & GraphicsContextState::UseDarkAppearanceChange)
+ ts.dumpProperty("use-dark-appearance", m_state.useDarkAppearance);
+#endif
}
TextStream& operator<<(TextStream& ts, const GraphicsContextStateChange& stateChange)
@@ -939,6 +958,15 @@
m_impl->updateState(m_state, GraphicsContextState::DrawLuminanceMaskChange);
}
+#if HAVE(OS_DARK_MODE_SUPPORT)
+void GraphicsContext::setUseDarkAppearance(bool useDarkAppearance)
+{
+ m_state.useDarkAppearance = useDarkAppearance;
+ if (m_impl)
+ m_impl->updateState(m_state, GraphicsContextState::UseDarkAppearanceChange);
+}
+#endif
+
#if !USE(CG) && !USE(DIRECT2D)
// Implement this if you want to go push the drawing mode into your native context immediately.
void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags)
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (245751 => 245752)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2019-05-24 19:49:57 UTC (rev 245751)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2019-05-24 21:41:00 UTC (rev 245752)
@@ -163,6 +163,9 @@
ShouldSubpixelQuantizeFontsChange = 1 << 19,
DrawLuminanceMaskChange = 1 << 20,
ImageInterpolationQualityChange = 1 << 21,
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ UseDarkAppearanceChange = 1 << 22,
+#endif
};
typedef uint32_t StateChangeFlags;
@@ -199,6 +202,9 @@
bool shadowsUseLegacyRadius : 1;
#endif
bool drawLuminanceMask : 1;
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ bool useDarkAppearance : 1;
+#endif
};
struct ImagePaintingOptions {
@@ -410,6 +416,11 @@
void setTextDrawingMode(TextDrawingModeFlags);
TextDrawingModeFlags textDrawingMode() const { return m_state.textDrawingMode; }
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ void setUseDarkAppearance(bool);
+ bool useDarkAppearance() const { return m_state.useDarkAppearance; }
+#endif
+
float drawText(const FontCascade&, const TextRun&, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt);
void drawGlyphs(const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&, FontSmoothingMode);
void drawEmphasisMarks(const FontCascade&, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt);
Modified: trunk/Source/WebCore/rendering/TextPaintStyle.cpp (245751 => 245752)
--- trunk/Source/WebCore/rendering/TextPaintStyle.cpp 2019-05-24 19:49:57 UTC (rev 245751)
+++ trunk/Source/WebCore/rendering/TextPaintStyle.cpp 2019-05-24 21:41:00 UTC (rev 245752)
@@ -52,6 +52,9 @@
#if ENABLE(LETTERPRESS)
&& useLetterpressEffect == other.useLetterpressEffect
#endif
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ && useDarkAppearance == other.useDarkAppearance
+#endif
&& lineCap == other.lineCap && miterLimit == other.miterLimit;
}
@@ -81,6 +84,11 @@
#if ENABLE(LETTERPRESS)
paintStyle.useLetterpressEffect = lineStyle.textDecorationsInEffect().contains(TextDecoration::Letterpress);
#endif
+
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ paintStyle.useDarkAppearance = frame.document() ? frame.document()->useDarkAppearance(&lineStyle) : false;
+#endif
+
auto viewportSize = frame.view() ? frame.view()->size() : IntSize();
paintStyle.strokeWidth = lineStyle.computedStrokeWidth(viewportSize);
paintStyle.paintOrder = lineStyle.paintOrder();
@@ -186,6 +194,10 @@
mode = newMode;
}
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ context.setUseDarkAppearance(paintStyle.useDarkAppearance);
+#endif
+
Color fillColor = fillColorType == UseEmphasisMarkColor ? paintStyle.emphasisMarkColor : paintStyle.fillColor;
if (mode & TextModeFill && (fillColor != context.fillColor()))
context.setFillColor(fillColor);
Modified: trunk/Source/WebCore/rendering/TextPaintStyle.h (245751 => 245752)
--- trunk/Source/WebCore/rendering/TextPaintStyle.h 2019-05-24 19:49:57 UTC (rev 245751)
+++ trunk/Source/WebCore/rendering/TextPaintStyle.h 2019-05-24 21:41:00 UTC (rev 245752)
@@ -52,6 +52,9 @@
#if ENABLE(LETTERPRESS)
bool useLetterpressEffect { false };
#endif
+#if HAVE(OS_DARK_MODE_SUPPORT)
+ bool useDarkAppearance { false };
+#endif
PaintOrder paintOrder { PaintOrder::Normal };
LineJoin lineJoin { MiterJoin };
LineCap lineCap { ButtCap };