AX: add "alt" as an overriding synonym of "-webkit-alt" (now in the CSS4 spec)
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Nov 2014 02:16:09 +0000 (02:16 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Nov 2014 02:16:09 +0000 (02:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138393

Reviewed by Dean Jackson.

Source/WebCore:

Add official "alt" CSS keyword and map -webkit-alt to that.

Test: platform/mac/accessibility/alt-for-css-content.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSPropertyNames.in:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):

LayoutTests:

* platform/mac/accessibility/alt-for-css-content-expected.txt: Added.
* platform/mac/accessibility/alt-for-css-content.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/alt-for-css-content-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/alt-for-css-content.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/StyleResolver.cpp

index 79f308e..a761b11 100644 (file)
@@ -1,3 +1,13 @@
+2014-11-05  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: add "alt" as an overriding synonym of "-webkit-alt" (now in the CSS4 spec)
+        https://bugs.webkit.org/show_bug.cgi?id=138393
+
+        Reviewed by Dean Jackson.
+
+        * platform/mac/accessibility/alt-for-css-content-expected.txt: Added.
+        * platform/mac/accessibility/alt-for-css-content.html: Added.
+
 2014-11-05  Dan Bernstein  <mitz@apple.com>
 
         Remove the unused deletion UI feature
diff --git a/LayoutTests/platform/mac/accessibility/alt-for-css-content-expected.txt b/LayoutTests/platform/mac/accessibility/alt-for-css-content-expected.txt
new file mode 100644 (file)
index 0000000..d6cc3ca
--- /dev/null
@@ -0,0 +1,52 @@
+This tests that alt (formerly known as -webkit-alt) applies to text and image content in CSS styles, and that it makes it to accessibility.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test1 - alt on image content with attr() function
+AXRole: AXImage
+AXDescription: ALTERNATIVE CONTENT TEST1
+AXTitle: 
+AXValue: 
+
+Test2 - alt on image content that is a string
+AXRole: AXImage
+AXDescription: ALTERNATIVE CONTENT TEST2
+AXTitle: 
+AXValue: 
+
+Test3 - alt on image content that is an empty string - representing that it should be ignored.
+AXRole: 
+AXDescription: 
+AXTitle: 
+AXValue: 
+
+Test4 - alt on text content
+AXRole: AXStaticText
+AXDescription: 
+AXTitle: 
+AXValue: ALTERNATIVE CONTENT TEST4
+
+Test5 - alt on text content that is an empty string - representing that is should be ignored.
+AXRole: AXStaticText
+AXDescription: 
+AXTitle: 
+AXValue: test5
+
+Test6 - alt on text content that uses the attr() function.
+AXRole: AXStaticText
+AXDescription: 
+AXTitle: 
+AXValue: ALTERNATIVE CONTENT TEST6
+
+alt accessed through Javascript: 'ALTERNATIVE CONTENT TEST2'
+Test7 - alt does not apply to DOM nodes.
+AXRole: AXImage
+AXDescription: This is the right text
+AXTitle: 
+AXValue: 
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/alt-for-css-content.html b/LayoutTests/platform/mac/accessibility/alt-for-css-content.html
new file mode 100644 (file)
index 0000000..695fa7c
--- /dev/null
@@ -0,0 +1,113 @@
+<!DOCTYPE html>
+<html>
+<title id="title">TITLE</title>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+
+<style>
+
+/* alt on image content with attr() function. */
+[test1]::after {
+    content: url(resources/cake.png);
+    alt: attr(test1);
+}
+
+/* alt on image content that is a string. */
+.test2::after {
+    content: url(resources/cake.png);
+    alt: "ALTERNATIVE CONTENT TEST2";
+}
+
+/* alt on image content that is an empty string - representing that it should be ignored. */
+.test3::after {
+    content: url(resources/cake.png);
+    alt: "";
+}
+
+/* alt on text content. */
+[aria-expanded="test4"]::before {
+    content: "\25BB";
+    alt: "ALTERNATIVE CONTENT TEST4";
+}
+
+/* alt on text content that is an empty string - representing that is should be ignored. */
+[aria-expanded="test5"]::before {
+    content: "\25BC";
+    alt: "";
+}
+
+/* alt on text content that uses the attr() function. */
+[aria-expanded="test6"]::before {
+    content: "\25BC";
+    alt: attr(test6);
+}
+</style>
+
+<div id="content">
+<div id="test1" test1="ALTERNATIVE CONTENT TEST1">test1</div>
+<div id="test2" class="test2">test2</div>
+<div id="test3" class="test3">test3</div>
+<div id="test4" aria-expanded="test4">test4</div>
+<div id="test5" test5="ALTERNATIVE CONTENT TEST5" aria-expanded="test5">test5</div>
+<div id="test6" test6="ALTERNATIVE CONTENT TEST6" aria-expanded="test6">test6</div>
+
+<img id="image1" src="#" alt="This is the right text" style="width:100px; height:100px; -webkit-alt: 'this is the wrong text';">
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that alt (formerly known as -webkit-alt) applies to text and image content in CSS styles, and that it makes it to accessibility.");
+    
+    function outputElement(element) {
+        var role = "AXRole: ";
+        var description = "AXDescription: ";
+        var title = "AXTitle: ";
+        var value = "AXValue: ";
+        if (element) {
+            role = element.role;
+            description = element.description;
+            title = element.title;
+            value = element.stringValue;
+        }
+        debug(role);
+        debug(description);
+        debug(title);
+        debug(value + "\n");
+    }
+
+    if (window.accessibilityController) {
+        debug("Test1 - alt on image content with attr() function");
+        outputElement(accessibilityController.accessibleElementById("test1").childAtIndex(1));
+
+        debug("Test2 - alt on image content that is a string");
+        outputElement(accessibilityController.accessibleElementById("test2").childAtIndex(1));
+
+        debug("Test3 - alt on image content that is an empty string - representing that it should be ignored.");
+        outputElement(accessibilityController.accessibleElementById("test3").childAtIndex(1));
+
+        debug("Test4 - alt on text content");
+        outputElement(accessibilityController.accessibleElementById("test4").childAtIndex(0));
+
+        debug("Test5 - alt on text content that is an empty string - representing that is should be ignored.");
+        outputElement(accessibilityController.accessibleElementById("test5").childAtIndex(0));
+
+        debug("Test6 - alt on text content that uses the attr() function.");
+        outputElement(accessibilityController.accessibleElementById("test6").childAtIndex(0));
+
+        debug("alt accessed through Javascript: " + getComputedStyle(document.getElementById("test2"), ':after').alt);
+
+        debug("Test7 - alt does not apply to DOM nodes.");
+        outputElement(accessibilityController.accessibleElementById("image1"));
+
+        document.getElementById("content").style.visibility = "hidden";
+    }
+
+</script>
+
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index 6447cb2..94f961c 100644 (file)
@@ -1,3 +1,22 @@
+2014-11-05  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: add "alt" as an overriding synonym of "-webkit-alt" (now in the CSS4 spec)
+        https://bugs.webkit.org/show_bug.cgi?id=138393
+
+        Reviewed by Dean Jackson.
+
+        Add official "alt" CSS keyword and map -webkit-alt to that.
+
+        Test: platform/mac/accessibility/alt-for-css-content.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSPropertyNames.in:
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyProperty):
+
 2014-11-05  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Unreviewed, EFL build fix since r175647
