Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: Source/core/platform/graphics/Color.cpp

Issue 14098003: Change the caret color according to the lightness of the background color. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: updated patch Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 lightness = 0.5 * (max + min); 408 lightness = 0.5 * (max + min);
409 if (max == min) 409 if (max == min)
410 saturation = 0.0; 410 saturation = 0.0;
411 else if (lightness <= 0.5) 411 else if (lightness <= 0.5)
412 saturation = ((max - min) / (max + min)); 412 saturation = ((max - min) / (max + min));
413 else 413 else
414 saturation = ((max - min) / (2.0 - (max + min))); 414 saturation = ((max - min) / (2.0 - (max + min)));
415 } 415 }
416 416
417 double Color::lightness() const
418 {
419 double hue, saturation, lightness;
420 getHSL(hue, saturation, lightness);
421
422 return lightness;
423 }
424
417 Color colorFromPremultipliedARGB(RGBA32 pixelColor) 425 Color colorFromPremultipliedARGB(RGBA32 pixelColor)
418 { 426 {
419 int alpha = alphaChannel(pixelColor); 427 int alpha = alphaChannel(pixelColor);
420 if (alpha && alpha < 255) { 428 if (alpha && alpha < 255) {
421 return Color::createUnchecked( 429 return Color::createUnchecked(
422 redChannel(pixelColor) * 255 / alpha, 430 redChannel(pixelColor) * 255 / alpha,
423 greenChannel(pixelColor) * 255 / alpha, 431 greenChannel(pixelColor) * 255 / alpha,
424 blueChannel(pixelColor) * 255 / alpha, 432 blueChannel(pixelColor) * 255 / alpha,
425 alpha); 433 alpha);
426 } else 434 } else
(...skipping 11 matching lines...) Expand all
438 (color.green() * alpha + 254) / 255, 446 (color.green() * alpha + 254) / 255,
439 (color.blue() * alpha + 254) / 255, 447 (color.blue() * alpha + 254) / 255,
440 alpha).rgb(); 448 alpha).rgb();
441 } else 449 } else
442 pixelColor = color.rgb(); 450 pixelColor = color.rgb();
443 451
444 return pixelColor; 452 return pixelColor;
445 } 453 }
446 454
447 } // namespace WebCore 455 } // namespace WebCore
OLDNEW
« Source/core/editing/FrameSelection.cpp ('K') | « Source/core/platform/graphics/Color.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698