Skip to content

Commit a04606a

Browse files
committed
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: * TestExpectations: Canonical link: https://commits.webkit.org/244510@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286123 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 497fdd7 commit a04606a

4 files changed

Lines changed: 37 additions & 4 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2021-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+
111
2021-11-22 Chris Fleizach <cfleizach@apple.com>
212

313
AX: WebKit: need a method to get visible text and frame of an element on screen

LayoutTests/TestExpectations

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,9 +1485,6 @@ webkit.org/b/209735 imported/w3c/web-platform-tests/css/selectors/root-siblings.
14851485
imported/w3c/web-platform-tests/css/mediaqueries/device-aspect-ratio-001.html [ Skip ]
14861486
imported/w3c/web-platform-tests/css/mediaqueries/device-aspect-ratio-005.html [ Skip ]
14871487

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 ]
1490-
14911488
# nth-child tests takes long time and Debug build sometimes timeouts because there are many test cases.
14921489
webkit.org/b/137149 fast/selectors/nth-child-of-basics.html [ Slow ]
14931490

Source/WebCore/ChangeLog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2021-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+
118
2021-11-22 Cameron McCormack <heycam@apple.com>
219

320
Fix some license find/replace errors

Source/WebCore/css/MediaQueryEvaluator.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "RenderStyle.h"
5050
#include "RenderView.h"
5151
#include "Settings.h"
52+
#include "StyleFontSizeFunctions.h"
5253
#include "Theme.h"
5354
#include <wtf/HashMap.h>
5455
#include <wtf/text/StringConcatenateNumbers.h>
@@ -926,9 +927,17 @@ bool MediaQueryEvaluator::evaluate(const MediaQueryExpression& expression) const
926927

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

934943
bool MediaQueryEvaluator::mediaAttributeMatches(Document& document, const String& attributeValue)

0 commit comments

Comments
 (0)