Changeset 12872 in webkit


Ignore:
Timestamp:
Feb 17, 2006 1:54:15 AM (18 years ago)
Author:
vicki
Message:

Reviewed by Justin.


Get rid of handleFocusOut on text fields and textareas - move this functionality to the place
where we resign focus on the previous node in setFocusNode. Add isTextField on RenderObject
as one way to distinguish from contenteditable elements - Win IE does not fire onChange for
contenteditable elements, so we won't either. Also, expose the dirty bit variables previously
checked in handleFocusOut methods in isEdited() and setEdited().

Fixes the following bugs:
<rdar://problem/4315673> REGRESSION (1.2.2 - 1.3): onChange and onFocus events firing order differs for mouse click and tab (7227)
<rdar://problem/4447009> for text fields, onChange should fire before onBlur to match Win IE

Test case is on the way.

  • dom/DocumentImpl.cpp: (WebCore::DocumentImpl::setFocusNode): For textareas and text fields, fire a change event on the node that is resigning focus. Make sure the blur event fires after the change event - 4447009.
  • rendering/render_form.cpp: (WebCore::RenderLineEdit::slotReturnPressed): Replace call to handleFocusOut with equivalent code. (WebCore::RenderLineEdit::isEdited): Added. (WebCore::RenderLineEdit::setEdited): Added. (WebCore::RenderTextArea::setEdited): Added.
  • rendering/render_form.h: (WebCore::RenderLineEdit::isTextField): Added. (WebCore::RenderTextArea::isTextArea): Make this non-virtual. (WebCore::RenderTextArea::isEdited): Added.
  • rendering/render_object.h: (WebCore::RenderObject::isEdited): Added. (WebCore::RenderObject::setEdited): Added. (WebCore::RenderObject::isTextField): Added.
  • rendering/render_replaced.h: Remove handleFocusOut().
  • rendering/render_replaced.cpp: Ditto. (WebCore::RenderWidget::eventFilter): Remove call to handleFocusOut(). Safe to do here, since we call setFocusNode immediately beforehand.
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r12871 r12872  
     12006-02-17  Vicki Murley <vicki@apple.com>
     2
     3        Reviewed by Justin.
     4 
     5        Get rid of handleFocusOut on text fields and textareas - move this functionality to the place
     6        where we resign focus on the previous node in setFocusNode.  Add isTextField on RenderObject
     7        as one way to distinguish from contenteditable elements - Win IE does not fire onChange for
     8        contenteditable elements, so we won't either. Also, expose the dirty bit variables previously
     9        checked in handleFocusOut methods in isEdited() and setEdited().
     10
     11        Fixes the following bugs:
     12        <rdar://problem/4315673> REGRESSION (1.2.2 - 1.3): onChange and onFocus events firing order differs for mouse click and tab (7227)
     13        <rdar://problem/4447009> for text fields, onChange should fire before onBlur to match Win IE
     14
     15        Test case is on the way.
     16
     17        * dom/DocumentImpl.cpp:
     18        (WebCore::DocumentImpl::setFocusNode): For textareas and text fields, fire a change event
     19        on the node that is resigning focus.  Make sure the blur event fires after the change event - 4447009.
     20        * rendering/render_form.cpp:
     21        (WebCore::RenderLineEdit::slotReturnPressed): Replace call to handleFocusOut with equivalent code.
     22        (WebCore::RenderLineEdit::isEdited): Added.
     23        (WebCore::RenderLineEdit::setEdited): Added.
     24        (WebCore::RenderTextArea::setEdited): Added.
     25        * rendering/render_form.h:
     26        (WebCore::RenderLineEdit::isTextField): Added.
     27        (WebCore::RenderTextArea::isTextArea): Make this non-virtual.
     28        (WebCore::RenderTextArea::isEdited): Added.
     29        * rendering/render_object.h:
     30        (WebCore::RenderObject::isEdited): Added.
     31        (WebCore::RenderObject::setEdited): Added.
     32        (WebCore::RenderObject::isTextField): Added.
     33        * rendering/render_replaced.h: Remove handleFocusOut().
     34        * rendering/render_replaced.cpp: Ditto.
     35        (WebCore::RenderWidget::eventFilter): Remove call to handleFocusOut().  Safe to do here,
     36        since we call setFocusNode immediately beforehand.
     37
    1382006-02-17  Mitz Pettel  <opendarwin.org@mitzpettel.com>
    239
  • trunk/WebCore/dom/DocumentImpl.cpp

    r12865 r12872  
    20532053
    20542054        oldFocusNode->setFocus(false);
     2055               
     2056        // Dispatch a change event for text fields or textareas that have been edited
     2057        RenderObject *r = static_cast<RenderObject*>(oldFocusNode.get()->renderer());
     2058        if ((r->isTextArea() || r->isTextField()) && r->isEdited()) {
     2059            oldFocusNode->dispatchHTMLEvent(changeEvent, true, false);
     2060            r->setEdited(false);
     2061        }
     2062
    20552063        oldFocusNode->dispatchHTMLEvent(blurEvent, false, false);
     2064
    20562065        if (m_focusNode) {
    20572066            // handler shifted focus
  • trunk/WebCore/rendering/render_form.cpp

    r12801 r12872  
    225225    // Works but might not be enough, dirk said he had another solution at
    226226    // hand (can't remember which) - David
    227     handleFocusOut();
     227    if (isTextField() && isEdited()) {
     228        element()->onChange();
     229        setEdited(false);
     230    }
    228231
    229232    HTMLFormElementImpl* fe = element()->form();
     
    242245    if (widget())
    243246        widget()->addSearchResult();
    244 }
    245 
    246 void RenderLineEdit::handleFocusOut()
    247 {
    248     if ( widget() && widget()->edited() && element()) {
    249         element()->onChange();
    250         widget()->setEdited( false );
    251     }
    252247}
    253248
     
    376371}
    377372
     373bool RenderLineEdit::isEdited() const
     374{
     375    return static_cast<QLineEdit*>(m_widget)->edited();
     376}
     377void RenderLineEdit::setEdited(bool x)
     378{
     379    static_cast<QLineEdit*>(m_widget)->setEdited(x);
     380}
     381
    378382void RenderLineEdit::setSelectionRange(int start, int end)
    379383{
     
    521525    if (isInline())
    522526        setReplaced(true);
    523 }
    524 
     527}   
     528   
    525529// -------------------------------------------------------------------------
    526530
     
    9961000}
    9971001
    998 void RenderTextArea::handleFocusOut()
    999 {
    1000     if ( m_dirty && element() ) {
    1001         element()->updateValue();
    1002         element()->onChange();
    1003     }
    1004     m_dirty = false;
    1005 }
    1006 
    10071002void RenderTextArea::calcMinMaxWidth()
    10081003{
     
    10471042
    10481043    w->setScrollBarModes(horizontalScrollMode, scrollMode);
     1044}
     1045
     1046void RenderTextArea::setEdited(bool x) {
     1047    m_dirty = x;
    10491048}
    10501049
  • trunk/WebCore/rendering/render_form.h

    r12782 r12872  
    132132    void setSelectionEnd(int);
    133133   
     134    bool isEdited() const;
     135    void setEdited(bool);
     136    bool isTextField() const { return true; }
    134137    void select();
    135138    void setSelectionRange(int, int);
     
    146149public:
    147150    void addSearchResult();
    148 
    149 protected:
    150     virtual void handleFocusOut();
    151151
    152152private:
     
    321321    virtual void setStyle(RenderStyle *);
    322322
    323     virtual bool isTextArea() const { return true; }
     323    bool isTextArea() const { return true; }
     324    bool isEdited() const { return m_dirty; }
     325    void setEdited (bool);
    324326   
    325327    // don't even think about making this method virtual!
     
    344346   
    345347protected:
    346     virtual void handleFocusOut();
    347 
    348348    virtual bool isEditable() const { return true; }
    349349
  • trunk/WebCore/rendering/render_object.h

    r12527 r12872  
    164164    virtual int getBaselineOfLastLineBox() const { return -1; }
    165165    virtual bool isEmpty() const { return firstChild() == 0; }
     166       
     167    virtual bool isEdited() const { return false; }
     168    virtual void setEdited(bool) { return; };
    166169   
    167170    // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
     
    263266    virtual bool isImage() const { return false; }
    264267    virtual bool isTextArea() const { return false; }
     268    virtual bool isTextField() const { return false; }
    265269    virtual bool isFrameSet() const { return false; }
    266270    virtual bool isApplet() const { return false; }
  • trunk/WebCore/rendering/render_replaced.cpp

    r12803 r12872  
    412412}
    413413
    414 void RenderWidget::handleFocusOut()
    415 {
    416 }
    417 
    418414bool RenderWidget::eventFilter(QObject* /*o*/, QEvent* e)
    419415{
     
    438434            if (elem->getDocument()->focusNode() == elem)
    439435                elem->getDocument()->setFocusNode(0);
    440             handleFocusOut();
    441436        }
    442437        break;
  • trunk/WebCore/rendering/render_replaced.h

    r12782 r12872  
    107107    void setQWidget(Widget *widget, bool deleteWidget = true);
    108108    void resizeWidget( Widget *widget, int w, int h );
    109     virtual void handleFocusOut();
    110109
    111110    bool m_deleteWidget;
Note: See TracChangeset for help on using the changeset viewer.