Title: [195699] trunk
Revision
195699
Author
[email protected]
Date
2016-01-27 15:31:38 -0800 (Wed, 27 Jan 2016)

Log Message

Support CSS3 Images values for the image-rendering property
https://bugs.webkit.org/show_bug.cgi?id=153556

Reviewed by Dean Jackson.

Source/WebCore:

CSS3 Images has the following values for image-rendering:
    auto, crisp-edges, pixelated

The old code supported:
    optimizeSpeed, optimizeQuality, -webkit-crisp-edges, -webkit-optimize-contrast

Add support for the new values without prefixes. Map -webkit-crisp-edges to crisp-edges,
and -webkit-optimize-contrast to crisp-edges. Support pixelated which behaves like
crisp-edges (a low quality scale).

The spec says that optimizeQuality should behave like 'auto', but that would be
a behavior change since ImageQualityController::shouldPaintAtLowQuality() currently
uses it as a trigger to avoid low quality scaling, so don't change that for now.

No new tests, covered by fast/css/script-tests/image-rendering-parsing.js

* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator EImageRendering):
* css/CSSValueKeywords.in:
* rendering/ImageQualityController.cpp:
(WebCore::ImageQualityController::shouldPaintAtLowQuality):
* rendering/RenderHTMLCanvas.cpp:
(WebCore::RenderHTMLCanvas::paintReplaced):
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleRareInheritedData.h: Need another bit.

Source/WebInspectorUI:

Add "crisp-edges", "pixelated" to the suggestions for image-rendering.

* UserInterface/Models/CSSKeywordCompletions.js:

LayoutTests:

Update for new values. Add a new SVG shape-rendering test which would have
detected a bug I caused with an earlier patch.

* fast/css/image-rendering-parsing-expected.txt:
* fast/css/script-tests/image-rendering-parsing.js:
* svg/css/script-tests/shape-rendering-parsing.js: Added.
* svg/css/shape-rendering-parsing.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195698 => 195699)


--- trunk/LayoutTests/ChangeLog	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/LayoutTests/ChangeLog	2016-01-27 23:31:38 UTC (rev 195699)
@@ -1,3 +1,18 @@
+2016-01-27  Simon Fraser  <[email protected]>
+
+        Support CSS3 Images values for the image-rendering property
+        https://bugs.webkit.org/show_bug.cgi?id=153556
+
+        Reviewed by Dean Jackson.
+
+        Update for new values. Add a new SVG shape-rendering test which would have
+        detected a bug I caused with an earlier patch.
+
+        * fast/css/image-rendering-parsing-expected.txt:
+        * fast/css/script-tests/image-rendering-parsing.js:
+        * svg/css/script-tests/shape-rendering-parsing.js: Added.
+        * svg/css/shape-rendering-parsing.html: Added.
+
 2016-01-27  Brady Eidson  <[email protected]>
 
         Modern IDB: Fix many Index tests.

Modified: trunk/LayoutTests/fast/css/image-rendering-parsing-expected.txt (195698 => 195699)


--- trunk/LayoutTests/fast/css/image-rendering-parsing-expected.txt	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/LayoutTests/fast/css/image-rendering-parsing-expected.txt	2016-01-27 23:31:38 UTC (rev 195699)
@@ -7,11 +7,17 @@
 PASS div.style.getPropertyValue('image-rendering') is "auto"
 PASS getComputedStyle(div).getPropertyValue('image-rendering') is "auto"
 PASS div.style.getPropertyCSSValue('image-rendering').cssValueType is CSSValue.CSS_PRIMITIVE_VALUE
+PASS div.style.getPropertyValue('image-rendering') is "crisp-edges"
+PASS getComputedStyle(div).getPropertyValue('image-rendering') is "crisp-edges"
+PASS div.style.getPropertyCSSValue('image-rendering').cssValueType is CSSValue.CSS_PRIMITIVE_VALUE
+PASS div.style.getPropertyValue('image-rendering') is "pixelated"
+PASS getComputedStyle(div).getPropertyValue('image-rendering') is "pixelated"
+PASS div.style.getPropertyCSSValue('image-rendering').cssValueType is CSSValue.CSS_PRIMITIVE_VALUE
 PASS div.style.getPropertyValue('image-rendering') is "-webkit-crisp-edges"
