[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

bdakin at apple.com bdakin at apple.com
Wed Apr 7 23:29:35 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 4a0593e3b4e82bf73b2a86cadd4620b4d2b80b36
Author: bdakin at apple.com <bdakin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 10 21:44:56 2009 +0000

    WebCore: Fix for <rdar://problem/7059710>
    -and corresponding-
    https://bugs.webkit.org/show_bug.cgi?id=31196 Implement -webkit-
    color-correction for CSS colors
    
    Reviewed by Darin Adler.
    
    New exported symbol for GraphicsContext::fillColor() which now
    accepts a ColorSpace as an optional parameter.
    * WebCore.base.exp:
    
    Added a new file, ColorSpace.h, to define the ColorSpace enum.
    * WebCore.xcodeproj/project.pbxproj:
    
    Computed Style for -webkit-color-correction
    * css/CSSComputedStyleDeclaration.cpp:
    (WebCore::):
    (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
    
    Parse -webkit-color-correction
    * css/CSSParser.cpp:
    (WebCore::CSSParser::parseValue):
    
           Map CSS identifiers to the appropriate values of the ColorSpace enum
    * css/CSSPrimitiveValueMappings.h:
    (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
    (WebCore::CSSPrimitiveValue::operator ColorSpace):
    
    New property -webkit-color-correction
    * css/CSSPropertyNames.in:
    
    Map -webkit-color-correction into the RenderStyle.
    * css/CSSStyleSelector.cpp:
    (WebCore::CSSStyleSelector::applyProperty):
    
    Add new value sRGB.
    * css/CSSValueKeywords.in:
    
    Comment out the reference to sRGB since it will now be inherited as
    a value from CSSValueKeywords.
    * css/SVGCSSValueKeywords.in:
    
    Definition of the ColorSpace enum.
    * platform/graphics/ColorSpace.h: Added.
    (WebCore::):
    
    These functions all now take a ColorSpace as a parameter.
    * platform/graphics/GraphicsContext.cpp:
    (WebCore::GraphicsContext::setStrokeColor):
    (WebCore::GraphicsContext::setFillColor):
    (WebCore::GraphicsContext::drawHighlightForText):
    
    Return the appropriate ColorSpace.
    (WebCore::GraphicsContext::strokeColorSpace):
    (WebCore::GraphicsContext::fillColorSpace):
    
    These functions all call other functions which require a ColorSpace
    as a parameter.
    (WebCore::GraphicsContext::setStrokePattern):
    (WebCore::GraphicsContext::setFillPattern):
    (WebCore::GraphicsContext::setStrokeGradient):
    (WebCore::GraphicsContext::setFillGradient):
    
    All of the GraphicsContext functions that take a Color should now
    also take a ColorSpace.
    * platform/graphics/GraphicsContext.h:
    
    Added new member variables stokeColorSpace and fillColorSpace.
    * platform/graphics/GraphicsContextPrivate.h:
    (WebCore::GraphicsContextState::GraphicsContextState):
    
    Attempt to keep the Cairo port building with all of the massive
    changes to GraphicsContext.
    * platform/graphics/cairo/GraphicsContextCairo.cpp:
    (WebCore::GraphicsContext::fillRect):
    (WebCore::GraphicsContext::setPlatformFillColor):
    (WebCore::GraphicsContext::setPlatformStrokeColor):
    (WebCore::GraphicsContext::fillRoundedRect):
    
    
    * platform/graphics/cg/GraphicsContextCG.cpp:
    (WebCore::sRGBColorSpaceRef): New static function that returns a
    CGColorSpaceRef for the sRGB color space.
    (WebCore::deviceRGBColorSpaceRef): New static function that returns
    a CGColorSpaceRef for the device RGB color space.
    
    (WebCore::setCGFillColor): Now takes a ColorSpace parameter and
    sets the fill color to the specified color in the given ColorSpace.
    (WebCore::setCGStrokeColor): Same, but for stroke.
    
    (WebCore::setCGFillColorSpace): New static to set the
    CGFillColorSpace to the given ColorSpace
    (WebCore::setCGStrokeColorSpace): Same, but for stroke.
    
    Send ColorSpaces when appropriate, set ColorSpaces when
    appropriate, and check ColorSpaces when appropriate.
    (WebCore::GraphicsContext::GraphicsContext):
    (WebCore::GraphicsContext::drawRect):
    (WebCore::GraphicsContext::drawLine):
    (WebCore::GraphicsContext::fillPath):
    (WebCore::GraphicsContext::strokePath):
    (WebCore::GraphicsContext::fillRect):
    (WebCore::GraphicsContext::fillRoundedRect):
    (WebCore::GraphicsContext::strokeRect):
    (WebCore::GraphicsContext::drawLineForText):
    (WebCore::GraphicsContext::setPlatformStrokeColor):
    (WebCore::GraphicsContext::setPlatformFillColor):
    
    Attempt to keep Haiku building.
    * platform/graphics/haiku/GraphicsContextHaiku.cpp:
    (WebCore::GraphicsContext::fillRect):
    (WebCore::GraphicsContext::fillRoundedRect):
    (WebCore::GraphicsContext::setPlatformStrokeColor):
    (WebCore::GraphicsContext::setPlatformFillColor):
    
    Attempt to keep QT building.
    * platform/graphics/qt/GraphicsContextQt.cpp:
    (WebCore::GraphicsContext::fillRect):
    (WebCore::GraphicsContext::fillRoundedRect):
    (WebCore::GraphicsContext::setPlatformStrokeColor):
    (WebCore::GraphicsContext::setPlatformFillColor):
    
    Attempt to keep Wince building.
    * platform/graphics/wince/GraphicsContextWince.cpp:
    (WebCore::GraphicsContext::fillRect):
    (WebCore::GraphicsContext::setPlatformFillColor):
    (WebCore::GraphicsContext::setPlatformStrokeColor):
    (WebCore::GraphicsContext::clearRect):
    (WebCore::GraphicsContext::fillRoundedRect):
    (WebCore::GraphicsContext::setPlatformShadow):
    
    Attempt to keep WX building.
    * platform/graphics/wx/GraphicsContextWx.cpp:
    (WebCore::GraphicsContext::fillRect):
    (WebCore::GraphicsContext::fillRoundedRect):
    (WebCore::GraphicsContext::setPlatformStrokeColor):
    (WebCore::GraphicsContext::setPlatformFillColor):
    
    Added functions colorSpace() and setColorSpace()
    * rendering/style/RenderStyle.h:
    (WebCore::InheritedFlags::colorSpace):
    (WebCore::InheritedFlags::setColorSpace):
    
    The ColorSpace is stored here.
    * rendering/style/StyleRareInheritedData.cpp:
    (WebCore::StyleRareInheritedData::StyleRareInheritedData):
    (WebCore::StyleRareInheritedData::operator==):
    * rendering/style/StyleRareInheritedData.h:
    
    All of these call sites call GraphicsContext functions which now
    require ColorSpaces.
    * editing/SelectionController.cpp:
    (WebCore::SelectionController::paintCaret):
    * html/canvas/CanvasRenderingContext2D.cpp:
    (WebCore::CanvasRenderingContext2D::drawTextInternal):
    * html/canvas/CanvasStyle.cpp:
    (WebCore::CanvasStyle::applyStrokeColor):
    (WebCore::CanvasStyle::applyFillColor):
    * inspector/InspectorController.cpp:
    (WebCore::drawOutlinedQuad):
    * page/FrameView.cpp:
    (WebCore::FrameView::paintContents):
    * platform/ScrollbarTheme.h:
    (WebCore::ScrollbarTheme::paintScrollCorner):
    * platform/ScrollbarThemeComposite.cpp:
    (WebCore::ScrollbarThemeComposite::paintScrollCorner):
    * platform/graphics/Image.cpp:
    (WebCore::Image::fillWithSolidColor):
    * platform/graphics/mac/FontMac.mm:
    (WebCore::Font::drawGlyphs):
    * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
    (WebCore::MediaPlayerPrivate::paint):
    * rendering/EllipsisBox.cpp:
    (WebCore::EllipsisBox::paint):
    * rendering/InlineFlowBox.cpp:
    (WebCore::InlineFlowBox::paintTextDecorations):
    * rendering/InlineTextBox.cpp:
    (WebCore::updateGraphicsContext):
    (WebCore::paintTextWithShadows):
    (WebCore::InlineTextBox::paint):
    (WebCore::InlineTextBox::paintSelection):
    (WebCore::InlineTextBox::paintCompositionBackground):
    (WebCore::InlineTextBox::paintDecoration):
    (WebCore::InlineTextBox::paintTextMatchMarker):
    (WebCore::InlineTextBox::paintCompositionUnderline):
    * rendering/InlineTextBox.h:
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::fillHorizontalSelectionGap):
    (WebCore::RenderBlock::fillVerticalSelectionGap):
    (WebCore::RenderBlock::fillLeftSelectionGap):
    (WebCore::RenderBlock::fillRightSelectionGap):
    * rendering/RenderBoxModelObject.cpp:
    (WebCore::RenderBoxModelObject::paintFillLayerExtended):
    (WebCore::RenderBoxModelObject::paintBoxShadow):
    * rendering/RenderFileUploadControl.cpp:
    (WebCore::RenderFileUploadControl::paintObject):
    * rendering/RenderFrameSet.cpp:
    (WebCore::RenderFrameSet::paintColumnBorder):
    (WebCore::RenderFrameSet::paintRowBorder):
    * rendering/RenderImage.cpp:
    (WebCore::RenderImage::paintReplaced):
    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::paintScrollCorner):
    (WebCore::RenderLayer::paintResizer):
    * rendering/RenderListBox.cpp:
    (WebCore::RenderListBox::paintItemForeground):
    (WebCore::RenderListBox::paintItemBackground):
    * rendering/RenderListMarker.cpp:
    (WebCore::RenderListMarker::paint):
    * rendering/RenderObject.cpp:
    (WebCore::RenderObject::drawLineForBoxSide):
    (WebCore::RenderObject::drawArcForBoxSide):
    * rendering/RenderReplaced.cpp:
    (WebCore::RenderReplaced::paint):
    * rendering/RenderScrollbarTheme.cpp:
    (WebCore::RenderScrollbarTheme::paintScrollCorner):
    * rendering/RenderThemeMac.mm:
    (WebCore::RenderThemeMac::paintMenuListButton):
    * rendering/RenderView.cpp:
    (WebCore::RenderView::paintBoxDecorations):
    * rendering/RenderWidget.cpp:
    (WebCore::RenderWidget::paint):
    * rendering/SVGInlineTextBox.cpp:
    (WebCore::SVGInlineTextBox::paintSelection):
    * svg/graphics/SVGPaintServerGradient.cpp:
    (WebCore::SVGPaintServerGradient::setup):
    * svg/graphics/SVGPaintServerSolid.cpp:
    (WebCore::SVGPaintServerSolid::setup):
    
    WebKit/mac: Small WebKit part of:
    Fix for <rdar://problem/7059710>
    -and corresponding-
    https://bugs.webkit.org/show_bug.cgi?id=31196 Implement -webkit-
    color-correction for CSS colors
    
    Reviewed by Darin Adler.
    
    * Misc/WebKitNSStringExtras.mm:
    (-[NSString _web_drawAtPoint:font:textColor:]): setFillColor now
    requires callers to pass a ColorSpace.
    
    LayoutTests: Tests for <rdar://problem/7059710>
    -and corresponding-
    https://bugs.webkit.org/show_bug.cgi?id=31196 Implement -webkit-
    color-correction for CSS colors
    
    Reviewed by Darin Adler.
    
    New tests.
    * fast/css/color-correction-backgrounds-and-text.html: Added.
    * fast/css/color-correction-on-backgrounds.html: Added.
    * fast/css/color-correction-on-text.html: Added.
    * fast/css/color-correction.html: Added.
    * fast/css/parsing-color-correction-expected.txt: Added.
    * fast/css/parsing-color-correction.html: Added.
    * fast/css/resources/parsing-color-correction.js: Added.
    (test):
    * fast/css/resources/purple-srgb.png: Added.
    * platform/mac/fast/css/color-correction-backgrounds-and-text-expected.checksum: Added.
    * platform/mac/fast/css/color-correction-backgrounds-and-text-expected.png: Added.
    * platform/mac/fast/css/color-correction-backgrounds-and-text-expected.txt: Added.
    * platform/mac/fast/css/color-correction-expected.checksum: Added.
    * platform/mac/fast/css/color-correction-expected.png: Added.
    * platform/mac/fast/css/color-correction-expected.txt: Added.
    * platform/mac/fast/css/color-correction-on-backgrounds-expected.checksum: Added.
    * platform/mac/fast/css/color-correction-on-backgrounds-expected.png: Added.
    * platform/mac/fast/css/color-correction-on-backgrounds-expected.txt: Added.
    * platform/mac/fast/css/color-correction-on-text-expected.checksum: Added.
    * platform/mac/fast/css/color-correction-on-text-expected.png: Added.
    * platform/mac/fast/css/color-correction-on-text-expected.txt: Added.
    
    New and improved results.
    * platform/mac/fast/css/getComputedStyle/computed-style-expected.txt:
    * platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
    * svg/css/getComputedStyle-basic-expected.txt:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50760 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6b30c71..b0ebd94 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,40 @@
+2009-11-10  Beth Dakin  <bdakin at apple.com>
+
+        Reviewed by Darin Adler.
+
+        Tests for <rdar://problem/7059710> 
+        -and corresponding-
+        https://bugs.webkit.org/show_bug.cgi?id=31196 Implement -webkit-
+        color-correction for CSS colors
+
+        New tests.
+        * fast/css/color-correction-backgrounds-and-text.html: Added.
+        * fast/css/color-correction-on-backgrounds.html: Added.
+        * fast/css/color-correction-on-text.html: Added.
+        * fast/css/color-correction.html: Added.
+        * fast/css/parsing-color-correction-expected.txt: Added.
+        * fast/css/parsing-color-correction.html: Added.
+        * fast/css/resources/parsing-color-correction.js: Added.
+        (test):
+        * fast/css/resources/purple-srgb.png: Added.
+        * platform/mac/fast/css/color-correction-backgrounds-and-text-expected.checksum: Added.
+        * platform/mac/fast/css/color-correction-backgrounds-and-text-expected.png: Added.
+        * platform/mac/fast/css/color-correction-backgrounds-and-text-expected.txt: Added.
+        * platform/mac/fast/css/color-correction-expected.checksum: Added.
+        * platform/mac/fast/css/color-correction-expected.png: Added.
+        * platform/mac/fast/css/color-correction-expected.txt: Added.
+        * platform/mac/fast/css/color-correction-on-backgrounds-expected.checksum: Added.
+        * platform/mac/fast/css/color-correction-on-backgrounds-expected.png: Added.
+        * platform/mac/fast/css/color-correction-on-backgrounds-expected.txt: Added.
+        * platform/mac/fast/css/color-correction-on-text-expected.checksum: Added.
+        * platform/mac/fast/css/color-correction-on-text-expected.png: Added.
+        * platform/mac/fast/css/color-correction-on-text-expected.txt: Added.
+
+        New and improved results.
+        * platform/mac/fast/css/getComputedStyle/computed-style-expected.txt:
+        * platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+        * svg/css/getComputedStyle-basic-expected.txt:
+
 2009-11-10  Gustavo Noronha Silva  <gustavo.noronha at collabora.co.uk>
 
         Unreviewed. Skip new tests.
diff --git a/LayoutTests/fast/css/color-correction-backgrounds-and-text.html b/LayoutTests/fast/css/color-correction-backgrounds-and-text.html
new file mode 100644
index 0000000..80f4ae5
--- /dev/null
+++ b/LayoutTests/fast/css/color-correction-backgrounds-and-text.html
@@ -0,0 +1,38 @@
+<html>
+<style>
+    .text {
+        color:green;
+        font-size:150px;
+        font-weight:bold;
+    }
+    
+    .container {
+        background-color:green; 
+        width:200px; 
+        height:200px;
+    }
+</style>
+<body>
+
+<p>This container has no color correction, and neither does the text inside, so it will not be visible since both are green and uncorrected.</p>
+<div class="container">
+    <span class="text">G</span>
+</div>
+
+<p>This container has sRGB color correction specified, and so does the text inside, so the text will not be visible since both are green and corrected.</p>
+<div class="container" style="-webkit-color-correction:sRGB;">
+    <span class="text" style="-webkit-color-correction:sRGB;">G</span>
+</div>
+
+<p>This container has sRGB color correction specified. The text inside does not have the property specified, but the text inherits the container's style, so the text will not be visible since both are green and corrected.</p>
+<div class="container" style="-webkit-color-correction:sRGB;">
+    <span class="text">G</span>
+</div>
+
+<p>This container has default color-correction specified, and the text has sRGB color correction specified. This text is visible even though both are green since the text is corrected and the container is not.</p>
+<div class="container" style="-webkit-color-correction:default;">
+    <span class="text" style="-webkit-color-correction:sRGB;">G</span>
+</div>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/css/color-correction-on-backgrounds.html b/LayoutTests/fast/css/color-correction-on-backgrounds.html
new file mode 100644
index 0000000..da04cd5
--- /dev/null
+++ b/LayoutTests/fast/css/color-correction-on-backgrounds.html
@@ -0,0 +1,14 @@
+<html>
+<body>
+
+<p>These should match:</p>
+<div style="background-color:#560063; width:100px; height:100px; -webkit-color-correction:sRGB; float:left;"></div>
+<img src="resources/purple-srgb.png"/>
+
+<br/>
+<p>These should not match (at this time):</p>
+<div style="background-color:#560063; width:100px; height:100px; -webkit-color-correction:default; float:left;"></div>
+<img src="resources/purple-srgb.png"/>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/css/color-correction-on-text.html b/LayoutTests/fast/css/color-correction-on-text.html
new file mode 100644
index 0000000..2baea3c
--- /dev/null
+++ b/LayoutTests/fast/css/color-correction-on-text.html
@@ -0,0 +1,19 @@
+<html>
+<style>
+    .text {
+        color:green;
+        font-size:150px;
+        font-weight:bold;
+    }
+</style>
+<body>
+
+    <p>The distinction below is subtle, but the middle "H" is color-corrected, and the first and last are not. 
+    </p>
+
+    <span class="text">H</span>
+    <span class="text" style="-webkit-color-correction:sRGB;">H</span>
+    <span class="text">H</span>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/css/color-correction.html b/LayoutTests/fast/css/color-correction.html
new file mode 100644
index 0000000..8dd6e5d
--- /dev/null
+++ b/LayoutTests/fast/css/color-correction.html
@@ -0,0 +1,13 @@
+<html>
+<style>
+.purple {
+    border: solid 20px #560063;
+}
+</style>
+<body>
+<p>This test demonstrates -webkit-color-correction. Below are 3 images with 20 pixel borders. The images are all the same -- purple with an sRGB color profile. The border is the same CSS color for all three images. The first image has no special CSS. The second has -webkit-color-correction set to default, so it matches the first image. And the third has -webkit-color-correction set to sRGB. This color-corrects the purple border from the sRGB color space, and the result is that the border and the image match.</p>
+<img src="resources/purple-srgb.png" class="purple" />
+<img src="resources/purple-srgb.png" class="purple" style="-webkit-color-correction: default;"/>
+<img src="resources/purple-srgb.png" class="purple" style="-webkit-color-correction: sRGB;"/>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/parsing-color-correction-expected.txt b/LayoutTests/fast/css/parsing-color-correction-expected.txt
new file mode 100644
index 0000000..f6282d4
--- /dev/null
+++ b/LayoutTests/fast/css/parsing-color-correction-expected.txt
@@ -0,0 +1,15 @@
+This tests checks that all of the input values for -webkit-color-correction parse correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS test("-webkit-color-correction: default;") is "default"
+PASS test("-webkit-color-correction: sRGB;") is "srgb"
+PASS test("-webkit-color-correction: srgb;") is "srgb"
+PASS test("-webkit-color-correction: apple;") is null
+PASS test("-webkit-color-correction: 15;") is null
+PASS test("-webkit-color-correction: auto;") is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/parsing-color-correction.html b/LayoutTests/fast/css/parsing-color-correction.html
new file mode 100644
index 0000000..faf2370
--- /dev/null
+++ b/LayoutTests/fast/css/parsing-color-correction.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<style type="text/css"></style>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/parsing-color-correction.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/resources/parsing-color-correction.js b/LayoutTests/fast/css/resources/parsing-color-correction.js
new file mode 100644
index 0000000..7fe2b46
--- /dev/null
+++ b/LayoutTests/fast/css/resources/parsing-color-correction.js
@@ -0,0 +1,22 @@
+description("This tests checks that all of the input values for -webkit-color-correction parse correctly.");
+
+function test(value)
+{
+    var div = document.createElement("div");
+    div.setAttribute("style", value);
+    document.body.appendChild(div);
+    
+    var result = div.style.getPropertyValue("-webkit-color-correction");
+    document.body.removeChild(div);
+    return result;
+}
+
+shouldBe('test("-webkit-color-correction: default;")', '"default"');
+shouldBe('test("-webkit-color-correction: sRGB;")', '"srgb"');
+shouldBe('test("-webkit-color-correction: srgb;")', '"srgb"');
+
+shouldBe('test("-webkit-color-correction: apple;")', 'null');
+shouldBe('test("-webkit-color-correction: 15;")', 'null');
+shouldBe('test("-webkit-color-correction: auto;")', 'null');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/css/resources/purple-srgb.png b/LayoutTests/fast/css/resources/purple-srgb.png
new file mode 100644
index 0000000..2dd28fc
Binary files /dev/null and b/LayoutTests/fast/css/resources/purple-srgb.png differ
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.checksum b/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.checksum
new file mode 100644
index 0000000..d9d58b9
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.checksum
@@ -0,0 +1 @@
+ce9409357b74f5781f7e57ee55e2059a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.png b/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.png
new file mode 100644
index 0000000..d6bee04
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.txt b/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.txt
new file mode 100644
index 0000000..97a53ba
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/color-correction-backgrounds-and-text-expected.txt
@@ -0,0 +1,41 @@
+layer at (0,0) size 785x1072
+  RenderView at (0,0) size 785x600
+layer at (0,0) size 785x1072
+  RenderBlock {HTML} at (0,0) size 785x1072
+    RenderBody {BODY} at (8,8) size 769x1056
+      RenderBlock {P} at (0,0) size 769x36
+        RenderText {#text} at (0,0) size 747x36
+          text run at (0,0) width 747: "This container has no color correction, and neither does the text inside, so it will not be visible since both are green and"
+          text run at (0,18) width 78: "uncorrected."
+      RenderBlock {DIV} at (0,52) size 200x200 [bgcolor=#008000]
+        RenderInline {SPAN} at (0,0) size 117x174 [color=#008000]
+          RenderText {#text} at (0,0) size 117x174
+            text run at (0,0) width 117: "G"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {P} at (0,268) size 769x36
+        RenderText {#text} at (0,0) size 751x36
+          text run at (0,0) width 751: "This container has sRGB color correction specified, and so does the text inside, so the text will not be visible since both"
+          text run at (0,18) width 151: "are green and corrected."
+      RenderBlock {DIV} at (0,320) size 200x200 [bgcolor=#008000]
+        RenderInline {SPAN} at (0,0) size 117x174 [color=#008000]
+          RenderText {#text} at (0,0) size 117x174
+            text run at (0,0) width 117: "G"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {P} at (0,536) size 769x36
+        RenderText {#text} at (0,0) size 732x36
+          text run at (0,0) width 732: "This container has sRGB color correction specified. The text inside does not have the property specified, but the text"
+          text run at (0,18) width 584: "inherits the container's style, so the text will not be visible since both are green and corrected."
+      RenderBlock {DIV} at (0,588) size 200x200 [bgcolor=#008000]
+        RenderInline {SPAN} at (0,0) size 117x174 [color=#008000]
+          RenderText {#text} at (0,0) size 117x174
+            text run at (0,0) width 117: "G"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {P} at (0,804) size 769x36
+        RenderText {#text} at (0,0) size 761x36
+          text run at (0,0) width 761: "This container has default color-correction specified, and the text has sRGB color correction specified. This text is visible"
+          text run at (0,18) width 488: "even though both are green since the text is corrected and the container is not."
+      RenderBlock {DIV} at (0,856) size 200x200 [bgcolor=#008000]
+        RenderInline {SPAN} at (0,0) size 117x174 [color=#008000]
+          RenderText {#text} at (0,0) size 117x174
+            text run at (0,0) width 117: "G"
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-expected.checksum b/LayoutTests/platform/mac/fast/css/color-correction-expected.checksum
new file mode 100644
index 0000000..81ab21a
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/color-correction-expected.checksum
@@ -0,0 +1 @@
+11cf0167207de95eefba08959747046f
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-expected.png b/LayoutTests/platform/mac/fast/css/color-correction-expected.png
new file mode 100644
index 0000000..a88dfd1
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/color-correction-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-expected.txt b/LayoutTests/platform/mac/fast/css/color-correction-expected.txt
new file mode 100644
index 0000000..5204b85
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/color-correction-expected.txt
@@ -0,0 +1,23 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x90
+        RenderText {#text} at (0,0) size 769x90
+          text run at (0,0) width 763: "This test demonstrates -webkit-color-correction. Below are 3 images with 20 pixel borders. The images are all the same --"
+          text run at (0,18) width 755: "purple with an sRGB color profile. The border is the same CSS color for all three images. The first image has no special"
+          text run at (0,36) width 769: "CSS. The second has -webkit-color-correction set to default, so it matches the first image. And the third has -webkit-color-"
+          text run at (0,54) width 759: "correction set to sRGB. This color-corrects the purple border from the sRGB color space, and the result is that the border"
+          text run at (0,72) width 134: "and the image match."
+      RenderBlock (anonymous) at (0,106) size 784x144
+        RenderImage {IMG} at (0,0) size 140x140 [border: (20px solid #560063)]
+        RenderText {#text} at (140,126) size 4x18
+          text run at (140,126) width 4: " "
+        RenderImage {IMG} at (144,0) size 140x140 [border: (20px solid #560063)]
+        RenderText {#text} at (284,126) size 4x18
+          text run at (284,126) width 4: " "
+        RenderImage {IMG} at (288,0) size 140x140 [border: (20px solid #560063)]
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.checksum b/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.checksum
new file mode 100644
index 0000000..7787705
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.checksum
@@ -0,0 +1 @@
+1eca5217d6000aafafbe1bddf64b5eeb
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.png b/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.png
new file mode 100644
index 0000000..eff9ac0
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.txt b/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.txt
new file mode 100644
index 0000000..da30bbe
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/color-correction-on-backgrounds-expected.txt
@@ -0,0 +1,23 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 130x18
+          text run at (0,0) width 130: "These should match:"
+      RenderBlock (floating) {DIV} at (0,34) size 100x100 [bgcolor=#560063]
+      RenderBlock (anonymous) at (0,34) size 784x104
+        RenderImage {IMG} at (100,0) size 100x100
+        RenderText {#text} at (200,86) size 4x18
+          text run at (200,86) width 4: " "
+        RenderBR {BR} at (0,0) size 0x0
+      RenderBlock {P} at (0,154) size 784x18
+        RenderText {#text} at (0,0) size 236x18
+          text run at (0,0) width 236: "These should not match (at this time):"
+      RenderBlock (floating) {DIV} at (0,188) size 100x100 [bgcolor=#560063]
+      RenderBlock (anonymous) at (0,188) size 784x100
+        RenderImage {IMG} at (100,0) size 100x100
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.checksum b/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.checksum
new file mode 100644
index 0000000..98de84a
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.checksum
@@ -0,0 +1 @@
+583bc3c97f662fc7fb4aee363d36b034
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.png b/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.png
new file mode 100644
index 0000000..a81b2c2
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.txt b/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.txt
new file mode 100644
index 0000000..d59005e
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/color-correction-on-text-expected.txt
@@ -0,0 +1,25 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 618x18
+          text run at (0,0) width 618: "The distinction below is subtle, but the middle \"H\" is color-corrected, and the first and last are not."
+      RenderBlock (anonymous) at (0,34) size 784x174
+        RenderInline {SPAN} at (0,0) size 117x174 [color=#008000]
+          RenderText {#text} at (0,0) size 117x174
+            text run at (0,0) width 117: "H"
+        RenderText {#text} at (117,122) size 4x18
+          text run at (117,122) width 4: " "
+        RenderInline {SPAN} at (0,0) size 117x174 [color=#008000]
+          RenderText {#text} at (121,0) size 117x174
+            text run at (121,0) width 117: "H"
+        RenderText {#text} at (238,122) size 4x18
+          text run at (238,122) width 4: " "
+        RenderInline {SPAN} at (0,0) size 117x174 [color=#008000]
+          RenderText {#text} at (242,0) size 117x174
+            text run at (242,0) width 117: "H"
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-expected.txt b/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-expected.txt
index 5fddcd2..ed29dc9 100644
--- a/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-expected.txt
+++ b/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-expected.txt
@@ -121,6 +121,7 @@ zoom: 1;
 -webkit-box-reflect: none;
 -webkit-box-shadow: none;
 -webkit-box-sizing: content-box;
+-webkit-color-correction: default;
 -webkit-column-break-after: auto;
 -webkit-column-break-before: auto;
 -webkit-column-break-inside: auto;
diff --git a/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt b/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
index 09b1c92..8328936 100644
--- a/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
+++ b/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
@@ -120,6 +120,7 @@ Computed style of an element whose parent's 'display' value is 'none':
     -webkit-box-reflect: none
     -webkit-box-shadow: none
     -webkit-box-sizing: content-box
+    -webkit-color-correction: default
     -webkit-column-break-after: auto
     -webkit-column-break-before: auto
     -webkit-column-break-inside: auto
diff --git a/LayoutTests/svg/css/getComputedStyle-basic-expected.txt b/LayoutTests/svg/css/getComputedStyle-basic-expected.txt
index 58d726f..439b215 100644
--- a/LayoutTests/svg/css/getComputedStyle-basic-expected.txt
+++ b/LayoutTests/svg/css/getComputedStyle-basic-expected.txt
@@ -240,6 +240,8 @@ rect: style.getPropertyValue(-webkit-box-shadow) : none
 rect: style.getPropertyCSSValue(-webkit-box-shadow) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-box-sizing) : content-box
 rect: style.getPropertyCSSValue(-webkit-box-sizing) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(-webkit-color-correction) : default
+rect: style.getPropertyCSSValue(-webkit-color-correction) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-column-break-after) : auto
 rect: style.getPropertyCSSValue(-webkit-column-break-after) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-column-break-before) : auto
@@ -652,6 +654,8 @@ g: style.getPropertyValue(-webkit-box-shadow) : none
 g: style.getPropertyCSSValue(-webkit-box-shadow) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-box-sizing) : content-box
 g: style.getPropertyCSSValue(-webkit-box-sizing) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(-webkit-color-correction) : default
+g: style.getPropertyCSSValue(-webkit-color-correction) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-column-break-after) : auto
 g: style.getPropertyCSSValue(-webkit-column-break-after) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-column-break-before) : auto
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b8ef948..a3305f0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,234 @@
+2009-11-10  Beth Dakin  <bdakin at apple.com>
+
+        Reviewed by Darin Adler.
+
+        Fix for <rdar://problem/7059710> 
+        -and corresponding-
+        https://bugs.webkit.org/show_bug.cgi?id=31196 Implement -webkit-
+        color-correction for CSS colors
+
+        New exported symbol for GraphicsContext::fillColor() which now 
+        accepts a ColorSpace as an optional parameter.
+        * WebCore.base.exp:
+
+        Added a new file, ColorSpace.h, to define the ColorSpace enum.
+        * WebCore.xcodeproj/project.pbxproj:
+
+        Computed Style for -webkit-color-correction
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+
+        Parse -webkit-color-correction
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+
+       Map CSS identifiers to the appropriate values of the ColorSpace enum
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator ColorSpace):
+
+        New property -webkit-color-correction
+        * css/CSSPropertyNames.in:
+
+        Map -webkit-color-correction into the RenderStyle.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+
+        Add new value sRGB.
+        * css/CSSValueKeywords.in:
+
+        Comment out the reference to sRGB since it will now be inherited as 
+        a value from CSSValueKeywords.
+        * css/SVGCSSValueKeywords.in:
+
+        Definition of the ColorSpace enum.
+        * platform/graphics/ColorSpace.h: Added.
+        (WebCore::):
+
+        These functions all now take a ColorSpace as a parameter.
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::setStrokeColor):
+        (WebCore::GraphicsContext::setFillColor):
+        (WebCore::GraphicsContext::drawHighlightForText):
+
+        Return the appropriate ColorSpace.
+        (WebCore::GraphicsContext::strokeColorSpace):
+        (WebCore::GraphicsContext::fillColorSpace):
+
+        These functions all call other functions which require a ColorSpace 
+        as a parameter.
+        (WebCore::GraphicsContext::setStrokePattern):
+        (WebCore::GraphicsContext::setFillPattern):
+        (WebCore::GraphicsContext::setStrokeGradient):
+        (WebCore::GraphicsContext::setFillGradient):
+
+        All of the GraphicsContext functions that take a Color should now 
+        also take a ColorSpace.
+        * platform/graphics/GraphicsContext.h:
+
+        Added new member variables stokeColorSpace and fillColorSpace.
+        * platform/graphics/GraphicsContextPrivate.h:
+        (WebCore::GraphicsContextState::GraphicsContextState):
+
+        Attempt to keep the Cairo port building with all of the massive 
+        changes to GraphicsContext.        
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::setPlatformFillColor):
+        (WebCore::GraphicsContext::setPlatformStrokeColor):
+        (WebCore::GraphicsContext::fillRoundedRect):
+
+        
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::sRGBColorSpaceRef): New static function that returns a 
+        CGColorSpaceRef for the sRGB color space.
+        (WebCore::deviceRGBColorSpaceRef): New static function that returns 
+        a CGColorSpaceRef for the device RGB color space.
+
+        (WebCore::setCGFillColor): Now takes a ColorSpace parameter and 
+        sets the fill color to the specified color in the given ColorSpace.
+        (WebCore::setCGStrokeColor): Same, but for stroke.
+
+        (WebCore::setCGFillColorSpace): New static to set the 
+        CGFillColorSpace to the given ColorSpace
+        (WebCore::setCGStrokeColorSpace): Same, but for stroke.
+
+        Send ColorSpaces when appropriate, set ColorSpaces when 
+        appropriate, and check ColorSpaces when appropriate.
+        (WebCore::GraphicsContext::GraphicsContext):
+        (WebCore::GraphicsContext::drawRect):
+        (WebCore::GraphicsContext::drawLine):
+        (WebCore::GraphicsContext::fillPath):
+        (WebCore::GraphicsContext::strokePath):
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::strokeRect):
+        (WebCore::GraphicsContext::drawLineForText):
+        (WebCore::GraphicsContext::setPlatformStrokeColor):
+        (WebCore::GraphicsContext::setPlatformFillColor):
+
+        Attempt to keep Haiku building.
+        * platform/graphics/haiku/GraphicsContextHaiku.cpp:
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::setPlatformStrokeColor):
+        (WebCore::GraphicsContext::setPlatformFillColor):
+
+        Attempt to keep QT building.
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::setPlatformStrokeColor):
+        (WebCore::GraphicsContext::setPlatformFillColor):
+
+        Attempt to keep Wince building.
+        * platform/graphics/wince/GraphicsContextWince.cpp:
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::setPlatformFillColor):
+        (WebCore::GraphicsContext::setPlatformStrokeColor):
+        (WebCore::GraphicsContext::clearRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::setPlatformShadow):
+
+        Attempt to keep WX building.
+        * platform/graphics/wx/GraphicsContextWx.cpp:
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::setPlatformStrokeColor):
+        (WebCore::GraphicsContext::setPlatformFillColor):
+
+        Added functions colorSpace() and setColorSpace()
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::colorSpace):
+        (WebCore::InheritedFlags::setColorSpace):
+
+        The ColorSpace is stored here.
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+        (WebCore::StyleRareInheritedData::operator==):
+        * rendering/style/StyleRareInheritedData.h:
+
+        All of these call sites call GraphicsContext functions which now 
+        require ColorSpaces.
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::paintCaret):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::drawTextInternal):
+        * html/canvas/CanvasStyle.cpp:
+        (WebCore::CanvasStyle::applyStrokeColor):
+        (WebCore::CanvasStyle::applyFillColor):
+        * inspector/InspectorController.cpp:
+        (WebCore::drawOutlinedQuad):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::paintContents):
+        * platform/ScrollbarTheme.h:
+        (WebCore::ScrollbarTheme::paintScrollCorner):
+        * platform/ScrollbarThemeComposite.cpp:
+        (WebCore::ScrollbarThemeComposite::paintScrollCorner):
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::fillWithSolidColor):
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::Font::drawGlyphs):
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivate::paint):
+        * rendering/EllipsisBox.cpp:
+        (WebCore::EllipsisBox::paint):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::paintTextDecorations):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::updateGraphicsContext):
+        (WebCore::paintTextWithShadows):
+        (WebCore::InlineTextBox::paint):
+        (WebCore::InlineTextBox::paintSelection):
+        (WebCore::InlineTextBox::paintCompositionBackground):
+        (WebCore::InlineTextBox::paintDecoration):
+        (WebCore::InlineTextBox::paintTextMatchMarker):
+        (WebCore::InlineTextBox::paintCompositionUnderline):
+        * rendering/InlineTextBox.h:
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::fillHorizontalSelectionGap):
+        (WebCore::RenderBlock::fillVerticalSelectionGap):
+        (WebCore::RenderBlock::fillLeftSelectionGap):
+        (WebCore::RenderBlock::fillRightSelectionGap):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        (WebCore::RenderBoxModelObject::paintBoxShadow):
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::RenderFileUploadControl::paintObject):
+        * rendering/RenderFrameSet.cpp:
+        (WebCore::RenderFrameSet::paintColumnBorder):
+        (WebCore::RenderFrameSet::paintRowBorder):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::paintReplaced):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::paintScrollCorner):
+        (WebCore::RenderLayer::paintResizer):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::paintItemForeground):
+        (WebCore::RenderListBox::paintItemBackground):
+        * rendering/RenderListMarker.cpp:
+        (WebCore::RenderListMarker::paint):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::drawLineForBoxSide):
+        (WebCore::RenderObject::drawArcForBoxSide):
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::paint):
+        * rendering/RenderScrollbarTheme.cpp:
+        (WebCore::RenderScrollbarTheme::paintScrollCorner):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintMenuListButton):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::paintBoxDecorations):
+        * rendering/RenderWidget.cpp:
+        (WebCore::RenderWidget::paint):
+        * rendering/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paintSelection):
+        * svg/graphics/SVGPaintServerGradient.cpp:
+        (WebCore::SVGPaintServerGradient::setup):
+        * svg/graphics/SVGPaintServerSolid.cpp:
+        (WebCore::SVGPaintServerSolid::setup):
+
 2009-11-10  Keishi Hattori  <casey.hattori at gmail.com>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index 82f3a2b..b4b148f 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -343,7 +343,7 @@ __ZN7WebCore15FocusController15setFocusedFrameEN3WTF10PassRefPtrINS_5FrameEEE
 __ZN7WebCore15FocusController15setInitialFocusENS_14FocusDirectionEPNS_13KeyboardEventE
 __ZN7WebCore15FocusController18focusedOrMainFrameEv
 __ZN7WebCore15FocusController9setActiveEb
-__ZN7WebCore15GraphicsContext12setFillColorERKNS_5ColorE
+__ZN7WebCore15GraphicsContext12setFillColorERKNS_5ColorENS_10ColorSpaceE
 __ZN7WebCore15GraphicsContextC1EP9CGContext
 __ZN7WebCore15GraphicsContextD1Ev
 __ZN7WebCore15JSDOMWindowBase18commonJSGlobalDataEv
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 4659398..92a3c65 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -2246,6 +2246,7 @@
 		938192030F87E1E600D5352A /* BinaryPropertyList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 938192020F87E1E600D5352A /* BinaryPropertyList.cpp */; };
 		938192050F87E1EC00D5352A /* BinaryPropertyList.h in Headers */ = {isa = PBXBuildFile; fileRef = 938192040F87E1EC00D5352A /* BinaryPropertyList.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9382AAB40D8C386100F357A6 /* NodeWithIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 9382AAB10D8C386100F357A6 /* NodeWithIndex.h */; };
+		9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 9382DF5710A8D5C900925652 /* ColorSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		93831B570D087D6000E5C984 /* ExceptionCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93831B560D087D6000E5C984 /* ExceptionCode.cpp */; };
 		938E65F109F09840008A48EC /* JSHTMLElementWrapperFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */; };
 		938E65F709F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */; };
@@ -7499,6 +7500,7 @@
 		938192020F87E1E600D5352A /* BinaryPropertyList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinaryPropertyList.cpp; sourceTree = "<group>"; };
 		938192040F87E1EC00D5352A /* BinaryPropertyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinaryPropertyList.h; sourceTree = "<group>"; };
 		9382AAB10D8C386100F357A6 /* NodeWithIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeWithIndex.h; sourceTree = "<group>"; };
+		9382DF5710A8D5C900925652 /* ColorSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorSpace.h; sourceTree = "<group>"; };
 		93831B560D087D6000E5C984 /* ExceptionCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionCode.cpp; sourceTree = "<group>"; };
 		938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLElementWrapperFactory.h; sourceTree = "<group>"; };
 		938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElementWrapperFactory.cpp; sourceTree = "<group>"; };
@@ -14067,6 +14069,7 @@
 				A89943260B42338700D7C802 /* BitmapImage.h */,
 				B27535380B053814002CE64F /* Color.cpp */,
 				B27535390B053814002CE64F /* Color.h */,
+				9382DF5710A8D5C900925652 /* ColorSpace.h */,
 				A8CB41020E85B8A50032C4F0 /* DashArray.h */,
 				B275353A0B053814002CE64F /* FloatPoint.cpp */,
 				B275353B0B053814002CE64F /* FloatPoint.h */,
@@ -18099,6 +18102,7 @@
 				1479FAF0109AE37500DED655 /* RenderRubyBase.h in Headers */,
 				1479FAF2109AE37500DED655 /* RenderRubyRun.h in Headers */,
 				1479FAF4109AE37500DED655 /* RenderRubyText.h in Headers */,
+				9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp
index b8769f9..28a57c4 100644
--- a/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -173,6 +173,7 @@ static const int computedProperties[] = {
     CSSPropertyWebkitBoxReflect,
     CSSPropertyWebkitBoxShadow,
     CSSPropertyWebkitBoxSizing,
+    CSSPropertyWebkitColorCorrection,
     CSSPropertyWebkitColumnBreakAfter,
     CSSPropertyWebkitColumnBreakBefore,
     CSSPropertyWebkitColumnBreakInside,
@@ -1348,6 +1349,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return getTimingFunctionValue(style->transitions());
         case CSSPropertyPointerEvents:
             return CSSPrimitiveValue::create(style->pointerEvents());
+        case CSSPropertyWebkitColorCorrection:
+            return CSSPrimitiveValue::create(style->colorSpace());
 
         /* Shorthand properties, currently not supported see bug 13658*/
         case CSSPropertyBackground:
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index 6024a5b..897fdd8 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -1245,6 +1245,9 @@ bool CSSParser::parseValue(int propId, bool important)
     case CSSPropertyWebkitBoxSizing:
         valid_primitive = id == CSSValueBorderBox || id == CSSValueContentBox;
         break;
+    case CSSPropertyWebkitColorCorrection:
+        valid_primitive = id == CSSValueSrgb || id == CSSValueDefault;
+        break;
     case CSSPropertyWebkitMarquee: {
         const int properties[5] = { CSSPropertyWebkitMarqueeDirection, CSSPropertyWebkitMarqueeIncrement,
                                     CSSPropertyWebkitMarqueeRepetition,
diff --git a/WebCore/css/CSSPrimitiveValueMappings.h b/WebCore/css/CSSPrimitiveValueMappings.h
index 6f89df9..b690b22 100644
--- a/WebCore/css/CSSPrimitiveValueMappings.h
+++ b/WebCore/css/CSSPrimitiveValueMappings.h
@@ -28,6 +28,7 @@
 #ifndef CSSPrimitiveValueMappings_h
 #define CSSPrimitiveValueMappings_h
 
+#include "ColorSpace.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSValueKeywords.h"
 #include "FontSmoothingMode.h"
@@ -1881,6 +1882,32 @@ template<> inline CSSPrimitiveValue::operator TextRenderingMode() const
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColorSpace space)
+    : m_type(CSS_IDENT)
+{
+    switch (space) {
+        case DeviceColorSpace:
+            m_value.ident = CSSValueDefault;
+            break;
+        case sRGBColorSpace:
+            m_value.ident = CSSValueSrgb;
+            break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator ColorSpace() const
+{
+    switch (m_value.ident) {
+        case CSSValueDefault:
+            return DeviceColorSpace;
+        case CSSValueSrgb:
+            return sRGBColorSpace;
+        default:
+            ASSERT_NOT_REACHED();
+            return DeviceColorSpace;
+    }
+}
+
 #if ENABLE(SVG)
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e)
diff --git a/WebCore/css/CSSPropertyNames.in b/WebCore/css/CSSPropertyNames.in
index 48a18e7..9695d0b 100644
--- a/WebCore/css/CSSPropertyNames.in
+++ b/WebCore/css/CSSPropertyNames.in
@@ -185,6 +185,7 @@ zoom
 -webkit-box-reflect
 -webkit-box-shadow
 -webkit-box-sizing
+-webkit-color-correction
 -webkit-column-break-after
 -webkit-column-break-before
 -webkit-column-break-inside
diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp
index 364b875..2ed58e5 100644
--- a/WebCore/css/CSSStyleSelector.cpp
+++ b/WebCore/css/CSSStyleSelector.cpp
@@ -5267,6 +5267,17 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         m_style->setPointerEvents(*primitiveValue);
         return;
     }
+    case CSSPropertyWebkitColorCorrection:
+        if (isInherit) 
+            m_style->setColorSpace(m_parentStyle->colorSpace());
+        else if (isInitial)
+            m_style->setColorSpace(DeviceColorSpace);
+        else {
+            if (!primitiveValue)
+                return;
+            m_style->setColorSpace(*primitiveValue);
+        }
+        return;
     case CSSPropertyInvalid:
         return;
     case CSSPropertyFontStretch:
diff --git a/WebCore/css/CSSValueKeywords.in b/WebCore/css/CSSValueKeywords.in
index 1b7b1d8..ccd5b9d 100644
--- a/WebCore/css/CSSValueKeywords.in
+++ b/WebCore/css/CSSValueKeywords.in
@@ -638,3 +638,7 @@ subpixel-antialiased
 optimizeSpeed
 optimizeLegibility
 geometricPrecision
+
+# -webkit-color-correction
+#default
+sRGB
diff --git a/WebCore/css/SVGCSSValueKeywords.in b/WebCore/css/SVGCSSValueKeywords.in
index 152a68f..91fb57e 100644
--- a/WebCore/css/SVGCSSValueKeywords.in
+++ b/WebCore/css/SVGCSSValueKeywords.in
@@ -183,7 +183,7 @@ new
 # CSS_PROP_STOP_OPACITY
 # CSS_PROP_COLOR_INTERPOLATION
 #auto
-sRGB
+#sRGB
 linearRGB
 
 # CSS_PROP_COLOR_INTERPOLATION_FILTERS
diff --git a/WebCore/editing/SelectionController.cpp b/WebCore/editing/SelectionController.cpp
index 00672f2..af89ccb 100644
--- a/WebCore/editing/SelectionController.cpp
+++ b/WebCore/editing/SelectionController.cpp
@@ -994,11 +994,14 @@ void SelectionController::paintCaret(GraphicsContext* p, int tx, int ty, const I
     IntRect caret = intersection(drawingRect, clipRect);
     if (!caret.isEmpty()) {
         Color caretColor = Color::black;
+        ColorSpace colorSpace = DeviceColorSpace;
         Element* element = rootEditableElement();
-        if (element && element->renderer())
+        if (element && element->renderer()) {
             caretColor = element->renderer()->style()->color();
+            colorSpace = element->renderer()->style()->colorSpace();
+        }
 
-        p->fillRect(caret, caretColor);
+        p->fillRect(caret, caretColor, colorSpace);
     }
 }
 
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index 3341901..f19379b 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -1526,9 +1526,9 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
         GraphicsContext* maskImageContext = maskImage->context();
 
         if (fill)
-            maskImageContext->setFillColor(Color::black);
+            maskImageContext->setFillColor(Color::black, DeviceColorSpace);
         else {
-            maskImageContext->setStrokeColor(Color::black);
+            maskImageContext->setStrokeColor(Color::black, DeviceColorSpace);
             maskImageContext->setStrokeThickness(c->strokeThickness());
         }
 
diff --git a/WebCore/html/canvas/CanvasStyle.cpp b/WebCore/html/canvas/CanvasStyle.cpp
index 946cac7..b893750 100644
--- a/WebCore/html/canvas/CanvasStyle.cpp
+++ b/WebCore/html/canvas/CanvasStyle.cpp
@@ -114,33 +114,33 @@ void CanvasStyle::applyStrokeColor(GraphicsContext* context)
         case ColorString: {
             Color c = Color(m_color);
             if (c.isValid()) {
-                context->setStrokeColor(c.rgb());
+                context->setStrokeColor(c.rgb(), DeviceColorSpace);
                 break;
             }
             RGBA32 color = 0; // default is transparent black
             if (CSSParser::parseColor(color, m_color))
-                context->setStrokeColor(color);
+                context->setStrokeColor(color, DeviceColorSpace);
             break;
         }
         case ColorStringWithAlpha: {
             Color c = Color(m_color);
             if (c.isValid()) {
-                context->setStrokeColor(colorWithOverrideAlpha(c.rgb(), m_alpha));
+                context->setStrokeColor(colorWithOverrideAlpha(c.rgb(), m_alpha), DeviceColorSpace);
                 break;
             }
             RGBA32 color = 0; // default is transparent black
             if (CSSParser::parseColor(color, m_color))
-                context->setStrokeColor(colorWithOverrideAlpha(color, m_alpha));
+                context->setStrokeColor(colorWithOverrideAlpha(color, m_alpha), DeviceColorSpace);
             break;
         }
         case GrayLevel:
             // We're only supporting 255 levels of gray here.  Since this isn't
             // even part of HTML5, I don't expect anyone will care.  If they do
             // we'll make a fancier Color abstraction.
-            context->setStrokeColor(Color(m_grayLevel, m_grayLevel, m_grayLevel, m_alpha));
+            context->setStrokeColor(Color(m_grayLevel, m_grayLevel, m_grayLevel, m_alpha), DeviceColorSpace);
             break;
         case RGBA:
-            context->setStrokeColor(Color(m_red, m_green, m_blue, m_alpha));
+            context->setStrokeColor(Color(m_red, m_green, m_blue, m_alpha), DeviceColorSpace);
             break;
         case CMYKA: {
             // FIXME: Do this through platform-independent GraphicsContext API.
@@ -175,33 +175,33 @@ void CanvasStyle::applyFillColor(GraphicsContext* context)
         case ColorString: {
             Color c = Color(m_color);
             if (c.isValid()) {
-                context->setFillColor(c.rgb());
+                context->setFillColor(c.rgb(), DeviceColorSpace);
                 break;
             }
             RGBA32 rgba = 0; // default is transparent black
             if (CSSParser::parseColor(rgba, m_color))
-                context->setFillColor(rgba);
+                context->setFillColor(rgba, DeviceColorSpace);
             break;
         }
         case ColorStringWithAlpha: {
             Color c = Color(m_color);
             if (c.isValid()) {
-                context->setFillColor(colorWithOverrideAlpha(c.rgb(), m_alpha));
+                context->setFillColor(colorWithOverrideAlpha(c.rgb(), m_alpha), DeviceColorSpace);
                 break;
             }
             RGBA32 color = 0; // default is transparent black
             if (CSSParser::parseColor(color, m_color))
-                context->setFillColor(colorWithOverrideAlpha(color, m_alpha));
+                context->setFillColor(colorWithOverrideAlpha(color, m_alpha), DeviceColorSpace);
             break;
         }
         case GrayLevel:
             // We're only supporting 255 levels of gray here.  Since this isn't
             // even part of HTML5, I don't expect anyone will care.  If they do
             // we'll make a fancier Color abstraction.
-            context->setFillColor(Color(m_grayLevel, m_grayLevel, m_grayLevel, m_alpha));
+            context->setFillColor(Color(m_grayLevel, m_grayLevel, m_grayLevel, m_alpha), DeviceColorSpace);
             break;
         case RGBA:
-            context->setFillColor(Color(m_red, m_green, m_blue, m_alpha));
+            context->setFillColor(Color(m_red, m_green, m_blue, m_alpha), DeviceColorSpace);
             break;
         case CMYKA: {
             // FIXME: Do this through platform-independent GraphicsContext API.
@@ -215,7 +215,7 @@ void CanvasStyle::applyFillColor(GraphicsContext* context)
             currentBrush.setColor(clr);
             context->platformContext()->setBrush(currentBrush);
 #else
-            context->setFillColor(Color(m_cyan, m_magenta, m_yellow, m_black, m_alpha));
+            context->setFillColor(Color(m_cyan, m_magenta, m_yellow, m_black, m_alpha), DeviceColorSpace);
 #endif
             break;
         }
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index 0c8cc15..8ff605f 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -1654,7 +1654,7 @@ static void drawOutlinedQuad(GraphicsContext& context, const FloatQuad& quad, co
 
         context.addPath(quadPath);
         context.setStrokeThickness(outlineThickness);
-        context.setStrokeColor(outlineColor);
+        context.setStrokeColor(outlineColor, DeviceColorSpace);
         context.strokePath();
 
         context.restore();
@@ -1662,7 +1662,7 @@ static void drawOutlinedQuad(GraphicsContext& context, const FloatQuad& quad, co
     
     // Now do the fill
     context.addPath(quadPath);
-    context.setFillColor(fillColor);
+    context.setFillColor(fillColor, DeviceColorSpace);
     context.fillPath();
 }
 
diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp
index 4ff6b23..e854de0 100644
--- a/WebCore/page/FrameView.cpp
+++ b/WebCore/page/FrameView.cpp
@@ -1664,7 +1664,7 @@ void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
         fillWithRed = true;
     
     if (fillWithRed)
-        p->fillRect(rect, Color(0xFF, 0, 0));
+        p->fillRect(rect, Color(0xFF, 0, 0), DeviceColorSpace);
 #endif
 
     bool isTopLevelPainter = !sCurrentPaintTimeStamp;
diff --git a/WebCore/platform/ScrollbarTheme.h b/WebCore/platform/ScrollbarTheme.h
index 9327dc6..dea50ab 100644
--- a/WebCore/platform/ScrollbarTheme.h
+++ b/WebCore/platform/ScrollbarTheme.h
@@ -73,7 +73,7 @@ public:
 
     virtual void invalidatePart(Scrollbar*, ScrollbarPart) {}
 
-    virtual void paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect) { context->fillRect(cornerRect, Color::white); }
+    virtual void paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect) { context->fillRect(cornerRect, Color::white, DeviceColorSpace); }
 
     virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&) { return false; }
     virtual bool shouldSnapBackToDragOrigin(Scrollbar*, const PlatformMouseEvent&) { return false; }
diff --git a/WebCore/platform/ScrollbarThemeComposite.cpp b/WebCore/platform/ScrollbarThemeComposite.cpp
index ab5e16b..74bfae3 100644
--- a/WebCore/platform/ScrollbarThemeComposite.cpp
+++ b/WebCore/platform/ScrollbarThemeComposite.cpp
@@ -297,7 +297,7 @@ void ScrollbarThemeComposite::paintScrollCorner(ScrollView* view, GraphicsContex
     Page* page = frameView->frame() ? frameView->frame()->page() : 0;
     if (page && page->settings()->shouldPaintCustomScrollbars()) {
         if (!page->chrome()->client()->paintCustomScrollCorner(context, cornerRect))
-            context->fillRect(cornerRect, Color::white);
+            context->fillRect(cornerRect, Color::white, DeviceColorSpace);
     }
 }
 
diff --git a/WebCore/platform/graphics/ColorSpace.h b/WebCore/platform/graphics/ColorSpace.h
new file mode 100644
index 0000000..1bad58c
--- /dev/null
+++ b/WebCore/platform/graphics/ColorSpace.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef ColorSpace_h
+#define ColorSpace_h
+
+namespace WebCore {
+
+    enum ColorSpace { DeviceColorSpace, sRGBColorSpace };
+    
+} // namespace WebCore
+
+#endif // ColorSpace_h
diff --git a/WebCore/platform/graphics/GraphicsContext.cpp b/WebCore/platform/graphics/GraphicsContext.cpp
index 523264e..0f53d4a 100644
--- a/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/WebCore/platform/graphics/GraphicsContext.cpp
@@ -120,11 +120,12 @@ void GraphicsContext::setStrokeStyle(const StrokeStyle& style)
     setPlatformStrokeStyle(style);
 }
 
-void GraphicsContext::setStrokeColor(const Color& color)
+void GraphicsContext::setStrokeColor(const Color& color, ColorSpace colorSpace)
 {
     m_common->state.strokeType = SolidColorType;
     m_common->state.strokeColor = color;
-    setPlatformStrokeColor(color);
+    m_common->state.strokeColorSpace = colorSpace;
+    setPlatformStrokeColor(color, colorSpace);
 }
 
 void GraphicsContext::setShadow(const IntSize& size, int blur, const Color& color)
@@ -167,6 +168,11 @@ Color GraphicsContext::strokeColor() const
     return m_common->state.strokeColor;
 }
 
+ColorSpace GraphicsContext::strokeColorSpace() const
+{
+    return m_common->state.strokeColorSpace;
+}
+
 WindRule GraphicsContext::fillRule() const
 {
     return m_common->state.fillRule;
@@ -177,11 +183,12 @@ void GraphicsContext::setFillRule(WindRule fillRule)
     m_common->state.fillRule = fillRule;
 }
 
-void GraphicsContext::setFillColor(const Color& color)
+void GraphicsContext::setFillColor(const Color& color, ColorSpace colorSpace)
 {
     m_common->state.fillType = SolidColorType;
     m_common->state.fillColor = color;
-    setPlatformFillColor(color);
+    m_common->state.fillColorSpace = colorSpace;
+    setPlatformFillColor(color, colorSpace);
 }
 
 Color GraphicsContext::fillColor() const
@@ -189,6 +196,11 @@ Color GraphicsContext::fillColor() const
     return m_common->state.fillColor;
 }
 
+ColorSpace GraphicsContext::fillColorSpace() const
+{
+    return m_common->state.fillColorSpace;
+}
+
 void GraphicsContext::setShouldAntialias(bool b)
 {
     m_common->state.shouldAntialias = b;
@@ -204,7 +216,7 @@ void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
 {
     ASSERT(pattern);
     if (!pattern) {
-        setStrokeColor(Color::black);
+        setStrokeColor(Color::black, DeviceColorSpace);
         return;
     }
     m_common->state.strokeType = PatternType;
@@ -216,7 +228,7 @@ void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern)
 {
     ASSERT(pattern);
     if (!pattern) {
-        setFillColor(Color::black);
+        setFillColor(Color::black, DeviceColorSpace);
         return;
     }
     m_common->state.fillType = PatternType;
@@ -228,7 +240,7 @@ void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient)
 {
     ASSERT(gradient);
     if (!gradient) {
-        setStrokeColor(Color::black);
+        setStrokeColor(Color::black, DeviceColorSpace);
         return;
     }
     m_common->state.strokeType = GradientType;
@@ -240,7 +252,7 @@ void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient)
 {
     ASSERT(gradient);
     if (!gradient) {
-        setFillColor(Color::black);
+        setFillColor(Color::black, DeviceColorSpace);
         return;
     }
     m_common->state.fillType = GradientType;
@@ -360,12 +372,12 @@ void GraphicsContext::drawBidiText(const Font& font, const TextRun& run, const F
     bidiResolver.deleteRuns();
 }
 
-void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run, const IntPoint& point, int h, const Color& backgroundColor, int from, int to)
+void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run, const IntPoint& point, int h, const Color& backgroundColor, ColorSpace colorSpace, int from, int to)
 {
     if (paintingDisabled())
         return;
 
-    fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor);
+    fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor, colorSpace);
 }
 
 void GraphicsContext::initFocusRing(int width, int offset)
diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h
index 86659cf..54e57a0 100644
--- a/WebCore/platform/graphics/GraphicsContext.h
+++ b/WebCore/platform/graphics/GraphicsContext.h
@@ -27,6 +27,7 @@
 #ifndef GraphicsContext_h
 #define GraphicsContext_h
 
+#include "ColorSpace.h"
 #include "DashArray.h"
 #include "FloatRect.h"
 #include "Image.h"
@@ -158,7 +159,8 @@ namespace WebCore {
         StrokeStyle strokeStyle() const;
         void setStrokeStyle(const StrokeStyle& style);
         Color strokeColor() const;
-        void setStrokeColor(const Color&);
+        ColorSpace strokeColorSpace() const;
+        void setStrokeColor(const Color&, ColorSpace);
 
         void setStrokePattern(PassRefPtr<Pattern>);
         Pattern* strokePattern() const;
@@ -169,7 +171,8 @@ namespace WebCore {
         WindRule fillRule() const;
         void setFillRule(WindRule);
         Color fillColor() const;
-        void setFillColor(const Color&);
+        ColorSpace fillColorSpace() const;
+        void setFillColor(const Color&, ColorSpace);
 
         void setFillPattern(PassRefPtr<Pattern>);
         Pattern* fillPattern() const;
@@ -207,9 +210,9 @@ namespace WebCore {
         void strokeArc(const IntRect&, int startAngle, int angleSpan);
 
         void fillRect(const FloatRect&);
-        void fillRect(const FloatRect&, const Color&);
+        void fillRect(const FloatRect&, const Color&, ColorSpace);
         void fillRect(const FloatRect&, Generator&);
-        void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&);
+        void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
 
         void clearRect(const FloatRect&);
 
@@ -245,7 +248,7 @@ namespace WebCore {
 
         void drawText(const Font&, const TextRun&, const IntPoint&, int from = 0, int to = -1);
         void drawBidiText(const Font&, const TextRun&, const FloatPoint&);
-        void drawHighlightForText(const Font&, const TextRun&, const IntPoint&, int h, const Color& backgroundColor, int from = 0, int to = -1);
+        void drawHighlightForText(const Font&, const TextRun&, const IntPoint&, int h, const Color& backgroundColor, ColorSpace, int from = 0, int to = -1);
 
         FloatRect roundToDevicePixels(const FloatRect&);
 
@@ -391,13 +394,13 @@ namespace WebCore {
         void setPlatformTextDrawingMode(int);
         void setPlatformFont(const Font& font);
 
-        void setPlatformStrokeColor(const Color&);
+        void setPlatformStrokeColor(const Color&, ColorSpace);
         void setPlatformStrokeStyle(const StrokeStyle&);
         void setPlatformStrokeThickness(float);
         void setPlatformStrokeGradient(Gradient*);
         void setPlatformStrokePattern(Pattern*);
 
-        void setPlatformFillColor(const Color&);
+        void setPlatformFillColor(const Color&, ColorSpace);
         void setPlatformFillGradient(Gradient*);
         void setPlatformFillPattern(Pattern*);
 
diff --git a/WebCore/platform/graphics/GraphicsContextPrivate.h b/WebCore/platform/graphics/GraphicsContextPrivate.h
index b08b3fb..bc2f9b7 100644
--- a/WebCore/platform/graphics/GraphicsContextPrivate.h
+++ b/WebCore/platform/graphics/GraphicsContextPrivate.h
@@ -40,9 +40,11 @@ namespace WebCore {
             , strokeThickness(0)
             , strokeType(SolidColorType)
             , strokeColor(Color::black)
+            , strokeColorSpace(DeviceColorSpace)
             , fillRule(RULE_NONZERO)
             , fillType(SolidColorType)
             , fillColor(Color::black)
+            , fillColorSpace(DeviceColorSpace)
             , shouldAntialias(true)
             , paintingDisabled(false)
             , shadowBlur(0)
@@ -59,12 +61,14 @@ namespace WebCore {
         float strokeThickness;
         FillOrStrokeType strokeType;
         Color strokeColor;
+        ColorSpace strokeColorSpace;
         RefPtr<Gradient> strokeGradient;
         RefPtr<Pattern> strokePattern;
         
         WindRule fillRule;
         FillOrStrokeType fillType;
         Color fillColor;
+        ColorSpace fillColorSpace;
         RefPtr<Gradient> fillGradient;
         RefPtr<Pattern> fillPattern;
 
diff --git a/WebCore/platform/graphics/Image.cpp b/WebCore/platform/graphics/Image.cpp
index 80b5457..9b63f0e 100644
--- a/WebCore/platform/graphics/Image.cpp
+++ b/WebCore/platform/graphics/Image.cpp
@@ -82,7 +82,7 @@ void Image::fillWithSolidColor(GraphicsContext* ctxt, const FloatRect& dstRect,
     
     ctxt->save();
     ctxt->setCompositeOperation(!color.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
-    ctxt->fillRect(dstRect, color);
+    ctxt->fillRect(dstRect, color, DeviceColorSpace);
     ctxt->restore();
 }
 
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
index a9200f1..46b631a 100644
--- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
@@ -470,7 +470,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     fillPath();
 }
 
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
@@ -634,13 +634,13 @@ IntPoint GraphicsContext::origin()
     return IntPoint(static_cast<int>(matrix.x0), static_cast<int>(matrix.y0));
 }
 
-void GraphicsContext::setPlatformFillColor(const Color& col)
+void GraphicsContext::setPlatformFillColor(const Color& col, ColorSpace colorSpace)
 {
     // Cairo contexts can't hold separate fill and stroke colors
     // so we set them just before we actually fill or stroke
 }
 
-void GraphicsContext::setPlatformStrokeColor(const Color& col)
+void GraphicsContext::setPlatformStrokeColor(const Color& col, ColorSpace colorSpace)
 {
     // Cairo contexts can't hold separate fill and stroke colors
     // so we set them just before we actually fill or stroke
@@ -997,7 +997,7 @@ void GraphicsContext::clipOutEllipseInRect(const IntRect& r)
     clipOut(p);
 }
 
-void GraphicsContext::fillRoundedRect(const IntRect& r, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
+void GraphicsContext::fillRoundedRect(const IntRect& r, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
index 306b24f..981df00 100644
--- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
+++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
@@ -61,18 +61,74 @@ using namespace std;
 
 namespace WebCore {
 
-static void setCGFillColor(CGContextRef context, const Color& color)
+static CGColorSpaceRef sRGBColorSpaceRef()
 {
-    CGFloat red, green, blue, alpha;
-    color.getRGBA(red, green, blue, alpha);
-    CGContextSetRGBFillColor(context, red, green, blue, alpha);
+    static CGColorSpaceRef sRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+    return sRGBSpace;
 }
 
-static void setCGStrokeColor(CGContextRef context, const Color& color)
+static CGColorSpaceRef deviceRGBColorSpaceRef()
 {
-    CGFloat red, green, blue, alpha;
-    color.getRGBA(red, green, blue, alpha);
-    CGContextSetRGBStrokeColor(context, red, green, blue, alpha);
+    static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB();
+    return deviceSpace;
+}
+
+static void setCGFillColor(CGContextRef context, const Color& color, ColorSpace colorSpace)
+{
+    CGFloat components[4];
+    color.getRGBA(components[0], components[1], components[2], components[3]);
+
+    CGColorRef cgColor;
+    if (colorSpace == sRGBColorSpace)
+        cgColor = CGColorCreate(sRGBColorSpaceRef(), components);
+    else
+        cgColor = CGColorCreate(deviceRGBColorSpaceRef(), components);
+
+    CGContextSetFillColorWithColor(context, cgColor);
+    CFRelease(cgColor);
+}
+
+static void setCGStrokeColor(CGContextRef context, const Color& color, ColorSpace colorSpace)
+{
+    CGFloat components[4];
+    color.getRGBA(components[0], components[1], components[2], components[3]);
+
+    CGColorRef cgColor;
+    if (colorSpace == sRGBColorSpace)
+        cgColor = CGColorCreate(sRGBColorSpaceRef(), components);
+    else
+        cgColor = CGColorCreate(deviceRGBColorSpaceRef(), components);
+
+    CGContextSetStrokeColorWithColor(context, cgColor);
+    CFRelease(cgColor);
+}
+
+static void setCGFillColorSpace(CGContextRef context, ColorSpace colorSpace)
+{
+    switch (colorSpace) {
+    case DeviceColorSpace:
+        break;
+    case sRGBColorSpace:
+        CGContextSetFillColorSpace(context, sRGBColorSpaceRef());
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
+static void setCGStrokeColorSpace(CGContextRef context, ColorSpace colorSpace)
+{
+    switch (colorSpace) {
+    case DeviceColorSpace:
+        break;
+    case sRGBColorSpace:
+        CGContextSetStrokeColorSpace(context, sRGBColorSpaceRef());
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
 }
 
 GraphicsContext::GraphicsContext(CGContextRef cgContext)
@@ -82,8 +138,8 @@ GraphicsContext::GraphicsContext(CGContextRef cgContext)
     setPaintingDisabled(!cgContext);
     if (cgContext) {
         // Make sure the context starts in sync with our state.
-        setPlatformFillColor(fillColor());
-        setPlatformStrokeColor(strokeColor());
+        setPlatformFillColor(fillColor(), fillColorSpace());
+        setPlatformStrokeColor(strokeColor(), strokeColorSpace());
     }
 }
 
@@ -133,7 +189,7 @@ void GraphicsContext::drawRect(const IntRect& rect)
         // We do a fill of four rects to simulate the stroke of a border.
         Color oldFillColor = fillColor();
         if (oldFillColor != strokeColor())
-            setCGFillColor(context, strokeColor());
+            setCGFillColor(context, strokeColor(), strokeColorSpace());
         CGRect rects[4] = {
             FloatRect(rect.x(), rect.y(), rect.width(), 1),
             FloatRect(rect.x(), rect.bottom() - 1, rect.width(), 1),
@@ -142,7 +198,7 @@ void GraphicsContext::drawRect(const IntRect& rect)
         };
         CGContextFillRects(context, rects, 4);
         if (oldFillColor != strokeColor())
-            setCGFillColor(context, oldFillColor);
+            setCGFillColor(context, oldFillColor, fillColorSpace());
     }
 }
 
@@ -210,7 +266,7 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
 
         // Do a rect fill of our endpoints.  This ensures we always have the
         // appearance of being a border.  We then draw the actual dotted/dashed line.
-        setCGFillColor(context, strokeColor());  // The save/restore make it safe to mutate the fill color here without setting it back to the old color.
+        setCGFillColor(context, strokeColor(), strokeColorSpace());  // The save/restore make it safe to mutate the fill color here without setting it back to the old color.
         if (isVerticalLine) {
             CGContextFillRect(context, FloatRect(p1.x() - width / 2, p1.y() - width, width, width));
             CGContextFillRect(context, FloatRect(p2.x() - width / 2, p2.y(), width, width));
@@ -494,6 +550,8 @@ void GraphicsContext::fillPath()
         return;
 
     CGContextRef context = platformContext();
+    setCGFillColorSpace(context, m_common->state.fillColorSpace);
+
     switch (m_common->state.fillType) {
     case SolidColorType:
         fillPathWithFillRule(context, fillRule());
@@ -521,6 +579,8 @@ void GraphicsContext::strokePath()
         return;
 
     CGContextRef context = platformContext();
+    setCGStrokeColorSpace(context, m_common->state.strokeColorSpace);
+
     switch (m_common->state.strokeType) {
     case SolidColorType:
         CGContextStrokePath(context);
@@ -544,7 +604,10 @@ void GraphicsContext::fillRect(const FloatRect& rect)
 {
     if (paintingDisabled())
         return;
+
     CGContextRef context = platformContext();
+    setCGFillColorSpace(context, m_common->state.fillColorSpace);
+
     switch (m_common->state.fillType) {
     case SolidColorType:
         CGContextFillRect(context, rect);
@@ -563,34 +626,40 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     }
 }
 
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
     CGContextRef context = platformContext();
     Color oldFillColor = fillColor();
-    if (oldFillColor != color)
-      setCGFillColor(context, color);
+    ColorSpace oldColorSpace = fillColorSpace();
+
+    if (oldFillColor != color || oldColorSpace != colorSpace)
+      setCGFillColor(context, color, colorSpace);
+
     CGContextFillRect(context, rect);
-    if (oldFillColor != color)
-      setCGFillColor(context, oldFillColor);
+
+    if (oldFillColor != color || oldColorSpace != colorSpace)
+      setCGFillColor(context, oldFillColor, oldColorSpace);
 }
 
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
+void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
 
     CGContextRef context = platformContext();
     Color oldFillColor = fillColor();
-    if (oldFillColor != color)
-        setCGFillColor(context, color);
+    ColorSpace oldColorSpace = fillColorSpace();
+
+    if (oldFillColor != color || oldColorSpace != colorSpace)
+        setCGFillColor(context, color, colorSpace);
 
     addPath(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight));
     fillPath();
 
-    if (oldFillColor != color)
-        setCGFillColor(context, oldFillColor);
+    if (oldFillColor != color || oldColorSpace != colorSpace)
+        setCGFillColor(context, oldFillColor, oldColorSpace);
 }
 
 void GraphicsContext::clip(const FloatRect& rect)
@@ -779,6 +848,8 @@ void GraphicsContext::strokeRect(const FloatRect& r, float lineWidth)
         return;
 
     CGContextRef context = platformContext();
+    setCGStrokeColorSpace(context, m_common->state.strokeColorSpace);
+
     switch (m_common->state.strokeType) {
     case SolidColorType:
         CGContextStrokeRectWithWidth(context, r, lineWidth);
@@ -996,10 +1067,10 @@ void GraphicsContext::drawLineForText(const IntPoint& point, int width, bool pri
     }
 
     if (fillColor() != strokeColor())
-        setCGFillColor(platformContext(), strokeColor());
+        setCGFillColor(platformContext(), strokeColor(), strokeColorSpace());
     CGContextFillRect(platformContext(), CGRectMake(x, y, lineLength, thickness));
     if (fillColor() != strokeColor())
-        setCGFillColor(platformContext(), fillColor());
+        setCGFillColor(platformContext(), fillColor(), fillColorSpace());
 
     if (restoreAntialiasMode)
         CGContextSetShouldAntialias(platformContext(), true);
@@ -1123,11 +1194,11 @@ void GraphicsContext::setPlatformTextDrawingMode(int mode)
     }
 }
 
-void GraphicsContext::setPlatformStrokeColor(const Color& color)
+void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
-    setCGStrokeColor(platformContext(), color);
+    setCGStrokeColor(platformContext(), color, colorSpace);
 }
 
 void GraphicsContext::setPlatformStrokeThickness(float thickness)
@@ -1137,11 +1208,11 @@ void GraphicsContext::setPlatformStrokeThickness(float thickness)
     CGContextSetLineWidth(platformContext(), thickness);
 }
 
-void GraphicsContext::setPlatformFillColor(const Color& color)
+void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
-    setCGFillColor(platformContext(), color);
+    setCGFillColor(platformContext(), color, colorSpace);
 }
 
 void GraphicsContext::setPlatformShouldAntialias(bool enable)
diff --git a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp
index c23b8a9..9b97c6f 100644
--- a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp
+++ b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp
@@ -152,7 +152,7 @@ void GraphicsContext::drawConvexPolygon(size_t pointsLength, const FloatPoint* p
         m_data->m_view->StrokePolygon(bPoints, pointsLength, true, getHaikuStrokeStyle());
 }
 
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
@@ -169,7 +169,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
         return;
 }
 
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
+void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled() || !color.alpha())
         return;
@@ -477,7 +477,7 @@ void GraphicsContext::setPlatformFont(const Font& font)
     m_data->m_view->SetFont(font.primaryFont()->platformData().font());
 }
 
-void GraphicsContext::setPlatformStrokeColor(const Color& color)
+void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSPace colorSpace)
 {
     if (paintingDisabled())
         return;
@@ -519,7 +519,7 @@ void GraphicsContext::setPlatformStrokeThickness(float thickness)
     m_data->m_view->SetPenSize(thickness);
 }
 
-void GraphicsContext::setPlatformFillColor(const Color& color)
+void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
diff --git a/WebCore/platform/graphics/mac/FontMac.mm b/WebCore/platform/graphics/mac/FontMac.mm
index b2b9a5c..7f110c2 100644
--- a/WebCore/platform/graphics/mac/FontMac.mm
+++ b/WebCore/platform/graphics/mac/FontMac.mm
@@ -122,15 +122,16 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
         // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
         context->clearShadow();
         Color fillColor = context->fillColor();
+        ColorSpace fillColorSpace = context->fillColorSpace();
         Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
-        context->setFillColor(shadowFillColor);
+        context->setFillColor(shadowFillColor, fillColorSpace);
         CGContextSetTextPosition(cgContext, point.x() + shadowSize.width(), point.y() + shadowSize.height());
         CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
         if (font->syntheticBoldOffset()) {
             CGContextSetTextPosition(cgContext, point.x() + shadowSize.width() + font->syntheticBoldOffset(), point.y() + shadowSize.height());
             CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
         }
-        context->setFillColor(fillColor);
+        context->setFillColor(fillColor, fillColorSpace);
     }
 
     CGContextSetTextPosition(cgContext, point.x(), point.y());
diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
index 30d0c82..8525a90 100644
--- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
+++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
@@ -1158,10 +1158,10 @@ void MediaPlayerPrivate::paint(GraphicsContext* context, const IntRect& r)
             TextRun textRun(text.characters(), text.length());
             const Color color(255, 0, 0);
             context->scale(FloatSize(1.0f, -1.0f));    
-            context->setStrokeColor(color);
+            context->setStrokeColor(color, styleToUse->colorSpace());
             context->setStrokeStyle(SolidStroke);
             context->setStrokeThickness(1.0f);
-            context->setFillColor(color);
+            context->setFillColor(color, styleToUse->colorSpace());
             context->drawText(styleToUse->font(), textRun, IntPoint(2, -3));
         }
     }
diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index e4f75e6..38f3e2a 100644
--- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -751,7 +751,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     }
 }
 
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& c)
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& c, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
@@ -762,7 +762,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& c)
     p->fillRect(rect, m_data->solidColor);
 }
 
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
+void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled() || !color.alpha())
         return;
@@ -1225,7 +1225,7 @@ void GraphicsContext::setURLForRect(const KURL&, const IntRect&)
     notImplemented();
 }
 
-void GraphicsContext::setPlatformStrokeColor(const Color& color)
+void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
@@ -1255,7 +1255,7 @@ void GraphicsContext::setPlatformStrokeThickness(float thickness)
     p->setPen(newPen);
 }
 
-void GraphicsContext::setPlatformFillColor(const Color& color)
+void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
diff --git a/WebCore/platform/graphics/wince/GraphicsContextWince.cpp b/WebCore/platform/graphics/wince/GraphicsContextWince.cpp
index 182f528..7be4243 100644
--- a/WebCore/platform/graphics/wince/GraphicsContextWince.cpp
+++ b/WebCore/platform/graphics/wince/GraphicsContextWince.cpp
@@ -947,7 +947,7 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
     }
 }
 
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled() || !m_data->m_opacity)
         return;
@@ -1051,12 +1051,12 @@ void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint&, int wi
     notImplemented();
 }
 
-void GraphicsContext::setPlatformFillColor(const Color& col)
+void GraphicsContext::setPlatformFillColor(const Color& col, ColorSpace colorSpace)
 {
     notImplemented();
 }
 
-void GraphicsContext::setPlatformStrokeColor(const Color& col)
+void GraphicsContext::setPlatformStrokeColor(const Color& col, ColorSpace colorSpace)
 {
     notImplemented();
 }
@@ -1088,7 +1088,7 @@ void GraphicsContext::clearRect(const FloatRect& rect)
         return;
     } 
 
-    fillRect(rect, Color(Color::white));
+    fillRect(rect, Color(Color::white), DeviceColorSpace);
 }
 
 void GraphicsContext::strokeRect(const FloatRect& rect, float width)
@@ -1238,7 +1238,7 @@ static inline IntPoint rectCenterPoint(const RECT& rect)
 {
     return IntPoint(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
 }
-void GraphicsContext::fillRoundedRect(const IntRect& fillRect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& c)
+void GraphicsContext::fillRoundedRect(const IntRect& fillRect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& c, ColorSpace colorSpace)
 {
     ScopeDCProvider dcProvider(m_data);
     if (!m_data->m_dc)
@@ -1449,7 +1449,7 @@ void GraphicsContext::fillRect(const FloatRect& r, const Gradient* gradient)
     if (numStops == 1) {
         const Gradient::ColorStop& stop = stops.first();
         Color color(stop.red, stop.green, stop.blue, stop.alpha);
-        fillRect(r, color);
+        fillRect(r, color, DeviceColorSpace);
         return;
     } 
     
@@ -1542,10 +1542,10 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     if (m_common->state.fillType == GradientType && m_common->state.fillGradient)
         fillRect(rect, m_common->state.fillGradient.get());
     else
-        fillRect(rect, fillColor());
+        fillRect(rect, fillColor(), DeviceColorSpace);
 }
 
-void GraphicsContext::setPlatformShadow(const IntSize&, int, const Color&)
+void GraphicsContext::setPlatformShadow(const IntSize&, int, const Color&, ColorSpace colorSpace)
 {
     notImplemented();
 }
diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp
index 39f14f4..f73b9bb 100644
--- a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp
+++ b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp
@@ -252,7 +252,7 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
     delete [] polygon;
 }
 
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
@@ -262,7 +262,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
     m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height());
 }
 
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
+void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
@@ -438,7 +438,7 @@ void GraphicsContext::addPath(const Path& path)
     notImplemented();
 }
 
-void GraphicsContext::setPlatformStrokeColor(const Color& color)
+void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
@@ -457,7 +457,7 @@ void GraphicsContext::setPlatformStrokeThickness(float thickness)
 
 }
 
-void GraphicsContext::setPlatformFillColor(const Color& color)
+void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorSpace)
 {
     if (paintingDisabled())
         return;
diff --git a/WebCore/rendering/EllipsisBox.cpp b/WebCore/rendering/EllipsisBox.cpp
index fa32492..2959f35 100644
--- a/WebCore/rendering/EllipsisBox.cpp
+++ b/WebCore/rendering/EllipsisBox.cpp
@@ -32,7 +32,7 @@ void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
     RenderStyle* style = m_renderer->style(m_firstLine);
     Color textColor = style->color();
     if (textColor != context->fillColor())
-        context->setFillColor(textColor);
+        context->setFillColor(textColor, style->colorSpace());
     bool setShadow = false;
     if (style->textShadow()) {
         context->setShadow(IntSize(style->textShadow()->x, style->textShadow()->y),
diff --git a/WebCore/rendering/InlineFlowBox.cpp b/WebCore/rendering/InlineFlowBox.cpp
index baea956..840ee22 100644
--- a/WebCore/rendering/InlineFlowBox.cpp
+++ b/WebCore/rendering/InlineFlowBox.cpp
@@ -988,18 +988,18 @@ void InlineFlowBox::paintTextDecorations(RenderObject::PaintInfo& paintInfo, int
             }
 
             if (paintUnderline) {
-                context->setStrokeColor(underline);
+                context->setStrokeColor(underline, renderer()->style()->colorSpace());
                 context->setStrokeStyle(SolidStroke);
                 // Leave one pixel of white between the baseline and the underline.
                 context->drawLineForText(IntPoint(tx, ty + baselinePos + 1), w, isPrinting);
             }
             if (paintOverline) {
-                context->setStrokeColor(overline);
+                context->setStrokeColor(overline, renderer()->style()->colorSpace());
                 context->setStrokeStyle(SolidStroke);
                 context->drawLineForText(IntPoint(tx, ty), w, isPrinting);
             }
             if (paintLineThrough) {
-                context->setStrokeColor(linethrough);
+                context->setStrokeColor(linethrough, renderer()->style()->colorSpace());
                 context->setStrokeStyle(SolidStroke);
                 context->drawLineForText(IntPoint(tx, ty + 2 * baselinePos / 3), w, isPrinting);
             }
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp
index 751340d..8f830bd 100644
--- a/WebCore/rendering/InlineTextBox.cpp
+++ b/WebCore/rendering/InlineTextBox.cpp
@@ -214,7 +214,7 @@ Color correctedTextColor(Color textColor, Color backgroundColor)
     return textColor.light();
 }
 
-void updateGraphicsContext(GraphicsContext* context, const Color& fillColor, const Color& strokeColor, float strokeThickness)
+void updateGraphicsContext(GraphicsContext* context, const Color& fillColor, const Color& strokeColor, float strokeThickness, ColorSpace colorSpace)
 {
     int mode = context->textDrawingMode();
     if (strokeThickness > 0) {
@@ -225,12 +225,12 @@ void updateGraphicsContext(GraphicsContext* context, const Color& fillColor, con
         }
     }
     
-    if (mode & cTextFill && fillColor != context->fillColor())
-        context->setFillColor(fillColor);
+    if (mode & cTextFill && (fillColor != context->fillColor() || colorSpace != context->fillColorSpace()))
+        context->setFillColor(fillColor, colorSpace);
 
     if (mode & cTextStroke) {
         if (strokeColor != context->strokeColor())
-            context->setStrokeColor(strokeColor);
+            context->setStrokeColor(strokeColor, colorSpace);
         if (strokeThickness != context->strokeThickness())
             context->setStrokeThickness(strokeThickness);
     }
@@ -257,9 +257,10 @@ bool InlineTextBox::nodeAtPoint(const HitTestRequest&, HitTestResult& result, in
 static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, const IntPoint& textOrigin, int x, int y, int w, int h, ShadowData* shadow, bool stroked)
 {
     Color fillColor = context->fillColor();
+    ColorSpace fillColorSpace = context->fillColorSpace();
     bool opaque = fillColor.alpha() == 255;
     if (!opaque)
-        context->setFillColor(Color::black);
+        context->setFillColor(Color::black, fillColorSpace);
 
     do {
         IntSize extraOffset;
@@ -281,7 +282,7 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
             }
             context->setShadow(shadowOffset, shadowBlur, shadowColor);
         } else if (!opaque)
-            context->setFillColor(fillColor);
+            context->setFillColor(fillColor, fillColorSpace);
 
         if (startOffset <= endOffset)
             context->drawText(font, textRun, textOrigin + extraOffset, startOffset, endOffset);
@@ -465,7 +466,7 @@ void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
         if (textStrokeWidth > 0)
             context->save();
 
-        updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth);
+        updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
         if (!paintSelectedTextSeparately || ePos <= sPos) {
             // FIXME: Truncate right-to-left text correctly.
             paintTextWithShadows(context, font, textRun, 0, m_truncation == cNoTruncation ? m_len : m_truncation, textOrigin, m_x + tx, m_y + ty, width(), height(), textShadow, textStrokeWidth > 0);
@@ -481,7 +482,7 @@ void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
         if (selectionStrokeWidth > 0)
             context->save();
 
-        updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth);
+        updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth, styleToUse->colorSpace());
         paintTextWithShadows(context, font, textRun, sPos, ePos, textOrigin, m_x + tx, m_y + ty, width(), height(), selectionShadow, selectionStrokeWidth > 0);
 
         if (selectionStrokeWidth > 0)
@@ -490,7 +491,7 @@ void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
 
     // Paint decorations
     if (d != TDNONE && paintInfo.phase != PaintPhaseSelection && styleToUse->htmlHacks()) {
-        context->setStrokeColor(styleToUse->color());
+        context->setStrokeColor(styleToUse->color(), styleToUse->colorSpace());
         paintDecoration(context, tx, ty, d, textShadow);
     }
 
@@ -561,13 +562,13 @@ void InlineTextBox::paintSelection(GraphicsContext* context, int tx, int ty, Ren
         c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
 
     context->save();
-    updateGraphicsContext(context, c, c, 0);  // Don't draw text at all!
+    updateGraphicsContext(context, c, c, 0, style->colorSpace());  // Don't draw text at all!
     int y = selectionTop();
     int h = selectionHeight();
     context->clip(IntRect(m_x + tx, y + ty, m_width, h));
     context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, 
                                   direction() == RTL, m_dirOverride || style->visuallyOrdered()),
-                                  IntPoint(m_x + tx, y + ty), h, c, sPos, ePos);
+                                  IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
     context->restore();
 }
 
@@ -584,13 +585,13 @@ void InlineTextBox::paintCompositionBackground(GraphicsContext* context, int tx,
 
     Color c = Color(225, 221, 85);
     
-    updateGraphicsContext(context, c, c, 0); // Don't draw text at all!
+    updateGraphicsContext(context, c, c, 0, style->colorSpace()); // Don't draw text at all!
 
     int y = selectionTop();
     int h = selectionHeight();
     context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd,
                                   direction() == RTL, m_dirOverride || style->visuallyOrdered()),
-                                  IntPoint(m_x + tx, y + ty), h, c, sPos, ePos);
+                                  IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
     context->restore();
 }
 
@@ -675,18 +676,18 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
         }
 
         if (deco & UNDERLINE) {
-            context->setStrokeColor(underline);
+            context->setStrokeColor(underline, renderer()->style()->colorSpace());
             context->setStrokeStyle(SolidStroke);
             // Leave one pixel of white between the baseline and the underline.
             context->drawLineForText(IntPoint(tx, ty + baseline + 1), width, isPrinting);
         }
         if (deco & OVERLINE) {
-            context->setStrokeColor(overline);
+            context->setStrokeColor(overline, renderer()->style()->colorSpace());
             context->setStrokeStyle(SolidStroke);
             context->drawLineForText(IntPoint(tx, ty), width, isPrinting);
         }
         if (deco & LINE_THROUGH) {
-            context->setStrokeColor(linethrough);
+            context->setStrokeColor(linethrough, renderer()->style()->colorSpace());
             context->setStrokeStyle(SolidStroke);
             context->drawLineForText(IntPoint(tx, ty + 2 * baseline / 3), width, isPrinting);
         }
@@ -783,9 +784,9 @@ void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, int tx, int ty, Do
             renderer()->theme()->platformActiveTextSearchHighlightColor() :
             renderer()->theme()->platformInactiveTextSearchHighlightColor();
         pt->save();
-        updateGraphicsContext(pt, color, color, 0);  // Don't draw text at all!
+        updateGraphicsContext(pt, color, color, 0, style->colorSpace());  // Don't draw text at all!
         pt->clip(IntRect(tx + m_x, ty + y, m_width, h));
-        pt->drawHighlightForText(font, run, startPoint, h, color, sPos, ePos);
+        pt->drawHighlightForText(font, run, startPoint, h, color, style->colorSpace(), sPos, ePos);
         pt->restore();
     }
 }
@@ -911,7 +912,7 @@ void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, int tx, int
     start += 1;
     width -= 2;
 
-    ctx->setStrokeColor(underline.color);
+    ctx->setStrokeColor(underline.color, renderer()->style()->colorSpace());
     ctx->setStrokeThickness(lineThickness);
     ctx->drawLineForText(IntPoint(tx + start, ty + height() - lineThickness), width, textRenderer()->document()->printing());
 }
diff --git a/WebCore/rendering/InlineTextBox.h b/WebCore/rendering/InlineTextBox.h
index 3bbb453..d6658df 100644
--- a/WebCore/rendering/InlineTextBox.h
+++ b/WebCore/rendering/InlineTextBox.h
@@ -34,7 +34,7 @@ const unsigned short cNoTruncation = USHRT_MAX;
 const unsigned short cFullTruncation = USHRT_MAX - 1;
 
 // Helper functions shared by InlineTextBox / SVGRootInlineBox
-void updateGraphicsContext(GraphicsContext* context, const Color& fillColor, const Color& strokeColor, float strokeThickness);
+void updateGraphicsContext(GraphicsContext*, const Color& fillColor, const Color& strokeColor, float strokeThickness, ColorSpace);
 Color correctedTextColor(Color textColor, Color backgroundColor);
 
 class InlineTextBox : public InlineRunBox {
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index daf6910..470358d 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -2120,7 +2120,7 @@ IntRect RenderBlock::fillHorizontalSelectionGap(RenderObject* selObj, int xPos,
         return IntRect();
     IntRect gapRect(xPos, yPos, width, height);
     if (paintInfo && selObj->style()->visibility() == VISIBLE)
-        paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor());
+        paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor(), selObj->style()->colorSpace());
     return gapRect;
 }
 
@@ -2141,7 +2141,7 @@ IntRect RenderBlock::fillVerticalSelectionGap(int lastTop, int lastLeft, int las
 
     IntRect gapRect(left, top, width, height);
     if (paintInfo)
-        paintInfo->context->fillRect(gapRect, selectionBackgroundColor());
+        paintInfo->context->fillRect(gapRect, selectionBackgroundColor(), style()->colorSpace());
     return gapRect;
 }
 
@@ -2157,7 +2157,7 @@ IntRect RenderBlock::fillLeftSelectionGap(RenderObject* selObj, int xPos, int yP
 
     IntRect gapRect(left, top, width, height);
     if (paintInfo)
-        paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor());
+        paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor(), selObj->style()->colorSpace());
     return gapRect;
 }
 
@@ -2173,7 +2173,7 @@ IntRect RenderBlock::fillRightSelectionGap(RenderObject* selObj, int xPos, int y
 
     IntRect gapRect(left, top, width, height);
     if (paintInfo)
-        paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor());
+        paintInfo->context->fillRect(gapRect, selObj->selectionBackgroundColor(), selObj->style()->colorSpace());
     return gapRect;
 }
 
diff --git a/WebCore/rendering/RenderBoxModelObject.cpp b/WebCore/rendering/RenderBoxModelObject.cpp
index 23dad2d..3ba1c34 100644
--- a/WebCore/rendering/RenderBoxModelObject.cpp
+++ b/WebCore/rendering/RenderBoxModelObject.cpp
@@ -441,14 +441,14 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
             if (baseColor.alpha() > 0) {
                 context->save();
                 context->setCompositeOperation(CompositeCopy);
-                context->fillRect(rect, baseColor);
+                context->fillRect(rect, baseColor, style()->colorSpace());
                 context->restore();
             } else
                 context->clearRect(rect);
         }
 
         if (bgColor.isValid() && bgColor.alpha() > 0)
-            context->fillRect(rect, bgColor);
+            context->fillRect(rect, bgColor, style()->colorSpace());
     }
 
     // no progressive loading of the background image
@@ -1241,7 +1241,7 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
 
                 if (!rectToClipOut.isEmpty())
                     context->clipOutRoundedRect(rectToClipOut, topLeftToClipOut, topRightToClipOut, bottomLeftToClipOut, bottomRightToClipOut);
-                context->fillRoundedRect(fillRect, topLeft, topRight, bottomLeft, bottomRight, Color::black);
+                context->fillRoundedRect(fillRect, topLeft, topRight, bottomLeft, bottomRight, Color::black, s->colorSpace());
             } else {
                 IntRect rectToClipOut = rect;
 
@@ -1258,7 +1258,7 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
 
                 if (!rectToClipOut.isEmpty())
                     context->clipOut(rectToClipOut);
-                context->fillRect(fillRect, Color::black);
+                context->fillRect(fillRect, Color::black, s->colorSpace());
             }
 
             context->restore();
@@ -1269,9 +1269,9 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
 
             if (holeRect.isEmpty()) {
                 if (hasBorderRadius)
-                    context->fillRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight, shadowColor);
+                    context->fillRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight, shadowColor, s->colorSpace());
                 else
-                    context->fillRect(rect, shadowColor);
+                    context->fillRect(rect, shadowColor, s->colorSpace());
                 continue;
             }
             if (!begin) {
@@ -1320,7 +1320,7 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
                 context->addPath(Path::createRectangle(holeRect));
 
             context->setFillRule(RULE_EVENODD);
-            context->setFillColor(fillColor);
+            context->setFillColor(fillColor, s->colorSpace());
             context->setShadow(shadowOffset, shadowBlur, shadowColor);
             context->fillPath();
 
diff --git a/WebCore/rendering/RenderFileUploadControl.cpp b/WebCore/rendering/RenderFileUploadControl.cpp
index 262be31..0a49288 100644
--- a/WebCore/rendering/RenderFileUploadControl.cpp
+++ b/WebCore/rendering/RenderFileUploadControl.cpp
@@ -207,7 +207,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, int tx, int ty)
             + buttonRenderer->marginTop() + buttonRenderer->borderTop() + buttonRenderer->paddingTop()
             + buttonRenderer->baselinePosition(true, false);
 
-        paintInfo.context->setFillColor(style()->color());
+        paintInfo.context->setFillColor(style()->color(), style()->colorSpace());
         
         // Draw the filename
         paintInfo.context->drawBidiText(style()->font(), textRun, IntPoint(textX, textY));
diff --git a/WebCore/rendering/RenderFrameSet.cpp b/WebCore/rendering/RenderFrameSet.cpp
index 8a7f09d..a456ef4 100644
--- a/WebCore/rendering/RenderFrameSet.cpp
+++ b/WebCore/rendering/RenderFrameSet.cpp
@@ -85,13 +85,14 @@ void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect
     
     // Fill first.
     GraphicsContext* context = paintInfo.context;
-    context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->borderLeftColor() : borderFillColor());
+    ColorSpace colorSpace = style()->colorSpace();
+    context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->borderLeftColor() : borderFillColor(), colorSpace);
     
     // 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.topLeft(), IntSize(1, height())), borderStartEdgeColor());
-        context->fillRect(IntRect(borderRect.topRight(), IntSize(1, height())), borderEndEdgeColor());
+        context->fillRect(IntRect(borderRect.topLeft(), IntSize(1, height())), borderStartEdgeColor(), colorSpace);
+        context->fillRect(IntRect(borderRect.topRight(), IntSize(1, height())), borderEndEdgeColor(), colorSpace);
     }
 }
 
@@ -104,13 +105,14 @@ void RenderFrameSet::paintRowBorder(const PaintInfo& paintInfo, const IntRect& b
     
     // Fill first.
     GraphicsContext* context = paintInfo.context;
-    context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->borderLeftColor() : borderFillColor());
+    ColorSpace colorSpace = style()->colorSpace();
+    context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->borderLeftColor() : borderFillColor(), colorSpace);
 
     // 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.topLeft(), IntSize(width(), 1)), borderStartEdgeColor());
-        context->fillRect(IntRect(borderRect.bottomLeft(), IntSize(width(), 1)), borderEndEdgeColor());
+        context->fillRect(IntRect(borderRect.topLeft(), IntSize(width(), 1)), borderStartEdgeColor(), colorSpace);
+        context->fillRect(IntRect(borderRect.bottomLeft(), IntSize(width(), 1)), borderEndEdgeColor(), colorSpace);
     }
 }
 
diff --git a/WebCore/rendering/RenderImage.cpp b/WebCore/rendering/RenderImage.cpp
index 4206b1c..cab76e4 100644
--- a/WebCore/rendering/RenderImage.cpp
+++ b/WebCore/rendering/RenderImage.cpp
@@ -364,8 +364,8 @@ void RenderImage::paintReplaced(PaintInfo& paintInfo, int tx, int ty)
         if (cWidth > 2 && cHeight > 2) {
             // Draw an outline rect where the image should be.
             context->setStrokeStyle(SolidStroke);
-            context->setStrokeColor(Color::lightGray);
-            context->setFillColor(Color::transparent);
+            context->setStrokeColor(Color::lightGray, style()->colorSpace());
+            context->setFillColor(Color::transparent, style()->colorSpace());
             context->drawRect(IntRect(tx + leftBorder + leftPad, ty + topBorder + topPad, cWidth, cHeight));
 
             bool errorPictureDrawn = false;
@@ -392,7 +392,7 @@ void RenderImage::paintReplaced(PaintInfo& paintInfo, int tx, int ty)
 
             if (!m_altText.isEmpty()) {
                 String text = document()->displayStringModifiedByEncoding(m_altText);
-                context->setFillColor(style()->color());
+                context->setFillColor(style()->color(), style()->colorSpace());
                 int ax = tx + leftBorder + leftPad;
                 int ay = ty + topBorder + topPad;
                 const Font& font = style()->font();
diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp
index c59ea97..292545a 100644
--- a/WebCore/rendering/RenderLayer.cpp
+++ b/WebCore/rendering/RenderLayer.cpp
@@ -1913,7 +1913,7 @@ void RenderLayer::paintScrollCorner(GraphicsContext* context, int tx, int ty, co
         return;
     }
     
-    context->fillRect(absRect, Color::white);
+    context->fillRect(absRect, Color::white, box->style()->colorSpace());
 }
 
 void RenderLayer::paintResizer(GraphicsContext* context, int tx, int ty, const IntRect& damageRect)
@@ -1951,9 +1951,9 @@ void RenderLayer::paintResizer(GraphicsContext* context, int tx, int ty, const I
         context->clip(absRect);
         IntRect largerCorner = absRect;
         largerCorner.setSize(IntSize(largerCorner.width() + 1, largerCorner.height() + 1));
-        context->setStrokeColor(Color(makeRGB(217, 217, 217)));
+        context->setStrokeColor(Color(makeRGB(217, 217, 217)), DeviceColorSpace);
         context->setStrokeThickness(1.0f);
-        context->setFillColor(Color::transparent);
+        context->setFillColor(Color::transparent, DeviceColorSpace);
         context->drawRect(largerCorner);
         context->restore();
     }
diff --git a/WebCore/rendering/RenderListBox.cpp b/WebCore/rendering/RenderListBox.cpp
index 0edfdef..15c652c 100644
--- a/WebCore/rendering/RenderListBox.cpp
+++ b/WebCore/rendering/RenderListBox.cpp
@@ -321,7 +321,8 @@ void RenderListBox::paintItemForeground(PaintInfo& paintInfo, int tx, int ty, in
             textColor = theme()->inactiveListBoxSelectionForegroundColor();
     }
 
-    paintInfo.context->setFillColor(textColor);
+    ColorSpace colorSpace = itemStyle->colorSpace();
+    paintInfo.context->setFillColor(textColor, colorSpace);
 
     Font itemFont = style()->font();
     if (isOptionGroupElement(element)) {
@@ -358,9 +359,10 @@ void RenderListBox::paintItemBackground(PaintInfo& paintInfo, int tx, int ty, in
 
     // Draw the background for this list box item
     if (!element->renderStyle() || element->renderStyle()->visibility() != HIDDEN) {
+        ColorSpace colorSpace = element->renderStyle() ? element->renderStyle()->colorSpace() : style()->colorSpace();
         IntRect itemRect = itemBoundingBoxRect(tx, ty, listIndex);
         itemRect.intersect(controlClipRect(tx, ty));
-        paintInfo.context->fillRect(itemRect, backColor);
+        paintInfo.context->fillRect(itemRect, backColor, colorSpace);
     }
 }
 
diff --git a/WebCore/rendering/RenderListMarker.cpp b/WebCore/rendering/RenderListMarker.cpp
index 9627711..692666a 100644
--- a/WebCore/rendering/RenderListMarker.cpp
+++ b/WebCore/rendering/RenderListMarker.cpp
@@ -546,7 +546,7 @@ void RenderListMarker::paint(PaintInfo& paintInfo, int tx, int ty)
         context->drawImage(m_image->image(this, marker.size()), marker.location());
         if (selectionState() != SelectionNone) {
             // FIXME: selectionRect() is in absolute, not painting coordinates.
-            context->fillRect(selectionRect(), selectionBackgroundColor());
+            context->fillRect(selectionRect(), selectionBackgroundColor(), style()->colorSpace());
         }
         return;
     }
@@ -559,21 +559,21 @@ void RenderListMarker::paint(PaintInfo& paintInfo, int tx, int ty)
 
     if (selectionState() != SelectionNone) {
         // FIXME: selectionRect() is in absolute, not painting coordinates.
-        context->fillRect(selectionRect(), selectionBackgroundColor());
+        context->fillRect(selectionRect(), selectionBackgroundColor(), style()->colorSpace());
     }
 
     const Color color(style()->color());
-    context->setStrokeColor(color);
+    context->setStrokeColor(color, style()->colorSpace());
     context->setStrokeStyle(SolidStroke);
     context->setStrokeThickness(1.0f);
-    context->setFillColor(color);
+    context->setFillColor(color, style()->colorSpace());
 
     switch (style()->listStyleType()) {
         case DISC:
             context->drawEllipse(marker);
             return;
         case CIRCLE:
-            context->setFillColor(Color::transparent);
+            context->setFillColor(Color::transparent, DeviceColorSpace);
             context->drawEllipse(marker);
             return;
         case SQUARE:
diff --git a/WebCore/rendering/RenderObject.cpp b/WebCore/rendering/RenderObject.cpp
index 3dc565c..1e8e19f 100644
--- a/WebCore/rendering/RenderObject.cpp
+++ b/WebCore/rendering/RenderObject.cpp
@@ -716,7 +716,7 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
             return;
         case DOTTED:
         case DASHED:
-            graphicsContext->setStrokeColor(c);
+            graphicsContext->setStrokeColor(c, m_style->colorSpace());
             graphicsContext->setStrokeThickness(width);
             graphicsContext->setStrokeStyle(style == DASHED ? DashedStroke : DottedStroke);
 
@@ -737,7 +737,7 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
 
             if (adjbw1 == 0 && adjbw2 == 0) {
                 graphicsContext->setStrokeStyle(NoStroke);
-                graphicsContext->setFillColor(c);
+                graphicsContext->setFillColor(c, m_style->colorSpace());
                 switch (s) {
                     case BSTop:
                     case BSBottom:
@@ -850,7 +850,7 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
             // fall through
         case SOLID: {
             graphicsContext->setStrokeStyle(NoStroke);
-            graphicsContext->setFillColor(c);
+            graphicsContext->setFillColor(c, m_style->colorSpace());
             ASSERT(x2 >= x1);
             ASSERT(y2 >= y1);
             if (!adjbw1 && !adjbw2) {
@@ -910,7 +910,7 @@ void RenderObject::drawArcForBoxSide(GraphicsContext* graphicsContext, int x, in
             return;
         case DOTTED:
         case DASHED:
-            graphicsContext->setStrokeColor(c);
+            graphicsContext->setStrokeColor(c, m_style->colorSpace());
             graphicsContext->setStrokeStyle(style == DOTTED ? DottedStroke : DashedStroke);
             graphicsContext->setStrokeThickness(thickness);
             graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
@@ -932,7 +932,7 @@ void RenderObject::drawArcForBoxSide(GraphicsContext* graphicsContext, int x, in
             }
 
             graphicsContext->setStrokeStyle(SolidStroke);
-            graphicsContext->setStrokeColor(c);
+            graphicsContext->setStrokeColor(c, m_style->colorSpace());
             graphicsContext->setStrokeThickness(third);
             graphicsContext->strokeArc(IntRect(x, outerY, radius.width() * 2, outerHeight), angleStart, angleSpan);
             graphicsContext->setStrokeThickness(innerThird > 2 ? innerThird - 1 : innerThird);
@@ -951,13 +951,13 @@ void RenderObject::drawArcForBoxSide(GraphicsContext* graphicsContext, int x, in
             }
 
             graphicsContext->setStrokeStyle(SolidStroke);
-            graphicsContext->setStrokeColor(c);
+            graphicsContext->setStrokeColor(c, m_style->colorSpace());
             graphicsContext->setStrokeThickness(thickness);
             graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
 
             float halfThickness = (thickness + 1.0f) / 4.0f;
             int shiftForInner = static_cast<int>(halfThickness * 1.5f);
-            graphicsContext->setStrokeColor(c2);
+            graphicsContext->setStrokeColor(c2, m_style->colorSpace());
             graphicsContext->setStrokeThickness(halfThickness > 2 ? halfThickness - 1 : halfThickness);
             graphicsContext->strokeArc(IntRect(x + shiftForInner, y + shiftForInner, (radius.width() - shiftForInner) * 2,
                                        (radius.height() - shiftForInner) * 2), angleStart, angleSpan);
@@ -971,7 +971,7 @@ void RenderObject::drawArcForBoxSide(GraphicsContext* graphicsContext, int x, in
                 c = c.dark();
         case SOLID:
             graphicsContext->setStrokeStyle(SolidStroke);
-            graphicsContext->setStrokeColor(c);
+            graphicsContext->setStrokeColor(c, m_style->colorSpace());
             graphicsContext->setStrokeThickness(thickness);
             graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan);
             break;
diff --git a/WebCore/rendering/RenderReplaced.cpp b/WebCore/rendering/RenderReplaced.cpp
index 27d2e72..ba579df 100644
--- a/WebCore/rendering/RenderReplaced.cpp
+++ b/WebCore/rendering/RenderReplaced.cpp
@@ -153,7 +153,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
     if (drawSelectionTint) {
         IntRect selectionPaintingRect = localSelectionRect();
         selectionPaintingRect.move(tx, ty);
-        paintInfo.context->fillRect(selectionPaintingRect, selectionBackgroundColor());
+        paintInfo.context->fillRect(selectionPaintingRect, selectionBackgroundColor(), style()->colorSpace());
     }
 }
 
diff --git a/WebCore/rendering/RenderScrollbarTheme.cpp b/WebCore/rendering/RenderScrollbarTheme.cpp
index 06ca32a..19143cc 100644
--- a/WebCore/rendering/RenderScrollbarTheme.cpp
+++ b/WebCore/rendering/RenderScrollbarTheme.cpp
@@ -109,7 +109,7 @@ IntRect RenderScrollbarTheme::constrainTrackRectToTrackPieces(Scrollbar* scrollb
 void RenderScrollbarTheme::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect)
 {
     // FIXME: Implement.
-    context->fillRect(cornerRect, Color::white);
+    context->fillRect(cornerRect, Color::white, DeviceColorSpace);
 }
 
 void RenderScrollbarTheme::paintScrollbarBackground(GraphicsContext* context, Scrollbar* scrollbar)
diff --git a/WebCore/rendering/RenderThemeMac.mm b/WebCore/rendering/RenderThemeMac.mm
index 03e39a0..959841a 100644
--- a/WebCore/rendering/RenderThemeMac.mm
+++ b/WebCore/rendering/RenderThemeMac.mm
@@ -913,7 +913,7 @@ bool RenderThemeMac::paintMenuListButton(RenderObject* o, const RenderObject::Pa
     
     paintInfo.context->save();
 
-    paintInfo.context->setFillColor(o->style()->color());
+    paintInfo.context->setFillColor(o->style()->color(), o->style()->colorSpace());
     paintInfo.context->setStrokeStyle(NoStroke);
 
     FloatPoint arrow1[3];
@@ -942,11 +942,11 @@ bool RenderThemeMac::paintMenuListButton(RenderObject* o, const RenderObject::Pa
     // Draw the separator to the left of the arrows
     paintInfo.context->setStrokeThickness(1.0f); // Deliberately ignores zoom since it looks nicer if it stays thin.
     paintInfo.context->setStrokeStyle(SolidStroke);
-    paintInfo.context->setStrokeColor(leftSeparatorColor);
+    paintInfo.context->setStrokeColor(leftSeparatorColor, DeviceColorSpace);
     paintInfo.context->drawLine(IntPoint(leftEdgeOfSeparator, bounds.y()),
                                 IntPoint(leftEdgeOfSeparator, bounds.bottom()));
 
-    paintInfo.context->setStrokeColor(rightSeparatorColor);
+    paintInfo.context->setStrokeColor(rightSeparatorColor, DeviceColorSpace);
     paintInfo.context->drawLine(IntPoint(leftEdgeOfSeparator + separatorSpace, bounds.y()),
                                 IntPoint(leftEdgeOfSeparator + separatorSpace, bounds.bottom()));
 
diff --git a/WebCore/rendering/RenderView.cpp b/WebCore/rendering/RenderView.cpp
index e2b4b04..02a45d3 100644
--- a/WebCore/rendering/RenderView.cpp
+++ b/WebCore/rendering/RenderView.cpp
@@ -198,7 +198,7 @@ void RenderView::paintBoxDecorations(PaintInfo& paintInfo, int, int)
         if (baseColor.alpha() > 0) {
             paintInfo.context->save();
             paintInfo.context->setCompositeOperation(CompositeCopy);
-            paintInfo.context->fillRect(paintInfo.rect, baseColor);
+            paintInfo.context->fillRect(paintInfo.rect, baseColor, style()->colorSpace());
             paintInfo.context->restore();
         } else
             paintInfo.context->clearRect(paintInfo.rect);
diff --git a/WebCore/rendering/RenderWidget.cpp b/WebCore/rendering/RenderWidget.cpp
index dfce998..5150e5a 100644
--- a/WebCore/rendering/RenderWidget.cpp
+++ b/WebCore/rendering/RenderWidget.cpp
@@ -276,7 +276,7 @@ void RenderWidget::paint(PaintInfo& paintInfo, int tx, int ty)
     // Paint a partially transparent wash over selected widgets.
     if (isSelected() && !document()->printing()) {
         // FIXME: selectionRect() is in absolute, not painting coordinates.
-        paintInfo.context->fillRect(selectionRect(), selectionBackgroundColor());
+        paintInfo.context->fillRect(selectionRect(), selectionBackgroundColor(), style()->colorSpace());
     }
 }
 
diff --git a/WebCore/rendering/SVGInlineTextBox.cpp b/WebCore/rendering/SVGInlineTextBox.cpp
index 6f02863..a5d440d 100644
--- a/WebCore/rendering/SVGInlineTextBox.cpp
+++ b/WebCore/rendering/SVGInlineTextBox.cpp
@@ -475,7 +475,7 @@ void SVGInlineTextBox::paintSelection(int boxStartOffset, const SVGChar& svgChar
     int adjust = startPos >= boxStartOffset ? boxStartOffset : 0;
     p->drawHighlightForText(font, svgTextRunForInlineTextBox(textRenderer()->text()->characters() + start() + boxStartOffset, length, style, this, svgChar.x),
                             IntPoint((int) svgChar.x, (int) svgChar.y - font.ascent()),
-                            font.ascent() + font.descent(), color, startPos - adjust, endPos - adjust);
+                            font.ascent() + font.descent(), color, style->colorSpace(), startPos - adjust, endPos - adjust);
 
     p->restore();
 }
diff --git a/WebCore/rendering/style/RenderStyle.h b/WebCore/rendering/style/RenderStyle.h
index d3dee5b..0605f1f 100644
--- a/WebCore/rendering/style/RenderStyle.h
+++ b/WebCore/rendering/style/RenderStyle.h
@@ -37,6 +37,7 @@
 #include "CachedImage.h"
 #include "CollapsedBorderValue.h"
 #include "Color.h"
+#include "ColorSpace.h"
 #include "ContentData.h"
 #include "CounterDirectives.h"
 #include "CursorList.h"
@@ -599,6 +600,7 @@ public:
     const Color& textStrokeColor() const { return rareInheritedData->textStrokeColor; }
     float textStrokeWidth() const { return rareInheritedData->textStrokeWidth; }
     const Color& textFillColor() const { return rareInheritedData->textFillColor; }
+    ColorSpace colorSpace() const { return static_cast<ColorSpace>(rareInheritedData->colorSpace); }
     float opacity() const { return rareNonInheritedData->opacity; }
     ControlPart appearance() const { return static_cast<ControlPart>(rareNonInheritedData->m_appearance); }
     EBoxAlignment boxAlign() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->align); }
@@ -930,6 +932,7 @@ public:
     void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c) }
     void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w) }
     void setTextFillColor(const Color& c) { SET_VAR(rareInheritedData, textFillColor, c) }
+    void setColorSpace(ColorSpace space) { SET_VAR(rareInheritedData, colorSpace, space) }
     void setOpacity(float f) { SET_VAR(rareNonInheritedData, opacity, f); }
     void setAppearance(ControlPart a) { SET_VAR(rareNonInheritedData, m_appearance, a); }
     void setBoxAlign(EBoxAlignment a) { SET_VAR(rareNonInheritedData.access()->flexibleBox, align, a); }
diff --git a/WebCore/rendering/style/StyleRareInheritedData.cpp b/WebCore/rendering/style/StyleRareInheritedData.cpp
index ce21720..f731098 100644
--- a/WebCore/rendering/style/StyleRareInheritedData.cpp
+++ b/WebCore/rendering/style/StyleRareInheritedData.cpp
@@ -39,6 +39,7 @@ StyleRareInheritedData::StyleRareInheritedData()
     , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
     , resize(RenderStyle::initialResize())
     , userSelect(RenderStyle::initialUserSelect())
+    , colorSpace(DeviceColorSpace)
 {
 }
 
@@ -58,6 +59,7 @@ StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
     , textSizeAdjust(o.textSizeAdjust)
     , resize(o.resize)
     , userSelect(o.userSelect)
+    , colorSpace(o.colorSpace)
 {
 }
 
@@ -81,7 +83,8 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
         && khtmlLineBreak == o.khtmlLineBreak
         && textSizeAdjust == o.textSizeAdjust
         && resize == o.resize
-        && userSelect == o.userSelect;
+        && userSelect == o.userSelect
+        && colorSpace == o.colorSpace;
 }
 
 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
diff --git a/WebCore/rendering/style/StyleRareInheritedData.h b/WebCore/rendering/style/StyleRareInheritedData.h
index 06ad400..2e87e6b 100644
--- a/WebCore/rendering/style/StyleRareInheritedData.h
+++ b/WebCore/rendering/style/StyleRareInheritedData.h
@@ -65,6 +65,7 @@ public:
     bool textSizeAdjust : 1; // An Apple extension.
     unsigned resize : 2; // EResize
     unsigned userSelect : 1;  // EUserSelect
+    unsigned colorSpace : 1; // ColorSpace
     
 private:
     StyleRareInheritedData();
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
index 4a8e9e0..74e3c22 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
@@ -233,7 +233,7 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
         // lines or rectangles without width or height.
         if (bbox.width() == 0 || bbox.height() == 0) {
             Color color(0, 0, 0);
-            context->setStrokeColor(color);
+            context->setStrokeColor(color, object->style()->colorSpace());
             return true;
         }
         matrix.translate(bbox.x(), bbox.y());
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.cpp b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
index b333042..72baad2 100644
--- a/WebCore/svg/graphics/SVGPaintServerSolid.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
@@ -64,10 +64,11 @@ bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* o
 {
     RenderStyle* style = object ? object->style() : 0;
     const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0;
+    ColorSpace colorSpace = style ? style->colorSpace() : DeviceColorSpace;
 
     if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) {
         context->setAlpha(style ? svgStyle->fillOpacity() : 1);
-        context->setFillColor(color().rgb());
+        context->setFillColor(color().rgb(), colorSpace);
         context->setFillRule(style ? svgStyle->fillRule() : RULE_NONZERO);
 
         if (isPaintingText)
@@ -76,7 +77,7 @@ bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* o
 
     if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) {
         context->setAlpha(style ? svgStyle->strokeOpacity() : 1);
-        context->setStrokeColor(color().rgb());
+        context->setStrokeColor(color().rgb(), colorSpace);
 
         if (style)
             applyStrokeStyleToContext(context, style, object);
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 2f69c18..57c8240 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,17 @@
+2009-11-10  Beth Dakin  <bdakin at apple.com>
+
+        Reviewed by Darin Adler.
+
+        Small WebKit part of:
+        Fix for <rdar://problem/7059710> 
+        -and corresponding-
+        https://bugs.webkit.org/show_bug.cgi?id=31196 Implement -webkit-
+        color-correction for CSS colors
+
+        * Misc/WebKitNSStringExtras.mm:
+        (-[NSString _web_drawAtPoint:font:textColor:]): setFillColor now 
+        requires callers to pass a ColorSpace.
+
 2009-11-10  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Eric Carlson and Darin Adler.
diff --git a/WebKit/mac/Misc/WebKitNSStringExtras.mm b/WebKit/mac/Misc/WebKitNSStringExtras.mm
index 5eb3e1f..da46630 100644
--- a/WebKit/mac/Misc/WebKitNSStringExtras.mm
+++ b/WebKit/mac/Misc/WebKitNSStringExtras.mm
@@ -93,7 +93,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
         CGFloat blue;
         CGFloat alpha;
         [[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
-        graphicsContext.setFillColor(makeRGBA(red * 255, green * 255, blue * 255, alpha * 255));
+        graphicsContext.setFillColor(makeRGBA(red * 255, green * 255, blue * 255, alpha * 255), DeviceColorSpace);
 
         webCoreFont.drawText(&graphicsContext, run, FloatPoint(point.x, (flipped ? point.y : (-1 * point.y))));
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list