WebCore:

2008-06-17  Michelangelo De Simone  <m.des@mac.com>

        Reviewed by Adele.
        
        Fix for https://bugs.webkit.org/show_bug.cgi?id=18887
        Added support for autofocus controls.

        When authors specify the "autofocus" attribute on form controls these 
        acquire focus automatically as the document is rendered.

        Tests: fast/forms/autofocus-attribute.html
               fast/forms/autofocus-opera-001.html
               fast/forms/autofocus-opera-002.html
               fast/forms/autofocus-opera-003.html
               fast/forms/autofocus-opera-004.html
               fast/forms/autofocus-opera-005.html
               fast/forms/autofocus-opera-006.html
               fast/forms/autofocus-opera-007.html
               fast/forms/autofocus-opera-008.html

        * dom/Document.cpp: (WebCore::Document::Document): Initialize the flag to ignore autofocus.
        * dom/Document.h:
        * html/HTMLAttributeNames.in:
        * html/HTMLButtonElement.idl:
        * html/HTMLFormControlElement.cpp:
        (WebCore::HTMLFormControlElement::attach): Sets focus onto the appropriate "autofocus" control
        (WebCore::HTMLFormControlElement::autofocus): Autofocus attribute getter
        (WebCore::HTMLFormControlElement::setAutofocus): Autofocus attribute setter
        * html/HTMLFormControlElement.h:
        * html/HTMLInputElement.idl:
        * html/HTMLSelectElement.idl:
        * html/HTMLTextAreaElement.idl:
        * rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::setUserEdited):
          Sets the "ignore autofocus" flag on document if the user edited the control.
        * rendering/RenderTextControl.h:

LayoutTests:

2008-06-17  Michelangelo De Simone  <m.des@mac.com>

        Reviewed by Adele.

        Tests for https://bugs.webkit.org/show_bug.cgi?id=18887
        Added support for autofocus controls.

        Test cases "autofocus-opera*" have been imported from the Opera test suite
        originally located at:
        http://tc.labs.opera.com/html/forms/input/common-attributes/autofocus/
        
        * fast/dom/domListEnumeration-expected.txt:
        * fast/dom/resources/domListEnumeration.js:
        * fast/forms/autofocus-attribute-expected.txt: Added.
        * fast/forms/autofocus-attribute.html: Added.
        * fast/forms/autofocus-opera-001-expected.txt: Added.
        * fast/forms/autofocus-opera-001.html: Added.
        * fast/forms/autofocus-opera-002-expected.txt: Added.
        * fast/forms/autofocus-opera-002.html: Added.
        * fast/forms/autofocus-opera-003-expected.txt: Added.
        * fast/forms/autofocus-opera-003.html: Added.
        * fast/forms/autofocus-opera-004-expected.txt: Added.
        * fast/forms/autofocus-opera-004.html: Added.
        * fast/forms/autofocus-opera-005-expected.txt: Added.
        * fast/forms/autofocus-opera-005.html: Added.
        * fast/forms/autofocus-opera-006-expected.txt: Added.
        * fast/forms/autofocus-opera-006.html: Added.
        * fast/forms/autofocus-opera-007-expected.txt: Added.
        * fast/forms/autofocus-opera-007.html: Added.
        * fast/forms/autofocus-opera-008-expected.txt: Added.
        * fast/forms/autofocus-opera-008.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 8f01c99..b67923e 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -302,6 +302,8 @@
     m_document.resetSkippingRef(this);
 
     m_printing = false;
+    
+    m_ignoreAutofocus = false;
 
     m_frame = frame;
     m_renderArena = 0;
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index a1349a1..81a08d0 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -482,6 +482,11 @@
     bool setFocusedNode(PassRefPtr<Node>);
     Node* focusedNode() const { return m_focusedNode.get(); }
 
+    // The m_ignoreAutofocus flag specifies whether or not the document has been changed by the user enough 
+    // for WebCore to ignore the autofocus attribute on any form controls
+    bool ignoreAutofocus() const { return m_ignoreAutofocus; };
+    void setIgnoreAutofocus(bool shouldIgnore = true) { m_ignoreAutofocus = shouldIgnore; };
+
     void setHoverNode(PassRefPtr<Node>);
     Node* hoverNode() const { return m_hoverNode.get(); }
 
@@ -805,6 +810,8 @@
     RefPtr<CSSStyleSheet> m_mappedElementSheet;
 
     bool m_printing;
+    
+    bool m_ignoreAutofocus;
 
     ParseMode m_parseMode;