text-emphasis-position CSS property doesn't recognize 'left' and 'right'
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jan 2014 18:47:04 +0000 (18:47 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jan 2014 18:47:04 +0000 (18:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126611

Reviewed by Simon Fraser.

Source/WebCore:

This patch allows the text-emphasis-position to accept the "left" and
"right" CSS values. In horizontal writing modes, these values no not
change behavior. In vertical writing modes, however, these values specify
which side to place the emphasis mark. Similarly, in vertical writing
modes, the "above" and "below" values should not change behavior.

However, in order to keep existing behavior, if neither "left" nor "right"
is specified, we should draw as if the appropriate value were
specified ("over" -> "right" and "under" -> "left"). Note that this
will have to be updated when we implement the
"text-orientation: sideways-left" CSS property.

Tests: fast/text/emphasis-horizontal-left-right.html
       fast/text/emphasis-vertical-over-right.html
       fast/text/emphasis-vertical-over-under.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::renderEmphasisPositionFlagsToCSSValue):
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue):
(WebCore::isKeywordPropertyID):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseTextEmphasisPosition):
* css/CSSParser.h:
* css/CSSPrimitiveValueMappings.h:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::valueToEmphasisPosition):
(WebCore::ApplyPropertyTextEmphasisPosition::applyValue):
(WebCore::ApplyPropertyTextEmphasisPosition::createHandler):
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::placeBoxesInBlockDirection):
(WebCore::InlineFlowBox::addTextBoxVisualOverflow):
(WebCore::InlineFlowBox::computeOverAnnotationAdjustment):
(WebCore::InlineFlowBox::computeUnderAnnotationAdjustment):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::emphasisMarkExistsAndIsAbove):
(WebCore::InlineTextBox::paint):
* rendering/InlineTextBox.h:
* rendering/style/RenderStyle.h:
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
* rendering/style/StyleRareInheritedData.h:

LayoutTests:

With regards to text-emphasis-position, "left" and "right" are only valid in
vertical writing modes, and "over" and "under" are only valid in horizontal
writing modes.

In order to keep in line with existing pages, specifying "under" without
"left" or "right" should draw text as if "under left" was specified (and
vice-versa).

The default value for text-emphasis-position should be "over right".

* fast/css/getComputedStyle/computed-style-expected.txt:
* fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* fast/css/parsing-text-emphasis-expected.txt:
* fast/css/parsing-text-emphasis.html:
* fast/text/emphasis-horizontal-left-right-expected.html: Added.
* fast/text/emphasis-horizontal-left-right.html: Added.
* fast/text/emphasis-vertical-over-right-expected.html: Added.
* fast/text/emphasis-vertical-over-right.html: Added.
* fast/text/emphasis-vertical-over-under-expected.html: Added.
* fast/text/emphasis-vertical-over-under.html: Added.

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

25 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt
LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
LayoutTests/fast/css/parsing-text-emphasis-expected.txt
LayoutTests/fast/css/parsing-text-emphasis.html
LayoutTests/fast/text/emphasis-horizontal-left-right-expected.html [new file with mode: 0644]
LayoutTests/fast/text/emphasis-horizontal-left-right.html [new file with mode: 0644]
LayoutTests/fast/text/emphasis-vertical-over-right-expected.html [new file with mode: 0644]
LayoutTests/fast/text/emphasis-vertical-over-right.html [new file with mode: 0644]
LayoutTests/fast/text/emphasis-vertical-over-under-expected.html [new file with mode: 0644]
LayoutTests/fast/text/emphasis-vertical-over-under.html [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/CSSParser.h
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/DeprecatedStyleBuilder.cpp
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/InlineTextBox.h
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 1f2dc3fee76766281fdbf68b32533c7cc75b0cbd..4343d0a3d65c86e8f3e495a709fefc8f299132e0 100644 (file)
@@ -1,3 +1,31 @@
+2014-01-07  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        text-emphasis-position CSS property doesn't recognize 'left' and 'right'
+        https://bugs.webkit.org/show_bug.cgi?id=126611
+
+        Reviewed by Simon Fraser.
+
+        With regards to text-emphasis-position, "left" and "right" are only valid in
+        vertical writing modes, and "over" and "under" are only valid in horizontal
+        writing modes.
+
+        In order to keep in line with existing pages, specifying "under" without
+        "left" or "right" should draw text as if "under left" was specified (and
+        vice-versa).
+
+        The default value for text-emphasis-position should be "over right".
+
+        * fast/css/getComputedStyle/computed-style-expected.txt:
+        * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+        * fast/css/parsing-text-emphasis-expected.txt:
+        * fast/css/parsing-text-emphasis.html:
+        * fast/text/emphasis-horizontal-left-right-expected.html: Added.
+        * fast/text/emphasis-horizontal-left-right.html: Added.
+        * fast/text/emphasis-vertical-over-right-expected.html: Added.
+        * fast/text/emphasis-vertical-over-right.html: Added.
+        * fast/text/emphasis-vertical-over-under-expected.html: Added.
+        * fast/text/emphasis-vertical-over-under.html: Added.
+
 2014-01-16  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
 
         Unreviewed EFL gardening
index 19dd7e2179a74aecdc7b8ed118fb21407c11601d..4306ba3999f4090b34e8d6f1322ba92ce8877b39 100644 (file)
@@ -193,7 +193,7 @@ zoom: 1;
 -webkit-text-combine: none;
 -webkit-text-decorations-in-effect: none;
 -webkit-text-emphasis-color: rgb(0, 0, 0);
--webkit-text-emphasis-position: over;
+-webkit-text-emphasis-position: over right;
 -webkit-text-emphasis-style: none;
 -webkit-text-fill-color: rgb(0, 0, 0);
 -webkit-text-orientation: vertical-right;
index e2a8b7449524c5a769a8297e58434fa190e2cc68..53d3dac988de3841c5a336bf7808562c90871bd4 100644 (file)
@@ -192,7 +192,7 @@ zoom: 1
 -webkit-text-combine: none
 -webkit-text-decorations-in-effect: none
 -webkit-text-emphasis-color: rgb(0, 0, 0)
--webkit-text-emphasis-position: over
+-webkit-text-emphasis-position: over right
 -webkit-text-emphasis-style: none
 -webkit-text-fill-color: rgb(0, 0, 0)
 -webkit-text-orientation: vertical-right
index 1f1e8d8a27a8f0ee2ffcbb85aa6ed7c640a67ed1..a822716462671e2af33f88d9633cd5df08a14e73 100644 (file)
@@ -10,6 +10,16 @@ PASS: '-webkit-text-emphasis-position: initial;' parsed as ['', 'initial', '', '
 PASS: '-webkit-text-emphasis-position: inherit;' parsed as ['', 'inherit', '', '']
 PASS: '-webkit-text-emphasis-position: over;' parsed as ['', 'over', '', '']
 PASS: '-webkit-text-emphasis-position: under;' parsed as ['', 'under', '', '']
+PASS: '-webkit-text-emphasis-position: right;' parsed as ['', '', '', '']
+PASS: '-webkit-text-emphasis-position: left;' parsed as ['', '', '', '']
+PASS: '-webkit-text-emphasis-position: right over;' parsed as ['', 'over right', '', '']
+PASS: '-webkit-text-emphasis-position: right under;' parsed as ['', 'under right', '', '']
+PASS: '-webkit-text-emphasis-position: left over;' parsed as ['', 'over left', '', '']
+PASS: '-webkit-text-emphasis-position: left under;' parsed as ['', 'under left', '', '']
+PASS: '-webkit-text-emphasis-position: left right under;' parsed as ['', '', '', '']
+PASS: '-webkit-text-emphasis-position: left right left;' parsed as ['', '', '', '']
+PASS: '-webkit-text-emphasis-position: left under left;' parsed as ['', '', '', '']
+PASS: '-webkit-text-emphasis-position: over inherit;' parsed as ['', '', '', '']
 PASS: '-webkit-text-emphasis-position: bold;' parsed as ['', '', '', '']
 PASS: '-webkit-text-emphasis-position: 1px;' parsed as ['', '', '', '']
 PASS: '-webkit-text-emphasis-position: "over";' parsed as ['', '', '', '']
index 32f8f24500bda0177587bd5c88a929688f443fb5..a6173308725f54a09fe3625c4a51798e905a6d62 100644 (file)
     test('-webkit-text-emphasis-position: inherit;', '', 'inherit', '');
     test('-webkit-text-emphasis-position: over;', '', 'over', '');
     test('-webkit-text-emphasis-position: under;', '', 'under', '');
+    test('-webkit-text-emphasis-position: right;', '', '', '');
+    test('-webkit-text-emphasis-position: left;', '', '', '');
+    test('-webkit-text-emphasis-position: right over;', '', 'over right', '');
+    test('-webkit-text-emphasis-position: right under;', '', 'under right', '');
+    test('-webkit-text-emphasis-position: left over;', '', 'over left', '');
+    test('-webkit-text-emphasis-position: left under;', '', 'under left', '');
+    test('-webkit-text-emphasis-position: left right under;', '', '', '');
+    test('-webkit-text-emphasis-position: left right left;', '', '', '');
+    test('-webkit-text-emphasis-position: left under left;', '', '', '');
+    test('-webkit-text-emphasis-position: over inherit;', '', '', '');
     test('-webkit-text-emphasis-position: bold;', '', '', '');
     test('-webkit-text-emphasis-position: 1px;', '', '', '');
     test('-webkit-text-emphasis-position: "over";', '', '', '');
diff --git a/LayoutTests/fast/text/emphasis-horizontal-left-right-expected.html b/LayoutTests/fast/text/emphasis-horizontal-left-right-expected.html
new file mode 100644 (file)
index 0000000..a468227
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test is testing that when text is in a horizontal writing mode, the "left" and "right" values of the
+CSS text-emphasis-position property have no effect
+<div style="-webkit-text-emphasis-style: filled dot; -webkit-text-emphasis-position: right under;">Demo String</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/emphasis-horizontal-left-right.html b/LayoutTests/fast/text/emphasis-horizontal-left-right.html
new file mode 100644 (file)
index 0000000..97e8d13
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test is testing that when text is in a horizontal writing mode, the "left" and "right" values of the
+CSS text-emphasis-position property have no effect
+<div style="-webkit-text-emphasis-style: filled dot; -webkit-text-emphasis-position: left under;">Demo String</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/emphasis-vertical-over-right-expected.html b/LayoutTests/fast/text/emphasis-vertical-over-right-expected.html
new file mode 100644 (file)
index 0000000..0e7c214
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test is testing that when text is in a vertical writing mode, the "under" and "left over" values of the
+CSS text-emphasis-position property act the same
+<div style="-webkit-writing-mode: vertical-lr; -webkit-text-emphasis-style: filled dot; -webkit-text-emphasis-position: under;">Demo String</div>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/text/emphasis-vertical-over-right.html b/LayoutTests/fast/text/emphasis-vertical-over-right.html
new file mode 100644 (file)
index 0000000..737ebc1
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test is testing that when text is in a vertical writing mode, the "under" and "left over" values of the
+CSS text-emphasis-position property act the same
+<div style="-webkit-writing-mode: vertical-lr; -webkit-text-emphasis-style: filled dot; -webkit-text-emphasis-position: left over;">Demo String</div>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/text/emphasis-vertical-over-under-expected.html b/LayoutTests/fast/text/emphasis-vertical-over-under-expected.html
new file mode 100644 (file)
index 0000000..7fbf8de
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test is testing that when text is in a vertical writing mode, the "over" and "under" values of the
+CSS text-emphasis-position property have no effect
+<div style="-webkit-writing-mode: vertical-lr; -webkit-text-emphasis-style: filled dot; -webkit-text-emphasis-position: left over;">Demo String</div>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/text/emphasis-vertical-over-under.html b/LayoutTests/fast/text/emphasis-vertical-over-under.html
new file mode 100644 (file)
index 0000000..d928451
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test is testing that when text is in a vertical writing mode, the "over" and "under" values of the
+CSS text-emphasis-position property have no effect
+<div style="-webkit-writing-mode: vertical-lr; -webkit-text-emphasis-style: filled dot; -webkit-text-emphasis-position: left under;">Demo String</div>
+</body>
+</html>
+
index d31d30ee96a5479b673e2f7b244c04e8193c3cb3..db304df77189b22b71690a2fd269b16ff5f09222 100644 (file)
@@ -384,8 +384,8 @@ rect: style.getPropertyValue(-webkit-text-decorations-in-effect) : none
 rect: style.getPropertyCSSValue(-webkit-text-decorations-in-effect) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-text-emphasis-color) : rgb(0, 0, 0)
 rect: style.getPropertyCSSValue(-webkit-text-emphasis-color) : [object CSSPrimitiveValue]
-rect: style.getPropertyValue(-webkit-text-emphasis-position) : over
-rect: style.getPropertyCSSValue(-webkit-text-emphasis-position) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(-webkit-text-emphasis-position) : over right
+rect: style.getPropertyCSSValue(-webkit-text-emphasis-position) : [object CSSValueList]
 rect: style.getPropertyValue(-webkit-text-emphasis-style) : none
 rect: style.getPropertyCSSValue(-webkit-text-emphasis-style) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-text-fill-color) : rgb(0, 0, 0)
@@ -880,8 +880,8 @@ g: style.getPropertyValue(-webkit-text-decorations-in-effect) : none
 g: style.getPropertyCSSValue(-webkit-text-decorations-in-effect) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-text-emphasis-color) : rgb(0, 0, 0)
 g: style.getPropertyCSSValue(-webkit-text-emphasis-color) : [object CSSPrimitiveValue]
-g: style.getPropertyValue(-webkit-text-emphasis-position) : over
-g: style.getPropertyCSSValue(-webkit-text-emphasis-position) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(-webkit-text-emphasis-position) : over right
+g: style.getPropertyCSSValue(-webkit-text-emphasis-position) : [object CSSValueList]
 g: style.getPropertyValue(-webkit-text-emphasis-style) : none
 g: style.getPropertyCSSValue(-webkit-text-emphasis-style) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-text-fill-color) : rgb(0, 0, 0)
index 34fb95382ba8a7a40876eebd7d7810549094109e..52df1961d9ca6e46f30635553a89ab7097c48cc4 100644 (file)
@@ -1,3 +1,56 @@
+2014-01-07  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        text-emphasis-position CSS property doesn't recognize 'left' and 'right'
+        https://bugs.webkit.org/show_bug.cgi?id=126611
+
+        Reviewed by Simon Fraser.
+
+        This patch allows the text-emphasis-position to accept the "left" and
+        "right" CSS values. In horizontal writing modes, these values no not
+        change behavior. In vertical writing modes, however, these values specify
+        which side to place the emphasis mark. Similarly, in vertical writing
+        modes, the "above" and "below" values should not change behavior.
+
+        However, in order to keep existing behavior, if neither "left" nor "right"
+        is specified, we should draw as if the appropriate value were
+        specified ("over" -> "right" and "under" -> "left"). Note that this
+        will have to be updated when we implement the
+        "text-orientation: sideways-left" CSS property.
+
+        Tests: fast/text/emphasis-horizontal-left-right.html
+               fast/text/emphasis-vertical-over-right.html
+               fast/text/emphasis-vertical-over-under.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::renderEmphasisPositionFlagsToCSSValue):
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/CSSParser.cpp:
+        (WebCore::isValidKeywordPropertyAndValue):
+        (WebCore::isKeywordPropertyID):
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseTextEmphasisPosition):
+        * css/CSSParser.h:
+        * css/CSSPrimitiveValueMappings.h:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::valueToEmphasisPosition):
+        (WebCore::ApplyPropertyTextEmphasisPosition::applyValue):
+        (WebCore::ApplyPropertyTextEmphasisPosition::createHandler):
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
+        (WebCore::InlineFlowBox::addTextBoxVisualOverflow):
+        (WebCore::InlineFlowBox::computeOverAnnotationAdjustment):
+        (WebCore::InlineFlowBox::computeUnderAnnotationAdjustment):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::emphasisMarkExistsAndIsAbove):
+        (WebCore::InlineTextBox::paint):
+        * rendering/InlineTextBox.h:
+        * rendering/style/RenderStyle.h:
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+        * rendering/style/StyleRareInheritedData.h:
+
 2014-01-16  Chris Fleizach  <cfleizach@apple.com>
 
         AX: WebKit is not firing AXMenuOpenedNotification
index fe08457359f5ce4e9af6ac6fd411f6fa83192036..5f3f2efd69fff1f60bf6587d89460f5b00a6655a 100644 (file)
@@ -1463,6 +1463,25 @@ static PassRef<CSSValue> renderTextDecorationSkipFlagsToCSSValue(TextDecorationS
 }
 #endif // CSS3_TEXT_DECORATION
 
+static PassRef<CSSValue> renderEmphasisPositionFlagsToCSSValue(TextEmphasisPosition textEmphasisPosition)
+{
+    ASSERT(!((textEmphasisPosition & TextEmphasisPositionOver) && (textEmphasisPosition & TextEmphasisPositionUnder)));
+    ASSERT(!((textEmphasisPosition & TextEmphasisPositionLeft) && (textEmphasisPosition & TextEmphasisPositionRight)));
+    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+    if (textEmphasisPosition & TextEmphasisPositionOver)
+        list->append(cssValuePool().createIdentifierValue(CSSValueOver));
+    if (textEmphasisPosition & TextEmphasisPositionUnder)
+        list->append(cssValuePool().createIdentifierValue(CSSValueUnder));
+    if (textEmphasisPosition & TextEmphasisPositionLeft)
+        list->append(cssValuePool().createIdentifierValue(CSSValueLeft));
+    if (textEmphasisPosition & TextEmphasisPositionRight)
+        list->append(cssValuePool().createIdentifierValue(CSSValueRight));
+
+    if (!list->length())
+        return cssValuePool().createIdentifierValue(CSSValueNone);
+    return list.releaseNonNull();
+}
+
 static PassRef<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
 {
     // For backwards compatibility, if both values are equal, just return one of them. And
@@ -2399,7 +2418,7 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
         case CSSPropertyWebkitTextEmphasisColor:
             return currentColorOrValidColor(style.get(), style->textEmphasisColor());
         case CSSPropertyWebkitTextEmphasisPosition:
-            return cssValuePool().createValue(style->textEmphasisPosition());
+            return renderEmphasisPositionFlagsToCSSValue(style->textEmphasisPosition());
         case CSSPropertyWebkitTextEmphasisStyle:
             switch (style->textEmphasisMark()) {
             case TextEmphasisMarkNone:
index 88d72b2937dcfccc12b2a9f9c17984cdfa9412c4..0ccbba39809b1f00ac848844499f37d93d9a7bf3 100644 (file)
@@ -983,10 +983,6 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
         if (valueID == CSSValueNone || valueID == CSSValueHorizontal)
             return true;
         break;
-    case CSSPropertyWebkitTextEmphasisPosition:
-        if (valueID == CSSValueOver || valueID == CSSValueUnder)
-            return true;
-        break;
 #if ENABLE(CSS3_TEXT)
     case CSSPropertyWebkitTextJustify:
         // auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida
@@ -1156,7 +1152,6 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
     case CSSPropertyWebkitTextAlignLast:
 #endif // CSS3_TEXT
     case CSSPropertyWebkitTextCombine:
-    case CSSPropertyWebkitTextEmphasisPosition:
 #if ENABLE(CSS3_TEXT)
     case CSSPropertyWebkitTextJustify:
 #endif // CSS3_TEXT
@@ -2921,6 +2916,9 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertyWebkitTextEmphasisStyle:
         return parseTextEmphasisStyle(important);
 
+    case CSSPropertyWebkitTextEmphasisPosition:
+        return parseTextEmphasisPosition(important);
+
     case CSSPropertyWebkitTextOrientation:
         // FIXME: For now just support sideways, sideways-right, upright and vertical-right.
         if (id == CSSValueSideways || id == CSSValueSidewaysRight || id == CSSValueVerticalRight || id == CSSValueUpright)
@@ -3068,7 +3066,6 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertyWebkitTextAlignLast:
 #endif // CSS3_TEXT
     case CSSPropertyWebkitTextCombine:
-    case CSSPropertyWebkitTextEmphasisPosition:
 #if ENABLE(CSS3_TEXT)
     case CSSPropertyWebkitTextJustify:
 #endif // CSS3_TEXT
@@ -10188,6 +10185,52 @@ bool CSSParser::parseTextEmphasisStyle(bool important)
     return false;
 }
 
+bool CSSParser::parseTextEmphasisPosition(bool important)
+{
+    bool foundOverOrUnder = false;
+    CSSValueID overUnderValueID = CSSValueOver;
+    bool foundLeftOrRight = false;
+    CSSValueID leftRightValueID = CSSValueRight;
+    for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) {
+        switch (value->id) {
+        case CSSValueOver:
+            if (foundOverOrUnder)
+                return false;
+            foundOverOrUnder = true;
+            overUnderValueID = CSSValueOver;
+            break;
+        case CSSValueUnder:
+            if (foundOverOrUnder)
+                return false;
+            foundOverOrUnder = true;
+            overUnderValueID = CSSValueUnder;
+            break;
+        case CSSValueLeft:
+            if (foundLeftOrRight)
+                return false;
+            foundLeftOrRight = true;
+            leftRightValueID = CSSValueLeft;
+            break;
+        case CSSValueRight:
+            if (foundLeftOrRight)
+                return false;
+            foundLeftOrRight = true;
+            leftRightValueID = CSSValueRight;
+            break;
+        default:
+            return false;
+        }
+    }
+    if (!foundOverOrUnder)
+        return false;
+    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+    list->append(cssValuePool().createIdentifierValue(overUnderValueID));
+    if (foundLeftOrRight)
+        list->append(cssValuePool().createIdentifierValue(leftRightValueID));
+    addProperty(CSSPropertyWebkitTextEmphasisPosition, list, important);
+    return true;
+}
+
 PassRefPtr<CSSValue> CSSParser::parseTextIndent()
 {
     // <length> | <percentage> | inherit  when CSS3_TEXT is disabled.
index 43b9f6d7dd2e43e4ec27a6191d1e53c54686147a..cf0e57a0e08620f774704689dba8790b8be40b44 100644 (file)
@@ -288,6 +288,7 @@ public:
     bool parsePerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2,  RefPtr<CSSValue>&, RefPtr<CSSValue>&);
 
     bool parseTextEmphasisStyle(bool important);
+    bool parseTextEmphasisPosition(bool important);
 
     void addTextDecorationProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important);
     bool parseTextDecoration(CSSPropertyID propId, bool important);
index 72bcad85f85cf2800efac4d41c112ea5636d85c8..10bb49149ff793137026f7844fe45974c9c18728 100644 (file)
@@ -3301,37 +3301,6 @@ template<> inline CSSPrimitiveValue::operator RubyPosition() const
     return RubyPositionBefore;
 }
 
-template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextEmphasisPosition position)
-    : CSSValue(PrimitiveClass)
-{
-    m_primitiveUnitType = CSS_VALUE_ID;
-    switch (position) {
-    case TextEmphasisPositionOver:
-        m_value.valueID = CSSValueOver;
-        break;
-    case TextEmphasisPositionUnder:
-        m_value.valueID = CSSValueUnder;
-        break;
-    }
-}
-
-template<> inline CSSPrimitiveValue::operator TextEmphasisPosition() const
-{
-    ASSERT(isValueID());
-
-    switch (m_value.valueID) {
-    case CSSValueOver:
-        return TextEmphasisPositionOver;
-    case CSSValueUnder:
-        return TextEmphasisPositionUnder;
-    default:
-        break;
-    }
-
-    ASSERT_NOT_REACHED();
-    return TextEmphasisPositionOver;
-}
-
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextOverflow overflow)
     : CSSValue(PrimitiveClass)
 {
index b86cd49df0bd99cba4e0033525676a58424abbe9..6a8a355630e151a4d0b3b1d60b54629465a86015 100644 (file)
@@ -1789,6 +1789,48 @@ public:
     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
 };
 
+static TextEmphasisPosition valueToEmphasisPosition(CSSPrimitiveValue& primitiveValue)
+{
+    ASSERT(primitiveValue.isValueID());
+
+    switch (primitiveValue.getValueID()) {
+    case CSSValueOver:
+        return TextEmphasisPositionOver;
+    case CSSValueUnder:
+        return TextEmphasisPositionUnder;
+    case CSSValueLeft:
+        return TextEmphasisPositionLeft;
+    case CSSValueRight:
+        return TextEmphasisPositionRight;
+    default:
+        break;
+    }
+
+    ASSERT_NOT_REACHED();
+    return RenderStyle::initialTextEmphasisPosition();
+}
+
+class ApplyPropertyTextEmphasisPosition {
+public:
+    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
+    {
+        if (value->isPrimitiveValue()) {
+            styleResolver->style()->setTextEmphasisPosition(valueToEmphasisPosition(*toCSSPrimitiveValue(value)));
+            return;
+        }
+
+        TextEmphasisPosition position = 0;
+        for (CSSValueListIterator i(value); i.hasMore(); i.advance())
+            position |= valueToEmphasisPosition(*toCSSPrimitiveValue(i.value()));
+        styleResolver->style()->setTextEmphasisPosition(position);
+    }
+    static PropertyHandler createHandler()
+    {
+        PropertyHandler handler = ApplyPropertyDefaultBase<TextEmphasisPosition, &RenderStyle::textEmphasisPosition, TextEmphasisPosition, &RenderStyle::setTextEmphasisPosition, TextEmphasisPosition, &RenderStyle::initialTextEmphasisPosition>::createHandler();
+        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
+    }
+};
+
 template <typename T,
           T (Animation::*getterFunction)() const,
           void (Animation::*setterFunction)(T),
