Changeset 283572 in webkit


Ignore:
Timestamp:
Oct 5, 2021 3:12:56 PM (10 months ago)
Author:
Patrick Angle
Message:

Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
https://bugs.webkit.org/show_bug.cgi?id=231205

Reviewed by Devin Rousso.

Source/JavaScriptCore:

Use an enum instead of strings for color space values sent to the frontend.

  • inspector/protocol/Canvas.json:
  • inspector/scripts/codegen/generator.py:

Source/WebCore:

Use an enum instead of strings for color space values sent to the frontend.

  • inspector/InspectorCanvas.cpp:

(WebCore::buildObjectForCanvasContextAttributes):

Source/WebInspectorUI:

For canvas context's with a color space attribute, show the color space next to the context type in the header
of each context card in the Graphics tab.

  • UserInterface/Models/Canvas.js:

(WI.Canvas.displayNameForColorSpace):

  • UserInterface/Views/CanvasContentView.js:

(WI.CanvasContentView.prototype.initialLayout):

  • UserInterface/Views/CanvasOverviewContentView.css:

(.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),):
(.content-view.canvas-overview > .content-view.canvas > header .color-space::before):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r283567 r283572  
     12021-10-05  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
     4        https://bugs.webkit.org/show_bug.cgi?id=231205
     5
     6        Reviewed by Devin Rousso.
     7
     8        Use an enum instead of strings for color space values sent to the frontend.
     9
     10        * inspector/protocol/Canvas.json:
     11        * inspector/scripts/codegen/generator.py:
     12
    1132021-10-05  Mark Lam  <mark.lam@apple.com>
    214
  • trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json

    r282984 r283572  
    1717        },
    1818        {
     19            "id": "ColorSpace",
     20            "type": "string",
     21            "enum": ["srgb", "display-p3"]
     22        },
     23        {
    1924            "id": "ContextType",
    2025            "type": "string",
     
    4045            "properties": [
    4146                { "name": "alpha", "type": "boolean", "optional": true, "description": "WebGL, WebGL2, ImageBitmapRenderingContext" },
    42                 { "name": "colorSpace", "type": "string", "optional": true, "description": "2D" },
     47                { "name": "colorSpace", "$ref": "ColorSpace", "optional": true, "description": "2D" },
    4348                { "name": "desynchronized", "type": "boolean", "optional": true, "description": "2D" },
    4449                { "name": "depth", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generator.py

    r280467 r283572  
    4343    return str[:1].upper() + str[1:]
    4444
    45 _ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS = set(['2D', 'API', 'CSS', 'DOM', 'HTML', 'JIT', 'XHR', 'XML', 'IOS', 'MacOS', 'JavaScript', 'ServiceWorker'])
     45
     46_ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS = set(['2D', 'API', 'CSS', 'DOM', 'HTML', 'JIT', 'SRGB', 'XHR', 'XML', 'IOS', 'MacOS', 'JavaScript', 'ServiceWorker'])
    4647_ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE = dict([(s.upper(), s) for s in _ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS])
    4748
  • trunk/Source/WebCore/ChangeLog

    r283570 r283572  
     12021-10-05  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
     4        https://bugs.webkit.org/show_bug.cgi?id=231205
     5
     6        Reviewed by Devin Rousso.
     7
     8        Use an enum instead of strings for color space values sent to the frontend.
     9
     10        * inspector/InspectorCanvas.cpp:
     11        (WebCore::buildObjectForCanvasContextAttributes):
     12
    1132021-10-05  Alan Bujtas  <zalan@apple.com>
    214
  • trunk/Source/WebCore/inspector/InspectorCanvas.cpp

    r282984 r283572  
    822822        switch (attributes.colorSpace) {
    823823        case PredefinedColorSpace::SRGB:
    824             contextAttributesPayload->setColorSpace("srgb"_s);
     824            contextAttributesPayload->setColorSpace(Protocol::Canvas::ColorSpace::SRGB);
    825825            break;
    826826
    827827#if ENABLE(PREDEFINED_COLOR_SPACE_DISPLAY_P3)
    828828        case PredefinedColorSpace::DisplayP3:
    829             contextAttributesPayload->setColorSpace("display-p3"_s);
     829            contextAttributesPayload->setColorSpace(Protocol::Canvas::ColorSpace::DisplayP3);
    830830            break;
    831831#endif
  • trunk/Source/WebInspectorUI/ChangeLog

    r283276 r283572  
     12021-10-05  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
     4        https://bugs.webkit.org/show_bug.cgi?id=231205
     5
     6        Reviewed by Devin Rousso.
     7
     8        For canvas context's with a color space attribute, show the color space next to the context type in the header
     9        of each context card in the Graphics tab.
     10
     11        * UserInterface/Models/Canvas.js:
     12        (WI.Canvas.displayNameForColorSpace):
     13        * UserInterface/Views/CanvasContentView.js:
     14        (WI.CanvasContentView.prototype.initialLayout):
     15        * UserInterface/Views/CanvasOverviewContentView.css:
     16        (.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),):
     17        (.content-view.canvas-overview > .content-view.canvas > header .color-space::before):
     18
    1192021-09-29  BJ Burg  <bburg@apple.com>
    220
  • trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js

    r255396 r283572  
    113113    }
    114114
     115    static displayNameForColorSpace(colorSpace)
     116    {
     117        switch(colorSpace) {
     118        case WI.Canvas.ColorSpace.SRGB:
     119            return WI.unlocalizedString("sRGB");
     120        case WI.Canvas.ColorSpace.DisplayP3:
     121            return WI.unlocalizedString("Display P3");
     122        }
     123
     124        console.assert(false, "Unknown canvas color space", colorSpace);
     125        return null;
     126    }
     127
    115128    static resetUniqueDisplayNameNumbers()
    116129    {
     
    455468};
    456469
     470WI.Canvas.ColorSpace = {
     471    SRGB: "srgb",
     472    DisplayP3: "display-p3",
     473};
     474
    457475WI.Canvas.RecordingState = {
    458476    Inactive: "canvas-recording-state-inactive",
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js

    r276170 r283572  
    106106            subtitle.textContent = WI.Canvas.displayNameForContextType(this.representedObject.contextType);
    107107
     108            if (this.representedObject.contextAttributes.colorSpace) {
     109                let subtitle = titles.appendChild(document.createElement("span"));
     110                subtitle.className = "color-space";
     111                subtitle.textContent = "(" + WI.Canvas.displayNameForColorSpace(this.representedObject.contextAttributes.colorSpace) + ")";
     112            }
     113
    108114            let navigationBar = new WI.NavigationBar;
    109115
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.css

    r269166 r283572  
    7777}
    7878
    79 .content-view.canvas-overview > .content-view.canvas > header > .titles > .subtitle,
     79.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),
    8080.content-view.canvas-overview > .content-view.canvas > footer .memory-cost {
    8181    color: var(--text-color-gray-medium);
     
    8484.content-view.canvas-overview > .content-view.canvas > header .subtitle::before {
    8585    content: "\00A0\2014\00A0"; /* &nbsp;&mdash;&nbsp; */;
     86}
     87
     88.content-view.canvas-overview > .content-view.canvas > header .color-space::before {
     89    content: "\00A0"; /* &nbsp; */;
    8690}
    8791
Note: See TracChangeset for help on using the changeset viewer.