Title: [270167] trunk/Source/WebCore
Revision
270167
Author
[email protected]
Date
2020-11-26 15:59:37 -0800 (Thu, 26 Nov 2020)

Log Message

Fix non-unified build problem in CSSPropertyParserHelpers.cpp along with a little refactoring
https://bugs.webkit.org/show_bug.cgi?id=219222

Reviewed by Sam Weinig.

* css/parser/CSSPropertyParser.cpp:
(WebCore::fontStyleIsWithinRange): Deleted.
(WebCore::consumeFontStyleRange): Updated for name change to isFontStyleAngleInRange,
don't force angles to float since the values are stored as double. Use local variables
to avoid multiple calls to doubleValue.

* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::isCSSWideKeyword): Moved inline function here
from the header since it's only used inside this file.
(WebCore::CSSPropertyParserHelpers::consumeFontStyleRaw): Updated for the name change
of isFontStyleAngleInRange, and also eliminated local since it's clear without it.

* css/parser/CSSPropertyParserHelpers.h:
(WebCore::CSSPropertyParserHelpers::isCSSWideKeyword): Deleted. This had "static" on it
in a header, which is not good style, but also didn't need to be in a header.
(WebCore::CSSPropertyParserHelpers::isFontStyleAngleInRange): Moved this here so we can
use it in two different .cpp files. Also renamed it for improved clarity, and used an
inline function because this is super simple.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270166 => 270167)


--- trunk/Source/WebCore/ChangeLog	2020-11-26 23:56:03 UTC (rev 270166)
+++ trunk/Source/WebCore/ChangeLog	2020-11-26 23:59:37 UTC (rev 270167)
@@ -1,3 +1,29 @@
+2020-11-26  Darin Adler  <[email protected]>
+
+        Fix non-unified build problem in CSSPropertyParserHelpers.cpp along with a little refactoring
+        https://bugs.webkit.org/show_bug.cgi?id=219222
+
+        Reviewed by Sam Weinig.
+
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::fontStyleIsWithinRange): Deleted.
+        (WebCore::consumeFontStyleRange): Updated for name change to isFontStyleAngleInRange,
+        don't force angles to float since the values are stored as double. Use local variables
+        to avoid multiple calls to doubleValue.
+
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::isCSSWideKeyword): Moved inline function here
+        from the header since it's only used inside this file.
+        (WebCore::CSSPropertyParserHelpers::consumeFontStyleRaw): Updated for the name change
+        of isFontStyleAngleInRange, and also eliminated local since it's clear without it.
+
+        * css/parser/CSSPropertyParserHelpers.h:
+        (WebCore::CSSPropertyParserHelpers::isCSSWideKeyword): Deleted. This had "static" on it
+        in a header, which is not good style, but also didn't need to be in a header.
+        (WebCore::CSSPropertyParserHelpers::isFontStyleAngleInRange): Moved this here so we can
+        use it in two different .cpp files. Also renamed it for improved clarity, and used an
+        inline function because this is super simple.
+
 2020-11-22  Antti Koivisto  <[email protected]>
 
         [LFC][Integration] Convert some remaining InlineBox access to use inline iterator

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (270166 => 270167)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-11-26 23:56:03 UTC (rev 270166)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-11-26 23:59:37 UTC (rev 270167)
@@ -957,13 +957,6 @@
     return consumeIdent<CSSValueNormal, CSSValueItalic, CSSValueOblique>(range);
 }
 
-#if ENABLE(VARIATION_FONTS)
-static bool fontStyleIsWithinRange(float oblique)
-{
-    return oblique > -90 && oblique < 90;
-}
-#endif
-
 static RefPtr<CSSFontStyleValue> consumeFontStyle(CSSParserTokenRange& range, CSSParserMode cssParserMode)
 {
     if (auto result = consumeFontStyleRaw(range, cssParserMode)) {
@@ -989,7 +982,8 @@
         return CSSFontStyleRangeValue::create(keyword.releaseNonNull());
 
     if (auto firstAngle = consumeAngle(range, cssParserMode)) {
-        if (!fontStyleIsWithinRange(firstAngle->value<float>(CSSUnitType::CSS_DEG)))
+        auto firstAngleInDegrees = firstAngle->doubleValue(CSSUnitType::CSS_DEG);
+        if (!isFontStyleAngleInRange(firstAngleInDegrees))
             return nullptr;
         if (range.atEnd()) {
             auto result = CSSValueList::createSpaceSeparated();
@@ -997,8 +991,11 @@
             return CSSFontStyleRangeValue::create(keyword.releaseNonNull(), WTFMove(result));
         }
         auto secondAngle = consumeAngle(range, cssParserMode);
-        if (!secondAngle || !fontStyleIsWithinRange(secondAngle->value<float>(CSSUnitType::CSS_DEG)) || firstAngle->floatValue(CSSUnitType::CSS_DEG) > secondAngle->floatValue(CSSUnitType::CSS_DEG))
+        if (!secondAngle)
             return nullptr;
+        auto secondAngleInDegrees = secondAngle->doubleValue(CSSUnitType::CSS_DEG);
+        if (!isFontStyleAngleInRange(secondAngleInDegrees) || firstAngleInDegrees > secondAngleInDegrees)
+            return nullptr;
         auto result = CSSValueList::createSpaceSeparated();
         result->append(firstAngle.releaseNonNull());
         result->append(secondAngle.releaseNonNull());

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (270166 => 270167)


--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp	2020-11-26 23:56:03 UTC (rev 270166)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp	2020-11-26 23:59:37 UTC (rev 270167)
@@ -51,6 +51,11 @@
 
 namespace CSSPropertyParserHelpers {
 
+static inline bool isCSSWideKeyword(CSSValueID id)
+{
+    return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset || id == CSSValueRevert || id == CSSValueDefault;
+}
+
 bool consumeCommaIncludingWhitespace(CSSParserTokenRange& range)
 {
     CSSParserToken value = range.peek();
@@ -1953,8 +1958,7 @@
 #if ENABLE(VARIATION_FONTS)
     if (!range.atEnd()) {
         if (auto angle = consumeAngleRaw(range, cssParserMode)) {
-            auto angleInDegrees = CSSPrimitiveValue::computeDegrees(angle->type, angle->value);
-            if (fontStyleIsWithinRange(angleInDegrees))
+            if (isFontStyleAngleInRange(CSSPrimitiveValue::computeDegrees(angle->type, angle->value)))
                 return { { CSSValueOblique, WTFMove(angle) } };
             return WTF::nullopt;
         }

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h (270166 => 270167)


--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h	2020-11-26 23:56:03 UTC (rev 270166)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h	2020-11-26 23:59:37 UTC (rev 270167)
@@ -67,7 +67,7 @@
     double value;
 };
 
-using LengthOrPercentRaw = WTF::Variant<LengthRaw, double>;
+using LengthOrPercentRaw = Variant<LengthRaw, double>;
 
 RefPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRange&, double minimumValue = -std::numeric_limits<double>::max());
 RefPtr<CSSPrimitiveValue> consumePositiveInteger(CSSParserTokenRange&);
@@ -134,10 +134,10 @@
     CSSValueID style;
     Optional<AngleRaw> angle;
 };
-using FontWeightRaw = WTF::Variant<CSSValueID, double>;
-using FontSizeRaw = WTF::Variant<CSSValueID, CSSPropertyParserHelpers::LengthOrPercentRaw>;
-using LineHeightRaw = WTF::Variant<CSSValueID, double, CSSPropertyParserHelpers::LengthOrPercentRaw>;
-using FontFamilyRaw = WTF::Variant<CSSValueID, String>;
+using FontWeightRaw = Variant<CSSValueID, double>;
+using FontSizeRaw = Variant<CSSValueID, CSSPropertyParserHelpers::LengthOrPercentRaw>;
+using LineHeightRaw = Variant<CSSValueID, double, CSSPropertyParserHelpers::LengthOrPercentRaw>;
+using FontFamilyRaw = Variant<CSSValueID, String>;
 
 struct FontRaw {
     Optional<FontStyleRaw> style;
@@ -146,7 +146,7 @@
     Optional<CSSValueID> stretch;
     FontSizeRaw size;
     Optional<LineHeightRaw> lineHeight;
-    WTF::Vector<FontFamilyRaw> family;
+    Vector<FontFamilyRaw> family;
 };
 
 Optional<CSSValueID> consumeFontVariantCSS21Raw(CSSParserTokenRange&);
@@ -158,14 +158,16 @@
 String concatenateFamilyName(CSSParserTokenRange&);
 String consumeFamilyNameRaw(CSSParserTokenRange&);
 Optional<CSSValueID> consumeGenericFamilyRaw(CSSParserTokenRange&);
-Optional<WTF::Vector<FontFamilyRaw>> consumeFontFamilyRaw(CSSParserTokenRange&);
+Optional<Vector<FontFamilyRaw>> consumeFontFamilyRaw(CSSParserTokenRange&);
 Optional<FontSizeRaw> consumeFontSizeRaw(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk = UnitlessQuirk::Forbid);
 Optional<LineHeightRaw> consumeLineHeightRaw(CSSParserTokenRange&, CSSParserMode);
 Optional<FontRaw> consumeFontWorkerSafe(CSSParserTokenRange&, CSSParserMode);
 const AtomString& genericFontFamilyFromValueID(CSSValueID);
 
-// Template implementations are at the bottom of the file for readability.
+bool isFontStyleAngleInRange(double angleInDegrees);
 
+// Template and inline implementations are at the bottom of the file for readability.
+
 template<typename... emptyBaseCase> inline bool identMatches(CSSValueID) { return false; }
 template<CSSValueID head, CSSValueID... tail> inline bool identMatches(CSSValueID id)
 {
@@ -186,9 +188,9 @@
     return CSSValuePool::singleton().createIdentifierValue(range.consumeIncludingWhitespace().id());
 }
 
-static inline bool isCSSWideKeyword(const CSSValueID& id)
+inline bool isFontStyleAngleInRange(double angleInDegrees)
 {
-    return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset || id == CSSValueRevert || id == CSSValueDefault;
+    return angleInDegrees > -90 && angleInDegrees < 90;
 }
 
 } // namespace CSSPropertyParserHelpers
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to