@@ -2530,7 +2572,7 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     setPropertyHandler(CSSPropertyWebkitRubyPosition, ApplyPropertyDefault<RubyPosition, &RenderStyle::rubyPosition, RubyPosition, &RenderStyle::setRubyPosition, RubyPosition, &RenderStyle::initialRubyPosition>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextCombine, ApplyPropertyDefault<TextCombine, &RenderStyle::textCombine, TextCombine, &RenderStyle::setTextCombine, TextCombine, &RenderStyle::initialTextCombine>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextEmphasisColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textEmphasisColor, &RenderStyle::setTextEmphasisColor, &RenderStyle::setVisitedLinkTextEmphasisColor, &RenderStyle::color>::createHandler());
-    setPropertyHandler(CSSPropertyWebkitTextEmphasisPosition, ApplyPropertyDefault<TextEmphasisPosition, &RenderStyle::textEmphasisPosition, TextEmphasisPosition, &RenderStyle::setTextEmphasisPosition, TextEmphasisPosition, &RenderStyle::initialTextEmphasisPosition>::createHandler());
+    setPropertyHandler(CSSPropertyWebkitTextEmphasisPosition, ApplyPropertyTextEmphasisPosition::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextEmphasisStyle, ApplyPropertyTextEmphasisStyle::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextFillColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textFillColor, &RenderStyle::setTextFillColor, &RenderStyle::setVisitedLinkTextFillColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextSecurity, ApplyPropertyDefault<ETextSecurity, &RenderStyle::textSecurity, ETextSecurity, &RenderStyle::setTextSecurity, ETextSecurity, &RenderStyle::initialTextSecurity>::createHandler());
index 05da0f19bf187b49f4ab450062b9cf407f770d16..26ef069d9ff8d6236423fddde8c9bac04286c89d 100644 (file)
@@ -694,9 +694,8 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
                 }
             }
             if (curr->isInlineTextBox()) {
-                TextEmphasisPosition emphasisMarkPosition;
-                if (toInlineTextBox(curr)->getEmphasisMarkPosition(childLineStyle, emphasisMarkPosition)) {
-                    bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphasisPositionOver;
+                bool emphasisMarkIsOver;
+                if (toInlineTextBox(curr)->emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsOver)) {
                     if (emphasisMarkIsOver != childLineStyle.isFlippedLinesWritingMode())
                         hasAnnotationsBefore = true;
                     else
@@ -867,10 +866,10 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
     int leftGlyphOverflow = -strokeOverflow - leftGlyphEdge;
     int rightGlyphOverflow = strokeOverflow + rightGlyphEdge;
 
-    TextEmphasisPosition emphasisMarkPosition;
-    if (lineStyle.textEmphasisMark() != TextEmphasisMarkNone && textBox->getEmphasisMarkPosition(lineStyle, emphasisMarkPosition)) {
+    bool emphasisMarkIsAbove;
+    if (lineStyle.textEmphasisMark() != TextEmphasisMarkNone && textBox->emphasisMarkExistsAndIsAbove(lineStyle, emphasisMarkIsAbove)) {
         int emphasisMarkHeight = lineStyle.font().emphasisMarkHeight(lineStyle.textEmphasisMarkString());
-        if ((emphasisMarkPosition == TextEmphasisPositionOver) == (!lineStyle.isFlippedLinesWritingMode()))
+        if (emphasisMarkIsAbove == !lineStyle.isFlippedLinesWritingMode())
             topGlyphOverflow = std::min(topGlyphOverflow, -emphasisMarkHeight);
         else
             bottomGlyphOverflow = std::max(bottomGlyphOverflow, emphasisMarkHeight);
@@ -1534,8 +1533,8 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi
 
         if (curr->isInlineTextBox()) {
             const RenderStyle& childLineStyle = curr->lineStyle();
-            TextEmphasisPosition emphasisMarkPosition;
-            if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && toInlineTextBox(curr)->getEmphasisMarkPosition(childLineStyle, emphasisMarkPosition) && emphasisMarkPosition == TextEmphasisPositionOver) {
+            bool emphasisMarkIsAbove;
+            if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && toInlineTextBox(curr)->emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove) && emphasisMarkIsAbove) {
                 if (!childLineStyle.isFlippedLinesWritingMode()) {
                     int topOfEmphasisMark = curr->logicalTop() - childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
                     result = std::max(result, allowedPosition - topOfEmphasisMark);
@@ -1582,7 +1581,9 @@ LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos
 
         if (curr->isInlineTextBox()) {
             const RenderStyle& childLineStyle = curr->lineStyle();
-            if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && childLineStyle.textEmphasisPosition() == TextEmphasisPositionUnder) {
+            bool emphasisMarkIsAbove;
+            toInlineTextBox(curr)->emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove);
+            if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && !emphasisMarkIsAbove) {
                 if (!childLineStyle.isFlippedLinesWritingMode()) {
                     LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
                     result = std::max(result, bottomOfEmphasisMark - allowedPosition);
index b8d2df9ec7ce3a1dd6bfa45c58fcda2fc822bc64..de90703f33bcdc75b92fe195d765f2ef56649a1d 100644 (file)
@@ -462,14 +462,30 @@ FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context,
     return extraOffset;
 }
 
-bool InlineTextBox::getEmphasisMarkPosition(const RenderStyle& style, TextEmphasisPosition& emphasisPosition) const
+static inline bool emphasisPositionHasNeitherLeftNorRight(TextEmphasisPosition emphasisPosition)
+{
+    return !(emphasisPosition & TextEmphasisPositionLeft) && !(emphasisPosition & TextEmphasisPositionRight);
+}
+
+bool InlineTextBox::emphasisMarkExistsAndIsAbove(const RenderStyle& style, bool& above) const
 {
     // This function returns true if there are text emphasis marks and they are suppressed by ruby text.
     if (style.textEmphasisMark() == TextEmphasisMarkNone)
         return false;
 
-    emphasisPosition = style.textEmphasisPosition();
-    if (emphasisPosition == TextEmphasisPositionUnder)
+    TextEmphasisPosition emphasisPosition = style.textEmphasisPosition();
+    ASSERT(!((emphasisPosition & TextEmphasisPositionOver) && (emphasisPosition & TextEmphasisPositionUnder)));
+    ASSERT(!((emphasisPosition & TextEmphasisPositionLeft) && (emphasisPosition & TextEmphasisPositionRight)));
+    
+    if (emphasisPositionHasNeitherLeftNorRight(emphasisPosition))
+        above = emphasisPosition & TextEmphasisPositionOver;
+    else if (style.isHorizontalWritingMode())
+        above = emphasisPosition & TextEmphasisPositionOver;
+    else
+        above = emphasisPosition & TextEmphasisPositionRight;
+    
+    if ((style.isHorizontalWritingMode() && (emphasisPosition & TextEmphasisPositionUnder))
+        || (!style.isHorizontalWritingMode() && (emphasisPosition & TextEmphasisPositionLeft)))
         return true; // Ruby text is always over, so it cannot suppress emphasis marks under.
 
     RenderBlock* containingBlock = renderer().containingBlock();
@@ -629,11 +645,11 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
     }
 
     int emphasisMarkOffset = 0;
-    TextEmphasisPosition emphasisMarkPosition;
-    bool hasTextEmphasis = getEmphasisMarkPosition(lineStyle, emphasisMarkPosition);
+    bool emphasisMarkAbove;
+    bool hasTextEmphasis = emphasisMarkExistsAndIsAbove(lineStyle, emphasisMarkAbove);
     const AtomicString& emphasisMark = hasTextEmphasis ? lineStyle.textEmphasisMarkString() : nullAtom;
     if (!emphasisMark.isEmpty())
-        emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark);
+        emphasisMarkOffset = emphasisMarkAbove ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark);
 
     const ShadowData* textShadow = paintInfo.forceBlackText() ? 0 : lineStyle.textShadow();
 
index b0aab3161fb5c9d92e979baa3e5a373e3b732b32..4043ffc34eeea93cefb54735b09727e29715d586 100644 (file)
@@ -89,7 +89,7 @@ public:
     virtual int baselinePosition(FontBaseline) const OVERRIDE FINAL;
     virtual LayoutUnit lineHeight() const OVERRIDE FINAL;
 
-    bool getEmphasisMarkPosition(const RenderStyle&, TextEmphasisPosition&) const;
+    bool emphasisMarkExistsAndIsAbove(const RenderStyle&, bool& isAbove) const;
 
     LayoutRect logicalOverflowRect() const;
     void setLogicalOverflowRect(const LayoutRect&);
index 98b3d4522f364e8731d97721c5618bd86ab331e5..31d71d6a70cb15e7f9029e8e80c55fa3d176adfb 100644 (file)
@@ -1769,7 +1769,7 @@ public:
     static TextEmphasisFill initialTextEmphasisFill() { return TextEmphasisFillFilled; }
     static TextEmphasisMark initialTextEmphasisMark() { return TextEmphasisMarkNone; }
     static const AtomicString& initialTextEmphasisCustomMark() { return nullAtom; }
-    static TextEmphasisPosition initialTextEmphasisPosition() { return TextEmphasisPositionOver; }
+    static TextEmphasisPosition initialTextEmphasisPosition() { return TextEmphasisPositionOver | TextEmphasisPositionRight; }
     static RubyPosition initialRubyPosition() { return RubyPositionBefore; }
     static LineBoxContain initialLineBoxContain() { return LineBoxContainBlock | LineBoxContainInline | LineBoxContainReplaced; }
     static ImageOrientationEnum initialImageOrientation() { return OriginTopLeft; }
index 8add09c0a2efe65f46bf7209a479736f49f6dc6d..2718d54d4b07f22e19739837fd1d91ac79b8b491 100644 (file)
@@ -505,7 +505,13 @@ enum TextEmphasisFill { TextEmphasisFillFilled, TextEmphasisFillOpen };
 
 enum TextEmphasisMark { TextEmphasisMarkNone, TextEmphasisMarkAuto, TextEmphasisMarkDot, TextEmphasisMarkCircle, TextEmphasisMarkDoubleCircle, TextEmphasisMarkTriangle, TextEmphasisMarkSesame, TextEmphasisMarkCustom };
 
-enum TextEmphasisPosition { TextEmphasisPositionOver, TextEmphasisPositionUnder };
+enum TextEmphasisPositions {
+    TextEmphasisPositionOver = 1 << 0,
+    TextEmphasisPositionUnder = 1 << 1,
+    TextEmphasisPositionLeft = 1 << 2,
+    TextEmphasisPositionRight = 1 << 3
+};
+typedef unsigned TextEmphasisPosition;
 
 enum TextOrientation { TextOrientationVerticalRight, TextOrientationUpright, TextOrientationSideways, TextOrientationSidewaysRight };
 
index 28b99b3cf85e0f535accd8b4a30ea8620b79d8f8..a5af5a7ff5455c85332c5b03abbf523a038831dc 100644 (file)
@@ -89,7 +89,7 @@ StyleRareInheritedData::StyleRareInheritedData()
     , hyphens(HyphensManual)
     , textEmphasisFill(TextEmphasisFillFilled)
     , textEmphasisMark(TextEmphasisMarkNone)
-    , textEmphasisPosition(TextEmphasisPositionOver)
+    , textEmphasisPosition(TextEmphasisPositionOver | TextEmphasisPositionRight)
     , m_textOrientation(TextOrientationVerticalRight)
 #if ENABLE(CSS3_TEXT)
     , m_textIndentLine(RenderStyle::initialTextIndentLine())
index fd2292a20c7617e6f0c3b141f29b3df2d13c57ac..c07a43b8441f9b10034d50b1a2b1a3eadfdd92e7 100644 (file)
@@ -97,7 +97,7 @@ public:
     unsigned hyphens : 2; // Hyphens
     unsigned textEmphasisFill : 1; // TextEmphasisFill
     unsigned textEmphasisMark : 3; // TextEmphasisMark
-    unsigned textEmphasisPosition : 1; // TextEmphasisPosition
+    unsigned textEmphasisPosition : 4; // TextEmphasisPosition
     unsigned m_textOrientation : 2; // TextOrientation
 #if ENABLE(CSS3_TEXT)
     unsigned m_textIndentLine : 1; // TextIndentLine