-PASS getComputedStyle(div).getPropertyValue('image-rendering') is "-webkit-crisp-edges"
+PASS getComputedStyle(div).getPropertyValue('image-rendering') is "crisp-edges"
 PASS div.style.getPropertyCSSValue('image-rendering').cssValueType is CSSValue.CSS_PRIMITIVE_VALUE
 PASS div.style.getPropertyValue('image-rendering') is "-webkit-optimize-contrast"
-PASS getComputedStyle(div).getPropertyValue('image-rendering') is "-webkit-crisp-edges"
+PASS getComputedStyle(div).getPropertyValue('image-rendering') is "crisp-edges"
 PASS div.style.getPropertyCSSValue('image-rendering').cssValueType is CSSValue.CSS_PRIMITIVE_VALUE
 PASS div.style.getPropertyValue('image-rendering') is "optimizespeed"
 PASS getComputedStyle(div).getPropertyValue('image-rendering') is "optimizespeed"

Modified: trunk/LayoutTests/fast/css/script-tests/image-rendering-parsing.js (195698 => 195699)


--- trunk/LayoutTests/fast/css/script-tests/image-rendering-parsing.js	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/LayoutTests/fast/css/script-tests/image-rendering-parsing.js	2016-01-27 23:31:38 UTC (rev 195699)
@@ -14,8 +14,10 @@
 }
 
 testImageRendering('auto', 'auto');
-testImageRendering('-webkit-crisp-edges', '-webkit-crisp-edges');
-testImageRendering('-webkit-optimize-contrast', '-webkit-crisp-edges');
+testImageRendering('crisp-edges', 'crisp-edges');
+testImageRendering('pixelated', 'pixelated');
+testImageRendering('-webkit-crisp-edges', 'crisp-edges');
+testImageRendering('-webkit-optimize-contrast', 'crisp-edges');
 testImageRendering('optimizespeed', 'optimizespeed');
 testImageRendering('optimizequality', 'optimizequality');
 

Added: trunk/LayoutTests/svg/css/script-tests/shape-rendering-parsing.js (0 => 195699)


--- trunk/LayoutTests/svg/css/script-tests/shape-rendering-parsing.js	                        (rev 0)
+++ trunk/LayoutTests/svg/css/script-tests/shape-rendering-parsing.js	2016-01-27 23:31:38 UTC (rev 195699)
@@ -0,0 +1,24 @@
+description("Tests the parsing of shape-rendering property values")
+createSVGTestCase();
+
+var group = createSVGElement("g");
+rootSVGElement.appendChild(group);
+
+// Test initial value of font-length.
+shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "auto");
+
+group.setAttribute("shape-rendering", "crispEdges");
+shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "crispedges");
+
+group.setAttribute("shape-rendering", "crispedges");
+shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "crispedges");
+
+group.setAttribute("shape-rendering", "optimizeSpeed");
+shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "optimizespeed");
+
+group.setAttribute("shape-rendering", "geometricPrecision");
+shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "geometricprecision");
+
+var successfullyParsed = true;
+
+completeTest();

Added: trunk/LayoutTests/svg/css/shape-rendering-parsing-expected.txt (0 => 195699)


--- trunk/LayoutTests/svg/css/shape-rendering-parsing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/css/shape-rendering-parsing-expected.txt	2016-01-27 23:31:38 UTC (rev 195699)
@@ -0,0 +1,14 @@
+Tests the parsing of shape-rendering property values
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "auto"
+PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "crispedges"
+PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "crispedges"
+PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "optimizespeed"
+PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "geometricprecision"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/css/shape-rendering-parsing.html (0 => 195699)


--- trunk/LayoutTests/svg/css/shape-rendering-parsing.html	                        (rev 0)
+++ trunk/LayoutTests/svg/css/shape-rendering-parsing.html	2016-01-27 23:31:38 UTC (rev 195699)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (195698 => 195699)


