https://bugs.webkit.org/show_bug.cgi?id=78934
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2012 23:13:29 +0000 (23:13 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2012 23:13:29 +0000 (23:13 +0000)
Add the -webkit-line-align property to support the alignment of lines in the inline direction
to the line grid.

Reviewed by Dan Bernstein.

Source/WebCore:

Added fast/line-grid/line-align-parsing.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore):
(WebCore::CSSPrimitiveValue::operator LineAlign):
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
* css/CSSPropertyNames.in:
* css/CSSStyleApplyProperty.cpp:
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* css/CSSValueKeywords.in:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):
* rendering/style/StyleRareInheritedData.h:
(StyleRareInheritedData):

LayoutTests:

* fast/line-grid/line-align-parsing-expected.txt: Added.
* fast/line-grid/line-align-parsing.html: Added.
* fast/line-grid/script-tests/line-align-parsing.js: Added.

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/line-grid/line-align-parsing-expected.txt [new file with mode: 0644]
LayoutTests/fast/line-grid/line-align-parsing.html [new file with mode: 0644]
LayoutTests/fast/line-grid/script-tests/line-align-parsing.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleApplyProperty.cpp
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h

index 6f8fa6a..e615ed1 100644 (file)
@@ -1,3 +1,16 @@
+2012-02-17  David Hyatt  <hyatt@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=78934
+        
+        Add the -webkit-line-align property to support the alignment of lines in the inline direction
+        to the line grid.
+
+        Reviewed by Dan Bernstein.
+
+        * fast/line-grid/line-align-parsing-expected.txt: Added.
+        * fast/line-grid/line-align-parsing.html: Added.
+        * fast/line-grid/script-tests/line-align-parsing.js: Added.
+
 2012-02-17  James Robinson  <jamesr@chromium.org>
 
         [chromium] Unreviewed. Land the last (hopefully) new baselines for fast/css/non-empty-span.html
diff --git a/LayoutTests/fast/line-grid/line-align-parsing-expected.txt b/LayoutTests/fast/line-grid/line-align-parsing-expected.txt
new file mode 100644 (file)
index 0000000..cc544b0
--- /dev/null
@@ -0,0 +1,21 @@
+Test parsing of the CSS line-snap property.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS test("-webkit-line-align: none") is "none"
+PASS test("-webkit-line-align: edges") is "edges"
+PASS test("-webkit-line-align: ;") is ""
+PASS test("-webkit-line-align: 1") is ""
+PASS test("-webkit-line-align: 1.2") is ""
+PASS test("-webkit-line-align: -1") is ""
+PASS test("-webkit-line-align: 12px") is ""
+PASS testComputedStyle("none") is "none"
+PASS testComputedStyle("") is "none"
+PASS testComputedStyle("12px") is "none"
+PASS testInherited("none") is "none"
+PASS testInherited("edges") is "edges"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/line-grid/line-align-parsing.html b/LayoutTests/fast/line-grid/line-align-parsing.html
new file mode 100644 (file)
index 0000000..18440b5
--- /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-align-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-align-parsing.js b/LayoutTests/fast/line-grid/script-tests/line-align-parsing.js
new file mode 100644 (file)
index 0000000..42a1b64
--- /dev/null
@@ -0,0 +1,48 @@
+description('Test parsing of the CSS line-snap property.');
+
+function test(declaration) {
+    var div = document.createElement("div");
+    div.setAttribute("style", declaration);
+    return div.style.webkitLineAlign;
+}
+
+function testComputedStyle(value) {
+    var div = document.createElement("div");
+    document.body.appendChild(div);
+    div.style.setProperty("-webkit-line-align", value);
+    var webkitFlowComputedValue = getComputedStyle(div).getPropertyValue("-webkit-line-align");
+    document.body.removeChild(div);
+    return webkitFlowComputedValue;
+}
+
+function testInherited(parentValue) {
+    var parentDiv = document.createElement("div");
+    document.body.appendChild(parentDiv);
+    parentDiv.style.setProperty("-webkit-line-align", parentValue);
+
+    var childDiv = document.createElement("div");
+    parentDiv.appendChild(childDiv);
+
+    var childWebKitFlowComputedValue = getComputedStyle(childDiv).getPropertyValue("-webkit-line-align");
+
+    parentDiv.removeChild(childDiv);
+    document.body.removeChild(parentDiv);
+
+    return childWebKitFlowComputedValue;
+}
+
+shouldBeEqualToString('test("-webkit-line-align: none")', "none");
+shouldBeEqualToString('test("-webkit-line-align: edges")', "edges");
+shouldBeEqualToString('test("-webkit-line-align: ;")', "");
+shouldBeEqualToString('test("-webkit-line-align: 1")', "");
+shouldBeEqualToString('test("-webkit-line-align: 1.2")', "");
+shouldBeEqualToString('test("-webkit-line-align: -1")', "");
+shouldBeEqualToString('test("-webkit-line-align: 12px")', "");
+
+shouldBeEqualToString('testComputedStyle("none")', "none");
+shouldBeEqualToString('testComputedStyle("")', "none");
+shouldBeEqualToString('testComputedStyle("12px")', "none");
+
+shouldBeEqualToString('testInherited("none")', "none");
+shouldBeEqualToString('testInherited("edges")', "edges");
+
index f485b07..13261d0 100644 (file)
@@ -1,3 +1,41 @@
+2012-02-17  David Hyatt  <hyatt@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=78934
+        
+        Add the -webkit-line-align property to support the alignment of lines in the inline direction
+        to the line grid.
+
+        Reviewed by Dan Bernstein.
+
+        Added fast/line-grid/line-align-parsing.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore):
+        (WebCore::CSSPrimitiveValue::operator LineAlign):
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isInheritedProperty):
+        * css/CSSPropertyNames.in:
+        * css/CSSStyleApplyProperty.cpp:
+        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * css/CSSValueKeywords.in:
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::diff):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+        (WebCore::StyleRareInheritedData::operator==):
+        * rendering/style/StyleRareInheritedData.h:
+        (StyleRareInheritedData):
+
 2012-02-17  Emil A Eklund  <eae@chromium.org>
 
         Add FractionalLayoutSize for sub-pixel layout
