[CSSRegions] Parse -webkit-content-order property
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jul 2011 00:29:55 +0000 (00:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jul 2011 00:29:55 +0000 (00:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=63897

Patch by Mihnea Ovidenie <mihnea@adobe.com> on 2011-07-13
Reviewed by David Hyatt.

Source/WebCore:

Test: fast/regions/webkit-content-order-parsing.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSPropertyNames.in:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::regionIndex):
(WebCore::InheritedFlags::setRegionIndex):
(WebCore::InheritedFlags::initialRegionIndex):
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):
* rendering/style/StyleRareNonInheritedData.h:

LayoutTests:

* fast/regions/script-tests/webkit-content-order-parsing.js: Added.
* fast/regions/webkit-content-order-parsing-expected.txt: Added.
* fast/regions/webkit-content-order-parsing.html: Added.

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/regions/script-tests/webkit-content-order-parsing.js [new file with mode: 0644]
LayoutTests/fast/regions/webkit-content-order-parsing-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/webkit-content-order-parsing.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
Source/WebCore/rendering/style/StyleRareNonInheritedData.h

index d7a709a70f852c633deccdf05167fe26297672bd..3d14db81a9eb3ea43a4dd6796faf07cc0aa620ba 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-13  Mihnea Ovidenie  <mihnea@adobe.com>
+
+        [CSSRegions] Parse -webkit-content-order property
+        https://bugs.webkit.org/show_bug.cgi?id=63897
+
+        Reviewed by David Hyatt.
+
+        * fast/regions/script-tests/webkit-content-order-parsing.js: Added.
+        * fast/regions/webkit-content-order-parsing-expected.txt: Added.
+        * fast/regions/webkit-content-order-parsing.html: Added.
+
 2011-07-13  Michael Saboff  <msaboff@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=64202
diff --git a/LayoutTests/fast/regions/script-tests/webkit-content-order-parsing.js b/LayoutTests/fast/regions/script-tests/webkit-content-order-parsing.js
new file mode 100644 (file)
index 0000000..f3a048d
--- /dev/null
@@ -0,0 +1,68 @@
+description('Tests parsing of webkit-content-order property');
+
+var webkitContentOrderProperty = "-webkit-content-order";
+
+function testCSSText(declaration) {
+    var div = document.createElement("div");
+    div.setAttribute("style", declaration);
+    return div.style.webkitContentOrder;
+}
+
+function testComputedStyle(declaration) {
+    var div = document.createElement("div");
+    document.body.appendChild(div);
+    div.style.setProperty(webkitContentOrderProperty, declaration);
+
+    var contentComputedValue = getComputedStyle(div).getPropertyValue(webkitContentOrderProperty);
+    document.body.removeChild(div);
+    return contentComputedValue;
+}
+
+function testNotInherited(parentValue, childValue) {
+    var parentDiv = document.createElement("div");
+    document.body.appendChild(parentDiv);
+    parentDiv.style.setProperty(webkitContentOrderProperty, parentValue);
+
+    var childDiv = document.createElement("div");
+    parentDiv.appendChild(childDiv);
+    childDiv.style.setProperty(webkitContentOrderProperty, childValue);
+
+    var childWebKitFlowComputedValue = getComputedStyle(childDiv).getPropertyValue(webkitContentOrderProperty);
+
+    parentDiv.removeChild(childDiv);
+    document.body.removeChild(parentDiv);
+
+    return childWebKitFlowComputedValue;
+}
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': auto")', "");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': initial")', "initial");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': inherit")', "inherit");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': 1")', "1");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': 0")', "0");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': -1")', "-1");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': 2147483647")', "2147483647");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': 2147483648")', "2147483648");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': -2147483648")', "-2147483648");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': -2147483649")', "-2147483649");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': 12.5")', "");
+shouldBeEqualToString('testCSSText("' + webkitContentOrderProperty + ': 1px")', "");
+
+shouldBeEqualToString('testComputedStyle("auto")', "0");
+shouldBeEqualToString('testComputedStyle("initial")', "0");
+shouldBeEqualToString('testComputedStyle("inherit")', "0");
+shouldBeEqualToString('testComputedStyle("1")', "1");
+shouldBeEqualToString('testComputedStyle("0")', "0");
+shouldBeEqualToString('testComputedStyle("-1")', "-1");
+shouldBeEqualToString('testComputedStyle("2147483647")', "2147483647");
+shouldBeEqualToString('testComputedStyle("2147483648")', "2147483647");
+shouldBeEqualToString('testComputedStyle("-2147483648")', "-2147483648");
+shouldBeEqualToString('testComputedStyle("-2147483649")', "-2147483648");
+shouldBeEqualToString('testComputedStyle("12.5")', "0");
+shouldBeEqualToString('testComputedStyle("1px")', "0");
+
+shouldBeEqualToString('testNotInherited("0", "0")', "0");
+shouldBeEqualToString('testNotInherited("0", "1")', "1");
+shouldBeEqualToString('testNotInherited("1", "0")', "0");
+shouldBeEqualToString('testNotInherited("1", "2")', "2");
+
+successfullyParsed = true;
diff --git a/LayoutTests/fast/regions/webkit-content-order-parsing-expected.txt b/LayoutTests/fast/regions/webkit-content-order-parsing-expected.txt
new file mode 100644 (file)
index 0000000..532495d
--- /dev/null
@@ -0,0 +1,37 @@
+Tests parsing of webkit-content-order property
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testCSSText("-webkit-content-order: auto") is ""
+PASS testCSSText("-webkit-content-order: initial") is "initial"
+PASS testCSSText("-webkit-content-order: inherit") is "inherit"
+PASS testCSSText("-webkit-content-order: 1") is "1"
+PASS testCSSText("-webkit-content-order: 0") is "0"
+PASS testCSSText("-webkit-content-order: -1") is "-1"
+PASS testCSSText("-webkit-content-order: 2147483647") is "2147483647"
+PASS testCSSText("-webkit-content-order: 2147483648") is "2147483648"
+PASS testCSSText("-webkit-content-order: -2147483648") is "-2147483648"
+PASS testCSSText("-webkit-content-order: -2147483649") is "-2147483649"
+PASS testCSSText("-webkit-content-order: 12.5") is ""
+PASS testCSSText("-webkit-content-order: 1px") is ""
+PASS testComputedStyle("auto") is "0"
+PASS testComputedStyle("initial") is "0"
+PASS testComputedStyle("inherit") is "0"
+PASS testComputedStyle("1") is "1"
+PASS testComputedStyle("0") is "0"
+PASS testComputedStyle("-1") is "-1"
+PASS testComputedStyle("2147483647") is "2147483647"
+PASS testComputedStyle("2147483648") is "2147483647"
+PASS testComputedStyle("-2147483648") is "-2147483648"
+PASS testComputedStyle("-2147483649") is "-2147483648"
+PASS testComputedStyle("12.5") is "0"
+PASS testComputedStyle("1px") is "0"
+PASS testNotInherited("0", "0") is "0"
+PASS testNotInherited("0", "1") is "1"
+PASS testNotInherited("1", "0") is "0"
+PASS testNotInherited("1", "2") is "2"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/regions/webkit-content-order-parsing.html b/LayoutTests/fast/regions/webkit-content-order-parsing.html
new file mode 100644 (file)
index 0000000..06b2f01
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/webkit-content-order-parsing.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 14b001df08e1dd4d0a70aaaff73cc3b753fd6efc..1cbba1bff16fc3eaf57d2e26445afb0724be5625 100644 (file)
@@ -1,3 +1,30 @@
+2011-07-13  Mihnea Ovidenie  <mihnea@adobe.com>
+
+        [CSSRegions] Parse -webkit-content-order property
+        https://bugs.webkit.org/show_bug.cgi?id=63897
+
+        Reviewed by David Hyatt.
+
+        Test: fast/regions/webkit-content-order-parsing.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSPropertyNames.in:
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::diff):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::regionIndex):
+        (WebCore::InheritedFlags::setRegionIndex):
+        (WebCore::InheritedFlags::initialRegionIndex):
+        * rendering/style/StyleRareNonInheritedData.cpp:
+        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+        (WebCore::StyleRareNonInheritedData::operator==):
+        * rendering/style/StyleRareNonInheritedData.h:
+
 2011-07-13  James Robinson  <jamesr@chromium.org>
 
         Reviewed by Kenneth Russell.
index c98e8f2da8d5a949efa7f00da10c9b0ccb04b70a..b7797642d715f297753c76843de415b44075043f 100644 (file)
@@ -248,6 +248,7 @@ static const int computedProperties[] = {
     CSSPropertyWebkitWritingMode
 #if ENABLE(CSS_REGIONS)
     , CSSPropertyWebkitFlow
+    , CSSPropertyWebkitContentOrder
 #endif
 #if ENABLE(SVG)
     ,
@@ -1667,6 +1668,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             if (style->flowThread().isNull())
                 return primitiveValueCache->createIdentifierValue(CSSValueAuto);
             return primitiveValueCache->createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
+        case CSSPropertyWebkitContentOrder:
+            return primitiveValueCache->createValue(style->regionIndex(), CSSPrimitiveValue::CSS_NUMBER);
 #endif
         /* Shorthand properties, currently not supported see bug 13658*/
         case CSSPropertyBackground:
index 51db658910b9eeb2c6a5d1cc0038a7c2a902166e..71d604e1c6b9be2a51e35cd64ede877abd49eda4 100644 (file)
@@ -1591,6 +1591,9 @@ bool CSSParser::parseValue(int propId, bool important)
 #if ENABLE(CSS_REGIONS)
     case CSSPropertyWebkitFlow:
         return parseFlowThread(propId, important);
+    case CSSPropertyWebkitContentOrder:
+        validPrimitive = validUnit(value, FInteger, m_strict);
+        break;
 #endif
     case CSSPropertyWebkitUserDrag: // auto | none | element
         if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueElement)
index ee771df200f13ebed22cca8e332c4d44bb4ffca4..c14cc3cd268f5586c99c82dc0b746ab66358feba 100644 (file)
@@ -328,6 +328,7 @@ z-index
 -webkit-user-select
 #if defined(ENABLE_CSS_REGIONS) && ENABLE_CSS_REGIONS
 -webkit-flow
+-webkit-content-order
 #endif
 #if defined(ENABLE_CSS_EXCLUSIONS) && ENABLE_CSS_EXCLUSIONS
 -webkit-wrap-shape
index d0cdfab83a7d96ca4b7054ee9cf71846a66e8b6e..e3fb4f3889ffd9c72278a9a64a5e3c734ff5cfcd 100644 (file)
@@ -4892,6 +4892,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         else
             m_style->setFlowThread(primitiveValue->getStringValue());
         return;
+    case CSSPropertyWebkitContentOrder:
+        HANDLE_INHERIT_AND_INITIAL(regionIndex, RegionIndex);
+        m_style->setRegionIndex(clampToInteger(primitiveValue->getDoubleValue()));
+        return;
 #endif
     case CSSPropertyWebkitMarqueeDirection:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(marqueeDirection, MarqueeDirection)
index 1fc99a30e23ebec5312ce48d40f26b8ac8bf8b3c..723d3e5fa28e38e45caf04f862361a815dcb91e1 100644 (file)
@@ -347,7 +347,8 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
 
 #if ENABLE(CSS_REGIONS)
         if (rareNonInheritedData->m_flowThread != other->rareNonInheritedData->m_flowThread
-            || rareNonInheritedData->m_regionThread != other->rareNonInheritedData->m_regionThread)
+            || rareNonInheritedData->m_regionThread != other->rareNonInheritedData->m_regionThread
+            || rareNonInheritedData->m_regionIndex != other->rareNonInheritedData->m_regionIndex)
             return StyleDifferenceLayout;
 #endif
         if (rareNonInheritedData->m_deprecatedFlexibleBox.get() != other->rareNonInheritedData->m_deprecatedFlexibleBox.get()
index d0be2d5fbcc0f40254483b80ecacb06eba00aab3..69978e59665f0a431b9d9ac150da0e30041c1b10 100644 (file)
@@ -746,6 +746,7 @@ public:
 #if ENABLE(CSS_REGIONS)
     const AtomicString& flowThread() const { return rareNonInheritedData->m_flowThread; }
     const AtomicString& regionThread() const { return rareNonInheritedData->m_regionThread; }
+    int regionIndex() const { return rareNonInheritedData->m_regionIndex; }
 #endif
 
     // Apple-specific property getter methods
@@ -1099,6 +1100,7 @@ public:
 #if ENABLE(CSS_REGIONS)
     void setFlowThread(const AtomicString& flowThread) { SET_VAR(rareNonInheritedData, m_flowThread, flowThread); }
     void setRegionThread(const AtomicString& regionThread) { SET_VAR(rareNonInheritedData, m_regionThread, regionThread); }
+    void setRegionIndex(int regionIndex) { SET_VAR(rareNonInheritedData, m_regionIndex, regionIndex); }
 #endif
 
     // Apple-specific property setters
@@ -1343,6 +1345,7 @@ public:
 #if ENABLE(CSS_REGIONS)
     static const AtomicString& initialFlowThread() { return nullAtom; }
     static const AtomicString& initialRegionThread() { return nullAtom; }
+    static int initialRegionIndex() { return 0; }
 #endif
 
     // Keep these at the end.
index a7428f8ccc1a97c3e5378428f3cbc6aa561a4731..aeec0b2363a9c50a1fb9b9012f74da51b82f2e1d 100644 (file)
@@ -58,6 +58,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData()
 #if ENABLE(CSS_REGIONS)
     , m_flowThread(RenderStyle::initialFlowThread())
     , m_regionThread(RenderStyle::initialRegionThread())
+    , m_regionIndex(RenderStyle::initialRegionIndex())
 #endif
 #if ENABLE(CSS_EXCLUSIONS)
     , m_wrapShape(RenderStyle::initialWrapShape())
@@ -104,6 +105,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInherited
 #if ENABLE(CSS_REGIONS)
     , m_flowThread(o.m_flowThread)
     , m_regionThread(o.m_regionThread)
+    , m_regionIndex(o.m_regionIndex)
 #endif
 #if ENABLE(CSS_EXCLUSIONS)
     , m_wrapShape(o.m_wrapShape)
@@ -157,6 +159,7 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
 #if ENABLE(CSS_REGIONS)
         && (m_flowThread == o.m_flowThread)
         && (m_regionThread == o.m_regionThread)
+        && (m_regionIndex == o.m_regionIndex)
 #endif
 #if ENABLE(CSS_EXCLUSIONS)
         && (m_wrapShape == o.m_wrapShape)
index 7a1c8a6e307aceedb0b2df673826175e31d51975..78b7d223143ba1952d46fb0eb9540ba0649c6839 100644 (file)
@@ -135,6 +135,7 @@ public:
 #if ENABLE(CSS_REGIONS)
     AtomicString m_flowThread;
     AtomicString m_regionThread;
+    int m_regionIndex;
 #endif
 
 #if ENABLE(CSS_EXCLUSIONS)