2011-02-06 Dominic Cooney <dominicc@google.com>
authormorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Feb 2011 01:40:17 +0000 (01:40 +0000)
committermorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Feb 2011 01:40:17 +0000 (01:40 +0000)
        Reviewed by Dimitri Glazkov.

        Convert <keygen> option elements to a shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=51379

        * html5lib/runner-expected.txt: Two more tests pass.
        * platform/mac/fast/html/keygen-expected.txt: Shadow render tree.
        * platform/mac/fast/invalid/residual-style-expected.txt:
2011-02-03  Dominic Cooney  <dominicc@google.com>

        Reviewed by Dimitri Glazkov.

        Convert <keygen> option elements to a shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=51379

        Covered by existing tests e.g. fast/html/keygen.html,
        html5lib/runner.html, etc.

        * css/html.css:
        (form): Cleanup.
        (keygen, select): Border radii should match so focus ring looks good.
        (keygen::-webkit-keygen-select): No margin on the shadow element.
        (select): Hoisting border radius to keygen, select rule.
        * dom/SelectElement.cpp:
        (WebCore::toSelectElement): keygen is no longer a select element.
        * html/HTMLKeygenElement.cpp: Implements keygen shadow.
        (WebCore::KeygenSelectElement::create):
        (WebCore::KeygenSelectElement::shadowPseudoId):
        (WebCore::KeygenSelectElement::KeygenSelectElement):
        (WebCore::HTMLKeygenElement::HTMLKeygenElement):
        (WebCore::HTMLKeygenElement::parseMappedAttribute):
        (WebCore::HTMLKeygenElement::appendFormData):
        (WebCore::HTMLKeygenElement::formControlType):
        (WebCore::HTMLKeygenElement::reset):
        (WebCore::HTMLKeygenElement::selectShadow):
        * html/HTMLKeygenElement.h: keygen is no longer a select on C++ side.
        (WebCore::HTMLKeygenElement::canStartSelection):
        (WebCore::HTMLKeygenElement::isEnumeratable):
        (WebCore::HTMLKeygenElement::isResettable):
        * html/HTMLOptionElement.cpp:
        (WebCore::HTMLOptionElement::ownerSelectElement): Only owned by selects.
        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::HTMLSelectElement): Only 'select' tag name.

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/html5lib/runner-expected.txt
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/fast/html/keygen-expected.txt
LayoutTests/platform/mac/fast/invalid/residual-style-expected.txt
LayoutTests/platform/qt/Skipped
Source/WebCore/ChangeLog
Source/WebCore/css/html.css
Source/WebCore/dom/SelectElement.cpp
Source/WebCore/html/HTMLKeygenElement.cpp
Source/WebCore/html/HTMLKeygenElement.h
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLSelectElement.cpp

index 8f302bc..0c0dd0e 100644 (file)
@@ -1,3 +1,14 @@
+2011-02-06  Dominic Cooney  <dominicc@google.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        Convert <keygen> option elements to a shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=51379
+
+        * html5lib/runner-expected.txt: Two more tests pass.
+        * platform/mac/fast/html/keygen-expected.txt: Shadow render tree.
+        * platform/mac/fast/invalid/residual-style-expected.txt:
+
 2011-02-06  Patrick Gansterer  <paroga@webkit.org>
 
         Reviewed by Oliver Hunt.
index 1dd95a1..a3872ec 100644 (file)
@@ -27,29 +27,8 @@ resources/tests5.dat: PASS
 
 resources/tests6.dat: PASS
 
-resources/tests7.dat:
-30
+resources/tests7.dat: PASS
 
-Test 30 of 30 in resources/tests7.dat failed. Input:
-<select><keygen>
-Got:
-| <html>
-|   <head>
-|   <body>
-|     <select>
-|     <keygen>
-|       <option>
-|         "2048 (High Grade)"
-|       <option>
-|         "1024 (Medium Grade)"
-|       <option>
-|         "512 (Low Grade)"
-Expected:
-| <html>
-|   <head>
-|   <body>
-|     <select>
-|     <keygen>
 resources/tests8.dat: PASS
 
 resources/tests9.dat:
@@ -249,7 +228,6 @@ resources/tests18.dat: PASS
 resources/tests19.dat:
 31
 32
-63
 78
 
 Test 31 of 97 in resources/tests19.dat failed. Input:
@@ -298,27 +276,6 @@ Expected:
 |     <p>
 |     <h1>
 
-Test 63 of 97 in resources/tests19.dat failed. Input:
-<!doctype html><keygen><frameset>
-Got:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <keygen>
-|       <option>
-|         "2048 (High Grade)"
-|       <option>
-|         "1024 (Medium Grade)"
-|       <option>
-|         "512 (Low Grade)"
-Expected:
-| <!DOCTYPE html>
-| <html>
-|   <head>
-|   <body>
-|     <keygen>
-
 Test 78 of 97 in resources/tests19.dat failed. Input:
 <!doctype html><p><math><mn><span></p>a
 Got:
index 0315604..23606c5 100644 (file)
@@ -4386,10 +4386,6 @@ svg/dom/path-parser.html
 http/tests/security/401-logout/401-logout.php
 http/tests/xmlhttprequest/remember-bad-password.html
 
-# There's somethign strange going on with <keygen> that causes a
-# different DOM to be created.
-html5lib/runner.html
-
 # Still failing, looks like a bug in the EventSender drag-and-drop
 fast/css/user-drag-none.html
 
index 81504be..6da83e5 100644 (file)
@@ -3,8 +3,9 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderMenuList {KEYGEN} at (2,2) size 148x18 [bgcolor=#FFFFFF]
-        RenderBlock (anonymous) at (0,0) size 148x18
-          RenderText at (8,2) size 99x13
-            text run at (8,2) width 99: "2048 (High Grade)"
+      RenderBlock {KEYGEN} at (2,2) size 148x18
+        RenderMenuList {SELECT} at (0,0) size 148x18 [bgcolor=#FFFFFF]
+          RenderBlock (anonymous) at (0,0) size 148x18
+            RenderText at (8,2) size 99x13
+              text run at (8,2) width 99: "2048 (High Grade)"
       RenderText {#text} at (0,0) size 0x0
index c3aebb6..5e1851f 100644 (file)
@@ -444,10 +444,11 @@ layer at (0,0) size 785x3441
       RenderBlock (anonymous) at (0,1911) size 769x22
         RenderText {#text} at (0,1) size 76x18
           text run at (0,1) width 76: "KEYGEN: "
-        RenderMenuList {KEYGEN} at (78,2) size 148x18 [bgcolor=#FFFFFF]
-          RenderBlock (anonymous) at (0,0) size 148x18
-            RenderText at (8,2) size 99x13
-              text run at (8,2) width 99: "2048 (High Grade)"
+        RenderBlock {KEYGEN} at (78,2) size 148x18
+          RenderMenuList {SELECT} at (0,0) size 148x18 [bgcolor=#FFFFFF]
+            RenderBlock (anonymous) at (0,0) size 148x18
+              RenderText at (8,2) size 99x13
+                text run at (8,2) width 99: "2048 (High Grade)"
         RenderInline {FONT} at (0,0) size 171x18 [color=#008000]
           RenderText {#text} at (228,1) size 171x18
             text run at (228,1) width 171: "All of this should be green."
index cd06ded..bf4dc00 100644 (file)
@@ -4824,10 +4824,6 @@ http/tests/misc/webtiming-slow-load.php
 http/tests/security/401-logout/401-logout.php
 http/tests/xmlhttprequest/remember-bad-password.html
 
-# There's somethign strange going on with <keygen> that causes a
-# different DOM to be created.
-html5lib/runner.html
-
 # The feature was disabled due to a compatibility issue.
 # https://bugs.webkit.org/show_bug.cgi?id=40520
 fast/forms/interactive-validation-lost-focusable.html
index 36c356b..0203921 100644 (file)
@@ -1,3 +1,39 @@
+2011-02-03  Dominic Cooney  <dominicc@google.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        Convert <keygen> option elements to a shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=51379
+
+        Covered by existing tests e.g. fast/html/keygen.html,
+        html5lib/runner.html, etc.
+
+        * css/html.css:
+        (form): Cleanup.
+        (keygen, select): Border radii should match so focus ring looks good.
+        (keygen::-webkit-keygen-select): No margin on the shadow element.
+        (select): Hoisting border radius to keygen, select rule.
+        * dom/SelectElement.cpp:
+        (WebCore::toSelectElement): keygen is no longer a select element.
+        * html/HTMLKeygenElement.cpp: Implements keygen shadow.
+        (WebCore::KeygenSelectElement::create):
+        (WebCore::KeygenSelectElement::shadowPseudoId):
+        (WebCore::KeygenSelectElement::KeygenSelectElement):
+        (WebCore::HTMLKeygenElement::HTMLKeygenElement):
+        (WebCore::HTMLKeygenElement::parseMappedAttribute):
+        (WebCore::HTMLKeygenElement::appendFormData):
+        (WebCore::HTMLKeygenElement::formControlType):
+        (WebCore::HTMLKeygenElement::reset):
+        (WebCore::HTMLKeygenElement::selectShadow):
+        * html/HTMLKeygenElement.h: keygen is no longer a select on C++ side.
+        (WebCore::HTMLKeygenElement::canStartSelection):
+        (WebCore::HTMLKeygenElement::isEnumeratable):
+        (WebCore::HTMLKeygenElement::isResettable):
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::ownerSelectElement): Only owned by selects.
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::HTMLSelectElement): Only 'select' tag name.
+
 2011-02-06  Benjamin Poulain  <ikipou@gmail.com>
 
         Reviewed by Kenneth Rohde Christiansen.
index bc7a445..0f13fcb 100644 (file)
@@ -323,7 +323,7 @@ ol ul, ul ol, ul ul, ol ol {
 
 form {
     display: block;
-    margin-top: 0__qem
+    margin-top: 0__qem;
 }
 
 label {
@@ -433,6 +433,14 @@ input::-webkit-input-speech-button {
     display: inline-block;
 }
 
+keygen, select {
+    -webkit-border-radius: 5px;
+}
+
+keygen::-webkit-keygen-select {
+    margin: 0px;
+}
+
 textarea {
     -webkit-appearance: textarea;
     background-color: white;
@@ -535,12 +543,11 @@ input[type="radio"] {
     -webkit-box-sizing: border-box;
 }
 
-keygen, select {
+select {
     -webkit-appearance: menulist;
     -webkit-box-sizing: border-box;
     -webkit-box-align: center;
     border: 1px solid;
-    -webkit-border-radius: 5px;
     white-space: pre;
     -webkit-rtl-ordering: logical;
     color: black;
index a66d803..a4da0ae 100644 (file)
@@ -30,7 +30,6 @@
 #include "FormDataList.h"
 #include "Frame.h"
 #include "HTMLFormElement.h"
-#include "HTMLKeygenElement.h"
 #include "HTMLNames.h"
 #include "HTMLSelectElement.h"
 #include "KeyboardEvent.h"
@@ -1027,12 +1026,8 @@ const Vector<Element*>& SelectElementData::listItems(const Element* element) con
 
 SelectElement* toSelectElement(Element* element)
 {
-    if (element->isHTMLElement()) {
-        if (element->hasTagName(HTMLNames::selectTag))
-            return static_cast<HTMLSelectElement*>(element);
-        if (element->hasTagName(HTMLNames::keygenTag))
-            return static_cast<HTMLKeygenElement*>(element);
-    }
+    if (element->isHTMLElement() && element->hasTagName(HTMLNames::selectTag))
+        return static_cast<HTMLSelectElement*>(element);
 
 #if ENABLE(WML)
     if (element->isWMLElement() && element->hasTagName(WMLNames::selectTag))
index 881a0a8..b90335e 100644 (file)
@@ -29,6 +29,7 @@
 #include "Document.h"
 #include "FormDataList.h"
 #include "HTMLNames.h"
+#include "HTMLSelectElement.h"
 #include "HTMLOptionElement.h"
 #include "SSLKeyGenerator.h"
 #include "Text.h"
@@ -40,20 +41,41 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
+class KeygenSelectElement : public HTMLSelectElement {
+public:
+    static PassRefPtr<KeygenSelectElement> create(Document* document)
+    {
+        return adoptRef(new KeygenSelectElement(document));
+    }
+
+    virtual const AtomicString& shadowPseudoId() const
+    {
+        DEFINE_STATIC_LOCAL(AtomicString, pseudoId, ("-webkit-keygen-select"));
+        return pseudoId;
+    }
+
+protected:
+    KeygenSelectElement(Document* document)
+        : HTMLSelectElement(selectTag, document, 0)
+    {
+    }
+};
+
 inline HTMLKeygenElement::HTMLKeygenElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
-    : HTMLSelectElement(tagName, document, form)
+    : HTMLFormControlElementWithState(tagName, document, form)
 {
     ASSERT(hasTagName(keygenTag));
 
-    // FIXME: This markup should go in the shadow tree.
-    // Add one option element for each key size.
+    // Create a select element with one option element for each key size.
+    RefPtr<HTMLSelectElement> select = KeygenSelectElement::create(document);
     Vector<String> keys;
     getSupportedKeySizes(keys);
     for (size_t i = 0; i < keys.size(); ++i) {
         RefPtr<HTMLOptionElement> option = HTMLOptionElement::create(document, this->form());
-        parserAddChild(option);
+        select->parserAddChild(option);
         option->parserAddChild(Text::create(document, keys[i]));
     }
+    setShadowRoot(select);
 }
 
 PassRefPtr<HTMLKeygenElement> HTMLKeygenElement::create(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
@@ -61,22 +83,18 @@ PassRefPtr<HTMLKeygenElement> HTMLKeygenElement::create(const QualifiedName& tag
     return adoptRef(new HTMLKeygenElement(tagName, document, form));
 }
 
-const AtomicString& HTMLKeygenElement::formControlType() const
-{
-    DEFINE_STATIC_LOCAL(const AtomicString, keygen, ("keygen"));
-    return keygen;
-}
-
 void HTMLKeygenElement::parseMappedAttribute(Attribute* attr)
 {
+    // Reflect disabled attribute on the shadow select element
+    if (attr->name() == disabledAttr)
+        selectShadow()->setAttribute(attr->name(), attr->value());
+
     if (attr->name() == challengeAttr)
         m_challenge = attr->value();
     else if (attr->name() == keytypeAttr)
         m_keyType = attr->value();
-    else {
-        // Skip HTMLSelectElement parsing.
+    else
         HTMLFormControlElement::parseMappedAttribute(attr);
-    }
 }
 
 bool HTMLKeygenElement::appendFormData(FormDataList& encoded_values, bool)
@@ -84,11 +102,27 @@ bool HTMLKeygenElement::appendFormData(FormDataList& encoded_values, bool)
     // Only RSA is supported at this time.
     if (!m_keyType.isNull() && !equalIgnoringCase(m_keyType, "rsa"))
         return false;
-    String value = signedPublicKeyAndChallengeString(selectedIndex(), m_challenge, document()->baseURL());
+    String value = signedPublicKeyAndChallengeString(selectShadow()->selectedIndex(), m_challenge, document()->baseURL());
     if (value.isNull())
         return false;
     encoded_values.appendData(name(), value.utf8());
     return true;
 }
 
+const AtomicString& HTMLKeygenElement::formControlType() const
+{
+    DEFINE_STATIC_LOCAL(const AtomicString, keygen, ("keygen"));
+    return keygen;
+}
+
+void HTMLKeygenElement::reset()
+{
+    static_cast<HTMLFormControlElement*>(selectShadow())->reset();
+}
+
+HTMLSelectElement* HTMLKeygenElement::selectShadow()
+{
+    return static_cast<HTMLSelectElement*>(shadowRoot());
+}
+
 } // namespace
index 3dc4ad2..a7a8a64 100644 (file)
 #ifndef HTMLKeygenElement_h
 #define HTMLKeygenElement_h
 
-#include "HTMLSelectElement.h"
+#include "HTMLFormControlElement.h"
 
 namespace WebCore {
 
-class HTMLKeygenElement : public HTMLSelectElement {
+class HTMLSelectElement;
+
+class HTMLKeygenElement : public HTMLFormControlElementWithState {
 public:
     static PassRefPtr<HTMLKeygenElement> create(const QualifiedName&, Document*, HTMLFormElement*);
 
@@ -37,13 +39,21 @@ public:
 private:
     HTMLKeygenElement(const QualifiedName&, Document*, HTMLFormElement*);
 
-    virtual bool isResettable() const { return true; }
+    virtual bool canStartSelection() const { return false; }
 
-    virtual const AtomicString& formControlType() const;
     virtual void parseMappedAttribute(Attribute*);
+
     virtual bool appendFormData(FormDataList&, bool);
+    virtual const AtomicString& formControlType() const;
     virtual bool isOptionalFormControl() const { return false; }
 
+    virtual bool isEnumeratable() const { return true; }
+
+    virtual bool isResettable() const { return true; }
+    virtual void reset();
+
+    HTMLSelectElement* selectShadow();
+
     AtomicString m_challenge;
     AtomicString m_keyType;
 };
index bc5788d..966f837 100644 (file)
@@ -194,7 +194,7 @@ void HTMLOptionElement::childrenChanged(bool changedByParser, Node* beforeChange
 HTMLSelectElement* HTMLOptionElement::ownerSelectElement() const
 {
     ContainerNode* select = parentNode();
-    while (select && !(select->hasTagName(selectTag) || select->hasTagName(keygenTag)))
+    while (select && !select->hasTagName(selectTag))
         select = select->parentNode();
 
     if (!select)
index da72aa9..91f860b 100644 (file)
@@ -49,7 +49,7 @@ static const unsigned maxSelectItems = 10000;
 HTMLSelectElement::HTMLSelectElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
     : HTMLFormControlElementWithState(tagName, document, form)
 {
-    ASSERT(hasTagName(selectTag) || hasTagName(keygenTag));
+    ASSERT(hasTagName(selectTag));
 }
 
 PassRefPtr<HTMLSelectElement> HTMLSelectElement::create(const QualifiedName& tagName, Document* document, HTMLFormElement* form)