From 1f45fc0339dc1997ea254c55def330cde4dcac2e Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Wed, 12 Sep 2018 17:37:37 +1000 Subject: [PATCH] style: Update comments to no longer point to nsRuleNode. There are a few mentions of nsRuleNode left but they are mostly historical references so it makes sense to keep them. Differential Revision: https://phabricator.services.mozilla.com/D5505 --- components/style/properties/gecko.mako.rs | 24 ++++++++++++----------- components/style/rule_tree/mod.rs | 3 --- components/style/values/specified/font.rs | 10 ++++++---- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 9e9a6835a42..1de99ec16f1 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -2403,7 +2403,8 @@ fn static_assert() { /// Calculates the constrained and unconstrained font sizes to be inherited /// from the parent. /// - /// See ComputeScriptLevelSize in Gecko's nsRuleNode.cpp + /// This is a port of Gecko's old ComputeScriptLevelSize function: + /// https://dxr.mozilla.org/mozilla-central/rev/35fbf14b9/layout/style/nsRuleNode.cpp#3197-3254 /// /// scriptlevel is a property that affects how font-size is inherited. If scriptlevel is /// +1, for example, it will inherit as the script size multiplier times @@ -2511,17 +2512,18 @@ fn static_assert() { = self.calculate_script_level_size(parent, device); if adjusted_size.0 != parent.gecko.mSize || adjusted_unconstrained_size.0 != parent.gecko.mScriptUnconstrainedSize { - // This is incorrect. When there is both a keyword size being inherited - // and a scriptlevel change, we must handle the keyword size the same - // way we handle em units. This complicates things because we now have - // to keep track of the adjusted and unadjusted ratios in the kw font size. - // This only affects the use case of a generic font being used in MathML. + // FIXME(Manishearth): This is incorrect. When there is both a + // keyword size being inherited and a scriptlevel change, we must + // handle the keyword size the same way we handle em units. This + // complicates things because we now have to keep track of the + // adjusted and unadjusted ratios in the kw font size. This only + // affects the use case of a generic font being used in MathML. // - // If we were to fix this I would prefer doing it by removing the - // ruletree walk on the Gecko side in nsRuleNode::SetGenericFont - // and instead using extra bookkeeping in the mSize and mScriptUnconstrainedSize - // values, and reusing those instead of font_size_keyword. - + // If we were to fix this I would prefer doing it not doing + // something like the ruletree walk that Gecko used to do in + // nsRuleNode::SetGenericFont and instead using extra bookkeeping in + // the mSize and mScriptUnconstrainedSize values, and reusing those + // instead of font_size_keyword. // In the case that MathML has given us an adjusted size, apply it. // Keep track of the unconstrained adjusted size. diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index d4fb0d00925..26c089eb4ad 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -1200,9 +1200,6 @@ impl StrongRuleNode { } } - /// Implementation of `nsRuleNode::HasAuthorSpecifiedRules` for Servo rule - /// nodes. - /// /// Returns true if any properties specified by `rule_type_mask` was set by /// an author rule. #[cfg(feature = "gecko")] diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs index d9cf921bca5..5613ae603d2 100644 --- a/components/style/values/specified/font.rs +++ b/components/style/values/specified/font.rs @@ -746,7 +746,12 @@ impl ToComputedValue for KeywordSize { fn to_computed_value(&self, cx: &Context) -> NonNegativeLength { use context::QuirksMode; use values::specified::length::au_to_int_px; - // Data from nsRuleNode.cpp in Gecko + + // The tables in this function are originally from + // nsRuleNode::CalcFontPointSize in Gecko: + // + // https://dxr.mozilla.org/mozilla-central/rev/35fbf14b9/layout/style/nsRuleNode.cpp#3262-3336 + // Mapping from base size and HTML size to pixels // The first index is (base_size - 9), the second is the // HTML size. "0" is CSS keyword xx-small, not HTML size 0, @@ -765,9 +770,6 @@ impl ToComputedValue for KeywordSize { [9, 10, 13, 16, 18, 24, 32, 48], ]; - // Data from nsRuleNode.cpp in Gecko - // (https://dxr.mozilla.org/mozilla-central/rev/35fbf14b9/layout/style/nsRuleNode.cpp#3303) - // // This table gives us compatibility with WinNav4 for the default fonts only. // In WinNav4, the default fonts were: //