2011-05-23 Mike Lawther <mikelawther@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2011 02:25:43 +0000 (02:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2011 02:25:43 +0000 (02:25 +0000)
        Reviewed by James Robinson.

        implement image-rendering: optimize-contrast (with a vendor prefix) as defined in CSS3 image values
        https://bugs.webkit.org/show_bug.cgi?id=56627

        * css3/images/optimize-contrast-canvas-expected.checksum: Added.
        * css3/images/optimize-contrast-canvas-expected.png: Added.
        * css3/images/optimize-contrast-canvas-expected.txt: Added.
        * css3/images/optimize-contrast-canvas.html: Added.
        * css3/images/optimize-contrast-image-expected.checksum: Added.
        * css3/images/optimize-contrast-image-expected.png: Added.
        * css3/images/optimize-contrast-image-expected.txt: Added.
        * css3/images/optimize-contrast-image.html: Added.
2011-05-23  Mike Lawther  <mikelawther@chromium.org>

        Reviewed by James Robinson.

        implement image-rendering: optimize-contrast (with a vendor prefix) as defined in CSS3 image values
        https://bugs.webkit.org/show_bug.cgi?id=56627

        Tests: css3/images/optimize-contrast-canvas.html
               css3/images/optimize-contrast-image.html

        * WebCore.xcodeproj/project.pbxproj:
        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
        * css/CSSParser.cpp:
        (WebCore::CSSParser::parseValue):
        * css/CSSPrimitiveValueMappings.h:
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
        (WebCore::CSSPrimitiveValue::operator EImageRendering):
        * css/CSSPropertyNames.in:
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applyProperty):
        * css/CSSValueKeywords.in:
        * css/SVGCSSComputedStyleDeclaration.cpp:
        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
        * css/SVGCSSPropertyNames.in:
        * css/SVGCSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applySVGProperty):
        * css/SVGCSSValueKeywords.in:
        * html/HTMLCanvasElement.cpp:
        (WebCore::HTMLCanvasElement::paint):
        * html/HTMLCanvasElement.h:
        * platform/graphics/ImageRenderingMode.h: Added.
        * rendering/RenderBoxModelObject.cpp:
        (WebCore::ImageQualityController::shouldPaintAtLowQuality):
        * rendering/RenderHTMLCanvas.cpp:
        (WebCore::RenderHTMLCanvas::paintReplaced):
        * rendering/style/RenderStyle.cpp:
        (WebCore::RenderStyle::diff):
        * rendering/style/RenderStyle.h:
        (WebCore::InheritedFlags::imageRendering):
        (WebCore::InheritedFlags::setImageRendering):
        (WebCore::InheritedFlags::initialImageRendering):
        * rendering/style/RenderStyleConstants.h:
        * rendering/style/SVGRenderStyle.cpp:
        (WebCore::SVGRenderStyle::diff):
        * rendering/style/SVGRenderStyle.h:
        (WebCore::SVGRenderStyle::InheritedFlags::operator==):
        (WebCore::SVGRenderStyle::setBitDefaults):
        * rendering/style/SVGRenderStyleDefs.h:
        * rendering/svg/SVGRenderTreeAsText.cpp:
        (WebCore::writeStyle):

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

38 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/images/optimize-contrast-canvas-expected.png [new file with mode: 0644]
LayoutTests/css3/images/optimize-contrast-canvas-expected.txt [new file with mode: 0644]
LayoutTests/css3/images/optimize-contrast-canvas.html [new file with mode: 0644]
LayoutTests/css3/images/optimize-contrast-image-expected.png [new file with mode: 0644]
LayoutTests/css3/images/optimize-contrast-image-expected.txt [new file with mode: 0644]
LayoutTests/css3/images/optimize-contrast-image.html [new file with mode: 0644]
LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt
LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
LayoutTests/platform/qt/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
LayoutTests/svg/css/getComputedStyle-basic-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp
Source/WebCore/css/SVGCSSPropertyNames.in
Source/WebCore/css/SVGCSSStyleSelector.cpp
Source/WebCore/css/SVGCSSValueKeywords.in
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLCanvasElement.h
Source/WebCore/platform/graphics/ImageRenderingMode.h [new file with mode: 0644]
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderHTMLCanvas.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/rendering/style/SVGRenderStyle.cpp
Source/WebCore/rendering/style/SVGRenderStyle.h
Source/WebCore/rendering/style/SVGRenderStyleDefs.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h
Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp

index 3b26bcc..c70771b 100644 (file)
@@ -1,3 +1,19 @@
+2011-05-23  Mike Lawther  <mikelawther@chromium.org>
+
+        Reviewed by James Robinson.
+
+        implement image-rendering: optimize-contrast (with a vendor prefix) as defined in CSS3 image values
+        https://bugs.webkit.org/show_bug.cgi?id=56627
+
+        * css3/images/optimize-contrast-canvas-expected.checksum: Added.
+        * css3/images/optimize-contrast-canvas-expected.png: Added.
+        * css3/images/optimize-contrast-canvas-expected.txt: Added.
+        * css3/images/optimize-contrast-canvas.html: Added.
+        * css3/images/optimize-contrast-image-expected.checksum: Added.
+        * css3/images/optimize-contrast-image-expected.png: Added.
+        * css3/images/optimize-contrast-image-expected.txt: Added.
+        * css3/images/optimize-contrast-image.html: Added.
+
 2011-05-23  Justin Schuh  <jschuh@chromium.org>
 
         Unreviewed.
diff --git a/LayoutTests/css3/images/optimize-contrast-canvas-expected.png b/LayoutTests/css3/images/optimize-contrast-canvas-expected.png
new file mode 100644 (file)
index 0000000..f591dec
Binary files /dev/null and b/LayoutTests/css3/images/optimize-contrast-canvas-expected.png differ
diff --git a/LayoutTests/css3/images/optimize-contrast-canvas-expected.txt b/LayoutTests/css3/images/optimize-contrast-canvas-expected.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/LayoutTests/css3/images/optimize-contrast-canvas.html b/LayoutTests/css3/images/optimize-contrast-canvas.html
new file mode 100644 (file)
index 0000000..b9d1f4f
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE html> 
+<style> 
+       canvas {
+               display: block;
+               position: fixed;
+               left: 0px;
+               top: 0px;
+               right: 0px;
+               bottom: 0px;
+               border: none;
+               width: 100px;
+               height: 100px;
+               margin: 0px;
+               padding: 0px;
+               image-rendering: -webkit-optimize-contrast;
+       }
+</style> 
+<body> 
+    <!-- The resulting image should be 100x100, consisting of 4 50x50 blocks of solid color, with no blurring of edges -->
+       <canvas width="2" height="2"></canvas> 
+</body> 
+<script> 
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText(true);
+        
+       var canvas;
+       var imageHandle;
+       canvas = document.getElementsByTagName("canvas")[0].getContext("2d");
+       canvas.width = 2;
+       canvas.height = 2;
+       imageHandle = canvas.createImageData(2, 2);
+
+       var index = 0;
+       var length = imageHandle.data.length;
+
+    imageHandle.data[index++] = 255;
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 255;
+
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 255;
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 255;
+
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 255;
+    imageHandle.data[index++] = 255;
+
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 0;
+    imageHandle.data[index++] = 255;
+
+       canvas.putImageData(imageHandle, 0, 0);
+</script> 
diff --git a/LayoutTests/css3/images/optimize-contrast-image-expected.png b/LayoutTests/css3/images/optimize-contrast-image-expected.png
new file mode 100644 (file)
index 0000000..f591dec
Binary files /dev/null and b/LayoutTests/css3/images/optimize-contrast-image-expected.png differ
diff --git a/LayoutTests/css3/images/optimize-contrast-image-expected.txt b/LayoutTests/css3/images/optimize-contrast-image-expected.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/LayoutTests/css3/images/optimize-contrast-image.html b/LayoutTests/css3/images/optimize-contrast-image.html
new file mode 100644 (file)
index 0000000..032fcfa
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html> 
+<style> 
+       img {
+               display: block;
+               position: fixed;
+               left: 0px;
+               top: 0px;
+               right: 0px;
+               bottom: 0px;
+               border: none;
+               width: 100px;
+               height: 100px;
+               margin: 0px;
+               padding: 0px;
+               image-rendering: -webkit-optimize-contrast;
+       }
+</style> 
+<body> 
+    <!-- The resulting image should be 100x100, consisting of 4 50x50 blocks of solid color, with no blurring of edges -->
+       <image style="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFElEQVQIHWP4z8DwHwyBNJDN8B8AQNEG+t5Ik2kAAAAASUVORK5CYII="></img> 
+</body> 
+<script> 
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText(true);
+</script>
index 67b7e0e..a77054c 100644 (file)
@@ -43,6 +43,7 @@ font-style: normal;
 font-variant: normal;
 font-weight: normal;
 height: 576px;
+image-rendering: auto;
 left: auto;
 letter-spacing: normal;
 line-height: normal;
@@ -200,7 +201,6 @@ color-rendering: auto;
 fill: #000000;
 fill-opacity: 1;
 fill-rule: nonzero;
-image-rendering: auto;
 marker-end: none;
 marker-mid: none;
 marker-start: none;
index 4a34db2..cb74c29 100644 (file)
@@ -42,6 +42,7 @@ Computed style of an element whose parent's 'display' value is 'none':
     font-variant: normal
     font-weight: normal
     height: 100px
+    image-rendering: auto
     left: auto
     letter-spacing: normal
     line-height: normal
@@ -190,7 +191,6 @@ Computed style of an element whose parent's 'display' value is 'none':
     fill: #000000
     fill-opacity: 1
     fill-rule: nonzero
-    image-rendering: auto
     marker-end: none
     marker-mid: none
     marker-start: none
index 843e09b..5539683 100644 (file)
@@ -42,6 +42,7 @@ Computed style of an element whose parent's 'display' value is 'none':
     font-variant: normal
     font-weight: normal
     height: 100px
+    image-rendering: auto
     left: auto
     letter-spacing: normal
     line-height: normal
@@ -199,7 +200,6 @@ Computed style of an element whose parent's 'display' value is 'none':
     fill: #000000
     fill-opacity: 1
     fill-rule: nonzero
-    image-rendering: auto
     marker-end: none
     marker-mid: none
     marker-start: none
index 843e09b..5539683 100644 (file)
@@ -42,6 +42,7 @@ Computed style of an element whose parent's 'display' value is 'none':
     font-variant: normal
     font-weight: normal
     height: 100px
+    image-rendering: auto
     left: auto
     letter-spacing: normal
     line-height: normal
@@ -199,7 +200,6 @@ Computed style of an element whose parent's 'display' value is 'none':
     fill: #000000
     fill-opacity: 1
     fill-rule: nonzero
-    image-rendering: auto
     marker-end: none
     marker-mid: none
     marker-start: none
index 6f66cf0..7d0f521 100644 (file)
@@ -84,6 +84,8 @@ rect: style.getPropertyValue(font-weight) : normal
 rect: style.getPropertyCSSValue(font-weight) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(height) : 0px
 rect: style.getPropertyCSSValue(height) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(image-rendering) : auto
+rect: style.getPropertyCSSValue(image-rendering) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(left) : auto
 rect: style.getPropertyCSSValue(left) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(letter-spacing) : normal
@@ -398,8 +400,6 @@ rect: style.getPropertyValue(fill-opacity) : 1
 rect: style.getPropertyCSSValue(fill-opacity) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(fill-rule) : nonzero
 rect: style.getPropertyCSSValue(fill-rule) : [object CSSPrimitiveValue]
-rect: style.getPropertyValue(image-rendering) : auto
-rect: style.getPropertyCSSValue(image-rendering) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(marker-end) : none
 rect: style.getPropertyCSSValue(marker-end) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(marker-mid) : none
@@ -530,6 +530,8 @@ g: style.getPropertyValue(font-weight) : normal
 g: style.getPropertyCSSValue(font-weight) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(height) : 0px
 g: style.getPropertyCSSValue(height) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(image-rendering) : auto
+g: style.getPropertyCSSValue(image-rendering) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(left) : auto
 g: style.getPropertyCSSValue(left) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(letter-spacing) : normal
@@ -844,8 +846,6 @@ g: style.getPropertyValue(fill-opacity) : 1
 g: style.getPropertyCSSValue(fill-opacity) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(fill-rule) : nonzero
 g: style.getPropertyCSSValue(fill-rule) : [object CSSPrimitiveValue]
-g: style.getPropertyValue(image-rendering) : auto
-g: style.getPropertyCSSValue(image-rendering) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(marker-end) : none
 g: style.getPropertyCSSValue(marker-end) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(marker-mid) : none
index 0f96456..32fddbf 100644 (file)
@@ -1,3 +1,55 @@
+2011-05-23  Mike Lawther  <mikelawther@chromium.org>
+
+        Reviewed by James Robinson.
+
+        implement image-rendering: optimize-contrast (with a vendor prefix) as defined in CSS3 image values
+        https://bugs.webkit.org/show_bug.cgi?id=56627
+
+        Tests: css3/images/optimize-contrast-canvas.html
+               css3/images/optimize-contrast-image.html
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EImageRendering):
+        * css/CSSPropertyNames.in:
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * css/CSSValueKeywords.in:
+        * css/SVGCSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
+        * css/SVGCSSPropertyNames.in:
+        * css/SVGCSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applySVGProperty):
+        * css/SVGCSSValueKeywords.in:
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::paint):
+        * html/HTMLCanvasElement.h:
+        * platform/graphics/ImageRenderingMode.h: Added.
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::ImageQualityController::shouldPaintAtLowQuality):
+        * rendering/RenderHTMLCanvas.cpp:
+        (WebCore::RenderHTMLCanvas::paintReplaced):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::diff):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::imageRendering):
+        (WebCore::InheritedFlags::setImageRendering):
+        (WebCore::InheritedFlags::initialImageRendering):
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/SVGRenderStyle.cpp:
+        (WebCore::SVGRenderStyle::diff):
+        * rendering/style/SVGRenderStyle.h:
+        (WebCore::SVGRenderStyle::InheritedFlags::operator==):
+        (WebCore::SVGRenderStyle::setBitDefaults):
+        * rendering/style/SVGRenderStyleDefs.h:
+        * rendering/svg/SVGRenderTreeAsText.cpp:
+        (WebCore::writeStyle):
+
 2011-05-23  Sailesh Agrawal  <sail@chromium.org>
 
         Reviewed by James Robinson.
index 0b78d89..c714d91 100644 (file)
                490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */; };
                490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; };
                492863991253B8FC00F792D6 /* ResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 492863981253B8FC00F792D6 /* ResourceLoadInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               49291E4B134172C800E753DE /* ImageRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 49291E4A134172C800E753DE /* ImageRenderingMode.h */; };
                493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 493E5E0812D6420500020081 /* PlatformCALayerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */; };
                49484FC2102CF23C00187DD3 /* CanvasGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 49484FB4102CF23C00187DD3 /* CanvasGradient.h */; };
                490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEWebKitBridge.cpp; sourceTree = "<group>"; };
                490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = "<group>"; };
                492863981253B8FC00F792D6 /* ResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadInfo.h; sourceTree = "<group>"; };
+               49291E4A134172C800E753DE /* ImageRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageRenderingMode.h; sourceTree = "<group>"; };
                493E5E0812D6420500020081 /* PlatformCALayerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCALayerClient.h; path = ca/PlatformCALayerClient.h; sourceTree = "<group>"; };
                49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CanvasGradient.cpp; path = canvas/CanvasGradient.cpp; sourceTree = "<group>"; };
                49484FB4102CF23C00187DD3 /* CanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasGradient.h; path = canvas/CanvasGradient.h; sourceTree = "<group>"; };
                                B2A10B910B3818BD00099AA4 /* ImageBuffer.h */,
                                22BD9F7D1353625C009BD102 /* ImageBufferData.h */,
                                BC7F44A70B9E324E00A9D081 /* ImageObserver.h */,
+                               49291E4A134172C800E753DE /* ImageRenderingMode.h */,
                                B27535430B053814002CE64F /* ImageSource.h */,
                                B27535440B053814002CE64F /* IntPoint.h */,
                                E462A4A0113E71BE004A4220 /* IntPointHash.h */,
                                F55B3DC21251F12D003EF269 /* ImageInputType.h in Headers */,
                                089582560E857A7E00F82C83 /* ImageLoader.h in Headers */,
                                BC7F44A80B9E324E00A9D081 /* ImageObserver.h in Headers */,
+                               49291E4B134172C800E753DE /* ImageRenderingMode.h in Headers */,
                                B27535710B053814002CE64F /* ImageSource.h in Headers */,
                                4B3480940EEF50D400AC1B41 /* ImageSourceCG.h in Headers */,
                                316FE1180E6E1DA700BF6088 /* ImplicitAnimation.h in Headers */,
