Resolve CSS Exclusions shapeInside, shapeOutside properties to Length based WrapShape...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2012 22:48:41 +0000 (22:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2012 22:48:41 +0000 (22:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89670

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

Source/WebCore:

Layout of CSS Exclusions requires length based WrapShape classes,
rather than the existing CSSValue based CSSWrapShape classes. This
patch adds length based WrapShape analogs to the CSSWrapShapes, and
modifies RenderStyle to use a WrapShape instead of a CSSWrapShape.
The translation between WrapShape and CSSWrapShape classes
is handled by helper functions in the new WrapShapeFunctions files.
StyleBuilder resolves CSSWrapShapes to WrapShapes for layout use.
CSSComputedStyleDeclaration translates WrapShapes to CSSWrapShapes
for style use.

There are existing tests that cover the style serialization / resolution
in fast/exclusions/parsing-wrap-shape-inside.html and
fast/exclusions/parsing/wrap-shape-outside.html

Test: fast/exclusions/parsing-wrap-shape-lengths.html

* CMakeLists.txt: Build system changes for adding new files
* GNUmakefile.list.am: Ditto
* Target.pri: Ditto
* WebCore.gypi: Ditto
* WebCore.vcproj/WebCore.vcproj: Ditto
* WebCore.xcodeproj/project.pbxproj: Ditto
* css/CSSComputedStyleDeclaration.cpp: Translate WrapShapes back to CSSWrapShapes
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSWrapShapes.h: Mostly changing functions to be const
(WebCore::CSSWrapShapeRectangle::type):
(WebCore::CSSWrapShapeCircle::type):
(WebCore::CSSWrapShapeEllipse::type):
(WebCore::CSSWrapShapePolygon::getXAt):
(WebCore::CSSWrapShapePolygon::getYAt):
(WebCore::CSSWrapShapePolygon::values):
(WebCore::CSSWrapShapePolygon::type):
* css/StyleBuilder.cpp: Resolve CSSWrapShapes to WrapShapes
(WebCore):
(WebCore::ApplyPropertyWrapShape::setValue):
(WebCore::ApplyPropertyWrapShape::applyValue):
(WebCore::ApplyPropertyWrapShape::createHandler):
* css/WrapShapeFunctions.cpp: Added.
(WebCore):
(WebCore::valueForWrapShape):
(WebCore::convertToLength):
(WebCore::wrapShapeForValue):
* css/WrapShapeFunctions.h: Added.
(WebCore):
* rendering/style/RenderStyle.h:
* rendering/style/StyleRareNonInheritedData.h:
(StyleRareNonInheritedData):
* rendering/style/WrapShapes.h: Added.
(WebCore):
(WrapShape):
(WebCore::WrapShape::~WrapShape):
(WebCore::WrapShape::WrapShape):
(WrapShapeRectangle):
(WebCore::WrapShapeRectangle::create):
(WebCore::WrapShapeRectangle::left):
(WebCore::WrapShapeRectangle::top):
(WebCore::WrapShapeRectangle::width):
(WebCore::WrapShapeRectangle::height):
(WebCore::WrapShapeRectangle::cornerRadiusX):
(WebCore::WrapShapeRectangle::cornerRadiusY):
(WebCore::WrapShapeRectangle::setLeft):
(WebCore::WrapShapeRectangle::setTop):
(WebCore::WrapShapeRectangle::setWidth):
(WebCore::WrapShapeRectangle::setHeight):
(WebCore::WrapShapeRectangle::setCornerRadiusX):
(WebCore::WrapShapeRectangle::setCornerRadiusY):
(WebCore::WrapShapeRectangle::type):
(WebCore::WrapShapeRectangle::WrapShapeRectangle):
(WrapShapeCircle):
(WebCore::WrapShapeCircle::create):
(WebCore::WrapShapeCircle::left):
(WebCore::WrapShapeCircle::top):
(WebCore::WrapShapeCircle::radius):
(WebCore::WrapShapeCircle::setLeft):
(WebCore::WrapShapeCircle::setTop):
(WebCore::WrapShapeCircle::setRadius):
(WebCore::WrapShapeCircle::type):
(WebCore::WrapShapeCircle::WrapShapeCircle):
(WrapShapeEllipse):
(WebCore::WrapShapeEllipse::create):
(WebCore::WrapShapeEllipse::top):
(WebCore::WrapShapeEllipse::left):
(WebCore::WrapShapeEllipse::radiusX):
(WebCore::WrapShapeEllipse::radiusY):
(WebCore::WrapShapeEllipse::setTop):
(WebCore::WrapShapeEllipse::setLeft):
(WebCore::WrapShapeEllipse::setRadiusX):
(WebCore::WrapShapeEllipse::setRadiusY):
(WebCore::WrapShapeEllipse::type):
(WebCore::WrapShapeEllipse::WrapShapeEllipse):
(WrapShapePolygon):
(WebCore::WrapShapePolygon::create):
(WebCore::WrapShapePolygon::windRule):
(WebCore::WrapShapePolygon::values):
(WebCore::WrapShapePolygon::getXAt):
(WebCore::WrapShapePolygon::getYAt):
(WebCore::WrapShapePolygon::setWindRule):
(WebCore::WrapShapePolygon::appendPoint):
(WebCore::WrapShapePolygon::type):
(WebCore::WrapShapePolygon::WrapShapePolygon):

LayoutTests:

Test that wrap shapes accept different length types
Wrap shape parsing and serialization is tested by parsing-wrap-shape-inside/outside

* fast/exclusions/parsing-wrap-shape-lengths-expected.txt: Added.
* fast/exclusions/parsing-wrap-shape-lengths.html: Added.

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/exclusions/parsing-wrap-shape-lengths-expected.txt [new file with mode: 0644]
LayoutTests/fast/exclusions/parsing-wrap-shape-lengths.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
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/CSSWrapShapes.h
Source/WebCore/css/StyleBuilder.cpp
Source/WebCore/css/WrapShapeFunctions.cpp [new file with mode: 0644]
Source/WebCore/css/WrapShapeFunctions.h [new file with mode: 0644]
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareNonInheritedData.h
Source/WebCore/rendering/style/WrapShapes.h [new file with mode: 0644]

index 1016ab5fc6b44b748bfc86c008dc3010f469fab7..7615b6dd021396323d52af79213426631124838e 100644 (file)
@@ -1,3 +1,16 @@
+2012-07-16  Bear Travis  <betravis@adobe.com>
+
+        Resolve CSS Exclusions shapeInside, shapeOutside properties to Length based WrapShape classes
+        https://bugs.webkit.org/show_bug.cgi?id=89670
+
+        Reviewed by Dirk Schulze.
+
+        Test that wrap shapes accept different length types
+        Wrap shape parsing and serialization is tested by parsing-wrap-shape-inside/outside
+
+        * fast/exclusions/parsing-wrap-shape-lengths-expected.txt: Added.
+        * fast/exclusions/parsing-wrap-shape-lengths.html: Added.
+
 2012-07-16  Ojan Vafai  <ojan@chromium.org>
 
         [chromium] Assign some bug numbers to failing tests.
diff --git a/LayoutTests/fast/exclusions/parsing-wrap-shape-lengths-expected.txt b/LayoutTests/fast/exclusions/parsing-wrap-shape-lengths-expected.txt
new file mode 100644 (file)
index 0000000..3cf1928
--- /dev/null
@@ -0,0 +1,35 @@
+Test that exclusion shapes accept different length units
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS innerStyle("-webkit-shape-inside", "circle(0, 0, 0)") is "circle(0px, 0px, 0px)"
+PASS innerStyle("-webkit-shape-inside", "circle(-1px, +1px, 1px)") is "circle(-1px, 1px, 1px)"
+PASS innerStyle("-webkit-shape-inside", "circle(-1.5px, +1.5px, 1.5px)") is "circle(-1.5px, 1.5px, 1.5px)"
+PASS innerStyle("-webkit-shape-inside", "circle(-.5px, +.5px, .5px)") is "circle(-0.5px, 0.5px, 0.5px)"
+PASS innerStyle("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)") is "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)"
+PASS innerStyle("-webkit-shape-inside", "circle(-1em, +1em, 1em)") is "circle(-1em, 1em, 1em)"
+PASS innerStyle("-webkit-shape-inside", "circle(-1.5em, +1.5em, 1.5em)") is "circle(-1.5em, 1.5em, 1.5em)"
+PASS innerStyle("-webkit-shape-inside", "circle(-.5em, +.5em, .5em)") is "circle(-0.5em, 0.5em, 0.5em)"
+PASS innerStyle("-webkit-shape-inside", "circle(1ex, 1ex, 1ex)") is "circle(1ex, 1ex, 1ex)"
+PASS innerStyle("-webkit-shape-inside", "circle(1rem, 1rem, 1rem)") is "circle(1rem, 1rem, 1rem)"
+PASS computedStyle("-webkit-shape-inside", "circle(.5em, 1em, 1.5em)") is "circle(4px, 8px, 12px)"
+PASS computedStyle("-webkit-shape-inside", "circle(.5rem, 1rem, 1.5rem)") is "circle(8px, 16px, 24px)"
+PASS innerStyle("-webkit-shape-inside", "circle(1vw, 1vw, 1vw)") is "circle(1vw, 1vw, 1vw)"
+PASS innerStyle("-webkit-shape-inside", "circle(1vh, 1vh, 1vh)") is "circle(1vh, 1vh, 1vh)"
+PASS innerStyle("-webkit-shape-inside", "circle(1vmin, 1vmin, 1vmin)") is "circle(1vmin, 1vmin, 1vmin)"
+PASS computedStyle("-webkit-shape-inside", "circle(.5vw, 1vw, 1.5vw)") is "circle(0.5vw, 1vw, 1.5vw)"
+PASS computedStyle("-webkit-shape-inside", "circle(.5vh, 1vh, 1.5vh)") is "circle(0.5vh, 1vh, 1.5vh)"
+PASS computedStyle("-webkit-shape-inside", "circle(.5vmin, 1vmin, 1.5vmin)") is "circle(0.5vmin, 1vmin, 1.5vmin)"
+PASS innerStyle("-webkit-shape-inside", "circle(1px, 1px, 1)") is null
+PASS computedStyle("-webkit-shape-inside", "circle(1px, 1px, 1)") is "auto"
+PASS innerStyle("-webkit-shape-inside", "circle(1px, 1px, px)") is null
+PASS computedStyle("-webkit-shape-inside", "circle(1px, 1px, px)") is "auto"
+PASS innerStyle("-webkit-shape-inside", "circle(1px, 1px, 1p)") is null
+PASS computedStyle("-webkit-shape-inside", "circle(1px, 1px, 1p)") is "auto"
+PASS innerStyle("-webkit-shape-inside", "circle(1px, 1px, calc())") is null
+PASS computedStyle("-webkit-shape-inside", "circle(1px, 1px, calc())") is "auto"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/exclusions/parsing-wrap-shape-lengths.html b/LayoutTests/fast/exclusions/parsing-wrap-shape-lengths.html
new file mode 100644 (file)
index 0000000..c69d587
--- /dev/null
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<html>
+<style>
+* { font-size: 16px; }
+div { font-size: 8px; }
+</style>
+<body>
+<script src="../js/resources/js-test-pre.js"></script>
+<script>
+description('Test that exclusion shapes accept different length units');
+
+if (window.internals)
+    window.internals.settings.setCSSExclusionsEnabled(true);
+
+function computedStyle(property, value) {
+    var div = document.createElement("div");
+    document.body.appendChild(div);
+    div.style.setProperty(property, value);
+    var computedValue = getComputedStyle(div).getPropertyValue(property);
+    document.body.removeChild(div);
+    return computedValue;
+}
+
+function innerStyle(property, value) {
+    var div = document.createElement("div");
+    div.style.setProperty(property, value);
+    return div.style.getPropertyValue(property);
+}
+
+function testComputed(property, value, expected) {
+    shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected);
+}
+
+function testInner(property, value, expected) {
+    if (expected === null)
+        shouldBeNull('innerStyle("' + property + '", "' + value + '")');
+    else
+        shouldBeEqualToString('innerStyle("' + property + '", "' + value + '")', expected);
+}
+
+function negativeTest(property, value) {
+    testInner(property, value, null);
+    testComputed(property, value, 'auto');
+}
+
+// absolute lengths - number serialization, units
+testInner("-webkit-shape-inside", "circle(0, 0, 0)", "circle(0px, 0px, 0px)");
+testInner("-webkit-shape-inside", "circle(-1px, +1px, 1px)", "circle(-1px, 1px, 1px)");
+testInner("-webkit-shape-inside", "circle(-1.5px, +1.5px, 1.5px)", "circle(-1.5px, 1.5px, 1.5px)");
+testInner("-webkit-shape-inside", "circle(-.5px, +.5px, .5px)", "circle(-0.5px, 0.5px, 0.5px)");
+
+testInner("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)", "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)");
+
+// font-relative lengths - number serialization, units, resolution
+testInner("-webkit-shape-inside", "circle(-1em, +1em, 1em)", "circle(-1em, 1em, 1em)");
+testInner("-webkit-shape-inside", "circle(-1.5em, +1.5em, 1.5em)", "circle(-1.5em, 1.5em, 1.5em)");
+testInner("-webkit-shape-inside", "circle(-.5em, +.5em, .5em)", "circle(-0.5em, 0.5em, 0.5em)");
+
+testInner("-webkit-shape-inside", "circle(1ex, 1ex, 1ex)", "circle(1ex, 1ex, 1ex)");
+// FIXME: Add ch test when it is supported
+testInner("-webkit-shape-inside", "circle(1rem, 1rem, 1rem)", "circle(1rem, 1rem, 1rem)");
+
+testComputed("-webkit-shape-inside", "circle(.5em, 1em, 1.5em)", "circle(4px, 8px, 12px)");
+testComputed("-webkit-shape-inside", "circle(.5rem, 1rem, 1.5rem)", "circle(8px, 16px, 24px)");
+
+// viewport-percentage lengths - units, resolution
+testInner("-webkit-shape-inside", "circle(1vw, 1vw, 1vw)", "circle(1vw, 1vw, 1vw)");
+testInner("-webkit-shape-inside", "circle(1vh, 1vh, 1vh)", "circle(1vh, 1vh, 1vh)");
+testInner("-webkit-shape-inside", "circle(1vmin, 1vmin, 1vmin)", "circle(1vmin, 1vmin, 1vmin)");
+
+testComputed("-webkit-shape-inside", "circle(.5vw, 1vw, 1.5vw)", "circle(0.5vw, 1vw, 1.5vw)");
+testComputed("-webkit-shape-inside", "circle(.5vh, 1vh, 1.5vh)", "circle(0.5vh, 1vh, 1.5vh)");
+testComputed("-webkit-shape-inside", "circle(.5vmin, 1vmin, 1.5vmin)", "circle(0.5vmin, 1vmin, 1.5vmin)");
+
+// reject non-lengths
+negativeTest("-webkit-shape-inside", "circle(1px, 1px, 1)");
+negativeTest("-webkit-shape-inside", "circle(1px, 1px, px)");
+negativeTest("-webkit-shape-inside", "circle(1px, 1px, 1p)");
+negativeTest("-webkit-shape-inside", "circle(1px, 1px, calc())");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 603ce2196c182284345bdc7fbe3da96e120b044f..f726d61e8debc665deab3f2e5fa8dd5383c23ef8 100644 (file)
@@ -547,6 +547,7 @@ SET(WebCore_SOURCES
     css/WebKitCSSRegionRule.cpp
     css/WebKitCSSSVGDocumentValue.cpp
     css/WebKitCSSTransformValue.cpp
+    css/WrapShapeFunctions.cpp
 
     dom/ActiveDOMObject.cpp
     dom/Attr.cpp
index c437bf2edfad773f6f84344f48a4ae40f08be00b..7c7671ad9bf2cae6878efefb194ee57475b69807 100644 (file)
@@ -1,3 +1,111 @@
+2012-07-16  Bear Travis  <betravis@adobe.com>
+
+        Resolve CSS Exclusions shapeInside, shapeOutside properties to Length based WrapShape classes
+        https://bugs.webkit.org/show_bug.cgi?id=89670
+
+        Reviewed by Dirk Schulze.
+
+        Layout of CSS Exclusions requires length based WrapShape classes,
+        rather than the existing CSSValue based CSSWrapShape classes. This
+        patch adds length based WrapShape analogs to the CSSWrapShapes, and
+        modifies RenderStyle to use a WrapShape instead of a CSSWrapShape.
+        The translation between WrapShape and CSSWrapShape classes
+        is handled by helper functions in the new WrapShapeFunctions files.
+        StyleBuilder resolves CSSWrapShapes to WrapShapes for layout use.
+        CSSComputedStyleDeclaration translates WrapShapes to CSSWrapShapes
+        for style use.
+
+        There are existing tests that cover the style serialization / resolution
+        in fast/exclusions/parsing-wrap-shape-inside.html and
+        fast/exclusions/parsing/wrap-shape-outside.html
+
+        Test: fast/exclusions/parsing-wrap-shape-lengths.html
+
+        * CMakeLists.txt: Build system changes for adding new files
+        * GNUmakefile.list.am: Ditto
+        * Target.pri: Ditto
+        * WebCore.gypi: Ditto
+        * WebCore.vcproj/WebCore.vcproj: Ditto
+        * WebCore.xcodeproj/project.pbxproj: Ditto
+        * css/CSSComputedStyleDeclaration.cpp: Translate WrapShapes back to CSSWrapShapes
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSWrapShapes.h: Mostly changing functions to be const
+        (WebCore::CSSWrapShapeRectangle::type):
+        (WebCore::CSSWrapShapeCircle::type):
+        (WebCore::CSSWrapShapeEllipse::type):
+        (WebCore::CSSWrapShapePolygon::getXAt):
+        (WebCore::CSSWrapShapePolygon::getYAt):
+        (WebCore::CSSWrapShapePolygon::values):
+        (WebCore::CSSWrapShapePolygon::type):
+        * css/StyleBuilder.cpp: Resolve CSSWrapShapes to WrapShapes
+        (WebCore):
+        (WebCore::ApplyPropertyWrapShape::setValue):
+        (WebCore::ApplyPropertyWrapShape::applyValue):
+        (WebCore::ApplyPropertyWrapShape::createHandler):
+        * css/WrapShapeFunctions.cpp: Added.
+        (WebCore):
+        (WebCore::valueForWrapShape):
+        (WebCore::convertToLength):
+        (WebCore::wrapShapeForValue):
+        * css/WrapShapeFunctions.h: Added.
+        (WebCore):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/StyleRareNonInheritedData.h:
+        (StyleRareNonInheritedData):
+        * rendering/style/WrapShapes.h: Added.
+        (WebCore):
+        (WrapShape):
+        (WebCore::WrapShape::~WrapShape):
+        (WebCore::WrapShape::WrapShape):
+        (WrapShapeRectangle):
+        (WebCore::WrapShapeRectangle::create):
+        (WebCore::WrapShapeRectangle::left):
+        (WebCore::WrapShapeRectangle::top):
+        (WebCore::WrapShapeRectangle::width):
+        (WebCore::WrapShapeRectangle::height):
+        (WebCore::WrapShapeRectangle::cornerRadiusX):
+        (WebCore::WrapShapeRectangle::cornerRadiusY):
+        (WebCore::WrapShapeRectangle::setLeft):
+        (WebCore::WrapShapeRectangle::setTop):
+        (WebCore::WrapShapeRectangle::setWidth):
+        (WebCore::WrapShapeRectangle::setHeight):
+        (WebCore::WrapShapeRectangle::setCornerRadiusX):
+        (WebCore::WrapShapeRectangle::setCornerRadiusY):
+        (WebCore::WrapShapeRectangle::type):
+        (WebCore::WrapShapeRectangle::WrapShapeRectangle):
+        (WrapShapeCircle):
+        (WebCore::WrapShapeCircle::create):
+        (WebCore::WrapShapeCircle::left):
+        (WebCore::WrapShapeCircle::top):
+        (WebCore::WrapShapeCircle::radius):
+        (WebCore::WrapShapeCircle::setLeft):
+        (WebCore::WrapShapeCircle::setTop):
+        (WebCore::WrapShapeCircle::setRadius):
+        (WebCore::WrapShapeCircle::type):
+        (WebCore::WrapShapeCircle::WrapShapeCircle):
+        (WrapShapeEllipse):
+        (WebCore::WrapShapeEllipse::create):
+        (WebCore::WrapShapeEllipse::top):
+        (WebCore::WrapShapeEllipse::left):
+        (WebCore::WrapShapeEllipse::radiusX):
+        (WebCore::WrapShapeEllipse::radiusY):
+        (WebCore::WrapShapeEllipse::setTop):
+        (WebCore::WrapShapeEllipse::setLeft):
+        (WebCore::WrapShapeEllipse::setRadiusX):
+        (WebCore::WrapShapeEllipse::setRadiusY):
+        (WebCore::WrapShapeEllipse::type):
+        (WebCore::WrapShapeEllipse::WrapShapeEllipse):
+        (WrapShapePolygon):
+        (WebCore::WrapShapePolygon::create):
+        (WebCore::WrapShapePolygon::windRule):
+        (WebCore::WrapShapePolygon::values):
+        (WebCore::WrapShapePolygon::getXAt):
+        (WebCore::WrapShapePolygon::getYAt):
+        (WebCore::WrapShapePolygon::setWindRule):
+        (WebCore::WrapShapePolygon::appendPoint):
+        (WebCore::WrapShapePolygon::type):
+        (WebCore::WrapShapePolygon::WrapShapePolygon):
+
 2012-07-16  Simon Fraser  <simon.fraser@apple.com>
 
         Fix compositing layers in columns when in paginated mode
index 372135e08d157ecbc48f68e7369bf11205a2c1e2..585ed7f84193670e89b1a77a5a312d1b2588e9c7 100644 (file)
@@ -1798,6 +1798,8 @@ webcore_sources += \
        Source/WebCore/css/WebKitCSSShaderValue.h \
        Source/WebCore/css/WebKitCSSTransformValue.cpp \
        Source/WebCore/css/WebKitCSSTransformValue.h \
+       Source/WebCore/css/WrapShapeFunctions.cpp \
+       Source/WebCore/css/WrapShapeFunctions.h \
        Source/WebCore/dom/ActiveDOMObject.cpp \
        Source/WebCore/dom/ActiveDOMObject.h \
        Source/WebCore/dom/Attr.cpp \
index 3d68088af986ed644e117e5011aabc33b0c32b26..8f0e33eb797b8b04a695576f6e3c7d8b1cab5760 100644 (file)
@@ -511,6 +511,7 @@ SOURCES += \
     css/WebKitCSSSVGDocumentValue.cpp \
     css/WebKitCSSShaderValue.cpp \
     css/WebKitCSSTransformValue.cpp \
+    css/WrapShapeFunctions.cpp \
     dom/ActiveDOMObject.cpp \
     dom/Attr.cpp \
     dom/BeforeTextInsertedEvent.cpp \
@@ -1703,6 +1704,7 @@ HEADERS += \
     css/WebKitCSSSVGDocumentValue.h \
     css/WebKitCSSShaderValue.h \
     css/WebKitCSSTransformValue.h \
+    css/WrapShapeFunctions.h \
     dom/ActiveDOMObject.h \
     dom/Attr.h \
     dom/Attribute.h \
index f3f77ea43adac5b19f09b3e0cad43bae5a479154..df21693629686f27ce4a6011dce412198c5e8ac9 100644 (file)
             'css/WebKitCSSFilterValue.h',
             'css/WebKitCSSShaderValue.h',
             'css/WebKitCSSTransformValue.h',
+            'css/WrapShapeFunctions.h',
             'editing/ApplyBlockElementCommand.h',
             'editing/CompositeEditCommand.h',
             'editing/DeleteSelectionCommand.h',
             'css/WebKitCSSSVGDocumentValue.cpp',
             'css/WebKitCSSSVGDocumentValue.h',
             'css/WebKitCSSTransformValue.cpp',
+            'css/WrapShapeFunctions.cpp',
             'editing/AlternativeTextController.cpp',
             'editing/AlternativeTextController.h',
             'editing/AppendNodeCommand.cpp',
index 53b224c3b498a704cea328782398a6c685c58b4d..29ccad3f7ceb8957663f35990a068e064c359a1d 100755 (executable)
                                RelativePath="..\css\WebKitCSSTransformValue.h"
                                >
                        </File>
+                       <File
+                           RelativePath="..\css\WrapShapeFunctions.cpp"
+                           >
+                       </File>
+                       <File
+                           RelativePath="..\css\WrapShapeFunctions.h"
+                           >
+                       </File>
                </Filter>
                <Filter
                        Name="rendering"
index da47309198ebbc67f73836da5a49aa39a35cd168..b7bc2c3cae332ca9e1cc79dbae7d3435fd255270 100644 (file)
                FDB1700614A2BAB200A2B5D9 /* MultiChannelResampler.h in Headers */ = {isa = PBXBuildFile; fileRef = FDB1700414A2BAB200A2B5D9 /* MultiChannelResampler.h */; };
                FDC54F041399B0DA008D9117 /* BiquadFilterNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDC54F011399B0DA008D9117 /* BiquadFilterNode.cpp */; };
                FDC54F051399B0DA008D9117 /* BiquadFilterNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FDC54F021399B0DA008D9117 /* BiquadFilterNode.h */; };