--- trunk/Source/WebCore/ChangeLog	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebCore/ChangeLog	2016-01-27 23:31:38 UTC (rev 195699)
@@ -1,3 +1,39 @@
+2016-01-27  Simon Fraser  <[email protected]>
+
+        Support CSS3 Images values for the image-rendering property
+        https://bugs.webkit.org/show_bug.cgi?id=153556
+
+        Reviewed by Dean Jackson.
+
+        CSS3 Images has the following values for image-rendering:
+            auto, crisp-edges, pixelated
+
+        The old code supported:
+            optimizeSpeed, optimizeQuality, -webkit-crisp-edges, -webkit-optimize-contrast
+
+        Add support for the new values without prefixes. Map -webkit-crisp-edges to crisp-edges,
+        and -webkit-optimize-contrast to crisp-edges. Support pixelated which behaves like 
+        crisp-edges (a low quality scale).
+
+        The spec says that optimizeQuality should behave like 'auto', but that would be
+        a behavior change since ImageQualityController::shouldPaintAtLowQuality() currently
+        uses it as a trigger to avoid low quality scaling, so don't change that for now.
+
+        No new tests, covered by fast/css/script-tests/image-rendering-parsing.js
+
+        * css/CSSParser.cpp:
+        (WebCore::isValidKeywordPropertyAndValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EImageRendering):
+        * css/CSSValueKeywords.in:
+        * rendering/ImageQualityController.cpp:
+        (WebCore::ImageQualityController::shouldPaintAtLowQuality):
+        * rendering/RenderHTMLCanvas.cpp:
+        (WebCore::RenderHTMLCanvas::paintReplaced):
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleRareInheritedData.h: Need another bit.
+
 2016-01-27  Anders Carlsson  <[email protected]>
 
         Add WebKitAdditions extension points to WebCore, WebKit and WebKitLegacy

Modified: trunk/Source/WebCore/css/CSSParser.cpp (195698 => 195699)


--- trunk/Source/WebCore/css/CSSParser.cpp	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2016-01-27 23:31:38 UTC (rev 195699)
@@ -706,9 +706,10 @@
         if (valueID == CSSValueNormal || valueID == CSSValueItalic || valueID == CSSValueOblique)
             return true;
         break;
-    case CSSPropertyImageRendering: // auto | optimizeSpeed | optimizeQuality | -webkit-crisp-edges | -webkit-optimize-contrast
+    case CSSPropertyImageRendering: // auto | optimizeSpeed | optimizeQuality | -webkit-crisp-edges | -webkit-optimize-contrast | crisp-edges | pixelated
+        // optimizeSpeed and optimizeQuality are deprecated; a user agent must accept them as valid values but must treat them as having the same behavior as pixelated and auto respectively.
         if (valueID == CSSValueAuto || valueID == CSSValueOptimizespeed || valueID == CSSValueOptimizequality
-            || valueID == CSSValueWebkitCrispEdges || valueID == CSSValueWebkitOptimizeContrast)
+            || valueID == CSSValueWebkitCrispEdges || valueID == CSSValueWebkitOptimizeContrast || valueID == CSSValueCrispEdges || valueID == CSSValuePixelated)
             return true;
         break;
     case CSSPropertyListStylePosition: // inside | outside | inherit

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (195698 => 195699)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2016-01-27 23:31:38 UTC (rev 195699)
@@ -4321,17 +4321,20 @@
     return BorderFitLines;
 }
 
