Bug 29682

Summary: [Qt] QWebElement lacks hasFocus and SetFocus apis
Product: WebKit Reporter: Joseph Ligman <joseph.ligman>
Component: WebKit QtAssignee: Joseph Ligman <joseph.ligman>
Status: RESOLVED FIXED    
Severity: Enhancement CC: commit-queue, eric, kenneth, laszlo.gombos, tonikitoo, vestbo
Priority: P2 Keywords: Qt
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Attachments:
Description Flags
Proposed patch, adds setFocus, hasFocus to QWebElement
hausmann: review-
Proposed patch, adds API setFocus, hasFocus to QWebElement none

Description Joseph Ligman 2009-09-23 07:00:35 PDT
These APIs are needed for clients of QWebElement.
Comment 1 Joseph Ligman 2009-09-23 09:25:40 PDT
Created attachment 40000 [details]
Proposed patch, adds setFocus, hasFocus to QWebElement

This patch adds setFocus and hasFocus Api to QWebElement. And a test case.
Comment 2 Antonio Gomes 2009-09-23 09:30:10 PDT
good stuff
Comment 3 Eric Seidel (no email) 2009-09-23 17:48:15 PDT
Are these standard Qt apis?  Please explain (ideally in the ChangeLog) why you're adding these, and why this particular API makes sense.
Comment 4 Simon Hausmann 2009-09-25 04:15:12 PDT
Comment on attachment 40000 [details]
Proposed patch, adds setFocus, hasFocus to QWebElement

In principle this looks good. I think only a few small fixes are necessary.


>  /*!
> +    \since 4.6
> +    Returns true if this QWebElement has keyboard input focus; otherwise, returns false

In the documentation you can simply use "this element" instead of repeating the class name.
Just like in the other methods of this class :)

> +
> +    \sa setFocus()
> +*/
> +bool QWebElement::hasFocus() const
> +{
> +    if (m_element->document() && m_element->isFocusable())
> +        return m_element == m_element->document()->focusedNode();
> +    return false;
> +}

Please add a null pointer check for m_element.

> +/*!
> +    \since 4.6
> +    Gives keyboard input focus to this QWebElement
> +
> +    \sa hasFocus()
> +*/
> +void QWebElement::setFocus()
> +{
> +    if (m_element->document() && m_element->isFocusable())
> +        m_element->document()->setFocusedNode(m_element);
> +}

Same here :)
Comment 5 Kenneth Rohde Christiansen 2009-09-25 07:02:44 PDT
> >  /*!
> > +    \since 4.6
> > +    Returns true if this QWebElement has keyboard input focus; otherwise, returns false
> 

The QWebElement class is new in 4.6 so I believe we should leave out the \since 4.6
Comment 6 Joseph Ligman 2009-09-25 11:13:41 PDT
Created attachment 40127 [details]
Proposed patch, adds API setFocus, hasFocus to QWebElement

Fixed the comments and added the null pointer check for m_element
Comment 7 Simon Hausmann 2009-09-27 14:23:50 PDT
Comment on attachment 40127 [details]
Proposed patch, adds API setFocus, hasFocus to QWebElement

r=me, thanks!
Comment 8 WebKit Commit Bot 2009-09-27 14:33:50 PDT
Comment on attachment 40127 [details]
Proposed patch, adds API setFocus, hasFocus to QWebElement

Clearing flags on attachment: 40127

Committed r48805: <http://trac.webkit.org/changeset/48805>
Comment 9 WebKit Commit Bot 2009-09-27 14:33:54 PDT
All reviewed patches have been landed.  Closing bug.