Diff
Modified: trunk/Source/WebCore/ChangeLog (264283 => 264284)
--- trunk/Source/WebCore/ChangeLog 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/ChangeLog 2020-07-12 19:46:00 UTC (rev 264284)
@@ -1,3 +1,27 @@
+2020-07-12 Sam Weinig <wei...@apple.com>
+
+ Tidy up color usage in accessibility code
+ https://bugs.webkit.org/show_bug.cgi?id=214226
+
+ Reviewed by Darin Adler.
+
+ Rather than passing around r, g, b components as out-parameters,
+ use SRGBA<uint8_t> return values.
+
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::colorValue const):
+ * accessibility/AccessibilityNodeObject.h:
+ * accessibility/AccessibilityObject.h:
+ * accessibility/AccessibilityObjectInterface.h:
+ * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
+ (webkitAccessibleTextGetText):
+ * accessibility/isolatedtree/AXIsolatedObject.cpp:
+ (WebCore::AXIsolatedObject::initializeAttributeData):
+ (WebCore::AXIsolatedObject::colorValue const):
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+
2020-07-12 Rob Buis <rb...@igalia.com>
Improve IPv6 detection when setting host/hostname
Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (264283 => 264284)
--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2020-07-12 19:46:00 UTC (rev 264284)
@@ -1992,23 +1992,18 @@
return String();
}
-void AccessibilityNodeObject::colorValue(int& r, int& g, int& b) const
+SRGBA<uint8_t> AccessibilityNodeObject::colorValue() const
{
- r = 0;
- g = 0;
- b = 0;
-
-#if ENABLE(INPUT_TYPE_COLOR)
+#if !ENABLE(INPUT_TYPE_COLOR)
+ return Color::transparent;
+#else
if (!isColorWell())
- return;
+ return Color::transparent;
if (!is<HTMLInputElement>(node()))
- return;
+ return Color::transparent;
- auto color = downcast<HTMLInputElement>(*node()).valueAsColor().toSRGBALossy<uint8_t>();
- r = color.red;
- g = color.green;
- b = color.blue;
+ return downcast<HTMLInputElement>(*node()).valueAsColor().toSRGBALossy<uint8_t>();
#endif
}
Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h (264283 => 264284)
--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h 2020-07-12 19:46:00 UTC (rev 264284)
@@ -112,7 +112,7 @@
String title() const override;
String text() const override;
String stringValue() const override;
- void colorValue(int& r, int& g, int& b) const override;
+ SRGBA<uint8_t> colorValue() const override;
String ariaLabeledByAttribute() const override;
bool hasAttributesRequiredForInclusion() const final;
void setIsExpanded(bool) override;
Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (264283 => 264284)
--- trunk/Source/WebCore/accessibility/AccessibilityObject.h 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h 2020-07-12 19:46:00 UTC (rev 264284)
@@ -403,7 +403,7 @@
void elementsFromAttribute(Vector<Element*>&, const QualifiedName&) const override;
// Only if isColorWell()
- void colorValue(int& r, int& g, int& b) const override { r = 0; g = 0; b = 0; }
+ SRGBA<uint8_t> colorValue() const override { return Color::transparent; }
AccessibilityRole roleValue() const override { return m_role; }
String rolePlatformString() const override;
Modified: trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h (264283 => 264284)
--- trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h 2020-07-12 19:46:00 UTC (rev 264284)
@@ -840,7 +840,7 @@
virtual void elementsFromAttribute(Vector<Element*>&, const QualifiedName&) const = 0;
// Only if isColorWell()
- virtual void colorValue(int& r, int& g, int& b) const = 0;
+ virtual SRGBA<uint8_t> colorValue() const = 0;
virtual AccessibilityRole roleValue() const = 0;
// Non-localized string associated with the object role.
Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp (264283 => 264284)
--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp 2020-07-12 19:46:00 UTC (rev 264284)
@@ -448,9 +448,8 @@
#if ENABLE(INPUT_TYPE_COLOR)
if (coreObject->roleValue() == AccessibilityRole::ColorWell) {
- int r, g, b;
- coreObject->colorValue(r, g, b);
- return g_strdup_printf("rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.);
+ auto color = convertToComponentFloats(coreObject->colorValue());
+ return g_strdup_printf("rgb %7.5f %7.5f %7.5f 1", color.red, color.green, color.blue);
}
#endif
Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (264283 => 264284)
--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm 2020-07-12 19:46:00 UTC (rev 264284)
@@ -1422,9 +1422,8 @@
return nil;
if (self.axBackingObject->isColorWell()) {
- int r, g, b;
- self.axBackingObject->colorValue(r, g, b);
- return [NSString stringWithFormat:@"rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.];
+ auto color = convertToComponentFloats(self.axBackingObject->colorValue());
+ return [NSString stringWithFormat:@"rgb %7.5f %7.5f %7.5f 1", color.red, color.green, color.blue];
}
return nil;
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (264283 => 264284)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2020-07-12 19:46:00 UTC (rev 264284)
@@ -350,11 +350,9 @@
combinedClassList.append(" ");
}
setProperty(AXPropertyName::ClassList, combinedClassList);
+
+ setProperty(AXPropertyName::ColorValue, object.colorValue());
- int r, g, b;
- object.colorValue(r, g, b);
- setProperty(AXPropertyName::ColorValue, makeSimpleColor(r, g, b));
-
if (bool isMathElement = object.isMathElement()) {
setProperty(AXPropertyName::IsMathElement, isMathElement);
setProperty(AXPropertyName::IsAnonymousMathOperator, object.isAnonymousMathOperator());
@@ -708,12 +706,9 @@
});
}
-void AXIsolatedObject::colorValue(int& r, int& g, int& b) const
+SRGBA<uint8_t> AXIsolatedObject::colorValue() const
{
- auto color = colorAttributeValue(AXPropertyName::ColorValue).toSRGBALossy<uint8_t>();
- r = color.red;
- g = color.green;
- b = color.blue;
+ return colorAttributeValue(AXPropertyName::ColorValue).toSRGBALossy<uint8_t>();
}
AXCoreObject* AXIsolatedObject::accessibilityHitTest(const IntPoint& point) const
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (264283 => 264284)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2020-07-12 19:46:00 UTC (rev 264284)
@@ -541,7 +541,7 @@
const String placeholderValue() const override { return stringAttributeValue(AXPropertyName::PlaceholderValue); }
String expandedTextValue() const override { return stringAttributeValue(AXPropertyName::ExpandedTextValue); }
bool supportsExpandedTextValue() const override { return boolAttributeValue(AXPropertyName::SupportsExpandedTextValue); }
- void colorValue(int&, int&, int&) const override;
+ SRGBA<uint8_t> colorValue() const override;
AccessibilityRole roleValue() const override { return static_cast<AccessibilityRole>(intAttributeValue(AXPropertyName::RoleValue)); }
String rolePlatformString() const override { return stringAttributeValue(AXPropertyName::RolePlatformString); }
String roleDescription() const override { return stringAttributeValue(AXPropertyName::RoleDescription); }
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (264283 => 264284)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2020-07-12 18:53:53 UTC (rev 264283)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2020-07-12 19:46:00 UTC (rev 264284)
@@ -2542,9 +2542,8 @@
return @(backingObject->isSelected());
if (backingObject->isColorWell()) {
- int r, g, b;
- backingObject->colorValue(r, g, b);
- return [NSString stringWithFormat:@"rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.];
+ auto color = convertToComponentFloats(backingObject->colorValue());
+ return [NSString stringWithFormat:@"rgb %7.5f %7.5f %7.5f 1", color.red, color.green, color.blue];
}
return backingObject->stringValue();