Changeset 207265 in webkit
- Timestamp:
- Oct 12, 2016 6:14:15 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r207041 r207265 2204 2204 platform/graphics/CrossfadeGeneratedImage.cpp 2205 2205 platform/graphics/DisplayRefreshMonitorClient.cpp 2206 platform/graphics/ExtendedColor.cpp 2206 2207 platform/graphics/FloatPoint.cpp 2207 2208 platform/graphics/FloatPoint3D.cpp -
trunk/Source/WebCore/ChangeLog
r207245 r207265 1 2016-10-11 Dean Jackson <dino@apple.com> 2 3 Add preliminary support for extended colors to WebCore::Color 4 https://bugs.webkit.org/show_bug.cgi?id=162878 5 <rdar://problem/28596413> 6 7 Reviewed by Darin Adler. 8 9 Add an ExtendedColor class that will hold the data necessary 10 for wider-than-sRGB (and more precise) colors. In order to 11 avoid increasing the size of Color, implement a tagged 12 pointer that is either referencing an ExtendedColor, or 13 is a 64-bit number with the top 32-bits being the RGBA, and 14 the bottom 2 bits indicating an invalid RGBA or a valid RGBA, 15 plus the tag. 16 17 Add copy constructors and operator= so that the new Color objects 18 are correctly copied. 19 20 There isn't yet a way to create an ExtendedColor. That's coming 21 in a followup patch (and will require changes to the CSS parser). 22 23 Covered by existing tests, and new API tests in Color. 24 25 * CMakeLists.txt: 26 * WebCore.xcodeproj/project.pbxproj: Add new files. 27 28 * platform/graphics/Color.cpp: Update everything to use m_rgbaAndFlags 29 instead of m_color + m_valid. 30 (WebCore::Color::Color): 31 (WebCore::Color::~Color): 32 (WebCore::Color::operator=): 33 (WebCore::Color::nameForRenderTreeAsText): 34 (WebCore::Color::setNamedColor): 35 (WebCore::Color::light): 36 (WebCore::Color::dark): 37 (WebCore::Color::setValid): 38 (WebCore::Color::setExtended): 39 (WebCore::Color::isExtended): 40 (WebCore::Color::asExtended): 41 * platform/graphics/Color.h: Implement the tagged union. 42 (WebCore::Color::Color): 43 (WebCore::Color::isValid): 44 (WebCore::Color::red): 45 (WebCore::Color::green): 46 (WebCore::Color::blue): 47 (WebCore::Color::alpha): 48 (WebCore::Color::rgb): 49 (WebCore::Color::setRGB): 50 (WebCore::operator==): 51 52 * platform/graphics/ExtendedColor.cpp: New file. Holds floating point 53 red, green, blue and alpha, plus a color space. 54 (WebCore::ExtendedColor::create): 55 (WebCore::ExtendedColor::~ExtendedColor): 56 (WebCore::ExtendedColor::ref): 57 (WebCore::ExtendedColor::deref): 58 * platform/graphics/ExtendedColor.h: 59 (WebCore::ExtendedColor::red): 60 (WebCore::ExtendedColor::green): 61 (WebCore::ExtendedColor::blue): 62 (WebCore::ExtendedColor::alpha): 63 (WebCore::ExtendedColor::colorSpace): 64 (WebCore::ExtendedColor::ExtendedColor): 65 66 * platform/graphics/cg/ColorCG.cpp: Update the constructors for 67 the platform specific color classes. 68 (WebCore::Color::Color): 69 * platform/graphics/gtk/ColorGtk.cpp: 70 (WebCore::Color::Color): 71 * platform/graphics/win/ColorDirect2D.cpp: 72 (WebCore::Color::Color): 73 74 * rendering/RenderEmbeddedObject.cpp: Use NeverDestroyed. 75 (WebCore::replacementTextRoundedRectPressedColor): 76 (WebCore::replacementTextRoundedRectColor): 77 (WebCore::replacementTextColor): 78 (WebCore::unavailablePluginBorderColor): 79 80 * rendering/RenderFrameSet.cpp: Ditto. 81 (WebCore::borderStartEdgeColor): 82 (WebCore::borderEndEdgeColor): 83 (WebCore::borderFillColor): 84 85 * rendering/RenderTableCell.cpp: This grows in size slightly 86 because it can no longer pack bits. 87 1 88 2016-10-12 Antoine Quint <graouts@apple.com> 2 89 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r207239 r207265 1382 1382 31D591B316697A6C00E6BF02 /* PlugInClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D591B116697A6C00E6BF02 /* PlugInClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1383 1383 31DCD29D1AB4FBDE0072E817 /* AnimationTrigger.h in Headers */ = {isa = PBXBuildFile; fileRef = 31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1384 31DCDF431DA1C45400EA5B93 /* ExtendedColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31DCDF411DA1C45400EA5B93 /* ExtendedColor.cpp */; }; 1385 31DCDF441DA1C45400EA5B93 /* ExtendedColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 31DCDF421DA1C45400EA5B93 /* ExtendedColor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1384 1386 31DEA4551B39F4D900F77178 /* WebSystemBackdropLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 31DEA4531B39F4D900F77178 /* WebSystemBackdropLayer.mm */; }; 1385 1387 31DEA4561B39F4D900F77178 /* WebSystemBackdropLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 31DEA4541B39F4D900F77178 /* WebSystemBackdropLayer.h */; }; … … 8350 8352 31D591B116697A6C00E6BF02 /* PlugInClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInClient.h; sourceTree = "<group>"; }; 8351 8353 31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationTrigger.h; sourceTree = "<group>"; }; 8354 31DCDF411DA1C45400EA5B93 /* ExtendedColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtendedColor.cpp; sourceTree = "<group>"; }; 8355 31DCDF421DA1C45400EA5B93 /* ExtendedColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtendedColor.h; sourceTree = "<group>"; }; 8352 8356 31DEA4531B39F4D900F77178 /* WebSystemBackdropLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSystemBackdropLayer.mm; sourceTree = "<group>"; }; 8353 8357 31DEA4541B39F4D900F77178 /* WebSystemBackdropLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSystemBackdropLayer.h; sourceTree = "<group>"; }; … … 20734 20738 B27535380B053814002CE64F /* Color.cpp */, 20735 20739 B27535390B053814002CE64F /* Color.h */, 20740 31DCDF411DA1C45400EA5B93 /* ExtendedColor.cpp */, 20741 31DCDF421DA1C45400EA5B93 /* ExtendedColor.h */, 20736 20742 9382DF5710A8D5C900925652 /* ColorSpace.h */, 20737 20743 2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */, … … 24929 24935 510192D218B6B9AB007FC7A1 /* ImageControlsRootElementMac.h in Headers */, 24930 24936 A779791A0D6B9D0C003851B9 /* ImageData.h in Headers */, 24937 31DCDF441DA1C45400EA5B93 /* ExtendedColor.h in Headers */, 24931 24938 555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */, 24932 24939 97205AB61239291000B17380 /* ImageDocument.h in Headers */, … … 30377 30384 B2227AF20D00BF220071B782 /* SVGViewSpec.cpp in Sources */, 30378 30385 8485228A1190173C006EDC7F /* SVGVKernElement.cpp in Sources */, 30386 31DCDF431DA1C45400EA5B93 /* ExtendedColor.cpp in Sources */, 30379 30387 B2227AF50D00BF220071B782 /* SVGZoomAndPan.cpp in Sources */, 30380 30388 B2E4EC970D00C22B00432643 /* SVGZoomEvent.cpp in Sources */, -
trunk/Source/WebCore/platform/graphics/Color.cpp
r206043 r207265 226 226 { 227 227 if (name[0] == '#') { 228 RGBA32 color; 229 bool valid; 230 228 231 if (name.is8Bit()) 229 m_valid = parseHexColor(name.characters8() + 1, name.length() - 1, m_color);232 valid = parseHexColor(name.characters8() + 1, name.length() - 1, color); 230 233 else 231 m_valid = parseHexColor(name.characters16() + 1, name.length() - 1, m_color); 234 valid = parseHexColor(name.characters16() + 1, name.length() - 1, color); 235 236 if (valid) 237 setRGB(color); 232 238 } else 233 239 setNamedColor(name); … … 236 242 Color::Color(const char* name) 237 243 { 244 RGBA32 color; 245 bool valid; 238 246 if (name[0] == '#') 239 m_valid = parseHexColor((String)&name[1], m_color);247 valid = parseHexColor((String)&name[1], color); 240 248 else { 241 249 const NamedColor* foundColor = findColor(name, strlen(name)); 242 m_color = foundColor ? foundColor->ARGBValue : 0; 243 m_valid = foundColor; 244 } 250 color = foundColor ? foundColor->ARGBValue : 0; 251 valid = foundColor; 252 } 253 254 if (valid) 255 setRGB(color); 256 } 257 258 Color::Color(const Color& other) 259 : m_colorData(other.m_colorData) 260 { 261 if (isExtended()) 262 m_colorData.extendedColor->ref(); 263 } 264 265 Color::Color(Color&& other) 266 { 267 *this = WTFMove(other); 268 } 269 270 Color::~Color() 271 { 272 if (isExtended()) 273 m_colorData.extendedColor->deref(); 274 } 275 276 Color& Color::operator=(const Color& other) 277 { 278 if (*this == other) 279 return *this; 280 281 if (isExtended()) 282 m_colorData.extendedColor->deref(); 283 284 m_colorData = other.m_colorData; 285 286 if (isExtended()) 287 m_colorData.extendedColor->ref(); 288 return *this; 289 } 290 291 Color& Color::operator=(Color&& other) 292 { 293 if (*this == other) 294 return *this; 295 296 m_colorData = other.m_colorData; 297 other.m_colorData.rgbaAndFlags = invalidRGBAColor; 298 299 return *this; 245 300 } 246 301 … … 292 347 String Color::nameForRenderTreeAsText() const 293 348 { 349 // FIXME: Handle ExtendedColors. 294 350 if (alpha() < 0xFF) 295 351 return String::format("#%02X%02X%02X%02X", red(), green(), blue(), alpha()); … … 316 372 { 317 373 const NamedColor* foundColor = findNamedColor(name); 318 m_color = foundColor ? foundColor->ARGBValue : 0; 319 m_valid = foundColor; 374 if (foundColor) 375 setRGB(foundColor->ARGBValue); 376 else 377 m_colorData.rgbaAndFlags = invalidRGBAColor; 320 378 } 321 379 … … 323 381 { 324 382 // Hardcode this common case for speed. 325 if ( m_color== black)383 if (rgb() == black) 326 384 return lightenedBlack; 327 385 … … 348 406 { 349 407 // Hardcode this common case for speed. 350 if ( m_color== white)408 if (rgb() == white) 351 409 return darkenedWhite; 352 410 … … 562 620 } 563 621 622 void Color::tagAsValid() 623 { 624 m_colorData.rgbaAndFlags |= validRGBAColor; 625 } 626 627 void Color::tagAsExtended() 628 { 629 // FIXME: Is this method necessary? Will colors ever change from RGBA32 to Extended? 630 // Valid colors should not change type. 631 ASSERT(!isValid()); 632 m_colorData.rgbaAndFlags &= ~(invalidRGBAColor); 633 } 634 635 bool Color::isExtended() const 636 { 637 return !(m_colorData.rgbaAndFlags & invalidRGBAColor); 638 } 639 640 ExtendedColor* Color::asExtended() const 641 { 642 ASSERT(isExtended()); 643 if (!isExtended()) 644 return nullptr; 645 return m_colorData.extendedColor; 646 } 647 564 648 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/Color.h
r206773 r207265 24 24 */ 25 25 26 #ifndef Color_h 27 #define Color_h 26 #pragma once 28 27 29 28 #include "ColorSpace.h" 29 #include "ExtendedColor.h" 30 30 #include "PlatformExportMacros.h" 31 31 #include <algorithm> … … 108 108 WTF_MAKE_FAST_ALLOCATED; 109 109 public: 110 Color() : m_color(0), m_valid(false) { } 111 Color(RGBA, ColorSpace); 110 Color() { } 112 111 113 112 // FIXME: Remove all these constructors and creation functions and replace the ones that are still needed with free functions. 114 Color(RGBA32 color, bool valid = true) : m_color(color), m_valid(valid) { ASSERT(!m_color || m_valid); } 115 Color(int r, int g, int b) : m_color(makeRGB(r, g, b)), m_valid(true) { } 116 Color(int r, int g, int b, int a) : m_color(makeRGBA(r, g, b, a)), m_valid(true) { } 117 // Color is currently limited to 32bit RGBA, perhaps some day we'll support better colors 118 Color(float r, float g, float b, float a) : m_color(makeRGBA32FromFloats(r, g, b, a)), m_valid(true) { } 113 114 Color(RGBA32 color, bool valid = true) 115 { 116 if (valid) 117 setRGB(color); 118 } 119 120 Color(int r, int g, int b) 121 { 122 setRGB(r, g, b); 123 } 124 125 Color(int r, int g, int b, int a) 126 { 127 setRGB(makeRGBA(r, g, b, a)); 128 } 129 130 Color(float r, float g, float b, float a) 131 { 132 setRGB(makeRGBA32FromFloats(r, g, b, a)); 133 } 134 119 135 // Creates a new color from the specific CMYK and alpha values. 120 Color(float c, float m, float y, float k, float a) : m_color(makeRGBAFromCMYKA(c, m, y, k, a)), m_valid(true) { } 136 Color(float c, float m, float y, float k, float a) 137 { 138 setRGB(makeRGBAFromCMYKA(c, m, y, k, a)); 139 } 140 121 141 WEBCORE_EXPORT explicit Color(const String&); 122 142 explicit Color(const char*); 143 144 // FIXME: Add constructor for ExtendedColor type. 145 146 Color(RGBA, ColorSpace); 147 WEBCORE_EXPORT Color(const Color&); 148 WEBCORE_EXPORT Color(Color&&); 149 150 WEBCORE_EXPORT ~Color(); 151 123 152 static Color createUnchecked(int r, int g, int b) 124 153 { … … 144 173 void setNamedColor(const String&); 145 174 146 // FIXME: Remove this after moving clients to all use OptionalColor instead. 147 bool isValid() const { return m_valid; } 175 bool isValid() const { return m_colorData.rgbaAndFlags & validRGBAColorBit; } 148 176 149 177 bool hasAlpha() const { return alpha() < 255; } 150 178 151 int red() const { return redChannel( m_color); }152 int green() const { return greenChannel( m_color); }153 int blue() const { return blueChannel( m_color); }154 int alpha() const { return alphaChannel( m_color); }179 int red() const { return redChannel(rgb()); } 180 int green() const { return greenChannel(rgb()); } 181 int blue() const { return blueChannel(rgb()); } 182 int alpha() const { return alphaChannel(rgb()); } 155 183 156 RGBA32 rgb() const { return m_color; } // Preserve the alpha. 157 void setRGB(int r, int g, int b) { m_color = makeRGB(r, g, b); m_valid = true; } 158 void setRGB(RGBA32 rgb) { m_color = rgb; m_valid = true; } 184 RGBA32 rgb() const { ASSERT(!isExtended()); return static_cast<RGBA32>(m_colorData.rgbaAndFlags >> 32); } 185 void setRGB(int r, int g, int b) { setRGB(makeRGB(r, g, b)); } 186 void setRGB(RGBA32); 187 159 188 WEBCORE_EXPORT void getRGBA(float& r, float& g, float& b, float& a) const; 160 189 WEBCORE_EXPORT void getRGBA(double& r, double& g, double& b, double& a) const; … … 209 238 #endif 210 239 240 WEBCORE_EXPORT bool isExtended() const; 241 WEBCORE_EXPORT ExtendedColor* asExtended() const; 242 243 WEBCORE_EXPORT Color& operator=(const Color&); 244 WEBCORE_EXPORT Color& operator=(Color&&); 245 246 friend bool operator==(const Color& a, const Color& b); 247 211 248 private: 212 RGBA32 m_color; 213 bool m_valid; 249 250 // 0x_______00 is an ExtendedColor pointer. 251 // 0x_______01 is an invalid RGBA32. 252 // 0x_______11 is a valid RGBA32. 253 static const uint64_t extendedColor = 0x0; 254 static const uint64_t invalidRGBAColor = 0x1; 255 static const uint64_t validRGBAColorBit = 0x2; 256 static const uint64_t validRGBAColor = 0x3; 257 258 WEBCORE_EXPORT void tagAsValid(); 259 void tagAsExtended(); 260 261 union { 262 uint64_t rgbaAndFlags { invalidRGBAColor }; 263 ExtendedColor* extendedColor; 264 } m_colorData; 214 265 }; 215 266 … … 271 322 272 323 inline Color::Color(RGBA color, ColorSpace space) 273 : m_color(color.m_integer) 274 , m_valid(true) 275 { 324 { 325 setRGB(color.m_integer); 276 326 ASSERT_UNUSED(space, space == ColorSpaceSRGB); 277 327 } … … 279 329 inline bool operator==(const Color& a, const Color& b) 280 330 { 281 return a. rgb() == b.rgb() && a.isValid() == b.isValid();331 return a.m_colorData.rgbaAndFlags == b.m_colorData.rgbaAndFlags; 282 332 } 283 333 … … 316 366 } 317 367 368 inline void Color::setRGB(RGBA32 rgb) 369 { 370 m_colorData.rgbaAndFlags = static_cast<uint64_t>(rgb) << 32; 371 tagAsValid(); 372 } 373 318 374 WEBCORE_EXPORT TextStream& operator<<(TextStream&, const Color&); 319 375 320 376 } // namespace WebCore 321 322 #endif // Color_h -
trunk/Source/WebCore/platform/graphics/ExtendedColor.cpp
r207263 r207265 1 1 /* 2 * Copyright (C) 20 03, 2004, 2005, 2006, 2007, 2010Apple Inc. All rights reserved.2 * Copyright (C) 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 26 #include "config.h" 27 #include " Color.h"27 #include "ExtendedColor.h" 28 28 29 #if PLATFORM(WIN) 30 31 #include <d2d1.h> 32 #include <d2d1_1helper.h> 29 #include "ColorSpace.h" 33 30 34 31 namespace WebCore { 35 32 36 Color::Color(D2D1_COLOR_F color)33 Ref<ExtendedColor> ExtendedColor::create(float r, float g, float b, float a, ColorSpace colorSpace) 37 34 { 38 m_color = makeRGBA(color.r * 255, color.g * 255, color.b * 255, color.a * 255); 39 m_valid = true; 40 } 41 42 Color::operator D2D1_COLOR_F() const 43 { 44 float colorAlpha = alpha() / 255.0f; 45 46 return D2D1::ColorF(rgb(), colorAlpha); 47 } 48 49 Color::operator D2D1_VECTOR_4F() const 50 { 51 float r, g, b, a; 52 getRGBA(r, g, b, a); 53 return D2D1::Vector4F(r, g, b, a); 35 return adoptRef(*new ExtendedColor(r, g, b, a, colorSpace)); 54 36 } 55 37 56 38 } 57 58 #endif // PLATFORM(WIN) -
trunk/Source/WebCore/platform/graphics/ExtendedColor.h
r207263 r207265 1 1 /* 2 * Copyright (C) 20 03, 2004, 2005, 2006, 2007, 2010Apple Inc. All rights reserved.2 * Copyright (C) 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 #include "config.h" 27 #include "Color.h" 26 #pragma once 28 27 29 #i f PLATFORM(WIN)28 #include "ColorSpace.h" 30 29 31 #include < d2d1.h>32 #include < d2d1_1helper.h>30 #include <wtf/Ref.h> 31 #include <wtf/RefCounted.h> 33 32 34 33 namespace WebCore { 35 34 36 Color::Color(D2D1_COLOR_F color) 37 { 38 m_color = makeRGBA(color.r * 255, color.g * 255, color.b * 255, color.a * 255); 39 m_valid = true; 40 } 35 class ExtendedColor : public RefCounted<ExtendedColor> { 36 public: 37 static Ref<ExtendedColor> create(float r, float g, float b, float a, ColorSpace = ColorSpace::ColorSpaceSRGB); 41 38 42 Color::operator D2D1_COLOR_F() const 43 { 44 float colorAlpha = alpha() / 255.0f; 39 float red() const { return m_red; } 40 float green() const { return m_green; } 41 float blue() const { return m_blue; } 42 float alpha() const { return m_alpha; } 45 43 46 return D2D1::ColorF(rgb(), colorAlpha); 47 } 44 ColorSpace colorSpace() const { return m_colorSpace; } 48 45 49 Color::operator D2D1_VECTOR_4F() const 50 { 51 float r, g, b, a; 52 getRGBA(r, g, b, a); 53 return D2D1::Vector4F(r, g, b, a); 54 } 46 private: 47 ExtendedColor(float r, float g, float b, float a, ColorSpace colorSpace) 48 : m_red(r) 49 , m_green(g) 50 , m_blue(b) 51 , m_alpha(a) 52 , m_colorSpace(colorSpace) 53 { } 54 55 float m_red { 0 }; 56 float m_green { 0 }; 57 float m_blue { 0 }; 58 float m_alpha { 0 }; 59 60 ColorSpace m_colorSpace { ColorSpace::ColorSpaceSRGB }; 61 }; 55 62 56 63 } 57 58 #endif // PLATFORM(WIN) -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r206830 r207265 1372 1372 // they start to obscure useful information. 1373 1373 if ((!m_transform.isIdentity() || m_usingTiledBacking) && !m_visibleTileWashLayer) { 1374 static ColorwashFillColor(255, 0, 0, 50);1375 static ColorwashBorderColor(255, 0, 0, 100);1374 static NeverDestroyed<Color> washFillColor(255, 0, 0, 50); 1375 static NeverDestroyed<Color> washBorderColor(255, 0, 0, 100); 1376 1376 1377 1377 m_visibleTileWashLayer = createPlatformCALayer(PlatformCALayer::LayerTypeLayer, this); -
trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp
r203038 r207265 74 74 { 75 75 if (!color) { 76 m_color = 0; 77 m_valid = false; 76 m_colorData.rgbaAndFlags = invalidRGBAColor; 78 77 return; 79 78 } … … 112 111 } 113 112 114 m_color = makeRGBA(r * 255, g * 255, b * 255, a * 255); 115 m_valid = true; 113 setRGB(makeRGBA(r * 255, g * 255, b * 255, a * 255)); 116 114 } 117 115 -
trunk/Source/WebCore/platform/graphics/gtk/ColorGtk.cpp
r75056 r207265 27 27 28 28 Color::Color(const GdkColor& c) 29 : m_color(makeRGB(c.red >> 8, c.green >> 8, c.blue >> 8))30 , m_valid(true)31 29 { 30 setRGB(makeRGB(c.red >> 8, c.green >> 8, c.blue >> 8)); 32 31 } 33 32 34 33 #ifndef GTK_API_VERSION_2 35 34 Color::Color(const GdkRGBA& c) 36 : m_color(makeRGBA(static_cast<int>(c.red * 255),37 static_cast<int>(c.green * 255),38 static_cast<int>(c.blue * 255),39 static_cast<int>(c.alpha * 255)))40 , m_valid(true)41 35 { 36 setRGB(makeRGBA(static_cast<int>(c.red * 255), 37 static_cast<int>(c.green * 255), 38 static_cast<int>(c.blue * 255), 39 static_cast<int>(c.alpha * 255))); 42 40 } 43 41 -
trunk/Source/WebCore/platform/graphics/win/ColorDirect2D.cpp
r206773 r207265 36 36 Color::Color(D2D1_COLOR_F color) 37 37 { 38 m_color = makeRGBA(color.r * 255, color.g * 255, color.b * 255, color.a * 255); 39 m_valid = true; 38 setRGB(makeRGBA(color.r * 255, color.g * 255, color.b * 255, color.a * 255)); 40 39 } 41 40 -
trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp
r202105 r207265 76 76 static const Color& replacementTextRoundedRectPressedColor() 77 77 { 78 static const Colorpressed(105, 105, 105, 242);78 static NeverDestroyed<Color> pressed(105, 105, 105, 242); 79 79 return pressed; 80 80 } … … 82 82 static const Color& replacementTextRoundedRectColor() 83 83 { 84 static const Colorstandard(125, 125, 125, 242);84 static NeverDestroyed<Color> standard(125, 125, 125, 242); 85 85 return standard; 86 86 } … … 88 88 static const Color& replacementTextColor() 89 89 { 90 static const Colorstandard(240, 240, 240, 255);90 static NeverDestroyed<Color> standard(240, 240, 240, 255); 91 91 return standard; 92 92 } … … 94 94 static const Color& unavailablePluginBorderColor() 95 95 { 96 static const Colorstandard(255, 255, 255, 216);96 static NeverDestroyed<Color> standard(255, 255, 255, 216); 97 97 return standard; 98 98 } -
trunk/Source/WebCore/rendering/RenderFrameSet.cpp
r206538 r207265 70 70 static const Color& borderStartEdgeColor() 71 71 { 72 static const Colorcolor(170, 170, 170);72 static NeverDestroyed<Color> color(170, 170, 170); 73 73 return color; 74 74 } … … 76 76 static const Color& borderEndEdgeColor() 77 77 { 78 static const Colorcolor = Color::black;78 static NeverDestroyed<Color> color = Color::black; 79 79 return color; 80 80 } … … 82 82 static const Color& borderFillColor() 83 83 { 84 static const Colorcolor(208, 208, 208);84 static NeverDestroyed<Color> color(208, 208, 208); 85 85 return color; 86 86 } -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r205892 r207265 53 53 54 54 COMPILE_ASSERT(sizeof(RenderTableCell) == sizeof(SameSizeAsRenderTableCell), RenderTableCell_should_stay_small); 55 COMPILE_ASSERT(sizeof(CollapsedBorderValue) == 16, CollapsedBorderValue_should_stay_small);55 COMPILE_ASSERT(sizeof(CollapsedBorderValue) <= 24, CollapsedBorderValue_should_stay_small); 56 56 57 57 RenderTableCell::RenderTableCell(Element& element, RenderStyle&& style) -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r206761 r207265 326 326 const Color& RenderThemeIOS::shadowColor() const 327 327 { 328 static Colorcolor(0.0f, 0.0f, 0.0f, 0.7f);328 static NeverDestroyed<Color> color(0.0f, 0.0f, 0.0f, 0.7f); 329 329 return color; 330 330 } -
trunk/Source/WebKit/mac/WebView/WebIndicateLayer.mm
r192140 r207265 33 33 #import <WebCore/QuartzCoreSPI.h> 34 34 #import <WebCore/WAKWindow.h> 35 #import <wtf/NeverDestroyed.h> 35 36 36 37 using namespace WebCore; … … 50 51 51 52 // Blue highlight color. 52 static ColorhighlightColor(111.0f / 255.0f, 168.0f / 255.0f, 220.0f / 255.0f, 0.66f);53 static NeverDestroyed<Color> highlightColor(111.0f / 255.0f, 168.0f / 255.0f, 220.0f / 255.0f, 0.66f); 53 54 self.backgroundColor = cachedCGColor(highlightColor); 54 55 -
trunk/Tools/ChangeLog
r207237 r207265 1 2016-10-11 Dean Jackson <dino@apple.com> 2 3 Add preliminary support for extended colors to WebCore::Color 4 https://bugs.webkit.org/show_bug.cgi?id=162878 5 <rdar://problem/28596413> 6 7 Reviewed by Darin Adler. 8 9 A new API test for Colors. 10 11 * TestWebKitAPI/Tests/WebCore/Color.cpp: 12 (TestWebKitAPI::TEST): 13 1 14 2016-10-12 Ryan Haddad <ryanhaddad@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/Color.cpp
r200659 r207265 145 145 } 146 146 147 TEST(Color, Validity) 148 { 149 Color invalidColor; 150 EXPECT_FALSE(invalidColor.isValid()); 151 EXPECT_FALSE(invalidColor.isExtended()); 152 153 Color otherInvalidColor = invalidColor; 154 EXPECT_FALSE(otherInvalidColor.isValid()); 155 EXPECT_FALSE(otherInvalidColor.isExtended()); 156 157 Color validColor(255, 0, 0); 158 EXPECT_TRUE(validColor.isValid()); 159 EXPECT_FALSE(validColor.isExtended()); 160 161 Color otherValidColor = validColor; 162 EXPECT_TRUE(otherValidColor.isValid()); 163 EXPECT_FALSE(otherValidColor.isExtended()); 164 165 validColor = Color(1, 2, 3, 4); 166 EXPECT_TRUE(validColor.isValid()); 167 EXPECT_FALSE(validColor.isExtended()); 168 EXPECT_EQ(validColor.red(), 1); 169 EXPECT_EQ(validColor.green(), 2); 170 EXPECT_EQ(validColor.blue(), 3); 171 EXPECT_EQ(validColor.alpha(), 4); 172 173 Color yetAnotherValidColor(WTFMove(validColor)); 174 EXPECT_TRUE(yetAnotherValidColor.isValid()); 175 EXPECT_FALSE(yetAnotherValidColor.isExtended()); 176 EXPECT_EQ(yetAnotherValidColor.red(), 1); 177 EXPECT_EQ(yetAnotherValidColor.green(), 2); 178 EXPECT_EQ(yetAnotherValidColor.blue(), 3); 179 EXPECT_EQ(yetAnotherValidColor.alpha(), 4); 180 181 otherValidColor = WTFMove(yetAnotherValidColor); 182 EXPECT_TRUE(otherValidColor.isValid()); 183 EXPECT_FALSE(otherValidColor.isExtended()); 184 EXPECT_EQ(otherValidColor.red(), 1); 185 EXPECT_EQ(otherValidColor.green(), 2); 186 EXPECT_EQ(otherValidColor.blue(), 3); 187 EXPECT_EQ(otherValidColor.alpha(), 4); 188 } 189 147 190 } // namespace TestWebKitAPI
Note: See TracChangeset
for help on using the changeset viewer.