Changeset 120641 in webkit


Ignore:
Timestamp:
Jun 18, 2012 4:30:29 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Add from-image to css3-images image-resolution
https://bugs.webkit.org/show_bug.cgi?id=85451

Patch by David Barr <davidbarr@chromium.org> on 2012-06-18
Reviewed by Tony Chang.

Source/WebCore:

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.

LayoutTests:

  • fast/css/image-resolution/image-resolution-expected.txt:
  • fast/css/image-resolution/image-resolution.html:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120639 r120641  
     12012-06-18  David Barr  <davidbarr@chromium.org>
     2
     3        Add from-image to css3-images image-resolution
     4        https://bugs.webkit.org/show_bug.cgi?id=85451
     5
     6        Reviewed by Tony Chang.
     7
     8        * fast/css/image-resolution/image-resolution-expected.txt:
     9        * fast/css/image-resolution/image-resolution.html:
     10
    1112012-06-18  Igor Oliveira  <igor.o@sisa.samsung.com>
    212
  • trunk/LayoutTests/fast/css/image-resolution/image-resolution-expected.txt

    r120308 r120641  
    1 Apply image-resolution property to a fixed image (16x16@0.75dppx).
     1Apply image-resolution property to a fixed image (16x16).
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     
    7676TEST ""
    7777PASS img.style.cssText is ""
     78TEST "0dppx from-image"
     79PASS img.style.cssText is ""
     80TEST "from-image 0dppx"
     81PASS img.style.cssText is ""
     82TEST "1dppx from-image"
     83PASS img.style.cssText is "image-resolution: 1dppx from-image; "
     84PASS img.offsetWidth is 16
     85PASS img.offsetHeight is 16
     86TEST "from-image 1dppx"
     87PASS img.style.cssText is "image-resolution: from-image 1dppx; "
     88PASS img.offsetWidth is 16
     89PASS img.offsetHeight is 16
     90TEST "2dppx from-image"
     91PASS img.style.cssText is "image-resolution: 2dppx from-image; "
     92PASS img.offsetWidth is 8
     93PASS img.offsetHeight is 8
     94TEST "from-image 2dppx"
     95PASS img.style.cssText is "image-resolution: from-image 2dppx; "
     96PASS img.offsetWidth is 8
     97PASS img.offsetHeight is 8
     98TEST "3dppx from-image"
     99PASS img.style.cssText is "image-resolution: 3dppx from-image; "
     100PASS img.offsetWidth is 5
     101PASS img.offsetHeight is 5
     102TEST "from-image 3dppx"
     103PASS img.style.cssText is "image-resolution: from-image 3dppx; "
     104PASS img.offsetWidth is 5
     105PASS img.offsetHeight is 5
     106TEST "4dppx from-image"
     107PASS img.style.cssText is "image-resolution: 4dppx from-image; "
     108PASS img.offsetWidth is 4
     109PASS img.offsetHeight is 4
     110TEST "from-image 4dppx"
     111PASS img.style.cssText is "image-resolution: from-image 4dppx; "
     112PASS img.offsetWidth is 4
     113PASS img.offsetHeight is 4
     114TEST "0dpi from-image"
     115PASS img.style.cssText is ""
     116TEST "from-image 0dpi"
     117PASS img.style.cssText is ""
     118TEST "96dpi from-image"
     119PASS img.style.cssText is "image-resolution: 96dpi from-image; "
     120PASS img.offsetWidth is 16
     121PASS img.offsetHeight is 16
     122TEST "from-image 96dpi"
     123PASS img.style.cssText is "image-resolution: from-image 96dpi; "
     124PASS img.offsetWidth is 16
     125PASS img.offsetHeight is 16
     126TEST "192dpi from-image"
     127PASS img.style.cssText is "image-resolution: 192dpi from-image; "
     128PASS img.offsetWidth is 8
     129PASS img.offsetHeight is 8
     130TEST "from-image 192dpi"
     131PASS img.style.cssText is "image-resolution: from-image 192dpi; "
     132PASS img.offsetWidth is 8
     133PASS img.offsetHeight is 8
     134TEST "288dpi from-image"
     135PASS img.style.cssText is "image-resolution: 288dpi from-image; "
     136PASS img.offsetWidth is 5
     137PASS img.offsetHeight is 5
     138TEST "from-image 288dpi"
     139PASS img.style.cssText is "image-resolution: from-image 288dpi; "
     140PASS img.offsetWidth is 5
     141PASS img.offsetHeight is 5
     142TEST "384dpi from-image"
     143PASS img.style.cssText is "image-resolution: 384dpi from-image; "
     144PASS img.offsetWidth is 4
     145PASS img.offsetHeight is 4
     146TEST "from-image 384dpi"
     147PASS img.style.cssText is "image-resolution: from-image 384dpi; "
     148PASS img.offsetWidth is 4
     149PASS img.offsetHeight is 4
     150TEST "150dpi from-image"
     151PASS img.style.cssText is "image-resolution: 150dpi from-image; "
     152PASS img.offsetWidth is 10
     153PASS img.offsetHeight is 10
     154TEST "from-image 150dpi"
     155PASS img.style.cssText is "image-resolution: from-image 150dpi; "
     156PASS img.offsetWidth is 10
     157PASS img.offsetHeight is 10
     158TEST "300dpi from-image"
     159PASS img.style.cssText is "image-resolution: 300dpi from-image; "
     160PASS img.offsetWidth is 5
     161PASS img.offsetHeight is 5
     162TEST "from-image 300dpi"
     163PASS img.style.cssText is "image-resolution: from-image 300dpi; "
     164PASS img.offsetWidth is 5
     165PASS img.offsetHeight is 5
     166TEST "450dpi from-image"
     167PASS img.style.cssText is "image-resolution: 450dpi from-image; "
     168PASS img.offsetWidth is 3
     169PASS img.offsetHeight is 3
     170TEST "from-image 450dpi"
     171PASS img.style.cssText is "image-resolution: from-image 450dpi; "
     172PASS img.offsetWidth is 3
     173PASS img.offsetHeight is 3
     174TEST "600dpi from-image"
     175PASS img.style.cssText is "image-resolution: 600dpi from-image; "
     176PASS img.offsetWidth is 2
     177PASS img.offsetHeight is 2
     178TEST "from-image 600dpi"
     179PASS img.style.cssText is "image-resolution: from-image 600dpi; "
     180PASS img.offsetWidth is 2
     181PASS img.offsetHeight is 2
     182TEST "0dpcm from-image"
     183PASS img.style.cssText is ""
     184TEST "from-image 0dpcm"
     185PASS img.style.cssText is ""
     186TEST "37.7dpcm from-image"
     187PASS img.style.cssText is "image-resolution: 37.7dpcm from-image; "
     188PASS img.offsetWidth is 16
     189PASS img.offsetHeight is 16
     190TEST "from-image 37.7dpcm"
     191PASS img.style.cssText is "image-resolution: from-image 37.7dpcm; "
     192PASS img.offsetWidth is 16
     193PASS img.offsetHeight is 16
     194TEST "75.5dpcm from-image"
     195PASS img.style.cssText is "image-resolution: 75.5dpcm from-image; "
     196PASS img.offsetWidth is 8
     197PASS img.offsetHeight is 8
     198TEST "from-image 75.5dpcm"
     199PASS img.style.cssText is "image-resolution: from-image 75.5dpcm; "
     200PASS img.offsetWidth is 8
     201PASS img.offsetHeight is 8
     202TEST "113.3dpcm from-image"
     203PASS img.style.cssText is "image-resolution: 113.3dpcm from-image; "
     204PASS img.offsetWidth is 5
     205PASS img.offsetHeight is 5
     206TEST "from-image 113.3dpcm"
     207PASS img.style.cssText is "image-resolution: from-image 113.3dpcm; "
     208PASS img.offsetWidth is 5
     209PASS img.offsetHeight is 5
     210TEST "151.1dpcm from-image"
     211PASS img.style.cssText is "image-resolution: 151.1dpcm from-image; "
     212PASS img.offsetWidth is 4
     213PASS img.offsetHeight is 4
     214TEST "from-image 151.1dpcm"
     215PASS img.style.cssText is "image-resolution: from-image 151.1dpcm; "
     216PASS img.offsetWidth is 4
     217PASS img.offsetHeight is 4
     218TEST "from-image"
     219PASS img.style.cssText is "image-resolution: from-image; "
     220PASS img.offsetWidth is 16
     221PASS img.offsetHeight is 16
    78222PASS successfullyParsed is true
    79223
  • trunk/LayoutTests/fast/css/image-resolution/image-resolution.html

    r120308 r120641  
    4040            dppx = value / (cssPxPerIn / cmPerIn);
    4141    }
    42     if (fromImage)
     42    if (fromImage && imgResolutionDppx)
    4343        dppx = imgResolutionDppx;
    4444    if (snap)
     
    4949}
    5050
     51function permute2(rule) {
     52    var s = rule.trim().split(' ');
     53    if (s.length == 1)
     54        return s;
     55    return [s.join(' '), [s[1], s[0]].join(' ')];
     56}
     57
     58function generateTests(resolutions) {
     59    var tests = resolutions.slice();
     60    resolutions.forEach(function(resolution) {
     61        tests.push.apply(tests, permute2(resolution + ' from-image'));
     62    });
     63    return tests;
     64}
     65
    5166var imgUrl = '../../images/resources/green.jpg';
    5267var imgWidthPx = 16;
    5368var imgHeightPx = 16;
    54 var imgResolutionDppx = 72 / 96;
    55 var dimensions = imgWidthPx + 'x' + imgHeightPx + '@' + imgResolutionDppx + 'dppx';
     69var imgResolutionDppx = 0; /* Embedded image resolution data not plumbed yet. */
     70var dimensions = imgWidthPx + 'x' + imgHeightPx;
    5671
    5772description('Apply image-resolution property to a fixed image (' + dimensions + ').');
     
    6681
    6782img.onload = function() {
    68     resolutions.forEach(function(test) {
     83    generateTests(resolutions).forEach(function(test) {
    6984        var dppx = computeResolution(test, imgResolutionDppx);
    7085        img.style.imageResolution = '';
  • trunk/Source/WebCore/ChangeLog

    r120640 r120641  
     12012-06-18  David Barr  <davidbarr@chromium.org>
     2
     3        Add from-image to css3-images image-resolution
     4        https://bugs.webkit.org/show_bug.cgi?id=85451
     5
     6        Reviewed by Tony Chang.
     7
     8        The css3-images module is at candidate recommendation.
     9        http://www.w3.org/TR/2012/CR-css3-images-20120417/#the-image-resolution
     10
     11        No new tests; extended fast/css/image-resolution/image-resolution.html
     12
     13        * css/CSSParser.cpp: Accept from-image identifier in image-resolution property.
     14        (WebCore::CSSParser::parseImageResolution): Map CSSValueFromImage to identifier value from cssValuePool.
     15        * css/CSSValueKeywords.in: Add from-image.
     16        * css/StyleBuilder.cpp: Extend ApplyPropertyImageResolution to apply RenderStyle::imageResolutionSource.
     17        (WebCore::ApplyPropertyImageResolution::applyInheritValue): Apply RenderStyle::imageResolutionSource.
     18        (WebCore::ApplyPropertyImageResolution::applyInitialValue): Apply RenderStyle::imageResolutionSource.
     19        (WebCore::ApplyPropertyImageResolution::applyValue): Map CSSValueFromImage to ImageResolutionFromImage.
     20        * rendering/RenderImage.cpp: Extend conditions for recalculation of intrinsic size.
     21        (WebCore::RenderImage::styleDidChange): Update intrinsic size if RenderStyle::imageResolutionSource() has changed.
     22        * rendering/style/RenderStyle.cpp: Include StyleRareInheritedData::m_imageResolutionSource in style diff.
     23        (WebCore::RenderStyle::diff): Map change in StyleRareInheritedData::m_imageResolutionSource to StyleDifferenceLayout.
     24        * rendering/style/RenderStyle.h: Add RenderStyle::imageResolutionSource, RenderStyle::setImageResolutionSource, RenderStyle::initialImageResolutionSource.
     25        * rendering/style/RenderStyleConstants.h: Add enum ImageResolutionSource.
     26        * rendering/style/StyleRareInheritedData.cpp: Add StyleRareInheritedData::m_imageResolutionSource.
     27        (WebCore::StyleRareInheritedData::StyleRareInheritedData): Add m_imageResolutionSource to default and copy constructor.
     28        (WebCore::StyleRareInheritedData::operator==): Include m_imageResolutionSource in comparison.
     29        * rendering/style/StyleRareInheritedData.h: Add StyleRareInheritedData::m_imageResolutionSource.
     30        (StyleRareInheritedData): Add 1-bit field StyleRareInheritedData::m_imageResolutionSource.
     31
    1322012-06-18  James Robinson  <jamesr@chromium.org>
    233
  • trunk/Source/WebCore/css/CSSParser.cpp

    r120609 r120641  
    68946894    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    68956895    bool haveResolution = false;
     6896    bool haveFromImage = false;
    68966897
    68976898    CSSParserValue* value = valueList->current();
    68986899    while (value) {
    6899         if (!haveResolution && validUnit(value, FResolution | FNonNeg) && value->fValue > 0) {
     6900        if (!haveFromImage && value->id == CSSValueFromImage) {
     6901            list->append(cssValuePool().createIdentifierValue(value->id));
     6902            haveFromImage = true;
     6903        } else if (!haveResolution && validUnit(value, FResolution | FNonNeg) && value->fValue > 0) {
    69006904            list->append(createPrimitiveNumericValue(value));
    69016905            haveResolution = true;
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r120029 r120641  
    925925#endif // CSS_SHADERS
    926926#endif // CSS_FILTERS
     927
     928#if defined(ENABLE_CSS_IMAGE_RESOLUTION) && ENABLE_CSS_IMAGE_RESOLUTION
     929from-image
     930#endif
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r120609 r120641  
    17731773    static void applyInheritValue(StyleResolver* styleResolver)
    17741774    {
     1775        ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInheritValue(styleResolver);
    17751776        ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInheritValue(styleResolver);
    17761777    }
     
    17781779    static void applyInitialValue(StyleResolver* styleResolver)
    17791780    {
     1781        ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInitialValue(styleResolver);
    17801782        ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInitialValue(styleResolver);
    17811783    }
     
    17861788            return;
    17871789        CSSValueList* valueList = static_cast<CSSValueList*>(value);
     1790        ImageResolutionSource source = RenderStyle::initialImageResolutionSource();
     1791        double resolution = RenderStyle::initialImageResolution();
    17881792        for (size_t i = 0; i < valueList->length(); i++) {
    17891793            CSSValue* item = valueList->itemWithoutBoundsCheck(i);
     
    17911795                continue;
    17921796            CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item);
    1793             styleResolver->style()->setImageResolution(primitiveValue->getDoubleValue(CSSPrimitiveValue::CSS_DPPX));
    1794         }
     1797            if (primitiveValue->getIdent() == CSSValueFromImage)
     1798                source = ImageResolutionFromImage;
     1799            else
     1800                resolution = primitiveValue->getDoubleValue(CSSPrimitiveValue::CSS_DPPX);
     1801        }
     1802        styleResolver->style()->setImageResolutionSource(source);
     1803        styleResolver->style()->setImageResolution(resolution);
    17951804    }
    17961805
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r119984 r120641  
    139139    }
    140140#if ENABLE(CSS_IMAGE_RESOLUTION)
    141     if (diff == StyleDifferenceLayout && oldStyle->imageResolution() != style()->imageResolution())
     141    if (diff == StyleDifferenceLayout
     142        && (oldStyle->imageResolution() != style()->imageResolution()
     143            || oldStyle->imageResolutionSource() != style()->imageResolutionSource()))
    142144        imageDimensionsChanged(true /* imageSizeChanged */);
    143145#endif
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r120154 r120641  
    474474            || rareInheritedData->m_lineGrid != other->rareInheritedData->m_lineGrid
    475475#if ENABLE(CSS_IMAGE_RESOLUTION)
     476            || rareInheritedData->m_imageResolutionSource != other->rareInheritedData->m_imageResolutionSource
    476477            || rareInheritedData->m_imageResolution != other->rareInheritedData->m_imageResolution
    477478#endif
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r120609 r120641  
    984984
    985985#if ENABLE(CSS_IMAGE_RESOLUTION)
     986    ImageResolutionSource imageResolutionSource() const { return static_cast<ImageResolutionSource>(rareInheritedData->m_imageResolutionSource); }
    986987    float imageResolution() const { return rareInheritedData->m_imageResolution; }
    987988#endif
     
    11541155
    11551156#if ENABLE(CSS_IMAGE_RESOLUTION)
     1157    void setImageResolutionSource(ImageResolutionSource v) { SET_VAR(rareInheritedData, m_imageResolutionSource, v) }
    11561158    void setImageResolution(float f) { SET_VAR(rareInheritedData, m_imageResolution, f) }
    11571159#endif
     
    16681670    static LineBoxContain initialLineBoxContain() { return LineBoxContainBlock | LineBoxContainInline | LineBoxContainReplaced; }
    16691671    static EImageRendering initialImageRendering() { return ImageRenderingAuto; }
     1672    static ImageResolutionSource initialImageResolutionSource() { return ImageResolutionSpecified; }
    16701673    static float initialImageResolution() { return 1; }
    16711674    static StyleImage* initialBorderImageSource() { return 0; }
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r120609 r120641  
    455455enum EImageRendering { ImageRenderingAuto, ImageRenderingOptimizeSpeed, ImageRenderingOptimizeQuality, ImageRenderingOptimizeContrast };
    456456
     457enum ImageResolutionSource { ImageResolutionSpecified = 0, ImageResolutionFromImage };
     458
    457459enum Order { LogicalOrder = 0, VisualOrder };
    458460
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r120366 r120641  
    8787#if ENABLE(OVERFLOW_SCROLLING)
    8888    , useTouchOverflowScrolling(RenderStyle::initialUseTouchOverflowScrolling())
     89#endif
     90#if ENABLE(CSS_IMAGE_RESOLUTION)
     91    , m_imageResolutionSource(RenderStyle::initialImageResolutionSource())
    8992#endif
    9093    , hyphenationLimitBefore(-1)
     
    143146    , useTouchOverflowScrolling(o.useTouchOverflowScrolling)
    144147#endif
     148#if ENABLE(CSS_IMAGE_RESOLUTION)
     149    , m_imageResolutionSource(o.m_imageResolutionSource)
     150#endif
    145151    , hyphenationString(o.hyphenationString)
    146152    , hyphenationLimitBefore(o.hyphenationLimitBefore)
     
    225231        && m_imageRendering == o.m_imageRendering
    226232#if ENABLE(CSS_IMAGE_RESOLUTION)
     233        && m_imageResolutionSource == o.m_imageResolutionSource
    227234        && m_imageResolution == o.m_imageResolution
    228235#endif
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r120366 r120641  
    102102    unsigned useTouchOverflowScrolling: 1;
    103103#endif
     104#if ENABLE(CSS_IMAGE_RESOLUTION)
     105    unsigned m_imageResolutionSource : 1; // ImageResolutionSource
     106#endif
    104107
    105108    AtomicString hyphenationString;
Note: See TracChangeset for help on using the changeset viewer.