index 2ba84fd..891f401 100644 (file)
@@ -91,6 +91,7 @@ namespace WebCore {
 
 // List of all properties we know how to compute, omitting shorthands.
 static const CSSPropertyID computedProperties[] = {
+    CSSPropertyAlt,
     CSSPropertyBackgroundAttachment,
     CSSPropertyBackgroundBlendMode,
     CSSPropertyBackgroundClip,
@@ -224,7 +225,6 @@ static const CSSPropertyID computedProperties[] = {
     CSSPropertyZIndex,
     CSSPropertyZoom,
 
-    CSSPropertyWebkitAlt,
     CSSPropertyWebkitAnimationDelay,
     CSSPropertyWebkitAnimationDirection,
     CSSPropertyWebkitAnimationDuration,
@@ -2840,7 +2840,7 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
             return CSSPrimitiveValue::create(style->textOrientation());
         case CSSPropertyWebkitLineBoxContain:
             return createLineBoxContainValue(style->lineBoxContain());
-        case CSSPropertyWebkitAlt:
+        case CSSPropertyAlt:
             return altTextToCSSValue(style.get());
         case CSSPropertyContent:
             return contentToCSSValue(style.get());
index 5dd1587..c7c4f64 100644 (file)
@@ -1867,7 +1867,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
         // close-quote | no-open-quote | no-close-quote ]+ | inherit
         return parseContent(propId, important);
 
-    case CSSPropertyWebkitAlt: // [ <string> | attr(X) ]
+    case CSSPropertyAlt: // [ <string> | attr(X) ]
         return parseAlt(propId, important);
             
     case CSSPropertyClip:                 // <shape> | auto | inherit
index 1f58588..2f1605b 100644 (file)
@@ -256,7 +256,8 @@ word-break [Inherited, NewStyleBuilder]
 word-spacing [Inherited]
 word-wrap [Inherited, NewStyleBuilder=EOverflowWrap, NameForMethods=OverflowWrap]
 z-index
--webkit-alt
+alt
+-webkit-alt = alt
 -webkit-animation
 -webkit-animation-delay
 -webkit-animation-direction
index c2af71b..00d470e 100644 (file)
@@ -2230,7 +2230,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
                 state.style()->clearContent();
             return;
         }
-    case CSSPropertyWebkitAlt:
+    case CSSPropertyAlt:
         {
             bool didSet = false;
             if (primitiveValue->isString()) {