[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:11:14 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 3b232c25609fe060a0c81a5a668ec937d31d8293
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 12 20:05:59 2003 +0000

            Reviewed by Richard
    
            * khtml/html/html_formimpl.cpp:
            (HTMLButtonElementImpl::click): Implemented. Missed this in my earlier patch.
            (HTMLButtonElementImpl::accessKeyAction): Added. Focus and click.
            (HTMLInputElementImpl::accessKeyAction): Added. Focus the element.
            (HTMLSelectElementImpl::accessKeyAction): Added. Focus the element.
            (HTMLTextAreaElementImpl::accessKeyAction): Added. Focus the element.
            * khtml/html/html_formimpl.h:
            * khtml/html/html_inlineimpl.cpp:
            (HTMLAnchorElementImpl::accessKeyAction): Added. Focus and click.
            * khtml/html/html_inlineimpl.h:
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::DocumentImpl):
            (DocumentImpl::addElementById): Dirty the accesskey dictionary.
            (DocumentImpl::removeElementById): Ditto.
            (DocumentImpl::getElementByAccessKey): Function to look up an element
    	based on the key provided.
            (DocumentImpl::setDocumentChanged): Dirty the accesskey dictionary.
            (DocumentImpl::defaultEventHandler): Check the accesskey dictionary
    	to see if some element wants to handle a key event.
            * khtml/xml/dom_docimpl.h:
            * khtml/xml/dom_elementimpl.h:
            (DOM::ElementImpl::accessKeyAction): Added. Send a click to the element.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5468 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 63312b8..f72cca3 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -2,6 +2,33 @@
 
         Reviewed by Richard
 
+        * khtml/html/html_formimpl.cpp:
+        (HTMLButtonElementImpl::click): Implemented. Missed this in my earlier patch.
+        (HTMLButtonElementImpl::accessKeyAction): Added. Focus and click.
+        (HTMLInputElementImpl::accessKeyAction): Added. Focus the element.
+        (HTMLSelectElementImpl::accessKeyAction): Added. Focus the element.
+        (HTMLTextAreaElementImpl::accessKeyAction): Added. Focus the element.
+        * khtml/html/html_formimpl.h:
+        * khtml/html/html_inlineimpl.cpp:
+        (HTMLAnchorElementImpl::accessKeyAction): Added. Focus and click.
+        * khtml/html/html_inlineimpl.h:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::addElementById): Dirty the accesskey dictionary.
+        (DocumentImpl::removeElementById): Ditto.
+        (DocumentImpl::getElementByAccessKey): Function to look up an element
+	based on the key provided.
+        (DocumentImpl::setDocumentChanged): Dirty the accesskey dictionary.
+        (DocumentImpl::defaultEventHandler): Check the accesskey dictionary
+	to see if some element wants to handle a key event.
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_elementimpl.h:
+        (DOM::ElementImpl::accessKeyAction): Added. Send a click to the element.
+
+2003-11-12  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Richard
+
 	Fix for this bug:
 
 	<rdar://problem/3481600>: key event objects do not preserve unmodified keys
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index 29a2489..f5045a6 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -1088,6 +1088,25 @@ bool HTMLButtonElementImpl::encoding(const QTextCodec* codec, khtml::encodingLis
     return true;
 }
 
+void HTMLButtonElementImpl::click()
+{
+#if APPLE_CHANGES
+    QWidget *widget;
+    if (renderer() && (widget = static_cast<RenderWidget *>(renderer())->widget())) {
+        // using this method gives us nice Cocoa user interface feedback
+        static_cast<QButton *>(widget)->click();
+    }
+    else
+#endif
+        HTMLGenericFormElementImpl::click();
+}
+
+void HTMLButtonElementImpl::accessKeyAction()
+{   
+    focus();
+    click();
+}
+
 // -------------------------------------------------------------------------
 
 HTMLFieldSetElementImpl::HTMLFieldSetElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)
@@ -1279,6 +1298,31 @@ void HTMLInputElementImpl::click()
     }
 }
 
+void HTMLInputElementImpl::accessKeyAction()
+{
+    switch (inputType()) {
+        case HIDDEN:
+            // a no-op for this type
+            break;
+        case TEXT:
+        case PASSWORD:
+        case ISINDEX:
+        case FILE:
+            focus();
+            break;
+        case CHECKBOX:
+        case RADIO:
+        case SUBMIT:
+        case RESET:
+        case IMAGE:
+        case BUTTON:
+            // focus and click
+            focus();
+            click();
+            break;
+    }
+}
+
 void HTMLInputElementImpl::parseAttribute(AttributeImpl *attr)
 {
     switch(attr->id())
@@ -2288,6 +2332,11 @@ void HTMLSelectElementImpl::defaultEventHandler(EventImpl *evt)
 }
 #endif
 
+void HTMLSelectElementImpl::accessKeyAction()
+{
+    focus();
+}
+
 // -------------------------------------------------------------------------
 
 HTMLKeygenElementImpl::HTMLKeygenElementImpl(DocumentPtr* doc, HTMLFormElementImpl* f)
@@ -2718,6 +2767,11 @@ bool HTMLTextAreaElementImpl::isEditable()
     return true;
 }
 
+void HTMLTextAreaElementImpl::accessKeyAction()
+{
+    focus();
+}
+
 // -------------------------------------------------------------------------
 
 HTMLIsIndexElementImpl::HTMLIsIndexElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)
diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h
index e8ee6ad..2642de2 100644
--- a/WebCore/khtml/html/html_formimpl.h
+++ b/WebCore/khtml/html/html_formimpl.h
@@ -219,7 +219,10 @@ public:
     virtual bool isSuccessfulSubmitButton() const;
     virtual bool isActivatedSubmit() const;
     virtual void setActivatedSubmit(bool flag);
-        
+
+    virtual void click();
+    virtual void accessKeyAction();
+    
 protected:
     DOMString m_value;
     QString   m_currValue;
@@ -301,6 +304,7 @@ public:
     void select();
     
     virtual void click();
+    virtual void accessKeyAction();
 
     virtual void parseAttribute(AttributeImpl *attr);
 
@@ -448,6 +452,8 @@ public:
     virtual void defaultEventHandler(EventImpl *evt);
 #endif
 
+    virtual void accessKeyAction();
+
 private:
     void recalcListItems();
 
@@ -581,7 +587,9 @@ public:
     void focus();
 
     virtual bool isEditable();
-
+    
+    virtual void accessKeyAction();
+    
 protected:
     int m_rows;
     int m_cols;
diff --git a/WebCore/khtml/html/html_inlineimpl.cpp b/WebCore/khtml/html/html_inlineimpl.cpp
index 64a3d67..b0b7d88 100644
--- a/WebCore/khtml/html/html_inlineimpl.cpp
+++ b/WebCore/khtml/html/html_inlineimpl.cpp
@@ -189,6 +189,12 @@ void HTMLAnchorElementImpl::parseAttribute(AttributeImpl *attr)
     }
 }
 
+void HTMLAnchorElementImpl::accessKeyAction()
+{
+    focus();
+    click();
+}
+
 // -------------------------------------------------------------------------
 
 HTMLBRElementImpl::HTMLBRElementImpl(DocumentPtr *doc) : HTMLElementImpl(doc)
diff --git a/WebCore/khtml/html/html_inlineimpl.h b/WebCore/khtml/html/html_inlineimpl.h
index 6c4458b..ce5525b 100644
--- a/WebCore/khtml/html/html_inlineimpl.h
+++ b/WebCore/khtml/html/html_inlineimpl.h
@@ -43,6 +43,7 @@ public:
     virtual Id id() const;
     virtual void parseAttribute(AttributeImpl *attr);
     virtual void defaultEventHandler(EventImpl *evt);
+    virtual void accessKeyAction();
 protected:
     bool m_hasTarget : 1;
 };
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index f58165e..3cb2fb8 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -311,6 +311,7 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     m_ignorePendingStylesheets = false;
 
     m_cssTarget = 0;
+    m_accessKeyDictValid = false;
 }
 
 DocumentImpl::~DocumentImpl()
@@ -535,6 +536,7 @@ void DocumentImpl::addElementById(const DOMString &elementId, ElementImpl *eleme
 
     if (m_elementsById.find(qId) == NULL) {
 	m_elementsById.insert(qId, element);
+        m_accessKeyDictValid = false;
     }
 }
 
@@ -544,9 +546,35 @@ void DocumentImpl::removeElementById(const DOMString &elementId, ElementImpl *el
 
     if (m_elementsById.find(qId) == element) {
 	m_elementsById.remove(qId);
+        m_accessKeyDictValid = false;
     }
 }
 
+ElementImpl *DocumentImpl::getElementByAccessKey( const DOMString &key )
+{
+    if (key.length() == 0)
+	return 0;
+
+    QString k(key.string());
+    if (!m_accessKeyDictValid) {
+        m_elementsByAccessKey.clear();
+    
+        const NodeImpl *n;
+        for (n = this; n != 0; n = n->traverseNextNode()) {
+            if (!n->isElementNode())
+                continue;
+            const ElementImpl *elementImpl = static_cast<const ElementImpl *>(n);
+            DOMString accessKey(elementImpl->getAttribute(ATTR_ACCESSKEY));
+            if (!accessKey.isEmpty()) {
+                QString ak = accessKey.string().lower();
+                if (m_elementsByAccessKey.find(ak) == NULL)
+                    m_elementsByAccessKey.insert(ak, elementImpl);
+            }
+        }
+        m_accessKeyDictValid = true;
+    }
+    return m_elementsByAccessKey.find(k);
+}
 
 void DocumentImpl::setTitle(DOMString _title)
 {
@@ -910,6 +938,9 @@ void DocumentImpl::setDocumentChanged(bool b)
     else if (!b && m_docChanged)
         changedDocuments->remove(this);
     m_docChanged = b;
+    
+    if (m_docChanged)
+        m_accessKeyDictValid = false;
 }
 
 void DocumentImpl::recalcStyle( StyleChange change )
@@ -2181,6 +2212,19 @@ void DocumentImpl::defaultEventHandler(EventImpl *evt)
             it.current()->listener->handleEvent(ev, true);
 	}
     }
+
+    // handle accesskey
+    if (evt->id()==EventImpl::KEYDOWN_EVENT) {
+        KeyboardEventImpl *kevt = static_cast<KeyboardEventImpl *>(evt);
+        if (kevt->ctrlKey()) {
+            QString key = kevt->qKeyEvent()->unmodifiedText().lower();
+            ElementImpl *elem = getElementByAccessKey(key);
+            if (elem) {
+                elem->accessKeyAction();
+                evt->setDefaultHandled();
+            }
+        }
+    }
 }
 
 void DocumentImpl::setHTMLWindowEventListener(int id, EventListener *listener)
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index b4ea5f1..11bc949 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -175,6 +175,8 @@ public:
 
     khtml::CSSStyleSelector *styleSelector() { return m_styleSelector; }
 
+    ElementImpl *DocumentImpl::getElementByAccessKey( const DOMString &key );
+    
     /**
      * Updates the pending sheet count and then calls updateStyleSelector.
      */
@@ -587,6 +589,9 @@ private:
     khtml::Decoder *m_decoder;
 
     QDict<ElementImpl> m_elementsById;
+    
+    QDict<ElementImpl> m_elementsByAccessKey;
+    bool m_accessKeyDictValid;
  
     bool m_createRenderers;
 #endif
diff --git a/WebCore/khtml/xml/dom_elementimpl.h b/WebCore/khtml/xml/dom_elementimpl.h
index f9da3f8..9cc47f6 100644
--- a/WebCore/khtml/xml/dom_elementimpl.h
+++ b/WebCore/khtml/xml/dom_elementimpl.h
@@ -211,6 +211,8 @@ public:
     void dispatchAttrRemovalEvent(AttributeImpl *attr);
     void dispatchAttrAdditionEvent(AttributeImpl *attr);
 
+    virtual void accessKeyAction() {};
+
 #ifndef NDEBUG
     virtual void dump(QTextStream *stream, QString ind = "") const;
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list