+               FDE6860215B0A93B00BB480C /* WrapShapeFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD7E95A215ACD6090039E3D0 /* WrapShapeFunctions.cpp */; };
+               FDE6860315B0A96100BB480C /* WrapShapeFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = FD7E95A015ACD5620039E3D0 /* WrapShapeFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               FDE6860415B0A96100BB480C /* WrapShapes.h in Headers */ = {isa = PBXBuildFile; fileRef = FDB51CF4159CD70300E227C5 /* WrapShapes.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FDEA6242152102E200479DF0 /* JSOscillator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDEA6240152102E200479DF0 /* JSOscillator.cpp */; };
                FDEA6243152102E200479DF0 /* JSOscillator.h in Headers */ = {isa = PBXBuildFile; fileRef = FDEA6241152102E200479DF0 /* JSOscillator.h */; };
                FDEA6246152102FC00479DF0 /* JSWaveTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDEA6244152102FC00479DF0 /* JSWaveTable.cpp */; };
                FD6F252B13F5EF0E0065165F /* MediaElementAudioSourceNode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaElementAudioSourceNode.idl; sourceTree = "<group>"; };
                FD7868B7136B999200D403DF /* JSDynamicsCompressorNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDynamicsCompressorNode.cpp; sourceTree = "<group>"; };
                FD7868B8136B999200D403DF /* JSDynamicsCompressorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDynamicsCompressorNode.h; sourceTree = "<group>"; };
+               FD7E95A015ACD5620039E3D0 /* WrapShapeFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WrapShapeFunctions.h; sourceTree = "<group>"; };
+               FD7E95A215ACD6090039E3D0 /* WrapShapeFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WrapShapeFunctions.cpp; sourceTree = "<group>"; };
                FD7F298A13D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaveShaperDSPKernel.cpp; sourceTree = "<group>"; };
                FD7F298B13D4C0CB00AD9535 /* WaveShaperDSPKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WaveShaperDSPKernel.h; sourceTree = "<group>"; };
                FD7F298C13D4C0CB00AD9535 /* WaveShaperNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaveShaperNode.cpp; sourceTree = "<group>"; };
                FDB052DE1561A42C00B500D6 /* AudioSummingJunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioSummingJunction.h; sourceTree = "<group>"; };
                FDB1700314A2BAB200A2B5D9 /* MultiChannelResampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MultiChannelResampler.cpp; sourceTree = "<group>"; };
                FDB1700414A2BAB200A2B5D9 /* MultiChannelResampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MultiChannelResampler.h; sourceTree = "<group>"; };
+               FDB51CF4159CD70300E227C5 /* WrapShapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WrapShapes.h; path = style/WrapShapes.h; sourceTree = "<group>"; };
                FDC54F011399B0DA008D9117 /* BiquadFilterNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BiquadFilterNode.cpp; sourceTree = "<group>"; };
                FDC54F021399B0DA008D9117 /* BiquadFilterNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BiquadFilterNode.h; sourceTree = "<group>"; };
                FDC54F031399B0DA008D9117 /* BiquadFilterNode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = BiquadFilterNode.idl; sourceTree = "<group>"; };
                                BC2274750E8366E200E7F975 /* SVGRenderStyle.h */,
                                BC2274760E8366E200E7F975 /* SVGRenderStyleDefs.cpp */,
                                BC2274770E8366E200E7F975 /* SVGRenderStyleDefs.h */,
+                               FDB51CF4159CD70300E227C5 /* WrapShapes.h */,
                        );
                        name = style;
                        sourceTree = "<group>";
                                BC9ADD7F0CC4092200098C4C /* WebKitCSSTransformValue.cpp */,
                                BC9ADD220CC4032600098C4C /* WebKitCSSTransformValue.h */,
                                31611E540E1C4D4A00F6A579 /* WebKitCSSTransformValue.idl */,
+                               FD7E95A215ACD6090039E3D0 /* WrapShapeFunctions.cpp */,
+                               FD7E95A015ACD5620039E3D0 /* WrapShapeFunctions.h */,
                        );
                        path = css;
                        sourceTree = "<group>";
                        buildActionMask = 2147483647;
                        files = (
                                97BC69DB1505F076001B74AC /* AbstractDatabase.h in Headers */,
+                               FDE6860415B0A96100BB480C /* WrapShapes.h in Headers */,
+                               FDE6860315B0A96100BB480C /* WrapShapeFunctions.h in Headers */,
                                41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
                                29A8122E0FBB9C1D00510293 /* AccessibilityARIAGridCell.h in Headers */,
                                29A812330FBB9C1D00510293 /* AccessibilityARIAGridRow.h in Headers */,
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               FDE6860215B0A93B00BB480C /* WrapShapeFunctions.cpp in Sources */,
                                97BC69DA1505F076001B74AC /* AbstractDatabase.cpp in Sources */,
                                41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */,
                                0F29C16E1300C2E2002D794E /* AccessibilityAllInOne.cpp in Sources */,
index 208d4701930d3835f842bd2f19695d25695d5182..4d571cf1eca4944001f77f3d7d3521d128e39c20 100644 (file)
 #include "WebKitCSSTransformValue.h"
 #include "WebKitFontFamilyNames.h"
 
+#if ENABLE(CSS_EXCLUSIONS)
+#include "CSSWrapShapes.h"
+#include "WrapShapeFunctions.h"
+#include "WrapShapes.h"
+#endif
+
 #if ENABLE(CSS_SHADERS)
 #include "CustomFilterNumberParameter.h"
 #include "CustomFilterOperation.h"
@@ -2365,11 +2371,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
         case CSSPropertyWebkitShapeInside:
             if (!style->wrapShapeInside())
                 return cssValuePool().createIdentifierValue(CSSValueAuto);
-            return cssValuePool().createValue(style->wrapShapeInside());
+            return valueForWrapShape(style->wrapShapeInside());
         case CSSPropertyWebkitShapeOutside:
             if (!style->wrapShapeOutside())
                 return cssValuePool().createIdentifierValue(CSSValueAuto);
-            return cssValuePool().createValue(style->wrapShapeOutside());
+            return valueForWrapShape(style->wrapShapeOutside());
         case CSSPropertyWebkitWrapThrough:
             return cssValuePool().createValue(style->wrapThrough());
 #endif
index c877a270f242df06a53b481633d94e5805760f0d..713b8dd60c9274444eeed44ad194ce046a3901b7 100644 (file)
@@ -47,7 +47,7 @@ public:
         CSS_WRAP_SHAPE_POLYGON = 4
     };
 
-    virtual Type type() = 0;
+    virtual Type type() const = 0;
     virtual String cssText() const = 0;
 
 public:
@@ -75,7 +75,7 @@ public:
     void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
     void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
 
-    virtual Type type() { return CSS_WRAP_SHAPE_RECTANGLE; }
+    virtual Type type() const { return CSS_WRAP_SHAPE_RECTANGLE; }
     virtual String cssText() const;
 
 private:
@@ -101,7 +101,7 @@ public:
     void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
     void setRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_radius = radius; }
 
-    virtual Type type() { return CSS_WRAP_SHAPE_CIRCLE; }
+    virtual Type type() const { return CSS_WRAP_SHAPE_CIRCLE; }
     virtual String cssText() const;
 
 private:
@@ -126,7 +126,7 @@ public:
     void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
     void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
 
-    virtual Type type() { return CSS_WRAP_SHAPE_ELLIPSE; }
+    virtual Type type() const { return CSS_WRAP_SHAPE_ELLIPSE; }
     virtual String cssText() const;
 
 private:
@@ -148,13 +148,14 @@ public:
         m_values.append(y);
     }
 
-    PassRefPtr<CSSPrimitiveValue> getXAt(unsigned i) { return m_values.at(i * 2); }
-    PassRefPtr<CSSPrimitiveValue> getYAt(unsigned i) { return m_values.at(i * 2 + 1); }
+    PassRefPtr<CSSPrimitiveValue> getXAt(unsigned i) const { return m_values.at(i * 2); }
+    PassRefPtr<CSSPrimitiveValue> getYAt(unsigned i) const { return m_values.at(i * 2 + 1); }
+    const Vector<RefPtr<CSSPrimitiveValue> >& values() const { return m_values; }
 
     void setWindRule(WindRule w) { m_windRule = w; }
     WindRule windRule() const { return m_windRule; }
 
