[CSSRegions]Parse content: -webkit-from-flow
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jul 2011 17:29:10 +0000 (17:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jul 2011 17:29:10 +0000 (17:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=63133

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

Source/WebCore:

Test: fast/regions/content-webkit-from-flow-parsing.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::contentToCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseContent):
(WebCore::CSSParser::parseFromFlowContent):
* css/CSSParser.h:
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::cleanup):
(WebCore::CSSPrimitiveValue::getStringValue):
(WebCore::CSSPrimitiveValue::cssText):
* css/CSSPrimitiveValue.h:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::regionThread):
(WebCore::InheritedFlags::setRegionThread):
(WebCore::InheritedFlags::initialRegionThread):
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):
* rendering/style/StyleRareNonInheritedData.h:

LayoutTests:

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

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/regions/content-webkit-from-flow-parsing-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/content-webkit-from-flow-parsing.html [new file with mode: 0644]
LayoutTests/fast/regions/script-tests/content-webkit-from-flow-parsing.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSPrimitiveValue.cpp
Source/WebCore/css/CSSPrimitiveValue.h
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 76be098755a4e0d82574e7b5e33ba9e99f3ac21f..b31228d196f5226840f9e6625784ed7481ab3d06 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-08  Mihnea Ovidenie  <mihnea@adobe.com>
+
+        [CSSRegions]Parse content: -webkit-from-flow
+        https://bugs.webkit.org/show_bug.cgi?id=63133
+
+        Reviewed by David Hyatt.
+
+        * fast/regions/content-webkit-from-flow-parsing-expected.txt: Added.
+        * fast/regions/content-webkit-from-flow-parsing.html: Added.
+        * fast/regions/script-tests/content-webkit-from-flow-parsing.js: Added.
+
 2011-07-08  Vsevolod Vlasov  <vsevik@chromium.org>
 
         REGRESSION (r90557): http/tests/inspector/network/network-embed.html fails