index 08626dd..13d6340 100644 (file)
@@ -99,6 +99,7 @@ static const int computedProperties[] = {
     CSSPropertyFontVariant,
     CSSPropertyFontWeight,
     CSSPropertyHeight,
+    CSSPropertyImageRendering,
     CSSPropertyLeft,
     CSSPropertyLetterSpacing,
     CSSPropertyLineHeight,
@@ -263,7 +264,6 @@ static const int computedProperties[] = {
     CSSPropertyFill,
     CSSPropertyFillOpacity,
     CSSPropertyFillRule,
-    CSSPropertyImageRendering,
     CSSPropertyMarkerEnd,
     CSSPropertyMarkerMid,
     CSSPropertyMarkerStart,
@@ -1156,6 +1156,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             if (style->borderFit() == BorderFitBorder)
                 return primitiveValueCache->createIdentifierValue(CSSValueBorder);
             return primitiveValueCache->createIdentifierValue(CSSValueLines);
+        case CSSPropertyImageRendering:
+            return CSSPrimitiveValue::create(style->imageRendering());
         case CSSPropertyLeft:
             return getPositionOffsetValue(style.get(), CSSPropertyLeft, primitiveValueCache);
         case CSSPropertyLetterSpacing:
@@ -1782,7 +1784,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyFill:
         case CSSPropertyFillOpacity:
         case CSSPropertyFillRule:
-        case CSSPropertyImageRendering:
         case CSSPropertyMarker:
         case CSSPropertyMarkerEnd:
         case CSSPropertyMarkerMid:
index 5824135..c64d725 100644 (file)
@@ -1716,7 +1716,10 @@ bool CSSParser::parseValue(int propId, bool important)
             (id >= CSSValueVisiblepainted && id <= CSSValueStroke))
             validPrimitive = true;
         break;
-
+    case CSSPropertyImageRendering: // auto | optimizeContrast
+        if (id == CSSValueAuto || id == CSSValueWebkitOptimizeContrast)
+            validPrimitive = true;
+        break;
     // End of CSS3 properties
 
     // Apple specific properties.  These will never be standardized and are purely to
index dd6fee0..e3022e6 100644 (file)
@@ -2801,6 +2801,43 @@ template<> inline CSSPrimitiveValue::operator EBorderCollapse() const
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e)
+    : m_type(CSS_IDENT)
+    , m_hasCachedCSSText(false)
+{
+    switch (e) {
+    case ImageRenderingAuto:
+        m_value.ident = CSSValueAuto;
+        break;
+    case ImageRenderingOptimizeSpeed:
+        m_value.ident = CSSValueOptimizespeed;
+        break;
+    case ImageRenderingOptimizeQuality:
+        m_value.ident = CSSValueOptimizequality;
+        break;
+    case ImageRenderingOptimizeContrast:
+        m_value.ident = CSSValueWebkitOptimizeContrast;
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EImageRendering() const
+{
+    switch (m_value.ident) {
+    case CSSValueAuto:
+        return ImageRenderingAuto;
+    case CSSValueOptimizespeed:
+        return ImageRenderingOptimizeSpeed;
+    case CSSValueOptimizequality:
+        return ImageRenderingOptimizeQuality;
+    case CSSValueWebkitOptimizeContrast:
+        return ImageRenderingOptimizeContrast;
+    default:
+        ASSERT_NOT_REACHED();
+        return ImageRenderingAuto;
+    }
+}
+    
 #if ENABLE(SVG)
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorInterpolation e)
@@ -2944,38 +2981,6 @@ template<> inline CSSPrimitiveValue::operator EDominantBaseline() const
     }
 }
 
-template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e)
-    : m_type(CSS_IDENT)
-    , m_hasCachedCSSText(false)
-{
-    switch (e) {
-        case IR_AUTO:
-            m_value.ident = CSSValueAuto;
-            break;
-        case IR_OPTIMIZESPEED:
-            m_value.ident = CSSValueOptimizespeed;
-            break;
-        case IR_OPTIMIZEQUALITY:
-            m_value.ident = CSSValueOptimizequality;
-            break;
-    }
-}
-
-template<> inline CSSPrimitiveValue::operator EImageRendering() const
-{
-    switch (m_value.ident) {
-        case CSSValueAuto:
-            return IR_AUTO;
-        case CSSValueOptimizespeed:
-            return IR_OPTIMIZESPEED;
-        case CSSValueOptimizequality:
-            return IR_OPTIMIZEQUALITY;
-        default:
-            ASSERT_NOT_REACHED();
-            return IR_AUTO;
-    }
-}
-
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EShapeRendering e)
     : m_type(CSS_IDENT)
     , m_hasCachedCSSText(false)
index ea54c12..9fa62e1 100644 (file)
@@ -93,6 +93,7 @@ empty-cells
 float
 font-stretch
 height
+image-rendering
 left
 letter-spacing
 list-style
index 99e65ec..db62e48 100644 (file)
@@ -4698,6 +4698,11 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset)
         m_style->setOutlineOffset(primitiveValue->computeLengthInt(style(), m_rootElementStyle, zoomFactor));
         return;
+    case CSSPropertyImageRendering:
+        if (!primitiveValue)
+            return;
+        m_style->setImageRendering(*primitiveValue);
+        return;
     case CSSPropertyTextRendering: {
         FontDescription fontDescription = m_style->fontDescription();
         if (isInherit) 
index 6dac06f..d670a62 100644 (file)
@@ -803,4 +803,8 @@ glyphs
 inline-box
 replaced
 
-
+# image-rendering
+#auto
+#optimizeSpeed
+optimizeQuality
+-webkit-optimize-contrast
index 5dfe03e..0c2aaff 100644 (file)
@@ -103,8 +103,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro
             return CSSPrimitiveValue::create(svgStyle->fillRule());
         case CSSPropertyColorRendering:
             return CSSPrimitiveValue::create(svgStyle->colorRendering());
-        case CSSPropertyImageRendering:
-            return CSSPrimitiveValue::create(svgStyle->imageRendering());
         case CSSPropertyShapeRendering:
             return CSSPrimitiveValue::create(svgStyle->shapeRendering());
         case CSSPropertyStrokeLinecap:
index 7c157a8..38ad3b6 100644 (file)
@@ -23,7 +23,7 @@ fill
 fill-opacity
 fill-rule
 #font-size-adjust
-image-rendering
+#image-rendering
 marker
 marker-end
 marker-mid
index 6b09426..8cb6b7e 100644 (file)
@@ -214,13 +214,6 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
                 svgstyle->setJoinStyle(*primitiveValue);
             break;
         }
-        case CSSPropertyImageRendering:
-        {
-            HANDLE_INHERIT_AND_INITIAL(imageRendering, ImageRendering)
-            if (primitiveValue)
-                svgstyle->setImageRendering(*primitiveValue);
-            break;
-        }
         case CSSPropertyShapeRendering:
         {
             HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering)
index a2c9f83..417a8d5 100644 (file)
@@ -197,7 +197,7 @@ linearRGB
 # CSS_PROP_COLOR_RENDERING
 #auto
 #optimizeSpeed
-optimizeQuality
+#optimizeQuality
 
 ## CSS_PROP_FILL
 #currentColor
index d416562..5f3d633 100644 (file)
@@ -262,7 +262,7 @@ void HTMLCanvasElement::reset()
         (*it)->canvasResized(this);
 }
 
-void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
+void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r, bool useLowQualityScale)
 {
     // Clear the dirty rect
     m_dirtyRect = FloatRect();
@@ -280,11 +280,11 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
         ImageBuffer* imageBuffer = buffer();
         if (imageBuffer) {
             if (m_presentedImage)
-                context->drawImage(m_presentedImage.get(), ColorSpaceDeviceRGB, r);
+                context->drawImage(m_presentedImage.get(), ColorSpaceDeviceRGB, r, CompositeSourceOver, useLowQualityScale);
             else if (imageBuffer->drawsUsingCopy())
-                context->drawImage(copiedImage(), ColorSpaceDeviceRGB, r);
+                context->drawImage(copiedImage(), ColorSpaceDeviceRGB, r, CompositeSourceOver, useLowQualityScale);
             else
-                context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, r);
+                context->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, r, CompositeSourceOver, useLowQualityScale);
         }
     }
 
index 97d55cc..9db9673 100644 (file)
@@ -97,7 +97,7 @@ public:
     // Used for rendering
     void didDraw(const FloatRect&);
 
-    void paint(GraphicsContext*, const IntRect&);
+    void paint(GraphicsContext*, const IntRect&, bool useLowQualityScale = false);
 
     GraphicsContext* drawingContext() const;
     GraphicsContext* existingDrawingContext() const;
diff --git a/Source/WebCore/platform/graphics/ImageRenderingMode.h b/Source/WebCore/platform/graphics/ImageRenderingMode.h
new file mode 100644 (file)
index 0000000..3e462fb
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011 Google 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. AND ITS CONTRIBUTORS ``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 ITS 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 ImageRenderingMode_h
+#define ImageRenderingMode_h
+    
+namespace WebCore {
+
+enum ImageRenderingMode { AutoImageRendering, OptimizeContrast };
+
+} // namespace WebCore
+    
+#endif // ImageRenderingMode_h
index c03ba3b..b25217e 100644 (file)
@@ -139,6 +139,9 @@ bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R
     if (!image || !image->isBitmapImage() || context->paintingDisabled())
         return false;
 
+    if (object->style()->imageRendering() == ImageRenderingOptimizeContrast)
+        return true;
+    
     // Make sure to use the unzoomed image size, since if a full page zoom is in effect, the image
     // is actually being scaled.
     IntSize imageSize(image->width(), image->height());
index de2a2c1..821c5b0 100644 (file)
@@ -58,7 +58,8 @@ void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, int tx, int ty)
 {
     IntRect rect = contentBoxRect();
     rect.move(tx, ty);
-    static_cast<HTMLCanvasElement*>(node())->paint(paintInfo.context, rect);
+    bool useLowQualityScale = style()->imageRendering() == ImageRenderingOptimizeContrast;
+    static_cast<HTMLCanvasElement*>(node())->paint(paintInfo.context, rect, useLowQualityScale);
 }
 
 void RenderHTMLCanvas::canvasSizeChanged()
index 7d8663a..4ea8b29 100644 (file)
@@ -560,7 +560,8 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
         || rareInheritedData->textFillColor != other->rareInheritedData->textFillColor
         || rareInheritedData->textStrokeColor != other->rareInheritedData->textStrokeColor
         || rareInheritedData->textEmphasisColor != other->rareInheritedData->textEmphasisColor
-        || rareInheritedData->textEmphasisFill != other->rareInheritedData->textEmphasisFill)
+        || rareInheritedData->textEmphasisFill != other->rareInheritedData->textEmphasisFill
+        || rareInheritedData->m_imageRendering != other->rareInheritedData->m_imageRendering)
         return StyleDifferenceRepaint;
 
 #if USE(ACCELERATED_COMPOSITING)
index 23f5535..743f9fe 100644 (file)
@@ -783,6 +783,8 @@ public:
     bool isFlippedLinesWritingMode() const { return writingMode() == LeftToRightWritingMode || writingMode() == BottomToTopWritingMode; }
     bool isFlippedBlocksWritingMode() const { return writingMode() == RightToLeftWritingMode || writingMode() == BottomToTopWritingMode; }
 
+    EImageRendering imageRendering() const { return static_cast<EImageRendering>(rareInheritedData->m_imageRendering); }
+    
     ESpeak speak() { return static_cast<ESpeak>(rareInheritedData->speak); }
         
 // attribute setter methods
@@ -934,6 +936,7 @@ public:
     void setLineHeight(Length v) { SET_VAR(inherited, line_height, v) }
     void setZoom(float f) { SET_VAR(visual, m_zoom, f); setEffectiveZoom(effectiveZoom() * zoom()); }
     void setEffectiveZoom(float f) { SET_VAR(rareInheritedData, m_effectiveZoom, f) }
+    void setImageRendering(EImageRendering v) { SET_VAR(rareInheritedData, m_imageRendering, v) }
 
     void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; }
 
@@ -1317,6 +1320,7 @@ public:
     static const AtomicString& initialTextEmphasisCustomMark() { return nullAtom; }
     static TextEmphasisPosition initialTextEmphasisPosition() { return TextEmphasisPositionOver; }
     static LineBoxContain initialLineBoxContain() { return LineBoxContainBlock | LineBoxContainInline | LineBoxContainReplaced; }
+    static EImageRendering initialImageRendering() { return ImageRenderingAuto; }
 
     // Keep these at the end.
     static LineClampValue initialLineClamp() { return LineClampValue(); }
index ccf15f9..ca55865 100644 (file)
@@ -426,6 +426,8 @@ enum TextEmphasisMark { TextEmphasisMarkNone, TextEmphasisMarkAuto, TextEmphasis
 
 enum TextEmphasisPosition { TextEmphasisPositionOver, TextEmphasisPositionUnder };
 
+enum EImageRendering { ImageRenderingAuto, ImageRenderingOptimizeSpeed, ImageRenderingOptimizeQuality, ImageRenderingOptimizeContrast };
+    
 } // namespace WebCore
 
 #endif // RenderStyleConstants_h