-template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering e)
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EImageRendering imageRendering)
     : CSSValue(PrimitiveClass)
 {
     m_primitiveUnitType = CSS_VALUE_ID;
-    switch (e) {
+    switch (imageRendering) {
     case ImageRenderingAuto:
         m_value.valueID = CSSValueAuto;
         break;
     case ImageRenderingCrispEdges:
-        m_value.valueID = CSSValueWebkitCrispEdges;
+        m_value.valueID = CSSValueCrispEdges;
         break;
+    case ImageRenderingPixelated:
+        m_value.valueID = CSSValuePixelated;
+        break;
     case ImageRenderingOptimizeSpeed:
         m_value.valueID = CSSValueOptimizespeed;
         break;
@@ -4349,8 +4352,11 @@
     case CSSValueAuto:
         return ImageRenderingAuto;
     case CSSValueWebkitOptimizeContrast:
+    case CSSValueCrispEdges:
     case CSSValueWebkitCrispEdges:
         return ImageRenderingCrispEdges;
+    case CSSValuePixelated:
+        return ImageRenderingPixelated;
     case CSSValueOptimizespeed:
         return ImageRenderingOptimizeSpeed;
     case CSSValueOptimizequality:

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (195698 => 195699)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2016-01-27 23:31:38 UTC (rev 195699)
@@ -1050,8 +1050,10 @@
 
 // image-rendering
 // auto
-// optimizeSpeed
-optimizeQuality
+// optimizeSpeed (deprecated)
+optimizeQuality // ( deprecated)
+crisp-edges
+pixelated
 -webkit-crisp-edges
 -webkit-optimize-contrast
 

Modified: trunk/Source/WebCore/rendering/ImageQualityController.cpp (195698 => 195699)


--- trunk/Source/WebCore/rendering/ImageQualityController.cpp	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebCore/rendering/ImageQualityController.cpp	2016-01-27 23:31:38 UTC (rev 195699)
@@ -109,9 +109,10 @@
     switch (object->style().imageRendering()) {
     case ImageRenderingOptimizeSpeed:
     case ImageRenderingCrispEdges:
+    case ImageRenderingPixelated:
         return true;
     case ImageRenderingOptimizeQuality:
-        return false;
+        return false; // FIXME: CSS 3 Images says that optimizeQuality should behave like 'auto', but that prevents authors from overriding this low quality rendering behavior.
     case ImageRenderingAuto:
         break;
     }

Modified: trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp (195698 => 195699)


--- trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp	2016-01-27 23:31:38 UTC (rev 195699)
@@ -84,7 +84,7 @@
             page->addRelevantRepaintedObject(this, intersection(replacedContentRect, contentBoxRect));
     }
 
-    bool useLowQualityScale = style().imageRendering() == ImageRenderingCrispEdges || style().imageRendering() == ImageRenderingOptimizeSpeed;
+    bool useLowQualityScale = style().imageRendering() == ImageRenderingCrispEdges || style().imageRendering() == ImageRenderingPixelated || style().imageRendering() == ImageRenderingOptimizeSpeed;
     canvasElement().paint(context, replacedContentRect, useLowQualityScale);
 }
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (195698 => 195699)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2016-01-27 23:31:38 UTC (rev 195699)
@@ -593,7 +593,13 @@
 
 enum TextOverflow { TextOverflowClip = 0, TextOverflowEllipsis };
 
-enum EImageRendering { ImageRenderingAuto = 0, ImageRenderingOptimizeSpeed, ImageRenderingOptimizeQuality, ImageRenderingCrispEdges };
+enum EImageRendering {
+    ImageRenderingAuto = 0,
+    ImageRenderingOptimizeSpeed,
+    ImageRenderingOptimizeQuality,
+    ImageRenderingCrispEdges,
+    ImageRenderingPixelated
+};
 
 enum ImageResolutionSource { ImageResolutionSpecified = 0, ImageResolutionFromImage };
 

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (195698 => 195699)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2016-01-27 23:31:38 UTC (rev 195699)
@@ -110,7 +110,7 @@
 #if ENABLE(CSS_IMAGE_ORIENTATION)
     unsigned m_imageOrientation : 4; // ImageOrientationEnum
 #endif
-    unsigned m_imageRendering : 2; // EImageRendering
+    unsigned m_imageRendering : 3; // EImageRendering
     unsigned m_lineSnap : 2; // LineSnap
     unsigned m_lineAlign : 1; // LineAlign
 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)

Modified: trunk/Source/WebInspectorUI/ChangeLog (195698 => 195699)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-01-27 23:31:38 UTC (rev 195699)
@@ -1,3 +1,14 @@
+2016-01-27  Simon Fraser  <[email protected]>
+
+        Support CSS3 Images values for the image-rendering property
+        https://bugs.webkit.org/show_bug.cgi?id=153556
+
+        Reviewed by Dean Jackson.
+
+        Add "crisp-edges", "pixelated" to the suggestions for image-rendering.
+
+        * UserInterface/Models/CSSKeywordCompletions.js:
+
 2016-01-26  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Remove unused FramesLarge.png variants, only the smaller Frames icon is used for the Rendering Frames timeline

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js (195698 => 195699)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2016-01-27 23:12:31 UTC (rev 195698)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2016-01-27 23:31:38 UTC (rev 195699)
@@ -392,7 +392,7 @@
         "flex", "inline-flex", "-webkit-grid", "-webkit-inline-grid"
     ],
     "image-rendering": [
-        "auto", "optimizeSpeed", "optimizeQuality", "-webkit-crisp-edges", "-webkit-optimize-contrast"
+        "auto", "optimizeSpeed", "optimizeQuality", "-webkit-crisp-edges", "-webkit-optimize-contrast", "crisp-edges", "pixelated"
     ],
     "alignment-baseline": [
         "baseline", "middle", "auto", "before-edge", "after-edge", "central", "text-before-edge", "text-after-edge",
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to