diff --git a/LayoutTests/fast/regions/content-webkit-from-flow-parsing-expected.txt b/LayoutTests/fast/regions/content-webkit-from-flow-parsing-expected.txt
new file mode 100644 (file)
index 0000000..18ff13b
--- /dev/null
@@ -0,0 +1,38 @@
+Tests being able to set content to -webkit-from-flow
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testCSSText("content: -webkit-from-flow('first-flow')") is "-webkit-from-flow(first-flow)"
+PASS testCSSText("content: -webkit-from-flow('first flow')") is "-webkit-from-flow('first flow')"
+PASS testCSSText("content: -webkit-from-flow('auto')") is "-webkit-from-flow(auto)"
+PASS testCSSText("content: -webkit-from-flow(auto)") is ""
+PASS testCSSText("content: -webkit-from-flow(initial)") is ""
+PASS testCSSText("content: -webkit-from-flow(inherit)") is ""
+PASS testCSSText("content: -webkit-from-flow()") is ""
+PASS testCSSText("content: -webkit-from-flow('')") is "-webkit-from-flow('')"
+PASS testCSSText("content: ;") is ""
+PASS testCSSText("content: -webkit-from-flow(1)") is ""
+PASS testCSSText("content: -webkit-from-flow(1.2)") is ""
+PASS testCSSText("content: -webkit-from-flow(-1)") is ""
+PASS testCSSText("content: -webkit-from-flow(12px)") is ""
+PASS testCSSText("content: -webkit-from-flow(first flow)") is ""
+PASS testCSSText("content: -webkit-from-flow(first-flow)") is ""
+PASS testComputedStyle("'first-flow'") is "first-flow"
+PASS testComputedStyle("'first flow'") is "'first flow'"
+PASS testComputedStyle("'auto'") is "auto"
+PASS testComputedStyle("auto") is ""
+PASS testComputedStyle("initial") is ""
+PASS testComputedStyle("inherit") is ""
+PASS testComputedStyle("") is ""
+PASS testComputedStyle("1") is ""
+PASS testComputedStyle("1.2") is ""
+PASS testComputedStyle("-1") is ""
+PASS testComputedStyle("12px") is ""
+PASS testComputedStyle("''") is "''"
+PASS testComputedStyle("first flow") is ""
+PASS testComputedStyle("first-flow") is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/regions/content-webkit-from-flow-parsing.html b/LayoutTests/fast/regions/content-webkit-from-flow-parsing.html
new file mode 100644 (file)
index 0000000..6a2a6fb
--- /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/content-webkit-from-flow-parsing.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/regions/script-tests/content-webkit-from-flow-parsing.js b/LayoutTests/fast/regions/script-tests/content-webkit-from-flow-parsing.js
new file mode 100644 (file)
index 0000000..84ee7c6
--- /dev/null
@@ -0,0 +1,50 @@
+description('Tests being able to set content to -webkit-from-flow');
+
+function testCSSText(declaration) {
+    var div = document.createElement("div");
+    div.setAttribute("style", declaration);
+    return div.style.content;
+}
+
+function testComputedStyle(declaration) {
+    var div = document.createElement("div");
+    document.body.appendChild(div);
+    div.style.setProperty("content", declaration);
+
+    var contentComputedValue = getComputedStyle(div).getPropertyValue("content");
+    document.body.removeChild(div);
+    return contentComputedValue;
+}
+
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(\'first-flow\')")', "-webkit-from-flow(first-flow)");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(\'first flow\')")', "-webkit-from-flow('first flow')");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(\'auto\')")', "-webkit-from-flow(auto)");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(auto)")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(initial)")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(inherit)")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow()")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(\'\')")', "-webkit-from-flow('')");
+shouldBeEqualToString('testCSSText("content: ;")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(1)")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(1.2)")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(-1)")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(12px)")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(first flow)")', "");
+shouldBeEqualToString('testCSSText("content: -webkit-from-flow(first-flow)")', "");
+
+shouldBeEqualToString('testComputedStyle("\'first-flow\'")', "first-flow");
+shouldBeEqualToString('testComputedStyle("\'first flow\'")', "'first flow'");
+shouldBeEqualToString('testComputedStyle("\'auto\'")', "auto");
+shouldBeEqualToString('testComputedStyle("auto")', "");
+shouldBeEqualToString('testComputedStyle("initial")', "");
+shouldBeEqualToString('testComputedStyle("inherit")', "");
+shouldBeEqualToString('testComputedStyle("")', "");
+shouldBeEqualToString('testComputedStyle("1")', "");
+shouldBeEqualToString('testComputedStyle("1.2")', "");
+shouldBeEqualToString('testComputedStyle("-1")', "");
+shouldBeEqualToString('testComputedStyle("12px")', "");
+shouldBeEqualToString('testComputedStyle("\'\'")', "''");
+shouldBeEqualToString('testComputedStyle("first flow")', "");
+shouldBeEqualToString('testComputedStyle("first-flow")', "");
+
+successfullyParsed = true;
index a4a540885ef8c6d3411874c111c315edfce5ae32..985adcd64e55e118496217b5e09c269206aae04b 100644 (file)
@@ -1,3 +1,36 @@
+2011-07-08  Mihnea Ovidenie  <mihnea@adobe.com>
+
+        [CSSRegions]Parse content: -webkit-from-flow
+        https://bugs.webkit.org/show_bug.cgi?id=63133
+
+        Reviewed by David Hyatt.
+
+        Test: fast/regions/content-webkit-from-flow-parsing.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::contentToCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseContent):
+        (WebCore::CSSParser::parseFromFlowContent):
+        * css/CSSParser.h:
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::cleanup):
+        (WebCore::CSSPrimitiveValue::getStringValue):
+        (WebCore::CSSPrimitiveValue::cssText):
+        * css/CSSPrimitiveValue.h:
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::diff):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::regionThread):
+        (WebCore::InheritedFlags::setRegionThread):
+        (WebCore::InheritedFlags::initialRegionThread):
+        * rendering/style/StyleRareNonInheritedData.cpp:
+        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+        (WebCore::StyleRareNonInheritedData::operator==):
+        * rendering/style/StyleRareNonInheritedData.h:
+
 2011-07-08  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: NetworkPanel search failed if the matched sting is in the query part of url
index 6f55ac8f9a0fb4ee89b9e73b7b263f3966a52209..22280e1b99a8d9902233d975e2a4d482bc97363f 100644 (file)
@@ -767,6 +767,10 @@ static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style, CSSPrimi
         } else if (contentData->isText())
             list->append(primitiveValueCache->createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
     }
+#if ENABLE(CSS_REGIONS)
+    if (!style->regionThread().isNull())
+        list->append(primitiveValueCache->createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
+#endif
     return list.release();
 }
 
index acf77522693148828913edb5f5014a439f776b16..19cdc02a471e33ae089dbaf2ca55704fd95915a0 100644 (file)
@@ -2657,6 +2657,12 @@ bool CSSParser::parseContent(int propId, bool important)
             } else if (isGeneratedImageValue(val)) {
                 if (!parseGeneratedImage(parsedValue))
                     return false;
+#if ENABLE(CSS_REGIONS)
+            } else if (equalIgnoringCase(val->function->name, "-webkit-from-flow(")) {
+                parsedValue = parseFromFlowContent(args);
+                if (!parsedValue)
+                    return false;
+#endif
             } else
                 return false;
         } else if (val->unit == CSSPrimitiveValue::CSS_IDENT) {
@@ -5865,6 +5871,22 @@ bool CSSParser::parseFlowThread(int propId, bool important)
 
     return false;
 }
+
+// The region name is now specified as an argument to the content property:
+// content: from-flow(flow_thread_name)
+PassRefPtr<CSSValue> CSSParser::parseFromFlowContent(CSSParserValueList* args)
+{
+    // It should be only one name for the region thread.
+    if (args->size() != 1)
+        return 0;
+
+    CSSParserValue* argFlowThreadName = args->current();
+
+    if (argFlowThreadName->unit != CSSPrimitiveValue::CSS_STRING)
+        return 0;
+
+    return CSSPrimitiveValue::create(argFlowThreadName->string, CSSPrimitiveValue::CSS_FROM_FLOW);
+}
 #endif
 
 bool CSSParser::parseTransformOrigin(int propId, int& propId1, int& propId2, int& propId3, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3)
index c175cabc8e0d0f3eb29cd4bc8432c90396bc9caa..c8b4ad36250e9f726bd9a8ad3df113f0456423a6 100644 (file)
@@ -158,6 +158,7 @@ namespace WebCore {
 
 #if ENABLE(CSS_REGIONS)
         bool parseFlowThread(int propId, bool important);
+        PassRefPtr<CSSValue> parseFromFlowContent(CSSParserValueList*);
 #endif
         // CSS3 Parsing Routines (for properties specific to CSS3)
         bool parseShadow(int propId, bool important);
index be889abca7bb2470516275a6838a8baabd9ca513..3ec7f5536c5aff74bd815ab7c7ba20e812a0aa8b 100644 (file)
@@ -221,6 +221,9 @@ void CSSPrimitiveValue::cleanup()
         case CSS_STRING:
         case CSS_URI:
         case CSS_ATTR:
+#if ENABLE(CSS_REGIONS)
+        case CSS_FROM_FLOW:
+#endif
         case CSS_PARSER_HEXCOLOR:
             if (m_value.string)
                 m_value.string->deref();
@@ -504,6 +507,9 @@ String CSSPrimitiveValue::getStringValue(ExceptionCode& ec) const
         case CSS_STRING:
         case CSS_ATTR:
         case CSS_URI:
+#if ENABLE(CSS_REGIONS)
+        case CSS_FROM_FLOW:
+#endif
             return m_value.string;
         case CSS_IDENT:
             return valueOrPropertyName(m_value.ident);
@@ -684,6 +690,11 @@ String CSSPrimitiveValue::cssText() const
         case CSS_STRING:
             text = quoteCSSStringIfNeeded(m_value.string);
             break;
+#if ENABLE(CSS_REGIONS)
+        case CSS_FROM_FLOW:
+            text = "-webkit-from-flow(" + quoteCSSStringIfNeeded(m_value.string) + ")";
+            break;
+#endif
         case CSS_URI:
             text = "url(" + quoteCSSURLIfNeeded(m_value.string) + ")";
             break;
index 907d0b940a4835a4f6b6cbe81dc6afd3068b2b72..ab9033cc3dfb92dc2fcb6ff591b62c71a65762ba 100644 (file)
@@ -94,7 +94,8 @@ public:
         CSS_REMS = 108,
 
         // This is used internally for counter names (as opposed to counter values)
-        CSS_COUNTER_NAME = 109
+        CSS_COUNTER_NAME = 109,
+        CSS_FROM_FLOW = 110
     };
     
     // This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY for frequencies.
index 6f84faef7f03557ff7c1f66b88789e7e4b55ab21..c3f98bf24021a58fa1651634d9f7301a380ff6d3 100644 (file)
@@ -4140,6 +4140,16 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         CSSValueList* list = static_cast<CSSValueList*>(value);
         int len = list->length();
 
