Changeset 271620 in webkit


Ignore:
Timestamp:
Jan 19, 2021 2:55:26 PM (18 months ago)
Author:
Patrick Angle
Message:

Web Inspector: Font Details sidebar - Fractional variation axis ranges/default values are rounded.
https://bugs.webkit.org/show_bug.cgi?id=220474

Reviewed by BJ Burg.

Source/WebCore:

Use float instead of int for variation axis range and defaults, as these values can be fractional.

  • platform/graphics/FontPlatformData.h:

(WebCore::FontPlatformData::FontVariationAxis::FontVariationAxis):
(WebCore::FontPlatformData::FontVariationAxis::defaultValue const):
(WebCore::FontPlatformData::FontVariationAxis::minimumValue const):
(WebCore::FontPlatformData::FontVariationAxis::maximumValue const):

Source/WebInspectorUI:

Fixes Font Details sidebar display of variation axis values, ranges, and defaults to show fractional precision
when such precision is present.

  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Views/FontDetailsPanel.js:

(WI.FontDetailsPanel.prototype.refresh):
(WI.FontDetailsPanel.prototype._formatSimpleSingleValue):
(WI.FontDetailsPanel.prototype._formatVariationValue):
(WI.FontDetailsPanel.prototype._createVariationValueElement):
(WI.FontDetailsPanel.prototype._formatAxisValueAsString):

  • Show fractional values with between 0 and 2 decimal places.
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271619 r271620  
     12021-01-19  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Font Details sidebar - Fractional variation axis ranges/default values are rounded.
     4        https://bugs.webkit.org/show_bug.cgi?id=220474
     5
     6        Reviewed by BJ Burg.
     7
     8        Use float instead of int for variation axis range and defaults, as these values can be fractional.
     9
     10        * platform/graphics/FontPlatformData.h:
     11        (WebCore::FontPlatformData::FontVariationAxis::FontVariationAxis):
     12        (WebCore::FontPlatformData::FontVariationAxis::defaultValue const):
     13        (WebCore::FontPlatformData::FontVariationAxis::minimumValue const):
     14        (WebCore::FontPlatformData::FontVariationAxis::maximumValue const):
     15
    1162021-01-19  Alex Christensen  <achristensen@webkit.org>
    217
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r270637 r271620  
    8282   
    8383    struct FontVariationAxis {
    84         FontVariationAxis(const String& name, const String& tag, int defaultValue, int minimumValue, int maximumValue)
     84        FontVariationAxis(const String& name, const String& tag, float defaultValue, float minimumValue, float maximumValue)
    8585            : m_name(name)
    8686            , m_tag(tag)
     
    9393        const String& name() const { return m_name; }
    9494        const String& tag() const { return m_tag; }
    95         int defaultValue() const { return m_defaultValue; }
    96         int minimumValue() const { return m_minimumValue; }
    97         int maximumValue() const { return m_maximumValue; }
     95        float defaultValue() const { return m_defaultValue; }
     96        float minimumValue() const { return m_minimumValue; }
     97        float maximumValue() const { return m_maximumValue; }
    9898
    9999    private:
    100100        const String m_name;
    101101        const String m_tag;
    102         int m_defaultValue;
    103         int m_minimumValue;
    104         int m_maximumValue;
     102        float m_defaultValue;
     103        float m_minimumValue;
     104        float m_maximumValue;
    105105    };
    106106
  • trunk/Source/WebInspectorUI/ChangeLog

    r271612 r271620  
     12021-01-19  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Font Details sidebar - Fractional variation axis ranges/default values are rounded.
     4        https://bugs.webkit.org/show_bug.cgi?id=220474
     5
     6        Reviewed by BJ Burg.
     7
     8        Fixes Font Details sidebar display of variation axis values, ranges, and defaults to show fractional precision
     9        when such precision is present.
     10
     11        * Localizations/en.lproj/localizedStrings.js:
     12        * UserInterface/Views/FontDetailsPanel.js:
     13        (WI.FontDetailsPanel.prototype.refresh):
     14        (WI.FontDetailsPanel.prototype._formatSimpleSingleValue):
     15        (WI.FontDetailsPanel.prototype._formatVariationValue):
     16        (WI.FontDetailsPanel.prototype._createVariationValueElement):
     17        (WI.FontDetailsPanel.prototype._formatAxisValueAsString):
     18        - Show fractional values with between 0 and 2 decimal places.
     19
    1202021-01-19  Patrick Angle  <pangle@apple.com>
    221
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r271612 r271620  
    33localizedStrings[" (Prototype)"] = " (Prototype)";
    44/* A range and default value for a single variation axis of a font. */
    5 localizedStrings[" (Range: %d-%d, Default: %d) @ Font Details Sidebar"] = " (Range: %d-%d, Default: %d)";
     5localizedStrings[" (Range: %s-%s, Default: %s) @ Font Details Sidebar"] = " (Range: %s-%s, Default: %s)";
    66localizedStrings[" (line %s)"] = " (line %s)";
    77localizedStrings["${expr} = expression"] = "${expr} = expression";
     
    5151localizedStrings["%d resource"] = "%d resource";
    5252localizedStrings["%d resources"] = "%d resources";
    53 localizedStrings["%d%%"] = "%d%%";
    5453localizedStrings["%dpx"] = "%dpx";
    5554localizedStrings["%dpx\u00B2"] = "%dpx\u00B2";
     
    7776localizedStrings["%s total"] = "%s total";
    7877localizedStrings["%s transferred"] = "%s transferred";
     78/* A single value expressed as a percentage where the value has already been converted from a number to a string. */
     79localizedStrings["%s%% @ Font Details Sidebar"] = "%s%%";
    7980localizedStrings["%s:"] = "%s:";
    8081localizedStrings["(%s)"] = "(%s)";
  • trunk/Source/WebInspectorUI/UserInterface/Views/FontDetailsPanel.js

    r271612 r271620  
    5858        this._fontSizeRow.value = this._formatSizeValue(this._fontPropertiesMap.get("font-size"));
    5959        this._fontStyleRow.value = this._formatStyleValue(this._fontPropertiesMap.get("font-style"));
    60         this._fontWeightRow.value = this._formatSimpleSingleValue(this._fontPropertiesMap.get("font-weight"), "wght", "%d");
    61         this._fontStretchRow.value = this._formatSimpleSingleValue(this._fontPropertiesMap.get("font-stretch"), "wdth", WI.UIString("%d%%"));
     60        this._fontWeightRow.value = this._formatSimpleSingleValue(this._fontPropertiesMap.get("font-weight"), "wght", "%s");
     61        this._fontStretchRow.value = this._formatSimpleSingleValue(this._fontPropertiesMap.get("font-stretch"), "wdth", WI.UIString("%s%%", "%s%% @ Font Details Sidebar", "A single value expressed as a percentage where the value has already been converted from a number to a string."));
    6262
    6363        this._fontVariantLigaturesRow.value = this._formatLigatureValue(this._fontPropertiesMap.get("font-variant-ligatures"));
     
    155155        let result;
    156156        if (this._hasVariationValue(property, variationTag))
    157             result = variationFormat.format(property.variations.get(variationTag).value);
     157            result = variationFormat.format(this._formatAxisValueAsString(property.variations.get(variationTag).value));
    158158        else
    159             result = property.value;
     159            result = this._formatAxisValueAsString(property.value);
    160160
    161161        if (this._hasVariationValue(property, variationTag, {optional: true})) {
     
    170170    {
    171171        let value = variation.value || variation.value === 0 ? variation.value : variation.defaultValue;
    172         return this._createVariationValueElement(value, variation.minimumValue, variation.maximumValue, variation.defaultValue);
     172        return this._createVariationValueElement(this._formatAxisValueAsString(value), variation.minimumValue, variation.maximumValue, variation.defaultValue);
    173173    }
    174174
     
    180180        let secondaryElement = valueElement.appendChild(document.createElement("span"));
    181181        secondaryElement.className = "secondary";
    182         secondaryElement.textContent = WI.UIString(" (Range: %d-%d, Default: %d)", " (Range: %d-%d, Default: %d) @ Font Details Sidebar", "A range and default value for a single variation axis of a font.").format(minimumValue, maximumValue, defaultValue);
     182        secondaryElement.textContent = WI.UIString(" (Range: %s-%s, Default: %s)", " (Range: %s-%s, Default: %s) @ Font Details Sidebar", "A range and default value for a single variation axis of a font.").format(this._formatAxisValueAsString(minimumValue), this._formatAxisValueAsString(maximumValue), this._formatAxisValueAsString(defaultValue));
    183183       
    184184        return valueElement;
     185    }
     186
     187    _formatAxisValueAsString(value)
     188    {
     189        const options = {
     190            minimumFractionDigits: 0,
     191            maximumFractionDigits: 2,
     192            useGrouping: false,
     193        }
     194        return value.toLocaleString(undefined, options);
    185195    }
    186196
Note: See TracChangeset for help on using the changeset viewer.