Extended Color Cleanup: Remove trivial uses of Color::rgb()
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2020 23:33:16 +0000 (23:33 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2020 23:33:16 +0000 (23:33 +0000)
commit5457e3aa6f16417e6b671c3673e8afe3c0e91a92
tree7ccd71d68540aa5d6c0b1c2d32a96a471e53f148
parentdee65fbe53ad93271b3aef0c793cb3077540cd07
Extended Color Cleanup: Remove trivial uses of Color::rgb()
https://bugs.webkit.org/show_bug.cgi?id=212231

Source/WebCore:

Reviewed by Darin Adler

Replaces a few unnecessary uses of Color::rgb():
- Uses of an idiom where code round-tripped a Color via Color(myColor.rgb()). This is
  not compatible with extended colors and seems to be unnecessary.
- Uses of colorWithOverrideAlpha(). This function requires a SimpleColor, so required
  using color.rgb(). We can't transition to Color::colorWithAlpha due to a slightly
  different rounding of the alpha, so a new function Color::colorWithAlphaUsingAlternativeRounding
  was added to which implements the alternative rounding. A later change can reconcile
  the two versions.
- Creation of D2D1::ColorF. D2D1::ColorF has a constructor that takes a four floats that
  is used instead.
- Comparing two colors using rgb() for each to avoid comparing the semantic bit. equalIgnoringSemanticColor
  exists for just this use.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverterCaches::colorPropertyValueForNode):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::addHTMLColorToStyle):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::setStrokeStyle):
(WebCore::CanvasRenderingContext2DBase::setFillStyle):
(WebCore::CanvasRenderingContext2DBase::setShadow):
* html/canvas/CanvasStyle.cpp:
(WebCore::CanvasStyle::createFromStringWithOverrideAlpha):
* html/track/InbandGenericTextTrack.cpp:
(WebCore::InbandGenericTextTrack::updateCueFromCueData):
* platform/graphics/Color.cpp:
(WebCore::Color::colorWithAlphaMultipliedByUsingAlternativeRounding const):
(WebCore::Color::colorWithAlpha const):
(WebCore::Color::colorWithAlphaUsingAlternativeRounding const):
(WebCore::colorWithOverrideAlpha): Deleted.
* platform/graphics/Color.h:
(WebCore::colorWithOverrideAlpha): Deleted.
* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::prepareCairoContextSource):
* platform/graphics/filters/FEFlood.cpp:
(WebCore::FEFlood::platformApplySoftware):
* platform/graphics/win/ColorDirect2D.cpp:
(WebCore::Color::operator D2D1_COLOR_F const):
(WebCore::Color::operator D2D1_VECTOR_4F const):
* platform/graphics/win/GraphicsContextDirect2D.cpp:
(WebCore::GraphicsContext::colorWithGlobalAlpha const):
* platform/mac/ThemeMac.mm:
(WebCore::drawCellFocusRingWithFrameAtTime):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintFileUploadIconDecorations):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::platformFocusRingColor const):
* rendering/RenderTreeAsText.cpp:
(WebCore::RenderTreeAsText::writeRenderObject):
* svg/SVGStopElement.cpp:
(WebCore::SVGStopElement::stopColorIncludingOpacity const):

Source/WebKit:

Reviewed by Darin Adler.

* UIProcess/API/ios/WKWebViewIOS.mm:
(scrollViewBackgroundColor):
Replace colorWithOverrideAlpha() with Color::colorWithAlphaUsingAlternativeRounding() to avoid
unnecessary use of Color::rgb()

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Source/WebCore/html/canvas/CanvasStyle.cpp
Source/WebCore/html/canvas/CanvasStyle.h
Source/WebCore/html/track/InbandGenericTextTrack.cpp
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/Color.h
Source/WebCore/platform/graphics/cairo/CairoOperations.cpp
Source/WebCore/platform/graphics/filters/FEFlood.cpp
Source/WebCore/platform/graphics/win/ColorDirect2D.cpp
Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp
Source/WebCore/platform/mac/ThemeMac.mm
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/svg/SVGStopElement.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm