Title: [107650] trunk
Revision
107650
Author
[email protected]
Date
2012-02-13 17:34:31 -0800 (Mon, 13 Feb 2012)

Log Message

Implement Element.webkitRegionOverflow

[CSSRegions][CSSOM] Implement Element.regionOverflow
https://bugs.webkit.org/show_bug.cgi?id=77863

Patch by Raul Hudea <[email protected]> on 2012-02-13
Reviewed by David Hyatt.

Source/WebCore:

On each layout, compute the overflowState for each region belonging to the flow thread

Tests: fast/regions/element-region-overflow-state-vertical-rl.html
       fast/regions/element-region-overflow-state.html

* dom/Element.cpp:
(WebCore::Element::webkitRegionOverflow):
(WebCore):
* dom/Element.h:
* dom/Element.idl:
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computeOverflow):
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::computeOverflowStateForRegions):
(WebCore):
* rendering/RenderFlowThread.h:
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::RenderRegion):
* rendering/RenderRegion.h:
(RenderRegion):
(WebCore::RenderRegion::regionState):
(WebCore::RenderRegion::setRegionState):

LayoutTests:

* fast/regions/element-region-overflow-state-expected.txt: Added.
* fast/regions/element-region-overflow-state-vertical-rl-expected.txt: Added.
* fast/regions/element-region-overflow-state-vertical-rl.html: Added.
* fast/regions/element-region-overflow-state.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107649 => 107650)


--- trunk/LayoutTests/ChangeLog	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/LayoutTests/ChangeLog	2012-02-14 01:34:31 UTC (rev 107650)
@@ -1,3 +1,17 @@
+2012-02-13  Raul Hudea  <[email protected]>
+
+        Implement Element.webkitRegionOverflow
+
+        [CSSRegions][CSSOM] Implement Element.regionOverflow
+        https://bugs.webkit.org/show_bug.cgi?id=77863
+
+        Reviewed by David Hyatt.
+
+        * fast/regions/element-region-overflow-state-expected.txt: Added.
+        * fast/regions/element-region-overflow-state-vertical-rl-expected.txt: Added.
+        * fast/regions/element-region-overflow-state-vertical-rl.html: Added.
+        * fast/regions/element-region-overflow-state.html: Added.
+
 2012-02-13  Tony Chang  <[email protected]>
 
         [chromium] Unreviewed, removing some tests that have been passing

Added: trunk/LayoutTests/fast/regions/element-region-overflow-state-expected.txt (0 => 107650)


--- trunk/LayoutTests/fast/regions/element-region-overflow-state-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/element-region-overflow-state-expected.txt	2012-02-14 01:34:31 UTC (rev 107650)
@@ -0,0 +1,33 @@
+Tests Element.webkitRegionOverflow attribute
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+  
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS regionOverflow('article') is "undefined"
+PASS regionOverflow('region_1') is "undefined"
+PASS regionOverflow('region_2') is "undefined"
+PASS regionOverflow('region_3') is "undefined"
+After first layout
+PASS regionOverflow('region_1') is "empty"
+PASS regionOverflow('region_2') is "empty"
+PASS regionOverflow('region_3') is "empty"
+Flow content
+PASS regionOverflow('region_1') is "overflow"
+PASS regionOverflow('region_2') is "fit"
+PASS regionOverflow('region_3') is "empty"
+Add more content
+PASS regionOverflow('region_1') is "overflow"
+PASS regionOverflow('region_2') is "overflow"
+PASS regionOverflow('region_3') is "fit"
+Add visual overflow
+PASS regionOverflow('region_1') is "overflow"
+PASS regionOverflow('region_2') is "overflow"
+PASS regionOverflow('region_3') is "overflow"
+Empty content
+PASS regionOverflow('region_1') is "empty"
+PASS regionOverflow('region_2') is "empty"
+PASS regionOverflow('region_3') is "empty"
+

Added: trunk/LayoutTests/fast/regions/element-region-overflow-state-vertical-rl-expected.txt (0 => 107650)


--- trunk/LayoutTests/fast/regions/element-region-overflow-state-vertical-rl-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/element-region-overflow-state-vertical-rl-expected.txt	2012-02-14 01:34:31 UTC (rev 107650)
@@ -0,0 +1,32 @@
+Tests Element.webkitRegionOverflow attribute
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+  
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS regionOverflow('article') is "undefined"
+PASS regionOverflow('region_1') is "undefined"
+PASS regionOverflow('region_2') is "undefined"
+PASS regionOverflow('region_3') is "undefined"
+PASS regionOverflow('region_1') is "empty"
+PASS regionOverflow('region_2') is "empty"
+PASS regionOverflow('region_3') is "empty"
+Flow content
+PASS regionOverflow('region_1') is "overflow"
+PASS regionOverflow('region_2') is "fit"
+PASS regionOverflow('region_3') is "empty"
+Add more content
+PASS regionOverflow('region_1') is "overflow"
+PASS regionOverflow('region_2') is "overflow"
+PASS regionOverflow('region_3') is "fit"
+Add visual overflow
+PASS regionOverflow('region_1') is "overflow"
+PASS regionOverflow('region_2') is "overflow"
+PASS regionOverflow('region_3') is "overflow"
+Empty content
+PASS regionOverflow('region_1') is "empty"
+PASS regionOverflow('region_2') is "empty"
+PASS regionOverflow('region_3') is "empty"
+

Added: trunk/LayoutTests/fast/regions/element-region-overflow-state-vertical-rl.html (0 => 107650)


--- trunk/LayoutTests/fast/regions/element-region-overflow-state-vertical-rl.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/element-region-overflow-state-vertical-rl.html	2012-02-14 01:34:31 UTC (rev 107650)
@@ -0,0 +1,122 @@
+<html>
+<head>
+<script src=""
+<style>
+html {-webkit-writing-mode: vertical-rl;}
+body { font-family: monospace; }
+
+#article {
+    -webkit-flow-into: article;
+    border: 2px solid black;
+}
+
+#region_1, #region_2, #region_3 {
+    -webkit-flow-from: no_article;
+    overflow:visible;
+    display:inline-block;
+    vertical-align:top;
+    margin:10px;
+}
+
+.block {
+   display:block;
+}
+
+#region_1 { height:110px; width:200px; border:1px solid #a0a0a0; }
+#region_2 { height:110px; width:200px; border:1px solid black }
+#region_3 { height:110px; width:200px; border:1px solid #a0a0a0; }
+
+</style>
+</head>
+<body>
+<div id="description" class="block"></div>
+<div id="article">
+    <div>
+        <div id="content" style="width: 396px; background-color: green;"></div>
+    </div>
+</div>
+
+<div id="region_1"></div>
+<div id="region_2"></div>
+<div id="region_3"></div>
+
+<div id="console" class="block"></div>
+
+<script>
+    description("Tests Element.webkitRegionOverflow attribute")
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+    }
+    function regionOverflow(id) {
+        var e = document.getElementById(id);
+        return e.webkitRegionOverflow;
+    }
+    function flowContent(flowName) {
+        var r = document.getElementById("region_1");
+        r.style.webkitFlowFrom = flowName;
+        r = document.getElementById("region_2");
+        r.style.webkitFlowFrom = flowName;
+        r = document.getElementById("region_3");
+        r.style.webkitFlowFrom = flowName;
+    }
+    function addVisualOverflow() {
+        var c = document.getElementById("article");
+        c.style.webkitBoxShadow="-30px 0px lime";
+    }
+    function addMoreContent() {
+        var c = document.getElementById("content");
+        c.style.width = 596;
+    }
+    function emptyContent() {
+
+    }
+    function test() {
+        shouldBeEqualToString("regionOverflow('article')", "undefined");
+        shouldBeEqualToString("regionOverflow('region_1')", "undefined");
+        shouldBeEqualToString("regionOverflow('region_2')", "undefined");
+        shouldBeEqualToString("regionOverflow('region_3')", "undefined");
+
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "empty");
+        shouldBeEqualToString("regionOverflow('region_2')", "empty");
+        shouldBeEqualToString("regionOverflow('region_3')", "empty");
+
+        debug("Flow content");
+        flowContent("article");
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_2')", "fit");
+        shouldBeEqualToString("regionOverflow('region_3')", "empty");
+
+        debug("Add more content");
+        addMoreContent();
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_2')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_3')", "fit");
+
+        debug("Add visual overflow");
+        addVisualOverflow();
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_2')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_3')", "overflow");
+
+        debug("Empty content");
+        flowContent("no_article");
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "empty");
+        shouldBeEqualToString("regionOverflow('region_2')", "empty");
+        shouldBeEqualToString("regionOverflow('region_3')", "empty");
+    }
+
+    window.addEventListener("load", test, false);
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/regions/element-region-overflow-state.html (0 => 107650)


--- trunk/LayoutTests/fast/regions/element-region-overflow-state.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/element-region-overflow-state.html	2012-02-14 01:34:31 UTC (rev 107650)
@@ -0,0 +1,113 @@
+<html>
+<head>
+<script src=""
+<style>
+#article {
+    -webkit-flow-into: article;
+    border: 2px solid black;
+}
+#region_1, #region_2, #region_3 {
+    -webkit-flow-from: no_article;
+    overflow:visible;
+    display:inline-block;
+    vertical-align:top;
+    margin:10px;
+}
+.block {
+   display:block;
+}
+#region_1 { height:110px; width:200px; }
+#region_2 { height:110px; width:200px; }
+#region_3 { height:110px; width:200px; }
+</style>
+</head>
+<body>
+<div id="description" class="block"></div>
+<div id="article">
+    <div>
+        <div id="content" style="height: 216px; background-color: green;"></div>
+    </div>
+</div>
+
+<div id="region_1"></div>
+<div id="region_2"></div>
+<div id="region_3"></div>
+
+<div id="console" class="block"></div>
+
+<script>
+    description("Tests Element.webkitRegionOverflow attribute")
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+    }
+    function regionOverflow(id) {
+        var e = document.getElementById(id);
+        return e.webkitRegionOverflow;
+    }
+    function flowContent(flowName) {
+        var r = document.getElementById("region_1");
+        r.style.webkitFlowFrom = flowName;
+        r = document.getElementById("region_2");
+        r.style.webkitFlowFrom = flowName;
+        r = document.getElementById("region_3");
+        r.style.webkitFlowFrom = flowName;
+    }
+    function addVisualOverflow() {
+        var c = document.getElementById("article");
+        c.style.webkitBoxShadow="0px 30px lime";
+    }
+    function addMoreContent() {
+        var c = document.getElementById("content");
+        c.style.height = 326;
+    }
+    function test() {
+        shouldBeEqualToString("regionOverflow('article')", "undefined");
+        shouldBeEqualToString("regionOverflow('region_1')", "undefined");
+        shouldBeEqualToString("regionOverflow('region_2')", "undefined");
+        shouldBeEqualToString("regionOverflow('region_3')", "undefined");
+
+        document.body.offsetTop; // force layout
+        debug("After first layout");
+
+        shouldBeEqualToString("regionOverflow('region_1')", "empty");
+        shouldBeEqualToString("regionOverflow('region_2')", "empty");
+        shouldBeEqualToString("regionOverflow('region_3')", "empty");
+
+        debug("Flow content");
+        flowContent("article");
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_2')", "fit");
+        shouldBeEqualToString("regionOverflow('region_3')", "empty");
+
+        debug("Add more content");
+        addMoreContent();
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_2')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_3')", "fit");
+
+        debug("Add visual overflow");
+        addVisualOverflow();
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_2')", "overflow");
+        shouldBeEqualToString("regionOverflow('region_3')", "overflow");
+
+        debug("Empty content");
+        flowContent("no_article");
+        document.body.offsetTop; // force layout
+
+        shouldBeEqualToString("regionOverflow('region_1')", "empty");
+        shouldBeEqualToString("regionOverflow('region_2')", "empty");
+        shouldBeEqualToString("regionOverflow('region_3')", "empty");
+    }
+
+    window.addEventListener("load", test, false);
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (107649 => 107650)


