Diff
Modified: trunk/Source/WebCore/ChangeLog (264049 => 264050)
--- trunk/Source/WebCore/ChangeLog 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/ChangeLog 2020-07-08 00:53:09 UTC (rev 264050)
@@ -1,3 +1,135 @@
+2020-07-07 Sam Weinig <[email protected]>
+
+ Part 2 of SimpleColor and SRGBA<uint8_t> are essentially the same - let's converge them
+ https://bugs.webkit.org/show_bug.cgi?id=213981
+
+ Reviewed by Darin Adler.
+
+ - Replaces internal representation of SimpleColor based on an ARGB uint32_t with SRGBA<uint8_t>.
+ - Removes SimpleColor constructor taking a uint32_t. Callers that still need to convert from ARGB
+ now do makeSimpleColor(asSRGBA(Packed::ARGB { value })).
+ - Removes value() and valueAsARGB() member functions from SimpleColor. Callers that need a packed
+ representation now do Packed::ARGB { simpleColor.asSRGBA<uint8_t>() }.value.
+
+ * css/StyleColor.cpp:
+ (WebCore::StyleColor::colorFromKeyword):
+ Use asSRGBA(Packed::ARGB{...}) to constuct the color.
+
+ * css/parser/CSSParserFastPaths.cpp:
+ (WebCore::finishParsingNamedColor):
+ Use asSRGBA(Packed::ARGB{...}) (or in one case, Packed::RGBA) to constuct the color.
+ These can almost certainly be simplified, but in the interest of keeping things smallish,
+ I have left that for a subsequent change.
+
+ * editing/CompositionHighlight.h:
+ Switch to using auto/makeSimpleColor.
+
+ * page/cocoa/ResourceUsageOverlayCocoa.mm:
+ Switch to using makeSimpleColor.
+
+ (WebCore::HistoricMemoryCategoryInfo::HistoricMemoryCategoryInfo):
+ (WebCore::HistoricResourceUsageData::HistoricResourceUsageData):
+ Switch to using auto/makeSimpleColor.
+
+ * platform/adwaita/ScrollbarThemeAdwaita.cpp:
+ Switch to using auto/makeSimpleColor.
+
+ * platform/graphics/Color.cpp:
+ * platform/graphics/Color.h:
+ - Switch to using auto/makeSimpleColor for named colors.
+ - Switch to storing/encoding the inline SimpleColor as a Packed::RGBA value.
+
+ * platform/graphics/ColorBlending.cpp:
+ (WebCore::blend):
+ Update for new name of clampToComponentBytes.
+
+ * platform/graphics/ColorTypes.h:
+ (WebCore::Packed::RGBA::RGBA):
+ (WebCore::Packed::ARGB::ARGB):
+ (WebCore::asSRGBA):
+ Rename WebCore::ARGB to WebCore::Packed::ARGB. Adds companion, WebCore::Packed::RGBA. And adds constructors
+ which make a packed type from an SRGBA<uint8_t>.
+
+ * platform/graphics/ColorUtilities.h:
+ (WebCore::clampToComponentByte):
+ (WebCore::clampToComponentFloat):
+ Extract out helper functions which just do the clamping for the type.
+
+ (WebCore::clampToComponentBytes):
+ (WebCore::clampToComponentFloats):
+ Rename conversion functions that just clamp to use "clamp" prefix rather than "convert". Make use
+ of extracted helpers.
+
+ * platform/graphics/ImageBackingStore.h:
+ (WebCore::ImageBackingStore::blendPixel):
+ (WebCore::ImageBackingStore::pixelValue const):
+ Update using new packed color types and funtions.
+
+ * platform/graphics/SimpleColor.h:
+ (WebCore::SimpleColor::SimpleColor):
+ (WebCore::SimpleColor::alphaComponent const):
+ (WebCore::SimpleColor::alphaComponentAsFloat const):
+ (WebCore::SimpleColor::isOpaque const):
+ (WebCore::SimpleColor::isVisible const):
+ (WebCore::SimpleColor::colorWithAlpha const):
+ (WebCore::SimpleColor::invertedColorWithAlpha const):
+ (WebCore::SimpleColor::asSRGBA const):
+ (WebCore::SimpleColor::get const):
+ (WebCore::makeSimpleColor):
+ (WebCore::SimpleColor::valueAsARGB const): Deleted.
+ (WebCore::SimpleColor::value const): Deleted.
+ (WebCore::SimpleColor::redComponent const): Deleted.
+ (WebCore::SimpleColor::greenComponent const): Deleted.
+ (WebCore::SimpleColor::blueComponent const): Deleted.
+ - Removes constructor taking an ARGB uint32_t.
+ - Removes valueAsARGB()/value() functions (can use Packed::ARGB directly if needed).
+ - Switches internal representation to SRGBA<uint8_t>.
+ - Streamline makeSimpleColor functions to use shared helpers from ColorUtilities.h
+
+ * platform/graphics/cg/ColorCG.cpp:
+ (WebCore::cachedCGColor):
+ * platform/graphics/mac/ColorMac.mm:
+ (WebCore::nsColor):
+ Use Packed::RGBA to extract uint32_t for quick lookup of transparent/white/black SimpleColors. Despite the
+ length of the calls, SimpleColor is fully constexpr, so these actually collapse down to the uint32_t representation
+ at compile time.
+
+ * platform/graphics/win/GraphicsContextCGWin.cpp:
+ (WebCore::GraphicsContext::drawDotsForDocumentMarker):
+ Switch to using auto/makeSimpleColor.
+
+ * platform/mock/MockRealtimeMediaSourceCenter.cpp:
+ (WebCore::defaultDevices):
+ Switch to using makeSimpleColor.
+
+ * platform/mock/MockRealtimeVideoSource.cpp:
+ (WebCore::MockRealtimeVideoSource::drawBoxes):
+ Switch to using auto/makeSimpleColor.
+
+ * platform/mock/ScrollbarThemeMock.cpp:
+ (WebCore::ScrollbarThemeMock::paintTrackBackground):
+ Switch to using makeSimpleColor.
+
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::calculateBorderStyleColor):
+ Update comment to use per-component values.
+
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::systemColor const):
+ Switch to using makeSimpleColor.
+
+ * rendering/RenderThemeAdwaita.cpp:
+ Switch to using auto/makeSimpleColor.
+
+ * rendering/RenderThemeIOS.h:
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::RenderThemeIOS::paintProgressBar):
+ Switch to using auto/makeSimpleColor.
+
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::systemColor const):
+ Switch to using auto/makeSimpleColor.
+
2020-07-07 Andres Gonzalez <[email protected]>
Web content process hangs in AccessibilityRenderObject::setSelectedVisiblePositionRange in some corner cases.
Modified: trunk/Source/WebCore/css/StyleColor.cpp (264049 => 264050)
--- trunk/Source/WebCore/css/StyleColor.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/css/StyleColor.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -41,7 +41,7 @@
{
if (const char* valueName = getValueName(keyword)) {
if (const NamedColor* namedColor = findColor(valueName, strlen(valueName)))
- return SimpleColor { namedColor->ARGBValue };
+ return makeSimpleColor(asSRGBA(Packed::ARGB { namedColor->ARGBValue }));
}
return RenderTheme::singleton().systemColor(keyword, options);
Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (264049 => 264050)
--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -414,21 +414,28 @@
switch (length) {
case 3:
// #abc converts to #aabbcc
- return SimpleColor { 0xFF000000
+ // FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
+ // the SRGBA<uint8_t> directly.
+ return makeSimpleColor(asSRGBA(Packed::ARGB {
+ 0xFF000000
| (value & 0xF00) << 12 | (value & 0xF00) << 8
| (value & 0xF0) << 8 | (value & 0xF0) << 4
- | (value & 0xF) << 4 | (value & 0xF) };
+ | (value & 0xF) << 4 | (value & 0xF) }));
case 4:
// #abcd converts to ddaabbcc since alpha bytes are the high bytes.
- return SimpleColor { (value & 0xF) << 28 | (value & 0xF) << 24
+ // FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
+ // the SRGBA<uint8_t> directly.
+ return makeSimpleColor(asSRGBA(Packed::ARGB {
+ (value & 0xF) << 28 | (value & 0xF) << 24
| (value & 0xF000) << 8 | (value & 0xF000) << 4
| (value & 0xF00) << 4 | (value & 0xF00)
- | (value & 0xF0) | (value & 0xF0) >> 4 };
+ | (value & 0xF0) | (value & 0xF0) >> 4 }));
case 6:
- return SimpleColor { 0xFF000000 | value };
+ // FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
+ // the SRGBA<uint8_t> directly.
+ return makeSimpleColor(asSRGBA(Packed::ARGB { 0xFF000000 | value }));
case 8:
- // We parsed the values into RGBA order, but we store them in ARGB order.
- return SimpleColor { value << 24 | value >> 8 };
+ return makeSimpleColor(asSRGBA(Packed::RGBA { value }));
}
return WTF::nullopt;
}
@@ -532,7 +539,7 @@
auto namedColor = findColor(buffer, length);
if (!namedColor)
return WTF::nullopt;
- return SimpleColor { namedColor->ARGBValue };
+ return makeSimpleColor(asSRGBA(Packed::ARGB { namedColor->ARGBValue }));
}
template<typename CharacterType> static Optional<SimpleColor> parseNamedColorInternal(const CharacterType* characters, unsigned length)
Modified: trunk/Source/WebCore/editing/CompositionHighlight.h (264049 => 264050)
--- trunk/Source/WebCore/editing/CompositionHighlight.h 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/editing/CompositionHighlight.h 2020-07-08 00:53:09 UTC (rev 264050)
@@ -40,9 +40,9 @@
}
#if PLATFORM(IOS_FAMILY)
- static constexpr SimpleColor defaultCompositionFillColor { 0x3CAFC0E3 };
+ static constexpr auto defaultCompositionFillColor = makeSimpleColor(175, 192, 227, 60);
#else
- static constexpr SimpleColor defaultCompositionFillColor { 0xFFE1DD55 };
+ static constexpr auto defaultCompositionFillColor = makeSimpleColor(225, 221, 85);
#endif
unsigned startOffset { 0 };
Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (264049 => 264050)
--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm 2020-07-08 00:53:09 UTC (rev 264050)
@@ -128,12 +128,12 @@
struct HistoricMemoryCategoryInfo {
HistoricMemoryCategoryInfo() { } // Needed for std::array.
- HistoricMemoryCategoryInfo(unsigned category, uint32_t argb, String name, bool subcategory = false)
+ HistoricMemoryCategoryInfo(unsigned category, SimpleColor color, String name, bool subcategory = false)
: name(WTFMove(name))
+ , color(cachedCGColor(color))
, isSubcategory(subcategory)
, type(category)
{
- color = cachedCGColor(SimpleColor { argb });
}
String name;
@@ -160,18 +160,18 @@
HistoricResourceUsageData::HistoricResourceUsageData()
{
// VM tag categories.
- categories[MemoryCategory::JSJIT] = HistoricMemoryCategoryInfo(MemoryCategory::JSJIT, 0xFFFF60FF, "JS JIT");
- categories[MemoryCategory::Gigacage] = HistoricMemoryCategoryInfo(MemoryCategory::Gigacage, 0xFF654FF0, "Gigacage");
- categories[MemoryCategory::Images] = HistoricMemoryCategoryInfo(MemoryCategory::Images, 0xFFFFFF00, "Images");
- categories[MemoryCategory::Layers] = HistoricMemoryCategoryInfo(MemoryCategory::Layers, 0xFF00FFFF, "Layers");
- categories[MemoryCategory::LibcMalloc] = HistoricMemoryCategoryInfo(MemoryCategory::LibcMalloc, 0xFF00FF00, "libc malloc");
- categories[MemoryCategory::bmalloc] = HistoricMemoryCategoryInfo(MemoryCategory::bmalloc, 0xFFFF6060, "bmalloc");
- categories[MemoryCategory::IsoHeap] = HistoricMemoryCategoryInfo(MemoryCategory::IsoHeap, 0xFF809F40, "IsoHeap");
- categories[MemoryCategory::Other] = HistoricMemoryCategoryInfo(MemoryCategory::Other, 0xFFC0FF00, "Other");
+ categories[MemoryCategory::JSJIT] = HistoricMemoryCategoryInfo(MemoryCategory::JSJIT, makeSimpleColor(255, 96, 255), "JS JIT");
+ categories[MemoryCategory::Gigacage] = HistoricMemoryCategoryInfo(MemoryCategory::Gigacage, makeSimpleColor(101, 79, 240), "Gigacage");
+ categories[MemoryCategory::Images] = HistoricMemoryCategoryInfo(MemoryCategory::Images, makeSimpleColor(255, 255, 0), "Images");
+ categories[MemoryCategory::Layers] = HistoricMemoryCategoryInfo(MemoryCategory::Layers, makeSimpleColor(0, 255, 255), "Layers");
+ categories[MemoryCategory::LibcMalloc] = HistoricMemoryCategoryInfo(MemoryCategory::LibcMalloc, makeSimpleColor(0, 255, 0), "libc malloc");
+ categories[MemoryCategory::bmalloc] = HistoricMemoryCategoryInfo(MemoryCategory::bmalloc, makeSimpleColor(255, 96, 96), "bmalloc");
+ categories[MemoryCategory::IsoHeap] = HistoricMemoryCategoryInfo(MemoryCategory::IsoHeap, makeSimpleColor(128, 159, 64), "IsoHeap");
+ categories[MemoryCategory::Other] = HistoricMemoryCategoryInfo(MemoryCategory::Other, makeSimpleColor(192, 255, 0), "Other");
// Sub categories (e.g breakdown of bmalloc tag.)
- categories[MemoryCategory::GCHeap] = HistoricMemoryCategoryInfo(MemoryCategory::GCHeap, 0xFFA0A0FF, "GC heap", true);
- categories[MemoryCategory::GCOwned] = HistoricMemoryCategoryInfo(MemoryCategory::GCOwned, 0xFFFFC060, "GC owned", true);
+ categories[MemoryCategory::GCHeap] = HistoricMemoryCategoryInfo(MemoryCategory::GCHeap, makeSimpleColor(160, 160, 255), "GC heap", true);
+ categories[MemoryCategory::GCOwned] = HistoricMemoryCategoryInfo(MemoryCategory::GCOwned, makeSimpleColor(255, 192, 96), "GC owned", true);
#ifndef NDEBUG
// Ensure this aligns with ResourceUsageData's category order.
Modified: trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp (264049 => 264050)
--- trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -89,7 +89,7 @@
{
GraphicsContextStateSaver stateSaver(context);
context.fillRect(clip, makeSimpleColor(0, 0, 0, 204));
- context.setFillColor(makeSimpleColor(230, 230, 230, 255));
+ context.setFillColor(makeSimpleColor(230, 230, 230));
FloatPoint position = { 10, 20 };
String string = "CPU: " + cpuUsageString(gData.cpu);
Modified: trunk/Source/WebCore/platform/adwaita/ScrollbarThemeAdwaita.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/adwaita/ScrollbarThemeAdwaita.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/adwaita/ScrollbarThemeAdwaita.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -43,13 +43,13 @@
static const unsigned minimumThumbSize = 40;
static const unsigned thumbSize = 6;
static const double scrollbarOpacity = 0.8;
-static const Color scrollbarBackgroundColor = makeSimpleColor(252, 252, 252);
-static const Color scrollbarBorderColor = makeSimpleColor(220, 223, 227);
-static const Color overlayThumbBorderColor = makeSimpleColor(255, 255, 255, 100);
-static const Color overlayThumbColor = makeSimpleColor(46, 52, 54, 100);
-static const Color thumbHoveredColor = makeSimpleColor(86, 91, 92);
-static const Color thumbPressedColor = makeSimpleColor(27, 106, 203);
-static const Color thumbColor = makeSimpleColor(126, 129, 130);
+static constexpr auto scrollbarBackgroundColor = makeSimpleColor(252, 252, 252);
+static constexpr auto scrollbarBorderColor = makeSimpleColor(220, 223, 227);
+static constexpr auto overlayThumbBorderColor = makeSimpleColor(255, 255, 255, 100);
+static constexpr auto overlayThumbColor = makeSimpleColor(46, 52, 54, 100);
+static constexpr auto thumbHoveredColor = makeSimpleColor(86, 91, 92);
+static constexpr auto thumbPressedColor = makeSimpleColor(27, 106, 203);
+static constexpr auto thumbColor = makeSimpleColor(126, 129, 130);
bool ScrollbarThemeAdwaita::usesOverlayScrollbars() const
{
Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/Color.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -36,8 +36,8 @@
namespace WebCore {
-static constexpr SimpleColor lightenedBlack { 0xFF545454 };
-static constexpr SimpleColor darkenedWhite { 0xFFABABAB };
+static constexpr auto lightenedBlack = makeSimpleColor(84, 84, 84);
+static constexpr auto darkenedWhite = makeSimpleColor(171, 171, 171);
Color::Color(const Color& other)
: m_colorData(other.m_colorData)
Modified: trunk/Source/WebCore/platform/graphics/Color.h (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/Color.h 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/Color.h 2020-07-08 00:53:09 UTC (rev 264050)
@@ -163,14 +163,14 @@
WEBCORE_EXPORT operator D2D1_VECTOR_4F() const;
#endif
- static constexpr SimpleColor black { 0xFF000000 };
- static constexpr SimpleColor white { 0xFFFFFFFF };
- static constexpr SimpleColor darkGray { 0xFF808080 };
- static constexpr SimpleColor gray { 0xFFA0A0A0 };
- static constexpr SimpleColor lightGray { 0xFFC0C0C0 };
- static constexpr SimpleColor transparent { 0x00000000 };
- static constexpr SimpleColor cyan { 0xFF00FFFF };
- static constexpr SimpleColor yellow { 0xFFFFFF00 };
+ static constexpr auto black = makeSimpleColor(0, 0, 0);
+ static constexpr auto white = makeSimpleColor(255, 255, 255);
+ static constexpr auto darkGray = makeSimpleColor(128, 128, 128);
+ static constexpr auto gray = makeSimpleColor(160, 160, 160);
+ static constexpr auto lightGray = makeSimpleColor(192, 192, 192);
+ static constexpr auto transparent = makeSimpleColor(0, 0, 0, 0);
+ static constexpr auto cyan = makeSimpleColor(0, 255, 255);
+ static constexpr auto yellow = makeSimpleColor(255, 255, 0);
bool isExtended() const { return !(m_colorData.simpleColorAndFlags & invalidSimpleColor); }
bool isSimple() const { return !isExtended(); }
@@ -301,12 +301,12 @@
inline const SimpleColor Color::asSimple() const
{
ASSERT(isSimple());
- return { static_cast<uint32_t>(m_colorData.simpleColorAndFlags >> 32) };
+ return makeSimpleColor(asSRGBA(Packed::RGBA { static_cast<uint32_t>(m_colorData.simpleColorAndFlags >> 32) }));
}
inline void Color::setSimpleColor(SimpleColor simpleColor)
{
- m_colorData.simpleColorAndFlags = static_cast<uint64_t>(simpleColor.value()) << 32;
+ m_colorData.simpleColorAndFlags = static_cast<uint64_t>(Packed::RGBA { simpleColor.asSRGBA<uint8_t>() }.value) << 32;
tagAsValid();
}
@@ -350,7 +350,7 @@
// FIXME: This should encode whether the color is semantic.
encoder << true;
- encoder << asSimple().value();
+ encoder << Packed::RGBA { asSimple().asSRGBA<uint8_t>() }.value;
}
template<class Decoder>
@@ -390,7 +390,7 @@
if (!decoder.decode(value))
return WTF::nullopt;
- return Color { SimpleColor { value } };
+ return Color { makeSimpleColor(asSRGBA(Packed::RGBA { value })) };
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ColorBlending.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/ColorBlending.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/ColorBlending.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -100,7 +100,7 @@
auto premultipliedFrom = premultipliedCeiling(from.toSRGBALossy<uint8_t>());
auto premultipliedTo = premultipliedCeiling(to.toSRGBALossy<uint8_t>());
- auto premultipliedBlended = convertToComponentBytes<SRGBA>(
+ auto premultipliedBlended = clampToComponentBytes<SRGBA>(
WebCore::blend(premultipliedFrom.red, premultipliedTo.red, progress),
WebCore::blend(premultipliedFrom.green, premultipliedTo.green, progress),
WebCore::blend(premultipliedFrom.blue, premultipliedTo.blue, progress),
Modified: trunk/Source/WebCore/platform/graphics/ColorTypes.h (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/ColorTypes.h 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/ColorTypes.h 2020-07-08 00:53:09 UTC (rev 264050)
@@ -240,16 +240,44 @@
// Packed Color Formats
+namespace Packed {
+
+struct RGBA {
+ constexpr explicit RGBA(uint32_t rgba)
+ : value { rgba }
+ {
+ }
+
+ constexpr explicit RGBA(SRGBA<uint8_t> color)
+ : value { static_cast<uint32_t>(color.red << 24 | color.green << 16 | color.blue << 8 | color.alpha) }
+ {
+ }
+
+ uint32_t value;
+};
+
struct ARGB {
+ constexpr explicit ARGB(uint32_t argb)
+ : value { argb }
+ {
+ }
+
+ constexpr explicit ARGB(SRGBA<uint8_t> color)
+ : value { static_cast<uint32_t>(color.alpha << 24 | color.red << 16 | color.green << 8 | color.blue) }
+ {
+ }
+
uint32_t value;
};
-constexpr ARGB asARGB(SRGBA<uint8_t> color)
+}
+
+constexpr SRGBA<uint8_t> asSRGBA(Packed::RGBA color)
{
- return { static_cast<unsigned>(color.alpha << 24 | color.red << 16 | color.green << 8 | color.blue) };
+ return { static_cast<uint8_t>(color.value >> 24), static_cast<uint8_t>(color.value >> 16), static_cast<uint8_t>(color.value >> 8), static_cast<uint8_t>(color.value) };
}
-constexpr SRGBA<uint8_t> asSRGBA(ARGB color)
+constexpr SRGBA<uint8_t> asSRGBA(Packed::ARGB color)
{
return { static_cast<uint8_t>(color.value >> 16), static_cast<uint8_t>(color.value >> 8), static_cast<uint8_t>(color.value), static_cast<uint8_t>(color.value >> 24) };
}
Modified: trunk/Source/WebCore/platform/graphics/ColorUtilities.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/ColorUtilities.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/ColorUtilities.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -79,7 +79,7 @@
return { 0, 0, 0, 0 };
if (a == 255)
return color;
- return convertToComponentBytes<SRGBA>(fastDivideBy255(r * a), fastDivideBy255(g * a), fastDivideBy255(b * a), a);
+ return clampToComponentBytes<SRGBA>(fastDivideBy255(r * a), fastDivideBy255(g * a), fastDivideBy255(b * a), a);
}
SRGBA<uint8_t> premultipliedCeiling(SRGBA<uint8_t> color)
@@ -89,7 +89,7 @@
return { 0, 0, 0, 0 };
if (a == 255)
return color;
- return convertToComponentBytes<SRGBA>(fastDivideBy255(r * a + 254), fastDivideBy255(g * a + 254), fastDivideBy255(b * a + 254), a);
+ return clampToComponentBytes<SRGBA>(fastDivideBy255(r * a + 254), fastDivideBy255(g * a + 254), fastDivideBy255(b * a + 254), a);
}
static inline uint16_t unpremultipliedComponentByte(uint8_t c, uint8_t a)
@@ -102,7 +102,7 @@
auto [r, g, b, a] = color;
if (!a || a == 255)
return color;
- return convertToComponentBytes<SRGBA>(unpremultipliedComponentByte(r, a), unpremultipliedComponentByte(g, a), unpremultipliedComponentByte(b, a), a);
+ return clampToComponentBytes<SRGBA>(unpremultipliedComponentByte(r, a), unpremultipliedComponentByte(g, a), unpremultipliedComponentByte(b, a), a);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ColorUtilities.h (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/ColorUtilities.h 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/ColorUtilities.h 2020-07-08 00:53:09 UTC (rev 264050)
@@ -54,6 +54,16 @@
return std::clamp(std::lround(f * 255.0f), 0l, 255l);
}
+constexpr uint8_t clampToComponentByte(int c)
+{
+ return static_cast<uint8_t>(std::clamp(c, 0, 0xFF));
+}
+
+constexpr uint8_t clampToComponentFloat(float f)
+{
+ return std::clamp(f, 0.0f, 1.0f);
+}
+
constexpr float convertToComponentFloat(uint8_t byte)
{
return byte / 255.0f;
@@ -65,11 +75,6 @@
return { convertToComponentByte(components[0]), convertToComponentByte(components[1]), convertToComponentByte(components[2]), convertToComponentByte(components[3]) };
}
-template<template<typename> typename ColorType> constexpr ColorType<uint8_t> convertToComponentBytes(int r, int g, int b, int a)
-{
- return { static_cast<uint8_t>(std::clamp(r, 0, 0xFF)), static_cast<uint8_t>(std::clamp(g, 0, 0xFF)), static_cast<uint8_t>(std::clamp(b, 0, 0xFF)), static_cast<uint8_t>(std::clamp(a, 0, 0xFF)) };
-}
-
template<template<typename> typename ColorType> constexpr ColorType<float> convertToComponentFloats(const ColorType<uint8_t>& color)
{
auto components = asColorComponents(color);
@@ -76,11 +81,16 @@
return { convertToComponentFloat(components[0]), convertToComponentFloat(components[1]), convertToComponentFloat(components[2]), convertToComponentFloat(components[3]) };
}
-template<template<typename> typename ColorType> constexpr ColorType<float> convertToComponentFloats(float r, float g, float b, float a)
+template<template<typename> typename ColorType> constexpr ColorType<uint8_t> clampToComponentBytes(int r, int g, int b, int a)
{
- return { std::clamp(r, 0.0f, 1.0f), std::clamp(g, 0.0f, 1.0f), std::clamp(b, 0.0f, 1.0f), std::clamp(a, 0.0f, 1.0f) };
+ return { clampToComponentByte(r), clampToComponentByte(g), clampToComponentByte(b), clampToComponentByte(a) };
}
+template<template<typename> typename ColorType> constexpr ColorType<float> clampToComponentFloats(float r, float g, float b, float a)
+{
+ return { clampToComponentFloat(r), clampToComponentFloat(g), clampToComponentFloat(b), clampToComponentFloat(a) };
+}
+
constexpr uint16_t fastMultiplyBy255(uint16_t value)
{
return (value << 8) - value;
Modified: trunk/Source/WebCore/platform/graphics/ImageBackingStore.h (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/ImageBackingStore.h 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/ImageBackingStore.h 2020-07-08 00:53:09 UTC (rev 264050)
@@ -152,7 +152,7 @@
if (!a)
return;
- auto pixel = asSRGBA(ARGB { *dest });
+ auto pixel = asSRGBA(Packed::ARGB { *dest });
if (a >= 255 || !pixel.alpha) {
setPixel(dest, r, g, b, a);
@@ -174,7 +174,7 @@
if (!m_premultiplyAlpha)
result = unpremultiplied(result);
- *dest = asARGB(result).value;
+ *dest = Packed::ARGB { result }.value;
}
static bool isOverSize(const IntSize& size)
@@ -231,7 +231,7 @@
if (m_premultiplyAlpha && a < 255)
result = premultipliedFlooring(result);
- return asARGB(result).value;
+ return Packed::ARGB { result }.value;
}
RefPtr<SharedBuffer::DataSegment> m_pixels;
Modified: trunk/Source/WebCore/platform/graphics/SimpleColor.h (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/SimpleColor.h 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/SimpleColor.h 2020-07-08 00:53:09 UTC (rev 264050)
@@ -32,38 +32,33 @@
namespace WebCore {
-// Color value with 8-bit components for red, green, blue, and alpha.
-// For historical reasons, stored as a 32-bit integer, with alpha in the high bits: ARGB.
class SimpleColor {
public:
- constexpr SimpleColor(uint32_t value = 0) : m_value { value } { }
- constexpr SimpleColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : m_value { static_cast<unsigned>(a << 24 | r << 16 | g << 8 | b) } { }
+ constexpr SimpleColor() : m_value { } { }
+ constexpr SimpleColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : m_value { r, g, b, a } { }
- constexpr uint32_t valueAsARGB() const { return m_value; }
- constexpr uint32_t value() const { return m_value; }
+ constexpr uint8_t alphaComponent() const { return m_value.alpha; }
+ constexpr float alphaComponentAsFloat() const { return convertToComponentFloat(m_value.alpha); }
- constexpr uint8_t alphaComponent() const { return m_value >> 24; }
- constexpr float alphaComponentAsFloat() const { return convertToComponentFloat(alphaComponent()); }
+ constexpr bool isOpaque() const { return m_value.alpha == 0xFF; }
+ constexpr bool isVisible() const { return m_value.alpha; }
- constexpr bool isOpaque() const { return alphaComponent() == 0xFF; }
- constexpr bool isVisible() const { return alphaComponent(); }
-
constexpr SimpleColor colorWithAlpha(uint8_t alpha) const
{
- return { (m_value & 0x00FFFFFF) | alpha << 24 };
+ return { m_value.red, m_value.green, m_value.blue, alpha };
}
constexpr SimpleColor invertedColorWithAlpha(uint8_t alpha) const
{
- return { static_cast<uint8_t>(0xFF - redComponent()), static_cast<uint8_t>(0xFF - greenComponent()), static_cast<uint8_t>(0xFF - blueComponent()), alpha };
+ return { static_cast<uint8_t>(0xFF - m_value.red), static_cast<uint8_t>(0xFF - m_value.green), static_cast<uint8_t>(0xFF - m_value.blue), alpha };
}
template<typename T> constexpr SRGBA<T> asSRGBA() const
{
if constexpr (std::is_same_v<T, float>)
- return { convertToComponentFloat(redComponent()), convertToComponentFloat(greenComponent()), convertToComponentFloat(blueComponent()), convertToComponentFloat(alphaComponent()) };
+ return convertToComponentFloats(m_value);
else if constexpr (std::is_same_v<T, uint8_t>)
- return { redComponent(), greenComponent(), blueComponent(), alphaComponent() };
+ return m_value;
}
template<std::size_t N>
@@ -71,21 +66,17 @@
{
static_assert(N < 4);
if constexpr (!N)
- return redComponent();
+ return m_value.red;
else if constexpr (N == 1)
- return greenComponent();
+ return m_value.green;
else if constexpr (N == 2)
- return blueComponent();
+ return m_value.blue;
else if constexpr (N == 3)
- return alphaComponent();
+ return m_value.alpha;
}
private:
- constexpr uint8_t redComponent() const { return m_value >> 16; }
- constexpr uint8_t greenComponent() const { return m_value >> 8; }
- constexpr uint8_t blueComponent() const { return m_value; }
-
- uint32_t m_value { 0 };
+ SRGBA<uint8_t> m_value { 0, 0, 0, 0 };
};
bool operator==(SimpleColor, SimpleColor);
@@ -98,7 +89,7 @@
inline bool operator==(SimpleColor a, SimpleColor b)
{
- return a.value() == b.value();
+ return a.asSRGBA<uint8_t>() == b.asSRGBA<uint8_t>();
}
inline bool operator!=(SimpleColor a, SimpleColor b)
@@ -106,24 +97,24 @@
return !(a == b);
}
-constexpr SimpleColor makeSimpleColor(int r, int g, int b)
+constexpr SimpleColor makeSimpleColor(const SRGBA<uint8_t>& sRGBA)
{
- return { static_cast<uint8_t>(std::clamp(r, 0, 0xFF)), static_cast<uint8_t>(std::clamp(g, 0, 0xFF)), static_cast<uint8_t>(std::clamp(b, 0, 0xFF)), 0xFF };
+ return { sRGBA.red, sRGBA.green, sRGBA.blue, sRGBA.alpha };
}
-constexpr SimpleColor makeSimpleColor(int r, int g, int b, int a)
+inline SimpleColor makeSimpleColor(const SRGBA<float>& sRGBA)
{
- return { static_cast<uint8_t>(std::clamp(r, 0, 0xFF)), static_cast<uint8_t>(std::clamp(g, 0, 0xFF)), static_cast<uint8_t>(std::clamp(b, 0, 0xFF)), static_cast<uint8_t>(std::clamp(a, 0, 0xFF)) };
+ return makeSimpleColor(convertToComponentBytes(sRGBA));
}
-constexpr SimpleColor makeSimpleColor(const SRGBA<uint8_t>& sRGBA)
+constexpr SimpleColor makeSimpleColor(int r, int g, int b)
{
- return { sRGBA.red, sRGBA.green, sRGBA.blue, sRGBA.alpha };
+ return makeSimpleColor(clampToComponentBytes<SRGBA>(r, g, b, 0xFF));
}
-inline SimpleColor makeSimpleColor(const SRGBA<float>& sRGBA)
+constexpr SimpleColor makeSimpleColor(int r, int g, int b, int a)
{
- return makeSimpleColor(convertToComponentBytes(sRGBA));
+ return makeSimpleColor(clampToComponentBytes<SRGBA>(r, g, b, a));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -84,9 +84,9 @@
const float verticalMargin = 2.5;
const float horizontalMargin = 5;
const unsigned fontSize = 22;
- constexpr auto backgroundColor = makeSimpleColor(128, 64, 255, 255);
- constexpr auto acceleratedContextLabelColor = makeSimpleColor(255, 0, 0, 255);
- constexpr auto unacceleratedContextLabelColor = makeSimpleColor(255, 255, 255, 255);
+ constexpr auto backgroundColor = makeSimpleColor(128, 64, 255);
+ constexpr auto acceleratedContextLabelColor = makeSimpleColor(255, 0, 0);
+ constexpr auto unacceleratedContextLabelColor = makeSimpleColor(255, 255, 255);
constexpr auto linearGlyphMaskOutlineColor = makeSimpleColor(0, 0, 0, 192);
constexpr auto displayListBorderColor = makeSimpleColor(0, 0, 0, 166);
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -80,9 +80,9 @@
unsigned* row = reinterpret_cast_ptr<unsigned*>(dataSrc + stride * y);
for (int x = 0; x < m_logicalSize.width(); x++) {
unsigned* pixel = row + x;
- auto pixelComponents = unpremultiplied(asSRGBA(ARGB { *pixel }));
+ auto pixelComponents = unpremultiplied(asSRGBA(Packed::ARGB { *pixel }));
pixelComponents = { lookUpTable[pixelComponents.red], lookUpTable[pixelComponents.green], lookUpTable[pixelComponents.blue], pixelComponents.alpha };
- *pixel = asARGB(premultipliedCeiling(pixelComponents)).value;
+ *pixel = Packed::ARGB { premultipliedCeiling(pixelComponents) }.value;
}
}
cairo_surface_mark_dirty_rectangle(m_surface.get(), 0, 0, m_logicalSize.width(), m_logicalSize.height());
Modified: trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -54,7 +54,7 @@
return Color();
unsigned* pixel = reinterpret_cast_ptr<unsigned*>(cairo_image_surface_get_data(image.get()));
- return makeSimpleColor(unpremultiplied(asSRGBA(ARGB { *pixel })));
+ return makeSimpleColor(unpremultiplied(asSRGBA(Packed::ARGB { *pixel })));
}
void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& imageSize, const ImagePaintingOptions& options)
Modified: trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -129,16 +129,16 @@
CGColorRef cachedCGColor(const Color& color)
{
if (color.isSimple()) {
- switch (color.asSimple().value()) {
- case Color::transparent.value(): {
+ switch (Packed::RGBA { color.asSimple().asSRGBA<uint8_t>() }.value) {
+ case Packed::RGBA { Color::transparent.asSRGBA<uint8_t>() }.value: {
static CGColorRef transparentCGColor = leakCGColor(color);
return transparentCGColor;
}
- case Color::black.value(): {
+ case Packed::RGBA { Color::black.asSRGBA<uint8_t>() }.value: {
static CGColorRef blackCGColor = leakCGColor(color);
return blackCGColor;
}
- case Color::white.value(): {
+ case Packed::RGBA { Color::white.asSRGBA<uint8_t>() }.value: {
static CGColorRef whiteCGColor = leakCGColor(color);
return whiteCGColor;
}
@@ -145,8 +145,6 @@
}
}
- ASSERT(color.isExtended() || color.asSimple().value());
-
static NeverDestroyed<TinyLRUCache<Color, RetainPtr<CGColorRef>, 32>> cache;
return cache.get().get(color).get();
}
Modified: trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm 2020-07-08 00:53:09 UTC (rev 264050)
@@ -49,7 +49,7 @@
Color oldAquaFocusRingColor()
{
- return SimpleColor { 0xFF7DADD9 };
+ return makeSimpleColor(125, 173, 217);
}
void setUsesTestModeFocusRingColor(bool newValue)
@@ -123,16 +123,16 @@
NSColor *nsColor(const Color& color)
{
if (color.isSimple()) {
- switch (color.asSimple().value()) {
- case Color::transparent.value(): {
+ switch (Packed::RGBA { color.asSimple().asSRGBA<uint8_t>() }.value) {
+ case Packed::RGBA { Color::transparent.asSRGBA<uint8_t>() }.value: {
static NSColor *clearColor = [[NSColor colorWithSRGBRed:0 green:0 blue:0 alpha:0] retain];
return clearColor;
}
- case Color::black.value(): {
+ case Packed::RGBA { Color::black.asSRGBA<uint8_t>() }.value: {
static NSColor *blackColor = [[NSColor colorWithSRGBRed:0 green:0 blue:0 alpha:1] retain];
return blackColor;
}
- case Color::white.value(): {
+ case Packed::RGBA { Color::white.asSRGBA<uint8_t>() }.value: {
static NSColor *whiteColor = [[NSColor colorWithSRGBRed:1 green:1 blue:1 alpha:1] retain];
return whiteColor;
}
Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -198,12 +198,11 @@
CGContextRef context = platformContext();
CGContextSaveGState(context);
- static constexpr SimpleColor spellingPatternColor { makeSimpleColor(255, 0, 0) };
- static constexpr SimpleColor grammarPatternColor { makeSimpleColor(0, 128, 0) };
+ static constexpr auto spellingPatternColor = makeSimpleColor(255, 0, 0);
+ static constexpr auto grammarPatternColor = makeSimpleColor(0, 128, 0);
- const SimpleColor& patternColor = style.mode == DocumentMarkerLineStyle::Mode::Grammar ? grammarPatternColor : spellingPatternColor;
- auto patternColorComponents = patternColor.asSRGBA<uint8_t>();
- CGContextSetRGBStrokeColor(context, patternColorComponents.red, patternColorComponents.green, patternColorComponents.blue, patternColorComponents.alpha);
+ auto [r, g, b, a] = style.mode == DocumentMarkerLineStyle::Mode::Grammar ? grammarPatternColor : spellingPatternColor;
+ CGContextSetRGBStrokeColor(context, r, g, b, a);
CGAffineTransform userToBase = getUserToBaseCTM(context);
CGPoint phase = CGPointApplyAffineTransform(point, userToBase);
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -86,8 +86,8 @@
MockMediaDevice { "SCREEN-1"_s, "Mock screen device 1"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, Color::lightGray, { 3840, 2160 } } },
MockMediaDevice { "SCREEN-2"_s, "Mock screen device 2"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, Color::yellow, { 1920, 1080 } } },
- MockMediaDevice { "WINDOW-2"_s, "Mock window 1"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, SimpleColor { 0xfff1b5 }, { 640, 480 } } },
- MockMediaDevice { "WINDOW-2"_s, "Mock window 2"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, SimpleColor { 0xffd0b5 }, { 1280, 600 } } },
+ MockMediaDevice { "WINDOW-2"_s, "Mock window 1"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, makeSimpleColor(255, 241, 181), { 640, 480 } } },
+ MockMediaDevice { "WINDOW-2"_s, "Mock window 2"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, makeSimpleColor(255, 208, 181), { 1280, 600 } } },
};
}
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -265,10 +265,10 @@
void MockRealtimeVideoSource::drawBoxes(GraphicsContext& context)
{
- constexpr SimpleColor magenta { 0xffff00ff };
- constexpr SimpleColor blue { 0xff0000ff };
- constexpr SimpleColor red { 0xffff0000 };
- constexpr SimpleColor darkGreen { 0xff008000 };
+ static constexpr auto magenta = makeSimpleColor(255, 0, 255);
+ static constexpr auto blue = makeSimpleColor(0, 0, 255);
+ static constexpr auto red = makeSimpleColor(255, 0, 0);
+ static constexpr auto darkGreen = makeSimpleColor(0, 128, 0);
IntSize size = captureSize();
float boxSize = size.width() * .035;
Modified: trunk/Source/WebCore/platform/mock/ScrollbarThemeMock.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/mock/ScrollbarThemeMock.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/mock/ScrollbarThemeMock.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -46,7 +46,7 @@
void ScrollbarThemeMock::paintTrackBackground(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& trackRect)
{
- context.fillRect(trackRect, scrollbar.enabled() ? Color::lightGray : SimpleColor { 0xFFE0E0E0 });
+ context.fillRect(trackRect, scrollbar.enabled() ? Color::lightGray : makeSimpleColor(224, 224, 224));
}
void ScrollbarThemeMock::paintThumb(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& thumbRect)
Modified: trunk/Source/WebCore/platform/win/DragImageWin.cpp (264049 => 264050)
--- trunk/Source/WebCore/platform/win/DragImageWin.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/platform/win/DragImageWin.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -195,7 +195,7 @@
context.fillRoundedRect(FloatRoundedRect(rect, radii, radii, radii, radii), backgroundColor);
// Draw the text
- constexpr auto topColor = makeSimpleColor(0, 0, 0, 255); // original alpha = 0.75
+ constexpr auto topColor = makeSimpleColor(0, 0, 0); // original alpha = 0.75
constexpr auto bottomColor = makeSimpleColor(255, 255, 255, 127); // original alpha = 0.5
if (drawURLString) {
if (clipURLString)
Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp (264049 => 264050)
--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -76,7 +76,7 @@
constexpr auto replacementTextRoundedRectPressedColor = makeSimpleColor(105, 105, 105, 242);
constexpr auto replacementTextRoundedRectColor = makeSimpleColor(125, 125, 125, 242);
-constexpr auto replacementTextColor = makeSimpleColor(240, 240, 240, 255);
+constexpr auto replacementTextColor = makeSimpleColor(240, 240, 240);
constexpr auto unavailablePluginBorderColor = makeSimpleColor(255, 255, 255, 216);
RenderEmbeddedObject::RenderEmbeddedObject(HTMLFrameOwnerElement& element, RenderStyle&& style)
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (264049 => 264050)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -1805,8 +1805,8 @@
ASSERT(style == BorderStyle::Inset || style == BorderStyle::Outset);
// This values were derived empirically.
- constexpr float baseDarkColorLuminance { 0.014443844f }; // Luminance of SimpleColor { 0xFF202020 }
- constexpr float baseLightColorLuminance { 0.83077f }; // Luminance of SimpleColor { 0xFFEBEBEB }
+ constexpr float baseDarkColorLuminance { 0.014443844f }; // Luminance of SRGBA<uint8_t> { 32, 32, 32 }
+ constexpr float baseLightColorLuminance { 0.83077f }; // Luminance of SRGBA<uint8_t> { 235, 235, 235 }
enum Operation { Darken, Lighten };
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (264049 => 264050)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -1334,30 +1334,30 @@
{
switch (cssValueId) {
case CSSValueWebkitLink:
- return options.contains(StyleColor::Options::ForVisitedLink) ? SimpleColor { 0xFF551A8B } : SimpleColor { 0xFF0000EE };
+ return options.contains(StyleColor::Options::ForVisitedLink) ? makeSimpleColor(85, 26, 139) : makeSimpleColor(0, 0, 238);
case CSSValueWebkitActivelink:
case CSSValueActivetext:
- return SimpleColor { 0xFFFF0000 };
+ return makeSimpleColor(255, 0, 0);
case CSSValueLinktext:
- return SimpleColor { 0xFF0000EE };
+ return makeSimpleColor(0, 0, 238);
case CSSValueVisitedtext:
- return SimpleColor { 0xFF551A8B };
+ return makeSimpleColor(85, 26, 139);
case CSSValueActiveborder:
return Color::white;
case CSSValueActivebuttontext:
return Color::black;
case CSSValueActivecaption:
- return SimpleColor { 0xFFCCCCCC };
+ return makeSimpleColor(204, 204, 204);
case CSSValueAppworkspace:
return Color::white;
case CSSValueBackground:
- return SimpleColor { 0xFF6363CE };
+ return makeSimpleColor(99, 99, 206);
case CSSValueButtonface:
return Color::lightGray;
case CSSValueButtonhighlight:
- return SimpleColor { 0xFFDDDDDD };
+ return makeSimpleColor(221, 221, 221);
case CSSValueButtonshadow:
- return SimpleColor { 0xFF888888 };
+ return makeSimpleColor(136, 136, 136);
case CSSValueButtontext:
return Color::black;
case CSSValueCaptiontext:
@@ -1371,9 +1371,9 @@
case CSSValueFieldtext:
return Color::black;
case CSSValueGraytext:
- return SimpleColor { 0xFF808080 };
+ return makeSimpleColor(128, 128, 128);
case CSSValueHighlight:
- return SimpleColor { 0xFFB5D5FF };
+ return makeSimpleColor(181, 213, 255);
case CSSValueHighlighttext:
return Color::black;
case CSSValueInactiveborder:
@@ -1381,9 +1381,9 @@
case CSSValueInactivecaption:
return Color::white;
case CSSValueInactivecaptiontext:
- return SimpleColor { 0xFF7F7F7F };
+ return makeSimpleColor(127, 127, 127);
case CSSValueInfobackground:
- return SimpleColor { 0xFFFBFCC5 };
+ return makeSimpleColor(251, 252, 197);
case CSSValueInfotext:
return Color::black;
case CSSValueMenu:
@@ -1395,19 +1395,19 @@
case CSSValueText:
return Color::black;
case CSSValueThreeddarkshadow:
- return SimpleColor { 0xFF666666 };
+ return makeSimpleColor(102, 102, 102);
case CSSValueThreedface:
return Color::lightGray;
case CSSValueThreedhighlight:
- return SimpleColor { 0xFFDDDDDD };
+ return makeSimpleColor(221, 221, 221);
case CSSValueThreedlightshadow:
return Color::lightGray;
case CSSValueThreedshadow:
- return SimpleColor { 0xFF888888 };
+ return makeSimpleColor(136, 136, 136);
case CSSValueWindow:
return Color::white;
case CSSValueWindowframe:
- return SimpleColor { 0xFFCCCCCC };
+ return makeSimpleColor(204, 204, 204);
case CSSValueWindowtext:
return Color::black;
default:
Modified: trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp (264049 => 264050)
--- trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -45,10 +45,10 @@
namespace WebCore {
static const int textFieldBorderSize = 1;
-static const Color textFieldBorderColor = makeSimpleColor(205, 199, 194);
-static const Color textFieldBorderDisabledColor = makeSimpleColor(213, 208, 204);
-static const Color textFieldBackgroundColor = makeSimpleColor(255, 255, 255);
-static const Color textFieldBackgroundDisabledColor = makeSimpleColor(252, 252, 252);
+static constexpr auto textFieldBorderColor = makeSimpleColor(205, 199, 194);
+static constexpr auto textFieldBorderDisabledColor = makeSimpleColor(213, 208, 204);
+static constexpr auto textFieldBackgroundColor = makeSimpleColor(255, 255, 255);
+static constexpr auto textFieldBackgroundDisabledColor = makeSimpleColor(252, 252, 252);
static const unsigned menuListButtonArrowSize = 16;
static const int menuListButtonFocusOffset = -3;
static const unsigned menuListButtonPadding = 5;
@@ -57,23 +57,23 @@
static const unsigned progressAnimationFrameCount = 75;
static const Seconds progressAnimationFrameRate = 33_ms; // 30fps.
static const unsigned progressBarSize = 6;
-static const Color progressBarBorderColor = makeSimpleColor(205, 199, 194);
-static const Color progressBarBackgroundColor = makeSimpleColor(225, 222, 219);
+static constexpr auto progressBarBorderColor = makeSimpleColor(205, 199, 194);
+static constexpr auto progressBarBackgroundColor = makeSimpleColor(225, 222, 219);
static const unsigned sliderTrackSize = 6;
static const int sliderTrackBorderSize = 1;
-static const Color sliderTrackBorderColor = makeSimpleColor(205, 199, 194);
-static const Color sliderTrackBackgroundColor = makeSimpleColor(225, 222, 219);
+static constexpr auto sliderTrackBorderColor = makeSimpleColor(205, 199, 194);
+static constexpr auto sliderTrackBackgroundColor = makeSimpleColor(225, 222, 219);
static const int sliderTrackFocusOffset = 2;
static const int sliderThumbSize = 20;
static const int sliderThumbBorderSize = 1;
-static const Color sliderThumbBorderColor = makeSimpleColor(205, 199, 194);
-static const Color sliderThumbBackgroundColor = makeSimpleColor(244, 242, 241);
-static const Color sliderThumbBackgroundHoveredColor = makeSimpleColor(248, 248, 247);
-static const Color sliderThumbBackgroundDisabledColor = makeSimpleColor(244, 242, 241);
+static constexpr auto sliderThumbBorderColor = makeSimpleColor(205, 199, 194);
+static constexpr auto sliderThumbBackgroundColor = makeSimpleColor(244, 242, 241);
+static constexpr auto sliderThumbBackgroundHoveredColor = makeSimpleColor(248, 248, 247);
+static constexpr auto sliderThumbBackgroundDisabledColor = makeSimpleColor(244, 242, 241);
#if ENABLE(VIDEO)
-static const Color mediaSliderTrackBackgroundcolor = makeSimpleColor(77, 77, 77);
-static const Color mediaSliderTrackBufferedColor = makeSimpleColor(173, 173, 173);
-static const Color mediaSliderTrackActiveColor = makeSimpleColor(252, 252, 252);
+static constexpr auto mediaSliderTrackBackgroundcolor = makeSimpleColor(77, 77, 77);
+static constexpr auto mediaSliderTrackBufferedColor = makeSimpleColor(173, 173, 173);
+static constexpr auto mediaSliderTrackActiveColor = makeSimpleColor(252, 252, 252);
#endif
#if !PLATFORM(GTK)
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (264049 => 264050)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.h 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h 2020-07-08 00:53:09 UTC (rev 264050)
@@ -121,7 +121,7 @@
#endif
#if ENABLE(TOUCH_EVENTS)
- Color platformTapHighlightColor() const override { return SimpleColor { 0x4D1A1A1A }; }
+ Color platformTapHighlightColor() const override { return makeSimpleColor(26, 26, 26, 0x4D); }
#endif
bool shouldHaveSpinButton(const HTMLInputElement&) const override;
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (264049 => 264050)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-07-08 00:53:09 UTC (rev 264050)
@@ -917,10 +917,10 @@
const float verticalRenderingPosition = rect.y() + verticalOffset;
auto strokeGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) });
- strokeGradient->addColorStop(0.0, makeSimpleColor(0x8d, 0x8d, 0x8d));
- strokeGradient->addColorStop(0.45, makeSimpleColor(0xee, 0xee, 0xee));
- strokeGradient->addColorStop(0.55, makeSimpleColor(0xee, 0xee, 0xee));
- strokeGradient->addColorStop(1.0, makeSimpleColor(0x8d, 0x8d, 0x8d));
+ strokeGradient->addColorStop(0.0, makeSimpleColor(141, 141, 141));
+ strokeGradient->addColorStop(0.45, makeSimpleColor(238, 238, 238));
+ strokeGradient->addColorStop(0.55, makeSimpleColor(238, 238, 238));
+ strokeGradient->addColorStop(1.0, makeSimpleColor(141, 141, 141));
context.setStrokeGradient(WTFMove(strokeGradient));
context.setFillColor(Color::black);
@@ -1383,10 +1383,10 @@
const CGSize attachmentSize = { 160, 119 };
const CGFloat attachmentBorderRadius = 16;
-constexpr SimpleColor attachmentBorderColor = makeSimpleColor(204, 204, 204);
+constexpr auto attachmentBorderColor = makeSimpleColor(204, 204, 204);
static CGFloat attachmentBorderThickness = 1;
-constexpr SimpleColor attachmentProgressColor = makeSimpleColor(222, 222, 222);
+constexpr auto attachmentProgressColor = makeSimpleColor(222, 222, 222);
const CGFloat attachmentProgressBorderThickness = 3;
const CGFloat attachmentProgressSize = 36;
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (264049 => 264050)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2020-07-08 00:53:09 UTC (rev 264050)
@@ -737,11 +737,11 @@
case CSSValueThreedface:
// We selected this value instead of [NSColor controlColor] to avoid website incompatibilities.
// We may want to consider changing to [NSColor controlColor] some day.
- return SimpleColor { 0xFFC0C0C0 };
+ return makeSimpleColor(192, 192, 192);
case CSSValueInfobackground:
// No corresponding NSColor for this so we use a hard coded value.
- return SimpleColor { 0xFFFBFCC5 };
+ return makeSimpleColor(251, 252, 197);
case CSSValueMenu:
return menuBackgroundColor();
@@ -750,30 +750,30 @@
case CSSValueActiveborder:
// Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting.
if (localAppearance.usingDarkAppearance())
- return { SimpleColor { 0xFF1AA9FF }, Color::Semantic };
- return { SimpleColor { 0xFF0067F4 }, Color::Semantic };
+ return { makeSimpleColor(26, 169, 255), Color::Semantic };
+ return { makeSimpleColor(0, 103, 244), Color::Semantic };
case CSSValueAppleSystemControlAccent:
// Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting.
// Same color in light and dark appearances.
- return { SimpleColor { 0xFF007AFF }, Color::Semantic };
+ return { makeSimpleColor(0, 122, 255), Color::Semantic };
case CSSValueAppleSystemSelectedContentBackground:
// Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting.
if (localAppearance.usingDarkAppearance())
- return { SimpleColor { 0xFF0058D0 }, Color::Semantic };
- return { SimpleColor { 0xFF0063E1 }, Color::Semantic };
+ return { makeSimpleColor(0, 88, 208), Color::Semantic };
+ return { makeSimpleColor(0, 99, 225), Color::Semantic };
case CSSValueHighlight:
case CSSValueAppleSystemSelectedTextBackground:
// Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting.
if (localAppearance.usingDarkAppearance())
- return { SimpleColor { 0xCC3F638B }, Color::Semantic };
- return { SimpleColor { 0x9980BCFE }, Color::Semantic };
+ return { makeSimpleColor(63, 99, 139, 204), Color::Semantic };
+ return { makeSimpleColor(128, 188, 254, 153), Color::Semantic };
#if !HAVE(OS_DARK_MODE_SUPPORT)
case CSSValueAppleSystemContainerBorder:
- return SimpleColor { 0xFFC5C5C5 };
+ return makeSimpleColor(197, 197, 197);
#endif
case CSSValueAppleSystemEvenAlternatingContentBackground: {
@@ -2413,8 +2413,8 @@
const CGFloat attachmentIconBackgroundRadius = 3;
const CGFloat attachmentIconToTitleMargin = 2;
-constexpr SimpleColor attachmentIconBackgroundColor = makeSimpleColor(0, 0, 0, 30);
-constexpr SimpleColor attachmentIconBorderColor = makeSimpleColor(255, 255, 255, 125);
+constexpr auto attachmentIconBackgroundColor = makeSimpleColor(0, 0, 0, 30);
+constexpr auto attachmentIconBorderColor = makeSimpleColor(255, 255, 255, 125);
const CGFloat attachmentTitleFontSize = 12;
const CGFloat attachmentTitleBackgroundRadius = 3;
@@ -2422,23 +2422,23 @@
const CGFloat attachmentTitleMaximumWidth = 100 - (attachmentTitleBackgroundPadding * 2);
const CFIndex attachmentTitleMaximumLineCount = 2;
-constexpr SimpleColor attachmentTitleInactiveBackgroundColor = makeSimpleColor(204, 204, 204, 255);
-constexpr SimpleColor attachmentTitleInactiveTextColor = makeSimpleColor(100, 100, 100, 255);
+constexpr auto attachmentTitleInactiveBackgroundColor = makeSimpleColor(204, 204, 204);
+constexpr auto attachmentTitleInactiveTextColor = makeSimpleColor(100, 100, 100);
const CGFloat attachmentSubtitleFontSize = 10;
const int attachmentSubtitleWidthIncrement = 10;
-constexpr SimpleColor attachmentSubtitleTextColor = makeSimpleColor(82, 145, 214, 255);
+constexpr auto attachmentSubtitleTextColor = makeSimpleColor(82, 145, 214);
const CGFloat attachmentProgressBarWidth = 30;
const CGFloat attachmentProgressBarHeight = 5;
const CGFloat attachmentProgressBarOffset = -9;
const CGFloat attachmentProgressBarBorderWidth = 1;
-constexpr SimpleColor attachmentProgressBarBackgroundColor = makeSimpleColor(0, 0, 0, 89);
-constexpr SimpleColor attachmentProgressBarFillColor = Color::white;
-constexpr SimpleColor attachmentProgressBarBorderColor = makeSimpleColor(0, 0, 0, 128);
+constexpr auto attachmentProgressBarBackgroundColor = makeSimpleColor(0, 0, 0, 89);
+constexpr auto attachmentProgressBarFillColor = Color::white;
+constexpr auto attachmentProgressBarBorderColor = makeSimpleColor(0, 0, 0, 128);
const CGFloat attachmentPlaceholderBorderRadius = 5;
-constexpr SimpleColor attachmentPlaceholderBorderColor = makeSimpleColor(0, 0, 0, 56);
+constexpr auto attachmentPlaceholderBorderColor = makeSimpleColor(0, 0, 0, 56);
const CGFloat attachmentPlaceholderBorderWidth = 2;
const CGFloat attachmentPlaceholderBorderDashLength = 6;
Modified: trunk/Source/WebKit/ChangeLog (264049 => 264050)
--- trunk/Source/WebKit/ChangeLog 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebKit/ChangeLog 2020-07-08 00:53:09 UTC (rev 264050)
@@ -1,3 +1,16 @@
+2020-07-07 Sam Weinig <[email protected]>
+
+ Part 2 of SimpleColor and SRGBA<uint8_t> are essentially the same - let's converge them
+ https://bugs.webkit.org/show_bug.cgi?id=213981
+
+ Reviewed by Darin Adler.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::paintSnapshotAtSize):
+ * WebProcess/WebPage/ios/FindControllerIOS.mm:
+ Make calls to makeSimpleColor more consistent. Use decimal rather than hex, don't pass unncessary
+ 255 as the 4th argument.
+
2020-07-07 Alex Christensen <[email protected]>
Use sendWithAsyncReply instead of EditingRangeCallback
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (264049 => 264050)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -2409,7 +2409,7 @@
if (options & SnapshotOptionsPaintSelectionRectangle) {
FloatRect selectionRectangle = frame.selection().selectionBounds();
- graphicsContext.setStrokeColor(makeSimpleColor(0xFF, 0, 0));
+ graphicsContext.setStrokeColor(makeSimpleColor(255, 0, 0));
graphicsContext.strokeRect(selectionRectangle, 1);
}
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm (264049 => 264050)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm 2020-07-08 00:53:09 UTC (rev 264050)
@@ -53,7 +53,7 @@
constexpr OptionSet<TextIndicatorOption> findTextIndicatorOptions { TextIndicatorOption::IncludeMarginIfRangeMatchesSelection, TextIndicatorOption::DoNotClipToVisibleRect };
-constexpr auto highlightColor = makeSimpleColor(255, 228, 56, 255);
+constexpr auto highlightColor = makeSimpleColor(255, 228, 56);
void FindIndicatorOverlayClientIOS::drawRect(PageOverlay& overlay, GraphicsContext& context, const IntRect& dirtyRect)
{
Modified: trunk/Source/WebKitLegacy/win/ChangeLog (264049 => 264050)
--- trunk/Source/WebKitLegacy/win/ChangeLog 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2020-07-08 00:53:09 UTC (rev 264050)
@@ -1,3 +1,13 @@
+2020-07-07 Sam Weinig <[email protected]>
+
+ Part 2 of SimpleColor and SRGBA<uint8_t> are essentially the same - let's converge them
+ https://bugs.webkit.org/show_bug.cgi?id=213981
+
+ Reviewed by Darin Adler.
+
+ * FullscreenVideoController.cpp:
+ Switch to using auto/makeSimpleColor.
+
2020-07-03 Said Abou-Hallawa <[email protected]>
Change the names of MIMETypeRegistry methods to comply with webkit naming style
Modified: trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp (264049 => 264050)
--- trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp 2020-07-08 00:32:35 UTC (rev 264049)
+++ trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp 2020-07-08 00:53:09 UTC (rev 264050)
@@ -74,11 +74,11 @@
static const int borderThickness = 2;
// Colors
-static const unsigned int backgroundColor = 0xA0202020;
-static const unsigned int borderColor = 0xFFA0A0A0;
-static const unsigned int sliderGutterColor = 0xFF141414;
-static const unsigned int sliderButtonColor = 0xFF808080;
-static const unsigned int textColor = 0xFFFFFFFF;
+static constexpr auto backgroundColor = makeSimpleColor(32, 32, 32, 160);
+static constexpr auto borderColor = makeSimpleColor(160, 160, 160);
+static constexpr auto sliderGutterColor = makeSimpleColor(20, 20, 20);
+static constexpr auto sliderButtonColor = makeSimpleColor(128, 128, 128);
+static constexpr auto textColor = makeSimpleColor(255, 255, 255);
HUDButton::HUDButton(HUDButtonType type, const IntPoint& position)
: HUDWidget(IntRect(position, IntSize()))