index c08e3eb..04f72c8 100644 (file)
@@ -239,6 +239,7 @@ static const int computedProperties[] = {
     CSSPropertyWebkitHyphenateLimitBefore,
     CSSPropertyWebkitHyphenateLimitLines,
     CSSPropertyWebkitHyphens,
+    CSSPropertyWebkitLineAlign,
     CSSPropertyWebkitLineBoxContain,
     CSSPropertyWebkitLineBreak,
     CSSPropertyWebkitLineClamp,
@@ -2231,6 +2232,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return cssValuePool->createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
         case CSSPropertyWebkitLineSnap:
             return CSSPrimitiveValue::create(style->lineSnap());
+        case CSSPropertyWebkitLineAlign:
+            return CSSPrimitiveValue::create(style->lineAlign());
         case CSSPropertyWebkitWritingMode:
             return cssValuePool->createValue(style->writingMode());
         case CSSPropertyWebkitTextCombine:
index 8fd1dc4..e2d4646 100644 (file)
@@ -2054,6 +2054,10 @@ bool CSSParser::parseValue(int propId, bool important)
         if (id == CSSValueNone || id == CSSValueBaseline || id == CSSValueContain)
             validPrimitive = true;
         break;
+    case CSSPropertyWebkitLineAlign:
+        if (id == CSSValueNone || id == CSSValueEdges)
+            validPrimitive = true;
+        break;
     case CSSPropertyWebkitLocale:
         if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
             validPrimitive = true;
index 2e61152..73491c3 100644 (file)
@@ -3190,6 +3190,33 @@ template<> inline CSSPrimitiveValue::operator LineSnap() const
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineAlign lineAlign)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_IDENT;
+    switch (lineAlign) {
+    case LineAlignNone:
+        m_value.ident = CSSValueNone;
+        break;
+    case LineAlignEdges:
+        m_value.ident = CSSValueEdges;
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator LineAlign() const
+{
+    switch (m_value.ident) {
+    case CSSValueNone:
+        return LineAlignNone;
+    case CSSValueEdges:
+        return LineAlignEdges;
+    default:
+        ASSERT_NOT_REACHED();
+        return LineAlignNone;
+    }
+}
+
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ESpeak e)
     : CSSValue(PrimitiveClass)
 {
index 06a48ab..fd85e9b 100644 (file)
@@ -328,6 +328,7 @@ bool CSSProperty::isInheritedProperty(unsigned propertyID)
     case CSSPropertyWebkitHyphenateLimitBefore:
     case CSSPropertyWebkitHyphenateLimitLines:
     case CSSPropertyWebkitHyphens:
+    case CSSPropertyWebkitLineAlign:
     case CSSPropertyWebkitLineBoxContain:
     case CSSPropertyWebkitLineBreak:
     case CSSPropertyWebkitLineGrid:
index de45230..9afda37 100644 (file)
@@ -271,6 +271,7 @@ z-index
 -webkit-hyphens
 -epub-hyphens = -webkit-hyphens
 -webkit-line-box-contain
+-webkit-line-align
 -webkit-line-break
 -webkit-line-clamp
 -webkit-line-grid
index 920d72f..842ac47 100644 (file)
@@ -1935,6 +1935,7 @@ CSSStyleApplyProperty::CSSStyleApplyProperty()
 
     setPropertyHandler(CSSPropertyWebkitLineGrid, ApplyPropertyString<MapNoneToNull, &RenderStyle::lineGrid, &RenderStyle::setLineGrid, &RenderStyle::initialLineGrid>::createHandler());
     setPropertyHandler(CSSPropertyWebkitLineSnap, ApplyPropertyDefault<LineSnap, &RenderStyle::lineSnap, LineSnap, &RenderStyle::setLineSnap, LineSnap, &RenderStyle::initialLineSnap>::createHandler());
+    setPropertyHandler(CSSPropertyWebkitLineAlign, ApplyPropertyDefault<LineAlign, &RenderStyle::lineAlign, LineAlign, &RenderStyle::setLineAlign, LineAlign, &RenderStyle::initialLineAlign>::createHandler());
 
     setPropertyHandler(CSSPropertyWebkitTextCombine, ApplyPropertyDefault<TextCombine, &RenderStyle::textCombine, TextCombine, &RenderStyle::setTextCombine, TextCombine, &RenderStyle::initialTextCombine>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextEmphasisPosition, ApplyPropertyDefault<TextEmphasisPosition, &RenderStyle::textEmphasisPosition, TextEmphasisPosition, &RenderStyle::setTextEmphasisPosition, TextEmphasisPosition, &RenderStyle::initialTextEmphasisPosition>::createHandler());
index c086a8f..bfd68da 100644 (file)
@@ -4106,6 +4106,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSSPropertyWebkitHyphenateLimitAfter:
     case CSSPropertyWebkitHyphenateLimitBefore:
     case CSSPropertyWebkitHyphenateLimitLines:
+    case CSSPropertyWebkitLineAlign:
     case CSSPropertyWebkitLineGrid:
     case CSSPropertyWebkitLineSnap:
     case CSSPropertyWebkitTextCombine:
index 1192ec7..d299391 100644 (file)
@@ -888,6 +888,9 @@ maximum
 wrap
 // none
 
+// -webkit-line-align
+edges
+
 #if defined(ENABLE_CSS_FILTERS) && ENABLE_CSS_FILTERS
 // -webkit-filter
 #if defined(ENABLE_CSS_SHADERS) && ENABLE_CSS_SHADERS
index 9ed05fd..c62b3b1 100644 (file)
@@ -466,7 +466,8 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
             || rareInheritedData->textEmphasisCustomMark != other->rareInheritedData->textEmphasisCustomMark
             || rareInheritedData->m_lineBoxContain != other->rareInheritedData->m_lineBoxContain
             || rareInheritedData->m_lineGrid != other->rareInheritedData->m_lineGrid
-            || rareInheritedData->m_lineSnap != other->rareInheritedData->m_lineSnap)
+            || rareInheritedData->m_lineSnap != other->rareInheritedData->m_lineSnap
+            || rareInheritedData->m_lineAlign != other->rareInheritedData->m_lineAlign)
             return StyleDifferenceLayout;
 
         if (!rareInheritedData->shadowDataEquivalent(*other->rareInheritedData.get()))
index 74cb31f..b4976c0 100644 (file)
@@ -904,6 +904,7 @@ public:
 
     const AtomicString& lineGrid() const { return rareInheritedData->m_lineGrid; }
     LineSnap lineSnap() const { return static_cast<LineSnap>(rareInheritedData->m_lineSnap); }
+    LineAlign lineAlign() const { return static_cast<LineAlign>(rareInheritedData->m_lineAlign); }
 
     WrapFlow wrapFlow() const { return static_cast<WrapFlow>(rareNonInheritedData->m_wrapFlow); }
     WrapThrough wrapThrough() const { return static_cast<WrapThrough>(rareNonInheritedData->m_wrapThrough); }
@@ -1306,6 +1307,7 @@ public:
 
     void setLineGrid(const AtomicString& lineGrid) { SET_VAR(rareInheritedData, m_lineGrid, lineGrid); }
     void setLineSnap(LineSnap lineSnap) { SET_VAR(rareInheritedData, m_lineSnap, lineSnap); }
+    void setLineAlign(LineAlign lineAlign) { SET_VAR(rareInheritedData, m_lineAlign, lineAlign); }
 
     void setFlowThread(const AtomicString& flowThread) { SET_VAR(rareNonInheritedData, m_flowThread, flowThread); }
     void setRegionThread(const AtomicString& regionThread) { SET_VAR(rareNonInheritedData, m_regionThread, regionThread); }
@@ -1638,6 +1640,7 @@ public:
 
     static const AtomicString& initialLineGrid() { return nullAtom; }
     static LineSnap initialLineSnap() { return LineSnapNone; }
+    static LineAlign initialLineAlign() { return LineAlignNone; }
 
     static const AtomicString& initialFlowThread() { return nullAtom; }
     static const AtomicString& initialRegionThread() { return nullAtom; }
index 755b6a9..aee1081 100644 (file)
@@ -456,6 +456,8 @@ enum ColumnAxis { HorizontalColumnAxis, VerticalColumnAxis, AutoColumnAxis };
 
 enum LineSnap { LineSnapNone, LineSnapBaseline, LineSnapContain };
 
+enum LineAlign { LineAlignNone, LineAlignEdges };
+
 enum WrapFlow { WrapFlowAuto, WrapFlowBoth, WrapFlowLeft, WrapFlowRight, WrapFlowMaximum, WrapFlowClear };
 
 enum WrapThrough { WrapThroughWrap, WrapThroughNone };
index 343fa7e..5d73793 100644 (file)
@@ -54,6 +54,7 @@ StyleRareInheritedData::StyleRareInheritedData()
     , m_lineBoxContain(RenderStyle::initialLineBoxContain())
     , m_imageRendering(RenderStyle::initialImageRendering())
     , m_lineSnap(RenderStyle::initialLineSnap())
+    , m_lineAlign(RenderStyle::initialLineAlign())
 #if ENABLE(OVERFLOW_SCROLLING)
     , useTouchOverflowScrolling(RenderStyle::initialUseTouchOverflowScrolling())
 #endif
@@ -101,6 +102,7 @@ StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
     , m_lineBoxContain(o.m_lineBoxContain)
     , m_imageRendering(o.m_imageRendering)
     , m_lineSnap(o.m_lineSnap)
+    , m_lineAlign(o.m_lineAlign)
 #if ENABLE(OVERFLOW_SCROLLING)
     , useTouchOverflowScrolling(o.useTouchOverflowScrolling)
 #endif
@@ -177,7 +179,8 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
         && QuotesData::equal(quotes.get(), o.quotes.get())
         && m_lineGrid == o.m_lineGrid
         && m_imageRendering == o.m_imageRendering
-        && m_lineSnap == o.m_lineSnap;
+        && m_lineSnap == o.m_lineSnap
+        && m_lineAlign == o.m_lineAlign;
 }
 
 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
index d043f5c..570dbb5 100644 (file)
@@ -92,6 +92,7 @@ public:
     // CSS Image Values Level 3
     unsigned m_imageRendering : 2; // EImageRendering
     unsigned m_lineSnap : 2; // LineSnap
+    unsigned m_lineAlign : 1; // LineAlign
 #if ENABLE(OVERFLOW_SCROLLING)
     unsigned useTouchOverflowScrolling: 1;
 #endif