--- trunk/Source/WebCore/ChangeLog	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/ChangeLog	2012-02-14 01:34:31 UTC (rev 107650)
@@ -1,3 +1,35 @@
+2012-02-13  Raul Hudea  <[email protected]>
+
+        Implement Element.webkitRegionOverflow
+
+        [CSSRegions][CSSOM] Implement Element.regionOverflow
+        https://bugs.webkit.org/show_bug.cgi?id=77863
+
+        Reviewed by David Hyatt.
+
+        On each layout, compute the overflowState for each region belonging to the flow thread
+
+        Tests: fast/regions/element-region-overflow-state-vertical-rl.html
+               fast/regions/element-region-overflow-state.html
+
+        * dom/Element.cpp:
+        (WebCore::Element::webkitRegionOverflow):
+        (WebCore):
+        * dom/Element.h:
+        * dom/Element.idl:
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::computeOverflow):
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::computeOverflowStateForRegions):
+        (WebCore):
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::RenderRegion):
+        * rendering/RenderRegion.h:
+        (RenderRegion):
+        (WebCore::RenderRegion::regionState):
+        (WebCore::RenderRegion::setRegionState):
+
 2012-02-13  Alexey Proskuryakov  <[email protected]>
 
         File API IDLs are incorrect in Xcode project

Modified: trunk/Source/WebCore/dom/Element.cpp (107649 => 107650)


--- trunk/Source/WebCore/dom/Element.cpp	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-02-14 01:34:31 UTC (rev 107650)
@@ -57,6 +57,7 @@
 #include "NodeRenderingContext.h"
 #include "Page.h"
 #include "RenderLayer.h"
+#include "RenderRegion.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
 #include "Settings.h"
@@ -1989,6 +1990,28 @@
     return animController->animationsForRenderer(renderer());
 }
 
+const AtomicString& Element::webkitRegionOverflow() const
+{
+    if (renderer() && renderer()->isRenderRegion()) {
+        RenderRegion* region = toRenderRegion(renderer());
+        switch (region->regionState()) {
+        case RenderRegion::RegionFit:
+            DEFINE_STATIC_LOCAL(AtomicString, fitState, ("fit"));
+            return fitState;
+        case RenderRegion::RegionEmpty:
+            DEFINE_STATIC_LOCAL(AtomicString, emptyState, ("empty"));
+            return emptyState;
+        case RenderRegion::RegionOverflow:
+            DEFINE_STATIC_LOCAL(AtomicString, overflowState, ("overflow"));
+            return overflowState;
+        default:
+            break;
+        }
+    }
+    DEFINE_STATIC_LOCAL(AtomicString, undefinedState, ("undefined"));
+    return undefinedState;
+}
+
 #ifndef NDEBUG
 bool Element::fastAttributeLookupAllowed(const QualifiedName& name) const
 {

Modified: trunk/Source/WebCore/dom/Element.h (107649 => 107650)


--- trunk/Source/WebCore/dom/Element.h	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/dom/Element.h	2012-02-14 01:34:31 UTC (rev 107650)
@@ -402,6 +402,8 @@
 
     PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
 
+    const AtomicString& webkitRegionOverflow() const;
+
 protected:
     Element(const QualifiedName& tagName, Document* document, ConstructionType type)
         : ContainerNode(document, type)

Modified: trunk/Source/WebCore/dom/Element.idl (107649 => 107650)


--- trunk/Source/WebCore/dom/Element.idl	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/dom/Element.idl	2012-02-14 01:34:31 UTC (rev 107650)
@@ -134,6 +134,9 @@
         [V8EnabledAtRuntime] void webkitRequestFullScreen(in [Optional=DefaultIsUndefined] unsigned short flags);
 #endif
 
+        // CSS Regions API
+        readonly attribute DOMString webkitRegionOverflow;
+
 #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
         // Event handler DOM attributes
         attribute [NotEnumerable] EventListener onabort;

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (107649 => 107650)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-02-14 01:34:31 UTC (rev 107650)
@@ -1505,6 +1505,9 @@
 
     // Add visual overflow from theme.
     addVisualOverflowFromTheme();
+
+    if (isRenderFlowThread())
+        enclosingRenderFlowThread()->computeOverflowStateForRegions(oldClientAfterEdge);
 }
 
 void RenderBlock::addOverflowFromBlockChildren()

Modified: trunk/Source/WebCore/rendering/RenderFlowThread.cpp (107649 => 107650)


--- trunk/Source/WebCore/rendering/RenderFlowThread.cpp	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.cpp	2012-02-14 01:34:31 UTC (rev 107650)
@@ -872,4 +872,31 @@
     return m_namedFlow.get();
 }
 
+void RenderFlowThread::computeOverflowStateForRegions(LayoutUnit oldClientAfterEdge)
+{
+    LayoutUnit height = oldClientAfterEdge;
+    // FIXME: the visual overflow of middle region (if it is the last one to contain any content in a render flow thread)
+    // might not be taken into account because the render flow thread height is greater that that regions height + its visual overflow
+    // because of how computeLogicalHeight is implemented for RenderFlowThread (as a sum of all regions height).
+    // This means that the middle region will be marked as fit (even if it has visual overflow flowing into the next region)
+    if (hasRenderOverflow())
+        height = isHorizontalWritingMode() ? visualOverflowRect().maxY() : visualOverflowRect().maxX();
+
+    for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
+        RenderRegion* region = *iter;
+        if (!region->isValid()) {
+            region->setRegionState(RenderRegion::RegionUndefined);
+            continue;
+        }
+        LayoutUnit flowMin = height - (isHorizontalWritingMode() ? region->regionRect().y() : region->regionRect().x());
+        LayoutUnit flowMax = height - (isHorizontalWritingMode() ? region->regionRect().maxY() : region->regionRect().maxX());
+        RenderRegion::RegionState state = RenderRegion::RegionFit;
+        if (flowMin <= 0)
+            state = RenderRegion::RegionEmpty;
+        if (flowMax > 0)
+            state = RenderRegion::RegionOverflow;
+        region->setRegionState(state);
+    }
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderFlowThread.h (107649 => 107650)


--- trunk/Source/WebCore/rendering/RenderFlowThread.h	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.h	2012-02-14 01:34:31 UTC (rev 107650)
@@ -133,6 +133,7 @@
                                       const RenderRegion* oldStartRegion = 0, const RenderRegion* oldEndRegion = 0,
                                       const RenderRegion* newStartRegion = 0, const RenderRegion* newEndRegion = 0);
     WebKitNamedFlow* ensureNamedFlow();
+    void computeOverflowStateForRegions(LayoutUnit oldClientAfterEdge);
 
 private:
     virtual const char* renderName() const { return "RenderFlowThread"; }

Modified: trunk/Source/WebCore/rendering/RenderRegion.cpp (107649 => 107650)


--- trunk/Source/WebCore/rendering/RenderRegion.cpp	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/rendering/RenderRegion.cpp	2012-02-14 01:34:31 UTC (rev 107650)
@@ -47,6 +47,7 @@
     , m_parentFlowThread(0)
     , m_isValid(false)
     , m_hasCustomRegionStyle(false)
+    , m_regionState(RegionUndefined)
 {
 }
 

Modified: trunk/Source/WebCore/rendering/RenderRegion.h (107649 => 107650)


--- trunk/Source/WebCore/rendering/RenderRegion.h	2012-02-14 01:32:25 UTC (rev 107649)
+++ trunk/Source/WebCore/rendering/RenderRegion.h	2012-02-14 01:34:31 UTC (rev 107650)
@@ -81,6 +81,16 @@
     bool isLastRegion() const;
 
     void clearBoxStyleInRegion(const RenderBox*);
+
+    enum RegionState {
+        RegionUndefined,
+        RegionEmpty,
+        RegionFit,
+        RegionOverflow
+    };
+
+    RegionState regionState() const { return isValid() ? m_regionState : RegionUndefined; }
+    void setRegionState(RegionState regionState) { m_regionState = regionState; }
 private:
     virtual const char* renderName() const { return "RenderRegion"; }
 
@@ -109,6 +119,7 @@
 
     bool m_isValid;
     bool m_hasCustomRegionStyle;
+    RegionState m_regionState;
 };
 
 inline RenderRegion* toRenderRegion(RenderObject* object)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to