[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.1/kdelibs/khtml
From:       Maks Orlovich <maksim () kde ! org>
Date:       2008-10-03 0:26:28
Message-ID: 1222993588.590289.24883.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 867176 by orlovich:

Support focus/blur on all elements (likely mozilla extension), 
used by Youtube quicklist

BUG: 169988


 M  +13 -4     ecma/kjs_dom.cpp  
 M  +1 -1      ecma/kjs_dom.h  
 M  +7 -56     ecma/kjs_html.cpp  
 M  +8 -8      ecma/kjs_html.h  
 M  +0 -44     html/html_formimpl.cpp  
 M  +0 -9      html/html_formimpl.h  
 M  +0 -13     html/html_inlineimpl.cpp  
 M  +0 -3      html/html_inlineimpl.h  
 M  +11 -0     xml/dom_elementimpl.cpp  
 M  +4 -0      xml/dom_elementimpl.h  


--- branches/KDE/4.1/kdelibs/khtml/ecma/kjs_dom.cpp #867175:867176
@@ -1183,6 +1183,9 @@
   getElementsByTagNameNS DOMElement::GetElementsByTagNameNS	DontDelete|Function 2
   hasAttributeNS	DOMElement::HasAttributeNS	DontDelete|Function 2
   getElementsByClassName DOMElement::GetElementsByClassName   DontDelete|Function 1
+# Extensions
+  blur          DOMElement::Blur    DontDelete|Function 0
+  focus         DOMElement::Focus   DontDelete|Function 0
 @end
 */
 KJS_IMPLEMENT_PROTOFUNC(DOMElementProtoFunc)
@@ -1305,7 +1308,7 @@
     case DOMElement::RemoveAttributeNS: // DOM2
       element.removeAttributeNS(args[0]->toString(exec).domString(),args[1]->toString(exec).domString(), \
exception);  return jsUndefined();
-   case DOMElement::GetAttributeNodeNS: // DOM2
+    case DOMElement::GetAttributeNodeNS: // DOM2
       return getDOMNode(exec,element.getAttributeNodeNS(args[0]->toString(exec).domString(),args[1]->toString(exec).domString(),exception));
  case DOMElement::SetAttributeNodeNS: {
       DOM::Attr toRet = element.setAttributeNodeNS(KJS::toAttr(args[0]), exception);
@@ -1315,10 +1318,16 @@
       return getDOMNodeList(exec,element.getElementsByTagNameNS(args[0]->toString(exec).domString(),args[1]->toString(exec).domString()));
  case DOMElement::HasAttributeNS: // DOM2
       return jsBoolean(element.hasAttributeNS(args[0]->toString(exec).domString(),args[1]->toString(exec).domString()));
                
-  case DOMElement::GetElementsByClassName: // HTML 5
+    case DOMElement::GetElementsByClassName: // HTML 5
       return getDOMNodeList(exec, \
                element.getElementsByClassName(args[0]->toString(exec).domString()));
-  default:
-    return jsUndefined();
+    case DOMElement::Focus:
+      element.focus();
+      return jsUndefined();
+    case DOMElement::Blur:
+      element.blur();
+      return jsUndefined();
+    default:
+      return jsUndefined();
   }
 }
 
--- branches/KDE/4.1/kdelibs/khtml/ecma/kjs_dom.h #867175:867176
@@ -170,7 +170,7 @@
            SetAttributeNode, RemoveAttributeNode, GetElementsByTagName,
            GetAttributeNS, SetAttributeNS, RemoveAttributeNS, GetAttributeNodeNS,
            SetAttributeNodeNS, GetElementsByTagNameNS, HasAttribute, HasAttributeNS,
-           GetElementsByClassName };
+           GetElementsByClassName, Blur, Focus };
   private:
 #if 0
     static JSValue *attributeGetter(ExecState *exec, JSObject*, const Identifier&, \
                const PropertySlot& slot);
--- branches/KDE/4.1/kdelibs/khtml/ecma/kjs_html.cpp #867175:867176
@@ -764,8 +764,8 @@
   onload        KJS::HTMLElement::BodyOnLoad     DontDelete
 @end
 @begin HTMLBodyElementProtoTable 2
-# Mozilla'ish extension. Ideally we would want to support this on all elements.
-# Not hard, but not an immediate need.
+# Even though we do blur/focus everywhere, we still handle body.focus()
+# specially for now
   focus         KJS::HTMLElement::BodyFocus      DontDelete|Function 0
 @end
 @begin HTMLFormElementTable 11
@@ -801,8 +801,6 @@
 @begin HTMLSelectElementProtoTable 4
   add		KJS::HTMLElement::SelectAdd	DontDelete|Function 2
   remove	KJS::HTMLElement::SelectRemove	DontDelete|Function 1
-  blur		KJS::HTMLElement::SelectBlur	DontDelete|Function 0
-  focus		KJS::HTMLElement::SelectFocus	DontDelete|Function 0
 @end
 @begin HTMLOptGroupElementTable 2
   disabled	KJS::HTMLElement::OptGroupDisabled	DontDelete
@@ -843,8 +841,6 @@
   selectionEnd   KJS::HTMLElement::InputSelectionEnd    DontDelete
 @end
 @begin HTMLInputElementProtoTable 5
-  blur		KJS::HTMLElement::InputBlur		DontDelete|Function 0
-  focus		KJS::HTMLElement::InputFocus		DontDelete|Function 0
   select	KJS::HTMLElement::InputSelect		DontDelete|Function 0
   click		KJS::HTMLElement::InputClick		DontDelete|Function 0
   setSelectionRange KJS::HTMLElement::InputSetSelectionRange DontDelete|Function 2
@@ -866,9 +862,7 @@
   textLength     KJS::HTMLElement::TextAreaTextLength     DontDelete|ReadOnly
 @end
 @begin HTMLTextAreaElementProtoTable 4
-  blur		KJS::HTMLElement::TextAreaBlur		DontDelete|Function 0
-  focus		KJS::HTMLElement::TextAreaFocus		DontDelete|Function 0
-  select	KJS::HTMLElement::TextAreaSelect	DontDelete|Function 0
+  select  KJS::HTMLElement::TextAreaSelect        DontDelete|Function 0
   setSelectionRange KJS::HTMLElement::TextAreaSetSelectionRange DontDelete|Function \
2  @end
 @begin HTMLButtonElementTable 9
@@ -881,8 +875,6 @@
   value		KJS::HTMLElement::ButtonValue		DontDelete
 @end
 @begin HTMLButtonElementProtoTable 3
-  blur		KJS::HTMLElement::ButtonBlur            DontDelete|Function 0
-  focus		KJS::HTMLElement::ButtonFocus           DontDelete|Function 0
   click		KJS::HTMLElement::ButtonClick           DontDelete|Function 0
 @end
 @begin HTMLLabelElementTable 3
@@ -984,8 +976,6 @@
   type		KJS::HTMLElement::AnchorType		DontDelete
 @end
 @begin HTMLAnchorElementProtoTable 3
-  blur		KJS::HTMLElement::AnchorBlur		DontDelete|Function 0
-  focus		KJS::HTMLElement::AnchorFocus		DontDelete|Function 0
   click		KJS::HTMLElement::AnchorClick		DontDelete|Function 0
 @end
 @begin HTMLImageElementTable 15
@@ -2164,27 +2154,11 @@
         select.remove(int(args[0]->toNumber(exec)));
         return jsUndefined();
       }
