Fix the lldb Color formatter
https://bugs.webkit.org/show_bug.cgi?id=235613

Reviewed by Darin Adler.
Source/WebCore:

* platform/graphics/ColorSpace.h:

Tools:

Copy the list of color spaces from ColorSpace.h

* lldb/lldb_webkit.py:
(WebCoreColorProvider._to_string_out_of_line):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index a1cd68ec..a351787 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,12 @@
+2022-01-25  Simon Fraser  <simon.fraser@apple.com>
+
+        Fix the lldb Color formatter
+        https://bugs.webkit.org/show_bug.cgi?id=235613
+
+        Reviewed by Darin Adler.
+
+        * platform/graphics/ColorSpace.h:
+
 2022-01-25  Alexey Shvayka  <ashvayka@apple.com>
 
         Remove unused Document::ListenerType enumerators
diff --git a/Source/WebCore/platform/graphics/ColorSpace.h b/Source/WebCore/platform/graphics/ColorSpace.h
index 3ed0326..8193f3d 100644
--- a/Source/WebCore/platform/graphics/ColorSpace.h
+++ b/Source/WebCore/platform/graphics/ColorSpace.h
@@ -32,6 +32,7 @@
 
 namespace WebCore {
 
+// Tools/lldb/lldb_webkit.py has a copy of this list, which should be kept in sync.
 enum class ColorSpace : uint8_t {
     A98RGB,
     DisplayP3,
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index f6984e4..b54f392 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,15 @@
+2022-01-25  Simon Fraser  <simon.fraser@apple.com>
+
+        Fix the lldb Color formatter
+        https://bugs.webkit.org/show_bug.cgi?id=235613
+
+        Reviewed by Darin Adler.
+        
+        Copy the list of color spaces from ColorSpace.h
+
+        * lldb/lldb_webkit.py:
+        (WebCoreColorProvider._to_string_out_of_line):
+
 2022-01-25  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         UIWKDocumentRequestSpatialAndCurrentSelection should limit context to the editable root of the current selection
diff --git a/Tools/lldb/lldb_webkit.py b/Tools/lldb/lldb_webkit.py
index 984af7c..b7512f5 100644
--- a/Tools/lldb/lldb_webkit.py
+++ b/Tools/lldb/lldb_webkit.py
@@ -534,28 +534,31 @@
 
         color_space = self._color_space(rgba_and_flags)
 
-        if color_space == 0:
-            profile = 'a98-rgb'
-        elif color_space == 1:
-            profile = 'display-p3'
-        elif color_space == 2:
-            profile = 'lch'
-        elif color_space == 3:
-            profile = 'lab'
-        elif color_space == 4:
-            profile = 'linear-srgb'
-        elif color_space == 5:
-            profile = 'linear-srgb'
-        elif color_space == 6:
-            profile = 'prophoto-rgb'
-        elif color_space == 7:
-            profile = 'rec2020'
-        elif color_space == 8:
-            profile = 'srgb'
-        elif color_space == 9:
-            profile = 'xyz-d50'
-        else:
-            profile = 'unknown'
+        # From ColorSpace.h.
+        color_spaces = [
+            'A98RGB',
+            'DisplayP3',
+            'ExtendedA98RGB',
+            'ExtendedDisplayP3',
+            'ExtendedLinearSRGB',
+            'ExtendedProPhotoRGB',
+            'ExtendedRec2020',
+            'ExtendedSRGB',
+            'HSL',
+            'HWB',
+            'LCH',
+            'Lab',
+            'LinearSRGB',
+            'OKLCH',
+            'OKLab',
+            'ProPhotoRGB',
+            'Rec2020',
+            'SRGB',
+            'XYZ_D50',
+            'XYZ_D65',
+        ]
+
+        profile = color_spaces[color_space] if color_space < len(color_spaces) else 'unknown'
 
         color_components = out_of_line_components.GetChildMemberWithName('m_components')
         std_array_elems = color_components.GetChildMemberWithName('components').GetChildMemberWithName('__elems_')