LayoutTests/ChangeLog

 12011-11-14 Tim Horton <timothy_horton@apple.com>
 2
 3 Implement CSS3 Images cross-fade() image function
 4 https://bugs.webkit.org/show_bug.cgi?id=52162
 5 <rdar://problem/10209254>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Add tests of -webkit-cross-fade, ensuring that simple cross-fades between
 10 two images work correctly.
 11
 12 * css3/images/cross-fade-invalidation.html: Added.
 13 * css3/images/cross-fade-simple.html: Added.
 14 * css3/images/cross-fade-sizing.html: Added.
 15 * css3/images/cross-fade-tiled.html: Added.
 16 * css3/images/resources/blue-10.png: Added.
 17 * css3/images/resources/blue-100.png: Added.
 18 * css3/images/resources/green-10.png: Added.
 19 * css3/images/resources/green-100.png: Added.
 20 * css3/images/resources/green-circle.svg: Added.
 21 * css3/images/resources/red-10.png: Added.
 22 * css3/images/resources/red-100.png: Added.
 23 * platform/mac/css3/images/cross-fade-invalidation-expected.png: Added.
 24 * platform/mac/css3/images/cross-fade-invalidation-expected.txt: Added.
 25 * platform/mac/css3/images/cross-fade-simple-expected.png: Added.
 26 * platform/mac/css3/images/cross-fade-simple-expected.txt: Added.
 27 * platform/mac/css3/images/cross-fade-sizing-expected.png: Added.
 28 * platform/mac/css3/images/cross-fade-sizing-expected.txt: Added.
 29 * platform/mac/css3/images/cross-fade-tiled-expected.png: Added.
 30 * platform/mac/css3/images/cross-fade-tiled-expected.txt: Added.
 31
1322011-11-14 Michael Nordman <michaeln@google.com>
233
334 Update layout tests for new websql error messages and console logging.

LayoutTests/css3/images/cross-fade-invalidation.html

 1<html>
 2<style>
 3div
 4{
 5 width: 100px;
 6 height: 100px;
 7 margin: 10px;
 8}
 9</style>
 10<script>
 11if(window.layoutTestController)
 12 layoutTestController.waitUntilDone();
 13
 14setTimeout(function() {
 15 if(window.layoutTestController)
 16 layoutTestController.notifyDone();
 17}, 100);
 18</script>
 19<!--The first cross-fade should appear as a light green square with a darker green circle inside it.-->
 20<div style="background-image: -webkit-cross-fade(url(resources/green-circle.svg), url(resources/green-100.png), 50%);"></div>
 21</html>

LayoutTests/css3/images/cross-fade-simple.html

 1<html>
 2<style>
 3div
 4{
 5 width: 100px;
 6 height: 100px;
 7 margin: 10px;
 8}
 9</style>
 10<!--The first cross-fade should appear as a 100% green square, 100x100px.-->
 11<div style="background-image: -webkit-cross-fade(url(resources/red-100.png), url(resources/green-100.png), 100%);"></div>
 12<!--The second cross-fade should appear as a 100% green square, 100x100px.-->
 13<div style="background-image: -webkit-cross-fade(url(resources/green-100.png), url(resources/red-100.png), 0%);"></div>
 14<!--The third cross-fade should appear as a blue-green square, 100x100px.-->
 15<div style="background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 50%);"></div>
 16</html>

LayoutTests/css3/images/cross-fade-sizing.html

 1<html>
 2<style>
 3div
 4{
 5 width: 100px;
 6 height: 100px;
 7 margin: 10px;
 8}
 9</style>
 10<!--The first cross-fade should appear as a 100% green square, 10x10px.-->
 11<div style="background-image: -webkit-cross-fade(url(resources/red-100.png), url(resources/green-10.png), 100%);"></div>
 12<!--The second cross-fade should appear as a 100% green square, 100x100px.-->
 13<div style="background-image: -webkit-cross-fade(url(resources/green-100.png), url(resources/red-10.png), 0%);"></div>
 14<!--The third cross-fade should appear as a blue-green square, 55x55px.-->
 15<div style="background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-10.png), 50%);"></div>
 16</html>

LayoutTests/css3/images/cross-fade-tiled.html

 1<html>
 2<style>
 3div
 4{
 5 width: 100px;
 6 height: 100px;
 7 margin: 10px;
 8
 9 -webkit-transform:translateZ(0);
 10 border: 1px solid black;
 11}
 12</style>
 13<!--The first cross-fade should appear as a 100% green square, 100x100px.-->
 14<div style="background-image: -webkit-cross-fade(url(resources/red-100.png), url(resources/green-100.png), 100%);"></div>
 15<!--The second cross-fade should appear as a 100% green square, 100x100px.-->
 16<div style="background-image: -webkit-cross-fade(url(resources/green-100.png), url(resources/red-100.png), 0%);"></div>
 17<!--The third cross-fade should appear as a blue-green square, 100x100px.-->
 18<div style="background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 50%);"></div>
 19</html>

LayoutTests/css3/images/resources/blue-10.png


Added


LayoutTests/css3/images/resources/blue-100.png


Added


LayoutTests/css3/images/resources/green-10.png


Added


LayoutTests/css3/images/resources/green-100.png


Added


LayoutTests/css3/images/resources/green-circle.svg

 1<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100">
 2 <circle cx="50" cy="50" r="40" stroke="black" stroke-width="2" fill="red">
 3 <animate attributeName="fill" from="red" to="green" begin="0s" dur="0.01s" fill="freeze" />
 4 </circle>
 5</svg>

LayoutTests/css3/images/resources/red-10.png


Added


LayoutTests/css3/images/resources/red-100.png


Added


LayoutTests/platform/mac/css3/images/cross-fade-invalidation-expected.png


Added

f9df8bce5e75b758a0899aa312408f0e

LayoutTests/platform/mac/css3/images/cross-fade-invalidation-expected.txt

 1layer at (0,0) size 800x600
 2 RenderView at (0,0) size 800x600
 3layer at (0,0) size 800x600
 4 RenderBlock {HTML} at (0,0) size 800x600
 5 RenderBody {BODY} at (8,10) size 784x580
 6 RenderBlock {DIV} at (10,0) size 100x100

LayoutTests/platform/mac/css3/images/cross-fade-simple-expected.png


Added

0c891023c5e0bb46f29317ef18eeb1b7

LayoutTests/platform/mac/css3/images/cross-fade-simple-expected.txt

 1layer at (0,0) size 800x600
 2 RenderView at (0,0) size 800x600
 3layer at (0,0) size 800x600
 4 RenderBlock {HTML} at (0,0) size 800x600
 5 RenderBody {BODY} at (8,10) size 784x580
 6 RenderBlock {DIV} at (10,0) size 100x100
 7 RenderBlock {DIV} at (10,110) size 100x100
 8 RenderBlock {DIV} at (10,220) size 100x100

LayoutTests/platform/mac/css3/images/cross-fade-sizing-expected.png


Added

9b844a2b34d8f8aaa99494a41628b747

LayoutTests/platform/mac/css3/images/cross-fade-sizing-expected.txt

 1layer at (0,0) size 800x600
 2 RenderView at (0,0) size 800x600
 3layer at (0,0) size 800x600
 4 RenderBlock {HTML} at (0,0) size 800x600
 5 RenderBody {BODY} at (8,10) size 784x580
 6 RenderBlock {DIV} at (10,0) size 100x100
 7 RenderBlock {DIV} at (10,110) size 100x100
 8 RenderBlock {DIV} at (10,220) size 100x100

LayoutTests/platform/mac/css3/images/cross-fade-tiled-expected.png


Added

45fd6fb546dbca7268b1c11fa3fbba82

LayoutTests/platform/mac/css3/images/cross-fade-tiled-expected.txt

 1layer at (0,0) size 800x600
 2 RenderView at (0,0) size 800x600
 3layer at (0,0) size 800x600
 4 RenderBlock {HTML} at (0,0) size 800x600
 5 RenderBody {BODY} at (8,10) size 784x580
 6layer at (18,10) size 102x102
 7 RenderBlock {DIV} at (10,0) size 102x102 [border: (1px solid #000000)]
 8layer at (18,122) size 102x102
 9 RenderBlock {DIV} at (10,112) size 102x102 [border: (1px solid #000000)]
 10layer at (18,234) size 102x102
 11 RenderBlock {DIV} at (10,224) size 102x102 [border: (1px solid #000000)]

Source/WebCore/CMakeLists.txt

@@SET(WebCore_SOURCES
10671067
10681068 platform/graphics/BitmapImage.cpp
10691069 platform/graphics/Color.cpp
 1070 platform/graphics/CrossfadeGeneratedImage.cpp
10701071 platform/graphics/FloatPoint.cpp
10711072 platform/graphics/FloatPoint3D.cpp
10721073 platform/graphics/FloatQuad.cpp

@@SET(WebCore_SOURCES
10801081 platform/graphics/FontFamily.cpp
10811082 platform/graphics/FontFastPath.cpp
10821083 platform/graphics/FontFeatureSettings.cpp
1083  platform/graphics/GeneratedImage.cpp
 1084 platform/graphics/GeneratorGeneratedImage.cpp
10841085 platform/graphics/GlyphPageTreeNode.cpp
10851086 platform/graphics/Gradient.cpp
10861087 platform/graphics/GraphicsContext.cpp

Source/WebCore/ChangeLog

 12011-11-14 Tim Horton <timothy_horton@apple.com>
 2
 3 Implement CSS3 Images cross-fade() image function
 4 https://bugs.webkit.org/show_bug.cgi?id=52162
 5 <rdar://problem/10209254>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Render -webkit-cross-fade. Only cross-fades entirely composed of images will render for now,
 10 cross-fades involving generated images are not yet implemented.
 11
 12 Reorganize GeneratedImage to be the base class for GeneratorGeneratedImage and CrossfadeGeneratedImage.
 13
 14 Add a pending state to CSSImageGeneratorValue, which is used to enable the pending-images loading
 15 mechanism for -webkit-cross-fade's sub-images. Rework the logic in CSSStyleSelector to support pending
 16 generated images.
 17
 18 Tests: css3/images/cross-fade-invalidation.html
 19 css3/images/cross-fade-simple.html
 20 css3/images/cross-fade-sizing.html
 21 css3/images/cross-fade-tiled.html
 22
 23 * CMakeLists.txt:
 24 * GNUmakefile.list.am:
 25 * Target.pri:
 26 * WebCore.gypi:
 27 * WebCore.xcodeproj/project.pbxproj:
 28 * css/CSSCanvasValue.h:
 29 (WebCore::CSSCanvasValue::isPending):
 30 (WebCore::CSSCanvasValue::loadSubimages):
 31 * css/CSSCrossfadeValue.cpp:
 32 (WebCore::CSSCrossfadeValue::isPending):
 33 (WebCore::CSSCrossfadeValue::loadSubimages):
 34 (WebCore::subimageIsPending):
 35 (WebCore::loadSubimage):
 36 (WebCore::cachedImageForCSSValue):
 37 (WebCore::CSSCrossfadeValue::image):
 38 (WebCore::CSSCrossfadeValue::crossfadeChanged):
 39 * css/CSSCrossfadeValue.h:
 40 (WebCore::CSSCrossfadeValue::create):
 41 (WebCore::CSSCrossfadeValue::~CSSCrossfadeValue):
 42 (WebCore::CSSCrossfadeValue::fixedSize):
 43 (WebCore::CSSCrossfadeValue::CSSCrossfadeValue):
 44 (WebCore::CSSCrossfadeValue::CrossfadeObserverProxy::CrossfadeObserverProxy):
 45 * css/CSSGradientValue.cpp:
 46 (WebCore::CSSGradientValue::image):
 47 * css/CSSGradientValue.h:
 48 (WebCore::CSSGradientValue::isPending):
 49 (WebCore::CSSGradientValue::loadSubimages):
 50 * css/CSSImageGeneratorValue.cpp:
 51 (WebCore::CSSImageGeneratorValue::generatedOrPendingImage):
 52 (WebCore::CSSImageGeneratorValue::generatedImage):
 53 (WebCore::CSSImageGeneratorValue::isPending):
 54 (WebCore::CSSImageGeneratorValue::loadSubimages):
 55 * css/CSSImageGeneratorValue.h:
 56 * css/CSSParser.cpp:
 57 (WebCore::CSSParser::parseCrossfade):
 58 * css/CSSStyleSelector.cpp:
 59 (WebCore::CSSStyleSelector::styleImage):
 60 (WebCore::CSSStyleSelector::generatedOrPendingFromValue):
 61 (WebCore::CSSStyleSelector::loadPendingImage):
 62 (WebCore::CSSStyleSelector::loadPendingImages):
 63 * css/CSSStyleSelector.h:
 64 * platform/graphics/BitmapImage.h:
 65 * platform/graphics/CrossfadeGeneratedImage.cpp: Added.
 66 (WebCore::CrossfadeGeneratedImage::CrossfadeGeneratedImage):
 67 (WebCore::CrossfadeGeneratedImage::~CrossfadeGeneratedImage):
 68 (WebCore::CrossfadeGeneratedImage::drawCrossfade):
 69 (WebCore::CrossfadeGeneratedImage::draw):
 70 (WebCore::CrossfadeGeneratedImage::drawPattern):
 71 (WebCore::CrossfadeGeneratedImage::imageChanged):
 72 * platform/graphics/CrossfadeGeneratedImage.h: Added.
 73 (WebCore::CrossfadeGeneratedImage::create):
 74 (WebCore::CrossfadeSubimageObserverProxy::CrossfadeSubimageObserverProxy):
 75 (WebCore::CrossfadeSubimageObserverProxy::setReady):
 76 * platform/graphics/GeneratedImage.h:
 77 (WebCore::GeneratedImage::GeneratedImage):
 78 * platform/graphics/GeneratorGeneratedImage.cpp: Renamed from Source/WebCore/platform/graphics/GeneratedImage.cpp.
 79 (WebCore::GeneratorGeneratedImage::draw):
 80 (WebCore::GeneratorGeneratedImage::drawPattern):
 81 (WebCore::GeneratedImage::computeIntrinsicDimensions):
 82 * platform/graphics/GeneratorGeneratedImage.h: Copied from Source/WebCore/platform/graphics/GeneratedImage.h.
 83 (WebCore::GeneratorGeneratedImage::create):
 84 (WebCore::GeneratorGeneratedImage::~GeneratorGeneratedImage):
 85 (WebCore::GeneratorGeneratedImage::GeneratorGeneratedImage):
 86 * platform/graphics/Image.h:
 87 * platform/graphics/ImageBuffer.h:
 88 * rendering/style/StylePendingImage.h:
 89 (WebCore::StylePendingImage::create):
 90 (WebCore::StylePendingImage::data):
 91 (WebCore::StylePendingImage::cssImageValue):
 92 (WebCore::StylePendingImage::cssImageGeneratorValue):
 93 (WebCore::StylePendingImage::StylePendingImage):
 94
1952011-11-14 Michael Nordman <michaeln@google.com>
296
397 Return more complete error and exception messages when a

Source/WebCore/GNUmakefile.list.am

@@webcore_sources += \
25092509 Source/WebCore/platform/graphics/BitmapImage.h \
25102510 Source/WebCore/platform/graphics/Color.cpp \
25112511 Source/WebCore/platform/graphics/Color.h \
 2512 Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp \
 2513 Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h \
25122514 Source/WebCore/platform/graphics/ColorSpace.h \
25132515 Source/WebCore/platform/graphics/DashArray.h \
25142516 Source/WebCore/platform/graphics/Extensions3D.h \

@@webcore_sources += \
26262628 Source/WebCore/platform/graphics/FontSmoothingMode.h \
26272629 Source/WebCore/platform/graphics/FontTraitsMask.h \
26282630 Source/WebCore/platform/graphics/FontWidthVariant.h \
2629  Source/WebCore/platform/graphics/GeneratedImage.cpp \
 2631 Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp \
 2632 Source/WebCore/platform/graphics/GeneratorGeneratedImage.h \
26302633 Source/WebCore/platform/graphics/GeneratedImage.h \
26312634 Source/WebCore/platform/graphics/Generator.h \
26322635 Source/WebCore/platform/graphics/Glyph.h \

Source/WebCore/Target.pri

@@SOURCES += \
10361036 platform/graphics/FontFeatureSettings.cpp \
10371037 platform/graphics/BitmapImage.cpp \
10381038 platform/graphics/Color.cpp \
 1039 platform/graphics/CrossfadeGeneratedImage.cpp \
10391040 platform/graphics/FloatPoint3D.cpp \
10401041 platform/graphics/FloatPoint.cpp \
10411042 platform/graphics/FloatQuad.cpp \

@@SOURCES += \
10441045 platform/graphics/FontData.cpp \
10451046 platform/graphics/Font.cpp \
10461047 platform/graphics/FontCache.cpp \
1047  platform/graphics/GeneratedImage.cpp \
 1048 platform/graphics/GeneratorGeneratedImage.cpp \
10481049 platform/graphics/Gradient.cpp \
10491050 platform/graphics/GraphicsContext.cpp \
10501051 platform/graphics/GraphicsLayer.cpp \

@@HEADERS += \
20722073 platform/mock/ScrollbarThemeMock.h \
20732074 platform/graphics/BitmapImage.h \
20742075 platform/graphics/Color.h \
 2076 platform/graphics/CrossfadeGeneratedImage.h \
20752077 platform/graphics/filters/FEBlend.h \
20762078 platform/graphics/filters/FEColorMatrix.h \
20772079 platform/graphics/filters/FEComponentTransfer.h \

@@HEADERS += \
21092111 platform/graphics/FontFeatureSettings.h \
21102112 platform/graphics/FontMetrics.h \
21112113 platform/graphics/Font.h \
 2114 platform/graphics/GeneratorGeneratedImage.h \
21122115 platform/graphics/GeneratedImage.h \
21132116 platform/graphics/GlyphPageTreeNode.h \
21142117 platform/graphics/Gradient.h \

Source/WebCore/WebCore.gypi

33303330 'platform/graphics/ANGLEWebKitBridge.h',
33313331 'platform/graphics/BitmapImage.cpp',
33323332 'platform/graphics/Color.cpp',
 3333 'platform/graphics/CrossfadeGeneratedImage.cpp',
 3334 'platform/graphics/CrossfadeGeneratedImage.h',
33333335 'platform/graphics/Extensions3D.h',
33343336 'platform/graphics/FloatPoint.cpp',
33353337 'platform/graphics/FloatPoint3D.cpp',

33463348 'platform/graphics/FontFastPath.cpp',
33473349 'platform/graphics/FontPlatformData.cpp',
33483350 'platform/graphics/FontPlatformData.h',
3349  'platform/graphics/GeneratedImage.cpp',
 3351 'platform/graphics/GeneratorGeneratedImage.cpp',
33503352 'platform/graphics/GeneratedImage.h',
33513353 'platform/graphics/GlyphPageTreeNode.cpp',
33523354 'platform/graphics/Gradient.cpp',

Source/WebCore/WebCore.xcodeproj/project.pbxproj

699699 2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */; };
700700 2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */; };
701701 2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */; settings = {ATTRIBUTES = (Private, ); }; };
 702 2D481F00146B5C4C00AA7834 /* CrossfadeGeneratedImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */; };
 703 2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */; };
 704 2D481F03146B5C6500AA7834 /* GeneratorGeneratedImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D2FC0561460CD6F00263633 /* GeneratorGeneratedImage.cpp */; };
 705 2D481F04146B5C6B00AA7834 /* GeneratorGeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D2FC0571460CD6F00263633 /* GeneratorGeneratedImage.h */; };
702706 2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */; };
703707 2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8FEBDB143E3EF70072502B /* CSSCrossfadeValue.h */; };
704708 2D9066060BE141D400956998 /* LayoutState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D9066040BE141D400956998 /* LayoutState.cpp */; };

52775281 BCE0139A0C0BEF180043860A /* JSStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE013980C0BEF180043860A /* JSStyleSheet.cpp */; };
52785282 BCE0139B0C0BEF180043860A /* JSStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE013990C0BEF180043860A /* JSStyleSheet.h */; };
52795283 BCE04C8A0DAFF7A0007A0F41 /* Generator.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE04C890DAFF7A0007A0F41 /* Generator.h */; settings = {ATTRIBUTES = (Private, ); }; };
5280  BCE04C940DAFF902007A0F41 /* GeneratedImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE04C930DAFF902007A0F41 /* GeneratedImage.cpp */; };
52815284 BCE1C41B0D982980003B02F2 /* Location.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE1C4190D982980003B02F2 /* Location.h */; };
52825285 BCE1C41C0D982981003B02F2 /* Location.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE1C41A0D982980003B02F2 /* Location.cpp */; };
52835286 BCE1C43B0D9830D3003B02F2 /* JSLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE1C4390D9830D3003B02F2 /* JSLocation.cpp */; };

78037806 29D7BCF91444AF7D0070619C /* AccessibilitySpinButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySpinButton.h; sourceTree = "<group>"; };
78047807 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
78057808 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLMetaCharsetParser.cpp; path = parser/HTMLMetaCharsetParser.cpp; sourceTree = "<group>"; };
 7809 2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossfadeGeneratedImage.cpp; sourceTree = "<group>"; };
 7810 2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossfadeGeneratedImage.h; sourceTree = "<group>"; };
 7811 2D2FC0561460CD6F00263633 /* GeneratorGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeneratorGeneratedImage.cpp; sourceTree = "<group>"; };
 7812 2D2FC0571460CD6F00263633 /* GeneratorGeneratedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratorGeneratedImage.h; sourceTree = "<group>"; };
78067813 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGParsingError.h; sourceTree = "<group>"; };
78077814 2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCrossfadeValue.cpp; sourceTree = "<group>"; };
78087815 2D8FEBDB143E3EF70072502B /* CSSCrossfadeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSCrossfadeValue.h; sourceTree = "<group>"; };

1257712584 BCE013980C0BEF180043860A /* JSStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSStyleSheet.cpp; sourceTree = "<group>"; };
1257812585 BCE013990C0BEF180043860A /* JSStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSStyleSheet.h; sourceTree = "<group>"; };
1257912586 BCE04C890DAFF7A0007A0F41 /* Generator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Generator.h; sourceTree = "<group>"; };
12580  BCE04C930DAFF902007A0F41 /* GeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeneratedImage.cpp; sourceTree = "<group>"; };
1258112587 BCE1C4190D982980003B02F2 /* Location.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Location.h; sourceTree = "<group>"; };
1258212588 BCE1C41A0D982980003B02F2 /* Location.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Location.cpp; sourceTree = "<group>"; };
1258312589 BCE1C4220D9829F2003B02F2 /* Location.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Location.idl; sourceTree = "<group>"; };

1921219218 37202198106213C600F25C4B /* FontSmoothingMode.h */,
1921319219 3784C34A0E11AA34007D8D48 /* FontTraitsMask.h */,
1921419220 BCE4413512F7490B009B84B8 /* FontWidthVariant.h */,
19215  BCE04C930DAFF902007A0F41 /* GeneratedImage.cpp */,
 19221 2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */,
 19222 2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */,
 19223 2D2FC0561460CD6F00263633 /* GeneratorGeneratedImage.cpp */,
 19224 2D2FC0571460CD6F00263633 /* GeneratorGeneratedImage.h */,
1921619225 BC23F0DA0DAFF4A4009FDC91 /* GeneratedImage.h */,
1921719226 BCE04C890DAFF7A0007A0F41 /* Generator.h */,
1921819227 086BBD0E136039C2008B15D8 /* Glyph.h */,

2237322382 19BFF64B11C0F2AC00B8C04D /* DOMSVGFEConvolveMatrixElement.h in Headers */,
2237422383 19BFF64D11C0F2AC00B8C04D /* DOMSVGFEConvolveMatrixElementInternal.h in Headers */,
2237522384 8502AB480AD438C000378540 /* DOMSVGFEDiffuseLightingElement.h in Headers */,
 22385 2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */,
 22386 2D481F04146B5C6B00AA7834 /* GeneratorGeneratedImage.h in Headers */,
2237622387 8502AB920AD4394E00378540 /* DOMSVGFEDiffuseLightingElementInternal.h in Headers */,
2237722388 8502AB4A0AD438C000378540 /* DOMSVGFEDisplacementMapElement.h in Headers */,
2237822389 8502AB930AD4394E00378540 /* DOMSVGFEDisplacementMapElementInternal.h in Headers */,

2505225063 buildActionMask = 2147483647;
2505325064 files = (
2505425065 AD03AAFA1468455300A39B5B /* CSSValue.cpp in Sources */,
 25066 2D481F00146B5C4C00AA7834 /* CrossfadeGeneratedImage.cpp in Sources */,
 25067 2D481F03146B5C6500AA7834 /* GeneratorGeneratedImage.cpp in Sources */,
2505525068 B5B5DC69119BB3D5002A8790 /* AbstractDatabase.cpp in Sources */,
2505625069 41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */,
2505725070 0F29C16E1300C2E2002D794E /* AccessibilityAllInOne.cpp in Sources */,

2578725800 97205AAF123928CA00B17380 /* FTPDirectoryDocument.cpp in Sources */,
2578825801 51C81B890C4422F70019ECE3 /* FTPDirectoryParser.cpp in Sources */,
2578925802 1432E8490C51493F00B1500F /* GCController.cpp in Sources */,
25790  BCE04C940DAFF902007A0F41 /* GeneratedImage.cpp in Sources */,
2579125803 FE80D7C50E9C1F25000D6F75 /* Geolocation.cpp in Sources */,
2579225804 052BFCE9128ABF1500FD338D /* GeolocationClientMock.cpp in Sources */,
2579325805 BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */,

Source/WebCore/css/CSSCanvasValue.h

@@public:
4444 bool isFixedSize() const { return true; }
4545 IntSize fixedSize(const RenderObject*);
4646
 47 bool isPending() const { return false; }
 48 void loadSubimages(CachedResourceLoader*) { }
 49
4750 void setName(const String& name) { m_name = name; }
4851
4952private:

Source/WebCore/css/CSSCrossfadeValue.cpp

2626#include "config.h"
2727#include "CSSCrossfadeValue.h"
2828
 29#include "CSSImageValue.h"
 30#include "CachedImage.h"
 31#include "CachedResourceLoader.h"
 32#include "CrossfadeGeneratedImage.h"
 33#include "ImageBuffer.h"
 34#include "RenderObject.h"
 35#include "StyleCachedImage.h"
 36#include "StyleGeneratedImage.h"
 37
2938namespace WebCore {
3039
 40CachedImage* cachedImageForCSSValue(PassRefPtr<CSSValue>, RenderObject*, const IntSize&);
 41void loadSubimage(PassRefPtr<CSSValue>, CachedResourceLoader*);
 42bool subimageIsPending(PassRefPtr<CSSValue>);
 43
3144String CSSCrossfadeValue::customCssText() const
3245{
3346 String result = "-webkit-cross-fade(";

@@String CSSCrossfadeValue::customCssText() const
3851 return result;
3952}
4053
41 IntSize CSSCrossfadeValue::fixedSize(const RenderObject* renderer)
 54bool CSSCrossfadeValue::isPending() const
4255{
43  UNUSED_PARAM(renderer);
 56 return subimageIsPending(m_fromImage) || subimageIsPending(m_toImage);
 57}
4458
45  return IntSize();
 59void CSSCrossfadeValue::loadSubimages(CachedResourceLoader* cachedResourceLoader)
 60{
 61 loadSubimage(m_fromImage, cachedResourceLoader);
 62 loadSubimage(m_toImage, cachedResourceLoader);
4663}
4764
48 PassRefPtr<Image> CSSCrossfadeValue::image(RenderObject* renderer, const IntSize& size)
 65bool subimageIsPending(PassRefPtr<CSSValue> value)
 66{
 67 if (value->isImageValue())
 68 return static_cast<CSSImageValue*>(value.get())->cachedOrPendingImage()->isPendingImage();
 69
 70 if (value->isImageGeneratorValue())
 71 return static_cast<CSSImageGeneratorValue*>(value.get())->isPending();
 72
 73 ASSERT_NOT_REACHED();
 74
 75 return false;
 76}
 77
 78void loadSubimage(PassRefPtr<CSSValue> value, CachedResourceLoader* cachedResourceLoader)
 79{
 80 if (value->isImageValue()) {
 81 static_cast<CSSImageValue*>(value.get())->cachedImage(cachedResourceLoader);
 82 return;
 83 }
 84
 85 if (value->isImageGeneratorValue()) {
 86 static_cast<CSSImageGeneratorValue*>(value.get())->loadSubimages(cachedResourceLoader);
 87 return;
 88 }
 89
 90 ASSERT_NOT_REACHED();
 91}
 92
 93CachedImage* cachedImageForCSSValue(PassRefPtr<CSSValue> value, RenderObject* renderer, const IntSize& size)
4994{
50  UNUSED_PARAM(renderer);
5195 UNUSED_PARAM(size);
5296
 97 CachedResourceLoader* cachedResourceLoader = renderer->document()->cachedResourceLoader();
 98
 99 if (value->isImageValue())
 100 return static_cast<CSSImageValue*>(value.get())->cachedImage(cachedResourceLoader)->cachedImage();
 101
 102 if (value->isImageGeneratorValue()) {
 103 // FIXME: Handle CSSImageGeneratorValue (and thus cross-fades with gradients and canvas).
 104 return 0;
 105 }
 106
 107 ASSERT_NOT_REACHED();
 108
53109 return 0;
54110}
55111
 112PassRefPtr<Image> CSSCrossfadeValue::image(RenderObject* renderer, const IntSize& size)
 113{
 114 if (size.isEmpty())
 115 return 0;
 116
 117 CachedImage* fromImage, * toImage;
 118
 119 fromImage = cachedImageForCSSValue(m_fromImage, renderer, size);
 120 toImage = cachedImageForCSSValue(m_toImage, renderer, size);
 121
 122 if (!fromImage || !toImage)
 123 return Image::nullImage();
 124
 125 m_generatedImage = CrossfadeGeneratedImage::create(fromImage, toImage, m_percentage->getDoubleValue() / 100.0, &m_crossfadeObserver, size);
 126
 127 return m_generatedImage.get();
 128}
 129
 130void CSSCrossfadeValue::crossfadeChanged(const IntRect& rect)
 131{
 132 UNUSED_PARAM(rect);
 133
 134 RenderObjectSizeCountMap::const_iterator end = clients().end();
 135 for (RenderObjectSizeCountMap::const_iterator curr = clients().begin(); curr != end; ++curr) {
 136 RenderObject* client = const_cast<RenderObject*>(curr->first);
 137 client->imageChanged(static_cast<WrappedImagePtr>(this));
 138 }
 139}
 140
56141} // namespace WebCore

Source/WebCore/css/CSSCrossfadeValue.h

2727#define CSSCrossfadeValue_h
2828
2929#include "CSSImageGeneratorValue.h"
30 #include "CSSImageValue.h"
 30#include "CSSPrimitiveValue.h"
3131#include "Image.h"
3232#include "ImageObserver.h"
3333
3434namespace WebCore {
3535
 36class CachedImage;
3637class RenderObject;
 38class Document;
3739
3840class CSSCrossfadeValue : public CSSImageGeneratorValue {
3941public:
40  static PassRefPtr<CSSCrossfadeValue> create(PassRefPtr<CSSImageValue> fromImage, PassRefPtr<CSSImageValue> toImage) { return adoptRef(new CSSCrossfadeValue(fromImage, toImage)); }
 42 static PassRefPtr<CSSCrossfadeValue> create(PassRefPtr<CSSValue> fromImage, PassRefPtr<CSSValue> toImage) { return adoptRef(new CSSCrossfadeValue(fromImage, toImage)); }
 43 ~CSSCrossfadeValue() { }
4144
4245 String customCssText() const;
4346
4447 PassRefPtr<Image> image(RenderObject*, const IntSize&);
4548 bool isFixedSize() const { return false; }
46  IntSize fixedSize(const RenderObject*);
 49 IntSize fixedSize(const RenderObject*) { return IntSize(); }
 50
 51 bool isPending() const;
 52 void loadSubimages(CachedResourceLoader*);
4753
4854 void setPercentage(PassRefPtr<CSSPrimitiveValue> percentage) { m_percentage = percentage; }
4955
5056private:
51  CSSCrossfadeValue(PassRefPtr<CSSImageValue> fromImage, PassRefPtr<CSSImageValue> toImage)
 57 CSSCrossfadeValue(PassRefPtr<CSSValue> fromImage, PassRefPtr<CSSValue> toImage)
5258 : CSSImageGeneratorValue(CrossfadeClass)
5359 , m_fromImage(fromImage)
5460 , m_toImage(toImage)
55  {
56  }
 61 , m_crossfadeObserver(this) { }
 62
 63 // NOTE: We put the ImageObserver in a member instead of inheriting from it
 64 // to avoid adding a vptr to CSSCrossfadeValue.
 65 class CrossfadeObserverProxy : public ImageObserver {
 66 public:
 67 CrossfadeObserverProxy(CSSCrossfadeValue* ownerValue) : m_ownerValue(ownerValue) { }
 68 virtual ~CrossfadeObserverProxy() OVERRIDE { }
 69 virtual void changedInRect(const Image*, const IntRect& rect) OVERRIDE { m_ownerValue->crossfadeChanged(rect); };
 70 virtual bool shouldPauseAnimation(const Image*) OVERRIDE { return false; }
 71 virtual void didDraw(const Image*) OVERRIDE { }
 72 virtual void animationAdvanced(const Image*) OVERRIDE { }
 73 virtual void decodedSizeChanged(const Image*, int) OVERRIDE { }
 74 private:
 75 CSSCrossfadeValue* m_ownerValue;
 76 };
 77
 78 void crossfadeChanged(const IntRect&);
5779
58  RefPtr<CSSImageValue> m_fromImage;
59  RefPtr<CSSImageValue> m_toImage;
 80 RefPtr<CSSValue> m_fromImage;
 81 RefPtr<CSSValue> m_toImage;
6082 RefPtr<CSSPrimitiveValue> m_percentage;
 83
 84 RefPtr<Image> m_generatedImage;
 85
 86 CrossfadeObserverProxy m_crossfadeObserver;
6187};
6288
6389} // namespace WebCore

Source/WebCore/css/CSSGradientValue.cpp

2626#include "config.h"
2727#include "CSSGradientValue.h"
2828
29 #include "CSSValueKeywords.h"
3029#include "CSSStyleSelector.h"
31 #include "GeneratedImage.h"
 30#include "CSSValueKeywords.h"
 31#include "GeneratorGeneratedImage.h"
3232#include "Gradient.h"
3333#include "Image.h"
3434#include "IntSize.h"

@@PassRefPtr<Image> CSSGradientValue::image(RenderObject* renderer, const IntSize&
6767 gradient = static_cast<CSSRadialGradientValue*>(this)->createGradient(renderer, size);
6868 }
6969
70  RefPtr<Image> newImage = GeneratedImage::create(gradient, size);
 70 RefPtr<Image> newImage = GeneratorGeneratedImage::create(gradient, size);
7171 if (cacheable)
7272 putImage(size, newImage);
7373

Source/WebCore/css/CSSGradientValue.h

@@public:
6969 bool isFixedSize() const { return false; }
7070 IntSize fixedSize(const RenderObject*) const { return IntSize(); }
7171
 72 bool isPending() const { return false; }
 73 void loadSubimages(CachedResourceLoader*) { }
 74
7275protected:
7376 CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, bool deprecatedType = false)
7477 : CSSImageGeneratorValue(classType)

Source/WebCore/css/CSSImageGeneratorValue.cpp

3232#include "Image.h"
3333#include "RenderObject.h"
3434#include "StyleGeneratedImage.h"
 35#include "StylePendingImage.h"
3536#include <wtf/text/WTFString.h>
3637
3738namespace WebCore {

@@void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
110111 m_images.add(size, image);
111112}
112113
 114StyleImage* CSSImageGeneratorValue::generatedOrPendingImage()
 115{
 116 if (isPending())
 117 m_image = StylePendingImage::create(this).get();
 118 else if (!m_accessedImage) {
 119 m_accessedImage = true;
 120 m_image = StyleGeneratedImage::create(this, isFixedSize());
 121 }
 122
 123 return m_image.get();
 124}
 125
113126StyleGeneratedImage* CSSImageGeneratorValue::generatedImage()
114127{
115128 if (!m_accessedImage) {
116129 m_accessedImage = true;
117130 m_image = StyleGeneratedImage::create(this, isFixedSize());
118131 }
119  return m_image.get();
 132
 133 return static_cast<StyleGeneratedImage*>(m_image.get());
120134}
121135
122136PassRefPtr<Image> CSSImageGeneratorValue::image(RenderObject* renderer, const IntSize& size)

@@IntSize CSSImageGeneratorValue::fixedSize(const RenderObject* renderer)
170184 return IntSize();
171185}
172186
 187bool CSSImageGeneratorValue::isPending() const
 188{
 189 switch (classType()) {
 190 case CrossfadeClass:
 191 return static_cast<const CSSCrossfadeValue*>(this)->isPending();
 192 case CanvasClass:
 193 return static_cast<const CSSCanvasValue*>(this)->isPending();
 194 case LinearGradientClass:
 195 return static_cast<const CSSLinearGradientValue*>(this)->isPending();
 196 case RadialGradientClass:
 197 return static_cast<const CSSRadialGradientValue*>(this)->isPending();
 198 default:
 199 ASSERT_NOT_REACHED();
 200 }
 201 return false;
 202}
 203
 204void CSSImageGeneratorValue::loadSubimages(CachedResourceLoader* cachedResourceLoader)
 205{
 206 switch (classType()) {
 207 case CrossfadeClass:
 208 static_cast<CSSCrossfadeValue*>(this)->loadSubimages(cachedResourceLoader);
 209 break;
 210 case CanvasClass:
 211 static_cast<CSSCanvasValue*>(this)->loadSubimages(cachedResourceLoader);
 212 break;
 213 case LinearGradientClass:
 214 static_cast<CSSLinearGradientValue*>(this)->loadSubimages(cachedResourceLoader);
 215 break;
 216 case RadialGradientClass:
 217 static_cast<CSSRadialGradientValue*>(this)->loadSubimages(cachedResourceLoader);
 218 break;
 219 default:
 220 ASSERT_NOT_REACHED();
 221 }
 222}
 223
173224} // namespace WebCore

Source/WebCore/css/CSSImageGeneratorValue.h

3333
3434namespace WebCore {
3535
 36class CachedResourceLoader;
3637class Image;
3738class RenderObject;
3839class StyleGeneratedImage;
 40class StyleImage;
3941
4042struct SizeAndCount {
4143 SizeAndCount(IntSize newSize = IntSize(), int newCount = 0)

@@public:
5860 void removeClient(RenderObject*);
5961 PassRefPtr<Image> image(RenderObject*, const IntSize&);
6062
 63 StyleImage* generatedOrPendingImage();
6164 StyleGeneratedImage* generatedImage();
6265
6366 bool isFixedSize() const;
6467 IntSize fixedSize(const RenderObject*);
6568
 69 bool isPending() const;
 70
 71 void loadSubimages(CachedResourceLoader*);
 72
6673protected:
6774 CSSImageGeneratorValue(ClassType);
6875

@@protected:
7077 void putImage(const IntSize&, PassRefPtr<Image>);
7178 const RenderObjectSizeCountMap& clients() const { return m_clients; }
7279
73  RefPtr<StyleGeneratedImage> m_image;
 80 RefPtr<StyleImage> m_image;
7481 bool m_accessedImage;
7582
7683 HashCountedSet<IntSize> m_sizes; // A count of how many times a given image size is in use.

Source/WebCore/css/CSSParser.cpp

@@bool CSSParser::parseCrossfade(CSSParserValueList* valueList, RefPtr<CSSValue>&
62906290 if (!a || a->unit != CSSPrimitiveValue::CSS_PERCENTAGE)
62916291 return false;
62926292
6293  result = CSSCrossfadeValue::create(static_cast<CSSImageValue*>(fromImageValue.get()), static_cast<CSSImageValue*>(toImageValue.get()));
 6293 result = CSSCrossfadeValue::create(fromImageValue, toImageValue);
62946294 result->setPercentage(createPrimitiveNumericValue(a));
62956295
62966296 crossfade = result;

Source/WebCore/css/CSSStyleSelector.cpp

@@StyleImage* CSSStyleSelector::styleImage(CSSPropertyID property, CSSValue* value
42464246 return cachedOrPendingFromValue(property, static_cast<CSSImageValue*>(value));
42474247
42484248 if (value->isImageGeneratorValue())
4249  return static_cast<CSSImageGeneratorValue*>(value)->generatedImage();
 4249 return generatedOrPendingFromValue(property, static_cast<CSSImageGeneratorValue*>(value));
42504250
42514251 return 0;
42524252}

@@StyleImage* CSSStyleSelector::cachedOrPendingFromValue(CSSPropertyID property, C
42594259 return image;
42604260}
42614261
 4262StyleImage* CSSStyleSelector::generatedOrPendingFromValue(CSSPropertyID property, CSSImageGeneratorValue* value)
 4263{
 4264 StyleImage* image = value->generatedOrPendingImage();
 4265 if (image && image->isPendingImage())
 4266 m_pendingImageProperties.add(property);
 4267 return image;
 4268}
 4269
42624270void CSSStyleSelector::mapFillImage(CSSPropertyID property, FillLayer* layer, CSSValue* value)
42634271{
42644272 if (value->isInitialValue()) {

@@bool CSSStyleSelector::createFilterOperations(CSSValue* inValue, RenderStyle* st
55765584
55775585#endif
55785586
 5587StyleImage* CSSStyleSelector::loadPendingImage(StylePendingImage* pendingImage)
 5588{
 5589 CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader();
 5590
 5591 if (pendingImage->cssImageValue()) {
 5592 CSSImageValue* imageValue = pendingImage->cssImageValue();
 5593 return imageValue->cachedImage(cachedResourceLoader);
 5594 }
 5595
 5596 if (pendingImage->cssImageGeneratorValue()) {
 5597 CSSImageGeneratorValue* imageGeneratorValue = pendingImage->cssImageGeneratorValue();
 5598 imageGeneratorValue->loadSubimages(cachedResourceLoader);
 5599 return imageGeneratorValue->generatedImage();
 5600 }
 5601
 5602 return 0;
 5603}
 5604
55795605void CSSStyleSelector::loadPendingImages()
55805606{
55815607 if (m_pendingImageProperties.isEmpty())

@@void CSSStyleSelector::loadPendingImages()
55855611 for (HashSet<int>::const_iterator it = m_pendingImageProperties.begin(); it != end; ++it) {
55865612 CSSPropertyID currentProperty = static_cast<CSSPropertyID>(*it);
55875613
5588  CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader();
5589 
55905614 switch (currentProperty) {
55915615 case CSSPropertyBackgroundImage: {
55925616 for (FillLayer* backgroundLayer = m_style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
55935617 if (backgroundLayer->image() && backgroundLayer->image()->isPendingImage()) {
5594  CSSImageValue* imageValue = static_cast<StylePendingImage*>(backgroundLayer->image())->cssImageValue();
5595  backgroundLayer->setImage(imageValue->cachedImage(cachedResourceLoader));
 5618 StyleImage* loadedImage = loadPendingImage(static_cast<StylePendingImage*>(backgroundLayer->image()));
 5619 backgroundLayer->setImage(loadedImage);
55965620 }
55975621 }
55985622 break;

@@void CSSStyleSelector::loadPendingImages()
56015625 case CSSPropertyContent: {
56025626 for (ContentData* contentData = const_cast<ContentData*>(m_style->contentData()); contentData; contentData = contentData->next()) {
56035627 if (contentData->isImage()) {
5604  const StyleImage* image = static_cast<ImageContentData*>(contentData)->image();
 5628 StyleImage* image = static_cast<ImageContentData*>(contentData)->image();
56055629 if (image->isPendingImage()) {
5606  CSSImageValue* imageValue = static_cast<const StylePendingImage*>(image)->cssImageValue();
5607  if (StyleCachedImage* cachedImage = imageValue->cachedImage(cachedResourceLoader))
5608  static_cast<ImageContentData*>(contentData)->setImage(cachedImage);
 5630 StyleImage* loadedImage = loadPendingImage(static_cast<StylePendingImage*>(image));
 5631 if (loadedImage)
 5632 static_cast<ImageContentData*>(contentData)->setImage(loadedImage);
56095633 }
56105634 }
56115635 }

@@void CSSStyleSelector::loadPendingImages()
56185642 CursorData& currentCursor = cursorList->at(i);
56195643 if (StyleImage* image = currentCursor.image()) {
56205644 if (image->isPendingImage()) {
5621  CSSImageValue* imageValue = static_cast<StylePendingImage*>(image)->cssImageValue();
5622  currentCursor.setImage(imageValue->cachedImage(cachedResourceLoader));
 5645 StyleImage* loadedImage = loadPendingImage(static_cast<StylePendingImage*>(image));
 5646 currentCursor.setImage(loadedImage);
56235647 }
56245648 }
56255649 }

@@void CSSStyleSelector::loadPendingImages()
56295653
56305654 case CSSPropertyListStyleImage: {
56315655 if (m_style->listStyleImage() && m_style->listStyleImage()->isPendingImage()) {
5632  CSSImageValue* imageValue = static_cast<StylePendingImage*>(m_style->listStyleImage())->cssImageValue();
5633  m_style->setListStyleImage(imageValue->cachedImage(cachedResourceLoader));
 5656 StyleImage* loadedImage = loadPendingImage(static_cast<StylePendingImage*>(m_style->listStyleImage()));
 5657 m_style->setListStyleImage(loadedImage);
56345658 }
56355659 break;
56365660 }
56375661
56385662 case CSSPropertyBorderImageSource: {
56395663 if (m_style->borderImageSource() && m_style->borderImageSource()->isPendingImage()) {
5640  CSSImageValue* imageValue = static_cast<StylePendingImage*>(m_style->borderImageSource())->cssImageValue();
5641  m_style->setBorderImageSource(imageValue->cachedImage(cachedResourceLoader));
 5664 StyleImage* loadedImage = loadPendingImage(static_cast<StylePendingImage*>(m_style->borderImageSource()));
 5665 m_style->setBorderImageSource(loadedImage);
56425666 }
56435667 break;
56445668 }

@@void CSSStyleSelector::loadPendingImages()
56475671 if (StyleReflection* reflection = m_style->boxReflect()) {
56485672 const NinePieceImage& maskImage = reflection->mask();
56495673 if (maskImage.image() && maskImage.image()->isPendingImage()) {
5650  CSSImageValue* imageValue = static_cast<StylePendingImage*>(maskImage.image())->cssImageValue();
5651  reflection->setMask(NinePieceImage(imageValue->cachedImage(cachedResourceLoader), maskImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), maskImage.horizontalRule(), maskImage.verticalRule()));
 5674 StyleImage* loadedImage = loadPendingImage(static_cast<StylePendingImage*>(maskImage.image()));
 5675 reflection->setMask(NinePieceImage(loadedImage, maskImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), maskImage.horizontalRule(), maskImage.verticalRule()));
56525676 }
56535677 }
56545678 break;

@@void CSSStyleSelector::loadPendingImages()
56565680
56575681 case CSSPropertyWebkitMaskBoxImageSource: {
56585682 if (m_style->maskBoxImageSource() && m_style->maskBoxImageSource()->isPendingImage()) {
5659  CSSImageValue* imageValue = static_cast<StylePendingImage*>(m_style->maskBoxImageSource())->cssImageValue();
5660  m_style->setMaskBoxImageSource(imageValue->cachedImage(cachedResourceLoader));
 5683 StyleImage* loadedImage = loadPendingImage(static_cast<StylePendingImage*>(m_style->maskBoxImageSource()));
 5684 m_style->setMaskBoxImageSource(loadedImage);
56615685 }
56625686 break;
56635687 }

@@void CSSStyleSelector::loadPendingImages()
56655689 case CSSPropertyWebkitMaskImage: {
56665690 for (FillLayer* maskLayer = m_style->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {
56675691 if (maskLayer->image() && maskLayer->image()->isPendingImage()) {
5668  CSSImageValue* imageValue = static_cast<StylePendingImage*>(maskLayer->image())->cssImageValue();
5669  maskLayer->setImage(imageValue->cachedImage(cachedResourceLoader));
 5692 StyleImage* loadedImage = loadPendingImage(static_cast<StylePendingImage*>(maskLayer->image()));
 5693 maskLayer->setImage(loadedImage);
56705694 }
56715695 }
56725696 break;

Source/WebCore/css/CSSStyleSelector.h

@@class CSSPrimitiveValue;
4444class CSSProperty;
4545class CSSFontFace;
4646class CSSFontFaceRule;
 47class CSSImageGeneratorValue;
4748class CSSImageValue;
4849class CSSRegionStyleRule;
4950class CSSRuleList;

@@class RuleData;
6667class RuleSet;
6768class Settings;
6869class StyleImage;
 70class StylePendingImage;
6971class StyleSheet;
7072class StyleSheetList;
7173class StyledElement;

@@public:
280282
281283 StyleImage* styleImage(CSSPropertyID, CSSValue*);
282284 StyleImage* cachedOrPendingFromValue(CSSPropertyID, CSSImageValue*);
 285 StyleImage* generatedOrPendingFromValue(CSSPropertyID, CSSImageGeneratorValue*);
283286
284287 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
285288 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }

@@private:
327330 void applySVGProperty(int id, CSSValue*);
328331#endif
329332
 333 StyleImage* loadPendingImage(StylePendingImage*);
330334 void loadPendingImages();
331335
332336 struct MatchedStyleDeclaration {

Source/WebCore/platform/graphics/BitmapImage.h

@@public:
9898
9999class BitmapImage : public Image {
100100 friend class GeneratedImage;
 101 friend class CrossfadeGeneratedImage;
 102 friend class GeneratorGeneratedImage;
101103 friend class GraphicsContext;
102104public:
103105 static PassRefPtr<BitmapImage> create(NativeImagePtr nativeImage, ImageObserver* observer = 0)

Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "CrossfadeGeneratedImage.h"
 28
 29#include "CSSCrossfadeValue.h"
 30#include "FloatRect.h"
 31#include "GraphicsContext.h"
 32#include "ImageBuffer.h"
 33
 34using namespace std;
 35
 36namespace WebCore {
 37
 38CrossfadeGeneratedImage::CrossfadeGeneratedImage(CachedImage* fromImage, CachedImage* toImage, float percentage, ImageObserver* observer, const IntSize& size)
 39 : m_fromImage(fromImage)
 40 , m_toImage(toImage)
 41 , m_percentage(percentage)
 42 , m_observer(observer)
 43 , m_crossfadeSubimageObserver(adoptPtr(new CrossfadeSubimageObserverProxy(this)))
 44{
 45 m_size = size;
 46
 47 m_fromImage->addClient(m_crossfadeSubimageObserver.get());
 48 m_toImage->addClient(m_crossfadeSubimageObserver.get());
 49
 50 m_crossfadeSubimageObserver->setReady(true);
 51}
 52
 53CrossfadeGeneratedImage::~CrossfadeGeneratedImage()
 54{
 55 m_fromImage->removeClient(m_crossfadeSubimageObserver.get());
 56 m_toImage->removeClient(m_crossfadeSubimageObserver.get());
 57}
 58
 59void CrossfadeGeneratedImage::drawCrossfade(GraphicsContext* context)
 60{
 61 Image* fromImage = 0;
 62 Image* toImage = 0;
 63 IntSize fromImageSize, toImageSize, crossfadeImageSize;
 64 float inversePercentage = 1.0f - m_percentage;
 65
 66 fromImage = m_fromImage->image();
 67 fromImageSize = fromImage->size();
 68 toImage = m_toImage->image();
 69 toImageSize = toImage->size();
 70
 71 // Draw nothing if either of the images hasn't loaded yet.
 72 if (fromImage == Image::nullImage() || toImage == Image::nullImage())
 73 return;
 74
 75 crossfadeImageSize = IntSize(fromImageSize.width() * inversePercentage + toImageSize.width() * m_percentage,
 76 fromImageSize.height() * inversePercentage + toImageSize.height() * m_percentage);
 77
 78 GraphicsContextStateSaver stateSaver(*context);
 79
 80 // Draw the image we're fading away from.
 81 context->save();
 82 if (crossfadeImageSize != fromImageSize)
 83 context->scale(FloatSize(static_cast<float>(crossfadeImageSize.width()) / fromImageSize.width(),
 84 static_cast<float>(crossfadeImageSize.height()) / fromImageSize.height()));
 85 context->setAlpha(inversePercentage);
 86 context->drawImage(fromImage, ColorSpaceDeviceRGB, IntPoint());
 87 context->restore();
 88
 89 // Draw the image we're fading towards.
 90 context->save();
 91 if (crossfadeImageSize != toImageSize)
 92 context->scale(FloatSize(static_cast<float>(crossfadeImageSize.width()) / toImageSize.width(),
 93 static_cast<float>(crossfadeImageSize.height()) / toImageSize.height()));
 94 context->setCompositeOperation(CompositeSourceOver);
 95 context->setAlpha(m_percentage);
 96 context->drawImage(toImage, ColorSpaceDeviceRGB, IntPoint());
 97 context->restore();
 98}
 99
 100void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
 101{
 102 UNUSED_PARAM(compositeOp);
 103 UNUSED_PARAM(srcRect);
 104
 105 GraphicsContextStateSaver stateSaver(*context);
 106 context->clip(dstRect);
 107 context->translate(dstRect.x(), dstRect.y());
 108
 109 drawCrossfade(context);
 110}
 111
 112void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
 113{
 114 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(m_size);
 115 if (!imageBuffer)
 116 return;
 117
 118 // Fill with the cross-faded image.
 119 GraphicsContext* graphicsContext = imageBuffer->context();
 120 drawCrossfade(graphicsContext);
 121
 122 // Tile the image buffer into the context.
 123 imageBuffer->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
 124}
 125
 126void CrossfadeGeneratedImage::imageChanged(CachedImage* image, const IntRect* rect)
 127{
 128 UNUSED_PARAM(image);
 129 m_observer->changedInRect(this, *rect);
 130}
 131
 132}

Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef CrossfadeGeneratedImage_h
 27#define CrossfadeGeneratedImage_h
 28
 29#include "CachedImage.h"
 30#include "GeneratedImage.h"
 31#include "Image.h"
 32#include "ImageObserver.h"
 33#include "IntSize.h"
 34#include <wtf/RefPtr.h>
 35
 36namespace WebCore {
 37
 38class CSSCrossfadeValue;
 39class CrossfadeSubimageObserverProxy;
 40
 41class CrossfadeGeneratedImage : public GeneratedImage {
 42 friend class CrossfadeSubimageObserverProxy;
 43public:
 44 static PassRefPtr<CrossfadeGeneratedImage> create(CachedImage* fromImage, CachedImage* toImage, float percentage, ImageObserver* observer, const IntSize& size)
 45 {
 46 return adoptRef(new CrossfadeGeneratedImage(fromImage, toImage, percentage, observer, size));
 47 }
 48 virtual ~CrossfadeGeneratedImage();
 49
 50protected:
 51 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
 52 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
 53
 54 CrossfadeGeneratedImage(CachedImage* fromImage, CachedImage* toImage, float percentage, ImageObserver*, const IntSize&);
 55
 56 void imageChanged(CachedImage*, const IntRect* = 0);
 57
 58private:
 59 void drawCrossfade(GraphicsContext*);
 60
 61 CachedImage* m_fromImage;
 62 CachedImage* m_toImage;
 63 float m_percentage;
 64
 65 ImageObserver* m_observer;
 66 OwnPtr<CrossfadeSubimageObserverProxy> m_crossfadeSubimageObserver;
 67};
 68
 69class CrossfadeSubimageObserverProxy : public CachedImageClient {
 70public:
 71 CrossfadeSubimageObserverProxy(CrossfadeGeneratedImage* ownerValue)
 72 : m_ownerValue(ownerValue)
 73 , m_ready(false) { }
 74
 75 virtual ~CrossfadeSubimageObserverProxy() OVERRIDE { }
 76 virtual void imageChanged(CachedImage* image, const IntRect* rect = 0) OVERRIDE {
 77 if (m_ready)
 78 m_ownerValue->imageChanged(image, rect);
 79 }
 80 void setReady(bool ready) { m_ready = ready; }
 81private:
 82 CrossfadeGeneratedImage* m_ownerValue;
 83 bool m_ready;
 84};
 85
 86}
 87
 88#endif

Source/WebCore/platform/graphics/GeneratedImage.cpp

1 /*
2  * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "GeneratedImage.h"
28 
29 #include "FloatRect.h"
30 #include "GraphicsContext.h"
31 #include "ImageBuffer.h"
32 #include "Length.h"
33 
34 namespace WebCore {
35 
36 void GeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
37 {
38  GraphicsContextStateSaver stateSaver(*context);
39  context->setCompositeOperation(compositeOp);
40  context->clip(dstRect);
41  context->translate(dstRect.x(), dstRect.y());
42  if (dstRect.size() != srcRect.size())
43  context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
44  context->translate(-srcRect.x(), -srcRect.y());
45  context->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
46 }
47 
48 void GeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
49  const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
50 {
51  // Allow the generator to provide visually-equivalent tiling parameters for better performance.
52  IntSize adjustedSize = m_size;
53  FloatRect adjustedSrcRect = srcRect;
54  m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
55 
56  // Create a BitmapImage and call drawPattern on it.
57  OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(adjustedSize);
58  if (!imageBuffer)
59  return;
60 
61  // Fill with the gradient.
62  GraphicsContext* graphicsContext = imageBuffer->context();
63  graphicsContext->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator.get());
64 
65  // Tile the image buffer into the context.
66  imageBuffer->drawPattern(context, adjustedSrcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
67 }
68 
69 void GeneratedImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
70 {
71  Image::computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
72  intrinsicRatio = FloatSize();
73 }
74 
75 }

Source/WebCore/platform/graphics/GeneratedImage.h

@@namespace WebCore {
3636
3737class GeneratedImage : public Image {
3838public:
39  static PassRefPtr<GeneratedImage> create(PassRefPtr<Generator> generator, const IntSize& size)
40  {
41  return adoptRef(new GeneratedImage(generator, size));
42  }
43  virtual ~GeneratedImage() {}
44 
4539 virtual bool hasSingleSecurityOrigin() const { return true; }
4640
4741 virtual void setContainerSize(const IntSize& size) { m_size = size; }

@@public:
5751 virtual unsigned decodedSize() const { return 0; }
5852
5953protected:
60  virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
 54 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator) = 0;
6155 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
62  const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
63 
64  GeneratedImage(PassRefPtr<Generator> generator, const IntSize& size)
65  : m_generator(generator)
66  , m_size(size)
67  {
68  }
 56 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect) = 0;
 57
 58 GeneratedImage() { }
6959
70  RefPtr<Generator> m_generator;
7160 IntSize m_size;
7261};
7362

Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp

 1/*
 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "GeneratorGeneratedImage.h"
 28
 29#include "FloatRect.h"
 30#include "GraphicsContext.h"
 31#include "ImageBuffer.h"
 32#include "Length.h"
 33
 34namespace WebCore {
 35
 36void GeneratorGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
 37{
 38 GraphicsContextStateSaver stateSaver(*context);
 39 context->setCompositeOperation(compositeOp);
 40 context->clip(dstRect);
 41 context->translate(dstRect.x(), dstRect.y());
 42 if (dstRect.size() != srcRect.size())
 43 context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
 44 context->translate(-srcRect.x(), -srcRect.y());
 45 context->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
 46}
 47
 48void GeneratorGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
 49 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
 50{
 51 // Allow the generator to provide visually-equivalent tiling parameters for better performance.
 52 IntSize adjustedSize = m_size;
 53 FloatRect adjustedSrcRect = srcRect;
 54 m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
 55
 56 // Create a BitmapImage and call drawPattern on it.
 57 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(adjustedSize);
 58 if (!imageBuffer)
 59 return;
 60
 61 // Fill with the generated image.
 62 GraphicsContext* graphicsContext = imageBuffer->context();
 63 graphicsContext->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator.get());
 64
 65 // Tile the image buffer into the context.
 66 imageBuffer->drawPattern(context, adjustedSrcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
 67}
 68
 69void GeneratedImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
 70{
 71 Image::computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
 72 intrinsicRatio = FloatSize();
 73}
 74
 75}

Source/WebCore/platform/graphics/GeneratorGeneratedImage.h

 1/*
 2 * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef GeneratorGeneratedImage_h
 27#define GeneratorGeneratedImage_h
 28
 29#include "GeneratedImage.h"
 30#include "Generator.h"
 31#include "Image.h"
 32#include "IntSize.h"
 33#include <wtf/RefPtr.h>
 34
 35namespace WebCore {
 36
 37class GeneratorGeneratedImage : public GeneratedImage {
 38public:
 39 static PassRefPtr<GeneratorGeneratedImage> create(PassRefPtr<Generator> generator, const IntSize& size)
 40 {
 41 return adoptRef(new GeneratorGeneratedImage(generator, size));
 42 }
 43 virtual ~GeneratorGeneratedImage() { }
 44
 45protected:
 46 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
 47 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
 48 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
 49
 50 GeneratorGeneratedImage(PassRefPtr<Generator> generator, const IntSize& size)
 51 : m_generator(generator)
 52 {
 53 m_size = size;
 54 }
 55
 56 RefPtr<Generator> m_generator;
 57};
 58
 59}
 60
 61#endif

Source/WebCore/platform/graphics/Image.h

@@class ImageObserver;
7979
8080class Image : public RefCounted<Image> {
8181 friend class GeneratedImage;
 82 friend class CrossfadeGeneratedImage;
 83 friend class GeneratorGeneratedImage;
8284 friend class GraphicsContext;
8385
8486public:

Source/WebCore/platform/graphics/ImageBuffer.h

@@namespace WebCore {
126126
127127 friend class GraphicsContext;
128128 friend class GeneratedImage;
 129 friend class CrossfadeGeneratedImage;
 130 friend class GeneratorGeneratedImage;
129131
130132 private:
131133 ImageBufferData m_data;

Source/WebCore/rendering/style/StylePendingImage.h

2626#ifndef StylePendingImage_h
2727#define StylePendingImage_h
2828
 29#include "CSSImageGeneratorValue.h"
 30#include "CSSImageValue.h"
2931#include "Image.h"
3032#include "StyleImage.h"
3133

@@namespace WebCore {
3739
3840class StylePendingImage : public StyleImage {
3941public:
40  static PassRefPtr<StylePendingImage> create(CSSImageValue* value) { return adoptRef(new StylePendingImage(value)); }
 42 static PassRefPtr<StylePendingImage> create(CSSValue* value) { return adoptRef(new StylePendingImage(value)); }
4143
42  virtual WrappedImagePtr data() const { return m_value; }
 44 virtual WrappedImagePtr data() const { return static_cast<CSSImageValue*>(m_value); }
4345
4446 virtual PassRefPtr<CSSValue> cssValue() const { return m_value; }
45  CSSImageValue* cssImageValue() const { return m_value; }
 47 CSSImageValue* cssImageValue() const { return m_value->isImageValue() ? static_cast<CSSImageValue*>(m_value) : 0; }
 48 CSSImageGeneratorValue* cssImageGeneratorValue() const { return m_value->isImageGeneratorValue() ? static_cast<CSSImageGeneratorValue*>(m_value) : 0; }
4649
4750 virtual IntSize imageSize(const RenderObject*, float /*multiplier*/) const { return IntSize(); }
4851 virtual bool imageHasRelativeWidth() const { return false; }

@@public:
5962 }
6063
6164private:
62  StylePendingImage(CSSImageValue* value)
 65 StylePendingImage(CSSValue* value)
6366 : m_value(value)
6467 {
6568 m_isPendingImage = true;
6669 }
6770
68  CSSImageValue* m_value; // Not retained; it owns us.
 71 CSSValue* m_value; // Not retained; it owns us.
6972};
7073
7174}