-      else if (id == KJS::HTMLElement::SelectBlur) {
-        select.blur();
-        return jsUndefined();
-      }
-      else if (id == KJS::HTMLElement::SelectFocus) {
-        select.focus();
-        return jsUndefined();
-      }
     }
     break;
     case ID_INPUT: {
       DOM::HTMLInputElementImpl& input = \
                static_cast<DOM::HTMLInputElementImpl&>(element);
-      if (id == KJS::HTMLElement::InputBlur) {
-        input.blur();
-        return jsUndefined();
-      }
-      else if (id == KJS::HTMLElement::InputFocus) {
-        input.focus();
-        return jsUndefined();
-      }
-      else if (id == KJS::HTMLElement::InputSelect) {
+      if (id == KJS::HTMLElement::InputSelect) {
         input.select();
         return jsUndefined();
       }
@@ -2200,14 +2174,7 @@
     break;
     case ID_BUTTON: {
       DOM::HTMLButtonElementImpl& button = \
                static_cast<DOM::HTMLButtonElementImpl&>(element);
-      if (id == KJS::HTMLElement::ButtonBlur) {
-        button.blur();
-        return jsUndefined();
-      }
-      else if (id == KJS::HTMLElement::ButtonFocus) {
-        button.focus();
-        return jsUndefined();
-      } else if (id == KJS::HTMLElement::ButtonClick) {
+      if (id == KJS::HTMLElement::ButtonClick) {
         button.click();
         return jsUndefined();      
       }
@@ -2215,15 +2182,7 @@
     break;
     case ID_TEXTAREA: {
       DOM::HTMLTextAreaElementImpl& textarea = \
                static_cast<DOM::HTMLTextAreaElementImpl&>(element);
-      if (id == KJS::HTMLElement::TextAreaBlur) {
-        textarea.blur();
-        return jsUndefined();
-      }
-      else if (id == KJS::HTMLElement::TextAreaFocus) {
-        textarea.focus();
-        return jsUndefined();
-      }
-      else if (id == KJS::HTMLElement::TextAreaSelect) {
+      if (id == KJS::HTMLElement::TextAreaSelect) {
         textarea.select();
         return jsUndefined();
       }
@@ -2236,15 +2195,7 @@
     break;
     case ID_A: {
       DOM::HTMLAnchorElementImpl& anchor = \
                static_cast<DOM::HTMLAnchorElementImpl&>(element);
-      if (id == KJS::HTMLElement::AnchorBlur) {
-        anchor.blur();
-        return jsUndefined();
-      }
-      else if (id == KJS::HTMLElement::AnchorFocus) {
-        anchor.focus();
-        return jsUndefined();
-      }
-      else if (id == KJS::HTMLElement::AnchorClick) {
+      if (id == KJS::HTMLElement::AnchorClick) {
         anchor.click();
         return jsUndefined();
       }
--- branches/KDE/4.1/kdelibs/khtml/ecma/kjs_html.h #867175:867176
@@ -92,21 +92,21 @@
            FormAction, FormEncType, FormElements, FormLength, FormAcceptCharset,
            FormReset, FormTarget, FormName, FormMethod, FormSubmit, SelectAdd,
            SelectTabIndex, SelectValue, SelectSelectedIndex, SelectLength,
-           SelectRemove, SelectForm, SelectBlur, SelectType, SelectOptions,
-           SelectDisabled, SelectMultiple, SelectName, SelectSize, SelectFocus,
+           SelectRemove, SelectForm, SelectType, SelectOptions,
+           SelectDisabled, SelectMultiple, SelectName, SelectSize, 
            OptGroupDisabled, OptGroupLabel, OptionIndex, OptionSelected,
            OptionForm, OptionText, OptionDefaultSelected, OptionDisabled,
-           OptionLabel, OptionValue, InputBlur, InputReadOnly, InputAccept,
+           OptionLabel, OptionValue, InputReadOnly, InputAccept,
            InputSize, InputDefaultValue, InputTabIndex, InputValue, InputType,
-           InputFocus, InputMaxLength, InputDefaultChecked, InputDisabled,
+           InputMaxLength, InputDefaultChecked, InputDisabled,
            InputChecked, InputIndeterminate, InputForm, InputAccessKey, InputAlign, \
InputAlt,  InputName, InputSrc, InputUseMap, InputSelect, InputClick,
            InputSelectionStart, InputSelectionEnd, InputSetSelectionRange,
            TextAreaAccessKey, TextAreaName, TextAreaDefaultValue, TextAreaSelect,
            TextAreaCols, TextAreaDisabled, TextAreaForm, TextAreaType,
            TextAreaTabIndex, TextAreaReadOnly, TextAreaRows, TextAreaValue,
-           TextAreaBlur, TextAreaFocus, TextAreaSelectionStart, \
                TextAreaSelectionEnd, TextAreaSetSelectionRange,
-           TextAreaTextLength, ButtonBlur, ButtonFocus, ButtonClick, ButtonForm, \
ButtonTabIndex, ButtonName, +           TextAreaSelectionStart, TextAreaSelectionEnd, \
TextAreaSetSelectionRange, +           TextAreaTextLength, ButtonClick, ButtonForm, \
                ButtonTabIndex, ButtonName,
            ButtonDisabled, ButtonAccessKey, ButtonType, ButtonValue, LabelHtmlFor,
            LabelForm, LabelAccessKey, FieldSetForm, LegendForm, LegendAccessKey,
            LegendAlign, UListType, UListCompact, OListStart, OListCompact,
@@ -116,9 +116,9 @@
            BaseFontFace, FontColor, FontSize, FontFace, HRWidth, HRNoShade,
            HRAlign, HRSize, ModCite, ModDateTime, AnchorShape, AnchorRel,
            AnchorAccessKey, AnchorCoords, AnchorHref, AnchorProtocol, AnchorHost,
-           AnchorCharset, AnchorHrefLang, AnchorHostname, AnchorType, AnchorFocus,
+           AnchorCharset, AnchorHrefLang, AnchorHostname, AnchorType,
            AnchorPort, AnchorPathName, AnchorHash, AnchorSearch, AnchorName,
-           AnchorRev, AnchorTabIndex, AnchorTarget, AnchorText, AnchorBlur, \
AnchorClick, +           AnchorRev, AnchorTabIndex, AnchorTarget, AnchorText, \
                AnchorClick,
            ImageName, ImageAlign, ImageHspace, ImageVspace, ImageUseMap, ImageAlt,
            ImageLowSrc, ImageWidth, ImageIsMap, ImageBorder, ImageHeight,
            ImageLongDesc, ImageSrc, ImageX, ImageY, ImageComplete, ObjectHspace, \
                ObjectHeight, ObjectAlign,
--- branches/KDE/4.1/kdelibs/khtml/html/html_formimpl.cpp #867175:867176
@@ -1130,17 +1130,6 @@
     return "";
 }
 
-void HTMLButtonElementImpl::blur()
-{
-    if(document()->focusNode() == this)
-        document()->setFocusNode(0);
-}
-
-void HTMLButtonElementImpl::focus()
-{
-    document()->setFocusNode(this);
-}
-
 void HTMLButtonElementImpl::parseAttribute(AttributeImpl *attr)
 {
     switch(attr->id())
@@ -1803,17 +1792,6 @@
     setChanged();
 }
 
-void HTMLInputElementImpl::blur()
-{
-    if(document()->focusNode() == this)
-	document()->setFocusNode(0);
-}
-
-void HTMLInputElementImpl::focus()
-{
-    document()->setFocusNode(this);
-}
-
 void HTMLInputElementImpl::defaultEventHandler(EventImpl *evt)
 {
     if ( !m_disabled )
@@ -2167,17 +2145,6 @@
         setRecalcListItems();
 }
 
-void HTMLSelectElementImpl::blur()
-{
-    if(document()->focusNode() == this)
-	document()->setFocusNode(0);
-}
-
-void HTMLSelectElementImpl::focus()
-{
-    document()->setFocusNode(this);
-}
-
 DOMString HTMLInputElementImpl::valueWithDefault() const
 {
     DOMString v = value();
@@ -2950,17 +2917,6 @@
     setValue(_defaultValue);
 }
 
-void HTMLTextAreaElementImpl::blur()
-{
-    if(document()->focusNode() == this)
-	document()->setFocusNode(0);
-}
-
-void HTMLTextAreaElementImpl::focus()
-{
-    document()->setFocusNode(this);
-}
-
 bool HTMLTextAreaElementImpl::isEditable()
 {
     return true;
--- branches/KDE/4.1/kdelibs/khtml/html/html_formimpl.h #867175:867176
@@ -209,8 +209,6 @@
     void activate();
     virtual void attach();
     void click();
-    void blur();
-    void focus();
 
 protected:
     DOMString             m_value;
@@ -283,9 +281,6 @@
 
     DOMString valueWithDefault() const;
 
-    void blur();
-    void focus();
-
     virtual bool maintainsState() { return true; }
     virtual QString state();
     virtual void restoreState(const QString &state);
@@ -407,8 +402,6 @@
 
     void add ( HTMLElementImpl* element, HTMLElementImpl* before, int& exceptioncode \
);  void remove ( long index );
-    void blur();
-    void focus();
 
     DOMString value() const;
     void setValue(DOMStringImpl* value);
@@ -566,8 +559,6 @@
     void setValue(DOMString _value);
     DOMString defaultValue();
     void setDefaultValue(DOMString _defaultValue);
-    void blur();
-    void focus();
 
     virtual bool isEditable();
     void setUnsubmittedFormChange(bool unsubmitted) { m_unsubmittedFormChange = \
                unsubmitted; }
--- branches/KDE/4.1/kdelibs/khtml/html/html_inlineimpl.cpp #867175:867176
@@ -162,19 +162,6 @@
     HTMLElementImpl::defaultEventHandler(evt);
 }
 
-
-void HTMLAnchorElementImpl::blur(  )
-{
-    if(document()->focusNode()==this)
-        document()->setFocusNode(0);
-}
-
-void HTMLAnchorElementImpl::focus(  )
-{
-    document()->setFocusNode(this);
-}
-
-
 void HTMLAnchorElementImpl::click()
 {
     QMouseEvent me(QEvent::MouseButtonRelease, QPoint(0,0),Qt::LeftButton, \
                Qt::LeftButton, 0);
--- branches/KDE/4.1/kdelibs/khtml/html/html_inlineimpl.h #867175:867176
@@ -40,9 +40,6 @@
     virtual void parseAttribute(AttributeImpl *attr);
     virtual void defaultEventHandler(EventImpl *evt);
     void click();
-
-    void focus();
-    void blur();
 protected:
     bool m_hasTarget : 1;
 };
--- branches/KDE/4.1/kdelibs/khtml/xml/dom_elementimpl.cpp #867175:867176
@@ -1269,6 +1269,17 @@
     return rd->m_computedStyle;
 }
 
+void ElementImpl::blur()
+{
+    if(document()->focusNode() == this)
+        document()->setFocusNode(0);
+}
+
+void ElementImpl::focus()
+{
+    document()->setFocusNode(this);
+}
+
 // -------------------------------------------------------------------------
 
 XMLElementImpl::XMLElementImpl(DocumentImpl *doc, NodeImpl::Id id)
--- branches/KDE/4.1/kdelibs/khtml/xml/dom_elementimpl.h #867175:867176
@@ -176,6 +176,10 @@
     AttrImpl* getAttributeNodeNS( const DOMString &namespaceURI, const DOMString \
&localName, int& exceptioncode );  Attr setAttributeNodeNS( AttrImpl* newAttr, int& \
exceptioncode );  
+    //Commonly supported extensions
+    void blur();
+    void focus();
+
     //Lower-level implementation primitives
     DOMString getAttribute( NodeImpl::Id id, bool nsAware = false, const DOMString& \
                qName = DOMString() ) const;
     DOMStringImpl* getAttributeImpl( NodeImpl::Id id, bool nsAware = false, \
DOMStringImpl* qName = 0 ) const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic