[CSS Exclusions] shape-outside on floats for rectangle shapes height/width
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Dec 2012 20:07:57 +0000 (20:07 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Dec 2012 20:07:57 +0000 (20:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=100398

Patch by Bem Jones-Bey <bjonesbe@adobe.com> on 2012-12-17
Reviewed by Julien Chaffraix.

Source/WebCore:

Implement shape outside for floats changing only the height and width
as a simple starting point.

This implementation changes floats to use the bounding box of the
shape outside instead of the margin box for layout. The content box of
the float is unchanged. This patch does not support positioning the
shape outside box, so the x and y parameters are currently ignored in
the specified shape. This will be fixed in a patch for bug 100399.

Tests: fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored.html
       fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html
       fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage.html
       fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle.html

* CMakeLists.txt: Add ExclusionShapeOutsideInfo.{cpp,h}.
* GNUmakefile.list.am: Add ExclusionShapeOutsideInfo.{cpp,h}.
* Target.pri: Add ExclusionShapeOutsideInfo.{cpp,h}.
* WebCore.gypi: Add ExclusionShapeOutsideInfo.{cpp,h}.
* WebCore.vcproj/WebCore.vcproj: Add ExclusionShapeOutsideInfo.{cpp,h}.
* WebCore.xcodeproj/project.pbxproj: Add ExclusionShapeOutsideInfo.{cpp,h}.
* rendering/ExclusionShapeOutsideInfo.cpp: Added. Associates the
    ExclusionShape object for shape outside with a RenderBox. Analagous to
    ExclusionShapeInsideInfo.
(WebCore::exclusionShapeOutsideInfoMap):
(WebCore::ExclusionShapeOutsideInfo::ExclusionShapeOutsideInfo):
(WebCore::ExclusionShapeOutsideInfo::~ExclusionShapeOutsideInfo):
(WebCore::ExclusionShapeOutsideInfo::ensureInfoForRenderBox):
(WebCore::ExclusionShapeOutsideInfo::infoForRenderBox):
(WebCore::ExclusionShapeOutsideInfo::isInfoEnabledForRenderBox):
(WebCore::ExclusionShapeOutsideInfo::removeInfoForRenderBox):
(WebCore::ExclusionShapeOutsideInfo::computedShape):
* rendering/ExclusionShapeOutsideInfo.h: Added. Associates the
    ExclusionShape object for shape outside with a RenderBox. Analagous to
    ExclusionShapeInsideInfo.
(ExclusionShapeOutsideInfo):
(WebCore::ExclusionShapeOutsideInfo::create):
(WebCore::ExclusionShapeOutsideInfo::shapeLogicalLeft):
(WebCore::ExclusionShapeOutsideInfo::shapeLogicalRight):
(WebCore::ExclusionShapeOutsideInfo::shapeLogicalTop):
(WebCore::ExclusionShapeOutsideInfo::shapeLogicalBottom):
(WebCore::ExclusionShapeOutsideInfo::shapeLogicalWidth):
(WebCore::ExclusionShapeOutsideInfo::shapeLogicalHeight):
(WebCore::ExclusionShapeOutsideInfo::setShapeSize):
(WebCore::ExclusionShapeOutsideInfo::dirtyShapeSize):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::insertFloatingObject): Use the shape outside's bounding box to set the width that is
    used for inline layout for the float and it's siblings.
(WebCore::RenderBlock::positionNewFloats): Use the shape outside's bounding box to set the height that
    is used for inline layout for the float and it's siblings. Ignore margins when positioning if the float
    has shape outside, per the exclusions spec.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::willBeDestroyed): Clean up associated ExclusionShape.
(WebCore::RenderBox::styleDidChange): Handle style change for shape outside.
(WebCore::RenderBox::updateExclusionShapeOutsideInfoAfterStyleChange): Handle style change for shape outside.
* rendering/RenderBox.h:
(WebCore::RenderBox::exclusionShapeOutsideInfo): Get the ExclusionShapeOutsideInfo associated with this
    RenderBox.

LayoutTests:

Tests for the basic shape outside functionality to show how the shape affects inline text and other floats.
Also test using percentages to specify the shape and that margins are properly ignored (per the spec), when a
shape is applied to a float.

* fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored-expected.html: Added.
* fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored.html: Added.
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-expected.html: Added.
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple-expected.html: Added.
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html: Added.
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage-expected.html: Added.
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage.html: Added.
* fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle.html: Added.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle.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/rendering/ExclusionShapeOutsideInfo.cpp [new file with mode: 0644]
Source/WebCore/rendering/ExclusionShapeOutsideInfo.h [new file with mode: 0644]
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h

index 4b71798..eb88165 100644 (file)
@@ -1,3 +1,23 @@
+2012-12-17  Bem Jones-Bey  <bjonesbe@adobe.com>
+
+        [CSS Exclusions] shape-outside on floats for rectangle shapes height/width
+        https://bugs.webkit.org/show_bug.cgi?id=100398
+
+        Reviewed by Julien Chaffraix.
+
+        Tests for the basic shape outside functionality to show how the shape affects inline text and other floats. 
+        Also test using percentages to specify the shape and that margins are properly ignored (per the spec), when a 
+        shape is applied to a float.
+
+        * fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored-expected.html: Added.
+        * fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored.html: Added.
+        * fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-expected.html: Added.
+        * fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple-expected.html: Added.
+        * fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html: Added.
+        * fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage-expected.html: Added.
+        * fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage.html: Added.
+        * fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle.html: Added.
+
 2012-12-17  John J. Barton  <johnjbarton@chromium.org>
 
         Web Inspector: Search by selection
diff --git a/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored-expected.html b/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored-expected.html
new file mode 100644 (file)
index 0000000..4fe1469
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    .container {
+        font: 10px/1 Ahem, sans-serif;
+        height: 30px;
+        width: 40px;
+        border: 1px solid black;
+    }
+    .float-right {
+        float: right;
+        margin: 0px;
+        height: 20px;
+        width: 20px;
+    }
+    .float-left {
+        float: left;
+        margin: 0px;
+        height: 20px;
+        width: 20px;
+    }
+</style>
+</head>
+<body>
+    <h1><a href="https://bugs.webkit.org/show_bug.cgi?id=100398">Bug 100398</a>: [CSS Exclusions] shape-outside on floats for rectangle shapes height/width</h1>
+    <h2>The following tests show that the margin is ignored when there is a shape outside. Each test should be a black rectangle with a white square in one corner.</h2>
+    <div class="container">
+        <div class="float-right"></div>
+        XX
+        XX
+        XXXX
+    </div>
+    <p></p>
+    <div class="container">
+        <div class="float-left"></div>
+        XX
+        XX
+        XXXX
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored.html b/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored.html
new file mode 100644 (file)
index 0000000..aa00b85
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    .container {
+        font: 10px/1 Ahem, sans-serif;
+        height: 30px;
+        width: 40px;
+        border: 1px solid black;
+    }
+    .float-right {
+        -webkit-shape-outside: rectangle(0px, 0px, 20px, 20px);
+        float: right;
+        margin: 10px;
+        height: 20px;
+        width: 20px;
+    }
+    .float-left {
+        -webkit-shape-outside: rectangle(0px, 0px, 20px, 20px);
+        float: left;
+        margin: 10px;
+        height: 20px;
+        width: 20px;
+    }
+</style>
+</head>
+<body>
+    <h1><a href="https://bugs.webkit.org/show_bug.cgi?id=100398">Bug 100398</a>: [CSS Exclusions] shape-outside on floats for rectangle shapes height/width</h1>
+    <h2>The following tests show that the margin is ignored when there is a shape outside. Each test should be a black rectangle with a white square in one corner.</h2>
+    <div class="container">
+        <div class="float-right"></div>
+        XX
+        XX
+        XXXX
+    </div>
+    <p></p>
+    <div class="container">
+        <div class="float-left"></div>
+        XX
+        XX
+        XXXX
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-expected.html b/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-expected.html
new file mode 100644 (file)
index 0000000..adffd5c
--- /dev/null
@@ -0,0 +1,243 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .test {
+            font: 10px/1 Ahem, sans-serif;
+            border: 1px solid black;
+        }
+        .vertical-lr {
+            -webkit-writing-mode: vertical-lr;
+        }
+        .vertical-rl {
+            -webkit-writing-mode: vertical-rl;
+        }
+        .container-horizontal {
+            width: 40px;
+            height: 30px;
+        }
+        .container-vertical {
+            width: 30px;
+            height: 40px;
+        }
+        .float-rectangle-horizontal {
+            width: 10px;
+            height: 20px;
+        }
+        .float-rectangle-vertical {
+            width: 20px;
+            height: 10px;
+        }
+        .float-square {
+            width: 20px;
+            height: 20px;
+        }
+        .exclusion-horizontal-larger {
+            width: 30px;
+            height: 20px;
+        }
+        .exclusion-vertical-larger {
+            width: 20px;
+            height: 30px;
+        }
+        .exclusion-horizontal-smaller {
+            width: 10px;
+            height: 20px;
+        }
+        .exclusion-vertical-smaller {
+            width: 20px;
+            height: 10px;
+        }
+    </style>
+</head>
+<body>
+    <h1><a href="https://bugs.webkit.org/show_bug.cgi?id=100398">Bug 100398</a>: [CSS Exclusions] shape-outside on floats for rectangle shapes height/width</h1>
+    <h2>The following tests all should have a white rectangle in one corner of a larger black rectangle.</h2>
+    <h3>Shape with greater width than float</h3>
+    <p></p>
+    <div class="test container-horizontal">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: right"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: left"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-rl">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: right"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-rl">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: left"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-lr">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: right"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-lr">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: left"></div>
+        X
+        X
+        XXXX
+    </div>
+
+    <h3>Shape with smaller width than float</h3>
+    <p></p>
+    <div class="test container-horizontal">
+        <div class="float-square exclusion-horizontal-smaller" style="float: right"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal">
+        <div class="float-square exclusion-horizontal-smaller" style="float: left"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-rl">
+        <div class="float-square exclusion-vertical-smaller" style="float: right"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-rl">
+        <div class="float-square exclusion-vertical-smaller" style="float: left"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-lr">
+        <div class="float-square exclusion-vertical-smaller" style="float: right"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-lr">
+        <div class="float-square exclusion-vertical-smaller" style="float: left"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+
+    <h3>Shape with greater height than float</h3>
+    <p></p>
+    <div class="test container-vertical">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: right"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-vertical">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: left"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-rl">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: right"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-rl">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: left"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-lr">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: right"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-lr">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: left"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+
+    <h3>Shape with smaller height than float</h3>
+    <p></p>
+    <div class="test container-vertical">
+        <div class="float-square exclusion-vertical-smaller" style="float: right"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-vertical">
+        <div class="float-square exclusion-vertical-smaller" style="float: left"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-rl">
+        <div class="float-square exclusion-horizontal-smaller" style="float: right"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-rl">
+        <div class="float-square exclusion-horizontal-smaller" style="float: left"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-lr">
+        <div class="float-square exclusion-horizontal-smaller" style="float: right"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-lr">
+        <div class="float-square exclusion-horizontal-smaller" style="float: left"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+</body>
diff --git a/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple-expected.html b/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple-expected.html
new file mode 100644 (file)
index 0000000..b98b402
--- /dev/null
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    .container {
+        font: 10px/1 Ahem, sans-serif;
+        height: 20px;
+        width: 40px;
+        border: 1px solid black;
+    }
+    .float-right {
+        float: right;
+        height: 20px;
+        width: 20px;
+        background-color: green;
+    }
+    .float-left {
+        float: left;
+        height: 20px;
+        width: 20px;
+        background-color: green;
+    }
+    .float-right-vertical {
+        float: right;
+        height: 20px;
+        width: 20px;
+        background-color: green;
+    }
+    .float-left-vertical {
+        float: left;
+        height: 20px;
+        width: 20px;
+        background-color: green;
+    }
+    .float-right-exclusion {
+        float: right;
+        height: 20px;
+        width: 10px;
+    }
+    .float-left-exclusion {
+        float: left;
+        height: 20px;
+        width: 10px;
+    }
+    .float-right-vertical-exclusion {
+        float: right;
+        height: 10px;
+        width: 20px;
+    }
+    .float-left-vertical-exclusion {
+        float: left;
+        height: 10px;
+        width: 20px;
+    }
+    .writing-mode-vertical-lr {
+        -webkit-writing-mode: vertical-lr;
+        height: 40px;
+        width: 20px;
+    }
+    .writing-mode-vertical-rl {
+        -webkit-writing-mode: vertical-rl;
+        height: 40px;
+        width: 20px;
+    }
+</style>
+</head>
+<body>
+    <h1><a href="https://bugs.webkit.org/show_bug.cgi?id=100398">Bug 100398</a>: [CSS Exclusions] shape-outside on floats for rectangle shapes height/width</h1>
+    <h2>These tests show that floats respect the shape outside on other floats. Each test should have a green square centegreen in a larger rectangle.</h2>
+    <div class="container">
+        <div class="float-right-exclusion"></div>
+        <div class="float-right"></div>
+    </div>
+    <p></p>
+    <div class="container">
+        <div class="float-left-exclusion"></div>
+        <div class="float-left"></div>
+    </div>
+    <p></p>
+    <div class="container writing-mode-vertical-lr">
+        <div class="float-right-vertical-exclusion"></div>
+        <div class="float-right-vertical"></div>
+
+    </div>
+    <p></p>
+    <div class="container writing-mode-vertical-lr">
+        <div class="float-left-vertical-exclusion"></div>
+        <div class="float-left-vertical"></div>
+
+    </div>
+    <p></p>
+    <div class="container writing-mode-vertical-rl">
+        <div class="float-right-vertical-exclusion"></div>
+        <div class="float-right-vertical"></div>
+
+    </div>
+    <p></p>
+    <div class="container writing-mode-vertical-rl">
+        <div class="float-left-vertical-exclusion"></div>
+        <div class="float-left-vertical"></div>
+
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html b/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html
new file mode 100644 (file)
index 0000000..776e3bc
--- /dev/null
@@ -0,0 +1,113 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    .container {
+        font: 10px/1 Ahem, sans-serif;
+        height: 20px;
+        width: 40px;
+        border: 1px solid black;
+    }
+    .float-right {
+        float: right;
+        height: 20px;
+        width: 20px;
+        background-color: green;
+    }
+    .float-left {
+        float: left;
+        height: 20px;
+        width: 20px;
+        background-color: green;
+    }
+    .float-right-vertical {
+        float: right;
+        height: 20px;
+        width: 20px;
+        background-color: green;
+    }
+    .float-left-vertical {
+        float: left;
+        height: 20px;
+        width: 20px;
+        background-color: green;
+    }
+    .float-right-exclusion {
+        -webkit-shape-outside: rectangle(10px, 0px, 10px, 20px);
+        float: right;
+        height: 20px;
+        width: 20px;
+    }
+    .float-left-exclusion {
+        -webkit-shape-outside: rectangle(0px, 0px, 10px, 20px);
+        float: left;
+        height: 20px;
+        width: 20px;
+    }
+    .float-right-vertical-exclusion {
+        -webkit-shape-outside: rectangle(0px, 10px, 20px, 10px);
+        float: right;
+        height: 20px;
+        width: 20px;
+    }
+    .float-left-vertical-exclusion {
+        -webkit-shape-outside: rectangle(0px, 0px, 20px, 10px);
+        float: left;
+        height: 20px;
+        width: 20px;
+    }
+    .writing-mode-vertical-lr {
+        -webkit-writing-mode: vertical-lr;
+        height: 40px;
+        width: 20px;
+    }
+    .writing-mode-vertical-rl {
+        -webkit-writing-mode: vertical-rl;
+        height: 40px;
+        width: 20px;
+    }
+</style>
+</head>
+<body>
+    <h1><a href="https://bugs.webkit.org/show_bug.cgi?id=100398">Bug 100398</a>: [CSS Exclusions] shape-outside on floats for rectangle shapes height/width</h1>
+    <h2>These tests show that floats respect the shape outside on other floats. Each test should have a green square centegreen in a larger rectangle.</h2>
+    <div class="container">
+        <div class="float-right-exclusion"></div>
+        <div class="float-right"></div>
+    </div>
+    <p></p>
+    <div class="container">
+        <div class="float-left-exclusion"></div>
+        <div class="float-left"></div>
+    </div>
+    <p></p>
+    <div class="container writing-mode-vertical-lr">
+        <div class="float-right-vertical-exclusion"></div>
+        <div class="float-right-vertical"></div>
+
+    </div>
+    <p></p>
+    <div class="container writing-mode-vertical-lr">
+        <div class="float-left-vertical-exclusion"></div>
+        <div class="float-left-vertical"></div>
+
+    </div>
+    <p></p>
+    <div class="container writing-mode-vertical-rl">
+        <div class="float-right-vertical-exclusion"></div>
+        <div class="float-right-vertical"></div>
+
+    </div>
+    <p></p>
+    <div class="container writing-mode-vertical-rl">
+        <div class="float-left-vertical-exclusion"></div>
+        <div class="float-left-vertical"></div>
+
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage-expected.html b/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage-expected.html
new file mode 100644 (file)
index 0000000..e4d953d
--- /dev/null
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    .container {
+        font: 10px/1 Ahem, sans-serif;
+        border: 1px solid black;
+    }
+    .container-smaller {
+        height: 40px;
+        width: 40px;
+    }
+    .container-horizontal-larger {
+        height: 40px;
+        width: 30px;
+    }
+    .container-vertical-larger {
+        height: 30px;
+        width: 40px;
+    }
+    .float-horizontal-smaller {
+        float: right;
+        height: 10px;
+        width: 20px;
+    }
+    .float-vertical-smaller {
+        float: right;
+        height: 20px;
+        width: 10px;
+    }
+    .float-horizontal-larger {
+        float: right;
+        height: 30px;
+        width: 20px;
+    }
+    .float-vertical-larger {
+        float: right;
+        height: 20px;
+        width: 30px;
+    }
+    .writing-mode-vertical-lr {
+        -webkit-writing-mode: vertical-lr;
+    }
+    .writing-mode-vertical-rl {
+        -webkit-writing-mode: vertical-rl;
+    }
+</style>
+</head>
+<body>
+    <h1><a href="https://bugs.webkit.org/show_bug.cgi?id=100398">Bug 100398</a>: [CSS Exclusions] shape-outside on floats for rectangle shapes height/width</h1>
+    <h2>These tests show that the shape outside works with shapes specified with percentages. Each rectangle below should have a smaller white rectangle on one corner.</h2>
+    <div class="container container-smaller">
+        <div class="float-horizontal-smaller"></div>
+        XX
+        XXXX
+        XXXX
+        XXXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-smaller writing-mode-vertical-lr">
+        <div class="float-vertical-smaller"></div>
+        XX
+        XXXX
+        XXXX
+        XXXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-smaller writing-mode-vertical-rl">
+        <div class="float-vertical-smaller"></div>
+        XX
+        XXXX
+        XXXX
+        XXXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-horizontal-larger">
+        <div class="float-horizontal-larger"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-vertical-larger writing-mode-vertical-lr">
+        <div class="float-vertical-larger"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-vertical-larger writing-mode-vertical-rl">
+        <div class="float-vertical-larger"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage.html b/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage.html
new file mode 100644 (file)
index 0000000..c11d639
--- /dev/null
@@ -0,0 +1,113 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    .container {
+        font: 10px/1 Ahem, sans-serif;
+        border: 1px solid black;
+    }
+    .container-smaller {
+        height: 40px;
+        width: 40px;
+    }
+    .container-horizontal-larger {
+        height: 40px;
+        width: 30px;
+    }
+    .container-vertical-larger {
+        height: 30px;
+        width: 40px;
+    }
+    .float-horizontal-smaller {
+        -webkit-shape-outside: rectangle(0px, 0px, 100%, 50%);
+        float: right;
+        height: 20px;
+        width: 20px;
+    }
+    .float-vertical-smaller {
+        -webkit-shape-outside: rectangle(0px, 0px, 50%, 100%);
+        float: right;
+        height: 50%
+        width: 50%
+    }
+    .float-horizontal-larger {
+        -webkit-shape-outside: rectangle(0px, 0px, 100%, 150%);
+        float: right;
+        height: 20px;
+        width: 20px;
+    }
+    .float-vertical-larger {
+        -webkit-shape-outside: rectangle(0px, 0px, 30px, 20px);
+        float: right;
+        height: 50%
+        width: 50%;
+    }
+    .writing-mode-vertical-lr {
+        -webkit-writing-mode: vertical-lr;
+    }
+    .writing-mode-vertical-rl {
+        -webkit-writing-mode: vertical-rl;
+    }
+</style>
+</head>
+<body>
+    <h1><a href="https://bugs.webkit.org/show_bug.cgi?id=100398">Bug 100398</a>: [CSS Exclusions] shape-outside on floats for rectangle shapes height/width</h1>
+    <h2>These tests show that the shape outside works with shapes specified with percentages. Each rectangle below should have a smaller white rectangle on one corner.</h2>
+    <div class="container container-smaller">
+        <div class="float-horizontal-smaller"></div>
+        XX
+        XXXX
+        XXXX
+        XXXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-smaller writing-mode-vertical-lr">
+        <div class="float-vertical-smaller"></div>
+        XX
+        XXXX
+        XXXX
+        XXXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-smaller writing-mode-vertical-rl">
+        <div class="float-vertical-smaller"></div>
+        XX
+        XXXX
+        XXXX
+        XXXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-horizontal-larger">
+        <div class="float-horizontal-larger"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-vertical-larger writing-mode-vertical-lr">
+        <div class="float-vertical-larger"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p>
+    </p>
+    <div class="container container-vertical-larger writing-mode-vertical-rl">
+        <div class="float-vertical-larger"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle.html b/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle.html
new file mode 100644 (file)
index 0000000..cb77ad8
--- /dev/null
@@ -0,0 +1,243 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script>
+        if (window.internals)
+            window.internals.settings.setCSSExclusionsEnabled(true);
+    </script>
+    <style>
+        .test {
+            font: 10px/1 Ahem, sans-serif;
+            border: 1px solid black;
+        }
+        .vertical-lr {
+            -webkit-writing-mode: vertical-lr;
+        }
+        .vertical-rl {
+            -webkit-writing-mode: vertical-rl;
+        }
+        .container-horizontal {
+            width: 40px;
+            height: 30px;
+        }
+        .container-vertical {
+            width: 30px;
+            height: 40px;
+        }
+        .float-rectangle-horizontal {
+            width: 10px;
+            height: 20px;
+        }
+        .float-rectangle-vertical {
+            width: 20px;
+            height: 10px;
+        }
+        .float-square {
+            width: 20px;
+            height: 20px;
+        }
+        .exclusion-horizontal-larger {
+            -webkit-shape-outside: rectangle(0, 0, 30px, 20px);
+        }
+        .exclusion-vertical-larger {
+            -webkit-shape-outside: rectangle(0, 0, 20px, 30px);
+        }
+        .exclusion-horizontal-smaller {
+            -webkit-shape-outside: rectangle(0, 0, 10px, 20px);
+        }
+        .exclusion-vertical-smaller {
+            -webkit-shape-outside: rectangle(0, 0, 20px, 10px);
+        }
+    </style>
+</head>
+<body>
+    <h1><a href="https://bugs.webkit.org/show_bug.cgi?id=100398">Bug 100398</a>: [CSS Exclusions] shape-outside on floats for rectangle shapes height/width</h1>
+    <h2>The following tests all should have a white rectangle in one corner of a larger black rectangle.</h2>
+    <h3>Shape with greater width than float</h3>
+    <p></p>
+    <div class="test container-horizontal">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: right"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: left"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-rl">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: right"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-rl">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: left"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-lr">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: right"></div>
+        X
+        X
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-lr">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: left"></div>
+        X
+        X
+        XXXX
+    </div>
+
+    <h3>Shape with smaller width than float</h3>
+    <p></p>
+    <div class="test container-horizontal">
+        <div class="float-square exclusion-horizontal-smaller" style="float: right"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal">
+        <div class="float-square exclusion-horizontal-smaller" style="float: left"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-rl">
+        <div class="float-square exclusion-vertical-smaller" style="float: right"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-rl">
+        <div class="float-square exclusion-vertical-smaller" style="float: left"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-lr">
+        <div class="float-square exclusion-vertical-smaller" style="float: right"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+    <p></p>
+    <div class="test container-vertical vertical-lr">
+        <div class="float-square exclusion-vertical-smaller" style="float: left"></div>
+        XXX
+        XXX
+        XXXX
+    </div>
+
+    <h3>Shape with greater height than float</h3>
+    <p></p>
+    <div class="test container-vertical">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: right"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-vertical">
+        <div class="float-rectangle-vertical exclusion-vertical-larger" style="float: left"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-rl">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: right"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-rl">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: left"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-lr">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: right"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-lr">
+        <div class="float-rectangle-horizontal exclusion-horizontal-larger" style="float: left"></div>
+        X
+        X
+        X
+        XXX
+    </div>
+
+    <h3>Shape with smaller height than float</h3>
+    <p></p>
+    <div class="test container-vertical">
+        <div class="float-square exclusion-vertical-smaller" style="float: right"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-vertical">
+        <div class="float-square exclusion-vertical-smaller" style="float: left"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-rl">
+        <div class="float-square exclusion-horizontal-smaller" style="float: right"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-rl">
+        <div class="float-square exclusion-horizontal-smaller" style="float: left"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-lr">
+        <div class="float-square exclusion-horizontal-smaller" style="float: right"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+    <p></p>
+    <div class="test container-horizontal vertical-lr">
+        <div class="float-square exclusion-horizontal-smaller" style="float: left"></div>
+        X
+        XXX
+        XXX
+        XXX
+    </div>
+</body>
index 3946cc8..2192d56 100644 (file)
@@ -2085,6 +2085,7 @@ set(WebCore_SOURCES
     rendering/ExclusionRectangle.cpp
     rendering/ExclusionShape.cpp
     rendering/ExclusionShapeInsideInfo.cpp
+    rendering/ExclusionShapeOutsideInfo.cpp
     rendering/FilterEffectRenderer.cpp
     rendering/FixedTableLayout.cpp
     rendering/FlowThreadController.cpp
index 51bc969..a2bd046 100644 (file)
@@ -1,3 +1,68 @@
+2012-12-17  Bem Jones-Bey  <bjonesbe@adobe.com>
+
+        [CSS Exclusions] shape-outside on floats for rectangle shapes height/width
+        https://bugs.webkit.org/show_bug.cgi?id=100398
+
+        Reviewed by Julien Chaffraix.
+
+        Implement shape outside for floats changing only the height and width
+        as a simple starting point.
+
+        This implementation changes floats to use the bounding box of the
+        shape outside instead of the margin box for layout. The content box of
+        the float is unchanged. This patch does not support positioning the
+        shape outside box, so the x and y parameters are currently ignored in
+        the specified shape. This will be fixed in a patch for bug 100399.
+
+        Tests: fast/exclusions/shape-outside-floats/shape-outside-floats-margin-is-ignored.html
+               fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-horizontal-multiple.html
+               fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle-percentage.html
+               fast/exclusions/shape-outside-floats/shape-outside-floats-simple-rectangle.html
+
+        * CMakeLists.txt: Add ExclusionShapeOutsideInfo.{cpp,h}.
+        * GNUmakefile.list.am: Add ExclusionShapeOutsideInfo.{cpp,h}.
+        * Target.pri: Add ExclusionShapeOutsideInfo.{cpp,h}.
+        * WebCore.gypi: Add ExclusionShapeOutsideInfo.{cpp,h}.
+        * WebCore.vcproj/WebCore.vcproj: Add ExclusionShapeOutsideInfo.{cpp,h}.
+        * WebCore.xcodeproj/project.pbxproj: Add ExclusionShapeOutsideInfo.{cpp,h}.
+        * rendering/ExclusionShapeOutsideInfo.cpp: Added. Associates the
+            ExclusionShape object for shape outside with a RenderBox. Analagous to
+            ExclusionShapeInsideInfo.
+        (WebCore::exclusionShapeOutsideInfoMap):
+        (WebCore::ExclusionShapeOutsideInfo::ExclusionShapeOutsideInfo):
+        (WebCore::ExclusionShapeOutsideInfo::~ExclusionShapeOutsideInfo):
+        (WebCore::ExclusionShapeOutsideInfo::ensureInfoForRenderBox):
+        (WebCore::ExclusionShapeOutsideInfo::infoForRenderBox):
+        (WebCore::ExclusionShapeOutsideInfo::isInfoEnabledForRenderBox):
+        (WebCore::ExclusionShapeOutsideInfo::removeInfoForRenderBox):
+        (WebCore::ExclusionShapeOutsideInfo::computedShape):
+        * rendering/ExclusionShapeOutsideInfo.h: Added. Associates the
+            ExclusionShape object for shape outside with a RenderBox. Analagous to
+            ExclusionShapeInsideInfo.
+        (ExclusionShapeOutsideInfo):
+        (WebCore::ExclusionShapeOutsideInfo::create):
+        (WebCore::ExclusionShapeOutsideInfo::shapeLogicalLeft):
+        (WebCore::ExclusionShapeOutsideInfo::shapeLogicalRight):
+        (WebCore::ExclusionShapeOutsideInfo::shapeLogicalTop):
+        (WebCore::ExclusionShapeOutsideInfo::shapeLogicalBottom):
+        (WebCore::ExclusionShapeOutsideInfo::shapeLogicalWidth):
+        (WebCore::ExclusionShapeOutsideInfo::shapeLogicalHeight):
+        (WebCore::ExclusionShapeOutsideInfo::setShapeSize):
+        (WebCore::ExclusionShapeOutsideInfo::dirtyShapeSize):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::insertFloatingObject): Use the shape outside's bounding box to set the width that is
+            used for inline layout for the float and it's siblings.
+        (WebCore::RenderBlock::positionNewFloats): Use the shape outside's bounding box to set the height that
+            is used for inline layout for the float and it's siblings. Ignore margins when positioning if the float
+            has shape outside, per the exclusions spec. 
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::willBeDestroyed): Clean up associated ExclusionShape.
+        (WebCore::RenderBox::styleDidChange): Handle style change for shape outside.
+        (WebCore::RenderBox::updateExclusionShapeOutsideInfoAfterStyleChange): Handle style change for shape outside.
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::exclusionShapeOutsideInfo): Get the ExclusionShapeOutsideInfo associated with this
+            RenderBox.
+
 2012-12-17  John J. Barton  <johnjbarton@chromium.org>
 
         Web Inspector: Search by selection
index 122b54f..b7a6a2c 100644 (file)
@@ -4243,6 +4243,8 @@ webcore_sources += \
        Source/WebCore/rendering/ExclusionShape.h \
        Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp \
        Source/WebCore/rendering/ExclusionShapeInsideInfo.h \
+       Source/WebCore/rendering/ExclusionShapeOutsideInfo.cpp \
+       Source/WebCore/rendering/ExclusionShapeOutsideInfo.h \
        Source/WebCore/rendering/FilterEffectRenderer.cpp \
        Source/WebCore/rendering/FilterEffectRenderer.h \
        Source/WebCore/rendering/FixedTableLayout.cpp \
index dbe8497..a68ad84 100644 (file)
@@ -1128,6 +1128,7 @@ SOURCES += \
     rendering/ExclusionRectangle.cpp \
     rendering/ExclusionShape.cpp \
     rendering/ExclusionShapeInsideInfo.cpp \
+    rendering/ExclusionShapeOutsideInfo.cpp \
     rendering/FilterEffectRenderer.cpp \
     rendering/FixedTableLayout.cpp \
     rendering/FlowThreadController.cpp \
@@ -2366,6 +2367,7 @@ HEADERS += \
     rendering/ExclusionRectangle.h \
     rendering/ExclusionShape.h \
     rendering/ExclusionShapeInsideInfo.h \
+    rendering/ExclusionShapeOutsideInfo.h \
     rendering/FilterEffectRenderer.h \
     rendering/FixedTableLayout.h \
     rendering/HitTestingTransformState.h \
index ab87bee..a0fdbd6 100644 (file)
             'rendering/ExclusionShape.h',
             'rendering/ExclusionShapeInsideInfo.cpp',
             'rendering/ExclusionShapeInsideInfo.h',
+            'rendering/ExclusionShapeOutsideInfo.cpp',
+            'rendering/ExclusionShapeOutsideInfo.h',
             'rendering/FilterEffectRenderer.cpp',
             'rendering/FilterEffectRenderer.h',
             'rendering/FixedTableLayout.cpp',
index ca20493..78f7824 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\rendering\ExclusionShapeOutsideInfo.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\rendering\ExclusionShapeOutsideInfo.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\rendering\FilterEffectRenderer.cpp"
                                >
                                <FileConfiguration
index 815eef0..21dd180 100644 (file)
                98CE432A129E00E5005821DC /* LinkLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 98CE4329129E00E5005821DC /* LinkLoader.h */; };
                98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = 98EB1F941313FE0500D0E1EA /* NotImplemented.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9A1B6F97158869C80011A8C4 /* JSDOMStringListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A1B6F96158869C80011A8C4 /* JSDOMStringListCustom.cpp */; };
+               9A9CEF8D163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9CEF8B163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.cpp */; };
+               9A9CEF8E163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9CEF8C163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9B0FB191140DB5790022588F /* HTTPValidation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0FB18F140DB5790022588F /* HTTPValidation.cpp */; };
                9B0FB192140DB5790022588F /* HTTPValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0FB190140DB5790022588F /* HTTPValidation.h */; };
                9B1AB07C1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B1AB07B1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp */; };
                98CE4329129E00E5005821DC /* LinkLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkLoader.h; sourceTree = "<group>"; };
                98EB1F941313FE0500D0E1EA /* NotImplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotImplemented.h; sourceTree = "<group>"; };
                9A1B6F96158869C80011A8C4 /* JSDOMStringListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMStringListCustom.cpp; sourceTree = "<group>"; };
+               9A9CEF8B163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExclusionShapeOutsideInfo.cpp; sourceTree = "<group>"; };
+               9A9CEF8C163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExclusionShapeOutsideInfo.h; sourceTree = "<group>"; };
                9B0FB18F140DB5790022588F /* HTTPValidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPValidation.cpp; sourceTree = "<group>"; };
                9B0FB190140DB5790022588F /* HTTPValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPValidation.h; sourceTree = "<group>"; };
                9B1AB0791648C69D0051F3F2 /* HTMLFormControlsCollection.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HTMLFormControlsCollection.idl; sourceTree = "<group>"; };
                                6E8798B915F81E4A00BFE4AA /* ExclusionShape.h */,
                                FD748ABD15BF74ED0059CF0D /* ExclusionShapeInsideInfo.cpp */,
                                FD748ABE15BF74ED0059CF0D /* ExclusionShapeInsideInfo.h */,
+                               9A9CEF8B163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.cpp */,
+                               9A9CEF8C163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.h */,
                                31313F631443B35E006E2A90 /* FilterEffectRenderer.cpp */,
                                31313F641443B35E006E2A90 /* FilterEffectRenderer.h */,
                                A8CFF0480A154F09000A4234 /* FixedTableLayout.cpp */,
                                97BC69DB1505F076001B74AC /* AbstractDatabase.h in Headers */,
                                41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
                                29A8122E0FBB9C1D00510293 /* AccessibilityARIAGridCell.h in Headers */,
+                               9A9CEF8E163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.h in Headers */,
                                29A812330FBB9C1D00510293 /* AccessibilityARIAGridRow.h in Headers */,
                                29A8123B0FBB9C1D00510293 /* AccessibilityImageMapLink.h in Headers */,
                                29A8122C0FBB9C1D00510293 /* AccessibilityList.h in Headers */,
                                FEDEF84116797108000E444A /* DatabaseStrategy.cpp in Sources */,
                                F37A56221679CF7B00C57046 /* HeapGraphSerializer.cpp in Sources */,
                                CD1E7347167BC78E009A885D /* TextTrackRepresentation.cpp in Sources */,
+                               9A9CEF8D163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Source/WebCore/rendering/ExclusionShapeOutsideInfo.cpp b/Source/WebCore/rendering/ExclusionShapeOutsideInfo.cpp
new file mode 100644 (file)
index 0000000..0353cbb
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * 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"
+
+#if ENABLE(CSS_EXCLUSIONS)
+
+#include "ExclusionShapeOutsideInfo.h"
+
+#include "RenderBox.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+typedef HashMap<const RenderBox*, OwnPtr<ExclusionShapeOutsideInfo> > ExclusionShapeOutsideInfoMap;
+
+static ExclusionShapeOutsideInfoMap& exclusionShapeOutsideInfoMap()
+{
+    DEFINE_STATIC_LOCAL(ExclusionShapeOutsideInfoMap, staticExclusionShapeOutsideInfoMap, ());
+    return staticExclusionShapeOutsideInfoMap;
+}
+
+ExclusionShapeOutsideInfo::ExclusionShapeOutsideInfo(RenderBox* box)
+    : m_box(box)
+    , m_logicalWidth(0)
+    , m_logicalHeight(0)
+{
+}
+
+ExclusionShapeOutsideInfo::~ExclusionShapeOutsideInfo()
+{
+}
+
+ExclusionShapeOutsideInfo* ExclusionShapeOutsideInfo::ensureInfoForRenderBox(RenderBox* box)
+{
+    ExclusionShapeOutsideInfoMap& infoMap = exclusionShapeOutsideInfoMap();
+    if (ExclusionShapeOutsideInfo* shapeInfo = infoMap.get(box))
+        return shapeInfo;
+
+    ExclusionShapeOutsideInfoMap::AddResult result = infoMap.add(box, create(box));
+    return result.iterator->value.get();
+}
+
+ExclusionShapeOutsideInfo* ExclusionShapeOutsideInfo::infoForRenderBox(const RenderBox* box)
+{
+    ASSERT(box->style()->shapeOutside());
+    return exclusionShapeOutsideInfoMap().get(box);
+}
+
+bool ExclusionShapeOutsideInfo::isInfoEnabledForRenderBox(const RenderBox* box)
+{
+    // FIXME: Enable shape outside for non-rectangular shapes! (bug 98664)
+    ExclusionShapeValue* value = box->style()->shapeOutside();
+    return value && (value->type() == ExclusionShapeValue::SHAPE) && (value->shape()->type() == BasicShape::BASIC_SHAPE_RECTANGLE);
+}
+
+void ExclusionShapeOutsideInfo::removeInfoForRenderBox(const RenderBox* box)
+{
+    exclusionShapeOutsideInfoMap().remove(box);
+}
+
+const ExclusionShape* ExclusionShapeOutsideInfo::computedShape() const
+{
+    if (ExclusionShape* shapeOutside = m_computedShape.get())
+        return shapeOutside;
+
+    ExclusionShapeValue* basicShapeValue = m_box->style()->shapeOutside();
+    ASSERT(basicShapeValue);
+    ASSERT(basicShapeValue->type() == ExclusionShapeValue::SHAPE);
+
+    m_computedShape = ExclusionShape::createExclusionShape(basicShapeValue->shape(), m_logicalWidth, m_logicalHeight, m_box->style()->writingMode());
+    return m_computedShape.get();
+}
+
+}
+#endif
diff --git a/Source/WebCore/rendering/ExclusionShapeOutsideInfo.h b/Source/WebCore/rendering/ExclusionShapeOutsideInfo.h
new file mode 100644 (file)
index 0000000..53a0071
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * 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 ExclusionShapeOutsideInfo_h
+#define ExclusionShapeOutsideInfo_h
+
+#if ENABLE(CSS_EXCLUSIONS)
+
+#include "ExclusionShape.h"
+#include "FloatRect.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class RenderBox;
+
+class ExclusionShapeOutsideInfo {
+    WTF_MAKE_NONCOPYABLE(ExclusionShapeOutsideInfo); WTF_MAKE_FAST_ALLOCATED;
+public:
+    ~ExclusionShapeOutsideInfo();
+
+    static PassOwnPtr<ExclusionShapeOutsideInfo> create(RenderBox* box) { return adoptPtr(new ExclusionShapeOutsideInfo(box)); }
+    static ExclusionShapeOutsideInfo* infoForRenderBox(const RenderBox*);
+    static ExclusionShapeOutsideInfo* ensureInfoForRenderBox(RenderBox*);
+    static void removeInfoForRenderBox(const RenderBox*);
+    static bool isInfoEnabledForRenderBox(const RenderBox*);
+
+    LayoutUnit shapeLogicalLeft() const
+    { 
+        return computedShape()->shapeLogicalBoundingBox().x();
+    }
+    LayoutUnit shapeLogicalRight() const
+    { 
+        return computedShape()->shapeLogicalBoundingBox().maxX();
+    }
+    LayoutUnit shapeLogicalTop() const
+    { 
+        return LayoutUnit::fromFloatCeil(computedShape()->shapeLogicalBoundingBox().y());
+    }
+    LayoutUnit shapeLogicalBottom() const
+    {
+        return LayoutUnit::fromFloatFloor(computedShape()->shapeLogicalBoundingBox().maxY());
+    }
+    LayoutUnit shapeLogicalWidth() const
+    { 
+        return computedShape()->shapeLogicalBoundingBox().width();
+    }
+    LayoutUnit shapeLogicalHeight() const
+    {
+        return computedShape()->shapeLogicalBoundingBox().height();
+    }
+
+    void setShapeSize(LayoutUnit logicalWidth, LayoutUnit logicalHeight)
+    {
+        if (m_logicalWidth == logicalWidth && m_logicalHeight == logicalHeight)
+            return;
+
+        dirtyShapeSize();
+        m_logicalWidth = logicalWidth;
+        m_logicalHeight = logicalHeight;
+    }
+
+    void dirtyShapeSize() { m_computedShape.clear(); }
+
+private:
+    explicit ExclusionShapeOutsideInfo(RenderBox*);
+    const ExclusionShape* computedShape() const;
+
+    RenderBox* m_box;
+    mutable OwnPtr<ExclusionShape> m_computedShape;
+
+    LayoutUnit m_logicalWidth;
+    LayoutUnit m_logicalHeight;
+};
+
+}
+#endif
+#endif
index eab138d..591ec3a 100644 (file)
@@ -65,6 +65,7 @@
 #include <wtf/StdLibExtras.h>
 #if ENABLE(CSS_EXCLUSIONS)
 #include "ExclusionShapeInsideInfo.h"
+#include "ExclusionShapeOutsideInfo.h"
 #endif
 #include <wtf/MemoryInstrumentationHashMap.h>
 #include <wtf/MemoryInstrumentationHashSet.h>
@@ -3749,7 +3750,17 @@ RenderBlock::FloatingObject* RenderBlock::insertFloatingObject(RenderBox* o)
         o->updateLogicalWidth();
         o->computeAndSetBlockDirectionMargins(this);
     }
-    setLogicalWidthForFloat(newObj, logicalWidthForChild(o) + marginStartForChild(o) + marginEndForChild(o));
+
+#if ENABLE(CSS_EXCLUSIONS)
+    ExclusionShapeOutsideInfo* shapeOutside = o->exclusionShapeOutsideInfo();
+    if (shapeOutside) {
+        shapeOutside->setShapeSize(o->logicalWidth(), o->logicalHeight());
+        // The CSS Exclusions specification says that the margins are ignored
+        // when a float has a shape outside.
+        setLogicalWidthForFloat(newObj, shapeOutside->shapeLogicalWidth());
+    } else
+#endif
+        setLogicalWidthForFloat(newObj, logicalWidthForChild(o) + marginStartForChild(o) + marginEndForChild(o));
 
     newObj->setShouldPaint(!o->hasSelfPaintingLayer()); // If a layer exists, the float will paint itself. Otherwise someone else will.
     newObj->setIsDescendant(true);
@@ -3935,8 +3946,14 @@ bool RenderBlock::positionNewFloats()
         LayoutPoint floatLogicalLocation = computeLogicalLocationForFloat(floatingObject, logicalTop);
 
         setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x());
-        setLogicalLeftForChild(childBox, floatLogicalLocation.x() + childLogicalLeftMargin);
-        setLogicalTopForChild(childBox, floatLogicalLocation.y() + marginBeforeForChild(childBox));
+
+        bool hasShapeOutside = false;
+#if ENABLE(CSS_EXCLUSIONS)
+        hasShapeOutside = floatingObject->renderer()->exclusionShapeOutsideInfo();
+#endif
+        // The CSS Exclusions specification says that the margins are ignored when a float has a shape outside.
+        setLogicalLeftForChild(childBox, floatLogicalLocation.x() + (hasShapeOutside ? LayoutUnit() : childLogicalLeftMargin));
+        setLogicalTopForChild(childBox, floatLogicalLocation.y() + (hasShapeOutside ? LayoutUnit() : marginBeforeForChild(childBox)));
 
         LayoutState* layoutState = view()->layoutState();
         bool isPaginated = layoutState->isPaginated();
@@ -3964,8 +3981,10 @@ bool RenderBlock::positionNewFloats()
 
                 floatLogicalLocation = computeLogicalLocationForFloat(floatingObject, newLogicalTop);
                 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x());
-                setLogicalLeftForChild(childBox, floatLogicalLocation.x() + childLogicalLeftMargin);
-                setLogicalTopForChild(childBox, floatLogicalLocation.y() + marginBeforeForChild(childBox));
+
+                // The CSS Exclusions specification says that the margins are ignored when a float has a shape outside.
+                setLogicalLeftForChild(childBox, floatLogicalLocation.x() + (hasShapeOutside ? LayoutUnit() : childLogicalLeftMargin));
+                setLogicalTopForChild(childBox, floatLogicalLocation.y() + (hasShapeOutside ? LayoutUnit() : marginBeforeForChild(childBox)));
         
                 if (childBlock)
                     childBlock->setChildNeedsLayout(true, MarkOnlyThis);
@@ -3974,7 +3993,12 @@ bool RenderBlock::positionNewFloats()
         }
 
         setLogicalTopForFloat(floatingObject, floatLogicalLocation.y());
-        setLogicalHeightForFloat(floatingObject, logicalHeightForChild(childBox) + marginBeforeForChild(childBox) + marginAfterForChild(childBox));
+#if ENABLE(CSS_EXCLUSIONS)
+        if (hasShapeOutside)
+            setLogicalHeightForFloat(floatingObject, floatingObject->renderer()->exclusionShapeOutsideInfo()->shapeLogicalHeight());
+        else
+#endif
+            setLogicalHeightForFloat(floatingObject, logicalHeightForChild(childBox) + marginBeforeForChild(childBox) + marginAfterForChild(childBox));
 
         m_floatingObjects->addPlacedObject(floatingObject);
 
index f7a5564..4b96ecd 100644 (file)
@@ -150,6 +150,10 @@ void RenderBox::willBeDestroyed()
 
     RenderBlock::removePercentHeightDescendantIfNeeded(this);
 
+#if ENABLE(CSS_EXCLUSIONS)
+    ExclusionShapeOutsideInfo::removeInfoForRenderBox(this);
+#endif
+
     RenderBoxModelObject::willBeDestroyed();
 }
 
@@ -282,8 +286,27 @@ void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle
 
         frame()->view()->recalculateScrollbarOverlayStyle();
     }
+
+#if ENABLE(CSS_EXCLUSIONS)
+    updateExclusionShapeOutsideInfoAfterStyleChange(style()->shapeOutside(), oldStyle ? oldStyle->shapeOutside() : 0);
+#endif
 }
 
+#if ENABLE(CSS_EXCLUSIONS)
+void RenderBox::updateExclusionShapeOutsideInfoAfterStyleChange(const ExclusionShapeValue* shapeOutside, const ExclusionShapeValue* oldShapeOutside)
+{
+    // FIXME: A future optimization would do a deep comparison for equality. (bug 100811)
+    if (shapeOutside == oldShapeOutside)
+        return;
+
+    if (shapeOutside) {
+        ExclusionShapeOutsideInfo* exclusionShapeOutsideInfo = ExclusionShapeOutsideInfo::ensureInfoForRenderBox(this);
+        exclusionShapeOutsideInfo->dirtyShapeSize();
+    } else
+        ExclusionShapeOutsideInfo::removeInfoForRenderBox(this);
+}
+#endif
+
 void RenderBox::updateFromStyle()
 {
     RenderBoxModelObject::updateFromStyle();
index 27bc840..ec3bd6d 100644 (file)
@@ -26,6 +26,9 @@
 #include "RenderBoxModelObject.h"
 #include "RenderOverflow.h"
 #include "ScrollTypes.h"
+#if ENABLE(CSS_EXCLUSIONS)
+#include "ExclusionShapeOutsideInfo.h"
+#endif
 
 namespace WebCore {
 
@@ -571,6 +574,13 @@ public:
     virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
     static void reportStaticMembersMemoryUsage(MemoryInstrumentation*);
 
+#if ENABLE(CSS_EXCLUSIONS)
+    ExclusionShapeOutsideInfo* exclusionShapeOutsideInfo() const
+    {
+        return style()->shapeOutside() && ExclusionShapeOutsideInfo::isInfoEnabledForRenderBox(this) ? ExclusionShapeOutsideInfo::infoForRenderBox(this) : 0;
+    }
+#endif
+
 protected:
     virtual void willBeDestroyed();
 
@@ -606,6 +616,10 @@ protected:
     RenderObject* splitAnonymousBoxesAroundChild(RenderObject* beforeChild);
  
 private:
+#if ENABLE(CSS_EXCLUSIONS)
+    void updateExclusionShapeOutsideInfoAfterStyleChange(const ExclusionShapeValue* shapeOutside, const ExclusionShapeValue* oldShapeOutside);
+#endif
+
     bool fixedElementLaysOutRelativeToFrame(Frame*, FrameView*) const;
 
     bool includeVerticalScrollbarSize() const;