Diff
Modified: trunk/LayoutTests/ChangeLog (233509 => 233510)
--- trunk/LayoutTests/ChangeLog 2018-07-04 20:12:37 UTC (rev 233509)
+++ trunk/LayoutTests/ChangeLog 2018-07-05 03:50:56 UTC (rev 233510)
@@ -1,3 +1,14 @@
+2018-07-04 Antti Koivisto <[email protected]>
+
+ Reparse user stylesheets when _useSystemAppearance changes
+ https://bugs.webkit.org/show_bug.cgi?id=187312
+ <rdar://problem/38565834>
+
+ Reviewed by Tim Horton.
+
+ * fast/media/use-system-appearance-user-stylesheet-parsing-expected.txt: Added.
+ * fast/media/use-system-appearance-user-stylesheet-parsing.html: Added.
+
2018-07-04 Alicia Boya GarcĂa <[email protected]>
Unreviewed GTK test gardening.
Added: trunk/LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing-expected.txt (0 => 233510)
--- trunk/LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing-expected.txt 2018-07-05 03:50:56 UTC (rev 233510)
@@ -0,0 +1,7 @@
+PASS getComputedStyle(test).color is "rgb(0, 0, 0)"
+PASS getComputedStyle(test).color is "rgb(0, 128, 0)"
+PASS getComputedStyle(test).color is "rgb(0, 0, 0)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing.html (0 => 233510)
--- trunk/LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing.html (rev 0)
+++ trunk/LayoutTests/fast/media/use-system-appearance-user-stylesheet-parsing.html 2018-07-05 03:50:56 UTC (rev 233510)
@@ -0,0 +1,13 @@
+<script src=""
+<div id=test></div>
+<script>
+testRunner.addUserStyleSheet("@media (prefers-dark-interface) { #test { color: green } }", true);
+testRunner.addUserStyleSheet("@media not screen and (prefers-dark-interface) { #test { color: green } }", true);
+
+shouldBeEqualToString("getComputedStyle(test).color", "rgb(0, 0, 0)");
+internals.setUseSystemAppearance(true);
+shouldBeEqualToString("getComputedStyle(test).color", "rgb(0, 128, 0)");
+internals.setUseSystemAppearance(false);
+shouldBeEqualToString("getComputedStyle(test).color", "rgb(0, 0, 0)");
+</script>
+<script src=""
Modified: trunk/Source/WebCore/ChangeLog (233509 => 233510)
--- trunk/Source/WebCore/ChangeLog 2018-07-04 20:12:37 UTC (rev 233509)
+++ trunk/Source/WebCore/ChangeLog 2018-07-05 03:50:56 UTC (rev 233510)
@@ -1,3 +1,24 @@
+2018-07-04 Antti Koivisto <[email protected]>
+
+ Reparse user stylesheets when _useSystemAppearance changes
+ https://bugs.webkit.org/show_bug.cgi?id=187312
+ <rdar://problem/38565834>
+
+ Reviewed by Tim Horton.
+
+ This setting may affect user stylesheet parsing. Reparse if it changes.
+
+ Test: fast/media/use-system-appearance-user-stylesheet-parsing.html
+
+ * page/Page.cpp:
+ (WebCore::Page::setUseSystemAppearance):
+ * page/Page.h:
+ (WebCore::Page::setUseSystemAppearance): Deleted.
+ * testing/Internals.cpp:
+ (WebCore::Internals::setUseSystemAppearance):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2018-07-04 Thibault Saunier <[email protected]>
RealtimeIncomingVideoSources: Call stop() directly in the destructor
Modified: trunk/Source/WebCore/page/Page.cpp (233509 => 233510)
--- trunk/Source/WebCore/page/Page.cpp 2018-07-04 20:12:37 UTC (rev 233509)
+++ trunk/Source/WebCore/page/Page.cpp 2018-07-05 03:50:56 UTC (rev 233510)
@@ -2369,6 +2369,22 @@
}
}
+void Page::setUseSystemAppearance(bool value)
+{
+ if (m_useSystemAppearance == value)
+ return;
+ m_useSystemAppearance = value;
+
+ for (auto* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ auto* document = frame->document();
+ if (!document)
+ continue;
+ // System apperance change may affect stylesheet parsing. We need to reparse.
+ document->extensionStyleSheets().clearPageUserSheet();
+ document->extensionStyleSheets().invalidateInjectedStyleSheetCache();
+ }
+}
+
bool Page::defaultAppearance() const
{
FrameView* view = mainFrame().view();
Modified: trunk/Source/WebCore/page/Page.h (233509 => 233510)
--- trunk/Source/WebCore/page/Page.h 2018-07-04 20:12:37 UTC (rev 233509)
+++ trunk/Source/WebCore/page/Page.h 2018-07-05 03:50:56 UTC (rev 233510)
@@ -340,7 +340,7 @@
#endif
bool useSystemAppearance() const { return m_useSystemAppearance; }
- void setUseSystemAppearance(bool a) { m_useSystemAppearance = a; }
+ WEBCORE_EXPORT void setUseSystemAppearance(bool);
WEBCORE_EXPORT bool defaultAppearance() const;
void setDefaultAppearance(bool a) { m_defaultAppearance = a; }
Modified: trunk/Source/WebCore/testing/Internals.cpp (233509 => 233510)
--- trunk/Source/WebCore/testing/Internals.cpp 2018-07-04 20:12:37 UTC (rev 233509)
+++ trunk/Source/WebCore/testing/Internals.cpp 2018-07-05 03:50:56 UTC (rev 233510)
@@ -4629,5 +4629,12 @@
if (auto* frame = this->frame())
frame->loader().reload(ReloadOption::DisableContentBlockers);
}
-
+
+void Internals::setUseSystemAppearance(bool value)
+{
+ if (!contextDocument() || !contextDocument()->page())
+ return;
+ contextDocument()->page()->setUseSystemAppearance(value);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.h (233509 => 233510)
--- trunk/Source/WebCore/testing/Internals.h 2018-07-04 20:12:37 UTC (rev 233509)
+++ trunk/Source/WebCore/testing/Internals.h 2018-07-05 03:50:56 UTC (rev 233510)
@@ -715,6 +715,8 @@
void reloadWithoutContentExtensions();
+ void setUseSystemAppearance(bool);
+
private:
explicit Internals(Document&);
Document* contextDocument() const;
Modified: trunk/Source/WebCore/testing/Internals.idl (233509 => 233510)
--- trunk/Source/WebCore/testing/Internals.idl 2018-07-04 20:12:37 UTC (rev 233509)
+++ trunk/Source/WebCore/testing/Internals.idl 2018-07-05 03:50:56 UTC (rev 233510)
@@ -652,4 +652,6 @@
void setCaptureExtraNetworkLoadMetricsEnabled(boolean value);
void reloadWithoutContentExtensions();
+
+ void setUseSystemAppearance(boolean value);
};