Changeset 286123 in webkit


Ignore:
Timestamp:
Nov 22, 2021 5:46:15 PM (8 months ago)
Author:
mmaxfield@apple.com
Message:

rem in media queries should be calculated using font-size:initial, not root element font-size
https://bugs.webkit.org/show_bug.cgi?id=156684
<rdar://problem/25778616>

Reviewed by Antti Koivisto.

Source/WebCore:

The CSS spec says:

Relative units in media queries are based on the initial value, which means that units are never based on results of declarations.

Tests: imported/w3c/web-platform-tests/css/mediaqueries/relative-units-001.html

imported/w3c/web-platform-tests/css/mediaqueries/mq-calc-005.html

  • css/MediaQueryEvaluator.cpp:

(WebCore::MediaQueryEvaluator::evaluate const):

LayoutTests:

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286116 r286123  
     12021-11-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        rem in media queries should be calculated using font-size:initial, not root element font-size
     4        https://bugs.webkit.org/show_bug.cgi?id=156684
     5        <rdar://problem/25778616>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        * TestExpectations:
     10
    1112021-11-22  Chris Fleizach  <cfleizach@apple.com>
    212
  • trunk/LayoutTests/TestExpectations

    r286100 r286123  
    14851485imported/w3c/web-platform-tests/css/mediaqueries/device-aspect-ratio-001.html [ Skip ]
    14861486imported/w3c/web-platform-tests/css/mediaqueries/device-aspect-ratio-005.html [ Skip ]
    1487 
    1488 webkit.org/b/156684 imported/w3c/web-platform-tests/css/mediaqueries/relative-units-001.html [ ImageOnlyFailure ]
    1489 webkit.org/b/156684 imported/w3c/web-platform-tests/css/mediaqueries/mq-calc-005.html [ ImageOnlyFailure ]
    14901487
    14911488# nth-child tests takes long time and Debug build sometimes timeouts because there are many test cases.
  • trunk/Source/WebCore/ChangeLog

    r286122 r286123  
     12021-11-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        rem in media queries should be calculated using font-size:initial, not root element font-size
     4        https://bugs.webkit.org/show_bug.cgi?id=156684
     5        <rdar://problem/25778616>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        The CSS spec says:
     10        > Relative units in media queries are based on the initial value, which means that units are never based on results of declarations.
     11
     12        Tests: imported/w3c/web-platform-tests/css/mediaqueries/relative-units-001.html
     13               imported/w3c/web-platform-tests/css/mediaqueries/mq-calc-005.html
     14
     15        * css/MediaQueryEvaluator.cpp:
     16        (WebCore::MediaQueryEvaluator::evaluate const):
     17
    1182021-11-22  Cameron McCormack  <heycam@apple.com>
    219
  • trunk/Source/WebCore/css/MediaQueryEvaluator.cpp

    r284536 r286123  
    5050#include "RenderView.h"
    5151#include "Settings.h"
     52#include "StyleFontSizeFunctions.h"
    5253#include "Theme.h"
    5354#include <wtf/HashMap.h>
     
    927928    if (!document.documentElement())
    928929        return false;
     930
     931    auto defaultStyle = RenderStyle::create();
     932    auto fontDescription = defaultStyle.fontDescription();
     933    auto size = Style::fontSizeForKeyword(CSSValueMedium, false, document);
     934    fontDescription.setComputedSize(size);
     935    fontDescription.setSpecifiedSize(size);
     936    defaultStyle.setFontDescription(WTFMove(fontDescription));
     937    defaultStyle.fontCascade().update();
    929938   
    930939    // Pass `nullptr` for `parentStyle` because we are in the context of a media query.
    931     return function(expression.value(), { m_style, document.documentElement()->renderStyle(), nullptr, document.renderView(), 1, std::nullopt }, *frame, NoPrefix);
     940    return function(expression.value(), { m_style, &defaultStyle, nullptr, document.renderView(), 1, std::nullopt }, *frame, NoPrefix);
    932941}
    933942
Note: See TracChangeset for help on using the changeset viewer.