Skip to content

style: Move font-size outside of mako - #19119

Merged
bors-servo merged 1 commit into
servo:masterfrom
CYBAI:font-size-out-of-mako
Nov 8, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
CYBAI:font-size-out-of-mako

Conversation

@CYBAI

@CYBAI CYBAI commented Nov 5, 2017 •

Copy link
Copy Markdown
Member

This is a sub-PR of #19015
r? emilio


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix Move font-size outside of mako. #19111 (github issue number if applicable).
  • These changes do not require tests

This change is Reviewable

@highfive

highfive commented Nov 5, 2017

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/servo/media_queries.rs, components/style/properties/gecko.mako.rs, components/style/values/specified/font.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs and 4 more
  • @canaltinova: components/style/servo/media_queries.rs, components/style/properties/gecko.mako.rs, components/style/values/specified/font.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs and 4 more
  • @emilio: components/style/servo/media_queries.rs, components/style/properties/gecko.mako.rs, components/style/values/specified/font.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs and 4 more

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 5, 2017
@highfive

highfive commented Nov 5, 2017

Copy link
Copy Markdown

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, as usual, thanks a lot @CYBAI!


#[inline]
/// Get initial value for specified font size.
pub fn get_initial_specified_value() -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call this method fn medium() instead.

}

/// Parses a font-size, with quirks.
pub fn parse_quirky<'i, 't>(context: &ParserContext,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto re. the indentation.


/// FIXME(emilio): This is very complex. Also, it should move to
/// StyleBuilder.
pub fn cascade_inherit_font_size(context: &mut Context) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two should probably be in computed::FontSize, but it's not a huge deal.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, let's call this medium, since it's the default value.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 5, 2017
@CYBAI
CYBAI force-pushed the font-size-out-of-mako branch from d6c81a3 to 856296c Compare November 6, 2017 02:44
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Nov 6, 2017
@CYBAI
CYBAI force-pushed the font-size-out-of-mako branch 2 times, most recently from 396ae5c to 6ba2038 Compare November 6, 2017 03:48
@emilio

emilio commented Nov 6, 2017

Copy link
Copy Markdown
Member

@bors-servo r+

Thanks a lot!

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 6ba2038 has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 6, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 6ba2038 with merge 1393588...

bors-servo pushed a commit that referenced this pull request Nov 6, 2017
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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-css

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 6, 2017
@emilio

emilio commented Nov 6, 2017

Copy link
Copy Markdown
Member

That failure seems related, I'm going to retry just in case it isn't, but otherwise it should be investigated.

@bors-servo retry

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ 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...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-css

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Nov 6, 2017
@CYBAI

CYBAI commented Nov 6, 2017

Copy link
Copy Markdown
Member Author

Still failed.
It seems that it's related to quirk mode.
How could I trace it or test it in local ?

@emilio

emilio commented Nov 6, 2017

Copy link
Copy Markdown
Member

You should be able to test it with ./mach test /_mozilla/mozilla/unitless-length.html

@CYBAI
CYBAI force-pushed the font-size-out-of-mako branch from 6ba2038 to b19e0c8 Compare November 6, 2017 16:36
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 6, 2017
@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Nov 7, 2017
@jdm

jdm commented Nov 7, 2017

Copy link
Copy Markdown
Member

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"
  │ 
  │ onload/</<@http://web-platform.test:8000/quirks-mode/unitless-length.html:209:17
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1489:20
  │ test@http://web-platform.test:8000/resources/testharness.js:511:9
  │ onload/<@http://web-platform.test:8000/quirks-mode/unitless-length.html:207:13
  └ onload@http://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"
  │ 
  │ onload/</<@http://web-platform.test:8000/_mozilla/mozilla/unitless-length.html:209:17
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1489:20
  │ test@http://web-platform.test:8000/resources/testharness.js:511:9
  │ onload/<@http://web-platform.test:8000/_mozilla/mozilla/unitless-length.html:207:13
  └ onload@http://web-platform.test:8000/_mozilla/mozilla/unitless-length.html:206:9

@emilio

emilio commented Nov 7, 2017 via email

Copy link
Copy Markdown
Member

@emilio

emilio commented Nov 7, 2017

Copy link
Copy Markdown
Member

So font_size::parse right now doesn't accept quirks, and the reason it doesn't, AIUI, is because it'd be ambiguous with line-height, font-weight, and other properties... I'm trying to see whether there's a spec here saying what to do or not.

@emilio

emilio commented Nov 7, 2017

Copy link
Copy Markdown
Member

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 emilio mentioned this pull request Nov 8, 2017
48 of 49 tasks
@CYBAI

CYBAI commented Nov 8, 2017

Copy link
Copy Markdown
Member Author

@emilio I'll try to fix it with what you proposed.
Besides, could you provide which spec you check to make me understand it more clear?
Thanks.

@emilio

emilio commented Nov 8, 2017

Copy link
Copy Markdown
Member

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.

@CYBAI
CYBAI force-pushed the font-size-out-of-mako branch from 40def57 to 0cec873 Compare November 8, 2017 01:58
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 8, 2017
@CYBAI

CYBAI commented Nov 8, 2017

Copy link
Copy Markdown
Member Author

Got it! I think that's why you make the match size do the None check earlier?

@CYBAI
CYBAI force-pushed the font-size-out-of-mako branch from 0cec873 to 0f57d25 Compare November 8, 2017 06:35
${name}: FontSize::system_font(sys),
% else:
${name}: ${name}::SpecifiedValue::system_font(sys),
% endif

@CYBAI CYBAI Nov 8, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw it got error from this line in Travis.
Due to unfamiliar with the SYSTEM_FONT_LONGHANDS, I just tried to change it with this ugly solution.
If there's any better solution, please tell me and I'll update it.

cc @emilio

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is fine, I can't think of anything better right now. This system_font thing is quite messy too...

@CYBAI CYBAI Nov 8, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is fine, I can't think of anything better right now. This system_font thing is quite messy too...

@emilio

emilio commented Nov 8, 2017

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 0f57d25 has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 8, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 0f57d25 with merge fd8b4b5...

bors-servo pushed a commit that referenced this pull request Nov 8, 2017
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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 8, 2017
@emilio

emilio commented Nov 8, 2017

Copy link
Copy Markdown
Member

@bors-servo retry

That crash can't be caused by this PR, though it looks worrying, cc @jdm

  ▶ CRASH [expected OK] /css/cssom/interfaces.html
  │ 
  │ VMware, Inc.
  │ softpipe
  │ 3.3 (Core Profile) Mesa 17.3.0-devel
  │ Stack trace for thread "ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(NonZero(NonZero(1))) }"
  │ stack backtrace:
  │    0:     0x7fbb8fba8d3c - backtrace::backtrace::trace::h3049d3b23f5565ad
  │    1:     0x7fbb8fba8d72 - backtrace::capture::Backtrace::new::h48230b597774155d
  │    2:     0x7fbb8f91104d - servo::install_crash_handler::handler::h1891983b809387e0
  │    3:     0x7fbb919bf2a3 - AsmJSFaultHandler
  │                         at /home/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/424067c/mozjs/js/src/asmjs/WasmSignalHandlers.cpp:1171
  │    4:     0x7fbb8d81e32f - <unknown>
  │    5:     0x7fbb849e9026 - <unknown>
  │ Stack trace for thread "ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(NonZero(NonZero(1))) }"
  │ stack backtrace:
  │    0:     0x7fbb8fba8d3c - backtrace::backtrace::trace::h3049d3b23f5565ad
  │    1:     0x7fbb8fba8d72 - backtrace::capture::Backtrace::new::h48230b597774155d
  │    2:     0x7fbb8f91104d - servo::install_crash_handler::handler::h1891983b809387e0
  │    3:     0x7fbb8d05dcaf - <unknown>
  │    4:     0x7fbb8f9110c0 - servo::install_crash_handler::handler::h1891983b809387e0
  │    5:     0x7fbb919bf2a3 - AsmJSFaultHandler
  │                         at /home/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/424067c/mozjs/js/src/asmjs/WasmSignalHandlers.cpp:1171
  │    6:     0x7fbb8d81e32f - <unknown>
  └    7:     0x7fbb849e9026 - <unknown>

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ 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...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ 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
Approved by: emilio
Pushing fd8b4b5 to master...

@bors-servo
bors-servo merged commit 0f57d25 into servo:master Nov 8, 2017
@CYBAI
CYBAI deleted the font-size-out-of-mako branch November 8, 2017 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move font-size outside of mako.

5 participants