Repository navigation
style: Move font-size outside of mako - #19119
Conversation
|
Heads up! This PR modifies the following files:
|
|
|
||
| #[inline] | ||
| /// Get initial value for specified font size. | ||
| pub fn get_initial_specified_value() -> Self { |
There was a problem hiding this comment.
Let's call this method fn medium() instead.
| } | ||
|
|
||
| /// Parses a font-size, with quirks. | ||
| pub fn parse_quirky<'i, 't>(context: &ParserContext, |
There was a problem hiding this comment.
Let's fix the indentation here:
pub fn parse_quirky<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {|
|
||
| #[allow(unused_mut)] | ||
| /// Cascade `font-size` with specified value | ||
| pub fn cascade_specified_font_size(context: &mut Context, |
|
|
||
| /// FIXME(emilio): This is very complex. Also, it should move to | ||
| /// StyleBuilder. | ||
| pub fn cascade_inherit_font_size(context: &mut Context) { |
There was a problem hiding this comment.
These two should probably be in computed::FontSize, but it's not a huge deal.
There was a problem hiding this comment.
Updated! I was originally we need to cascade when specified so I put it in specified module.
However, I think there's already a cascade_specified_font_size so I think you're right that I need to move these two into computed module.
Please review, thanks! 😄
|
|
||
| #[inline] | ||
| /// Get default value of font size. | ||
| pub fn get_initial_value() -> Self { |
There was a problem hiding this comment.
Again, let's call this medium, since it's the default value.
d6c81a3 to
856296c
Compare
396ae5c to
6ba2038
Compare
|
@bors-servo r+ Thanks a lot! |
|
📌 Commit 6ba2038 has been approved by |
style: Move font-size outside of mako This is a sub-PR of #19015 r? emilio --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19111 (github issue number if applicable). - [x] These changes do not require tests <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19119) <!-- Reviewable:end -->
|
💔 Test failed - linux-rel-css |
|
That failure seems related, I'm going to retry just in case it isn't, but otherwise it should be investigated. @bors-servo retry |
|
⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev are reusable. Rebuilding only linux-rel-css, mac-rel-css2... |
|
💔 Test failed - linux-rel-css |
|
Still failed. |
|
You should be able to test it with |
6ba2038 to
b19e0c8
Compare
|
Still the same: |
|
Err, I'm stupid, sorry for overlooking this.
FontSize::parse right now is:
parse_quirky(..., AllowQuirks::No)
But it was:
parse_quirky(..., AllowQuirks::Yes)
So, that explains the bug, but looks fishy to me.
…On 11/07/2017 09:53 PM, Josh Matthews wrote:
Still the same:
|▶ Unexpected subtest result in /quirks-mode/unitless-length.html: │ FAIL
[expected PASS] Excluded property font:normal normal normal 40
sans-serif │ → assert_equals: quirk was supported expected "16px" but
got "40px" │ │
***@***.***://web-platform.test:8000/quirks-mode/unitless-length.html:209:17
│
***@***.***://web-platform.test:8000/resources/testharness.js:1489:20
│ ***@***.***://web-platform.test:8000/resources/testharness.js:511:9 │
***@***.***://web-platform.test:8000/quirks-mode/unitless-length.html:207:13
└
***@***.***://web-platform.test:8000/quirks-mode/unitless-length.html:206:9
▶ Unexpected subtest result in /_mozilla/mozilla/unitless-length.html: │
FAIL [expected PASS] Excluded property font:normal normal normal 40
sans-serif │ → assert_equals: quirk was supported expected "16px" but
got "40px" │ │
***@***.***://web-platform.test:8000/_mozilla/mozilla/unitless-length.html:209:17
│
***@***.***://web-platform.test:8000/resources/testharness.js:1489:20
│ ***@***.***://web-platform.test:8000/resources/testharness.js:511:9 │
***@***.***://web-platform.test:8000/_mozilla/mozilla/unitless-length.html:207:13
└
***@***.***://web-platform.test:8000/_mozilla/mozilla/unitless-length.html:206:9
|
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19119 (comment)>, or
mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQwum0t8C1hx6DL8i7ZJnK-yJAaQiBgks5s0MM9gaJpZM4QSbF->.
|
|
So |
|
So browsers seem to agree... Here's my proposed fix: From 9deb8d9b254f4b2e3fccec3681a78f9b1a4e3b69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <[email protected]>
Date: Wed, 8 Nov 2017 00:23:18 +0100
Subject: [PATCH] fixup! style: Move font-size outside of mako
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Emilio Cobos Álvarez <[email protected]>
---
components/style/properties/shorthand/font.mako.rs | 32 +++++++++++++++-------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/components/style/properties/shorthand/font.mako.rs b/components/style/properties/shorthand/font.mako.rs
index b06f03a74e..cd70393a84 100644
--- a/components/style/properties/shorthand/font.mako.rs
+++ b/components/style/properties/shorthand/font.mako.rs
@@ -20,10 +20,11 @@
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font">
use parser::Parse;
use properties::longhands::{font_family, font_style, font_weight, font_stretch};
- use properties::longhands::{font_size, font_variant_caps};
+ use properties::longhands::font_variant_caps;
#[cfg(feature = "gecko")]
use properties::longhands::system_font::SystemFont;
use values::specified::text::LineHeight;
+ use values::specified::FontSize;
<%
gecko_sub_properties = "kerning language_override size_adjust \
@@ -89,27 +90,38 @@
continue
}
}
- size = Some(font_size::parse(context, input)?);
+ size = Some(FontSize::parse(context, input)?);
break
}
+
+ let size = match size {
+ Some(s) => s,
+ None => {
+ return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
+ }
+ };
+
+ let line_height = if input.try(|input| input.expect_delim('/')).is_ok() {
+ Some(LineHeight::parse(context, input)?)
+ } else {
+ None
+ };
+
#[inline]
fn count<T>(opt: &Option<T>) -> u8 {
if opt.is_some() { 1 } else { 0 }
}
- if size.is_none() ||
- (count(&style) + count(&weight) + count(&variant_caps) + count(&stretch) + nb_normals) > 4 {
+
+ if (count(&style) + count(&weight) + count(&variant_caps) + count(&stretch) + nb_normals) > 4 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
- let line_height = if input.try(|input| input.expect_delim('/')).is_ok() {
- Some(LineHeight::parse(context, input)?)
- } else {
- None
- };
+
let family = FontFamily::parse(input)?;
Ok(expanded! {
- % for name in "style weight stretch size variant_caps".split():
+ % for name in "style weight stretch variant_caps".split():
font_${name}: unwrap_or_initial!(font_${name}, ${name}),
% endfor
+ font_size: size,
line_height: line_height.unwrap_or(LineHeight::normal()),
font_family: family,
% if product == "gecko":
--
2.15.0 |
|
@emilio I'll try to fix it with what you proposed. |
|
I didn't find any relevant spec quote, but I did multiple tests with quirks mode documents like: <div style="font: 40 sans-serif">Which size am I</div>And noticed that it preserves behavior and other browsers also agree. |
40def57 to
0cec873
Compare
|
Got it! I think that's why you make the |
0cec873 to
0f57d25
Compare
| ${name}: FontSize::system_font(sys), | ||
| % else: | ||
| ${name}: ${name}::SpecifiedValue::system_font(sys), | ||
| % endif |
There was a problem hiding this comment.
Yeah, this is fine, I can't think of anything better right now. This system_font thing is quite messy too...
There was a problem hiding this comment.
Thanks for review! If anything I can help, welcome to tell me :)
| ${name}: FontSize::system_font(sys), | ||
| % else: | ||
| ${name}: ${name}::SpecifiedValue::system_font(sys), | ||
| % endif |
There was a problem hiding this comment.
Yeah, this is fine, I can't think of anything better right now. This system_font thing is quite messy too...
|
@bors-servo r+ |
|
📌 Commit 0f57d25 has been approved by |
style: Move font-size outside of mako This is a sub-PR of #19015 r? emilio --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19111 (github issue number if applicable). - [x] These changes do not require tests <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19119) <!-- Reviewable:end -->
|
💔 Test failed - linux-rel-wpt |
|
@bors-servo retry That crash can't be caused by this PR, though it looks worrying, cc @jdm |
|
⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-css, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev are reusable. Rebuilding only linux-rel-wpt, mac-rel-wpt1, mac-rel-wpt2... |
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
This is a sub-PR of #19015
r? emilio
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is