https://bugs.webkit.org/show_bug.cgi?id=191607
rdar://problem/
46045854
Reviewed by Dean Jackson.
Source/WebCore:
Test: css-dark-mode/default-colors.html
* css/html.css:
(html): Set color: text on macOS.
* dom/Document.cpp:
(WebCore::Document::processSupportedColorSchemes): Call recalculateBaseBackgroundColor().
* editing/EditingStyle.cpp:
(WebCore::caretColorFromStyle): Added.
(WebCore::EditingStyle::prepareToApplyAt): Use equalIgnoringSemanticColor. Check for
caret-color directly since removeEquivalentProperties fails with semantic colors.
(WebCore::extractPropertiesNotIn): Use equalIgnoringSemanticColor. Check for caret-color
directly since removeEquivalentProperties fails with semantic colors.
* page/Frame.cpp:
(WebCore::Frame::createView): Drop backgroundColor.
* page/Frame.h:
* page/FrameView.cpp:
(WebCore::FrameView::recalculateBaseBackgroundColor): Added.
(WebCore::FrameView::updateBackgroundRecursively): Drop backgroundColor argument.
Calculate the backgroundColor based on the transparent argument only.
* page/FrameView.h:
* platform/graphics/Color.h:
(WebCore::equalIgnoringSemanticColor): Added for EditingStyle.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange): Call recalculateBaseBackgroundColor().
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::shouldDumpPropertyForLayer const): Use isWhiteColor()
since it ignores the semantic color flag.
* testing/Internals.cpp:
(WebCore::Internals::setViewIsTransparent): Drop backgroundColor.
(WebCore::Internals::viewBaseBackgroundColor): Added.
* testing/Internals.h:
* testing/Internals.idl: Added viewBaseBackgroundColor.
Source/WebKit:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::backgroundColor const): Use controlBackgroundColor.
(WebKit::WebViewImpl::updateLayer): Simplified and use backgroundColor() getter.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setDrawsBackground): Drop backgroundColor.
Source/WebKitLegacy/win:
* WebFrame.cpp:
(WebFrame::updateBackground): Drop backgroundColor.
* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor.
LayoutTests:
* css-dark-mode/default-colors-expected.txt: Added.
* css-dark-mode/default-colors.html: Added.
* inspector/css/shadow-scoped-style-expected.txt: Rebaseline.
* platform/mac/printing/width-overflow-expected.txt: Rebaseline.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238212
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-11-14 Timothy Hatcher <timothy@apple.com>
+
+ Default the view background color and text color to different values when in dark mode.
+ https://bugs.webkit.org/show_bug.cgi?id=191607
+ rdar://problem/46045854
+
+ Reviewed by Dean Jackson.
+
+ * css-dark-mode/default-colors-expected.txt: Added.
+ * css-dark-mode/default-colors.html: Added.
+ * inspector/css/shadow-scoped-style-expected.txt: Rebaseline.
+ * platform/mac/printing/width-overflow-expected.txt: Rebaseline.
+
2018-11-14 Ryan Haddad <ryanhaddad@apple.com>
Layout test fast/layers/no-clipping-overflow-hidden-added-after-transform.html is a flaky failure on EWS bots
--- /dev/null
+
+PASS Body text color is black, since the page isn't in dark mode
+PASS View base background color is white, since the page isn't in dark mode
+PASS Set dark appearance
+PASS Body text color is black, since the page hasn't set a supported color scheme
+PASS View base background color is white, since the page hasn't set a supported color scheme
+PASS Set prefers-color-schemes: light dark on the body
+PASS Body text color is white
+PASS View base background color is a dark grey
+
--- /dev/null
+<!DOCTYPE html>
+
+<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] -->
+
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<body></body>
+
+<script>
+function test_prop(element, prop, expected) {
+ assert_equals(window.getComputedStyle(element).getPropertyValue(prop), expected);
+}
+
+test(function() {
+ test_prop(document.body, "color", "rgb(0, 0, 0)");
+}, "Body text color is black, since the page isn't in dark mode");
+
+test(function() {
+ assert_equals(internals.viewBaseBackgroundColor(), "rgb(255, 255, 255)");
+}, "View base background color is white, since the page isn't in dark mode");
+
+test(function() {
+ if (!window.internals)
+ return;
+ internals.settings.setUseDarkAppearance(true);
+}, "Set dark appearance");
+
+test(function() {
+ test_prop(document.body, "color", "rgb(0, 0, 0)");
+}, "Body text color is black, since the page hasn't set a supported color scheme");
+
+test(function() {
+ assert_equals(internals.viewBaseBackgroundColor(), "rgb(255, 255, 255)");
+}, "View base background color is white, since the page hasn't set a supported color scheme");
+
+test(function() {
+ let styleElement = document.createElement("style");
+ styleElement.textContent = ":root { supported-color-schemes: light dark; }";
+ document.head.appendChild(styleElement);
+}, "Set prefers-color-schemes: light dark on the body");
+
+test(function() {
+ test_prop(document.body, "color", "rgb(255, 255, 255)");
+}, "Body text color is white");
+
+test(function() {
+ if (!window.internals)
+ return;
+ assert_equals(internals.viewBaseBackgroundColor(), "rgb(30, 30, 30)");
+}, "View base background color is a dark grey");
+</script>
}
address, article, aside, div, footer, header, hgroup, layer, main, nav, section {
}
+html {
+}
-- Running test case: CSS.ShadowScopedStyle.ElementInShadowTree
PASS: Node should not have shadow roots.
text run at (0,0) width 765: "To run this test manually, print this page. If the right side of any lines is printed without being truncated, the test passes."
RenderBlock {DIV} at (0,34) size 1300x2218
RenderBlock {P} at (0,0) size 1300x72
- RenderText {#text} at (0,0) size 1288x72
- text run at (0,0) width 1288: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
- text run at (0,18) width 1288: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
- text run at (0,36) width 1288: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
- text run at (0,54) width 525: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
+ RenderText {#text} at (0,0) size 1289x72
+ text run at (0,0) width 1289: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
+ text run at (0,18) width 1289: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
+ text run at (0,36) width 1289: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
+ text run at (0,54) width 526: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
RenderBlock {P} at (0,88) size 1300x72
RenderText {#text} at (0,0) size 1288x72
text run at (0,0) width 1288: "B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B"
text run at (0,36) width 1288: "O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O"
text run at (0,54) width 790: "O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O"
RenderBlock {P} at (0,1284) size 1300x54
- RenderText {#text} at (0,0) size 1289x54
- text run at (0,0) width 1289: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
- text run at (0,18) width 1289: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
+ RenderText {#text} at (0,0) size 1290x54
+ text run at (0,0) width 1290: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
+ text run at (0,18) width 1290: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
text run at (0,36) width 1105: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
RenderBlock {P} at (0,1354) size 1300x72
RenderText {#text} at (0,0) size 1288x72
text run at (0,0) width 1292: "T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T"
text run at (0,18) width 1292: "T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T"
text run at (0,36) width 1292: "T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T"
- text run at (0,54) width 158: "T T T T T T T T T T T T"
+ text run at (0,54) width 159: "T T T T T T T T T T T T"
RenderBlock {P} at (0,1688) size 1300x72
RenderText {#text} at (0,0) size 1288x72
text run at (0,0) width 1288: "U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U"
text run at (0,0) width 1299: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
text run at (0,18) width 1299: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
text run at (0,36) width 1299: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
- text run at (0,54) width 580: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
+ text run at (0,54) width 581: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
RenderBlock {P} at (0,2146) size 1300x72
RenderText {#text} at (0,0) size 1291x72
text run at (0,0) width 1291: "Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z"
+2018-11-14 Timothy Hatcher <timothy@apple.com>
+
+ Default the view background color and text color to different values when in dark mode.
+ https://bugs.webkit.org/show_bug.cgi?id=191607
+ rdar://problem/46045854
+
+ Reviewed by Dean Jackson.
+
+ Test: css-dark-mode/default-colors.html
+
+ * css/html.css:
+ (html): Set color: text on macOS.
+ * dom/Document.cpp:
+ (WebCore::Document::processSupportedColorSchemes): Call recalculateBaseBackgroundColor().
+ * editing/EditingStyle.cpp:
+ (WebCore::caretColorFromStyle): Added.
+ (WebCore::EditingStyle::prepareToApplyAt): Use equalIgnoringSemanticColor. Check for
+ caret-color directly since removeEquivalentProperties fails with semantic colors.
+ (WebCore::extractPropertiesNotIn): Use equalIgnoringSemanticColor. Check for caret-color
+ directly since removeEquivalentProperties fails with semantic colors.
+ * page/Frame.cpp:
+ (WebCore::Frame::createView): Drop backgroundColor.
+ * page/Frame.h:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::recalculateBaseBackgroundColor): Added.
+ (WebCore::FrameView::updateBackgroundRecursively): Drop backgroundColor argument.
+ Calculate the backgroundColor based on the transparent argument only.
+ * page/FrameView.h:
+ * platform/graphics/Color.h:
+ (WebCore::equalIgnoringSemanticColor): Added for EditingStyle.
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::styleDidChange): Call recalculateBaseBackgroundColor().
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::shouldDumpPropertyForLayer const): Use isWhiteColor()
+ since it ignores the semantic color flag.
+ * testing/Internals.cpp:
+ (WebCore::Internals::setViewIsTransparent): Drop backgroundColor.
+ (WebCore::Internals::viewBaseBackgroundColor): Added.
+ * testing/Internals.h:
+ * testing/Internals.idl: Added viewBaseBackgroundColor.
+
2018-11-14 Justin Fan <justin_fan@apple.com>
[WebGPU] Code quality concerns raised for 191291: [WebGPU] Experimental prototype for WebGPURenderPipeline and WebGPUSwapChain
html {
display: block;
+#if defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC
+ color: text;
+#endif
}
/* children of the <head> element all have display:none */
m_supportedColorSchemes = supportedColorSchemes;
m_allowsColorSchemeTransformations = allowsTransformations;
+ if (auto* frameView = view())
+ frameView->recalculateBaseBackgroundColor();
+
if (auto* page = this->page())
page->updateStyleAfterChangeInEnvironment();
}
}
template<typename T>
+static inline Color caretColorFromStyle(T& style)
+{
+ return cssValueToColor(extractPropertyValue(style, CSSPropertyCaretColor).get());
+}
+
+template<typename T>
static inline Color backgroundColorFromStyle(T& style)
{
return cssValueToColor(extractPropertyValue(style, CSSPropertyBackgroundColor).get());
if (textAlignResolvingStartAndEnd(*m_mutableStyle) == textAlignResolvingStartAndEnd(*styleAtPosition))
m_mutableStyle->removeProperty(CSSPropertyTextAlign);
- if (textColorFromStyle(*m_mutableStyle) == textColorFromStyle(*styleAtPosition))
+ if (equalIgnoringSemanticColor(textColorFromStyle(*m_mutableStyle), textColorFromStyle(*styleAtPosition)))
m_mutableStyle->removeProperty(CSSPropertyColor);
+ if (equalIgnoringSemanticColor(caretColorFromStyle(*m_mutableStyle), caretColorFromStyle(*styleAtPosition)))
+ m_mutableStyle->removeProperty(CSSPropertyCaretColor);
+
if (hasTransparentBackgroundColor(m_mutableStyle.get())
|| cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgroundColor).get()) == rgbaBackgroundColorInEffect(position.containerNode()))
m_mutableStyle->removeProperty(CSSPropertyBackgroundColor);
if (extractPropertyValue(baseStyle, CSSPropertyFontWeight) && fontWeightIsBold(mutableStyle) == fontWeightIsBold(baseStyle))
mutableStyle->removeProperty(CSSPropertyFontWeight);
- if (extractPropertyValue(baseStyle, CSSPropertyColor) && textColorFromStyle(mutableStyle) == textColorFromStyle(baseStyle))
+ if (extractPropertyValue(baseStyle, CSSPropertyColor) && equalIgnoringSemanticColor(textColorFromStyle(mutableStyle), textColorFromStyle(baseStyle)))
mutableStyle->removeProperty(CSSPropertyColor);
+ if (extractPropertyValue(baseStyle, CSSPropertyCaretColor) && equalIgnoringSemanticColor(caretColorFromStyle(mutableStyle), caretColorFromStyle(baseStyle)))
+ mutableStyle->removeProperty(CSSPropertyCaretColor);
+
if (extractPropertyValue(baseStyle, CSSPropertyTextAlign)
&& textAlignResolvingStartAndEnd(mutableStyle) == textAlignResolvingStartAndEnd(baseStyle))
mutableStyle->removeProperty(CSSPropertyTextAlign);
- if (extractPropertyValue(baseStyle, CSSPropertyBackgroundColor) && backgroundColorFromStyle(mutableStyle) == backgroundColorFromStyle(baseStyle))
+ if (extractPropertyValue(baseStyle, CSSPropertyBackgroundColor) && equalIgnoringSemanticColor(backgroundColorFromStyle(mutableStyle), backgroundColorFromStyle(baseStyle)))
mutableStyle->removeProperty(CSSPropertyBackgroundColor);
return mutableStyle;
return nullptr;
}
-void Frame::createView(const IntSize& viewportSize, const Color& backgroundColor, bool transparent,
+void Frame::createView(const IntSize& viewportSize, bool transparent,
const IntSize& fixedLayoutSize, const IntRect& fixedVisibleContentRect,
bool useFixedLayout, ScrollbarMode horizontalScrollbarMode, bool horizontalLock,
ScrollbarMode verticalScrollbarMode, bool verticalLock)
setView(frameView.copyRef());
- frameView->updateBackgroundRecursively(backgroundColor, transparent);
+ frameView->updateBackgroundRecursively(transparent);
if (isMainFrame)
frameView->setParentVisible(true);
WEBCORE_EXPORT void initWithSimpleHTMLDocument(const String& style, const URL&);
#endif
WEBCORE_EXPORT void setView(RefPtr<FrameView>&&);
- WEBCORE_EXPORT void createView(const IntSize&, const Color& backgroundColor, bool transparent,
+ WEBCORE_EXPORT void createView(const IntSize&, bool transparent,
const IntSize& fixedLayoutSize, const IntRect& fixedVisibleContentRect,
bool useFixedLayout = false, ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
setScrollbarOverlayStyle(computedOverlayStyle);
}
+#if ENABLE(DARK_MODE_CSS)
+void FrameView::recalculateBaseBackgroundColor()
+{
+ bool usingDarkAppearance = useDarkAppearance();
+ if (m_usesDarkAppearance == usingDarkAppearance)
+ return;
+
+ m_usesDarkAppearance = usingDarkAppearance;
+ updateBackgroundRecursively(m_isTransparent);
+}
+#endif
+
void FrameView::clear()
{
setCanBlitOnScroll(true);
renderView()->compositor().rootBackgroundColorOrTransparencyChanged();
}
-void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool transparent)
+void FrameView::updateBackgroundRecursively(bool transparent)
{
+#if ENABLE(DARK_MODE_CSS)
+ Color backgroundColor = transparent ? Color::transparent : RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions());
+#else
+ Color backgroundColor = transparent ? Color::transparent : Color::white;
+#endif
+
for (auto* frame = m_frame.ptr(); frame; frame = frame->tree().traverseNext(m_frame.ptr())) {
if (FrameView* view = frame->view()) {
view->setTransparent(transparent);
void prepareForDetach();
void detachCustomScrollbars();
WEBCORE_EXPORT void recalculateScrollbarOverlayStyle();
+#if ENABLE(DARK_MODE_CSS)
+ void recalculateBaseBackgroundColor();
+#endif
void clear();
void resetLayoutMilestones();
WEBCORE_EXPORT Color baseBackgroundColor() const;
WEBCORE_EXPORT void setBaseBackgroundColor(const Color&);
- WEBCORE_EXPORT void updateBackgroundRecursively(const Color&, bool);
+ WEBCORE_EXPORT void updateBackgroundRecursively(bool);
enum ExtendedBackgroundModeFlags {
ExtendedBackgroundModeNone = 0,
WEBCORE_EXPORT Color& operator=(Color&&);
friend bool operator==(const Color& a, const Color& b);
+ friend bool equalIgnoringSemanticColor(const Color& a, const Color& b);
static bool isBlackColor(const Color&);
static bool isWhiteColor(const Color&);
return !(a == b);
}
+inline bool equalIgnoringSemanticColor(const Color& a, const Color& b)
+{
+ return (a.m_colorData.rgbaAndFlags & ~Color::isSemanticRBGAColorBit) == (b.m_colorData.rgbaAndFlags & ~Color::isSemanticRBGAColorBit);
+}
+
inline uint8_t roundAndClampColorChannel(int value)
{
return std::max(0, std::min(255, value));
setNeedsLayoutAndPrefWidthsRecalc();
}
+#if ENABLE(DARK_MODE_CSS)
+ view().frameView().recalculateBaseBackgroundColor();
+#endif
+
view().frameView().recalculateScrollbarOverlayStyle();
const Pagination& pagination = view().frameView().pagination();
return false;
// Background color could be of interest to tests or other dumpers if it's non-white.
- if (!strcmp(propertyName, "backgroundColor") && layer->backgroundColor() == Color::white)
+ if (!strcmp(propertyName, "backgroundColor") && Color::isWhiteColor(layer->backgroundColor()))
return false;
// The root tile cache's repaints will show up at the top with FrameView's,
Document* document = contextDocument();
if (!document || !document->view())
return Exception { InvalidAccessError };
- Color backgroundColor = transparent ? Color::transparent : Color::white;
- document->view()->updateBackgroundRecursively(backgroundColor, transparent);
+ document->view()->updateBackgroundRecursively(transparent);
return { };
}
+ExceptionOr<String> Internals::viewBaseBackgroundColor()
+{
+ Document* document = contextDocument();
+ if (!document || !document->view())
+ return Exception { InvalidAccessError };
+ return document->view()->baseBackgroundColor().cssText();
+}
+
ExceptionOr<void> Internals::setViewBaseBackgroundColor(const String& colorValue)
{
Document* document = contextDocument();
ExceptionOr<Ref<DOMRect>> visualViewportRect();
ExceptionOr<void> setViewIsTransparent(bool);
+
+ ExceptionOr<String> viewBaseBackgroundColor();
ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
[MayThrowException] DOMRect visualViewportRect();
[MayThrowException] void setViewIsTransparent(boolean trnasparent);
+
+ [MayThrowException] DOMString viewBaseBackgroundColor();
[MayThrowException] void setViewBaseBackgroundColor(DOMString colorValue);
[MayThrowException] void setPagination(DOMString mode, long gap, optional long pageLength = 0);
+2018-11-14 Timothy Hatcher <timothy@apple.com>
+
+ Default the view background color and text color to different values when in dark mode.
+ https://bugs.webkit.org/show_bug.cgi?id=191607
+ rdar://problem/46045854
+
+ Reviewed by Dean Jackson.
+
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::backgroundColor const): Use controlBackgroundColor.
+ (WebKit::WebViewImpl::updateLayer): Simplified and use backgroundColor() getter.
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor.
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::setDrawsBackground): Drop backgroundColor.
+
2018-11-14 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: Pass Inspector::FrontendChannel as a reference connect/disconnect methods
NSColor *WebViewImpl::backgroundColor() const
{
if (!m_backgroundColor)
+#if ENABLE(DARK_MODE_CSS)
+ return [NSColor controlBackgroundColor];
+#else
return [NSColor whiteColor];
+#endif
return m_backgroundColor.get();
}
void WebViewImpl::updateLayer()
{
- bool draws = drawsBackground();
- if (!draws || !m_backgroundColor)
- [m_view layer].backgroundColor = CGColorGetConstantColor(draws ? kCGColorWhite : kCGColorClear);
- else
- [m_view layer].backgroundColor = [m_backgroundColor CGColor];
+ [m_view layer].backgroundColor = drawsBackground() ? [backgroundColor() CGColor] : CGColorGetConstantColor(kCGColorClear);
}
void WebViewImpl::drawRect(CGRect rect)
{
WebPage* webPage = m_frame->page();
- Color backgroundColor = webPage->drawsBackground() ? Color::white : Color::transparent;
bool isMainFrame = m_frame->isMainFrame();
bool isTransparent = !webPage->drawsBackground();
bool shouldUseFixedLayout = isMainFrame && webPage->useFixedLayout();
bool horizontalLock = shouldHideScrollbars || webPage->alwaysShowsHorizontalScroller();
bool verticalLock = shouldHideScrollbars || webPage->alwaysShowsVerticalScroller();
- m_frame->coreFrame()->createView(webPage->size(), backgroundColor, isTransparent,
+ m_frame->coreFrame()->createView(webPage->size(), isTransparent,
webPage->fixedLayoutSize(), fixedVisibleContentRect, shouldUseFixedLayout,
horizontalScrollbarMode, horizontalLock, verticalScrollbarMode, verticalLock);
m_drawsBackground = drawsBackground;
if (FrameView* frameView = mainFrameView()) {
- Color backgroundColor = drawsBackground ? Color::white : Color::transparent;
bool isTransparent = !drawsBackground;
- frameView->updateBackgroundRecursively(backgroundColor, isTransparent);
+ frameView->updateBackgroundRecursively(isTransparent);
}
m_drawingArea->pageBackgroundTransparencyChanged();
+2018-11-14 Timothy Hatcher <timothy@apple.com>
+
+ Default the view background color and text color to different values when in dark mode.
+ https://bugs.webkit.org/show_bug.cgi?id=191607
+ rdar://problem/46045854
+
+ Reviewed by Dean Jackson.
+
+ * WebFrame.cpp:
+ (WebFrame::updateBackground): Drop backgroundColor.
+ * WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor.
+
2018-11-14 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: Pass Inspector::FrontendChannel as a reference connect/disconnect methods
RECT pixelRect;
view->frameRect(&pixelRect);
bool transparent = view->transparent();
- Color backgroundColor = transparent ? Color::transparent : Color::white;
FloatRect logicalFrame(pixelRect);
logicalFrame.scale(1.0f / view->deviceScaleFactor());
- core(m_webFrame)->createView(enclosingIntRect(logicalFrame).size(), backgroundColor, transparent, /* fixedLayoutSize */ { }, /* fixedVisibleContentRect */ { });
+ core(m_webFrame)->createView(enclosingIntRect(logicalFrame).size(), transparent, /* fixedLayoutSize */ { }, /* fixedVisibleContentRect */ { });
}
void WebFrameLoaderClient::didSaveToPageCache()
void WebFrame::updateBackground()
{
- Color backgroundColor = webView()->transparent() ? Color::transparent : Color::white;
Frame* coreFrame = core(this);
if (!coreFrame || !coreFrame->view())
return;
- coreFrame->view()->updateBackgroundRecursively(backgroundColor, webView()->transparent());
+ coreFrame->view()->updateBackgroundRecursively(webView()->transparent());
}
// IWebFrame2