+#if ENABLE(CSS_REGIONS)
+        if (len == 1 && list->itemWithoutBoundsCheck(0)->isPrimitiveValue()) {
+            CSSPrimitiveValue* contentValue = static_cast<CSSPrimitiveValue*>(list->itemWithoutBoundsCheck(0));
+            if (contentValue->primitiveType() == CSSPrimitiveValue::CSS_FROM_FLOW) {
+                m_style->setRegionThread(contentValue->getStringValue().impl());
+                return;
+            }
+        }
+#endif
+
         bool didSet = false;
         for (int i = 0; i < len; i++) {
             CSSValue* item = list->itemWithoutBoundsCheck(i);
@@ -4147,10 +4157,10 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                 m_style->setContent(static_cast<CSSImageGeneratorValue*>(item)->generatedImage(), didSet);
                 didSet = true;
             }
-            
+
             if (!item->isPrimitiveValue())
                 continue;
-            
+
             CSSPrimitiveValue* contentValue = static_cast<CSSPrimitiveValue*>(item);
             switch (contentValue->primitiveType()) {
             case CSSPrimitiveValue::CSS_STRING:
index c7aa84678a31e92279443b8b7d1561abf8af1f8a..3c0325c788e64ab9f8213cc22753debf6e77122c 100644 (file)
@@ -345,8 +345,9 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
             return StyleDifferenceLayout;
 
 #if ENABLE(CSS_REGIONS)
-        if (rareNonInheritedData->m_flowThread != other->rareNonInheritedData->m_flowThread)
-             return StyleDifferenceLayout;
+        if (rareNonInheritedData->m_flowThread != other->rareNonInheritedData->m_flowThread
+            || rareNonInheritedData->m_regionThread != other->rareNonInheritedData->m_regionThread)
+            return StyleDifferenceLayout;
 #endif
         if (rareNonInheritedData->m_deprecatedFlexibleBox.get() != other->rareNonInheritedData->m_deprecatedFlexibleBox.get()
             && *rareNonInheritedData->m_deprecatedFlexibleBox.get() != *other->rareNonInheritedData->m_deprecatedFlexibleBox.get())
index ea864292f09615f06be9e36fec7b6d71b8493d4a..3bed3055afb9d29a22097042a9e11ca33f42e4c6 100644 (file)
@@ -745,6 +745,7 @@ public:
 
 #if ENABLE(CSS_REGIONS)
     const AtomicString& flowThread() const { return rareNonInheritedData->m_flowThread; }
+    const AtomicString& regionThread() const { return rareNonInheritedData->m_regionThread; }
 #endif
 
     // Apple-specific property getter methods
@@ -1097,6 +1098,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); }
 #endif
 
     // Apple-specific property setters
@@ -1330,6 +1332,7 @@ public:
 
 #if ENABLE(CSS_REGIONS)
     static const AtomicString& initialFlowThread() { return nullAtom; }
+    static const AtomicString& initialRegionThread() { return nullAtom; }
 #endif
 
     // Keep these at the end.
index 1f491d318ece622bc3c5e262445b0157b4f9c992..9fd310e62011cf653eea41d122947e2e4b2a569c 100644 (file)
@@ -57,6 +57,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData()
     , m_pageSizeType(PAGE_SIZE_AUTO)
 #if ENABLE(CSS_REGIONS)
     , m_flowThread(RenderStyle::initialFlowThread())
+    , m_regionThread(RenderStyle::initialRegionThread())
 #endif
 {
 }
@@ -99,6 +100,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInherited
     , m_pageSizeType(o.m_pageSizeType)
 #if ENABLE(CSS_REGIONS)
     , m_flowThread(o.m_flowThread)
+    , m_regionThread(o.m_regionThread)
 #endif
 {
 }
@@ -148,6 +150,7 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
         && (m_pageSizeType == o.m_pageSizeType)
 #if ENABLE(CSS_REGIONS)
         && (m_flowThread == o.m_flowThread)
+        && (m_regionThread == o.m_regionThread)
 #endif
         ;
 }
index a4236e838051754e5564abdc2a60e26ba4c8fa01..10094ab232412ac7dad3ffe00acbccb3361f679e 100644 (file)
@@ -133,6 +133,7 @@ public:
 
 #if ENABLE(CSS_REGIONS)
     AtomicString m_flowThread;
+    AtomicString m_regionThread;
 #endif
 
 private: