[CSS Exclusions] Support outside-shape value on shape-inside
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Nov 2012 22:39:38 +0000 (22:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Nov 2012 22:39:38 +0000 (22:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=101108

Patch by Bear Travis <betravis@adobe.com> on 2012-11-20
Reviewed by Dirk Schulze.

Source/WebCore:

Shape-inside can potentially be: 'auto' | 'outside-shape' | <shape> | <url>.
Webkit currently supports the value 'auto' (null) and <shape> (a BasicShape*).
This patch adds support for the value 'outside-shape.' It adds the ExclusionShapeValue
class, which may be any of the three values: 'auto', 'outside-shape', or <shape>.
Bug 102738 tracks adding <url> support.

Modifying existing tests:
LayoutTests/fast/exclusions/parsing-wrap-shape-inside.html
LayoutTests/fast/exclusions/parsing-wrap-shape-outside.html

* GNUmakefile.list.am: Adding ExclusionShapeValue.h to the build files.
* Target.pri: Ditto.
* WebCore.gypi: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
(WebCore):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Modifying code to use
ExclusionShapeValue* rather than the previous BasicShape* values.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): Handle the outside-shape value.
* css/CSSValueKeywords.in: Adding outside-shape value.
* css/StyleBuilder.cpp:
(WebCore):
(WebCore::ApplyPropertyExclusionShape::setValue): Modify code to use
ExclusionShapeValue* rather than BasicShape*.
(WebCore::ApplyPropertyExclusionShape::applyValue): Ditto.
(WebCore::ApplyPropertyExclusionShape::createHandler): Ditto.
* page/animation/CSSPropertyAnimation.cpp: Ditto.
(WebCore::blendFunc): Ditto.
(WebCore::PropertyWrapperExclusionShape::PropertyWrapperExclusionShape): Ditto.
(WebCore::CSSPropertyAnimation::ensurePropertyMap): Ditto.
* rendering/ExclusionShapeInsideInfo.cpp:
(WebCore::ExclusionShapeInsideInfo::isExclusionShapeInsideInfoEnabledForRenderBlock):
Ditto.
(WebCore::ExclusionShapeInsideInfo::computeShapeSize): Ditto.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateExclusionShapeInsideInfoAfterStyleChange): Ditto.
* rendering/RenderBlock.h:
(RenderBlock):
* rendering/style/ExclusionShapeValue.h: Added.
(WebCore):
(ExclusionShapeValue): New type to represent the possible values of shape-inside
and shape-outside. Only shape-inside can have a value of 'outside-shape.'
(WebCore::ExclusionShapeValue::~ExclusionShapeValue):
(WebCore::ExclusionShapeValue::type): Returns the value type.
(WebCore::ExclusionShapeValue::shape): Returns <shape> value's BasicShape*.
(WebCore::ExclusionShapeValue::operator==):
(WebCore::ExclusionShapeInfo::createShapeValue):
(WebCore::ExclusionShapeInfo::createOutsideValue):
(WebCore::ExclusionShapeValue::ExclusionShapeValue):
* rendering/style/RenderStyle.h:
* rendering/style/StyleRareNonInheritedData.h:
(StyleRareNonInheritedData):

LayoutTests:

Adding tests to make sure the 'outside-shape' value properly applies only to the
shape-inside property.

* fast/exclusions/parsing-wrap-shape-inside-expected.txt:
* fast/exclusions/parsing-wrap-shape-outside-expected.txt:
* fast/exclusions/script-tests/parsing-wrap-shape-inside.js:
* fast/exclusions/script-tests/parsing-wrap-shape-outside.js:

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

22 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/exclusions/parsing-wrap-shape-inside-expected.txt
LayoutTests/fast/exclusions/parsing-wrap-shape-outside-expected.txt
LayoutTests/fast/exclusions/script-tests/parsing-wrap-shape-inside.js
LayoutTests/fast/exclusions/script-tests/parsing-wrap-shape-outside.js
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/StyleBuilder.cpp
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/style/ExclusionShapeValue.h [new file with mode: 0644]
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareNonInheritedData.h