-    virtual Type type() { return CSS_WRAP_SHAPE_POLYGON; }
+    virtual Type type() const { return CSS_WRAP_SHAPE_POLYGON; }
     virtual String cssText() const;
 
 private:
index 16f08d6d0233dd5dcc3fda4a1d3af1d56a028a97..44ec87f7ba720319d65cdca1f3c77103f1e68fe5 100644 (file)
 #include <wtf/StdLibExtras.h>
 #include <wtf/UnusedParam.h>
 
+#if ENABLE(CSS_EXCLUSIONS)
+#include "CSSWrapShapes.h"
+#include "WrapShapeFunctions.h"
+#include "WrapShapes.h"
+#endif
+
 using namespace std;
 
 namespace WebCore {
@@ -1726,23 +1732,25 @@ public:
 };
 
 #if ENABLE(CSS_EXCLUSIONS)
-template <CSSWrapShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<CSSWrapShape>), CSSWrapShape* (*initialFunction)()>
+template <WrapShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<WrapShape>), WrapShape* (*initialFunction)()>
 class ApplyPropertyWrapShape {
 public:
-    static void setValue(RenderStyle* style, PassRefPtr<CSSWrapShape> value) { (style->*setterFunction)(value); }
+    static void setValue(RenderStyle* style, PassRefPtr<WrapShape> value) { (style->*setterFunction)(value); }
     static void applyValue(StyleResolver* styleResolver, CSSValue* value)
     {
         if (value->isPrimitiveValue()) {
             CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
             if (primitiveValue->getIdent() == CSSValueAuto)
                 setValue(styleResolver->style(), 0);
-            else if (primitiveValue->isShape())
-                setValue(styleResolver->style(), primitiveValue->getShapeValue());
+            else if (primitiveValue->isShape()) {
+                RefPtr<WrapShape> wrapShape = wrapShapeForValue(styleResolver, primitiveValue->getShapeValue());
+                setValue(styleResolver->style(), wrapShape.release());
+            }
         }
     }
     static PropertyHandler createHandler()
     {
-        PropertyHandler handler = ApplyPropertyDefaultBase<CSSWrapShape*, getterFunction, PassRefPtr<CSSWrapShape>, setterFunction, CSSWrapShape*, initialFunction>::createHandler();
+        PropertyHandler handler = ApplyPropertyDefaultBase<WrapShape*, getterFunction, PassRefPtr<WrapShape>, setterFunction, WrapShape*, initialFunction>::createHandler();
         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
     }
 };
