Changeset 19636 in webkit


Ignore:
Timestamp:
Feb 14, 2007 7:17:54 PM (17 years ago)
Author:
aroben
Message:

LayoutTests:

Reviewed by Darin.

Test for http://bugs.webkit.org/show_bug.cgi?id=12517
<rdar://problem/4971227> REGRESSION: Tab order incorrect when input
inside frame/iframe gets initial focus (12517)

  • fast/events/frame-programmatic-focus-expected.txt: Added.
  • fast/events/frame-programmatic-focus.html: Added.
  • fast/forms/focus2-expected.txt: Updated results to now-correct behavior.

WebCore:

Reviewed by Darin.

Fix http://bugs.webkit.org/show_bug.cgi?id=12517
<rdar://problem/4971227> REGRESSION: Tab order incorrect when input
inside frame/iframe gets initial focus (12517)

Test: fast/events/frame-programmatic-focus.html

  • dom/Element.cpp: (WebCore::Element::focus): Call FocusController::setFocusedNode to set the focus for the whole page.
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::focus): Ditto.
  • html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::focus): Ditto.
  • page/EventHandler.cpp: (WebCore::EventHandler::handleTextInputEvent): Send the textInput event to the same target that was sent the keypress event before it.
  • page/FocusController.cpp: (WebCore::FocusController::advanceFocus): Added a FIXME. (WebCore::FocusController::setFocusedNode): Added. Sets the focused node for a whole page.
  • page/FocusController.h: Added declaration.
  • platform/cf/RetainPtr.h: Removed unused pointer_cast functions.
