2011-05-15 Kenichi Ishibashi <bashi@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 May 2011 05:59:46 +0000 (05:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 May 2011 05:59:46 +0000 (05:59 +0000)
        Reviewed by Kent Tamura.

        <output>, <meter> and <progress> elements with display:block can be focused if you try to tab to it
        https://bugs.webkit.org/show_bug.cgi?id=60602

        Add a test that ensures <output>, <meter> and <progress> are not focused.
        Add tabindex attributes to <progress> elements in progressbar.html so that these elements can be focused.

        * fast/forms/focus-with-display-block-expected.txt: Added.
        * fast/forms/focus-with-display-block.html: Added.
        * platform/mac/accessibility/progressbar.html: Added tabindex attributes to progress elements.
2011-05-15  Kenichi Ishibashi  <bashi@chromium.org>

        Reviewed by Kent Tamura.

        <output>, <meter> and <progress> elements with display:block can be focused if you try to tab to it
        https://bugs.webkit.org/show_bug.cgi?id=60602

        HTMLFormControlElement::isFocusable() returns true when the element is
        visible as a block element.  However, for output, meter, and progress
        elements, the function should not return true unless they have
        tabindex attributes.  Override supportsFocus() of these elements to
        apply the result of Node::supportsFocus() because it takes care of
        whether the element has tabindex or not.

        Test: fast/forms/focus-with-display-block.html

        * html/HTMLFormControlElement.h: Made supportsFocus() protected.
        * html/HTMLMeterElement.cpp:
        (WebCore::HTMLMeterElement::supportsFocus): Added.
        * html/HTMLMeterElement.h:
        * html/HTMLOutputElement.cpp:
        (WebCore::HTMLOutputElement::supportsFocus): Added.
        * html/HTMLOutputElement.h:
        * html/HTMLProgressElement.cpp:
        (WebCore::HTMLProgressElement::supportsFocus): Added.
        * html/HTMLProgressElement.h:

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/focus-with-display-block-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/focus-with-display-block.html [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/progressbar.html
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/HTMLMeterElement.cpp
Source/WebCore/html/HTMLMeterElement.h
Source/WebCore/html/HTMLOutputElement.cpp
Source/WebCore/html/HTMLOutputElement.h
Source/WebCore/html/HTMLProgressElement.cpp
Source/WebCore/html/HTMLProgressElement.h

index 487cf07..5922ad2 100644 (file)
@@ -1,3 +1,17 @@
+2011-05-15  Kenichi Ishibashi  <bashi@chromium.org>
+
+        Reviewed by Kent Tamura.
+
+        <output>, <meter> and <progress> elements with display:block can be focused if you try to tab to it
+        https://bugs.webkit.org/show_bug.cgi?id=60602
+
+        Add a test that ensures <output>, <meter> and <progress> are not focused.
+        Add tabindex attributes to <progress> elements in progressbar.html so that these elements can be focused.
+
+        * fast/forms/focus-with-display-block-expected.txt: Added.
+        * fast/forms/focus-with-display-block.html: Added.
+        * platform/mac/accessibility/progressbar.html: Added tabindex attributes to progress elements.
+
 2011-05-12  MORITA Hajime  <morrita@google.com>
 
         Reviewed by Dimitri Glazkov.
diff --git a/LayoutTests/fast/forms/focus-with-display-block-expected.txt b/LayoutTests/fast/forms/focus-with-display-block-expected.txt
new file mode 100644 (file)
index 0000000..aed5cac
--- /dev/null
@@ -0,0 +1,16 @@
+This test ensures that <output>, <meter> and <progress> are not focused.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+- Moves the focus by using keyDown() in DRT, otherwise using element.focus().
+- checkFocus() returns true when <output>, <meter> and <progress> do not have focus.
+PASS checkFocus() is true
+PASS checkFocus() is true
+PASS checkFocus() is true
+PASS checkFocus() is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Text in output element
+
diff --git a/LayoutTests/fast/forms/focus-with-display-block.html b/LayoutTests/fast/forms/focus-with-display-block.html
new file mode 100644 (file)
index 0000000..a070412
--- /dev/null
@@ -0,0 +1,63 @@
+<!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>
+<style>
+output, meter, progress {
+    display: block;
+}
+</style>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('This test ensures that &lt;output&gt;, &lt;meter&gt; and &lt;progress&gt; are not focused.');
+
+function moveFocus(element) {
+    if (window.layoutTestController)
+        eventSender.keyDown('\t');
+    else
+        element.focus();
+}
+
+function checkFocus() {
+    var active = document.activeElement.nodeName;
+    if (active == "OUTPUT" || active == "METER" || active == "PROGRESS") {
+        debug(active + ' should not have focus.');
+        return false;
+    }
+    return true;
+}
+
+var input = document.createElement('input');
+var output = document.createElement('output');
+var progress = document.createElement('progress');
+var meter = document.createElement('meter');
+
+// Set a placeholder text to the output element to display the element.
+output.innerHTML = 'Text in output element';
+
+document.body.appendChild(input);
+document.body.appendChild(output);
+document.body.appendChild(progress);
+document.body.appendChild(meter);
+
+debug('- Moves the focus by using keyDown() in DRT, otherwise using element.focus().');
+debug('- checkFocus() returns true when &lt;output&gt;, &lt;meter&gt; and &lt;progress&gt; do not have focus.');
+
+moveFocus(input);
+shouldBeTrue('checkFocus()');
+moveFocus(output);
+shouldBeTrue('checkFocus()');
+moveFocus(progress);
+shouldBeTrue('checkFocus()');
+moveFocus(meter);
+shouldBeTrue('checkFocus()');
+
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 84f58e4..8dcc74b 100644 (file)
@@ -12,8 +12,8 @@ var successfullyParsed = false;
 <span tabindex="0" role="progressbar" id="progressbar1" aria-valuenow=7 aria-valuemin=0 aria-valuemax=10>X</span>
 <span tabindex="0" role="progressbar" id="progressbar2" aria-valuemax=10>X</span>
 
-<progress id="progressbar3" value=7 max=10></progress>
-<progress id="progressbar4"></progress>
+<progress tabindex="0" id="progressbar3" value=7 max=10></progress>
+<progress tabindex="0" id="progressbar4"></progress>
 
 <p id="description"></p>
 <div id="console"></div>
index d1afded..be77a73 100644 (file)
@@ -1,3 +1,30 @@
+2011-05-15  Kenichi Ishibashi  <bashi@chromium.org>
+
+        Reviewed by Kent Tamura.
+
+        <output>, <meter> and <progress> elements with display:block can be focused if you try to tab to it
+        https://bugs.webkit.org/show_bug.cgi?id=60602
+
+        HTMLFormControlElement::isFocusable() returns true when the element is
+        visible as a block element.  However, for output, meter, and progress
+        elements, the function should not return true unless they have
+        tabindex attributes.  Override supportsFocus() of these elements to
+        apply the result of Node::supportsFocus() because it takes care of
+        whether the element has tabindex or not.
+
+        Test: fast/forms/focus-with-display-block.html
+
+        * html/HTMLFormControlElement.h: Made supportsFocus() protected.
+        * html/HTMLMeterElement.cpp:
+        (WebCore::HTMLMeterElement::supportsFocus): Added.
+        * html/HTMLMeterElement.h:
+        * html/HTMLOutputElement.cpp:
+        (WebCore::HTMLOutputElement::supportsFocus): Added.
+        * html/HTMLOutputElement.h:
+        * html/HTMLProgressElement.cpp:
+        (WebCore::HTMLProgressElement::supportsFocus): Added.
+        * html/HTMLProgressElement.h:
+
 2011-05-15  Jon Lee  <jonlee@apple.com>
 
         Reviewed by Dan Bernstein.
index f2701af..ca2c9b8 100644 (file)
@@ -117,6 +117,7 @@ protected:
     virtual void removedFromDocument();
     virtual void willMoveToNewOwnerDocument();
 
+    virtual bool supportsFocus() const;
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isMouseFocusable() const;
 
@@ -139,8 +140,6 @@ private:
 
     virtual bool isFormControlElement() const { return true; }
 
-    virtual bool supportsFocus() const;
-
     virtual short tabIndex() const;
 
     virtual HTMLFormElement* virtualForm() const;
index 88b1622..13e02ed 100644 (file)
@@ -66,6 +66,11 @@ const AtomicString& HTMLMeterElement::formControlType() const
     return meter;
 }
 
+bool HTMLMeterElement::supportsFocus() const
+{
+    return Node::supportsFocus() && !disabled();
+}
+
 void HTMLMeterElement::parseMappedAttribute(Attribute* attribute)
 {
     if (attribute->name() == valueAttr || attribute->name() == minAttr || attribute->name() == maxAttr || attribute->name() == lowAttr || attribute->name() == highAttr || attribute->name() == optimumAttr)
index 16700db..c1c02cd 100644 (file)
@@ -65,6 +65,8 @@ private:
     HTMLMeterElement(const QualifiedName&, Document*, HTMLFormElement*);
     virtual ~HTMLMeterElement();
 
+    virtual bool supportsFocus() const;
+
     virtual bool recalcWillValidate() const { return false; }
     virtual const AtomicString& formControlType() const;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
index 8be5d91..a85bfd4 100644 (file)
@@ -56,6 +56,11 @@ const AtomicString& HTMLOutputElement::formControlType() const
     return output;
 }
 
+bool HTMLOutputElement::supportsFocus() const
+{
+    return Node::supportsFocus() && !disabled();
+}
+
 void HTMLOutputElement::parseMappedAttribute(Attribute* attr)
 {
     if (attr->name() == HTMLNames::forAttr)
index af513d9..969c6cb 100644 (file)
@@ -58,6 +58,7 @@ private:
     virtual void parseMappedAttribute(Attribute*);
     virtual const AtomicString& formControlType() const;
     virtual bool isEnumeratable() const { return true; }
+    virtual bool supportsFocus() const;
     virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     virtual void reset();
 
index 710f7e4..94f820a 100644 (file)
@@ -64,6 +64,11 @@ RenderObject* HTMLProgressElement::createRenderer(RenderArena* arena, RenderStyl
     return new (arena) RenderProgress(this);
 }
 
+bool HTMLProgressElement::supportsFocus() const
+{
+    return Node::supportsFocus() && !disabled();
+}
+
 const AtomicString& HTMLProgressElement::formControlType() const
 {
     DEFINE_STATIC_LOCAL(const AtomicString, progress, ("progress"));
index 0148599..4e4a4e0 100644 (file)
@@ -49,6 +49,8 @@ private:
     HTMLProgressElement(const QualifiedName&, Document*, HTMLFormElement*);
     virtual ~HTMLProgressElement();
 
+    virtual bool supportsFocus() const;
+
     virtual bool recalcWillValidate() const { return false; }
 
     virtual const AtomicString& formControlType() const;