Diff
Modified: trunk/LayoutTests/ChangeLog (120640 => 120641)
--- trunk/LayoutTests/ChangeLog 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/LayoutTests/ChangeLog 2012-06-18 23:30:29 UTC (rev 120641)
@@ -1,3 +1,13 @@
+2012-06-18 David Barr <[email protected]>
+
+ Add from-image to css3-images image-resolution
+ https://bugs.webkit.org/show_bug.cgi?id=85451
+
+ Reviewed by Tony Chang.
+
+ * fast/css/image-resolution/image-resolution-expected.txt:
+ * fast/css/image-resolution/image-resolution.html:
+
2012-06-18 Igor Oliveira <[email protected]>
Unreviewed, rolling out r120119.
Modified: trunk/LayoutTests/fast/css/image-resolution/image-resolution-expected.txt (120640 => 120641)
--- trunk/LayoutTests/fast/css/image-resolution/image-resolution-expected.txt 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/LayoutTests/fast/css/image-resolution/image-resolution-expected.txt 2012-06-18 23:30:29 UTC (rev 120641)
@@ -1,4 +1,4 @@
-Apply image-resolution property to a fixed image ([email protected]).
+Apply image-resolution property to a fixed image (16x16).
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -75,6 +75,150 @@
PASS img.offsetHeight is 4
TEST ""
PASS img.style.cssText is ""
+TEST "0dppx from-image"
+PASS img.style.cssText is ""
+TEST "from-image 0dppx"
+PASS img.style.cssText is ""
+TEST "1dppx from-image"
+PASS img.style.cssText is "image-resolution: 1dppx from-image; "
+PASS img.offsetWidth is 16
+PASS img.offsetHeight is 16
+TEST "from-image 1dppx"
+PASS img.style.cssText is "image-resolution: from-image 1dppx; "
+PASS img.offsetWidth is 16
+PASS img.offsetHeight is 16
+TEST "2dppx from-image"
+PASS img.style.cssText is "image-resolution: 2dppx from-image; "
+PASS img.offsetWidth is 8
+PASS img.offsetHeight is 8
+TEST "from-image 2dppx"
+PASS img.style.cssText is "image-resolution: from-image 2dppx; "
+PASS img.offsetWidth is 8
+PASS img.offsetHeight is 8
+TEST "3dppx from-image"
+PASS img.style.cssText is "image-resolution: 3dppx from-image; "
+PASS img.offsetWidth is 5
+PASS img.offsetHeight is 5
+TEST "from-image 3dppx"
+PASS img.style.cssText is "image-resolution: from-image 3dppx; "
+PASS img.offsetWidth is 5
+PASS img.offsetHeight is 5
+TEST "4dppx from-image"
+PASS img.style.cssText is "image-resolution: 4dppx from-image; "
+PASS img.offsetWidth is 4
+PASS img.offsetHeight is 4
+TEST "from-image 4dppx"
+PASS img.style.cssText is "image-resolution: from-image 4dppx; "
+PASS img.offsetWidth is 4
+PASS img.offsetHeight is 4
+TEST "0dpi from-image"
+PASS img.style.cssText is ""
+TEST "from-image 0dpi"
+PASS img.style.cssText is ""
+TEST "96dpi from-image"
+PASS img.style.cssText is "image-resolution: 96dpi from-image; "
+PASS img.offsetWidth is 16
+PASS img.offsetHeight is 16
+TEST "from-image 96dpi"
+PASS img.style.cssText is "image-resolution: from-image 96dpi; "
+PASS img.offsetWidth is 16
+PASS img.offsetHeight is 16
+TEST "192dpi from-image"
+PASS img.style.cssText is "image-resolution: 192dpi from-image; "
+PASS img.offsetWidth is 8
+PASS img.offsetHeight is 8
+TEST "from-image 192dpi"
+PASS img.style.cssText is "image-resolution: from-image 192dpi; "
+PASS img.offsetWidth is 8
+PASS img.offsetHeight is 8
+TEST "288dpi from-image"
+PASS img.style.cssText is "image-resolution: 288dpi from-image; "
+PASS img.offsetWidth is 5
+PASS img.offsetHeight is 5
+TEST "from-image 288dpi"
+PASS img.style.cssText is "image-resolution: from-image 288dpi; "
+PASS img.offsetWidth is 5
+PASS img.offsetHeight is 5
+TEST "384dpi from-image"
+PASS img.style.cssText is "image-resolution: 384dpi from-image; "
+PASS img.offsetWidth is 4
+PASS img.offsetHeight is 4
+TEST "from-image 384dpi"
+PASS img.style.cssText is "image-resolution: from-image 384dpi; "
+PASS img.offsetWidth is 4
+PASS img.offsetHeight is 4
+TEST "150dpi from-image"
+PASS img.style.cssText is "image-resolution: 150dpi from-image; "
+PASS img.offsetWidth is 10
+PASS img.offsetHeight is 10
+TEST "from-image 150dpi"
+PASS img.style.cssText is "image-resolution: from-image 150dpi; "
+PASS img.offsetWidth is 10
+PASS img.offsetHeight is 10
+TEST "300dpi from-image"
+PASS img.style.cssText is "image-resolution: 300dpi from-image; "
+PASS img.offsetWidth is 5
+PASS img.offsetHeight is 5
+TEST "from-image 300dpi"
+PASS img.style.cssText is "image-resolution: from-image 300dpi; "
+PASS img.offsetWidth is 5
+PASS img.offsetHeight is 5
+TEST "450dpi from-image"
+PASS img.style.cssText is "image-resolution: 450dpi from-image; "
+PASS img.offsetWidth is 3
+PASS img.offsetHeight is 3
+TEST "from-image 450dpi"
+PASS img.style.cssText is "image-resolution: from-image 450dpi; "
+PASS img.offsetWidth is 3
+PASS img.offsetHeight is 3
+TEST "600dpi from-image"
+PASS img.style.cssText is "image-resolution: 600dpi from-image; "
+PASS img.offsetWidth is 2
+PASS img.offsetHeight is 2
+TEST "from-image 600dpi"
+PASS img.style.cssText is "image-resolution: from-image 600dpi; "
+PASS img.offsetWidth is 2
+PASS img.offsetHeight is 2
+TEST "0dpcm from-image"
+PASS img.style.cssText is ""
+TEST "from-image 0dpcm"
+PASS img.style.cssText is ""
+TEST "37.7dpcm from-image"
+PASS img.style.cssText is "image-resolution: 37.7dpcm from-image; "
+PASS img.offsetWidth is 16
+PASS img.offsetHeight is 16
+TEST "from-image 37.7dpcm"
+PASS img.style.cssText is "image-resolution: from-image 37.7dpcm; "
+PASS img.offsetWidth is 16
+PASS img.offsetHeight is 16
+TEST "75.5dpcm from-image"
+PASS img.style.cssText is "image-resolution: 75.5dpcm from-image; "
+PASS img.offsetWidth is 8
+PASS img.offsetHeight is 8
+TEST "from-image 75.5dpcm"
+PASS img.style.cssText is "image-resolution: from-image 75.5dpcm; "
+PASS img.offsetWidth is 8
+PASS img.offsetHeight is 8
+TEST "113.3dpcm from-image"
+PASS img.style.cssText is "image-resolution: 113.3dpcm from-image; "
+PASS img.offsetWidth is 5
+PASS img.offsetHeight is 5
+TEST "from-image 113.3dpcm"
+PASS img.style.cssText is "image-resolution: from-image 113.3dpcm; "
+PASS img.offsetWidth is 5
+PASS img.offsetHeight is 5
+TEST "151.1dpcm from-image"
+PASS img.style.cssText is "image-resolution: 151.1dpcm from-image; "
+PASS img.offsetWidth is 4
+PASS img.offsetHeight is 4
+TEST "from-image 151.1dpcm"
+PASS img.style.cssText is "image-resolution: from-image 151.1dpcm; "
+PASS img.offsetWidth is 4
+PASS img.offsetHeight is 4
+TEST "from-image"
+PASS img.style.cssText is "image-resolution: from-image; "
+PASS img.offsetWidth is 16
+PASS img.offsetHeight is 16
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/css/image-resolution/image-resolution.html (120640 => 120641)
--- trunk/LayoutTests/fast/css/image-resolution/image-resolution.html 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/LayoutTests/fast/css/image-resolution/image-resolution.html 2012-06-18 23:30:29 UTC (rev 120641)
@@ -39,7 +39,7 @@
else if (unit === 'dpcm')
dppx = value / (cssPxPerIn / cmPerIn);
}
- if (fromImage)
+ if (fromImage && imgResolutionDppx)
dppx = imgResolutionDppx;
if (snap)
dppx = Math.floor(dppx);
@@ -48,11 +48,26 @@
return dppx;
}
+function permute2(rule) {
+ var s = rule.trim().split(' ');
+ if (s.length == 1)
+ return s;
+ return [s.join(' '), [s[1], s[0]].join(' ')];
+}
+
+function generateTests(resolutions) {
+ var tests = resolutions.slice();
+ resolutions.forEach(function(resolution) {
+ tests.push.apply(tests, permute2(resolution + ' from-image'));
+ });
+ return tests;
+}
+
var imgUrl = '../../images/resources/green.jpg';
var imgWidthPx = 16;
var imgHeightPx = 16;
-var imgResolutionDppx = 72 / 96;
-var dimensions = imgWidthPx + 'x' + imgHeightPx + '@' + imgResolutionDppx + 'dppx';
+var imgResolutionDppx = 0; /* Embedded image resolution data not plumbed yet. */
+var dimensions = imgWidthPx + 'x' + imgHeightPx;
description('Apply image-resolution property to a fixed image (' + dimensions + ').');
@@ -65,7 +80,7 @@
'0dpcm', '37.7dpcm', '75.5dpcm', '113.3dpcm', '151.1dpcm', ''];
img._onload_ = function() {
- resolutions.forEach(function(test) {
+ generateTests(resolutions).forEach(function(test) {
var dppx = computeResolution(test, imgResolutionDppx);
img.style.imageResolution = '';
img.style.imageResolution = test;
Modified: trunk/Source/WebCore/ChangeLog (120640 => 120641)
--- trunk/Source/WebCore/ChangeLog 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/ChangeLog 2012-06-18 23:30:29 UTC (rev 120641)
@@ -1,3 +1,34 @@
+2012-06-18 David Barr <[email protected]>
+
+ Add from-image to css3-images image-resolution
+ https://bugs.webkit.org/show_bug.cgi?id=85451
+
+ Reviewed by Tony Chang.
+
+ The css3-images module is at candidate recommendation.
+ http://www.w3.org/TR/2012/CR-css3-images-20120417/#the-image-resolution
+
+ No new tests; extended fast/css/image-resolution/image-resolution.html
+
+ * css/CSSParser.cpp: Accept from-image identifier in image-resolution property.
+ (WebCore::CSSParser::parseImageResolution): Map CSSValueFromImage to identifier value from cssValuePool.
+ * css/CSSValueKeywords.in: Add from-image.
+ * css/StyleBuilder.cpp: Extend ApplyPropertyImageResolution to apply RenderStyle::imageResolutionSource.
+ (WebCore::ApplyPropertyImageResolution::applyInheritValue): Apply RenderStyle::imageResolutionSource.
+ (WebCore::ApplyPropertyImageResolution::applyInitialValue): Apply RenderStyle::imageResolutionSource.
+ (WebCore::ApplyPropertyImageResolution::applyValue): Map CSSValueFromImage to ImageResolutionFromImage.
+ * rendering/RenderImage.cpp: Extend conditions for recalculation of intrinsic size.
+ (WebCore::RenderImage::styleDidChange): Update intrinsic size if RenderStyle::imageResolutionSource() has changed.
+ * rendering/style/RenderStyle.cpp: Include StyleRareInheritedData::m_imageResolutionSource in style diff.
+ (WebCore::RenderStyle::diff): Map change in StyleRareInheritedData::m_imageResolutionSource to StyleDifferenceLayout.
+ * rendering/style/RenderStyle.h: Add RenderStyle::imageResolutionSource, RenderStyle::setImageResolutionSource, RenderStyle::initialImageResolutionSource.
+ * rendering/style/RenderStyleConstants.h: Add enum ImageResolutionSource.
+ * rendering/style/StyleRareInheritedData.cpp: Add StyleRareInheritedData::m_imageResolutionSource.
+ (WebCore::StyleRareInheritedData::StyleRareInheritedData): Add m_imageResolutionSource to default and copy constructor.
+ (WebCore::StyleRareInheritedData::operator==): Include m_imageResolutionSource in comparison.
+ * rendering/style/StyleRareInheritedData.h: Add StyleRareInheritedData::m_imageResolutionSource.
+ (StyleRareInheritedData): Add 1-bit field StyleRareInheritedData::m_imageResolutionSource.
+
2012-06-18 James Robinson <[email protected]>
[chromium] REGRESSION(r120346) ContentLayerPainter should clear rect to be painted
Modified: trunk/Source/WebCore/css/CSSParser.cpp (120640 => 120641)
--- trunk/Source/WebCore/css/CSSParser.cpp 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2012-06-18 23:30:29 UTC (rev 120641)
@@ -6893,10 +6893,14 @@
{
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
bool haveResolution = false;
+ bool haveFromImage = false;
CSSParserValue* value = valueList->current();
while (value) {
- if (!haveResolution && validUnit(value, FResolution | FNonNeg) && value->fValue > 0) {
+ if (!haveFromImage && value->id == CSSValueFromImage) {
+ list->append(cssValuePool().createIdentifierValue(value->id));
+ haveFromImage = true;
+ } else if (!haveResolution && validUnit(value, FResolution | FNonNeg) && value->fValue > 0) {
list->append(createPrimitiveNumericValue(value));
haveResolution = true;
} else
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (120640 => 120641)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2012-06-18 23:30:29 UTC (rev 120641)
@@ -924,3 +924,7 @@
detached
#endif // CSS_SHADERS
#endif // CSS_FILTERS
+
+#if defined(ENABLE_CSS_IMAGE_RESOLUTION) && ENABLE_CSS_IMAGE_RESOLUTION
+from-image
+#endif
Modified: trunk/Source/WebCore/css/StyleBuilder.cpp (120640 => 120641)
--- trunk/Source/WebCore/css/StyleBuilder.cpp 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/css/StyleBuilder.cpp 2012-06-18 23:30:29 UTC (rev 120641)
@@ -1772,11 +1772,13 @@
public:
static void applyInheritValue(StyleResolver* styleResolver)
{
+ ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInheritValue(styleResolver);
ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInheritValue(styleResolver);
}
static void applyInitialValue(StyleResolver* styleResolver)
{
+ ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInitialValue(styleResolver);
ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInitialValue(styleResolver);
}
@@ -1785,13 +1787,20 @@
if (!value->isValueList())
return;
CSSValueList* valueList = static_cast<CSSValueList*>(value);
+ ImageResolutionSource source = RenderStyle::initialImageResolutionSource();
+ double resolution = RenderStyle::initialImageResolution();
for (size_t i = 0; i < valueList->length(); i++) {
CSSValue* item = valueList->itemWithoutBoundsCheck(i);
if (!item->isPrimitiveValue())
continue;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item);
- styleResolver->style()->setImageResolution(primitiveValue->getDoubleValue(CSSPrimitiveValue::CSS_DPPX));
+ if (primitiveValue->getIdent() == CSSValueFromImage)
+ source = ImageResolutionFromImage;
+ else
+ resolution = primitiveValue->getDoubleValue(CSSPrimitiveValue::CSS_DPPX);
}
+ styleResolver->style()->setImageResolutionSource(source);
+ styleResolver->style()->setImageResolution(resolution);
}
static PropertyHandler createHandler()
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (120640 => 120641)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2012-06-18 23:30:29 UTC (rev 120641)
@@ -138,7 +138,9 @@
m_needsToSetSizeForAltText = false;
}
#if ENABLE(CSS_IMAGE_RESOLUTION)
- if (diff == StyleDifferenceLayout && oldStyle->imageResolution() != style()->imageResolution())
+ if (diff == StyleDifferenceLayout
+ && (oldStyle->imageResolution() != style()->imageResolution()
+ || oldStyle->imageResolutionSource() != style()->imageResolutionSource()))
imageDimensionsChanged(true /* imageSizeChanged */);
#endif
}
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (120640 => 120641)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2012-06-18 23:30:29 UTC (rev 120641)
@@ -473,6 +473,7 @@
|| rareInheritedData->m_lineBoxContain != other->rareInheritedData->m_lineBoxContain
|| rareInheritedData->m_lineGrid != other->rareInheritedData->m_lineGrid
#if ENABLE(CSS_IMAGE_RESOLUTION)
+ || rareInheritedData->m_imageResolutionSource != other->rareInheritedData->m_imageResolutionSource
|| rareInheritedData->m_imageResolution != other->rareInheritedData->m_imageResolution
#endif
|| rareInheritedData->m_lineSnap != other->rareInheritedData->m_lineSnap
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (120640 => 120641)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2012-06-18 23:30:29 UTC (rev 120641)
@@ -983,6 +983,7 @@
EImageRendering imageRendering() const { return static_cast<EImageRendering>(rareInheritedData->m_imageRendering); }
#if ENABLE(CSS_IMAGE_RESOLUTION)
+ ImageResolutionSource imageResolutionSource() const { return static_cast<ImageResolutionSource>(rareInheritedData->m_imageResolutionSource); }
float imageResolution() const { return rareInheritedData->m_imageResolution; }
#endif
@@ -1153,6 +1154,7 @@
void setImageRendering(EImageRendering v) { SET_VAR(rareInheritedData, m_imageRendering, v) }
#if ENABLE(CSS_IMAGE_RESOLUTION)
+ void setImageResolutionSource(ImageResolutionSource v) { SET_VAR(rareInheritedData, m_imageResolutionSource, v) }
void setImageResolution(float f) { SET_VAR(rareInheritedData, m_imageResolution, f) }
#endif
@@ -1667,6 +1669,7 @@
static TextEmphasisPosition initialTextEmphasisPosition() { return TextEmphasisPositionOver; }
static LineBoxContain initialLineBoxContain() { return LineBoxContainBlock | LineBoxContainInline | LineBoxContainReplaced; }
static EImageRendering initialImageRendering() { return ImageRenderingAuto; }
+ static ImageResolutionSource initialImageResolutionSource() { return ImageResolutionSpecified; }
static float initialImageResolution() { return 1; }
static StyleImage* initialBorderImageSource() { return 0; }
static StyleImage* initialMaskBoxImageSource() { return 0; }
Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (120640 => 120641)
--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2012-06-18 23:30:29 UTC (rev 120641)
@@ -454,6 +454,8 @@
enum EImageRendering { ImageRenderingAuto, ImageRenderingOptimizeSpeed, ImageRenderingOptimizeQuality, ImageRenderingOptimizeContrast };
+enum ImageResolutionSource { ImageResolutionSpecified = 0, ImageResolutionFromImage };
+
enum Order { LogicalOrder = 0, VisualOrder };
enum RegionOverflow { AutoRegionOverflow, BreakRegionOverflow };
Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp (120640 => 120641)
--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp 2012-06-18 23:30:29 UTC (rev 120641)
@@ -87,6 +87,9 @@
#if ENABLE(OVERFLOW_SCROLLING)
, useTouchOverflowScrolling(RenderStyle::initialUseTouchOverflowScrolling())
#endif
+#if ENABLE(CSS_IMAGE_RESOLUTION)
+ , m_imageResolutionSource(RenderStyle::initialImageResolutionSource())
+#endif
, hyphenationLimitBefore(-1)
, hyphenationLimitAfter(-1)
, hyphenationLimitLines(-1)
@@ -142,6 +145,9 @@
#if ENABLE(OVERFLOW_SCROLLING)
, useTouchOverflowScrolling(o.useTouchOverflowScrolling)
#endif
+#if ENABLE(CSS_IMAGE_RESOLUTION)
+ , m_imageResolutionSource(o.m_imageResolutionSource)
+#endif
, hyphenationString(o.hyphenationString)
, hyphenationLimitBefore(o.hyphenationLimitBefore)
, hyphenationLimitAfter(o.hyphenationLimitAfter)
@@ -224,6 +230,7 @@
&& m_lineGrid == o.m_lineGrid
&& m_imageRendering == o.m_imageRendering
#if ENABLE(CSS_IMAGE_RESOLUTION)
+ && m_imageResolutionSource == o.m_imageResolutionSource
&& m_imageResolution == o.m_imageResolution
#endif
&& m_lineSnap == o.m_lineSnap
Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (120640 => 120641)
--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h 2012-06-18 23:16:08 UTC (rev 120640)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h 2012-06-18 23:30:29 UTC (rev 120641)
@@ -101,6 +101,9 @@
#if ENABLE(OVERFLOW_SCROLLING)
unsigned useTouchOverflowScrolling: 1;
#endif
+#if ENABLE(CSS_IMAGE_RESOLUTION)
+ unsigned m_imageResolutionSource : 1; // ImageResolutionSource
+#endif
AtomicString hyphenationString;
short hyphenationLimitBefore;