https://bugs.webkit.org/show_bug.cgi?id=71061
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Oct 2011 21:21:32 +0000 (21:21 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Oct 2011 21:21:32 +0000 (21:21 +0000)
[CSS Line Grid] Add support for parsing the line-grid property.

Source/WebCore:

New tests in fast/line-grid.

Reviewed by Dan Bernstein.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
* css/CSSPropertyNames.in:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::lineGrid):
(WebCore::InheritedFlags::setLineGrid):
(WebCore::InheritedFlags::initialLineGrid):
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):
* rendering/style/StyleRareInheritedData.h:

LayoutTests:

Reviewed by Dan Bernstein.

* fast/css/getComputedStyle/computed-style-expected.txt:
* fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* fast/line-grid: Added.
* fast/line-grid/line-grid-parsing-expected.txt: Added.
* fast/line-grid/line-grid-parsing.html: Added.
* fast/line-grid/script-tests: Added.
* fast/line-grid/script-tests/line-grid-parsing.js: Added.

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt
LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
LayoutTests/fast/line-grid/line-grid-parsing-expected.txt [new file with mode: 0644]
LayoutTests/fast/line-grid/line-grid-parsing.html [new file with mode: 0644]
LayoutTests/fast/line-grid/script-tests/line-grid-parsing.js [new file with mode: 0644]
LayoutTests/svg/css/getComputedStyle-basic-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h

index 653a950..37acb97 100755 (executable)
@@ -1,3 +1,19 @@
+2011-10-27  David Hyatt  <hyatt@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=71061
+        
+        [CSS Line Grid] Add support for parsing the line-grid property.
+
+        Reviewed by Dan Bernstein.
+
+        * fast/css/getComputedStyle/computed-style-expected.txt:
+        * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+        * fast/line-grid: Added.
+        * fast/line-grid/line-grid-parsing-expected.txt: Added.
+        * fast/line-grid/line-grid-parsing.html: Added.
+        * fast/line-grid/script-tests: Added.
+        * fast/line-grid/script-tests/line-grid-parsing.js: Added.
+
 2011-10-27  Fady Samuel  <fsamuel@chromium.org>
 
         iframes seem to occasionally doubly scale or scale incorrectly when pageScaleFactor != 1.0
index 4064638..9db009c 100644 (file)
@@ -152,6 +152,7 @@ zoom: 1;
 -webkit-line-box-contain: block inline replaced;
 -webkit-line-break: normal;
 -webkit-line-clamp: none;
+-webkit-line-grid: none;
 -webkit-locale: auto;
 -webkit-margin-before-collapse: collapse;
 -webkit-margin-after-collapse: collapse;
index afbce36..7b05375 100644 (file)
@@ -151,6 +151,7 @@ Computed style of an element whose parent's 'display' value is 'none':
     -webkit-line-box-contain: block inline replaced
     -webkit-line-break: normal
     -webkit-line-clamp: none
+    -webkit-line-grid: none
     -webkit-locale: auto
     -webkit-margin-before-collapse: collapse
     -webkit-margin-after-collapse: collapse
diff --git a/LayoutTests/fast/line-grid/line-grid-parsing-expected.txt b/LayoutTests/fast/line-grid/line-grid-parsing-expected.txt
new file mode 100644 (file)
index 0000000..c9935e0
--- /dev/null
@@ -0,0 +1,24 @@
+Test parsing of the CSS line-grid property.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS test("-webkit-line-grid: none") is "none"
+PASS test("-webkit-line-grid: first-grid") is "first-grid"
+PASS test("-webkit-line-grid: 'first grid'") is ""
+PASS test("-webkit-line-grid: ;") is ""
+PASS test("-webkit-line-grid: 1") is ""
+PASS test("-webkit-line-grid: 1.2") is ""
+PASS test("-webkit-line-grid: -1") is ""
+PASS test("-webkit-line-grid: 12px") is ""
+PASS testComputedStyle("none") is "none"
+PASS testComputedStyle("") is "none"
+PASS testComputedStyle("'first-flow'") is "none"
+PASS testComputedStyle("first-grid") is "first-grid"
+PASS testComputedStyle("12px") is "none"
+PASS testInherited("none") is "none"
+PASS testInherited("grid") is "grid"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/line-grid/line-grid-parsing.html b/LayoutTests/fast/line-grid/line-grid-parsing.html
new file mode 100644 (file)
index 0000000..5bc6462
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/line-grid-parsing.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/line-grid/script-tests/line-grid-parsing.js b/LayoutTests/fast/line-grid/script-tests/line-grid-parsing.js
new file mode 100644 (file)
index 0000000..0fbc12f
--- /dev/null
@@ -0,0 +1,50 @@
+description('Test parsing of the CSS line-grid property.');
+
+function test(declaration) {
+    var div = document.createElement("div");
+    div.setAttribute("style", declaration);
+    return div.style.webkitLineGrid;
+}
+
+function testComputedStyle(value) {
+    var div = document.createElement("div");
+    document.body.appendChild(div);
+    div.style.setProperty("-webkit-line-grid", value);
+    var webkitFlowComputedValue = getComputedStyle(div).getPropertyValue("-webkit-line-grid");
+    document.body.removeChild(div);
+    return webkitFlowComputedValue;
+}
+
+function testInherited(parentValue) {
+    var parentDiv = document.createElement("div");
+    document.body.appendChild(parentDiv);
+    parentDiv.style.setProperty("-webkit-line-grid", parentValue);
+
+    var childDiv = document.createElement("div");
+    parentDiv.appendChild(childDiv);
+
+    var childWebKitFlowComputedValue = getComputedStyle(childDiv).getPropertyValue("-webkit-line-grid");
+
+    parentDiv.removeChild(childDiv);
+    document.body.removeChild(parentDiv);
+
+    return childWebKitFlowComputedValue;
+}
+
+shouldBeEqualToString('test("-webkit-line-grid: none")', "none");
+shouldBeEqualToString('test("-webkit-line-grid: first-grid")', "first-grid");
+shouldBeEqualToString('test("-webkit-line-grid: \'first grid\'")', "");
+shouldBeEqualToString('test("-webkit-line-grid: ;")', "");
+shouldBeEqualToString('test("-webkit-line-grid: 1")', "");
+shouldBeEqualToString('test("-webkit-line-grid: 1.2")', "");
+shouldBeEqualToString('test("-webkit-line-grid: -1")', "");
+shouldBeEqualToString('test("-webkit-line-grid: 12px")', "");
+
+shouldBeEqualToString('testComputedStyle("none")', "none");
+shouldBeEqualToString('testComputedStyle("")', "none");
+shouldBeEqualToString('testComputedStyle("\'first-flow\'")', "none");
+shouldBeEqualToString('testComputedStyle("first-grid")', "first-grid");
+shouldBeEqualToString('testComputedStyle("12px")', "none");
+
+shouldBeEqualToString('testInherited("none")', "none");
+shouldBeEqualToString('testInherited("grid")', "grid");
index 4efa550..f32fdc5 100644 (file)
@@ -302,6 +302,8 @@ rect: style.getPropertyValue(-webkit-line-break) : normal
 rect: style.getPropertyCSSValue(-webkit-line-break) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-line-clamp) : none
 rect: style.getPropertyCSSValue(-webkit-line-clamp) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(-webkit-line-grid) : none
+rect: style.getPropertyCSSValue(-webkit-line-grid) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-locale) : auto
 rect: style.getPropertyCSSValue(-webkit-locale) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-margin-before-collapse) : collapse
@@ -784,6 +786,8 @@ g: style.getPropertyValue(-webkit-line-break) : normal
 g: style.getPropertyCSSValue(-webkit-line-break) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-line-clamp) : none
 g: style.getPropertyCSSValue(-webkit-line-clamp) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(-webkit-line-grid) : none
+g: style.getPropertyCSSValue(-webkit-line-grid) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-locale) : auto
 g: style.getPropertyCSSValue(-webkit-locale) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-margin-before-collapse) : collapse
index 9b2f5f6..17298dd 100755 (executable)
@@ -1,3 +1,31 @@
+2011-10-27  David Hyatt  <hyatt@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=71061
+        
+        [CSS Line Grid] Add support for parsing the line-grid property.
+
+        New tests in fast/line-grid.
+
+        Reviewed by Dan Bernstein.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isInheritedProperty):
+        * css/CSSPropertyNames.in:
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::lineGrid):
+        (WebCore::InheritedFlags::setLineGrid):
+        (WebCore::InheritedFlags::initialLineGrid):
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+        (WebCore::StyleRareInheritedData::operator==):
+        * rendering/style/StyleRareInheritedData.h:
+
 2011-10-27  Fady Samuel  <fsamuel@chromium.org>
 
         iframes seem to occasionally doubly scale or scale incorrectly when pageScaleFactor != 1.0
index 731e430..bf958a0 100644 (file)
@@ -226,6 +226,7 @@ static const int computedProperties[] = {
     CSSPropertyWebkitLineBoxContain,
     CSSPropertyWebkitLineBreak,
     CSSPropertyWebkitLineClamp,
+    CSSPropertyWebkitLineGrid,
     CSSPropertyWebkitLocale,
     CSSPropertyWebkitMarginBeforeCollapse,
     CSSPropertyWebkitMarginAfterCollapse,
@@ -1973,6 +1974,10 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return primitiveValueCache->createValue(style->pointerEvents());
         case CSSPropertyWebkitColorCorrection:
             return primitiveValueCache->createValue(style->colorSpace());
+        case CSSPropertyWebkitLineGrid:
+            if (style->lineGrid().isNull())
+                return primitiveValueCache->createIdentifierValue(CSSValueNone);
+            return primitiveValueCache->createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
         case CSSPropertyWebkitWritingMode:
             return primitiveValueCache->createValue(style->writingMode());
         case CSSPropertyWebkitTextCombine:
index 69f72ce..a224fe0 100644 (file)
@@ -1903,6 +1903,17 @@ bool CSSParser::parseValue(int propId, bool important)
             validPrimitive = true;
         break;
 
+    case CSSPropertyWebkitLineGrid:
+        if (id == CSSValueNone)
+            validPrimitive = true;
+        else if (value->unit == CSSPrimitiveValue::CSS_IDENT) {
+            String lineGridValue = String(value->string);
+            if (!lineGridValue.isEmpty()) {
+                addProperty(propId, primitiveValueCache()->createValue(lineGridValue, CSSPrimitiveValue::CSS_STRING), important);
+                return true;
+            }
+        }
+        break;
     case CSSPropertyWebkitLocale:
         if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
             validPrimitive = true;
index eb8b2f9..17bf058 100644 (file)
@@ -330,6 +330,7 @@ bool CSSProperty::isInheritedProperty(unsigned propertyID)
     case CSSPropertyWebkitHyphens:
     case CSSPropertyWebkitLineBoxContain:
     case CSSPropertyWebkitLineBreak:
+    case CSSPropertyWebkitLineGrid:
     case CSSPropertyWebkitNbspMode:
     case CSSPropertyWebkitRtlOrdering:
     case CSSPropertyWebkitTextCombine:
index df31bec..04f3da4 100644 (file)
@@ -269,6 +269,7 @@ z-index
 -webkit-line-box-contain
 -webkit-line-break
 -webkit-line-clamp
+-webkit-line-grid
 -webkit-logical-width
 -webkit-logical-height
 -webkit-margin-after-collapse
index f6ad715..2571a0f 100644 (file)
@@ -3372,7 +3372,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSSPropertyWebkitColumnBreakInside:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE_WITH_VALUE(columnBreakInside, ColumnBreakInside, PageBreak)
         return;
-     case CSSPropertyWebkitColumnRule:
+    case CSSPropertyWebkitColumnRule:
         if (isInherit) {
             m_style->setColumnRuleColor(m_parentStyle->columnRuleColor().isValid() ? m_parentStyle->columnRuleColor() : m_parentStyle->color());
             m_style->setColumnRuleStyle(m_parentStyle->columnRuleStyle());
@@ -3381,6 +3381,13 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         else if (isInitial)
             m_style->resetColumnRule();
         return;
+    case CSSPropertyWebkitLineGrid:
+        HANDLE_INHERIT_AND_INITIAL(lineGrid, LineGrid);
+        if (primitiveValue->getIdent() == CSSValueNone)
+            m_style->setLineGrid(nullAtom);
+        else
+            m_style->setLineGrid(primitiveValue->getStringValue());
+        return;
     case CSSPropertyWebkitRegionBreakBefore:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE_WITH_VALUE(regionBreakBefore, RegionBreakBefore, PageBreak)
         return;
index 002230c..2df04be 100644 (file)
@@ -810,6 +810,8 @@ public:
     const AtomicString& regionThread() const { return rareNonInheritedData->m_regionThread; }
     RegionOverflow regionOverflow() const { return static_cast<RegionOverflow>(rareNonInheritedData->m_regionOverflow); }
 
+    const AtomicString& lineGrid() const { return rareInheritedData->m_lineGrid; }
+    
     // Apple-specific property getter methods
     EPointerEvents pointerEvents() const { return static_cast<EPointerEvents>(inherited_flags._pointerEvents); }
     const AnimationList* animations() const { return rareNonInheritedData->m_animations.get(); }
@@ -1189,6 +1191,8 @@ public:
 
     // End CSS3 Setters
 
+    void setLineGrid(const AtomicString& lineGrid) { SET_VAR(rareInheritedData, m_lineGrid, lineGrid); }
+
     void setFlowThread(const AtomicString& flowThread) { SET_VAR(rareNonInheritedData, m_flowThread, flowThread); }
     void setRegionThread(const AtomicString& regionThread) { SET_VAR(rareNonInheritedData, m_regionThread, regionThread); }
     void setRegionOverflow(RegionOverflow regionOverflow) { SET_VAR(rareNonInheritedData, m_regionOverflow, regionOverflow); }
@@ -1469,6 +1473,8 @@ public:
     static StyleImage* initialBorderImageSource() { return 0; }
     static StyleImage* initialMaskBoxImageSource() { return 0; }
 
+    static const AtomicString& initialLineGrid() { return nullAtom; }
+
     static const AtomicString& initialFlowThread() { return nullAtom; }
     static const AtomicString& initialRegionThread() { return nullAtom; }
     static RegionOverflow initialRegionOverflow() { return AutoRegionOverflow; }
index ac5e728..c7dc75b 100644 (file)
@@ -56,6 +56,7 @@ StyleRareInheritedData::StyleRareInheritedData()
     , hyphenationLimitBefore(-1)
     , hyphenationLimitAfter(-1)
     , hyphenationLimitLines(-1)
+    , m_lineGrid(RenderStyle::initialLineGrid())
 #if ENABLE(TOUCH_EVENTS)
     , tapHighlightColor(RenderStyle::initialTapHighlightColor())
 #endif    
@@ -101,6 +102,7 @@ StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
     , hyphenationLimitLines(o.hyphenationLimitLines)
     , locale(o.locale)
     , textEmphasisCustomMark(o.textEmphasisCustomMark)
+    , m_lineGrid(o.m_lineGrid)
 #if ENABLE(TOUCH_EVENTS)
     , tapHighlightColor(o.tapHighlightColor)
 #endif
@@ -162,6 +164,7 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
         && locale == o.locale
         && textEmphasisCustomMark == o.textEmphasisCustomMark
         && QuotesData::equal(quotes.get(), o.quotes.get())
+        && m_lineGrid == o.m_lineGrid
         && m_imageRendering == o.m_imageRendering;
 }
 
index cfe0854..f658c46 100644 (file)
@@ -102,6 +102,9 @@ public:
 
     AtomicString textEmphasisCustomMark;
     RefPtr<QuotesData> quotes;
+    
+    AtomicString m_lineGrid;
+
 #if ENABLE(TOUCH_EVENTS)
     Color tapHighlightColor;
 #endif