Extended Color: Replace Color constructors taking numeric values with type specific...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jun 2020 14:17:12 +0000 (14:17 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jun 2020 14:17:12 +0000 (14:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=212576

Reviewed by Tim Horton.

Replaces all remaining implicit and explicit uses of the Color constructors taking numeric
values with explicit calls to makeSimpleColor/makeSimpleColorFromFloats/makeExtendedColor,
giving us a consistent way to create colors. Also addes use constexpr SimpleColors where possible.

Source/WebCore:

* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):
* css/CSSValuePool.cpp:
(WebCore::StaticCSSValuePool::StaticCSSValuePool):
* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::parseColorFunctionParameters):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::createInnerTextStyle):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::shadowColor const):
(WebCore::CanvasRenderingContext2DBase::setShadow):
* html/canvas/CanvasStyle.cpp:
(WebCore::CanvasStyle::CanvasStyle):
(WebCore::CanvasStyle::isEquivalentRGBA const):
* inspector/InspectorOverlay.cpp:
(WebCore::drawOutlinedQuadWithClip):
(WebCore::drawShapeHighlight):
(WebCore::InspectorOverlay::paint):
(WebCore::InspectorOverlay::drawPaintRects):
(WebCore::InspectorOverlay::drawBounds):
(WebCore::InspectorOverlay::drawRulers):
(WebCore::InspectorOverlay::drawElementTitle):
* inspector/agents/InspectorDOMAgent.cpp:
(WebCore::parseColor):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::debugTextShadow):
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::captionsBackgroundCSS const):
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors):
(WebCore::NonFastScrollableRegionOverlay::drawRect):
* page/FrameView.cpp:
(WebCore::FrameView::paintContents):
* page/PrintContext.cpp:
(WebCore::PrintContext::spoolAllPagesWithBoundaries):
* page/linux/ResourceUsageOverlayLinux.cpp:
(WebCore::ResourceUsageOverlay::platformInitialize):
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::draw):
* platform/graphics/Color.cpp:
(WebCore::Color::light const):
(WebCore::Color::dark const):
(WebCore::Color::blendWithWhite const):
(WebCore::Color::colorWithAlphaMultipliedBy const):
(WebCore::Color::colorWithAlphaMultipliedByUsingAlternativeRounding const):
(WebCore::Color::colorWithAlpha const):
(WebCore::Color::colorWithAlphaUsingAlternativeRounding const):
(WebCore::blendWithoutPremultiply):
(WebCore::extendedColorsEqual): Deleted.
(WebCore::Color::tagAsValid): Deleted.
* platform/graphics/Color.h:
(WebCore::Color::Color):
(WebCore::Color::tagAsSemantic):
(WebCore::Color::tagAsValid):
(WebCore::extendedColorsEqual):
(WebCore::Color::decode):
(WebCore::Color::setIsSemantic): Deleted.
* platform/graphics/ExtendedColor.cpp:
(WebCore::makeExtendedColor):
* platform/graphics/ExtendedColor.h:
(WebCore::ExtendedColor::ExtendedColor):
(): Deleted.
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::getDebugBorderInfo const):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges):
(WebCore::contentsLayerDebugBorderColor):
(WebCore::cloneLayerDebugBorderColor):
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
* platform/graphics/ca/PlatformCALayer.cpp:
(WebCore::PlatformCALayer::drawRepaintIndicator):
* platform/graphics/ca/TileCoverageMap.cpp:
(WebCore::TileCoverageMap::TileCoverageMap):
(WebCore::TileCoverageMap::update):
* platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
(PlatformCALayerWinInternal::drawRepaintCounters):
* platform/graphics/cairo/GradientCairo.cpp:
(WebCore::interpolateColorStop):
* platform/graphics/cg/ColorCG.cpp:
(WebCore::Color::Color):
* platform/graphics/cg/NativeImageCG.cpp:
(WebCore::nativeImageSinglePixelSolidColor):
* platform/graphics/cocoa/GraphicsContextCocoa.mm:
(WebCore::colorForMarkerLineStyle):
* platform/graphics/filters/FilterOperation.cpp:
(WebCore::DropShadowFilterOperation::blend):
* platform/graphics/mac/ColorMac.mm:
(WebCore::colorFromNSColor):
* platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp:
(WebCore::TextureMapperPlatformLayerBuffer::paintToTextureMapper):
* platform/ios/DragImageIOS.mm:
(WebCore::createDragImageForLink):
* platform/ios/LegacyTileCache.mm:
(WebCore::LegacyTileCache::colorForGridTileBorder const):
* platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink):
* rendering/PaintInfo.h:
(WebCore::PaintInfo::forcedTextColor const):
* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::paintReplaced):
(WebCore::replacementTextRoundedRectPressedColor): Deleted.
(WebCore::replacementTextRoundedRectColor): Deleted.
(WebCore::replacementTextColor): Deleted.
(WebCore::unavailablePluginBorderColor): Deleted.
* rendering/RenderFrameSet.cpp:
(WebCore::RenderFrameSet::paintColumnBorder):
(WebCore::RenderFrameSet::paintRowBorder):
(WebCore::borderStartEdgeColor): Deleted.
(WebCore::borderEndEdgeColor): Deleted.
(WebCore::borderFillColor): Deleted.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::beginTransparencyLayers):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintDebugOverlays):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::platformActiveSelectionBackgroundColor const):
(WebCore::RenderTheme::platformInactiveSelectionBackgroundColor const):
(WebCore::RenderTheme::platformTextSearchHighlightColor const):
(WebCore::RenderTheme::paintSystemPreviewBadge):
(WebCore::RenderTheme::platformTapHighlightColor const):
* rendering/RenderTheme.h:
(WebCore::RenderTheme::platformFocusRingColor const):
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintCheckboxDecorations):
(WebCore::RenderThemeIOS::paintRadioDecorations):
(WebCore::RenderThemeIOS::paintMenuListButtonDecorations):
(WebCore::RenderThemeIOS::paintSliderTrack):
(WebCore::RenderThemeIOS::paintProgressBar):
(WebCore::paintAttachmentProgress):
(WebCore::paintAttachmentBorder):
(WebCore::RenderThemeIOS::paintSystemPreviewBadge):
(WebCore::RenderThemeIOS::shadowColor const): Deleted.
(WebCore::attachmentBorderColor): Deleted.
(WebCore::attachmentProgressColor): Deleted.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMenuListButtonDecorations):
(WebCore::titleTextColorForAttachment):
(WebCore::AttachmentLayout::layOutSubtitle):
(WebCore::paintAttachmentIconBackground):
(WebCore::paintAttachmentTitleBackground):
(WebCore::paintAttachmentProgress):
(WebCore::paintAttachmentPlaceholderBorder):
(WebCore::attachmentIconBackgroundColor): Deleted.
(WebCore::attachmentIconBorderColor): Deleted.
(WebCore::attachmentTitleInactiveBackgroundColor): Deleted.
(WebCore::attachmentTitleInactiveTextColor): Deleted.
(WebCore::attachmentSubtitleTextColor): Deleted.
(WebCore::attachmentProgressBarBackgroundColor): Deleted.
(WebCore::attachmentProgressBarFillColor): Deleted.
(WebCore::attachmentProgressBarBorderColor): Deleted.
(WebCore::attachmentPlaceholderBorderColor): Deleted.
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::platformActiveSelectionBackgroundColor const):
(WebCore::RenderThemeWin::platformInactiveSelectionBackgroundColor const):
(WebCore::RenderThemeWin::platformActiveSelectionForegroundColor const):
(WebCore::RenderThemeWin::systemColor const):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):
* rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::RenderMathMLBlock::paint):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::colorResolvingCurrentColor const):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::initialStrokeColor):
* rendering/style/SVGRenderStyle.h:
(WebCore::SVGRenderStyle::initialStopColor):
(WebCore::SVGRenderStyle::initialFloodColor):
(WebCore::SVGRenderStyle::initialLightingColor):
* svg/SVGStopElement.cpp:
(WebCore::SVGStopElement::stopColorIncludingOpacity const):
* svg/properties/SVGAnimationAdditiveValueFunctionImpl.h:
(WebCore::SVGAnimationColorFunction::animate):
* testing/MockPageOverlayClient.cpp:
(WebCore::MockPageOverlayClient::drawRect):
* testing/cocoa/WebViewVisualIdentificationOverlay.mm:
(-[WebViewVisualIdentificationOverlay initWithWebView:kind:deprecated:]):

Source/WebKit:

* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::drawInContext):
* UIProcess/API/wpe/WebKitColor.cpp:
(webkitColorToWebCoreColor):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _tapHighlightColorForFastClick:]):
* WebProcess/Inspector/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::showPaintRect):
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::drawRect):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::paintSnapshotAtSize):
* WebProcess/WebPage/ios/FindControllerIOS.mm:
(WebKit::FindIndicatorOverlayClientIOS::drawRect):
(WebKit::highlightColor): Deleted.

Source/WebKitLegacy/mac:

* WebView/WebIndicateLayer.mm:

Source/WebKitLegacy/win:

* WebView.cpp:
(compositionToUnderlines):

Tools:

* TestWebKitAPI/Tests/WebCore/ColorTests.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/ExtendedColorTests.cpp:
(TestWebKitAPI::TEST):
(TestWebKitAPI::makeColor):
* TestWebKitAPI/Tests/WebKitCocoa/PDFSnapshot.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/cocoa/TestPDFDocument.mm:
(TestWebKitAPI::TestPDFPage::colorAtPoint const):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@262377 268f45cc-cd09-0410-ab3c-d52691b4dbfc

72 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
Source/WebCore/css/CSSValuePool.cpp
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Source/WebCore/html/canvas/CanvasStyle.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp
Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp
Source/WebCore/page/DebugPageOverlays.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/PrintContext.cpp
Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/Color.h
Source/WebCore/platform/graphics/ExtendedColor.cpp
Source/WebCore/platform/graphics/ExtendedColor.h
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp
Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
Source/WebCore/platform/graphics/cairo/GradientCairo.cpp
Source/WebCore/platform/graphics/cg/ColorCG.cpp
Source/WebCore/platform/graphics/cg/NativeImageCG.cpp
Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm
Source/WebCore/platform/graphics/filters/FilterOperation.cpp
Source/WebCore/platform/graphics/mac/ColorMac.mm
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp
Source/WebCore/platform/ios/DragImageIOS.mm
Source/WebCore/platform/ios/LegacyTileCache.mm
Source/WebCore/platform/win/DragImageWin.cpp
Source/WebCore/rendering/PaintInfo.h
Source/WebCore/rendering/RenderEmbeddedObject.cpp
Source/WebCore/rendering/RenderFrameSet.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderThemeWin.cpp
Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/SVGRenderStyle.h
Source/WebCore/svg/SVGStopElement.cpp
Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h
Source/WebCore/testing/MockPageOverlayClient.cpp
Source/WebCore/testing/cocoa/WebViewVisualIdentificationOverlay.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm
Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebProcess/Inspector/WebInspectorClient.cpp
Source/WebKit/WebProcess/WebPage/FindController.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebIndicateLayer.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebView.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/ColorTests.cpp
Tools/TestWebKitAPI/Tests/WebCore/ExtendedColorTests.cpp
Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFSnapshot.mm
Tools/TestWebKitAPI/cocoa/TestPDFDocument.mm

index 6be8565..e0d6cc9 100644 (file)
@@ -1,3 +1,192 @@
+2020-06-01  Sam Weinig  <weinig@apple.com>
+
+        Extended Color: Replace Color constructors taking numeric values with type specific factory functions
+        https://bugs.webkit.org/show_bug.cgi?id=212576
+
+        Reviewed by Tim Horton.
+
+        Replaces all remaining implicit and explicit uses of the Color constructors taking numeric
+        values with explicit calls to makeSimpleColor/makeSimpleColorFromFloats/makeExtendedColor,
+        giving us a consistent way to create colors. Also addes use constexpr SimpleColors where possible.
+
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData):
+        * css/CSSValuePool.cpp:
+        (WebCore::StaticCSSValuePool::StaticCSSValuePool):
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::parseColorFunctionParameters):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::createInnerTextStyle):
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::shadowColor const):
+        (WebCore::CanvasRenderingContext2DBase::setShadow):
+        * html/canvas/CanvasStyle.cpp:
+        (WebCore::CanvasStyle::CanvasStyle):
+        (WebCore::CanvasStyle::isEquivalentRGBA const):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::drawOutlinedQuadWithClip):
+        (WebCore::drawShapeHighlight):
+        (WebCore::InspectorOverlay::paint):
+        (WebCore::InspectorOverlay::drawPaintRects):
+        (WebCore::InspectorOverlay::drawBounds):
+        (WebCore::InspectorOverlay::drawRulers):
+        (WebCore::InspectorOverlay::drawElementTitle):
+        * inspector/agents/InspectorDOMAgent.cpp:
+        (WebCore::parseColor):
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::debugTextShadow):
+        * page/CaptionUserPreferencesMediaAF.cpp:
+        (WebCore::CaptionUserPreferencesMediaAF::captionsBackgroundCSS const):
+        * page/DebugPageOverlays.cpp:
+        (WebCore::touchEventRegionColors):
+        (WebCore::NonFastScrollableRegionOverlay::drawRect):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::paintContents):
+        * page/PrintContext.cpp:
+        (WebCore::PrintContext::spoolAllPagesWithBoundaries):
+        * page/linux/ResourceUsageOverlayLinux.cpp:
+        (WebCore::ResourceUsageOverlay::platformInitialize):
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::draw):
+        * platform/graphics/Color.cpp:
+        (WebCore::Color::light const):
+        (WebCore::Color::dark const):
+        (WebCore::Color::blendWithWhite const):
+        (WebCore::Color::colorWithAlphaMultipliedBy const):
+        (WebCore::Color::colorWithAlphaMultipliedByUsingAlternativeRounding const):
+        (WebCore::Color::colorWithAlpha const):
+        (WebCore::Color::colorWithAlphaUsingAlternativeRounding const):
+        (WebCore::blendWithoutPremultiply):
+        (WebCore::extendedColorsEqual): Deleted.
+        (WebCore::Color::tagAsValid): Deleted.
+        * platform/graphics/Color.h:
+        (WebCore::Color::Color):
+        (WebCore::Color::tagAsSemantic):
+        (WebCore::Color::tagAsValid):
+        (WebCore::extendedColorsEqual):
+        (WebCore::Color::decode):
+        (WebCore::Color::setIsSemantic): Deleted.
+        * platform/graphics/ExtendedColor.cpp:
+        (WebCore::makeExtendedColor):
+        * platform/graphics/ExtendedColor.h:
+        (WebCore::ExtendedColor::ExtendedColor):
+        (): Deleted.
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::getDebugBorderInfo const):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::recursiveCommitChanges):
+        (WebCore::contentsLayerDebugBorderColor):
+        (WebCore::cloneLayerDebugBorderColor):
+        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
+        * platform/graphics/ca/PlatformCALayer.cpp:
+        (WebCore::PlatformCALayer::drawRepaintIndicator):
+        * platform/graphics/ca/TileCoverageMap.cpp:
+        (WebCore::TileCoverageMap::TileCoverageMap):
+        (WebCore::TileCoverageMap::update):
+        * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
+        (PlatformCALayerWinInternal::drawRepaintCounters):
+        * platform/graphics/cairo/GradientCairo.cpp:
+        (WebCore::interpolateColorStop):
+        * platform/graphics/cg/ColorCG.cpp:
+        (WebCore::Color::Color):
+        * platform/graphics/cg/NativeImageCG.cpp:
+        (WebCore::nativeImageSinglePixelSolidColor):
+        * platform/graphics/cocoa/GraphicsContextCocoa.mm:
+        (WebCore::colorForMarkerLineStyle):
+        * platform/graphics/filters/FilterOperation.cpp:
+        (WebCore::DropShadowFilterOperation::blend):
+        * platform/graphics/mac/ColorMac.mm:
+        (WebCore::colorFromNSColor):
+        * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp:
+        (WebCore::TextureMapperPlatformLayerBuffer::paintToTextureMapper):
+        * platform/ios/DragImageIOS.mm:
+        (WebCore::createDragImageForLink):
+        * platform/ios/LegacyTileCache.mm:
+        (WebCore::LegacyTileCache::colorForGridTileBorder const):
+        * platform/win/DragImageWin.cpp:
+        (WebCore::createDragImageForLink):
+        * rendering/PaintInfo.h:
+        (WebCore::PaintInfo::forcedTextColor const):
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::paintReplaced):
+        (WebCore::replacementTextRoundedRectPressedColor): Deleted.
+        (WebCore::replacementTextRoundedRectColor): Deleted.
+        (WebCore::replacementTextColor): Deleted.
+        (WebCore::unavailablePluginBorderColor): Deleted.
+        * rendering/RenderFrameSet.cpp:
+        (WebCore::RenderFrameSet::paintColumnBorder):
+        (WebCore::RenderFrameSet::paintRowBorder):
+        (WebCore::borderStartEdgeColor): Deleted.
+        (WebCore::borderEndEdgeColor): Deleted.
+        (WebCore::borderFillColor): Deleted.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::beginTransparencyLayers):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::paintDebugOverlays):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::platformActiveSelectionBackgroundColor const):
+        (WebCore::RenderTheme::platformInactiveSelectionBackgroundColor const):
+        (WebCore::RenderTheme::platformTextSearchHighlightColor const):
+        (WebCore::RenderTheme::paintSystemPreviewBadge):
+        (WebCore::RenderTheme::platformTapHighlightColor const):
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::platformFocusRingColor const):
+        * rendering/RenderThemeIOS.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::paintCheckboxDecorations):
+        (WebCore::RenderThemeIOS::paintRadioDecorations):
+        (WebCore::RenderThemeIOS::paintMenuListButtonDecorations):
+        (WebCore::RenderThemeIOS::paintSliderTrack):
+        (WebCore::RenderThemeIOS::paintProgressBar):
+        (WebCore::paintAttachmentProgress):
+        (WebCore::paintAttachmentBorder):
+        (WebCore::RenderThemeIOS::paintSystemPreviewBadge):
+        (WebCore::RenderThemeIOS::shadowColor const): Deleted.
+        (WebCore::attachmentBorderColor): Deleted.
+        (WebCore::attachmentProgressColor): Deleted.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintMenuListButtonDecorations):
+        (WebCore::titleTextColorForAttachment):
+        (WebCore::AttachmentLayout::layOutSubtitle):
+        (WebCore::paintAttachmentIconBackground):
+        (WebCore::paintAttachmentTitleBackground):
+        (WebCore::paintAttachmentProgress):
+        (WebCore::paintAttachmentPlaceholderBorder):
+        (WebCore::attachmentIconBackgroundColor): Deleted.
+        (WebCore::attachmentIconBorderColor): Deleted.
+        (WebCore::attachmentTitleInactiveBackgroundColor): Deleted.
+        (WebCore::attachmentTitleInactiveTextColor): Deleted.
+        (WebCore::attachmentSubtitleTextColor): Deleted.
+        (WebCore::attachmentProgressBarBackgroundColor): Deleted.
+        (WebCore::attachmentProgressBarFillColor): Deleted.
+        (WebCore::attachmentProgressBarBorderColor): Deleted.
+        (WebCore::attachmentPlaceholderBorderColor): Deleted.
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::RenderThemeWin::platformActiveSelectionBackgroundColor const):
+        (WebCore::RenderThemeWin::platformInactiveSelectionBackgroundColor const):
+        (WebCore::RenderThemeWin::platformActiveSelectionForegroundColor const):
+        (WebCore::RenderThemeWin::systemColor const):
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::paintFlow):
+        * rendering/mathml/RenderMathMLBlock.cpp:
+        (WebCore::RenderMathMLBlock::paint):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::colorResolvingCurrentColor const):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::initialStrokeColor):
+        * rendering/style/SVGRenderStyle.h:
+        (WebCore::SVGRenderStyle::initialStopColor):
+        (WebCore::SVGRenderStyle::initialFloodColor):
+        (WebCore::SVGRenderStyle::initialLightingColor):
+        * svg/SVGStopElement.cpp:
+        (WebCore::SVGStopElement::stopColorIncludingOpacity const):
+        * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h:
+        (WebCore::SVGAnimationColorFunction::animate):
+        * testing/MockPageOverlayClient.cpp:
+        (WebCore::MockPageOverlayClient::drawRect):
+        * testing/cocoa/WebViewVisualIdentificationOverlay.mm:
+        (-[WebViewVisualIdentificationOverlay initWithWebView:kind:deprecated:]):
+
 2020-06-01  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] When GraphicsLayerCA::m_uncommittedChanges is initialized with a non-zero value, nothing is painted.
index f353536..b64d839 100644 (file)
@@ -348,7 +348,7 @@ void AXIsolatedObject::initializeAttributeData(AXCoreObject& object, bool isRoot
     
     int r, g, b;
     object.colorValue(r, g, b);
-    setProperty(AXPropertyName::ColorValue, Color(r, g, b));
+    setProperty(AXPropertyName::ColorValue, makeSimpleColor(r, g, b));
     
     if (bool isMathElement = object.isMathElement()) {
         setProperty(AXPropertyName::IsMathElement, isMathElement);
index c2183b4..7b5ba3e 100644 (file)
@@ -44,9 +44,9 @@ StaticCSSValuePool::StaticCSSValuePool()
     m_unsetValue.construct(CSSValue::StaticCSSValue);
     m_revertValue.construct(CSSValue::StaticCSSValue);
 
-    m_transparentColor.construct(CSSValue::StaticCSSValue, Color(Color::transparent));
-    m_whiteColor.construct(CSSValue::StaticCSSValue, Color(Color::white));
-    m_blackColor.construct(CSSValue::StaticCSSValue, Color(Color::black));
+    m_transparentColor.construct(CSSValue::StaticCSSValue, Color::transparent);
+    m_whiteColor.construct(CSSValue::StaticCSSValue, Color::white);
+    m_blackColor.construct(CSSValue::StaticCSSValue, Color::black);
 
     for (unsigned i = firstCSSValueKeyword; i <= lastCSSValueKeyword; ++i)
         m_identifierValues[i].construct(CSSValue::StaticCSSValue, static_cast<CSSValueID>(i));
index 028b813..7adf897 100644 (file)
@@ -687,7 +687,7 @@ static Color parseColorFunctionParameters(CSSParserTokenRange& range)
     if (!args.atEnd())
         return Color();
     
-    return Color(colorChannels[0], colorChannels[1], colorChannels[2], colorChannels[3], colorSpace);
+    return makeExtendedColor(colorChannels[0], colorChannels[1], colorChannels[2], colorChannels[3], colorSpace);
 }
 
 static Optional<SimpleColor> parseHexColor(CSSParserTokenRange& range, bool acceptQuirkyColors)
index 502f702..0d9f927 100644 (file)
@@ -2092,7 +2092,7 @@ RenderStyle HTMLInputElement::createInnerTextStyle(const RenderStyle& style)
     if (hasAutoFillStrongPasswordButton() && !isDisabledOrReadOnly()) {
         textBlockStyle.setDisplay(DisplayType::InlineBlock);
         textBlockStyle.setMaxWidth(Length { 100, Percent });
-        textBlockStyle.setColor({ 0.0f, 0.0f, 0.0f, 0.6f });
+        textBlockStyle.setColor(makeSimpleColor(0, 0, 0, 153));
         textBlockStyle.setTextOverflow(TextOverflow::Clip);
         textBlockStyle.setMaskImage(StyleGeneratedImage::create(autoFillStrongPasswordMaskImage()));
         // A stacking context is needed for the mask.
index 573e576..94410a0 100644 (file)
@@ -626,7 +626,7 @@ void CanvasRenderingContext2DBase::setShadowBlur(float blur)
 
 String CanvasRenderingContext2DBase::shadowColor() const
 {
-    return Color(state().shadowColor).serialized();
+    return state().shadowColor.serialized();
 }
 
 void CanvasRenderingContext2DBase::setShadowColor(const String& colorString)
@@ -1307,17 +1307,17 @@ void CanvasRenderingContext2DBase::setShadow(float width, float height, float bl
 
 void CanvasRenderingContext2DBase::setShadow(float width, float height, float blur, float grayLevel, float alpha)
 {
-    setShadow(FloatSize(width, height), blur, Color(grayLevel, grayLevel, grayLevel, alpha));
+    setShadow(FloatSize(width, height), blur, makeSimpleColorFromFloats(grayLevel, grayLevel, grayLevel, alpha));
 }
 
 void CanvasRenderingContext2DBase::setShadow(float width, float height, float blur, float r, float g, float b, float a)
 {
-    setShadow(FloatSize(width, height), blur, Color(r, g, b, a));
+    setShadow(FloatSize(width, height), blur, makeSimpleColorFromFloats(r, g, b, a));
 }
 
 void CanvasRenderingContext2DBase::setShadow(float width, float height, float blur, float c, float m, float y, float k, float a)
 {
-    setShadow(FloatSize(width, height), blur, Color(c, m, y, k, a));
+    setShadow(FloatSize(width, height), blur, makeSimpleColorFromCMYKA(c, m, y, k, a));
 }
 
 void CanvasRenderingContext2DBase::clearShadow()
index 2bb93da..a4b433c 100644 (file)
@@ -93,17 +93,17 @@ CanvasStyle::CanvasStyle(Color color)
 }
 
 CanvasStyle::CanvasStyle(float grayLevel, float alpha)
-    : m_style(Color { grayLevel, grayLevel, grayLevel, alpha })
+    : m_style(makeSimpleColorFromFloats(grayLevel, grayLevel, grayLevel, alpha))
 {
 }
 
 CanvasStyle::CanvasStyle(float r, float g, float b, float a)
-    : m_style(Color { r, g, b, a })
+    : m_style(makeSimpleColorFromFloats(r, g, b, a))
 {
 }
 
 CanvasStyle::CanvasStyle(float c, float m, float y, float k, float a)
-    : m_style(CMYKAColor { Color { c, m, y, k, a }, c, m, y, k, a })
+    : m_style(CMYKAColor { makeSimpleColorFromCMYKA(c, m, y, k, a), c, m, y, k, a })
 {
 }
 
@@ -162,7 +162,7 @@ bool CanvasStyle::isEquivalentColor(const CanvasStyle& other) const
 
 bool CanvasStyle::isEquivalentRGBA(float r, float g, float b, float a) const
 {
-    return WTF::holds_alternative<Color>(m_style) && WTF::get<Color>(m_style) == Color { r, g, b, a };
+    return WTF::holds_alternative<Color>(m_style) && WTF::get<Color>(m_style) == makeSimpleColorFromFloats(r, g, b, a);
 }
 
 bool CanvasStyle::isEquivalentCMYKA(float c, float m, float y, float k, float a) const
index 23db0fb..281bdaf 100644 (file)
@@ -222,7 +222,7 @@ static void drawOutlinedQuadWithClip(GraphicsContext& context, const FloatQuad&
     context.fillPath(quadToPath(quad, bounds));
 
     context.setCompositeOperation(CompositeOperator::DestinationOut);
-    context.setFillColor(Color(255, 0, 0));
+    context.setFillColor(makeSimpleColor(255, 0, 0));
     context.fillPath(quadToPath(clipQuad, bounds));
 }
 
@@ -293,7 +293,7 @@ static void drawShapeHighlight(GraphicsContext& context, Node& node, Highlight::
     FrameView* containingView = containingFrame->view();
     FrameView* mainView = containingFrame->page()->mainFrame().view();
 
-    const Color shapeHighlightColor(96, 82, 127, 204);
+    constexpr auto shapeHighlightColor = makeSimpleColor(96, 82, 127, 204);
 
     Shape::DisplayPaths paths;
     shapeOutsideInfo->computedShape().buildDisplayPaths(paths);
@@ -345,7 +345,7 @@ static void drawShapeHighlight(GraphicsContext& context, Node& node, Highlight::
 
         GraphicsContextStateSaver stateSaver(context);
 
-        const Color shapeMarginHighlightColor(96, 82, 127, 153);
+        constexpr auto shapeMarginHighlightColor = makeSimpleColor(96, 82, 127, 153);
         context.setFillColor(shapeMarginHighlightColor);
         context.fillPath(marginPath);
     }
@@ -382,7 +382,7 @@ void InspectorOverlay::paint(GraphicsContext& context)
     if (m_indicating) {
         GraphicsContextStateSaver stateSaver(context);
 
-        const Color indicatingColor(111, 168, 220, 168);
+        constexpr auto indicatingColor = makeSimpleColor(111, 168, 220, 168);
         context.setFillColor(indicatingColor);
         context.fillRect({ FloatPoint::zero(), viewportSize });
     }
@@ -611,7 +611,7 @@ void InspectorOverlay::drawPaintRects(GraphicsContext& context, const Deque<Time
 {
     GraphicsContextStateSaver stateSaver(context);
 
-    const Color paintRectsColor(1.0f, 0.0f, 0.0f, 0.5f);
+    constexpr auto paintRectsColor = makeSimpleColor(255, 0, 0, 128);
     context.setFillColor(paintRectsColor);
 
     for (const TimeRectPair& pair : paintRects)
@@ -662,7 +662,7 @@ void InspectorOverlay::drawBounds(GraphicsContext& context, const Highlight::Bou
 
     context.setStrokeThickness(1);
 
-    const Color boundsColor(1.0f, 0.0f, 0.0f, 0.6f);
+    constexpr auto boundsColor = makeSimpleColor(255, 0, 0, 153);
     context.setStrokeColor(boundsColor);
 
     context.strokePath(path);
@@ -670,9 +670,9 @@ void InspectorOverlay::drawBounds(GraphicsContext& context, const Highlight::Bou
 
 void InspectorOverlay::drawRulers(GraphicsContext& context, const InspectorOverlay::RulerExclusion& rulerExclusion)
 {
-    const Color rulerBackgroundColor(1.0f, 1.0f, 1.0f, 0.6f);
-    const Color lightRulerColor(0.0f, 0.0f, 0.0f, 0.2f);
-    const Color darkRulerColor(0.0f, 0.0f, 0.0f, 0.5f);
+    constexpr auto rulerBackgroundColor = makeSimpleColor(255, 255, 255, 153);
+    constexpr auto lightRulerColor = makeSimpleColor(0, 0, 0, 51);
+    constexpr auto darkRulerColor = makeSimpleColor(0, 0, 0, 128);
 
     IntPoint scrollOffset;
 
@@ -1046,14 +1046,14 @@ Path InspectorOverlay::drawElementTitle(GraphicsContext& context, Node& node, co
 
     context.translate(elementDataBorderSize / 2.0f, elementDataBorderSize / 2.0f);
 
-    const Color elementTitleBackgroundColor(255, 255, 194);
+    constexpr auto elementTitleBackgroundColor = makeSimpleColor(255, 255, 194);
     context.setFillColor(elementTitleBackgroundColor);
 
     context.fillPath(path);
 
     context.setStrokeThickness(elementDataBorderSize);
 
-    const Color elementTitleBorderColor(128, 128, 128);
+    constexpr auto elementTitleBorderColor = makeSimpleColor(128, 128, 128);
     context.setStrokeColor(elementTitleBorderColor);
 
     context.strokePath(path);
@@ -1068,10 +1068,10 @@ Path InspectorOverlay::drawElementTitle(GraphicsContext& context, Node& node, co
         textPositionX += context.drawText(font, TextRun(text), { textPositionX, textPositionY });
     };
 
-    drawText(elementTagName, Color(136, 18, 128)); // Keep this in sync with XMLViewer.css (.tag)
-    drawText(elementIDValue, Color(26, 26, 166)); // Keep this in sync with XMLViewer.css (.attribute-value)
-    drawText(elementClassValue, Color(153, 69, 0)); // Keep this in sync with XMLViewer.css (.attribute-name)
-    drawText(elementPseudoType, Color(136, 18, 128)); // Keep this in sync with XMLViewer.css (.tag)
+    drawText(elementTagName, makeSimpleColor(136, 18, 128)); // Keep this in sync with XMLViewer.css (.tag)
+    drawText(elementIDValue, makeSimpleColor(26, 26, 166)); // Keep this in sync with XMLViewer.css (.attribute-value)
+    drawText(elementClassValue, makeSimpleColor(153, 69, 0)); // Keep this in sync with XMLViewer.css (.attribute-name)
+    drawText(elementPseudoType, makeSimpleColor(136, 18, 128)); // Keep this in sync with XMLViewer.css (.tag)
     drawText(" "_s, Color::black);
     drawText(elementWidth, Color::black);
     drawText("px"_s, Color::darkGray);
@@ -1085,7 +1085,7 @@ Path InspectorOverlay::drawElementTitle(GraphicsContext& context, Node& node, co
         textPositionX = boxX + elementDataSpacing;
         textPositionY += fontHeight;
 
-        drawText("Role"_s, Color(170, 13, 145));
+        drawText("Role"_s, makeSimpleColor(170, 13, 145));
         drawText(" "_s, Color::black);
         drawText(elementRole, Color::black);
     }
index 912999f..7fd01ea 100644 (file)
@@ -141,7 +141,7 @@ static Color parseColor(const JSON::Object* colorObject)
 
     double a = 1.0;
     if (!colorObject->getDouble("a", a))
-        return Color(r, g, b);
+        return makeSimpleColor(r, g, b);
 
     // Clamp alpha to the [0..1] range.
     if (a < 0)
@@ -149,7 +149,7 @@ static Color parseColor(const JSON::Object* colorObject)
     else if (a > 1)
         a = 1;
 
-    return Color(r, g, b, static_cast<int>(a * 255));
+    return makeSimpleColor(r, g, b, static_cast<int>(a * 255));
 }
 
 static Color parseConfigColor(const String& fieldName, const JSON::Object* configObject)
index a1808c4..51fc5e1 100644 (file)
@@ -361,7 +361,7 @@ ShadowData* LineLayout::debugTextShadow()
     if (!m_flow.settings().simpleLineLayoutDebugBordersEnabled())
         return nullptr;
 
-    static NeverDestroyed<ShadowData> debugTextShadow(IntPoint(0, 0), 10, 20, ShadowStyle::Normal, true, Color(0, 0, 150, 150));
+    static NeverDestroyed<ShadowData> debugTextShadow(IntPoint(0, 0), 10, 20, ShadowStyle::Normal, true, makeSimpleColor(0, 0, 150, 150));
     return &debugTextShadow.get();
 }
 
index d57b7a4..e3950c9 100644 (file)
@@ -288,7 +288,7 @@ String CaptionUserPreferencesMediaAF::captionsBackgroundCSS() const
 {
     // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-past-nodes
     // and webkit-media-text-track-future-nodes.
-    static NeverDestroyed<Color> defaultBackgroundColor(0, 0, 0, 0.8 * 255);
+    constexpr auto defaultBackgroundColor = makeSimpleColor(0, 0, 0, 0.8 * 255);
 
     MACaptionAppearanceBehavior behavior;
 
index 4e5711d..9f42b77 100644 (file)
@@ -82,7 +82,7 @@ public:
 
 private:
     explicit MouseWheelRegionOverlay(Page& page)
-        : RegionOverlay(page, Color(0.5f, 0.0f, 0.0f, 0.4f))
+        : RegionOverlay(page, makeSimpleColorFromFloats(0.5f, 0.0f, 0.0f, 0.4f))
     {
     }
 
@@ -118,7 +118,7 @@ public:
 
 private:
     explicit NonFastScrollableRegionOverlay(Page& page)
-        : RegionOverlay(page, Color(1.0f, 0.5f, 0.0f, 0.4f))
+        : RegionOverlay(page, makeSimpleColorFromFloats(1.0f, 0.5f, 0.0f, 0.4f))
     {
     }
 
@@ -144,7 +144,7 @@ bool NonFastScrollableRegionOverlay::updateRegion()
     return regionChanged;
 }
 
-static const HashMap<String, Color>& touchEventRegionColors()
+static const HashMap<String, SimpleColor>& touchEventRegionColors()
 {
     static const auto regionColors = makeNeverDestroyed([] {
         struct MapEntry {
@@ -163,9 +163,9 @@ static const HashMap<String, Color>& touchEventRegionColors()
             { "mousemove"_s, 245, 245, 80 },
             { "mouseup"_s, 80, 245, 176 },
         };
-        HashMap<String, Color> map;
+        HashMap<String, SimpleColor> map;
         for (auto& entry : entries)
-            map.add(entry.name, Color { entry.r, entry.g, entry.b, 50 });
+            map.add(entry.name, makeSimpleColor(entry.r, entry.g, entry.b, 50));
         return map;
     }());
     return regionColors;
@@ -246,7 +246,7 @@ void NonFastScrollableRegionOverlay::drawRect(PageOverlay& pageOverlay, Graphics
 #endif
 
     for (const auto& synchronousEventRegion : m_eventTrackingRegions.eventSpecificSynchronousDispatchRegions) {
-        Color regionColor(0, 0, 0, 64);
+        auto regionColor = makeSimpleColor(0, 0, 0, 64);
         auto it = touchEventRegionColors().find(synchronousEventRegion.key);
         if (it != touchEventRegionColors().end())
             regionColor = it->value;
index f16af16..3c51fb3 100644 (file)
@@ -4243,7 +4243,7 @@ void FrameView::paintContents(GraphicsContext& context, const IntRect& dirtyRect
     if (fillWithWarningColor) {
         IntRect debugRect = frameRect();
         debugRect.intersect(dirtyRect);
-        context.fillRect(debugRect, Color(255, 64, 255));
+        context.fillRect(debugRect, makeSimpleColor(255, 64, 255));
     }
 #endif
 
index eceeead..4e4c7e8 100644 (file)
@@ -430,7 +430,7 @@ void PrintContext::spoolAllPagesWithBoundaries(Frame& frame, GraphicsContext& gr
     int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;
 
     // Fill the whole background by white.
-    graphicsContext.setFillColor(Color(255, 255, 255));
+    graphicsContext.setFillColor(makeSimpleColor(255, 255, 255));
     graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
 
     graphicsContext.save();
@@ -445,8 +445,8 @@ void PrintContext::spoolAllPagesWithBoundaries(Frame& frame, GraphicsContext& gr
             int boundaryLineY = currentHeight - 1;
 #endif
             graphicsContext.save();
-            graphicsContext.setStrokeColor(Color(0, 0, 255));
-            graphicsContext.setFillColor(Color(0, 0, 255));
+            graphicsContext.setStrokeColor(makeSimpleColor(0, 0, 255));
+            graphicsContext.setFillColor(makeSimpleColor(0, 0, 255));
             graphicsContext.drawLine(IntPoint(0, boundaryLineY), IntPoint(pageWidth, boundaryLineY));
             graphicsContext.restore();
         }
index 9fe24c2..432331a 100644 (file)
@@ -88,8 +88,8 @@ private:
     void paintContents(const GraphicsLayer*, GraphicsContext& context, const FloatRect& clip, GraphicsLayerPaintBehavior) override
     {
         GraphicsContextStateSaver stateSaver(context);
-        context.fillRect(clip, Color(0.0f, 0.0f, 0.0f, 0.8f));
-        context.setFillColor(Color(0.9f, 0.9f, 0.9f, 1.f));
+        context.fillRect(clip, makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, 0.8f));
+        context.setFillColor(makeSimpleColorFromFloats(0.9f, 0.9f, 0.9f, 1.f));
 
         FloatPoint position = { 10, 20 };
         String string =  "CPU: " + cpuUsageString(gData.cpu);
@@ -137,7 +137,7 @@ void ResourceUsageOverlay::platformInitialize()
     m_paintLayer = GraphicsLayer::create(overlay().page()->chrome().client().graphicsLayerFactory(), *m_overlayPainter);
     m_paintLayer->setAnchorPoint(FloatPoint3D());
     m_paintLayer->setSize({ normalWidth, normalHeight });
-    m_paintLayer->setBackgroundColor(Color(0.0f, 0.0f, 0.0f, 0.8f));
+    m_paintLayer->setBackgroundColor(makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, 0.8f));
     m_paintLayer->setDrawsContent(true);
     overlay().layer().addChild(*m_paintLayer);
 
index e319ce6..4137393 100644 (file)
@@ -237,7 +237,7 @@ ImageDrawResult BitmapImage::draw(GraphicsContext& context, const FloatRect& des
 
         if (!frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(m_currentFrame, m_currentSubsamplingLevel, DecodingOptions(DecodingMode::Asynchronous))) {
             if (m_showDebugBackground)
-                fillWithSolidColor(context, destRect, Color(Color::yellow).colorWithAlpha(0.5), options.compositeOperator());
+                fillWithSolidColor(context, destRect, Color::yellow.colorWithAlpha(0.5), options.compositeOperator());
             return result;
         }
 
@@ -248,7 +248,7 @@ ImageDrawResult BitmapImage::draw(GraphicsContext& context, const FloatRect& des
         ASSERT_IMPLIES(status == StartAnimationStatus::DecodingActive, (!m_currentFrame && !m_repetitionsComplete) || frameHasFullSizeNativeImageAtIndex(m_currentFrame, m_currentSubsamplingLevel));
 
         if (status == StartAnimationStatus::DecodingActive && m_showDebugBackground) {
-            fillWithSolidColor(context, destRect, Color(Color::yellow).colorWithAlpha(0.5), options.compositeOperator());
+            fillWithSolidColor(context, destRect, Color::yellow.colorWithAlpha(0.5), options.compositeOperator());
             return result;
         }
         
@@ -266,7 +266,7 @@ ImageDrawResult BitmapImage::draw(GraphicsContext& context, const FloatRect& des
         } else if (frameIsBeingDecoded) {
             // FIXME: instead of showing the yellow rectangle and returning we need to wait for this frame to finish decoding.
             if (m_showDebugBackground) {
-                fillWithSolidColor(context, destRect, Color(Color::yellow).colorWithAlpha(0.5), options.compositeOperator());
+                fillWithSolidColor(context, destRect, Color::yellow.colorWithAlpha(0.5), options.compositeOperator());
                 LOG(Images, "BitmapImage::%s - %p - url: %s [waiting for async decoding to finish]", __FUNCTION__, this, sourceURL().string().utf8().data());
             }
             return ImageDrawResult::DidRequestDecoding;
index f979aeb..a2672bd 100644 (file)
@@ -66,20 +66,6 @@ Color::Color(Color&& other)
     *this = WTFMove(other);
 }
 
-Color::Color(float c1, float c2, float c3, float alpha, ColorSpace colorSpace)
-    : Color(ExtendedColor::create(c1, c2, c3, alpha, colorSpace))
-{
-}
-
-Color::Color(Ref<ExtendedColor>&& extendedColor)
-{
-    // Zero the union, just in case a 32-bit system only assigns the
-    // top 32 bits when copying the ExtendedColor pointer below.
-    m_colorData.simpleColorAndFlags = 0;
-    m_colorData.extendedColor = &extendedColor.leakRef();
-    ASSERT(isExtended());
-}
-
 Color& Color::operator=(const Color& other)
 {
     if (*this == other)
@@ -147,12 +133,12 @@ Color Color::light() const
 
     float multiplier = std::min(1.0f, v + 0.33f) / v;
 
-    return {
+    return makeSimpleColor(
         static_cast<int>(multiplier * r * scaleFactor),
         static_cast<int>(multiplier * g * scaleFactor),
         static_cast<int>(multiplier * b * scaleFactor),
         alpha()
-    };
+    );
 }
 
 Color Color::dark() const
@@ -168,12 +154,12 @@ Color Color::dark() const
     float v = std::max({ r, g, b });
     float multiplier = std::max(0.0f, (v - 0.33f) / v);
 
-    return {
+    return makeSimpleColor(
         static_cast<int>(multiplier * r * scaleFactor),
         static_cast<int>(multiplier * g * scaleFactor),
         static_cast<int>(multiplier * b * scaleFactor),
         alpha()
-    };
+    );
 }
 
 bool Color::isDark() const
@@ -245,19 +231,19 @@ Color Color::blendWithWhite() const
 
     // FIXME: Why is preserving the semantic bit desired and/or correct here?
     if (isSemantic())
-        result.setIsSemantic();
+        result.tagAsSemantic();
     return result;
 }
 
 Color Color::colorWithAlphaMultipliedBy(float amount) const
 {
-    float newAlpha = amount * (isExtended() ? m_colorData.extendedColor->alpha() : static_cast<float>(alpha()) / 255);
+    float newAlpha = amount * alphaAsFloat();
     return colorWithAlpha(newAlpha);
 }
 
 Color Color::colorWithAlphaMultipliedByUsingAlternativeRounding(float amount) const
 {
-    float newAlpha = amount * (isExtended() ? m_colorData.extendedColor->alpha() : static_cast<float>(alpha()) / 255);
+    float newAlpha = amount * alphaAsFloat();
     return colorWithAlphaUsingAlternativeRounding(newAlpha);
 }
 
@@ -271,7 +257,7 @@ Color Color::colorWithAlpha(float alpha) const
 
     Color result = asSimple().colorWithAlpha(newAlpha);
     if (isSemantic())
-        result.setIsSemantic();
+        result.tagAsSemantic();
     return result;
 }
 
@@ -285,7 +271,7 @@ Color Color::colorWithAlphaUsingAlternativeRounding(float alpha) const
 
     Color result = asSimple().colorWithAlpha(newAlpha);
     if (isSemantic())
-        result.setIsSemantic();
+        result.tagAsSemantic();
     return result;
 }
 
@@ -325,15 +311,6 @@ ColorComponents<float> Color::toSRGBAComponentsLossy() const
     return asSimple().asSRGBFloatComponents();
 }
 
-bool extendedColorsEqual(const Color& a, const Color& b)
-{
-    if (a.isExtended() && b.isExtended())
-        return a.asExtended() == b.asExtended();
-
-    ASSERT(a.isExtended() || b.isExtended());
-    return false;
-}
-
 Color blend(const Color& from, const Color& to, double progress)
 {
     // FIXME: ExtendedColor - needs to handle color spaces.
@@ -365,17 +342,12 @@ Color blendWithoutPremultiply(const Color& from, const Color& to, double progres
     auto fromSRGB = from.toSRGBASimpleColorLossy();
     auto toSRGB = from.toSRGBASimpleColorLossy();
 
-    return {
+    return makeSimpleColorFromFloats(
         WebCore::blend(fromSRGB.redComponent(), toSRGB.redComponent(), progress),
         WebCore::blend(fromSRGB.greenComponent(), toSRGB.greenComponent(), progress),
         WebCore::blend(fromSRGB.blueComponent(), toSRGB.blueComponent(), progress),
         WebCore::blend(fromSRGB.alphaComponent(), toSRGB.alphaComponent(), progress)
-    };
-}
-
-void Color::tagAsValid()
-{
-    m_colorData.simpleColorAndFlags |= validSimpleColor;
+    );
 }
 
 TextStream& operator<<(TextStream& ts, const Color& color)
index 223cf29..7fed449 100644 (file)
@@ -56,40 +56,25 @@ class Color {
 public:
     Color() { }
 
-    // FIXME: Remove all these constructors and creation functions and replace the ones that are still needed with free functions.
-
-    Color(SimpleColor color, bool valid = true)
+    Color(SimpleColor color)
     {
-        if (valid)
-            setSimpleColor(color);
+        setSimpleColor(color);
     }
 
     enum SemanticTag { Semantic };
     Color(SimpleColor color, SemanticTag)
+        : Color(color)
     {
-        setSimpleColor(color);
-        setIsSemantic();
-    }
-
-    Color(int r, int g, int b)
-    {
-        setSimpleColor(makeSimpleColor(r, g, b));
-    }
-
-    Color(int r, int g, int b, int a)
-    {
-        setSimpleColor(makeSimpleColor(r, g, b, a));
-    }
-
-    Color(float r, float g, float b, float a)
-    {
-        setSimpleColor(makeSimpleColorFromFloats(r, g, b, a));
+        tagAsSemantic();
     }
 
-    // Creates a new color from the specific CMYK and alpha values.
-    Color(float c, float m, float y, float k, float a)
+    Color(Ref<ExtendedColor>&& extendedColor)
     {
-        setSimpleColor(makeSimpleColorFromCMYKA(c, m, y, k, a));
+        // Zero the union, just in case a 32-bit system only assigns the
+        // top 32 bits when copying the ExtendedColor pointer below.
+        m_colorData.simpleColorAndFlags = 0;
+        m_colorData.extendedColor = &extendedColor.leakRef();
+        ASSERT(isExtended());
     }
 
     explicit Color(WTF::HashTableDeletedValueType)
@@ -114,12 +99,6 @@ public:
         ASSERT(!isExtended());
     }
 
-    // This creates an ExtendedColor.
-    // FIXME: If the colorSpace is sRGB and the values can all be
-    // converted exactly to integers, we should make a normal Color.
-    WEBCORE_EXPORT Color(float, float, float, float, ColorSpace);
-    WEBCORE_EXPORT Color(Ref<ExtendedColor>&&);
-
     WEBCORE_EXPORT Color(const Color&);
     WEBCORE_EXPORT Color(Color&&);
 
@@ -160,7 +139,6 @@ public:
     Color dark() const;
 
     bool isDark() const;
-    
     WEBCORE_EXPORT float lightness() const;
 
     // This is an implementation of Porter-Duff's "source-over" equation
@@ -222,7 +200,7 @@ public:
     // Extended and non-extended colors will always be non-equal.
     friend bool operator==(const Color& a, const Color& b);
     friend bool equalIgnoringSemanticColor(const Color& a, const Color& b);
-
+    friend bool extendedColorsEqual(const Color&, const Color&);
     friend int differenceSquared(const Color&, const Color&);
 
     static bool isBlackColor(const Color&);
@@ -235,7 +213,9 @@ private:
     const SimpleColor asSimple() const;
 
     void setSimpleColor(SimpleColor);
-    void setIsSemantic() { m_colorData.simpleColorAndFlags |= isSemanticSimpleColorBit; }
+
+    void tagAsSemantic() { m_colorData.simpleColorAndFlags |= isSemanticSimpleColorBit; }
+    void tagAsValid() { m_colorData.simpleColorAndFlags |= validSimpleColor; }
 
     // 0x_______00 is an ExtendedColor pointer.
     // 0x_______01 is an invalid SimpleColor.
@@ -249,8 +229,6 @@ private:
     static const uint64_t deletedHashValue = 0xFFFFFFFFFFFFFFFD;
     static const uint64_t emptyHashValue = 0xFFFFFFFFFFFFFFFB;
 
-    WEBCORE_EXPORT void tagAsValid();
-
     union {
         uint64_t simpleColorAndFlags { invalidSimpleColor };
         ExtendedColor* extendedColor;
@@ -261,7 +239,7 @@ bool operator==(const Color&, const Color&);
 bool operator!=(const Color&, const Color&);
 
 // One or both must be extended colors.
-WEBCORE_EXPORT bool extendedColorsEqual(const Color&, const Color&);
+bool extendedColorsEqual(const Color&, const Color&);
 
 Color blend(const Color& from, const Color& to, double progress);
 Color blendWithoutPremultiply(const Color& from, const Color& to, double progress);
@@ -288,6 +266,15 @@ inline bool operator!=(const Color& a, const Color& b)
     return !(a == b);
 }
 
+inline bool extendedColorsEqual(const Color& a, const Color& b)
+{
+    if (a.isExtended() && b.isExtended())
+        return a.asExtended() == b.asExtended();
+
+    ASSERT(a.isExtended() || b.isExtended());
+    return false;
+}
+
 inline bool equalIgnoringSemanticColor(const Color& a, const Color& b)
 {
     if (a.isExtended() || b.isExtended())
@@ -396,7 +383,7 @@ Optional<Color> Color::decode(Decoder& decoder)
             return WTF::nullopt;
         if (!decoder.decode(colorSpace))
             return WTF::nullopt;
-        return Color { c1, c2, c3, alpha, colorSpace };
+        return Color { ExtendedColor::create(c1, c2, c3, alpha, colorSpace) };
     }
 
     bool isValid;
index ec2faab..61e5030 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ExtendedColor.h"
 
+#include "Color.h"
 #include "ColorUtilities.h"
 #include <wtf/Hasher.h>
 #include <wtf/MathExtras.h>
@@ -105,4 +106,9 @@ bool ExtendedColor::isBlack() const
     return !c1 && !c2 && !c3 && alpha == 1;
 }
 
+Color makeExtendedColor(float c1, float c2, float c3, float alpha, ColorSpace colorSpace)
+{
+    return ExtendedColor::create(c1, c2, c3, alpha, colorSpace);
+}
+
 }
index a480eda..3f392d9 100644 (file)
 
 namespace WebCore {
 
+class Color;
+
 class ExtendedColor : public RefCounted<ExtendedColor> {
 public:
-    static Ref<ExtendedColor> create(float, float, float, float alpha, ColorSpace = ColorSpace::SRGB);
+    WEBCORE_EXPORT static Ref<ExtendedColor> create(float c1, float c2, float c3, float alpha, ColorSpace);
 
     float alpha() const { return m_components[3]; }
 
@@ -58,10 +60,11 @@ private:
     ExtendedColor(float c1, float c2, float c3, float alpha, ColorSpace colorSpace)
         : m_components(c1, c2, c3, alpha)
         , m_colorSpace(colorSpace)
-    { }
+    {
+    }
 
     ColorComponents<float> m_components;
-    ColorSpace m_colorSpace { ColorSpace::SRGB };
+    ColorSpace m_colorSpace;
 };
 
 inline bool operator==(const ExtendedColor& a, const ExtendedColor& b)
@@ -74,4 +77,8 @@ inline bool operator!=(const ExtendedColor& a, const ExtendedColor& b)
     return !(a == b);
 }
 
+// FIXME: If the ColorSpace is sRGB and the values can all be
+// converted exactly to integers, we should make a SimpleColor.
+WEBCORE_EXPORT Color makeExtendedColor(float c1, float c2, float c3, float alpha, ColorSpace);
+
 }
index af87c18..f6893ab 100644 (file)
@@ -598,34 +598,34 @@ void GraphicsLayer::getDebugBorderInfo(Color& color, float& width) const
     width = 2;
 
     if (needsBackdrop()) {
-        color = Color(255, 0, 255, 128); // has backdrop: magenta
+        color = makeSimpleColor(255, 0, 255, 128); // has backdrop: magenta
         width = 12;
         return;
     }
     
     if (drawsContent()) {
         if (tiledBacking()) {
-            color = Color(255, 128, 0, 128); // tiled layer: orange
+            color = makeSimpleColor(255, 128, 0, 128); // tiled layer: orange
             return;
         }
 
-        color = Color(0, 128, 32, 128); // normal layer: green
+        color = makeSimpleColor(0, 128, 32, 128); // normal layer: green
         return;
     }
 
     if (usesContentsLayer()) {
-        color = Color(0, 64, 128, 150); // non-painting layer with contents: blue
+        color = makeSimpleColor(0, 64, 128, 150); // non-painting layer with contents: blue
         width = 8;
         return;
     }
     
     if (masksToBounds()) {
-        color = Color(128, 255, 255, 48); // masking layer: pale blue
+        color = makeSimpleColor(128, 255, 255, 48); // masking layer: pale blue
         width = 16;
         return;
     }
 
-    color = Color(255, 255, 0, 192); // container: yellow
+    color = makeSimpleColor(255, 255, 0, 192); // container: yellow
 }
 
 void GraphicsLayer::updateDebugIndicators()
index 52c7636..f0bb5e9 100644 (file)
@@ -1589,8 +1589,8 @@ void GraphicsLayerCA::recursiveCommitChanges(CommitState& commitState, const Tra
     // Use having a transform as a key to making the tile wash layer. If every layer gets a wash,
     // they start to obscure useful information.
     if ((!m_transform.isIdentity() || tiledBacking()) && !m_visibleTileWashLayer) {
-        static NeverDestroyed<Color> washFillColor(255, 0, 0, 50);
-        static NeverDestroyed<Color> washBorderColor(255, 0, 0, 100);
+        constexpr auto washFillColor = makeSimpleColor(255, 0, 0, 50);
+        constexpr auto washBorderColor = makeSimpleColor(255, 0, 0, 100);
         
         m_visibleTileWashLayer = createPlatformCALayer(PlatformCALayer::LayerTypeLayer, this);
         String name = makeString("Visible Tile Wash Layer 0x", hex(reinterpret_cast<uintptr_t>(m_visibleTileWashLayer->platformLayer()), Lowercase));
@@ -2547,13 +2547,13 @@ static void setLayerDebugBorder(PlatformCALayer& layer, Color borderColor, float
 static const float contentsLayerBorderWidth = 4;
 static Color contentsLayerDebugBorderColor(bool showingBorders)
 {
-    return showingBorders ? Color(0, 0, 128, 180) : Color();
+    return showingBorders ? makeSimpleColor(0, 0, 128, 180) : Color { };
 }
 
 static const float cloneLayerBorderWidth = 2;
 static Color cloneLayerDebugBorderColor(bool showingBorders)
 {
-    return showingBorders ? Color(255, 122, 251) : Color();
+    return showingBorders ? makeSimpleColor(255, 122, 251) : Color();
 }
 
 void GraphicsLayerCA::updateDebugIndicators()
@@ -3775,7 +3775,7 @@ void GraphicsLayerCA::setDebugBackgroundColor(const Color& color)
 void GraphicsLayerCA::getDebugBorderInfo(Color& color, float& width) const
 {
     if (isPageTiledBackingLayer()) {
-        color = Color(0, 0, 128, 128); // tile cache layer: dark blue
+        color = makeSimpleColor(0, 0, 128, 128); // tile cache layer: dark blue
 #if OS(WINDOWS)
         width = 1.0;
 #else
index 9b0f0b2..9b1db0e 100644 (file)
@@ -84,11 +84,11 @@ void PlatformCALayer::drawRepaintIndicator(GraphicsContext& graphicsContext, Pla
     const float verticalMargin = 2.5;
     const float horizontalMargin = 5;
     const unsigned fontSize = 22;
-    const Color backgroundColor(0.5f, 0.25f, 1.0f, 1.0f);
-    const Color acceleratedContextLabelColor(1.0f, 0.f, 0.f, 1.0f);
-    const Color unacceleratedContextLabelColor(1.0f, 1.0f, 1.0f, 1.0f);
-    const Color linearGlyphMaskOutlineColor(0.f, 0.f, 0.f, 0.75f);
-    const Color displayListBorderColor(0.f, 0.f, 0.f, 0.65f);
+    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 linearGlyphMaskOutlineColor = makeSimpleColor(0, 0, 0, 192);
+    constexpr auto displayListBorderColor = makeSimpleColor(0, 0, 0, 166);
 
     TextRun textRun(String::number(repaintCount));
 
index f54fc99..0e259a9 100644 (file)
@@ -51,16 +51,16 @@ TileCoverageMap::TileCoverageMap(const TileController& controller)
     m_visibleViewportIndicatorLayer.get().setName("visible viewport indicator");
     m_visibleViewportIndicatorLayer.get().setBorderWidth(2);
     m_visibleViewportIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
-    m_visibleViewportIndicatorLayer.get().setBorderColor(Color(255, 0, 0, 200));
+    m_visibleViewportIndicatorLayer.get().setBorderColor(makeSimpleColor(255, 0, 0, 200));
 
     m_layoutViewportIndicatorLayer.get().setName("layout viewport indicator");
     m_layoutViewportIndicatorLayer.get().setBorderWidth(2);
     m_layoutViewportIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
-    m_layoutViewportIndicatorLayer.get().setBorderColor(Color(0, 128, 128, 200));
+    m_layoutViewportIndicatorLayer.get().setBorderColor(makeSimpleColor(0, 128, 128, 200));
     
     m_coverageRectIndicatorLayer.get().setName("coverage indicator");
     m_coverageRectIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
-    m_coverageRectIndicatorLayer.get().setBackgroundColor(Color(64, 64, 64, 50));
+    m_coverageRectIndicatorLayer.get().setBackgroundColor(makeSimpleColor(64, 64, 64, 50));
 
     m_layer.get().appendSublayer(m_coverageRectIndicatorLayer);
     m_layer.get().appendSublayer(m_visibleViewportIndicatorLayer);
@@ -136,16 +136,16 @@ void TileCoverageMap::update()
     Color visibleRectIndicatorColor;
     switch (m_controller.indicatorMode()) {
     case SynchronousScrollingBecauseOfLackOfScrollingCoordinatorIndication:
-        visibleRectIndicatorColor = Color(200, 80, 255);
+        visibleRectIndicatorColor = makeSimpleColor(200, 80, 255);
         break;
     case SynchronousScrollingBecauseOfStyleIndication:
-        visibleRectIndicatorColor = Color(255, 0, 0);
+        visibleRectIndicatorColor = makeSimpleColor(255, 0, 0);
         break;
     case SynchronousScrollingBecauseOfEventHandlersIndication:
-        visibleRectIndicatorColor = Color(255, 255, 0);
+        visibleRectIndicatorColor = makeSimpleColor(255, 255, 0);
         break;
     case AsyncScrollingIndication:
-        visibleRectIndicatorColor = Color(0, 200, 0);
+        visibleRectIndicatorColor = makeSimpleColor(0, 200, 0);
         break;
     }
 
index 7ed95a2..fa1bdae 100644 (file)
@@ -127,7 +127,7 @@ void PlatformCALayerWinInternal::drawRepaintCounters(CACFLayerRef caLayer, CGCon
     if (borderWidth > 0)
         backgroundColor = CACFLayerGetBorderColor(caLayer);
     else
-        backgroundColor = cachedCGColor(Color(255, 0, 0));
+        backgroundColor = cachedCGColor(makeSimpleColor(255, 0, 0));
 
     GraphicsContext graphicsContext(context);
     PlatformCALayer::drawRepaintIndicator(graphicsContext, owner(), drawCount, backgroundColor);
index d5aeabc..f1fe936 100644 (file)
@@ -144,7 +144,7 @@ static Gradient::ColorStop interpolateColorStop(Gradient::ColorStop from, Gradie
     float b = b1 + (b2 - b1) * 0.5f;
     float a = a1 + (a2 - a1) * 0.5f;
 
-    return Gradient::ColorStop(offset, Color(r, g, b, a));
+    return Gradient::ColorStop(offset, makeSimpleColorFromFloats(r, g, b, a));
 }
 
 static cairo_pattern_t* createConic(float xo, float yo, float r, float angleRadians,
index a2d926e..111a1e7 100644 (file)
@@ -104,7 +104,7 @@ Color::Color(CGColorRef color, SemanticTag)
     }
 
     setSimpleColor(makeSimpleColorFromCGColor(color));
-    setIsSemantic();
+    tagAsSemantic();
 }
 
 static CGColorRef leakCGColor(const Color& color)
index a64d189..6fd77e9 100644 (file)
@@ -64,9 +64,9 @@ Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image)
     CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), image.get());
 
     if (!pixel[3])
-        return Color(0, 0, 0, 0);
+        return Color::transparent;
 
-    return Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
+    return makeSimpleColor(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
 }
 
 void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& options)
index 55bb4e9..9b72eb4 100644 (file)
@@ -205,15 +205,15 @@ static CGColorRef colorForMarkerLineStyle(DocumentMarkerLineStyle::Mode style, b
     switch (style) {
     // Red
     case DocumentMarkerLineStyle::Mode::Spelling:
-        return cachedCGColor(useDarkMode ? Color { 255, 140, 140, 217 } : Color { 255, 59, 48, 191 });
+        return cachedCGColor(useDarkMode ? makeSimpleColor(255, 140, 140, 217) : makeSimpleColor(255, 59, 48, 191));
     // Blue
     case DocumentMarkerLineStyle::Mode::DictationAlternatives:
     case DocumentMarkerLineStyle::Mode::TextCheckingDictationPhraseWithAlternatives:
     case DocumentMarkerLineStyle::Mode::AutocorrectionReplacement:
-        return cachedCGColor(useDarkMode ? Color { 40, 145, 255, 217 } : Color { 0, 122, 255, 191 });
+        return cachedCGColor(useDarkMode ? makeSimpleColor(40, 145, 255, 217) : makeSimpleColor(0, 122, 255, 191));
     // Green
     case DocumentMarkerLineStyle::Mode::Grammar:
-        return cachedCGColor(useDarkMode ? Color { 50, 215, 75, 217 } : Color { 25, 175, 50, 191 });
+        return cachedCGColor(useDarkMode ? makeSimpleColor(50, 215, 75, 217) : makeSimpleColor(25, 175, 50, 191));
     }
 }
 
index c4b77d4..12749f4 100644 (file)
@@ -307,12 +307,12 @@ RefPtr<FilterOperation> DropShadowFilterOperation::blend(const FilterOperation*
         return DropShadowFilterOperation::create(
             WebCore::blend(m_location, IntPoint(), progress),
             WebCore::blend(m_stdDeviation, 0, progress),
-            WebCore::blend(m_color, Color(Color::transparent), progress));
+            WebCore::blend(m_color, Color::transparent, progress));
 
     const DropShadowFilterOperation* fromOperation = downcast<DropShadowFilterOperation>(from);
     IntPoint fromLocation = fromOperation ? fromOperation->location() : IntPoint();
     int fromStdDeviation = fromOperation ? fromOperation->stdDeviation() : 0;
-    Color fromColor = fromOperation ? fromOperation->color() : Color(Color::transparent);
+    Color fromColor = fromOperation ? fromOperation->color() : Color::transparent;
     
     return DropShadowFilterOperation::create(
         WebCore::blend(fromLocation, m_location, progress),
index 8abc467..accec98 100644 (file)
@@ -96,7 +96,7 @@ Color colorFromNSColor(NSColor *color)
 {
     // FIXME: ExtendedColor - needs to handle color spaces.
 
-    return Color(makeSimpleColorFromNSColor(color));
+    return makeSimpleColorFromNSColor(color);
 }
 
 Color semanticColorFromNSColor(NSColor *color)
index 936bef8..9959aef 100644 (file)
@@ -113,7 +113,7 @@ void TextureMapperPlatformLayerBuffer::paintToTextureMapper(TextureMapper& textu
         ASSERT(!m_texture);
         if (m_holePunchClient)
             m_holePunchClient->setVideoRectangle(enclosingIntRect(modelViewMatrix.mapRect(targetRect)));
-        texmapGL.drawSolidColor(targetRect, modelViewMatrix, Color(0, 0, 0, 0), false);
+        texmapGL.drawSolidColor(targetRect, modelViewMatrix, makeSimpleColor(0, 0, 0, 0), false);
         return;
     }
 
index 0ec5d58..7a220bd 100644 (file)
@@ -139,7 +139,7 @@ DragImageRef createDragImageForLink(Element& linkElement, URL& url, const String
         GraphicsContext context(rendererContext.CGContext);
         context.translate(0, CGRectGetHeight(imageRect));
         context.scale({ 1, -1 });
-        context.fillRoundedRect(FloatRoundedRect(imageRect, FloatRoundedRect::Radii(4)), { 255, 255, 255 });
+        context.fillRoundedRect(FloatRoundedRect(imageRect, FloatRoundedRect::Radii(4)), makeSimpleColor(255, 255, 255));
         titleFontCascade.get().drawText(context, TextRun(truncatedTopString), FloatPoint(dragImagePadding, 18 + dragImagePadding));
         if (!truncatedBottomString.isEmpty())
             urlFontCascade.get().drawText(context, TextRun(truncatedBottomString), FloatPoint(dragImagePadding, 40 + dragImagePadding));
index 852bb4b..276db8e 100644 (file)
@@ -462,9 +462,9 @@ unsigned LegacyTileCache::tileCapacityForGrid(LegacyTileGrid* grid)
 Color LegacyTileCache::colorForGridTileBorder(LegacyTileGrid* grid) const
 {
     if (grid == m_zoomedOutTileGrid.get())
-        return Color(0.2f, 1.0f, 0.f, 0.5f);
+        return makeSimpleColorFromFloats(0.2f, 1.0f, 0.f, 0.5f);
 
-    return Color(0.2f, 0.9f, 0.f, 0.5f);
+    return makeSimpleColorFromFloats(0.2f, 0.9f, 0.f, 0.5f);
 }
 
 static bool shouldRepaintInPieces(const CGRect& dirtyRect, CGSRegionObj dirtyRegion, CGFloat contentsScale)
index e81c801..8f77826 100644 (file)
@@ -189,14 +189,14 @@ DragImageRef createDragImageForLink(Element&, URL& url, const String& inLabel, T
     GraphicsContext context(contextRef);
     // On Mac alpha is {0.7, 0.7, 0.7, 0.8}, however we can't control alpha
     // for drag images on win, so we use 1
-    static const Color backgroundColor(140, 140, 140);
+    constexpr auto backgroundColor = makeSimpleColor(140, 140, 140);
     static const IntSize radii(DragLabelRadius, DragLabelRadius);
     IntRect rect(0, 0, imageSize.width(), imageSize.height());
     context.fillRoundedRect(FloatRoundedRect(rect, radii, radii, radii, radii), backgroundColor);
  
     // Draw the text
-    static const Color topColor(0, 0, 0, 255); // original alpha = 0.75
-    static const Color bottomColor(255, 255, 255, 127); // original alpha = 0.5
+    constexpr auto topColor = makeSimpleColor(0, 0, 0, 255); // original alpha = 0.75
+    constexpr auto bottomColor = makeSimpleColor(255, 255, 255, 127); // original alpha = 0.5
     if (drawURLString) {
         if (clipURLString)
             urlString = StringTruncator::rightTruncate(urlString, imageSize.width() - (DragLabelBorderX * 2.0f), *urlFont);
index f3afd55..4db5a47 100644 (file)
@@ -99,7 +99,7 @@ struct PaintInfo {
     bool forceTextColor() const { return forceBlackText() || forceWhiteText(); }
     bool forceBlackText() const { return paintBehavior.contains(PaintBehavior::ForceBlackText); }
     bool forceWhiteText() const { return paintBehavior.contains(PaintBehavior::ForceWhiteText); }
-    Color forcedTextColor() const { return (forceBlackText()) ? Color::black : Color::white; }
+    Color forcedTextColor() const { return forceBlackText() ? Color::black : Color::white; }
 
     bool skipRootBackground() const { return paintBehavior.contains(PaintBehavior::SkipRootBackground); }
     bool paintRootBackgroundOnly() const { return paintBehavior.contains(PaintBehavior::RootBackgroundOnly); }
index c6a9962..9c115d3 100644 (file)
@@ -74,29 +74,10 @@ static const float replacementArrowLeftMargin = -4;
 static const float replacementArrowPadding = 4;
 static const float replacementArrowCirclePadding = 3;
 
-static const Color& replacementTextRoundedRectPressedColor()
-{
-    static NeverDestroyed<Color> pressed(105, 105, 105, 242);
-    return pressed;
-}
-
-static const Color& replacementTextRoundedRectColor()
-{
-    static NeverDestroyed<Color> standard(125, 125, 125, 242);
-    return standard;
-}
-
-static const Color& replacementTextColor()
-{
-    static NeverDestroyed<Color> standard(240, 240, 240, 255);
-    return standard;
-}
-
-static const Color& unavailablePluginBorderColor()
-{
-    static NeverDestroyed<Color> standard(255, 255, 255, 216);
-    return standard;
-}
+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 unavailablePluginBorderColor = makeSimpleColor(255, 255, 255, 216);
 
 RenderEmbeddedObject::RenderEmbeddedObject(HTMLFrameOwnerElement& element, RenderStyle&& style)
     : RenderWidget(element, WTFMove(style))
@@ -312,7 +293,7 @@ void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint
 
     GraphicsContextStateSaver stateSaver(context);
     context.clip(contentRect);
-    context.setFillColor(m_unavailablePluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor() : replacementTextRoundedRectColor());
+    context.setFillColor(m_unavailablePluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor : replacementTextRoundedRectColor);
     context.fillPath(background);
 
     Path strokePath;
@@ -320,21 +301,21 @@ void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint
     strokeRect.inflate(1);
     strokePath.addRoundedRect(strokeRect, FloatSize(replacementTextRoundedRectRadius + 1, replacementTextRoundedRectRadius + 1));
 
-    context.setStrokeColor(unavailablePluginBorderColor());
+    context.setStrokeColor(unavailablePluginBorderColor);
     context.setStrokeThickness(2);
     context.strokePath(strokePath);
 
     const FontMetrics& fontMetrics = font.fontMetrics();
     float labelX = roundf(replacementTextRect.location().x() + replacementTextRoundedRectLeftTextMargin);
     float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent() + replacementTextRoundedRectTopTextMargin);
-    context.setFillColor(replacementTextColor());
+    context.setFillColor(replacementTextColor);
     context.drawBidiText(font, run, FloatPoint(labelX, labelY));
 
     if (shouldUnavailablePluginMessageBeButton(page(), m_pluginUnavailabilityReason)) {
         arrowRect.inflate(-replacementArrowCirclePadding);
 
         context.beginTransparencyLayer(1.0);
-        context.setFillColor(replacementTextColor());
+        context.setFillColor(replacementTextColor);
         context.fillEllipse(arrowRect);
 
         context.setCompositeOperation(CompositeOperator::Clear);
index 0e4ab8b..a874b7b 100644 (file)
@@ -68,23 +68,9 @@ RenderFrameSet::GridAxis::GridAxis()
 {
 }
 
-static const Color& borderStartEdgeColor()
-{
-    static NeverDestroyed<Color> color(170, 170, 170);
-    return color;
-}
-
-static const Color& borderEndEdgeColor()
-{
-    static NeverDestroyed<Color> color = Color::black;
-    return color;
-}
-
-static const Color& borderFillColor()
-{
-    static NeverDestroyed<Color> color(208, 208, 208);
-    return color;
-}
+constexpr auto borderStartEdgeColor = makeSimpleColor(170, 170, 170);
+constexpr auto borderEndEdgeColor = Color::black;
+constexpr auto borderFillColor = makeSimpleColor(208, 208, 208);
 
 void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect& borderRect)
 {
@@ -95,13 +81,13 @@ void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect
     
     // Fill first.
     GraphicsContext& context = paintInfo.context();
-    context.fillRect(borderRect, frameSetElement().hasBorderColor() ? style().visitedDependentColorWithColorFilter(CSSPropertyBorderLeftColor) : borderFillColor());
+    context.fillRect(borderRect, frameSetElement().hasBorderColor() ? style().visitedDependentColorWithColorFilter(CSSPropertyBorderLeftColor) : borderFillColor);
     
     // Now stroke the edges but only if we have enough room to paint both edges with a little
     // bit of the fill color showing through.
     if (borderRect.width() >= 3) {
-        context.fillRect(IntRect(borderRect.location(), IntSize(1, height())), borderStartEdgeColor());
-        context.fillRect(IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y()), IntSize(1, height())), borderEndEdgeColor());
+        context.fillRect(IntRect(borderRect.location(), IntSize(1, height())), borderStartEdgeColor);
+        context.fillRect(IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y()), IntSize(1, height())), borderEndEdgeColor);
     }
 }
 
@@ -114,13 +100,13 @@ void RenderFrameSet::paintRowBorder(const PaintInfo& paintInfo, const IntRect& b
     
     // Fill first.
     GraphicsContext& context = paintInfo.context();
-    context.fillRect(borderRect, frameSetElement().hasBorderColor() ? style().visitedDependentColorWithColorFilter(CSSPropertyBorderLeftColor) : borderFillColor());
+    context.fillRect(borderRect, frameSetElement().hasBorderColor() ? style().visitedDependentColorWithColorFilter(CSSPropertyBorderLeftColor) : borderFillColor);
 
     // Now stroke the edges but only if we have enough room to paint both edges with a little
     // bit of the fill color showing through.
     if (borderRect.height() >= 3) {
-        context.fillRect(IntRect(borderRect.location(), IntSize(width(), 1)), borderStartEdgeColor());
-        context.fillRect(IntRect(IntPoint(borderRect.x(), borderRect.maxY() - 1), IntSize(width(), 1)), borderEndEdgeColor());
+        context.fillRect(IntRect(borderRect.location(), IntSize(width(), 1)), borderStartEdgeColor);
+        context.fillRect(IntRect(IntPoint(borderRect.x(), borderRect.maxY() - 1), IntSize(width(), 1)), borderEndEdgeColor);
     }
 }
 
index b298fc2..9810ce3 100644 (file)
@@ -2218,7 +2218,7 @@ void RenderLayer::beginTransparencyLayers(GraphicsContext& context, const LayerP
 #endif
 
 #ifdef REVEAL_TRANSPARENCY_LAYERS
-        context.setFillColor(Color(0.0f, 0.0f, 0.5f, 0.2f));
+        context.setFillColor(makeSimpleColorFromFloats(0.0f, 0.0f, 0.5f, 0.2f));
         context.fillRect(pixelSnappedClipRect);
 #endif
     }
index 7bc6c24..d74857a 100644 (file)
@@ -3201,7 +3201,7 @@ void RenderLayerBacking::paintDebugOverlays(const GraphicsLayer* graphicsLayer,
     // The interactive part.
     // Paint rects for touch action.
     if (visibleDebugOverlayRegions & TouchActionRegion) {
-        Color regionColor(0, 0, 255, 50);
+        constexpr auto regionColor = makeSimpleColor(0, 0, 255, 50);
         context.setFillColor(regionColor);
         for (auto rect : eventRegion.region().rects())
             context.fillRect(rect);
@@ -3243,7 +3243,7 @@ void RenderLayerBacking::paintDebugOverlays(const GraphicsLayer* graphicsLayer,
 #if ENABLE(EDITABLE_REGION)
     // Paint rects for editable elements.
     if (visibleDebugOverlayRegions & EditableElementRegion) {
-        context.setFillColor({ 128, 0, 128, 50 });
+        context.setFillColor(makeSimpleColor(128, 0, 128, 50));
         for (auto rect : eventRegion.rectsForEditableElements())
             context.fillRect(rect);
     }
index 9895adb..50e8c80 100644 (file)
@@ -670,7 +670,7 @@ Color RenderTheme::inactiveListBoxSelectionForegroundColor(OptionSet<StyleColor:
 Color RenderTheme::platformActiveSelectionBackgroundColor(OptionSet<StyleColor::Options>) const
 {
     // Use a blue color by default if the platform theme doesn't define anything.
-    return Color(0, 0, 255);
+    return makeSimpleColor(0, 0, 255);
 }
 
 Color RenderTheme::platformActiveSelectionForegroundColor(OptionSet<StyleColor::Options>) const
@@ -683,7 +683,7 @@ Color RenderTheme::platformInactiveSelectionBackgroundColor(OptionSet<StyleColor
 {
     // Use a grey color by default if the platform theme doesn't define anything.
     // This color matches Firefox's inactive color.
-    return Color(176, 176, 176);
+    return makeSimpleColor(176, 176, 176);
 }
 
 Color RenderTheme::platformInactiveSelectionForegroundColor(OptionSet<StyleColor::Options>) const
@@ -1357,7 +1357,7 @@ Color RenderTheme::textSearchHighlightColor(OptionSet<StyleColor::Options> optio
 
 Color RenderTheme::platformTextSearchHighlightColor(OptionSet<StyleColor::Options>) const
 {
-    return Color(255, 255, 0); // Yellow.
+    return Color::yellow;
 }
 
 #if ENABLE(TOUCH_EVENTS)
@@ -1448,7 +1448,7 @@ void RenderTheme::paintSystemPreviewBadge(Image& image, const PaintInfo& paintIn
 
     auto markerRect = FloatRect {rect.x() + rect.width() - 24, rect.y() + 8, 16, 16 };
     auto roundedMarkerRect = FloatRoundedRect { markerRect, FloatRoundedRect::Radii { 8 } };
-    auto color = Color { 255, 0, 0 };
+    auto color = makeSimpleColor(255, 0, 0);
     context.fillRoundedRect(roundedMarkerRect, color);
 }
 #endif
@@ -1459,7 +1459,7 @@ Color RenderTheme::platformTapHighlightColor() const
 {
     // This color is expected to be drawn on a semi-transparent overlay,
     // making it more transparent than its alpha value indicates.
-    return Color(0, 0, 0, 102);
+    return makeSimpleColor(0, 0, 0, 102);
 }
 
 #endif
index b355378..2124d01 100644 (file)
@@ -160,7 +160,7 @@ public:
     virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const;
 
     WEBCORE_EXPORT Color focusRingColor(OptionSet<StyleColor::Options>) const;
-    virtual Color platformFocusRingColor(OptionSet<StyleColor::Options>) const { return Color(0, 0, 0); }
+    virtual Color platformFocusRingColor(OptionSet<StyleColor::Options>) const { return Color::black; }
     static void setCustomFocusRingColor(const Color&);
     static float platformFocusRingWidth() { return 3; }
     static float platformFocusRingOffset(float outlineWidth) { return std::max<float>(outlineWidth - platformFocusRingWidth(), 0); }
index 4eeb05f..35faad2 100644 (file)
@@ -155,7 +155,6 @@ private:
     String extraDefaultStyleSheet() final;
 #endif
 
-    const Color& shadowColor() const;
     FloatRect addRoundedBorderClip(const RenderObject& box, GraphicsContext&, const IntRect&);
 
     Color systemColor(CSSValueID, OptionSet<StyleColor::Options>) const override;
index 4b6d3a2..36fbb62 100644 (file)
@@ -317,12 +317,6 @@ void RenderThemeIOS::setContentSizeCategory(const String& contentSizeCategory)
     _contentSizeCategory() = contentSizeCategory;
 }
 
-const Color& RenderThemeIOS::shadowColor() const
-{
-    static NeverDestroyed<Color> color(0.0f, 0.0f, 0.0f, 0.7f);
-    return color;
-}
-
 FloatRect RenderThemeIOS::addRoundedBorderClip(const RenderObject& box, GraphicsContext& context, const IntRect& rect)
 {
     // To fix inner border bleeding issues <rdar://problem/9812507>, we clip to the outer border and assert that
@@ -387,7 +381,7 @@ bool RenderThemeIOS::paintCheckboxDecorations(const RenderObject& box, const Pai
 
     if (checked || indeterminate) {
         auto border = box.style().getRoundedBorderFor(rect);
-        paintInfo.context().fillRoundedRect(border.pixelSnappedRoundedRectForPainting(box.document().deviceScaleFactor()), Color(0.0f, 0.0f, 0.0f, 0.8f));
+        paintInfo.context().fillRoundedRect(border.pixelSnappedRoundedRectForPainting(box.document().deviceScaleFactor()), makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, 0.8f));
 
         auto clip = addRoundedBorderClip(box, paintInfo.context(), rect);
         auto width = clip.width();
@@ -423,10 +417,10 @@ bool RenderThemeIOS::paintCheckboxDecorations(const RenderObject& box, const Pai
         }
 
         lineWidth = std::max<float>(lineWidth, 1);
-        drawJoinedLines(cgContext, Vector<CGPoint> { WTFMove(shadow) }, kCGLineCapSquare, lineWidth, Color { 0.0f, 0.0f, 0.0f, 0.7f });
+        drawJoinedLines(cgContext, Vector<CGPoint> { WTFMove(shadow) }, kCGLineCapSquare, lineWidth, makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, 0.7f));
 
         lineWidth = std::max<float>(std::min(width, height) * thicknessRatio, 1);
-        drawJoinedLines(cgContext, Vector<CGPoint> { WTFMove(line) }, kCGLineCapButt, lineWidth, Color { 1.0f, 1.0f, 1.0f, 240 / 255.0f });
+        drawJoinedLines(cgContext, Vector<CGPoint> { WTFMove(line) }, kCGLineCapButt, lineWidth, makeSimpleColorFromFloats(1.0f, 1.0f, 1.0f, 240 / 255.0f));
     } else {
         auto clip = addRoundedBorderClip(box, paintInfo.context(), rect);
         auto width = clip.width();
@@ -484,7 +478,7 @@ bool RenderThemeIOS::paintRadioDecorations(const RenderObject& box, const PaintI
 
     if (isChecked(box)) {
         auto border = box.style().getRoundedBorderFor(rect);
-        paintInfo.context().fillRoundedRect(border.pixelSnappedRoundedRectForPainting(box.document().deviceScaleFactor()), Color(0.0f, 0.0f, 0.0f, 0.8f));
+        paintInfo.context().fillRoundedRect(border.pixelSnappedRoundedRectForPainting(box.document().deviceScaleFactor()), makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, 0.8f));
 
         auto clip = addRoundedBorderClip(box, paintInfo.context(), rect);
         drawAxialGradient(cgContext, gradientWithName(ConcaveGradient), clip.location(), FloatPoint(clip.x(), clip.maxY()), LinearInterpolation);
@@ -496,8 +490,9 @@ bool RenderThemeIOS::paintRadioDecorations(const RenderObject& box, const PaintI
 
         clip.inflateX(-clip.width() * InnerInverseRatio);
         clip.inflateY(-clip.height() * InnerInverseRatio);
-
-        paintInfo.context().drawRaisedEllipse(clip, Color::white, shadowColor());
+        
+        constexpr auto shadowColor = makeSimpleColor(0, 0, 0, 0.7f * 255);
+        paintInfo.context().drawRaisedEllipse(clip, Color::white, shadowColor);
 
         FloatSize radius(clip.width() / 2.0f, clip.height() / 2.0f);
         paintInfo.context().clipRoundedRect(FloatRoundedRect(clip, radius, radius, radius, radius));
@@ -731,7 +726,7 @@ bool RenderThemeIOS::paintMenuListButtonDecorations(const RenderBox& box, const
         FloatRect ellipse(buttonClip.x() + (buttonClip.width() - count * (size + padding) + padding) / 2.0, buttonClip.maxY() - 10.0, size, size);
 
         for (int i = 0; i < count; ++i) {
-            paintInfo.context().drawRaisedEllipse(ellipse, Color::white, Color(0.0f, 0.0f, 0.0f, 0.5f));
+            paintInfo.context().drawRaisedEllipse(ellipse, Color::white, makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, 0.5f));
             ellipse.move(size + padding, 0);
         }
     }  else {
@@ -751,8 +746,8 @@ bool RenderThemeIOS::paintMenuListButtonDecorations(const RenderBox& box, const
         };
 
         float opacity = isReadOnlyControl(box) ? 0.2 : 0.5;
-        paintInfo.context().setStrokeColor(Color(0.0f, 0.0f, 0.0f, opacity));
-        paintInfo.context().setFillColor(Color(0.0f, 0.0f, 0.0f, opacity));
+        paintInfo.context().setStrokeColor(makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, opacity));
+        paintInfo.context().setFillColor(makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, opacity));
         paintInfo.context().drawPath(Path::polygonPathFromPoints(shadow));
 
         paintInfo.context().setStrokeColor(Color::white);
@@ -840,9 +835,9 @@ bool RenderThemeIOS::paintSliderTrack(const RenderObject& box, const PaintInfo&
 
         CGContextRef cgContext = paintInfo.context().platformContext();
         if (readonly)
-            paintInfo.context().setStrokeColor(Color(178, 178, 178));
+            paintInfo.context().setStrokeColor(makeSimpleColor(178, 178, 178));
         else
-            paintInfo.context().setStrokeColor(Color(76, 76, 76));
+            paintInfo.context().setStrokeColor(makeSimpleColor(76, 76, 76));
 
         RetainPtr<CGMutablePathRef> roundedRectPath = adoptCF(CGPathCreateMutable());
         CGPathAddRoundedRect(roundedRectPath.get(), 0, trackClip, cornerWidth, cornerHeight);
@@ -919,13 +914,13 @@ bool RenderThemeIOS::paintProgressBar(const RenderObject& renderer, const PaintI
 
     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, Color(0x8d, 0x8d, 0x8d));
-    strokeGradient->addColorStop(0.45, Color(0xee, 0xee, 0xee));
-    strokeGradient->addColorStop(0.55, Color(0xee, 0xee, 0xee));
-    strokeGradient->addColorStop(1.0, Color(0x8d, 0x8d, 0x8d));
+    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));
     context.setStrokeGradient(WTFMove(strokeGradient));
 
-    context.setFillColor(Color(255, 255, 255));
+    context.setFillColor(Color::black);
 
     Path trackPath;
     FloatRect trackRect(rect.x() + 0.25, verticalRenderingPosition + 0.25, rect.width() - 0.5, progressBarHeight - 0.5);
@@ -939,8 +934,8 @@ bool RenderThemeIOS::paintProgressBar(const RenderObject& renderer, const PaintI
 
     float upperGradientHeight = progressBarHeight / 2.;
     auto upperGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition + 0.5), FloatPoint(rect.x(), verticalRenderingPosition + upperGradientHeight - 1.5) });
-    upperGradient->addColorStop(0.0, Color(133, 133, 133, 188));
-    upperGradient->addColorStop(1.0, Color(18, 18, 18, 51));
+    upperGradient->addColorStop(0.0, makeSimpleColor(133, 133, 133, 188));
+    upperGradient->addColorStop(1.0, makeSimpleColor(18, 18, 18, 51));
     context.setFillGradient(WTFMove(upperGradient));
 
     context.fillRect(FloatRect(rect.x(), verticalRenderingPosition, rect.width(), upperGradientHeight));
@@ -951,18 +946,18 @@ bool RenderThemeIOS::paintProgressBar(const RenderObject& renderer, const PaintI
         double position = clampTo(renderProgress.position(), 0.0, 1.0);
         double barWidth = position * rect.width();
         auto barGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition + 0.5), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) });
-        barGradient->addColorStop(0.0, Color(195, 217, 247));
-        barGradient->addColorStop(0.45, Color(118, 164, 228));
-        barGradient->addColorStop(0.49, Color(118, 164, 228));
-        barGradient->addColorStop(0.51, Color(36, 114, 210));
-        barGradient->addColorStop(0.55, Color(36, 114, 210));
-        barGradient->addColorStop(1.0, Color(57, 142, 244));
+        barGradient->addColorStop(0.0, makeSimpleColor(195, 217, 247));
+        barGradient->addColorStop(0.45, makeSimpleColor(118, 164, 228));
+        barGradient->addColorStop(0.49, makeSimpleColor(118, 164, 228));
+        barGradient->addColorStop(0.51, makeSimpleColor(36, 114, 210));
+        barGradient->addColorStop(0.55, makeSimpleColor(36, 114, 210));
+        barGradient->addColorStop(1.0, makeSimpleColor(57, 142, 244));
         context.setFillGradient(WTFMove(barGradient));
 
         auto barStrokeGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) });
-        barStrokeGradient->addColorStop(0.0, Color(95, 107, 183));
-        barStrokeGradient->addColorStop(0.5, Color(66, 106, 174, 240));
-        barStrokeGradient->addColorStop(1.0, Color(38, 104, 166));
+        barStrokeGradient->addColorStop(0.0, makeSimpleColor(95, 107, 183));
+        barStrokeGradient->addColorStop(0.5, makeSimpleColor(66, 106, 174, 240));
+        barStrokeGradient->addColorStop(1.0, makeSimpleColor(38, 104, 166));
         context.setStrokeGradient(WTFMove(barStrokeGradient));
 
         Path barPath;
@@ -1568,10 +1563,10 @@ Color RenderThemeIOS::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O
 const CGSize attachmentSize = { 160, 119 };
 
 const CGFloat attachmentBorderRadius = 16;
-static Color attachmentBorderColor() { return Color(204, 204, 204); }
+constexpr SimpleColor attachmentBorderColor = makeSimpleColor(204, 204, 204);
 static CGFloat attachmentBorderThickness = 1;
 
-static Color attachmentProgressColor() { return Color(222, 222, 222); }
+constexpr SimpleColor attachmentProgressColor = makeSimpleColor(222, 222, 222);
 const CGFloat attachmentProgressBorderThickness = 3;
 
 const CGFloat attachmentProgressSize = 36;
@@ -1870,8 +1865,8 @@ static void paintAttachmentProgress(GraphicsContext& context, RenderAttachmentIn
     GraphicsContextStateSaver saver(context);
 
     context.setStrokeThickness(attachmentProgressBorderThickness);
-    context.setStrokeColor(attachmentProgressColor());
-    context.setFillColor(attachmentProgressColor());
+    context.setStrokeColor(attachmentProgressColor);
+    context.setFillColor(attachmentProgressColor);
     context.strokeEllipse(info.progressRect);
 
     FloatPoint center = info.progressRect.center();
@@ -1896,7 +1891,7 @@ static Path attachmentBorderPath(RenderAttachmentInfo& info)
 
 static void paintAttachmentBorder(GraphicsContext& context, Path& borderPath)
 {
-    context.setStrokeColor(attachmentBorderColor());
+    context.setStrokeColor(attachmentBorderColor);
     context.setStrokeThickness(attachmentBorderThickness);
     context.strokePath(borderPath);
 }
@@ -2024,7 +2019,7 @@ void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& pain
     // Draw a drop shadow around the circle.
     // Use the GraphicsContext function, because it calculates the blur radius in context space,
     // rather than screen space.
-    Color shadowColor = Color { 0.f, 0.f, 0.f, 0.1f };
+    auto shadowColor = makeSimpleColorFromFloats(0.f, 0.f, 0.f, 0.1f);
     graphicsContext.setShadow(FloatSize { }, 16, shadowColor);
 
     // The circle must have an alpha channel value of 1 for the shadow color to appear.
index 2b05b0a..5df6dc8 100644 (file)
@@ -1649,8 +1649,8 @@ bool RenderThemeMac::paintMenuListButtonDecorations(const RenderBox& renderer, c
     };
     paintInfo.context().fillPath(Path::polygonPathFromPoints(arrow2));
 
-    Color leftSeparatorColor(0, 0, 0, 40);
-    Color rightSeparatorColor(255, 255, 255, 40);
+    constexpr auto leftSeparatorColor = makeSimpleColor(0, 0, 0, 40);
+    constexpr auto rightSeparatorColor = makeSimpleColor(255, 255, 255, 40);
 
     // FIXME: Should the separator thickness and space be scaled up by fontScale?
     int separatorSpace = 2; // Deliberately ignores zoom since it looks nicer if it stays thin.
@@ -2472,8 +2472,8 @@ const CGFloat attachmentIconSelectionBorderThickness = 1;
 const CGFloat attachmentIconBackgroundRadius = 3;
 const CGFloat attachmentIconToTitleMargin = 2;
 
-static Color attachmentIconBackgroundColor() { return Color(0, 0, 0, 30); }
-static Color attachmentIconBorderColor() { return Color(255, 255, 255, 125); }
+constexpr SimpleColor attachmentIconBackgroundColor = makeSimpleColor(0, 0, 0, 30);
+constexpr SimpleColor attachmentIconBorderColor = makeSimpleColor(255, 255, 255, 125);
 
 const CGFloat attachmentTitleFontSize = 12;
 const CGFloat attachmentTitleBackgroundRadius = 3;
@@ -2481,23 +2481,23 @@ const CGFloat attachmentTitleBackgroundPadding = 3;
 const CGFloat attachmentTitleMaximumWidth = 100 - (attachmentTitleBackgroundPadding * 2);
 const CFIndex attachmentTitleMaximumLineCount = 2;
 
-static Color attachmentTitleInactiveBackgroundColor() { return Color(204, 204, 204, 255); }
-static Color attachmentTitleInactiveTextColor() { return Color(100, 100, 100, 255); }
+constexpr SimpleColor attachmentTitleInactiveBackgroundColor = makeSimpleColor(204, 204, 204, 255);
+constexpr SimpleColor attachmentTitleInactiveTextColor = makeSimpleColor(100, 100, 100, 255);
 
 const CGFloat attachmentSubtitleFontSize = 10;
 const int attachmentSubtitleWidthIncrement = 10;
-static Color attachmentSubtitleTextColor() { return Color(82, 145, 214, 255); }
+constexpr SimpleColor attachmentSubtitleTextColor = makeSimpleColor(82, 145, 214, 255);
 
 const CGFloat attachmentProgressBarWidth = 30;
 const CGFloat attachmentProgressBarHeight = 5;
 const CGFloat attachmentProgressBarOffset = -9;
 const CGFloat attachmentProgressBarBorderWidth = 1;
-static Color attachmentProgressBarBackgroundColor() { return Color(0, 0, 0, 89); }
-static Color attachmentProgressBarFillColor() { return Color(Color::white); }
-static Color attachmentProgressBarBorderColor() { return Color(0, 0, 0, 128); }
+constexpr SimpleColor attachmentProgressBarBackgroundColor = makeSimpleColor(0, 0, 0, 89);
+constexpr SimpleColor attachmentProgressBarFillColor = Color::white;
+constexpr SimpleColor attachmentProgressBarBorderColor = makeSimpleColor(0, 0, 0, 128);
 
 const CGFloat attachmentPlaceholderBorderRadius = 5;
-static Color attachmentPlaceholderBorderColor() { return Color(0, 0, 0, 56); }
+constexpr SimpleColor attachmentPlaceholderBorderColor = makeSimpleColor(0, 0, 0, 56);
 const CGFloat attachmentPlaceholderBorderWidth = 2;
 const CGFloat attachmentPlaceholderBorderDashLength = 6;
 
@@ -2541,7 +2541,7 @@ static Color titleTextColorForAttachment(const RenderAttachment& attachment, Att
         if (attachment.frame().selection().isFocusedAndActive())
             result = colorFromNSColor([NSColor alternateSelectedControlTextColor]);
         else
-            result = attachmentTitleInactiveTextColor();
+            result = attachmentTitleInactiveTextColor;
     }
 
     return attachment.style().colorByApplyingColorFilter(result);
@@ -2647,7 +2647,7 @@ void AttachmentLayout::layOutSubtitle(const RenderAttachment& attachment)
     if (subtitleText.isEmpty())
         return;
 
-    Color subtitleColor = attachment.style().colorByApplyingColorFilter(attachmentSubtitleTextColor());
+    Color subtitleColor = attachment.style().colorByApplyingColorFilter(attachmentSubtitleTextColor);
     CFStringRef language = 0; // By not specifying a language we use the system language.
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, attachmentSubtitleFontSize, language));
     NSDictionary *textAttributes = @{
@@ -2721,7 +2721,7 @@ static void paintAttachmentIconBackground(const RenderAttachment& attachment, Gr
     if (paintBorder)
         backgroundRect.inflate(-attachmentIconSelectionBorderThickness);
 
-    Color backgroundColor = attachment.style().colorByApplyingColorFilter(attachmentIconBackgroundColor());
+    Color backgroundColor = attachment.style().colorByApplyingColorFilter(attachmentIconBackgroundColor);
     context.fillRoundedRect(FloatRoundedRect(backgroundRect, FloatRoundedRect::Radii(attachmentIconBackgroundRadius)), backgroundColor);
 
     if (paintBorder) {
@@ -2732,7 +2732,7 @@ static void paintAttachmentIconBackground(const RenderAttachment& attachment, Gr
         Path borderPath;
         borderPath.addRoundedRect(borderRect, iconBackgroundRadiusSize);
 
-        Color borderColor = attachment.style().colorByApplyingColorFilter(attachmentIconBorderColor());
+        Color borderColor = attachment.style().colorByApplyingColorFilter(attachmentIconBorderColor);
         context.setStrokeColor(borderColor);
         context.setStrokeThickness(attachmentIconSelectionBorderThickness);
         context.strokePath(borderPath);
@@ -2830,7 +2830,7 @@ static void paintAttachmentTitleBackground(const RenderAttachment& attachment, G
         backgroundColor = colorFromNSColor([NSColor alternateSelectedControlColor]);
         ALLOW_DEPRECATED_DECLARATIONS_END
     } else
-        backgroundColor = attachmentTitleInactiveBackgroundColor();
+        backgroundColor = attachmentTitleInactiveBackgroundColor;
 
     backgroundColor = attachment.style().colorByApplyingColorFilter(backgroundColor);
     context.setFillColor(backgroundColor);
@@ -2875,7 +2875,7 @@ static void paintAttachmentProgress(const RenderAttachment& attachment, Graphics
     backgroundRect.inflate(-attachmentProgressBarBorderWidth / 2);
 
     FloatRoundedRect backgroundRoundedRect(backgroundRect, FloatRoundedRect::Radii(backgroundRect.height() / 2));
-    context.fillRoundedRect(backgroundRoundedRect, attachmentProgressBarBackgroundColor());
+    context.fillRoundedRect(backgroundRoundedRect, attachmentProgressBarBackgroundColor);
 
     {
         GraphicsContextStateSaver clipSaver(context);
@@ -2885,13 +2885,13 @@ static void paintAttachmentProgress(const RenderAttachment& attachment, Graphics
         progressRect.setWidth(progressRect.width() * progress);
         progressRect = encloseRectToDevicePixels(progressRect, attachment.document().deviceScaleFactor());
 
-        context.fillRect(progressRect, attachmentProgressBarFillColor());
+        context.fillRect(progressRect, attachmentProgressBarFillColor);
     }
 
     Path borderPath;
     float borderRadius = borderRect.height() / 2;
     borderPath.addRoundedRect(borderRect, FloatSize(borderRadius, borderRadius));
-    context.setStrokeColor(attachmentProgressBarBorderColor());
+    context.setStrokeColor(attachmentProgressBarBorderColor);
     context.setStrokeThickness(attachmentProgressBarBorderWidth);
     context.strokePath(borderPath);
 }
@@ -2901,7 +2901,7 @@ static void paintAttachmentPlaceholderBorder(const RenderAttachment& attachment,
     Path borderPath;
     borderPath.addRoundedRect(layout.attachmentRect, FloatSize(attachmentPlaceholderBorderRadius, attachmentPlaceholderBorderRadius));
 
-    Color placeholderBorderColor = attachment.style().colorByApplyingColorFilter(attachmentPlaceholderBorderColor());
+    Color placeholderBorderColor = attachment.style().colorByApplyingColorFilter(attachmentPlaceholderBorderColor);
     context.setStrokeColor(placeholderBorderColor);
     context.setStrokeThickness(attachmentPlaceholderBorderWidth);
     context.setStrokeStyle(DashedStroke);
index d77f7fa..5a55713 100644 (file)
@@ -288,19 +288,19 @@ bool RenderThemeWin::supportsHover(const RenderStyle&) const
 Color RenderThemeWin::platformActiveSelectionBackgroundColor(OptionSet<StyleColor::Options>) const
 {
     COLORREF color = GetSysColor(COLOR_HIGHLIGHT);
-    return Color(GetRValue(color), GetGValue(color), GetBValue(color));
+    return makeSimpleColor(GetRValue(color), GetGValue(color), GetBValue(color));
 }
 
 Color RenderThemeWin::platformInactiveSelectionBackgroundColor(OptionSet<StyleColor::Options>) const
 {
     // This color matches Firefox.
-    return Color(176, 176, 176);
+    return makeSimpleColor(176, 176, 176);
 }
 
 Color RenderThemeWin::platformActiveSelectionForegroundColor(OptionSet<StyleColor::Options>) const
 {
     COLORREF color = GetSysColor(COLOR_HIGHLIGHTTEXT);
-    return Color(GetRValue(color), GetGValue(color), GetBValue(color));
+    return makeSimpleColor(GetRValue(color), GetGValue(color), GetBValue(color));
 }
 
 Color RenderThemeWin::platformInactiveSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
@@ -1009,7 +1009,7 @@ Color RenderThemeWin::systemColor(CSSValueID cssValueId, OptionSet<StyleColor::O
         return RenderTheme::systemColor(cssValueId, options);
 
     COLORREF color = GetSysColor(sysColorIndex);
-    return Color(GetRValue(color), GetGValue(color), GetBValue(color));
+    return makeSimpleColor(GetRValue(color), GetGValue(color), GetBValue(color));
 }
 
 #if ENABLE(VIDEO)
index 775128d..c1bb356 100644 (file)
@@ -102,7 +102,7 @@ void paintFlow(const RenderBlockFlow& flow, const Layout& layout, PaintInfo& pai
 
     std::unique_ptr<ShadowData> debugShadow = nullptr;
     if (flow.settings().simpleLineLayoutDebugBordersEnabled()) {
-        debugShadow = makeUnique<ShadowData>(IntPoint(0, 0), 10, 20, ShadowStyle::Normal, true, Color(0, 255, 0, 200));
+        debugShadow = makeUnique<ShadowData>(IntPoint(0, 0), 10, 20, ShadowStyle::Normal, true, makeSimpleColor(0, 255, 0, 200));
         textPainter.setShadow(debugShadow.get());
     }
 
index b44d018..c5e1efd 100644 (file)
@@ -119,7 +119,7 @@ void RenderMathMLBlock::paint(PaintInfo& info, const LayoutPoint& paintOffset)
 
     info.context().setStrokeThickness(1.0f);
     info.context().setStrokeStyle(SolidStroke);
-    info.context().setStrokeColor(Color(0, 0, 255));
+    info.context().setStrokeColor(makeSimpleColor(0, 0, 255));
 
     info.context().drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()));
     info.context().drawLine(IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y()), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + pixelSnappedOffsetHeight()));
@@ -128,13 +128,13 @@ void RenderMathMLBlock::paint(PaintInfo& info, const LayoutPoint& paintOffset)
 
     int topStart = paddingTop();
 
-    info.context().setStrokeColor(Color(0, 255, 0));
+    info.context().setStrokeColor(makeSimpleColor(0, 255, 0));
 
     info.context().drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + topStart), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + topStart));
 
     int baseline = roundToInt(baselinePosition(AlphabeticBaseline, true, HorizontalLine));
 
-    info.context().setStrokeColor(Color(255, 0, 0));
+    info.context().setStrokeColor(makeSimpleColor(255, 0, 0));
 
     info.context().drawLine(IntPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + baseline), IntPoint(adjustedPaintOffset.x() + pixelSnappedOffsetWidth(), adjustedPaintOffset.y() + baseline));
 }
index 6c6c8d2..7b210e8 100644 (file)
@@ -2026,7 +2026,7 @@ Color RenderStyle::colorResolvingCurrentColor(CSSPropertyID colorProperty, bool
     if (isCurrentColor(result)) {
         auto borderStyle = computeBorderStyle();
         if (!visitedLink && (borderStyle == BorderStyle::Inset || borderStyle == BorderStyle::Outset || borderStyle == BorderStyle::Ridge || borderStyle == BorderStyle::Groove))
-            return Color(238, 238, 238);
+            return makeSimpleColor(238, 238, 238);
 
         return visitedLink ? visitedLinkColor() : color();
     }
index d6dd4e1..1b7592f 100644 (file)
@@ -1319,7 +1319,7 @@ public:
     const Color& visitedLinkStrokeColor() const { return m_rareInheritedData->visitedLinkStrokeColor; }
     void setHasExplicitlySetStrokeColor(bool v) { SET_VAR(m_rareInheritedData, hasSetStrokeColor, static_cast<unsigned>(v)); }
     bool hasExplicitlySetStrokeColor() const { return m_rareInheritedData->hasSetStrokeColor; };
-    static Color initialStrokeColor() { return Color(Color::transparent); }
+    static Color initialStrokeColor() { return Color::transparent; }
     Color computedStrokeColor() const;
 
     float strokeMiterLimit() const { return m_rareInheritedData->miterLimit; }
index 8645024..79f04c9 100644 (file)
@@ -73,10 +73,10 @@ public:
     static String initialStrokePaintUri() { return String(); }
     static Vector<SVGLengthValue> initialStrokeDashArray() { return { }; }
     static float initialStopOpacity() { return 1; }
-    static Color initialStopColor() { return Color(0, 0, 0); }
+    static Color initialStopColor() { return makeSimpleColor(0, 0, 0); }
     static float initialFloodOpacity() { return 1; }
-    static Color initialFloodColor() { return Color(0, 0, 0); }
-    static Color initialLightingColor() { return Color(255, 255, 255); }
+    static Color initialFloodColor() { return makeSimpleColor(0, 0, 0); }
+    static Color initialLightingColor() { return makeSimpleColor(255, 255, 255); }
     static ShadowData* initialShadow() { return nullptr; }
     static String initialMaskerResource() { return String(); }
     static String initialMarkerStartResource() { return String(); }
index b575b76..ee8836f 100644 (file)
@@ -88,7 +88,7 @@ bool SVGStopElement::rendererIsNeeded(const RenderStyle&)
 Color SVGStopElement::stopColorIncludingOpacity() const
 {
     if (!renderer())
-        return Color(Color::transparent, true);
+        return Color::transparent;
 
     auto& style = renderer()->style();
     auto& svgStyle = style.svgStyle();
index 3dd26a0..f9ba1b6 100644 (file)
@@ -91,7 +91,7 @@ public:
         float blue = Base::animate(progress, repeatCount, simpleFrom.blueComponent(), simpleTo.blueComponent(), simpleToAtEndOfDuration.blueComponent(), simpleAnimated.blueComponent());
         float alpha = Base::animate(progress, repeatCount, simpleFrom.alphaComponent(), simpleTo.alphaComponent(), simpleToAtEndOfDuration.alphaComponent(), simpleAnimated.alphaComponent());
         
-        animated = { roundAndClampColorChannel(red), roundAndClampColorChannel(green), roundAndClampColorChannel(blue), roundAndClampColorChannel(alpha) };
+        animated = makeSimpleColor(roundAndClampColorChannel(red), roundAndClampColorChannel(green), roundAndClampColorChannel(blue), roundAndClampColorChannel(alpha));
     }
 
     Optional<float> calculateDistance(SVGElement*, const String& from, const String& to) const override
@@ -120,11 +120,11 @@ private:
         auto simpleTo = m_to.toSRGBASimpleColorLossy();
 
         // Ignores any alpha and sets alpha on result to 100% opaque.
-        m_to = {
+        m_to = makeSimpleColor(
             roundAndClampColorChannel(simpleTo.redComponent() + simpleFrom.redComponent()),
             roundAndClampColorChannel(simpleTo.greenComponent() + simpleFrom.greenComponent()),
             roundAndClampColorChannel(simpleTo.blueComponent() + simpleFrom.blueComponent())
-        };
+        );
     }
 
     static Color colorFromString(SVGElement*, const String&);
index e5a6cfe..d4ea6df 100644 (file)
@@ -105,10 +105,10 @@ void MockPageOverlayClient::drawRect(PageOverlay& overlay, GraphicsContext& cont
     FloatRect insetRect = overlay.bounds();
 
     if (overlay.overlayType() == PageOverlay::OverlayType::Document) {
-        context.setStrokeColor(Color(0, 255, 0));
+        context.setStrokeColor(makeSimpleColor(0, 255, 0));
         insetRect.inflate(-50);
     } else {
-        context.setStrokeColor(Color(0, 0, 255));
+        context.setStrokeColor(makeSimpleColor(0, 0, 255));
         insetRect.inflate(-20);
     }
 
index 47eb6f2..3621ca2 100644 (file)
@@ -91,7 +91,7 @@ const void* const webViewVisualIdentificationOverlayKey = &webViewVisualIdentifi
     _layer = adoptNS([[CATiledLayer alloc] init]);
     [_layer setName:@"WebViewVisualIdentificationOverlay"];
     [_layer setFrame:CGRectMake(0, 0, [_view bounds].size.width, [_view bounds].size.height)];
-    WebCore::Color viewColor = isDeprecated ? WebCore::Color(255, 0, 0, 32) : WebCore::Color(0, 0, 255, 32);
+    WebCore::Color viewColor = isDeprecated ? WebCore::makeSimpleColor(255, 0, 0, 32) : WebCore::makeSimpleColor(0, 0, 255, 32);
     [_layer setBackgroundColor:cachedCGColor(viewColor)];
     [_layer setZPosition:999];
     [_layer setDelegate:self];
index 3039793..d239550 100644 (file)
@@ -1,3 +1,30 @@
+2020-06-01  Sam Weinig  <weinig@apple.com>
+
+        Extended Color: Replace Color constructors taking numeric values with type specific factory functions
+        https://bugs.webkit.org/show_bug.cgi?id=212576
+
+        Reviewed by Tim Horton.
+
+        Replaces all remaining implicit and explicit uses of the Color constructors taking numeric
+        values with explicit calls to makeSimpleColor/makeSimpleColorFromFloats/makeExtendedColor,
+        giving us a consistent way to create colors. Also addes use constexpr SimpleColors where possible.
+
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::drawInContext):
+        * UIProcess/API/wpe/WebKitColor.cpp:
+        (webkitColorToWebCoreColor):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _tapHighlightColorForFastClick:]):
+        * WebProcess/Inspector/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::showPaintRect):
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::drawRect):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::paintSnapshotAtSize):
+        * WebProcess/WebPage/ios/FindControllerIOS.mm:
+        (WebKit::FindIndicatorOverlayClientIOS::drawRect):
+        (WebKit::highlightColor): Deleted.
+
 2020-06-01  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK4] Add printing support
index c28c9f4..1a9cf38 100644 (file)
@@ -319,7 +319,7 @@ void RemoteLayerBackingStore::drawInContext(WebCore::GraphicsContext& context, C
 
 #ifndef NDEBUG
     if (m_isOpaque)
-        context.fillRect(scaledLayerBounds, WebCore::Color(255, 47, 146));
+        context.fillRect(scaledLayerBounds, WebCore::makeSimpleColor(255, 47, 146));
 #endif
 
     context.scale(m_scale);
index 2a34735..9297ad4 100644 (file)
@@ -75,7 +75,7 @@ G_DEFINE_BOXED_TYPE(WebKitColor, webkit_color, webkit_color_copy, webkit_color_f
 
 const WebCore::Color webkitColorToWebCoreColor(WebKitColor* color)
 {
-    return WebCore::Color(static_cast<float>(color->red), static_cast<float>(color->green),
+    return WebCore::makeSimpleColorFromFloats(static_cast<float>(color->red), static_cast<float>(color->green),
         static_cast<float>(color->blue), static_cast<float>(color->alpha));
 }
 
index a344cf5..c4deccb 100644 (file)
@@ -4328,7 +4328,7 @@ static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoi
 - (WebCore::Color)_tapHighlightColorForFastClick:(BOOL)forFastClick
 {
     ASSERT(_showDebugTapHighlightsForFastClicking);
-    return forFastClick ? WebCore::Color(0, 225, 0, 127) : WebCore::Color(225, 0, 0, 127);
+    return forFastClick ? WebCore::makeSimpleColor(0, 225, 0, 127) : WebCore::makeSimpleColor(225, 0, 0, 127);
 }
 
 - (void)_setDoubleTapGesturesEnabled:(BOOL)enabled
index dcc473d..c4fe42b 100644 (file)
@@ -177,7 +177,7 @@ void WebInspectorClient::showPaintRect(const FloatRect& rect)
     paintLayer->setAnchorPoint(FloatPoint3D());
     paintLayer->setPosition(rect.location());
     paintLayer->setSize(rect.size());
-    paintLayer->setBackgroundColor(Color(1.0f, 0.0f, 0.0f, 0.2f));
+    paintLayer->setBackgroundColor(makeSimpleColorFromFloats(1.0f, 0.0f, 0.0f, 0.2f));
 
     KeyframeValueList fadeKeyframes(AnimatedPropertyOpacity);
     fadeKeyframes.insert(makeUnique<FloatAnimationValue>(0, 1));
index 6de5090..b533ae8 100644 (file)
@@ -509,8 +509,8 @@ void FindController::drawRect(PageOverlay&, GraphicsContext& graphicsContext, co
 {
     const int borderWidth = 1;
 
-    Color overlayBackgroundColor(0.1f, 0.1f, 0.1f, 0.25f);
-    Color shadowColor(0.0f, 0.0f, 0.0f, 0.5f);
+    auto overlayBackgroundColor = makeSimpleColorFromFloats(0.1f, 0.1f, 0.1f, 0.25f);
+    auto shadowColor = makeSimpleColorFromFloats(0.0f, 0.0f, 0.0f, 0.5f);
 
     IntRect borderInflatedDirtyRect = dirtyRect;
     borderInflatedDirtyRect.inflate(borderWidth);
index c78977a..0af6311 100644 (file)
@@ -2402,7 +2402,7 @@ void WebPage::paintSnapshotAtSize(const IntRect& rect, const IntSize& bitmapSize
 
     if (options & SnapshotOptionsPaintSelectionRectangle) {
         FloatRect selectionRectangle = frame.selection().selectionBounds();
-        graphicsContext.setStrokeColor(Color(0xFF, 0, 0));
+        graphicsContext.setStrokeColor(makeSimpleColor(0xFF, 0, 0));
         graphicsContext.strokeRect(selectionRectangle, 1);
     }
 }
index 41b4214..b63a624 100644 (file)
@@ -53,10 +53,7 @@ const int totalVerticalMargin = 1;
 
 constexpr OptionSet<TextIndicatorOption> findTextIndicatorOptions { TextIndicatorOption::IncludeMarginIfRangeMatchesSelection, TextIndicatorOption::DoNotClipToVisibleRect };
 
-static Color highlightColor()
-{
-    return Color(255, 228, 56, 255);
-}
+constexpr auto highlightColor = makeSimpleColor(255, 228, 56, 255);
 
 void FindIndicatorOverlayClientIOS::drawRect(PageOverlay& overlay, GraphicsContext& context, const IntRect& dirtyRect)
 {
@@ -79,7 +76,7 @@ void FindIndicatorOverlayClientIOS::drawRect(PageOverlay& overlay, GraphicsConte
     Vector<FloatRect> textRectsInBoundingRectCoordinates = m_textIndicator->textRectsInBoundingRectCoordinates();
     Vector<Path> paths = PathUtilities::pathsWithShrinkWrappedRects(textRectsInBoundingRectCoordinates, cornerRadius);
 
-    context.setFillColor(highlightColor());
+    context.setFillColor(highlightColor);
     for (const auto& path : paths)
         context.fillPath(path);
 
index 5c2094a..10a354e 100644 (file)
@@ -1,3 +1,16 @@
+2020-06-01  Sam Weinig  <weinig@apple.com>
+
+        Extended Color: Replace Color constructors taking numeric values with type specific factory functions
+        https://bugs.webkit.org/show_bug.cgi?id=212576
+
+        Reviewed by Tim Horton.
+
+        Replaces all remaining implicit and explicit uses of the Color constructors taking numeric
+        values with explicit calls to makeSimpleColor/makeSimpleColorFromFloats/makeExtendedColor,
+        giving us a consistent way to create colors. Also addes use constexpr SimpleColors where possible.
+
+        * WebView/WebIndicateLayer.mm:
+
 2020-05-29  Andy Estes  <aestes@apple.com>
 
         [Apple Pay] Remove conditionals for ENABLE_APPLE_PAY_SESSION_V(3|4)
index e6cc599..dac29d4 100644 (file)
@@ -50,7 +50,7 @@ using namespace WebCore;
     self.contentsScale = [[_webView window] screenScale];
 
     // Blue highlight color.
-    static NeverDestroyed<Color> highlightColor(111.0f / 255.0f, 168.0f / 255.0f, 220.0f / 255.0f, 0.66f);
+    constexpr auto highlightColor = makeSimpleColor(111, 168, 220, 168);
     self.backgroundColor = cachedCGColor(highlightColor);
 
     return self;
index cb2675c..ca22122 100644 (file)
@@ -1,3 +1,17 @@
+2020-06-01  Sam Weinig  <weinig@apple.com>
+
+        Extended Color: Replace Color constructors taking numeric values with type specific factory functions
+        https://bugs.webkit.org/show_bug.cgi?id=212576
+
+        Reviewed by Tim Horton.
+
+        Replaces all remaining implicit and explicit uses of the Color constructors taking numeric
+        values with explicit calls to makeSimpleColor/makeSimpleColorFromFloats/makeExtendedColor,
+        giving us a consistent way to create colors. Also addes use constexpr SimpleColors where possible.
+
+        * WebView.cpp:
+        (compositionToUnderlines):
+
 2020-06-01  Rob Buis  <rbuis@igalia.com>
 
         Rename ResourceResponseBase::isHTTP to isInHTTPFamily
index fe7cb6a..3bdee6b 100644 (file)
@@ -6274,7 +6274,7 @@ static void compositionToUnderlines(const Vector<DWORD>& clauses, const Vector<B
         underlines[i].endOffset = clauses[i + 1];
         BYTE attribute = attributes[clauses[i]];
         underlines[i].thick = attribute == ATTR_TARGET_CONVERTED || attribute == ATTR_TARGET_NOTCONVERTED;
-        underlines[i].color = Color(0,0,0);
+        underlines[i].color = makeSimpleColor(0, 0, 0);
     }
 }
 
index bf50e68..6475cfc 100644 (file)
@@ -1,3 +1,24 @@
+2020-06-01  Sam Weinig  <weinig@apple.com>
+
+        Extended Color: Replace Color constructors taking numeric values with type specific factory functions
+        https://bugs.webkit.org/show_bug.cgi?id=212576
+
+        Reviewed by Tim Horton.
+
+        Replaces all remaining implicit and explicit uses of the Color constructors taking numeric
+        values with explicit calls to makeSimpleColor/makeSimpleColorFromFloats/makeExtendedColor,
+        giving us a consistent way to create colors. Also addes use constexpr SimpleColors where possible.
+
+        * TestWebKitAPI/Tests/WebCore/ColorTests.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/ExtendedColorTests.cpp:
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::makeColor):
+        * TestWebKitAPI/Tests/WebKitCocoa/PDFSnapshot.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/cocoa/TestPDFDocument.mm:
+        (TestWebKitAPI::TestPDFPage::colorAtPoint const):
+
 2020-05-31  Dean Jackson  <dino@apple.com>
 
         AutoTrader crashed while browsing search results
index 3dd1d73..2b3669a 100644 (file)
@@ -67,7 +67,7 @@ TEST(Color, RGBToHSL_Black)
 
 TEST(Color, RGBToHSL_Red)
 {
-    Color color(255, 0, 0);
+    Color color = makeSimpleColor(255, 0, 0);
 
     auto [hue, saturation, lightness, alpha] = sRGBToHSL(color.toSRGBAComponentsLossy());
 
@@ -83,7 +83,7 @@ TEST(Color, RGBToHSL_Red)
 
 TEST(Color, RGBToHSL_Green)
 {
-    Color color(0, 255, 0);
+    Color color = makeSimpleColor(0, 255, 0);
 
     auto [hue, saturation, lightness, alpha] = sRGBToHSL(color.toSRGBAComponentsLossy());
 
@@ -99,7 +99,7 @@ TEST(Color, RGBToHSL_Green)
 
 TEST(Color, RGBToHSL_Blue)
 {
-    Color color(0, 0, 255);
+    Color color = makeSimpleColor(0, 0, 255);
 
     auto [hue, saturation, lightness, alpha] = sRGBToHSL(color.toSRGBAComponentsLossy());
 
@@ -171,7 +171,7 @@ TEST(Color, Validity)
     EXPECT_FALSE(otherInvalidColor.isValid());
     EXPECT_FALSE(otherInvalidColor.isExtended());
 
-    Color validColor(255, 0, 0);
+    Color validColor = makeSimpleColor(255, 0, 0);
     EXPECT_TRUE(validColor.isValid());
     EXPECT_FALSE(validColor.isExtended());
 
@@ -179,7 +179,7 @@ TEST(Color, Validity)
     EXPECT_TRUE(otherValidColor.isValid());
     EXPECT_FALSE(otherValidColor.isExtended());
 
-    validColor = Color(1, 2, 3, 4);
+    validColor = makeSimpleColor(1, 2, 3, 4);
     EXPECT_TRUE(validColor.isValid());
     EXPECT_FALSE(validColor.isExtended());
     auto simpleValidColor = validColor.toSRGBASimpleColorLossy();
index fb678f7..0d8c6a7 100644 (file)
@@ -36,7 +36,7 @@ namespace TestWebKitAPI {
 
 TEST(ExtendedColor, Constructor)
 {
-    Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+    Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
     EXPECT_TRUE(c1.isExtended());
 
     auto [r, g, b, alpha] = c1.asExtended().components();
@@ -51,7 +51,7 @@ TEST(ExtendedColor, Constructor)
 
 TEST(ExtendedColor, CopyConstructor)
 {
-    Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+    Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
     EXPECT_TRUE(c1.isExtended());
 
     Color c2(c1);
@@ -69,7 +69,7 @@ TEST(ExtendedColor, CopyConstructor)
 
 TEST(ExtendedColor, Assignment)
 {
-    Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+    Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
     EXPECT_TRUE(c1.isExtended());
 
     Color c2 = c1;
@@ -88,20 +88,20 @@ TEST(ExtendedColor, Assignment)
 TEST(ExtendedColor, Equality)
 {
     {
-        Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+        Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
         EXPECT_TRUE(c1.isExtended());
 
-        Color c2(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+        Color c2 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
         EXPECT_TRUE(c1.isExtended());
 
         EXPECT_EQ(c1, c2);
     }
 
     {
-        Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+        Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
         EXPECT_TRUE(c1.isExtended());
 
-        Color c2(1.0, 0.5, 0.25, 1.0, ColorSpace::SRGB);
+        Color c2 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::SRGB) };
         EXPECT_TRUE(c1.isExtended());
 
         EXPECT_NE(c1, c2);
@@ -111,8 +111,8 @@ TEST(ExtendedColor, Equality)
     int g = 128;
     int b = 63;
     int a = 127;
-    Color rgb1(r / 255.0, g / 255.0, b / 255.0, a / 255.0, ColorSpace::SRGB);
-    Color rgb2(r, g, b, a);
+    Color rgb1 { makeExtendedColor(r / 255.0, g / 255.0, b / 255.0, a / 255.0, ColorSpace::SRGB) };
+    Color rgb2 = makeSimpleColor(r, g, b, a);
     EXPECT_NE(rgb1, rgb2);
     EXPECT_NE(rgb2, rgb1);
 }
@@ -120,20 +120,20 @@ TEST(ExtendedColor, Equality)
 TEST(ExtendedColor, Hash)
 {
     {
-        Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+        Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
         EXPECT_TRUE(c1.isExtended());
 
-        Color c2(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+        Color c2 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
         EXPECT_TRUE(c1.isExtended());
 
         EXPECT_EQ(c1.hash(), c2.hash());
     }
 
     {
-        Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+        Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
         EXPECT_TRUE(c1.isExtended());
 
-        Color c2(1.0, 0.5, 0.25, 1.0, ColorSpace::SRGB);
+        Color c2 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::SRGB) };
         EXPECT_TRUE(c1.isExtended());
 
         EXPECT_NE(c1.hash(), c2.hash());
@@ -143,14 +143,14 @@ TEST(ExtendedColor, Hash)
     int g = 128;
     int b = 63;
     int a = 127;
-    Color rgb1(r / 255.0, g / 255.0, b / 255.0, a / 255.0, ColorSpace::SRGB);
-    Color rgb2(r, g, b, a);
+    Color rgb1 { makeExtendedColor(r / 255.0, g / 255.0, b / 255.0, a / 255.0, ColorSpace::SRGB) };
+    Color rgb2 = makeSimpleColor(r, g, b, a);
     EXPECT_NE(rgb1.hash(), rgb2.hash());
 }
 
 TEST(ExtendedColor, MoveConstructor)
 {
-    Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+    Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
     EXPECT_TRUE(c1.isExtended());
 
     Color c2(WTFMove(c1));
@@ -171,7 +171,7 @@ TEST(ExtendedColor, MoveConstructor)
 
 TEST(ExtendedColor, MoveAssignment)
 {
-    Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+    Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
     EXPECT_TRUE(c1.isExtended());
 
     Color c2 = WTFMove(c1);
@@ -193,7 +193,7 @@ TEST(ExtendedColor, MoveAssignment)
 
 TEST(ExtendedColor, BasicReferenceCounting)
 {
-    Color* c1 = new Color(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+    Color* c1 = new Color { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
     EXPECT_TRUE(c1->isExtended());
 
     Color* c2 = new Color(*c1);
@@ -219,7 +219,7 @@ TEST(ExtendedColor, BasicReferenceCounting)
 
 Color makeColor()
 {
-    Color c1(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3);
+    Color c1 { makeExtendedColor(1.0, 0.5, 0.25, 1.0, ColorSpace::DisplayP3) };
     EXPECT_TRUE(c1.isExtended());
     EXPECT_EQ(1u, c1.asExtended().refCount());
 
@@ -238,7 +238,7 @@ TEST(ExtendedColor, ReturnValues)
 TEST(ExtendedColor, P3ConversionToSRGB)
 {
     {
-        Color p3Color(1.0, 0.5, 0.25, 0.75, ColorSpace::DisplayP3);
+        Color p3Color { makeExtendedColor(1.0, 0.5, 0.25, 0.75, ColorSpace::DisplayP3) };
         EXPECT_TRUE(p3Color.isExtended());
 
         auto sRGBComponents = p3Color.toSRGBAComponentsLossy();
@@ -249,7 +249,7 @@ TEST(ExtendedColor, P3ConversionToSRGB)
     }
 
     {
-        Color linearColor(1.0, 0.5, 0.25, 0.75, ColorSpace::LinearRGB);
+        Color linearColor { makeExtendedColor(1.0, 0.5, 0.25, 0.75, ColorSpace::LinearRGB) };
         EXPECT_TRUE(linearColor.isExtended());
         auto sRGBComponents = linearColor.toSRGBAComponentsLossy();
         EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBComponents.components[0], 1.0f));
index 1bbfdca..d18f6f7 100644 (file)
@@ -35,8 +35,6 @@
 #import <WebKit/WKPDFConfiguration.h>
 #import <WebKit/WKWebViewPrivate.h>
 
-using WebCore::Color;
-
 namespace TestWebKitAPI {
 
 TEST(PDFSnapshot, FullContent)
@@ -60,7 +58,7 @@ TEST(PDFSnapshot, FullContent)
         EXPECT_EQ(page->text()[4], 'o');
 
         // The entire page should be green. Pick a point in the middle to check.
-        EXPECT_TRUE(page->colorAtPoint(400, 300) == Color(0, 255, 0));
+        EXPECT_TRUE(page->colorAtPoint(400, 300) == WebCore::makeSimpleColor(0, 255, 0));
 
         didTakeSnapshot = true;
     }];
@@ -91,7 +89,7 @@ TEST(PDFSnapshot, Subregions)
         EXPECT_EQ(page->characterCount(), 0u);
 
         // The entire page should be green. Pick a point in the middle to check.
-        EXPECT_TRUE(page->colorAtPoint(200, 150) == Color(0, 255, 0));
+        EXPECT_TRUE(page->colorAtPoint(200, 150) == WebCore::makeSimpleColor(0, 255, 0));
 
         didTakeSnapshot = true;
     }];
@@ -111,10 +109,10 @@ TEST(PDFSnapshot, Subregions)
         EXPECT_TRUE(CGRectEqualToRect(page->bounds(), CGRectMake(0, 0, 1200, 1200)));
 
         // A pixel that was in the view should be green. Pick a point in the middle to check.
-        EXPECT_TRUE(page->colorAtPoint(200, 150) == Color(0, 255, 0));
+        EXPECT_TRUE(page->colorAtPoint(200, 150) == WebCore::makeSimpleColor(0, 255, 0));
 
         // A pixel that was outside the view should also be green (we extend background color out). Pick a point in the middle to check.
-        EXPECT_TRUE(page->colorAtPoint(900, 700) == Color(0, 255, 0));
+        EXPECT_TRUE(page->colorAtPoint(900, 700) == WebCore::makeSimpleColor(0, 255, 0));
 
         didTakeSnapshot = true;
     }];
@@ -140,20 +138,20 @@ TEST(PDFSnapshot, Over200Inches)
         auto page = document->page(0);
         EXPECT_NE(page, nullptr);
         EXPECT_TRUE(CGRectEqualToRect(page->bounds(), CGRectMake(0, 0, 800, 14400)));
-        EXPECT_TRUE(page->colorAtPoint(400, 300) == Color(0, 255, 0));
+        EXPECT_TRUE(page->colorAtPoint(400, 300) == WebCore::makeSimpleColor(0, 255, 0));
         EXPECT_EQ(page->characterCount(), 5u);
 
         page = document->page(1);
         EXPECT_NE(page, nullptr);
         EXPECT_TRUE(CGRectEqualToRect(page->bounds(), CGRectMake(0, 0, 800, 14400)));
-        EXPECT_TRUE(page->colorAtPoint(400, 300) == Color(0, 255, 0));
+        EXPECT_TRUE(page->colorAtPoint(400, 300) == WebCore::makeSimpleColor(0, 255, 0));
 
         EXPECT_EQ(page->characterCount(), 0u);
 
         page = document->page(2);
         EXPECT_NE(page, nullptr);
         EXPECT_TRUE(CGRectEqualToRect(page->bounds(), CGRectMake(0, 0, 800, 600)));
-        EXPECT_TRUE(page->colorAtPoint(400, 300) == Color(0, 255, 0));
+        EXPECT_TRUE(page->colorAtPoint(400, 300) == WebCore::makeSimpleColor(0, 255, 0));
         EXPECT_EQ(page->characterCount(), 0u);
 
         didTakeSnapshot = true;
@@ -178,7 +176,7 @@ TEST(PDFSnapshot, Links)
         EXPECT_NE(page, nullptr);
 
         EXPECT_TRUE(CGRectEqualToRect(page->bounds(), CGRectMake(0, 0, 800, 14400)));
-        EXPECT_TRUE(page->colorAtPoint(400, 300) == Color(255, 255, 255));
+        EXPECT_TRUE(page->colorAtPoint(400, 300) == WebCore::makeSimpleColor(255, 255, 255));
 
         EXPECT_EQ(page->characterCount(), 8u);
         EXPECT_EQ(page->text()[0], 'C');
index 2ec6b32..f98677b 100644 (file)
@@ -144,8 +144,8 @@ WebCore::Color TestPDFPage::colorAtPoint(int x, int y) const
     auto a = pixel[i + 3];
 
     if (!a)
-        return { 0, 0, 0, 0 };
-    return { r * 255 / a, g * 255 / a, b * 255 / a, a };
+        return WebCore::makeSimpleColor(0, 0, 0, 0);
+    return WebCore::makeSimpleColor(r * 255 / a, g * 255 / a, b * 255 / a, a);
 }
 
 // Documents