Location:
trunk
Files:
1 added
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r19635 r19636  
     12007-02-14  Adam Roben  <aroben@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        Test for http://bugs.webkit.org/show_bug.cgi?id=12517
     6        <rdar://problem/4971227> REGRESSION: Tab order incorrect when input
     7        inside frame/iframe gets initial focus (12517)
     8
     9        * fast/events/frame-programmatic-focus-expected.txt: Added.
     10        * fast/events/frame-programmatic-focus.html: Added.
     11        * fast/forms/focus2-expected.txt: Updated results to now-correct
     12        behavior.
     13
    1142007-02-14  Justin Garcia  <justin.garcia@apple.com>
    215
  • trunk/LayoutTests/fast/events/frame-programmatic-focus.html

    • Property svn:eol-style set to native
    r19489 r19636  
    1414            window.onblur = function() { log('main frame blurred'); }
    1515
     16            var input = document.getElementsByTagName('input')[0];
     17            input.onfocus = function() { log('<input> focused'); }
     18            input.onblur = function() { log ('<input> blurred'); }
     19
    1620            var w = document.getElementById('frame').contentWindow;
    1721            w.onfocus = function() { log('iframe focused'); }
    1822            w.onblur = function() { log('iframe blurred'); }
    1923
    20             if (window.eventSender) {
    21                 eventSender.mouseMoveTo(50, 50);
    22                 eventSender.mouseClick();
     24            var inputInIframe = w.document.getElementsByTagName('input')[0];
     25            inputInIframe.onfocus = function() { log('<input> in iframe focused'); }
     26            inputInIframe.onblur = function() { log ('<input> in frame blurred'); }
    2327
    24                 // We need to "wait" a bit before the second click -- otherwise it is ignored
    25                 eventSender.leapForward(2000);
    26 
    27                 eventSender.mouseMoveTo(1, 300);
    28                 eventSender.mouseClick();
    29             }
     28            input.focus();
     29            inputInIframe.focus();
     30            input.focus();
    3031        }
    3132    </script>
    3233</head>
    3334<body onload="test()">
    34     <iframe id="frame" style="width: 100px; height: 100px; margin: 0px; border: 2px solid black;"></iframe>
    35     <p>This page tests that frames receive focus events when a click occurs
    36     within their content area, and blur events when a click occurs outside
    37     their content area.</p>
    38     <p>To test, click in the frame and then click on this text.</p>
     35    <input>
     36    <iframe id="frame" src="data:text/html,<input>" style="width: 100px; height: 100px; margin: 0px; border: 2px solid black;"></iframe>
     37    <p>This page tests that frames receive focus events when one of their child
     38    elements is programmatically focused, and receive blur events when an
     39    element not in that frame is programmatically focused.</p>
    3940
    4041    <pre id="log"></pre>
  • trunk/LayoutTests/fast/forms/focus2-expected.txt

    r18755 r19636  
    5050focus event: [to] BUTTON
    5151keypress event: [to] BUTTON
    52 focus event: [to] BUTTON
    53 keypress event: [to] BUTTON
    5452blur event: [to] BUTTON
    5553focus event: [to] CHECKBOX
     
    8785blur event: [to] TEXTAREA
    8886focus event: [to] DIV
     87keypress event: [to] DIV
     88blur event: [to] DIV
     89focus event: [to] ANCHOR
    8990
  • trunk/WebCore/ChangeLog

    r19635 r19636  
     12007-02-14  Adam Roben  <aroben@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        Fix http://bugs.webkit.org/show_bug.cgi?id=12517
     6        <rdar://problem/4971227> REGRESSION: Tab order incorrect when input
     7        inside frame/iframe gets initial focus (12517)
     8
     9        Test: fast/events/frame-programmatic-focus.html
     10
     11        * dom/Element.cpp:
     12        (WebCore::Element::focus): Call FocusController::setFocusedNode to set
     13        the focus for the whole page.
     14        * html/HTMLInputElement.cpp:
     15        (WebCore::HTMLInputElement::focus): Ditto.
     16        * html/HTMLTextAreaElement.cpp:
     17        (WebCore::HTMLTextAreaElement::focus): Ditto.
     18        * page/EventHandler.cpp:
     19        (WebCore::EventHandler::handleTextInputEvent): Send the textInput
     20        event to the same target that was sent the keypress event before it.
     21        * page/FocusController.cpp:
     22        (WebCore::FocusController::advanceFocus): Added a FIXME.
     23        (WebCore::FocusController::setFocusedNode): Added. Sets the focused
     24        node for a whole page.
     25        * page/FocusController.h: Added declaration.
     26        * platform/cf/RetainPtr.h: Removed unused pointer_cast functions.
     27
    1282007-02-14  Justin Garcia  <justin.garcia@apple.com>
    229
  • trunk/WebCore/dom/Element.cpp

    r19595 r19636  
    3131#include "Editor.h"
    3232#include "ExceptionCode.h"
     33#include "FocusController.h"
    3334#include "Frame.h"
    3435#include "FrameView.h"
    3536#include "HTMLNames.h"
    3637#include "NamedAttrMap.h"
     38#include "Page.h"
    3739#include "RenderBlock.h"
    3840#include "SelectionController.h"
     
    872874   
    873875    if (!supportsFocus())
    874         return;               
    875        
    876     doc->setFocusedNode(this);
     876        return;
     877   
     878    if (Page* page = doc->page())
     879        page->focusController()->setFocusedNode(this);
    877880
    878881    if (!isFocusable()) {
  • trunk/WebCore/html/HTMLInputElement.cpp

    r19595 r19636  
    3434#include "EventHandler.h"
    3535#include "EventNames.h"
     36#include "FocusController.h"
    3637#include "FormDataList.h"
    3738#include "Frame.h"
     
    4243#include "LocalizedStrings.h"
    4344#include "MouseEvent.h"
     45#include "Page.h"
    4446#include "RenderButton.h"
    4547#include "RenderFileUploadControl.h"
     
    190192        if (!supportsFocus())
    191193            return;
    192         doc->setFocusedNode(this);
     194        if (Page* page = doc->page())
     195            page->focusController()->setFocusedNode(this);
    193196        // FIXME: Should isFocusable do the updateLayout?
    194197        if (!isFocusable()) {
  • trunk/WebCore/html/HTMLTextAreaElement.cpp

    r19418 r19636  
    3232#include "Event.h"
    3333#include "EventNames.h"
     34#include "FocusController.h"
    3435#include "FormDataList.h"
    3536#include "Frame.h"
    3637#include "HTMLNames.h"
     38#include "Page.h"
    3739#include "RenderStyle.h"
    3840#include "RenderTextControl.h"
     
    207209    if (!supportsFocus())
    208210        return;
    209     doc->setFocusedNode(this);
     211    if (Page* page = doc->page())
     212        page->focusController()->setFocusedNode(this);
    210213    // FIXME: Should isFocusable do the updateLayout?
    211214    if (!isFocusable()) {
  • trunk/WebCore/page/EventHandler.cpp

    r19596 r19636  
    13601360    if (!m_frame)
    13611361        return false;
    1362     EventTargetNode* target = eventTargetNodeForDocument(m_frame->document());
     1362    EventTarget* target;
     1363    if (underlyingEvent)
     1364        target = underlyingEvent->target();
     1365    else
     1366        target = eventTargetNodeForDocument(m_frame->document());
    13631367    if (!target)
    13641368        return false;
  • trunk/WebCore/page/FocusController.cpp

    r19579 r19636  
    190190        return true;
    191191    }
     192   
     193    // FIXME: It would be nice to just be able to call setFocusedNode(node) here, but we can't do
     194    // that because some elements (e.g. HTMLInputElement and HTMLTextAreaElement) do extra work in
     195    // their focus() methods.
    192196
    193197    Document* newDocument = node->document();
     
    204208}
    205209
     210bool FocusController::setFocusedNode(Node* node)
     211{
     212    RefPtr<Frame> oldFocusedFrame = focusedFrame();
     213    RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document() : 0;
     214   
     215    if (!node) {
     216        if (oldDocument)
     217            oldDocument->setFocusedNode(0);
     218        return true;
     219    }
     220   
     221    RefPtr<Document> newDocument = node ? node->document() : 0;
     222    RefPtr<Frame> newFocusedFrame = newDocument ? newDocument->frame() : 0;
     223   
     224    if (newDocument && newDocument->focusedNode() == node)
     225        return true;
     226   
     227    if (oldDocument && oldDocument != newDocument)
     228        oldDocument->setFocusedNode(0);
     229   
     230    setFocusedFrame(newFocusedFrame);
     231   
     232    if (newDocument)
     233        newDocument->setFocusedNode(node);
     234   
     235    return true;
     236}
     237
    206238} // namespace WebCore
  • trunk/WebCore/page/FocusController.h

    r19579 r19636  
    3535    class Frame;
    3636    class KeyboardEvent;
     37    class Node;
    3738    class Page;
    3839
     
    4748        bool advanceFocus(KeyboardEvent*);
    4849        bool advanceFocus(FocusDirection, KeyboardEvent*);
     50       
     51        bool setFocusedNode(Node*);
    4952
    5053    private:
  • trunk/WebCore/platform/cf/RetainPtr.h

    r19162 r19636  
    193193        return a != b.get();
    194194    }
    195    
    196     template <typename T, typename U> inline RetainPtr<T> static_pointer_cast(const RetainPtr<U>& p)
    197     {
    198         return RetainPtr<T>(static_cast<typename RetainPtr<T>::PtrType>(p.get()));
    199     }
    200 
    201     template <typename T, typename U> inline RetainPtr<T> const_pointer_cast(const RetainPtr<U>& p)
    202     {
    203         return RetainPtr<T>(const_cast<typename RetainPtr<T>::PtrType>(p.get()));
    204     }
    205 
    206     template <typename T> inline typename RemovePointer<T>::type getPtr(const RetainPtr<T>& p)
    207     {
    208         return p.get();
    209     }
    210195
    211196}
Note: See TracChangeset for help on using the changeset viewer.