index ed9f972..b425d8e 100644 (file)
@@ -1,3 +1,18 @@
+2012-11-20  Bear Travis  <betravis@adobe.com>
+
+        [CSS Exclusions] Support outside-shape value on shape-inside
+        https://bugs.webkit.org/show_bug.cgi?id=101108
+
+        Reviewed by Dirk Schulze.
+
+        Adding tests to make sure the 'outside-shape' value properly applies only to the
+        shape-inside property.
+
+        * fast/exclusions/parsing-wrap-shape-inside-expected.txt:
+        * fast/exclusions/parsing-wrap-shape-outside-expected.txt:
+        * fast/exclusions/script-tests/parsing-wrap-shape-inside.js:
+        * fast/exclusions/script-tests/parsing-wrap-shape-outside.js:
+
 2012-11-20  Jian Li  <jianli@chromium.org>
 
         Unreviewed. Updated chromium test expectations.
index 7c42ec5..bc8e674 100644 (file)
@@ -5,6 +5,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS testCSSText("auto") is "auto"
 PASS testComputedStyle("auto") is "auto"
+PASS testCSSText("outside-shape") is "outside-shape"
+PASS testComputedStyle("outside-shape") is "outside-shape"
 PASS testCSSText("rectangle(10px, 20px, 30px, 40px)") is "rectangle(10px, 20px, 30px, 40px)"
 PASS testComputedStyle("rectangle(10px, 20px, 30px, 40px)") is "rectangle(10px, 20px, 30px, 40px)"
 PASS testCSSText("rectangle(10px, 20px, 30px, 40px, 5px)") is "rectangle(10px, 20px, 30px, 40px, 5px)"
@@ -22,6 +24,7 @@ PASS testComputedStyle("polygon(evenodd, 10px 20px, 30px 40px, 40px 50px)") is "
 PASS testCSSText("polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)") is "polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)"
 PASS testComputedStyle("polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)") is "polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)"
 PASS testNotInherited("auto", "rectangle(10px, 20px, 30px, 40px)") is "parent: auto, child: rectangle(10px, 20px, 30px, 40px)"
+PASS testNotInherited("outside-shape", "rectangle(10px, 20px, 30px, 40px)") is "parent: outside-shape, child: rectangle(10px, 20px, 30px, 40px)"
 PASS testNotInherited("rectangle(10px, 20px, 30px, 40px)", "initial") is "parent: rectangle(10px, 20px, 30px, 40px), child: auto"
 PASS testNotInherited("rectangle(10px, 20px, 30px, 40px)", "") is "parent: rectangle(10px, 20px, 30px, 40px), child: auto"
 PASS testNotInherited("rectangle(10px, 20px, 30px, 40px)", "inherit") is "parent: rectangle(10px, 20px, 30px, 40px), child: rectangle(10px, 20px, 30px, 40px)"
index 301a5d9..6c5b55e 100644 (file)
@@ -31,6 +31,8 @@ PASS testCSSText("calc()") is ""
 PASS testComputedStyle("calc()") is "auto"
 PASS testCSSText("none") is ""
 PASS testComputedStyle("none") is "auto"
+PASS testCSSText("outside-shape") is ""
+PASS testComputedStyle("outside-shape") is "auto"
 PASS testCSSText("rectangle()") is ""
 PASS testComputedStyle("rectangle()") is "auto"
 PASS testCSSText("rectangle(10px)") is ""
index 9c5d301..43928fe 100644 (file)
@@ -58,6 +58,7 @@ function negative_test(value) {
 // positive tests
 
 test("auto", "auto");
+test("outside-shape", "outside-shape");
 test("rectangle(10px, 20px, 30px, 40px)", "rectangle(10px, 20px, 30px, 40px)");
 test("rectangle(10px, 20px, 30px, 40px, 5px)", "rectangle(10px, 20px, 30px, 40px, 5px)");
 test("rectangle(10px, 20px, 30px, 40px, 5px, 10px)", "rectangle(10px, 20px, 30px, 40px, 5px, 10px)");
@@ -71,6 +72,7 @@ test("polygon(evenodd, 10px 20px, 30px 40px, 40px 50px)", "polygon(evenodd, 10px
 test("polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)", "polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)");
 
 shouldBeEqualToString('testNotInherited("auto", "rectangle(10px, 20px, 30px, 40px)")', "parent: auto, child: rectangle(10px, 20px, 30px, 40px)");
+shouldBeEqualToString('testNotInherited("outside-shape", "rectangle(10px, 20px, 30px, 40px)")', "parent: outside-shape, child: rectangle(10px, 20px, 30px, 40px)");
 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "initial")', "parent: rectangle(10px, 20px, 30px, 40px), child: auto");
 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "")', "parent: rectangle(10px, 20px, 30px, 40px), child: auto");
 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "inherit")', "parent: rectangle(10px, 20px, 30px, 40px), child: rectangle(10px, 20px, 30px, 40px)");
index 5b1d67e..162cd6d 100644 (file)
@@ -81,6 +81,7 @@ shouldBeEqualToString('testNotInherited("auto", "inherit")', "parent: auto, chil
 
 negative_test("calc()");
 negative_test("none");
+negative_test("outside-shape");
 
 negative_test("rectangle()");
 negative_test("rectangle(10px)");
index f8fbc74..f851ded 100644 (file)
@@ -1,3 +1,65 @@
+2012-11-20  Bear Travis  <betravis@adobe.com>
+
+        [CSS Exclusions] Support outside-shape value on shape-inside
+        https://bugs.webkit.org/show_bug.cgi?id=101108
+
+        Reviewed by Dirk Schulze.
+
+        Shape-inside can potentially be: 'auto' | 'outside-shape' | <shape> | <url>.
+        Webkit currently supports the value 'auto' (null) and <shape> (a BasicShape*).
+        This patch adds support for the value 'outside-shape.' It adds the ExclusionShapeValue
+        class, which may be any of the three values: 'auto', 'outside-shape', or <shape>.
+        Bug 102738 tracks adding <url> support.
+
+        Modifying existing tests:
+        LayoutTests/fast/exclusions/parsing-wrap-shape-inside.html
+        LayoutTests/fast/exclusions/parsing-wrap-shape-outside.html
+
+        * GNUmakefile.list.am: Adding ExclusionShapeValue.h to the build files.
+        * Target.pri: Ditto.
+        * WebCore.gypi: Ditto.
+        * WebCore.vcproj/WebCore.vcproj: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        (WebCore):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Modifying code to use
+        ExclusionShapeValue* rather than the previous BasicShape* values.
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue): Handle the outside-shape value.
+        * css/CSSValueKeywords.in: Adding outside-shape value.
+        * css/StyleBuilder.cpp:
+        (WebCore):
+        (WebCore::ApplyPropertyExclusionShape::setValue): Modify code to use
+        ExclusionShapeValue* rather than BasicShape*.
+        (WebCore::ApplyPropertyExclusionShape::applyValue): Ditto.
+        (WebCore::ApplyPropertyExclusionShape::createHandler): Ditto.
+        * page/animation/CSSPropertyAnimation.cpp: Ditto.
+        (WebCore::blendFunc): Ditto.
+        (WebCore::PropertyWrapperExclusionShape::PropertyWrapperExclusionShape): Ditto.
+        (WebCore::CSSPropertyAnimation::ensurePropertyMap): Ditto.
+        * rendering/ExclusionShapeInsideInfo.cpp:
+        (WebCore::ExclusionShapeInsideInfo::isExclusionShapeInsideInfoEnabledForRenderBlock):
+        Ditto.
+        (WebCore::ExclusionShapeInsideInfo::computeShapeSize): Ditto.
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::updateExclusionShapeInsideInfoAfterStyleChange): Ditto.
+        * rendering/RenderBlock.h:
+        (RenderBlock):
+        * rendering/style/ExclusionShapeValue.h: Added.
+        (WebCore):
+        (ExclusionShapeValue): New type to represent the possible values of shape-inside
+        and shape-outside. Only shape-inside can have a value of 'outside-shape.'
+        (WebCore::ExclusionShapeValue::~ExclusionShapeValue):
+        (WebCore::ExclusionShapeValue::type): Returns the value type.
+        (WebCore::ExclusionShapeValue::shape): Returns <shape> value's BasicShape*.
+        (WebCore::ExclusionShapeValue::operator==):
+        (WebCore::ExclusionShapeInfo::createShapeValue):
+        (WebCore::ExclusionShapeInfo::createOutsideValue):
+        (WebCore::ExclusionShapeValue::ExclusionShapeValue):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/StyleRareNonInheritedData.h:
+        (StyleRareNonInheritedData):
+
 2012-11-20  Alpha Lam  <hclam@chromium.org>
 
         [chromium] Make lazy image decoding thread-safe
index fea7efc..1e7ac1d 100644 (file)
@@ -4437,6 +4437,7 @@ webcore_sources += \
        Source/WebCore/rendering/style/CursorData.h \
        Source/WebCore/rendering/style/CursorList.h \
        Source/WebCore/rendering/style/DataRef.h \
+       Source/WebCore/rendering/style/ExclusionShapeValue.h \
        Source/WebCore/rendering/style/FillLayer.cpp \
        Source/WebCore/rendering/style/FillLayer.h \
        Source/WebCore/rendering/style/GridPosition.h \
index de10e1c..f669180 100644 (file)
@@ -2446,6 +2446,7 @@ HEADERS += \
     rendering/style/CounterDirectives.h \
     rendering/style/CursorData.h \
     rendering/style/CursorList.h \
+    rendering/style/ExclusionShapeValue.h \
     rendering/style/FillLayer.h \
     rendering/style/KeyframeList.h \
     rendering/style/NinePieceImage.h \
index 4029ee8..a8b3fed 100644 (file)
             'rendering/style/CursorData.h',
             'rendering/style/CursorList.h',
             'rendering/style/DataRef.h',
+            'rendering/style/ExclusionShapeValue.h',
             'rendering/style/FillLayer.h',
             'rendering/style/GridPosition.h',
             'rendering/style/LineClampValue.h',
index d018789..e004840 100755 (executable)
                                        >
                                </File>
                                <File
+                                   RelativePath="..\rendering\style\ExclusionShapeValue.h"
+                                   >
+                               </File>
+                               <File
                                        RelativePath="..\rendering\style\FillLayer.cpp"
                                        >
                                        <FileConfiguration
index 0aa125c..c7bffea 100644 (file)
                FD06DFA5134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD06DFA3134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp */; };
                FD06DFA6134A4DEF006F5D7D /* DefaultAudioDestinationNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD06DFA4134A4DEF006F5D7D /* DefaultAudioDestinationNode.h */; };
                FD1660A513787C6D001FFA7B /* DenormalDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = FD1660A413787C6D001FFA7B /* DenormalDisabler.h */; };
+               FD1AF1501656F15100C6D4F7 /* ExclusionShapeValue.h in Headers */ = {isa = PBXBuildFile; fileRef = FD1AF14E1656F12100C6D4F7 /* ExclusionShapeValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FD23A12513F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD23A12313F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp */; };
                FD23A12613F5FA5900F67001 /* JSMediaElementAudioSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD23A12413F5FA5900F67001 /* JSMediaElementAudioSourceNode.h */; };
                FD2DBF1212B048A300ED98C6 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD2DBF0E12B048A300ED98C6 /* Accelerate.framework */; };
                FD06DFA3134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DefaultAudioDestinationNode.cpp; sourceTree = "<group>"; };
                FD06DFA4134A4DEF006F5D7D /* DefaultAudioDestinationNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultAudioDestinationNode.h; sourceTree = "<group>"; };
                FD1660A413787C6D001FFA7B /* DenormalDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DenormalDisabler.h; sourceTree = "<group>"; };
+               FD1AF14E1656F12100C6D4F7 /* ExclusionShapeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExclusionShapeValue.h; path = style/ExclusionShapeValue.h; sourceTree = "<group>"; };
                FD23A12313F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaElementAudioSourceNode.cpp; sourceTree = "<group>"; };
                FD23A12413F5FA5900F67001 /* JSMediaElementAudioSourceNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaElementAudioSourceNode.h; sourceTree = "<group>"; };
                FD2DBF0E12B048A300ED98C6 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = /System/Library/Frameworks/Accelerate.framework; sourceTree = "<absolute>"; };
                                BC2272A10E82E87C00E7F975 /* CursorData.h */,
                                BC2272AC0E82E8F300E7F975 /* CursorList.h */,
                                BC22746E0E83664500E7F975 /* DataRef.h */,