diff --git a/Source/WebCore/css/WrapShapeFunctions.cpp b/Source/WebCore/css/WrapShapeFunctions.cpp
new file mode 100644 (file)
index 0000000..33fc5a6
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WrapShapeFunctions.h"
+
+#include "CSSPrimitiveValueMappings.h"
+#include "CSSValuePool.h"
+#include "CSSWrapShapes.h"
+#include "StyleResolver.h"
+#include "WrapShapes.h"
+
+namespace WebCore {
+
+PassRefPtr<CSSValue> valueForWrapShape(const WrapShape* wrapShape)
+{
+    RefPtr<CSSWrapShape> wrapShapeValue;
+    switch (wrapShape->type()) {
+    case WrapShape::WRAP_SHAPE_RECTANGLE: {
+        const WrapShapeRectangle* rectangle = static_cast<const WrapShapeRectangle*>(wrapShape);
+        RefPtr<CSSWrapShapeRectangle> rectangleValue = CSSWrapShapeRectangle::create();
+
+        rectangleValue->setLeft(cssValuePool().createValue(rectangle->left()));
+        rectangleValue->setTop(cssValuePool().createValue(rectangle->top()));
+        rectangleValue->setWidth(cssValuePool().createValue(rectangle->width()));
+        rectangleValue->setHeight(cssValuePool().createValue(rectangle->height()));
+        if (!rectangle->cornerRadiusX().isUndefined()) {
+            rectangleValue->setRadiusX(cssValuePool().createValue(rectangle->cornerRadiusX()));
+            if (!rectangle->cornerRadiusY().isUndefined())
+                rectangleValue->setRadiusY(cssValuePool().createValue(rectangle->cornerRadiusY()));
+        }
+
+        wrapShapeValue = rectangleValue.release();
+        break;
+    }
+    case WrapShape::WRAP_SHAPE_CIRCLE: {
+        const WrapShapeCircle* circle = static_cast<const WrapShapeCircle*>(wrapShape);
+        RefPtr<CSSWrapShapeCircle> circleValue = CSSWrapShapeCircle::create();
+
+        circleValue->setLeft(cssValuePool().createValue(circle->left()));
+        circleValue->setTop(cssValuePool().createValue(circle->top()));
+        circleValue->setRadius(cssValuePool().createValue(circle->radius()));
+
+        wrapShapeValue = circleValue.release();
+        break;
+    }
+    case WrapShape::WRAP_SHAPE_ELLIPSE: {
+        const WrapShapeEllipse* ellipse = static_cast<const WrapShapeEllipse*>(wrapShape);
+        RefPtr<CSSWrapShapeEllipse> ellipseValue = CSSWrapShapeEllipse::create();
+
+        ellipseValue->setLeft(cssValuePool().createValue(ellipse->left()));
+        ellipseValue->setTop(cssValuePool().createValue(ellipse->top()));
+        ellipseValue->setRadiusX(cssValuePool().createValue(ellipse->radiusX()));
+        ellipseValue->setRadiusY(cssValuePool().createValue(ellipse->radiusY()));
+
+        wrapShapeValue = ellipseValue.release();
+        break;
+    }
+    case WrapShape::WRAP_SHAPE_POLYGON: {
+        const WrapShapePolygon* polygon = static_cast<const WrapShapePolygon*>(wrapShape);
+        RefPtr<CSSWrapShapePolygon> polygonValue = CSSWrapShapePolygon::create();
+
+        polygonValue->setWindRule(polygon->windRule());
+        const Vector<Length>& values = polygon->values();
+        for (unsigned i = 0; i < values.size(); i += 2)
+            polygonValue->appendPoint(cssValuePool().createValue(values.at(i)), cssValuePool().createValue(values.at(i + 1)));
+
+        wrapShapeValue = polygonValue.release();
+        break;
+    }
+    default:
+        break;
+    }
+    return cssValuePool().createValue<PassRefPtr<CSSWrapShape> >(wrapShapeValue.release());
+}
+
+static Length convertToLength(const StyleResolver* styleResolver, CSSPrimitiveValue* value)
+{
+    return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
+}
+
+PassRefPtr<WrapShape> wrapShapeForValue(const StyleResolver* styleResolver, const CSSWrapShape* wrapShapeValue)
+{
+    RefPtr<WrapShape> wrapShape;
+
+    switch (wrapShapeValue->type()) {
+    case CSSWrapShape::CSS_WRAP_SHAPE_RECTANGLE: {
+        const CSSWrapShapeRectangle* rectValue = static_cast<const CSSWrapShapeRectangle *>(wrapShapeValue);
+        RefPtr<WrapShapeRectangle> rect = WrapShapeRectangle::create();
+
+        rect->setLeft(convertToLength(styleResolver, rectValue->left()));
+        rect->setTop(convertToLength(styleResolver, rectValue->top()));
+        rect->setWidth(convertToLength(styleResolver, rectValue->width()));
+        rect->setHeight(convertToLength(styleResolver, rectValue->height()));
+        if (rectValue->radiusX()) {
+            rect->setCornerRadiusX(convertToLength(styleResolver, rectValue->radiusX()));
+            if (rectValue->radiusY())
+                rect->setCornerRadiusY(convertToLength(styleResolver, rectValue->radiusY()));
+        }
+        wrapShape = rect.release();
+        break;
+    }
+    case CSSWrapShape::CSS_WRAP_SHAPE_CIRCLE: {
+        const CSSWrapShapeCircle* circleValue = static_cast<const CSSWrapShapeCircle *>(wrapShapeValue);
+        RefPtr<WrapShapeCircle> circle = WrapShapeCircle::create();
+
+        circle->setLeft(convertToLength(styleResolver, circleValue->left()));
+        circle->setTop(convertToLength(styleResolver, circleValue->top()));
+        circle->setRadius(convertToLength(styleResolver, circleValue->radius()));
+
+        wrapShape = circle.release();
+        break;
+    }
+    case CSSWrapShape::CSS_WRAP_SHAPE_ELLIPSE: {
+        const CSSWrapShapeEllipse* ellipseValue = static_cast<const CSSWrapShapeEllipse *>(wrapShapeValue);
+        RefPtr<WrapShapeEllipse> ellipse = WrapShapeEllipse::create();
+
+        ellipse->setLeft(convertToLength(styleResolver, ellipseValue->left()));
+        ellipse->setTop(convertToLength(styleResolver, ellipseValue->top()));
+        ellipse->setRadiusX(convertToLength(styleResolver, ellipseValue->radiusX()));
+        ellipse->setRadiusY(convertToLength(styleResolver, ellipseValue->radiusY()));
+
+        wrapShape = ellipse.release();
+        break;
+    }
+    case CSSWrapShape::CSS_WRAP_SHAPE_POLYGON: {
+        const CSSWrapShapePolygon* polygonValue = static_cast<const CSSWrapShapePolygon *>(wrapShapeValue);
+        RefPtr<WrapShapePolygon> polygon = WrapShapePolygon::create();
+
+        polygon->setWindRule(polygonValue->windRule());
+        const Vector<RefPtr<CSSPrimitiveValue> >& values = polygonValue->values();
+        for (unsigned i = 0; i < values.size(); i += 2)
+            polygon->appendPoint(convertToLength(styleResolver, values.at(i).get()), convertToLength(styleResolver, values.at(i + 1).get()));
+
+        wrapShape = polygon.release();
+        break;
+    }
+    default:
+        break;
+    }
+    return wrapShape.release();
+}
+}
diff --git a/Source/WebCore/css/WrapShapeFunctions.h b/Source/WebCore/css/WrapShapeFunctions.h
new file mode 100644 (file)
index 0000000..d3b953c
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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 WrapShapeFunctions_h
+#define WrapShapeFunctions_h
+
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class CSSValue;
+class CSSWrapShape;
+class StyleResolver;
+class WrapShape;
+
+PassRefPtr<CSSValue> valueForWrapShape(const WrapShape*);
+PassRefPtr<WrapShape> wrapShapeForValue(const StyleResolver*, const CSSWrapShape*);
+
+}
+#endif
index 8eb49f7d80f7b94209f75de906f3b3c104b7c01e..bb4b26937f6d66b82ec2fc7c996e3f7da8c17052 100644 (file)
@@ -1427,22 +1427,22 @@ public:
     void setKerning(SVGLength k) { accessSVGStyle()->setKerning(k); }
 #endif
 
-    void setWrapShapeInside(PassRefPtr<CSSWrapShape> shape)
+    void setWrapShapeInside(PassRefPtr<WrapShape> shape)
     {
         if (rareNonInheritedData->m_wrapShapeInside != shape)
             rareNonInheritedData.access()->m_wrapShapeInside = shape;
     }
-    CSSWrapShape* wrapShapeInside() const { return rareNonInheritedData->m_wrapShapeInside.get(); }
+    WrapShape* wrapShapeInside() const { return rareNonInheritedData->m_wrapShapeInside.get(); }
 
-    void setWrapShapeOutside(PassRefPtr<CSSWrapShape> shape)
+    void setWrapShapeOutside(PassRefPtr<WrapShape> shape)
     {
         if (rareNonInheritedData->m_wrapShapeOutside != shape)
             rareNonInheritedData.access()->m_wrapShapeOutside = shape;
     }
-    CSSWrapShape* wrapShapeOutside() const { return rareNonInheritedData->m_wrapShapeOutside.get(); }
+    WrapShape* wrapShapeOutside() const { return rareNonInheritedData->m_wrapShapeOutside.get(); }
 
-    static CSSWrapShape* initialWrapShapeInside() { return 0; }
-    static CSSWrapShape* initialWrapShapeOutside() { return 0; }
+    static WrapShape* initialWrapShapeInside() { return 0; }
+    static WrapShape* initialWrapShapeOutside() { return 0; }
 
     Length wrapPadding() const { return rareNonInheritedData->m_wrapPadding; }
     void setWrapPadding(Length wrapPadding) { SET_VAR(rareNonInheritedData, m_wrapPadding, wrapPadding); }
index 94c4c8dfb1c80f37c5c506d67e2bfb04408d3e16..5e6fde2a617cf39525e557bd9098662214e8cbee 100644 (file)
 #ifndef StyleRareNonInheritedData_h
 #define StyleRareNonInheritedData_h
 
-#include "CSSWrapShapes.h"
 #include "CounterDirectives.h"
 #include "CursorData.h"
 #include "DataRef.h"
 #include "FillLayer.h"
 #include "LineClampValue.h"
 #include "NinePieceImage.h"
+#include "WrapShapes.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
@@ -134,8 +134,8 @@ public:
 
     LengthSize m_pageSize;
 
-    RefPtr<CSSWrapShape> m_wrapShapeInside;
-    RefPtr<CSSWrapShape> m_wrapShapeOutside;
+    RefPtr<WrapShape> m_wrapShapeInside;
+    RefPtr<WrapShape> m_wrapShapeOutside;
     Length m_wrapMargin;
     Length m_wrapPadding;
     
diff --git a/Source/WebCore/rendering/style/WrapShapes.h b/Source/WebCore/rendering/style/WrapShapes.h
new file mode 100644 (file)
index 0000000..57e55ec
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * 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 WrapShapes_h
+#define WrapShapes_h
+
+#include "Length.h"
+#include "WindRule.h"
+
+namespace WebCore {
+
+class WrapShape : public RefCounted<WrapShape> {
+public:
+    enum Type {
+        WRAP_SHAPE_RECTANGLE = 1,
+        WRAP_SHAPE_CIRCLE = 2,
+        WRAP_SHAPE_ELLIPSE = 3,
+        WRAP_SHAPE_POLYGON = 4
+    };
+
+    virtual Type type() const = 0;
+    virtual ~WrapShape() { }
+
+protected:
+    WrapShape() { }
+};
+
+class WrapShapeRectangle : public WrapShape {
+public:
+    static PassRefPtr<WrapShapeRectangle> create() { return adoptRef(new WrapShapeRectangle); }
+
+    Length left() const { return m_left; }
+    Length top() const { return m_top; }
+    Length width() const { return m_width; }
+    Length height() const { return m_height; }
+    Length cornerRadiusX() const { return m_cornerRadiusX; }
+    Length cornerRadiusY() const { return m_cornerRadiusY; }
+
+    void setLeft(Length left) { m_left = left; }
+    void setTop(Length top) { m_top = top; }
+    void setWidth(Length width) { m_width = width; }
+    void setHeight(Length height) { m_height = height; }
+    void setCornerRadiusX(Length radiusX) { m_cornerRadiusX = radiusX; }
+    void setCornerRadiusY(Length radiusY) { m_cornerRadiusY = radiusY; }
+
+    virtual Type type() const { return WRAP_SHAPE_RECTANGLE; }
+
+private:
+    WrapShapeRectangle()
+        : m_cornerRadiusX(Undefined)
+        , m_cornerRadiusY(Undefined)
+    { }
+
+    Length m_top;
+    Length m_left;
+    Length m_width;
+    Length m_height;
+    Length m_cornerRadiusX;
+    Length m_cornerRadiusY;
+};
+
+class WrapShapeCircle : public WrapShape {
+public:
+    static PassRefPtr<WrapShapeCircle> create() { return adoptRef(new WrapShapeCircle); }
+
+    Length left() const { return m_left; }
+    Length top() const { return m_top; }
+    Length radius() const { return m_radius; }
+
+    void setLeft(Length left) { m_left = left; }
+    void setTop(Length top) { m_top = top; }
+    void setRadius(Length radius) { m_radius = radius; }
+
+    virtual Type type() const { return WRAP_SHAPE_CIRCLE; }
+private:
+    WrapShapeCircle() { }
+
+    Length m_top;
+    Length m_left;
+    Length m_radius;
+};
+
+class WrapShapeEllipse : public WrapShape {
+public:
+    static PassRefPtr<WrapShapeEllipse> create() { return adoptRef(new WrapShapeEllipse); }
+
+    Length top() const { return m_top; }
+    Length left() const { return m_left; }
+    Length radiusX() const { return m_radiusX; }
+    Length radiusY() const { return m_radiusY; }
+
+    void setTop(Length top) { m_top = top; }
+    void setLeft(Length left) { m_left = left; }
+    void setRadiusX(Length radiusX) { m_radiusX = radiusX; }
+    void setRadiusY(Length radiusY) { m_radiusY = radiusY; }
+
+    virtual Type type() const { return WRAP_SHAPE_ELLIPSE; }
+private:
+    WrapShapeEllipse() { }
+
+    Length m_top;
+    Length m_left;
+    Length m_radiusX;
+    Length m_radiusY;
+};
+
+class WrapShapePolygon : public WrapShape {
+public:
+    static PassRefPtr<WrapShapePolygon> create() { return adoptRef(new WrapShapePolygon); }
+
+    WindRule windRule() const { return m_windRule; }
+    const Vector<Length>& values() const { return m_values; }
+    Length getXAt(unsigned i) const { return m_values.at(2 * i); }
+    Length getYAt(unsigned i) const { return m_values.at(2 * i + 1); }
+
+    void setWindRule(WindRule windRule) { m_windRule = windRule; }
+    void appendPoint(Length x, Length y) { m_values.append(x); m_values.append(y); }
+
+    virtual Type type() const { return WRAP_SHAPE_POLYGON; }
+private:
+    WrapShapePolygon()
+        : m_windRule(RULE_NONZERO)
+    { }
+
+    WindRule m_windRule;
+    Vector<Length> m_values;
+};
+}
+#endif