index b2be48e..6049f74 100644 (file)
@@ -203,7 +203,6 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
 
     // Changes of these flags only cause repaints.
     if (svg_inherited_flags._colorRendering != other->svg_inherited_flags._colorRendering
-        || svg_inherited_flags._imageRendering != other->svg_inherited_flags._imageRendering
         || svg_inherited_flags._shapeRendering != other->svg_inherited_flags._shapeRendering
         || svg_inherited_flags._clipRule != other->svg_inherited_flags._clipRule
         || svg_inherited_flags._fillRule != other->svg_inherited_flags._fillRule
index 88a48df..0fe4a80 100644 (file)
@@ -63,7 +63,6 @@ public:
     static EColorInterpolation initialColorInterpolationFilters() { return CI_LINEARRGB; }
     static EColorRendering initialColorRendering() { return CR_AUTO; }
     static WindRule initialFillRule() { return RULE_NONZERO; }
-    static EImageRendering initialImageRendering() { return IR_AUTO; }
     static LineJoin initialJoinStyle() { return MiterJoin; }
     static EShapeRendering initialShapeRendering() { return SR_AUTO; }
     static ETextAnchor initialTextAnchor() { return TA_START; }
@@ -140,7 +139,6 @@ public:
     void setColorInterpolationFilters(EColorInterpolation val) { svg_inherited_flags._colorInterpolationFilters = val; }
     void setColorRendering(EColorRendering val) { svg_inherited_flags._colorRendering = val; }
     void setFillRule(WindRule val) { svg_inherited_flags._fillRule = val; }
-    void setImageRendering(EImageRendering val) { svg_inherited_flags._imageRendering = val; }
     void setJoinStyle(LineJoin val) { svg_inherited_flags._joinStyle = val; }
     void setShapeRendering(EShapeRendering val) { svg_inherited_flags._shapeRendering = val; }
     void setTextAnchor(ETextAnchor val) { svg_inherited_flags._textAnchor = val; }
@@ -297,7 +295,6 @@ public:
     EColorInterpolation colorInterpolationFilters() const { return (EColorInterpolation) svg_inherited_flags._colorInterpolationFilters; }
     EColorRendering colorRendering() const { return (EColorRendering) svg_inherited_flags._colorRendering; }
     WindRule fillRule() const { return (WindRule) svg_inherited_flags._fillRule; }
-    EImageRendering imageRendering() const { return (EImageRendering) svg_inherited_flags._imageRendering; }
     LineJoin joinStyle() const { return (LineJoin) svg_inherited_flags._joinStyle; }
     EShapeRendering shapeRendering() const { return (EShapeRendering) svg_inherited_flags._shapeRendering; }
     ETextAnchor textAnchor() const { return (ETextAnchor) svg_inherited_flags._textAnchor; }
@@ -346,7 +343,6 @@ protected:
         bool operator==(const InheritedFlags& other) const
         {
             return (_colorRendering == other._colorRendering)
-                && (_imageRendering == other._imageRendering)
                 && (_shapeRendering == other._shapeRendering)
                 && (_clipRule == other._clipRule)
                 && (_fillRule == other._fillRule)
@@ -366,7 +362,6 @@ protected:
         }
 
         unsigned _colorRendering : 2; // EColorRendering
-        unsigned _imageRendering : 2; // EImageRendering 
         unsigned _shapeRendering : 2; // EShapeRendering 
         unsigned _clipRule : 1; // WindRule
         unsigned _fillRule : 1; // WindRule
@@ -422,7 +417,6 @@ private:
         svg_inherited_flags._clipRule = initialClipRule();
         svg_inherited_flags._colorRendering = initialColorRendering();
         svg_inherited_flags._fillRule = initialFillRule();
-        svg_inherited_flags._imageRendering = initialImageRendering();
         svg_inherited_flags._shapeRendering = initialShapeRendering();
         svg_inherited_flags._textAnchor = initialTextAnchor();
         svg_inherited_flags._capStyle = initialCapStyle();
index 00358a0..2c33c6d 100644 (file)
@@ -54,11 +54,6 @@ namespace WebCore {
     enum EColorRendering {
         CR_AUTO, CR_OPTIMIZESPEED, CR_OPTIMIZEQUALITY
     };
-    
-    enum EImageRendering {
-        IR_AUTO, IR_OPTIMIZESPEED, IR_OPTIMIZEQUALITY
-    };
-
     enum EShapeRendering {
         SR_AUTO, SR_OPTIMIZESPEED, SR_CRISPEDGES, SR_GEOMETRICPRECISION
     };
index c384611..11606b1 100644 (file)
@@ -52,6 +52,7 @@ StyleRareInheritedData::StyleRareInheritedData()
     , textEmphasisMark(TextEmphasisMarkNone)
     , textEmphasisPosition(TextEmphasisPositionOver)
     , m_lineBoxContain(RenderStyle::initialLineBoxContain())
+    , m_imageRendering(RenderStyle::initialImageRendering())
     , hyphenationLimitBefore(-1)
     , hyphenationLimitAfter(-1)
 {
@@ -86,6 +87,7 @@ StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
     , textEmphasisMark(o.textEmphasisMark)
     , textEmphasisPosition(o.textEmphasisPosition)
     , m_lineBoxContain(o.m_lineBoxContain)
+    , m_imageRendering(o.m_imageRendering)
     , hyphenationString(o.hyphenationString)
     , hyphenationLimitBefore(o.hyphenationLimitBefore)
     , hyphenationLimitAfter(o.hyphenationLimitAfter)
@@ -141,7 +143,8 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
         && hyphenationString == o.hyphenationString
         && locale == o.locale
         && textEmphasisCustomMark == o.textEmphasisCustomMark
-        && *quotes == *o.quotes;
+        && *quotes == *o.quotes
+        && m_imageRendering == o.m_imageRendering;
 }
 
 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
index da410f1..b990ef8 100644 (file)
@@ -85,6 +85,9 @@ public:
     unsigned textEmphasisMark : 3; // TextEmphasisMark
     unsigned textEmphasisPosition : 1; // TextEmphasisPosition
     unsigned m_lineBoxContain: 7; // LineBoxContain
+    // CSS Image Values Level 3
+    unsigned m_imageRendering : 2; // EImageRendering
+
 
     AtomicString hyphenationString;
     short hyphenationLimitBefore;
index d9e84e5..76b9c9e 100644 (file)
@@ -287,7 +287,7 @@ static void writeStyle(TextStream& ts, const RenderObject& object)
 
     if (!object.localTransform().isIdentity())
         writeNameValuePair(ts, "transform", object.localTransform());
-    writeIfNotDefault(ts, "image rendering", svgStyle->imageRendering(), SVGRenderStyle::initialImageRendering());
+    writeIfNotDefault(ts, "image rendering", style->imageRendering(), RenderStyle::initialImageRendering());
     writeIfNotDefault(ts, "opacity", style->opacity(), RenderStyle::initialOpacity());
     if (object.isSVGPath()) {
         const RenderSVGPath& path = static_cast<const RenderSVGPath&>(object);