+                               FD1AF14E1656F12100C6D4F7 /* ExclusionShapeValue.h */,
                                BC5EB69C0E81DAEB00B25965 /* FillLayer.cpp */,
                                BC5EB69D0E81DAEB00B25965 /* FillLayer.h */,
                                A12705C21656BD6500C2E27C /* GridPosition.h */,
                        isa = PBXHeadersBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               FD1AF1501656F15100C6D4F7 /* ExclusionShapeValue.h in Headers */,
                                BC7FA6210D1F0CBD00DB22A9 /* DynamicNodeList.h in Headers */,
                                A81369DA097374F600D74463 /* HTMLOptionsCollection.h in Headers */,
                                A81369D8097374F600D74463 /* HTMLSelectElement.h in Headers */,
index f30d917..b127aa9 100644 (file)
 #include "WebKitFontFamilyNames.h"
 #include <wtf/text/StringBuilder.h>
 
+#if ENABLE(CSS_EXCLUSIONS)
+#include "ExclusionShapeValue.h"
+#endif
+
 #if ENABLE(CSS_SHADERS)
 #include "CustomFilterArrayParameter.h"
 #include "CustomFilterNumberParameter.h"
@@ -2504,11 +2508,15 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
         case CSSPropertyWebkitShapeInside:
             if (!style->shapeInside())
                 return cssValuePool().createIdentifierValue(CSSValueAuto);
-            return valueForBasicShape(style->shapeInside());
+            else if (style->shapeInside()->type() == ExclusionShapeValue::OUTSIDE)
+                return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
+            ASSERT(style->shapeInside()->type() == ExclusionShapeValue::SHAPE);
+            return valueForBasicShape(style->shapeInside()->shape());
         case CSSPropertyWebkitShapeOutside:
             if (!style->shapeOutside())
                 return cssValuePool().createIdentifierValue(CSSValueAuto);
-            return valueForBasicShape(style->shapeOutside());
+            ASSERT(style->shapeOutside()->type() == ExclusionShapeValue::SHAPE);
+            return valueForBasicShape(style->shapeOutside()->shape());
         case CSSPropertyWebkitWrapThrough:
             return cssValuePool().createValue(style->wrapThrough());
 #endif
index 9b2f708..d58c57b 100644 (file)
@@ -2735,6 +2735,8 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
             return false;
         if (id == CSSValueAuto)
             validPrimitive = true;
+        else if (propId == CSSPropertyWebkitShapeInside && id == CSSValueOutsideShape)
+            validPrimitive = true;
         else if (value->unit == CSSParserValue::Function)
             return parseBasicShape(propId, important);
         break;
index 4b9cc6e..10ba6ea 100644 (file)
@@ -914,9 +914,11 @@ off
 optimizeQuality
 -webkit-optimize-contrast
 
-// -webkit-wrap-shape
+// -webkit-shape-inside
+// -webkit-shape-outside
 nonzero
 evenodd
+outside-shape
 
 // -webkit-region-overflow
 // auto
index ed88640..968b96f 100644 (file)
 #include <wtf/StdLibExtras.h>
 #include <wtf/UnusedParam.h>
 
+#if ENABLE(CSS_EXCLUSIONS)
+#include "ExclusionShapeValue.h"
+#endif
+
 using namespace std;
 
 namespace WebCore {
@@ -1716,25 +1720,28 @@ public:
 };
 
 #if ENABLE(CSS_EXCLUSIONS)
-template <BasicShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<BasicShape>), BasicShape* (*initialFunction)()>
+template <ExclusionShapeValue* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<ExclusionShapeValue>), ExclusionShapeValue* (*initialFunction)()>
 class ApplyPropertyExclusionShape {
 public:
-    static void setValue(RenderStyle* style, PassRefPtr<BasicShape> value) { (style->*setterFunction)(value); }
+    static void setValue(RenderStyle* style, PassRefPtr<ExclusionShapeValue> value) { (style->*setterFunction)(value); }
     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
     {
         if (value->isPrimitiveValue()) {
             CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
             if (primitiveValue->getIdent() == CSSValueAuto)
                 setValue(styleResolver->style(), 0);
+            // FIXME Bug 102571: Layout for the value 'outside-shape' is not yet implemented
+            else if (primitiveValue->getIdent() == CSSValueOutsideShape)
+                setValue(styleResolver->style(), ExclusionShapeValue::createOutsideValue());
             else if (primitiveValue->isShape()) {
-                RefPtr<BasicShape> shape = basicShapeForValue(styleResolver, primitiveValue->getShapeValue());
+                RefPtr<ExclusionShapeValue> shape = ExclusionShapeValue::createShapeValue(basicShapeForValue(styleResolver, primitiveValue->getShapeValue()));
                 setValue(styleResolver->style(), shape.release());
             }
         }
     }
     static PropertyHandler createHandler()
     {
-        PropertyHandler handler = ApplyPropertyDefaultBase<BasicShape*, getterFunction, PassRefPtr<BasicShape>, setterFunction, BasicShape*, initialFunction>::createHandler();
+        PropertyHandler handler = ApplyPropertyDefaultBase<ExclusionShapeValue*, getterFunction, PassRefPtr<ExclusionShapeValue>, setterFunction, ExclusionShapeValue*, initialFunction>::createHandler();
         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
     }
 };
index b763b56..2504da4 100644 (file)
@@ -143,12 +143,19 @@ static inline PassRefPtr<ClipPathOperation> blendFunc(const AnimationBase*, Clip
 }
 
 #if ENABLE(CSS_EXCLUSIONS)
-static inline PassRefPtr<BasicShape> blendFunc(const AnimationBase*, BasicShape* from, BasicShape* to, double progress)
+static inline PassRefPtr<ExclusionShapeValue> blendFunc(const AnimationBase*, ExclusionShapeValue* from, ExclusionShapeValue* to, double progress)
 {
-    if (!from->canBlend(to))
+    // FIXME Bug 102723: Shape-inside should be able to animate a value of 'outside-shape' when shape-outside is set to a BasicShape
+    if (from->type() != ExclusionShapeValue::SHAPE || to->type() != ExclusionShapeValue::SHAPE)
         return to;
 
-    return to->blend(from, progress);
+    const BasicShape* fromShape = from->shape();
+    const BasicShape* toShape = to->shape();
+
+    if (!fromShape->canBlend(toShape))
+        return to;
+
+    return ExclusionShapeValue::createShapeValue(toShape->blend(fromShape, progress));
 }
 #endif
 
@@ -404,10 +411,10 @@ public:
 };
 
 #if ENABLE(CSS_EXCLUSIONS)
-class PropertyWrapperBasicShape : public RefCountedPropertyWrapper<BasicShape> {
+class PropertyWrapperExclusionShape : public RefCountedPropertyWrapper<ExclusionShapeValue> {
 public:
-    PropertyWrapperBasicShape(CSSPropertyID prop, BasicShape* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(PassRefPtr<BasicShape>))
-        : RefCountedPropertyWrapper<BasicShape>(prop, getter, setter)
+    PropertyWrapperExclusionShape(CSSPropertyID prop, ExclusionShapeValue* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(PassRefPtr<ExclusionShapeValue>))
+        : RefCountedPropertyWrapper<ExclusionShapeValue>(prop, getter, setter)
     {
     }
 };
@@ -1162,7 +1169,7 @@ void CSSPropertyAnimation::ensurePropertyMap()
     gPropertyWrappers->append(new PropertyWrapperClipPath(CSSPropertyWebkitClipPath, &RenderStyle::clipPath, &RenderStyle::setClipPath));
 
 #if ENABLE(CSS_EXCLUSIONS)
-    gPropertyWrappers->append(new PropertyWrapperBasicShape(CSSPropertyWebkitShapeInside, &RenderStyle::shapeInside, &RenderStyle::setShapeInside));
+    gPropertyWrappers->append(new PropertyWrapperExclusionShape(CSSPropertyWebkitShapeInside, &RenderStyle::shapeInside, &RenderStyle::setShapeInside));
 #endif
 
     gPropertyWrappers->append(new PropertyWrapperVisitedAffectedColor(CSSPropertyWebkitColumnRuleColor, MaybeInvalidColor, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor, &RenderStyle::visitedLinkColumnRuleColor, &RenderStyle::setVisitedLinkColumnRuleColor));
index b7830f1..934e3f2 100644 (file)
@@ -72,7 +72,8 @@ ExclusionShapeInsideInfo* ExclusionShapeInsideInfo::exclusionShapeInsideInfoForR
 bool ExclusionShapeInsideInfo::isExclusionShapeInsideInfoEnabledForRenderBlock(const RenderBlock* block)
 {
     // FIXME: Bug 89707: Enable shape inside for non-rectangular shapes
-    BasicShape* shape = block->style()->shapeInside();
+    ExclusionShapeValue* shapeValue = block->style()->shapeInside();
+    BasicShape* shape = (shapeValue && shapeValue->type() == ExclusionShapeValue::SHAPE) ? shapeValue->shape() : 0;
     return shape && (shape->type() == BasicShape::BASIC_SHAPE_RECTANGLE || shape->type() == BasicShape::BASIC_SHAPE_POLYGON);
 }
 
@@ -93,7 +94,9 @@ void ExclusionShapeInsideInfo::computeShapeSize(LayoutUnit logicalWidth, LayoutU
     m_logicalHeight = logicalHeight;
 
     // FIXME: Bug 89993: The wrap shape may come from the parent object
-    BasicShape* shape = m_block->style()->shapeInside();
+    ExclusionShapeValue* shapeValue = m_block->style()->shapeInside();
+    BasicShape* shape = (shapeValue && shapeValue->type() == ExclusionShapeValue::SHAPE) ? shapeValue->shape() : 0;
+
     ASSERT(shape);
 
     m_shape = ExclusionShape::createExclusionShape(shape, logicalWidth, logicalHeight, m_block->style()->writingMode());
index 4a5e893..84f7b3c 100644 (file)
@@ -1398,7 +1398,7 @@ void RenderBlock::layout()
 }
 
 #if ENABLE(CSS_EXCLUSIONS)
-void RenderBlock::updateExclusionShapeInsideInfoAfterStyleChange(const BasicShape* shapeInside, const BasicShape* oldShapeInside)
+void RenderBlock::updateExclusionShapeInsideInfoAfterStyleChange(const ExclusionShapeValue* shapeInside, const ExclusionShapeValue* oldShapeInside)
 {
     // FIXME: A future optimization would do a deep comparison for equality.
     if (shapeInside == oldShapeInside)
index 55a001f..a5566ed 100644 (file)
@@ -36,6 +36,7 @@
 
 #if ENABLE(CSS_EXCLUSIONS)
 #include "ExclusionShapeInsideInfo.h"
+#include "ExclusionShapeValue.h"
 #endif
 
 namespace WebCore {
@@ -521,7 +522,7 @@ protected:
 private:
 #if ENABLE(CSS_EXCLUSIONS)
     void computeExclusionShapeSize();
-    void updateExclusionShapeInsideInfoAfterStyleChange(const BasicShape*, const BasicShape* oldWrapShape);
+    void updateExclusionShapeInsideInfoAfterStyleChange(const ExclusionShapeValue*, const ExclusionShapeValue* oldExclusionShape);
 #endif
     virtual RenderObjectChildList* virtualChildren() { return children(); }
     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
diff --git a/Source/WebCore/rendering/style/ExclusionShapeValue.h b/Source/WebCore/rendering/style/ExclusionShapeValue.h
new file mode 100644 (file)
index 0000000..5a533af
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials
+ *    provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ExclusionShapeValue_h
+#define ExclusionShapeValue_h
+
+#include "BasicShapes.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class ExclusionShapeValue : public RefCounted<ExclusionShapeValue> {
+public:
+    enum ExclusionShapeValueType {
+        // The AUTO value is defined by a null ExclusionShapeValue*
+        SHAPE,
+        OUTSIDE
+    };
+
+    static PassRefPtr<ExclusionShapeValue> createShapeValue(PassRefPtr<BasicShape> shape)
+    {
+        return adoptRef(new ExclusionShapeValue(shape));
+    }
+
+    static PassRefPtr<ExclusionShapeValue> createOutsideValue()
+    {
+        return adoptRef(new ExclusionShapeValue(OUTSIDE));
+    }
+
+    ExclusionShapeValueType type() const { return m_type; }
+    BasicShape* shape() const { return m_shape.get(); }
+    bool operator==(const ExclusionShapeValue& other) const { return type() == other.type(); }
+
+private:
+    ExclusionShapeValue(PassRefPtr<BasicShape> shape) : m_type(SHAPE), m_shape(shape) { }
+    ExclusionShapeValue(ExclusionShapeValueType type) : m_type(type) { }
+    ExclusionShapeValueType m_type;
+    RefPtr<BasicShape> m_shape;
+};
+
+}
+
+#endif
index 40c32dd..31996fa 100644 (file)
@@ -34,6 +34,7 @@
 #include "ColorSpace.h"
 #include "CounterDirectives.h"
 #include "DataRef.h"
+#include "ExclusionShapeValue.h"
 #include "FontBaseline.h"
 #include "FontDescription.h"
 #include "GraphicsTypes.h"
@@ -1455,22 +1456,24 @@ public:
     void setKerning(SVGLength k) { accessSVGStyle()->setKerning(k); }
 #endif
 
-    void setShapeInside(PassRefPtr<BasicShape> shape)
+    void setShapeInside(PassRefPtr<ExclusionShapeValue> value)
     {
-        if (rareNonInheritedData->m_shapeInside != shape)
-            rareNonInheritedData.access()->m_shapeInside = shape;
+        if (rareNonInheritedData->m_shapeInside == value)
+            return;
+        rareNonInheritedData.access()->m_shapeInside = value;
     }
-    BasicShape* shapeInside() const { return rareNonInheritedData->m_shapeInside.get(); }
+    ExclusionShapeValue* shapeInside() const { return rareNonInheritedData->m_shapeInside.get(); }
 
-    void setShapeOutside(PassRefPtr<BasicShape> shape)
+    void setShapeOutside(PassRefPtr<ExclusionShapeValue> value)
     {
-        if (rareNonInheritedData->m_shapeOutside != shape)
-            rareNonInheritedData.access()->m_shapeOutside = shape;
+        if (rareNonInheritedData->m_shapeOutside == value)
+            return;
+        rareNonInheritedData.access()->m_shapeOutside = value;
     }
-    BasicShape* shapeOutside() const { return rareNonInheritedData->m_shapeOutside.get(); }
+    ExclusionShapeValue* shapeOutside() const { return rareNonInheritedData->m_shapeOutside.get(); }
 
-    static BasicShape* initialShapeInside() { return 0; }
-    static BasicShape* initialShapeOutside() { return 0; }
+    static ExclusionShapeValue* initialShapeInside() { return 0; }
+    static ExclusionShapeValue* initialShapeOutside() { return 0; }
 
     void setClipPath(PassRefPtr<ClipPathOperation> operation)
     {
index 4186bb1..c4ac0f6 100644 (file)
@@ -30,6 +30,7 @@
 #include "CounterDirectives.h"
 #include "CursorData.h"
 #include "DataRef.h"
+#include "ExclusionShapeValue.h"
 #include "FillLayer.h"
 #include "LineClampValue.h"
 #include "NinePieceImage.h"
@@ -137,8 +138,8 @@ public:
 
     LengthSize m_pageSize;
 
-    RefPtr<BasicShape> m_shapeInside;
-    RefPtr<BasicShape> m_shapeOutside;
+    RefPtr<ExclusionShapeValue> m_shapeInside;
+    RefPtr<ExclusionShapeValue> m_shapeOutside;
     Length m_shapeMargin;
     Length m_shapePadding;