Reviewed by Maciej.
authorvicki <vicki@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2005 06:01:45 +0000 (06:01 +0000)
committervicki <vicki@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2005 06:01:45 +0000 (06:01 +0000)
- fixed <rdar://problem/3871669> no focus or blur methods on HTML button elements

        * khtml/dom/html_form.cpp:
        (HTMLButtonElement::focus):
        (HTMLButtonElement::blur):
        * khtml/dom/html_form.h:
        * khtml/ecma/kjs_html.cpp:
        (KJS::HTMLElementFunction::tryCall):
        * khtml/ecma/kjs_html.h:
        (KJS::HTMLElement::):
        * khtml/ecma/kjs_html.lut.h:
        (KJS::):
        * khtml/html/html_formimpl.cpp:
        (DOM::HTMLButtonElementImpl::blur):
        (DOM::HTMLButtonElementImpl::focus):
        * khtml/html/html_formimpl.h:

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/dom/html_form.cpp
WebCore/khtml/dom/html_form.h
WebCore/khtml/ecma/kjs_html.cpp
WebCore/khtml/ecma/kjs_html.h
WebCore/khtml/ecma/kjs_html.lut.h
WebCore/khtml/html/html_formimpl.cpp
WebCore/khtml/html/html_formimpl.h

index 7b5b7667b55e1d55cd3472f5a78751f7ef3ebd4b..6c94c6a9713c1ea2abcdfa3fea34a648728e91ce 100644 (file)
@@ -1,3 +1,24 @@
+2005-04-04  Vicki Murley  <vicki@apple.com>
+
+        Reviewed by Maciej.
+
+       - fixed <rdar://problem/3871669> no focus or blur methods on HTML button elements
+
+        * khtml/dom/html_form.cpp:
+        (HTMLButtonElement::focus): 
+        (HTMLButtonElement::blur): 
+        * khtml/dom/html_form.h: 
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::HTMLElementFunction::tryCall):
+        * khtml/ecma/kjs_html.h:
+        (KJS::HTMLElement::):
+        * khtml/ecma/kjs_html.lut.h:
+        (KJS::):
+        * khtml/html/html_formimpl.cpp:
+        (DOM::HTMLButtonElementImpl::blur):
+        (DOM::HTMLButtonElementImpl::focus):
+        * khtml/html/html_formimpl.h:
+
 === WebCore-415 ===
 
 2005-03-28  David Harrison  <harrison@apple.com>
index ea6caa8b54373c219233df09de7915a4da0f9a62..60d8451614c835fc00fa28d74999acd034b0a778 100644 (file)
@@ -100,6 +100,18 @@ void HTMLButtonElement::setName( const DOMString &value )
     if(impl) static_cast<ElementImpl*>(impl)->setAttribute(ATTR_NAME, value);
 }
 
+void HTMLButtonElement::focus(  )
+{
+    if(impl)
+       ((HTMLButtonElementImpl*)impl)->focus();
+}
+
+void HTMLButtonElement::blur(  )
+{
+    if(impl)
+       ((HTMLButtonElementImpl*)impl)->blur();
+}
+
 long HTMLButtonElement::tabIndex() const
 {
     if(!impl) return 0;
index a2d6fe0b93978c96e976de29412f6471526d4d26..4147094ed986cda7a2e94518f6369064cc08aae7 100644 (file)
@@ -109,7 +109,7 @@ public:
      * see @ref name
      */
     void setName( const DOMString & );
-
+    
     /**
      * Index that represents the element's position in the tabbing
      * order. See the <a
@@ -144,8 +144,19 @@ public:
      * see @ref value
      */
     void setValue( const DOMString & );
+    
+    /**
+     * Removes keyboard focus from this element.
+     *
+     */
+    void blur (  );
+        
+    /**
+     * Gives keyboard focus to this element.
+     *
+     */
+    void focus (  );
 };
-
 // --------------------------------------------------------------------------
 
 class HTMLFieldSetElementImpl;
index 1866820ca8255bddf432e2dd7dc4f33c6857e59a..d2dd939042fe3d1897bd10e552382d5b08c373c0 100644 (file)
@@ -818,6 +818,8 @@ const ClassInfo* KJS::HTMLElement::classInfo() const
   tabIndex     KJS::HTMLElement::ButtonTabIndex        DontDelete
   type         KJS::HTMLElement::ButtonType            DontDelete|ReadOnly
   value                KJS::HTMLElement::ButtonValue           DontDelete
+  blur         KJS::HTMLElement::ButtonBlur            DontDelete|Function 0
+  focus                KJS::HTMLElement::ButtonFocus           DontDelete|Function 0
 @end
 @begin HTMLLabelElementTable 3
   form         KJS::HTMLElement::LabelForm             DontDelete|ReadOnly
@@ -2169,6 +2171,19 @@ Value KJS::HTMLElementFunction::tryCall(ExecState *exec, Object &thisObj, const
       }
     }
     break;
+    case ID_BUTTON: {
+      DOM::HTMLButtonElement button = element;
+      
+      if (id == KJS::HTMLElement::ButtonBlur) {
+        button.blur();
+        return Undefined();
+      }
+      else if (id == KJS::HTMLElement::ButtonFocus) {
+        button.focus();
+        return Undefined();
+      }
+    }
+    break;
     case ID_TEXTAREA: {
       DOM::HTMLTextAreaElement textarea = element;
       if (id == KJS::HTMLElement::TextAreaBlur) {
index 562fe83dabaf17541b266c98ee323b2f998cd39b..2d1d7ae693afd0a172973d35221c136298669556 100644 (file)
@@ -107,7 +107,7 @@ namespace KJS {
            TextAreaAccessKey, TextAreaName, TextAreaDefaultValue, TextAreaSelect,
            TextAreaCols, TextAreaDisabled, TextAreaForm, TextAreaType,
            TextAreaTabIndex, TextAreaReadOnly, TextAreaRows, TextAreaValue,
-           TextAreaBlur, TextAreaFocus, ButtonForm, ButtonTabIndex, ButtonName,
+           TextAreaBlur, TextAreaFocus, ButtonBlur, ButtonFocus, ButtonForm, ButtonTabIndex, ButtonName,
            ButtonDisabled, ButtonAccessKey, ButtonType, ButtonValue, LabelHtmlFor,
            LabelForm, LabelAccessKey, FieldSetForm, LegendForm, LegendAccessKey,
            LegendAlign, UListType, UListCompact, OListStart, OListCompact,
index dce45662dc129d18ed958af7833be3febf9d4e8d..2e34ccd819fa9829e64beab21d6fe8a93195f5bf 100644 (file)
@@ -362,15 +362,17 @@ const struct HashEntry HTMLButtonElementTableEntries[] = {
    { 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0 },
    { "form", KJS::HTMLElement::ButtonForm, DontDelete|ReadOnly, 0, &HTMLButtonElementTableEntries[7] },
-   { "tabIndex", KJS::HTMLElement::ButtonTabIndex, DontDelete, 0, 0 },
+   { "tabIndex", KJS::HTMLElement::ButtonTabIndex, DontDelete, 0, &HTMLButtonElementTableEntries[9] },
    { "name", KJS::HTMLElement::ButtonName, DontDelete, 0, 0 },
-   { "disabled", KJS::HTMLElement::ButtonDisabled, DontDelete, 0, 0 },
+   { "disabled", KJS::HTMLElement::ButtonDisabled, DontDelete, 0, &HTMLButtonElementTableEntries[10] },
    { "accessKey", KJS::HTMLElement::ButtonAccessKey, DontDelete, 0, 0 },
    { "type", KJS::HTMLElement::ButtonType, DontDelete|ReadOnly, 0, &HTMLButtonElementTableEntries[8] },
-   { "value", KJS::HTMLElement::ButtonValue, DontDelete, 0, 0 }
+   { "value", KJS::HTMLElement::ButtonValue, DontDelete, 0, 0 },
+   { "blur", KJS::HTMLElement::ButtonBlur, DontDelete|Function, 0, 0 },
+   { "focus", KJS::HTMLElement::ButtonFocus, DontDelete|Function, 0, 0 }
 };
 
-const struct HashTable HTMLButtonElementTable = { 2, 9, HTMLButtonElementTableEntries, 7 };
+const struct HashTable HTMLButtonElementTable = { 2, 11, HTMLButtonElementTableEntries, 7 };
 
 } // namespace
 
index 52dc3f811025b668d0e893f103f8a0bcb859116a..9bc135343125d090a3e475ad4f7d56b726d7479a 100644 (file)
@@ -1109,6 +1109,17 @@ DOMString HTMLButtonElementImpl::type() const
     return getAttribute(ATTR_TYPE);
 }
 
+void HTMLButtonElementImpl::blur()
+{
+    if(getDocument()->focusNode() == this)
+       getDocument()->setFocusNode(0);
+}
+
+void HTMLButtonElementImpl::focus()
+{
+    getDocument()->setFocusNode(this);
+}
+
 void HTMLButtonElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
index 342a5ed19a2687cd4b20b12aedda11629366d139..36c4122ac2732bd38bd11a882b012d6544b44107 100644 (file)
@@ -236,6 +236,8 @@ public:
 
     virtual void click(bool sendMouseEvents);
     virtual void accessKeyAction(bool sendToAnyElement);
+    void blur();
+    void focus();
     
 protected:
     DOMString m_value;