@media rules ignored in user agent style sheet html.css
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Nov 2017 17:45:50 +0000 (17:45 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Nov 2017 17:45:50 +0000 (17:45 +0000)
commit752d38ac3ee7ac8ccf8f36196e0459654b0f1aa9
treee93414c4c8c4c0f6904157a0090246f1175cc94b
parent46119c542f711ec1cae97a44eabed8fae7195f50
@media rules ignored in user agent style sheet html.css
https://bugs.webkit.org/show_bug.cgi?id=169245
<rdar://problem/30885951>

Reviewed by Darin Adler.

To support accessibility features, allow non-trivial @media rules in user agent stylesheet.

This patch creates a special stylesheet consisting of rules with media queries seen on user agent stylesheets.
The queries on this sheet are evaluated with the document's media query evaluator.

No tests as I don't want to add things to UA style just for testing purposes. This will
gain coverage when the feature is used.

 * css/CSSDefaultStyleSheets.cpp:
(WebCore::CSSDefaultStyleSheets::addToDefaultStyle):

    Add a helper.
    Build a new stylesheet that consists of complex media rules seen in user agent sheets.

(WebCore::CSSDefaultStyleSheets::loadFullDefaultStyle):
(WebCore::CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement):
* css/CSSDefaultStyleSheets.h:
* css/DocumentRuleSets.cpp:
(WebCore::DocumentRuleSets::userAgentMediaQueryStyle const):

    Rule set constructed from media queries seen on UA sheet.

(WebCore::DocumentRuleSets::updateUserAgentMediaQueryStyleIfNeeded const):

    Evalute the media queries if needed.
    Re-evaluate if the rule count of the media query stylesheet increases
    (this could happen when additional UA style is added).

(WebCore::DocumentRuleSets::resetUserAgentMediaQueryStyle):
(WebCore::DocumentRuleSets::collectFeatures const):

    Collect the features from userAgentMediaQueryStyle.

* css/DocumentRuleSets.h:
(WebCore::DocumentRuleSets::setIsForShadowScope):
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::ElementRuleCollector):
(WebCore::ElementRuleCollector::matchUARules):

    Also match rules in userAgentMediaQueryStyle.

* css/ElementRuleCollector.h:
* css/InspectorCSSOMWrappers.cpp:
(WebCore::InspectorCSSOMWrappers::collectDocumentWrappers):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
* style/StyleScope.cpp:
(WebCore::Style::Scope::resolver):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224495 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/css/CSSDefaultStyleSheets.cpp
Source/WebCore/css/CSSDefaultStyleSheets.h
Source/WebCore/css/DocumentRuleSets.cpp
Source/WebCore/css/DocumentRuleSets.h
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/css/ElementRuleCollector.h
Source/WebCore/css/InspectorCSSOMWrappers.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/style/StyleScope.cpp