Changeset 18614 in webkit


Ignore:
Timestamp:
Jan 4, 2007 11:44:46 PM (17 years ago)
Author:
aroben
Message:

WebCore:

Reviewed by Geoff, cheered by others.

Dead code elimination.

All layout tests pass.

  • page/EventHandler.h:
  • page/mac/EventHandlerMac.mm:
  • page/mac/WebCoreFrameBridge.h:
  • page/mac/WebCoreFrameBridge.mm:

WebKit:

Reviewed by Geoff, cheered by others.

Dead code elimination.

  • WebView/WebHTMLView.m:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r18610 r18614  
     12007-01-04  Adam Roben  <aroben@apple.com>
     2
     3        Reviewed by Geoff, cheered by others.
     4
     5        Dead code elimination.
     6
     7        All layout tests pass.
     8
     9        * page/EventHandler.h:
     10        * page/mac/EventHandlerMac.mm:
     11        * page/mac/WebCoreFrameBridge.h:
     12        * page/mac/WebCoreFrameBridge.mm:
     13
    1142007-01-04  Adam Roben  <aroben@apple.com>
    215
  • trunk/WebCore/page/EventHandler.h

    r18610 r18614  
    2727#define EventHandler_h
    2828
    29 #include "FocusDirection.h"
    3029#include "PlatformMouseEvent.h"
    3130#include "ScrollTypes.h"
     
    126125
    127126#if PLATFORM(MAC)
    128 
    129     NSView *nextKeyView(Node*, FocusDirection);
    130     NSView *nextKeyViewInFrameHierarchy(Node*, FocusDirection);
    131     static NSView *nextKeyView(Widget*, FocusDirection);
    132 
    133127    PassRefPtr<KeyboardEvent> currentKeyboardEvent() const;
    134128
     
    221215
    222216    NSView *mouseDownViewIfStillGood();
    223     NSView *nextKeyViewInFrame(Node*, FocusDirection, bool* focusCallResultedInViewBeingCreated = 0);
    224217#endif
    225218
  • trunk/WebCore/page/mac/EventHandlerMac.mm

    r18610 r18614  
    9393
    9494    return wheelEvent.isAccepted();
    95 }
    96 
    97 NSView* EventHandler::nextKeyViewInFrame(Node* n, FocusDirection direction, bool* focusCallResultedInViewBeingCreated)
    98 {
    99     Document* doc = m_frame->document();
    100     if (!doc)
    101         return nil;
    102 
    103     RefPtr<KeyboardEvent> event = currentKeyboardEvent();
    104 
    105     RefPtr<Node> node = n;
    106     for (;;) {
    107         node = (direction == FocusDirectionForward)
    108             ? doc->nextFocusableNode(node.get(), event.get())
    109             : doc->previousFocusableNode(node.get(), event.get());
    110         if (!node)
    111             return nil;
    112        
    113         RenderObject* renderer = node->renderer();
    114        
    115         if (!renderer->isWidget()) {
    116             static_cast<Element*>(node.get())->focus();
    117             // The call to focus might have triggered event handlers that causes the
    118             // current renderer to be destroyed.
    119             if (!(renderer = node->renderer()))
    120                 continue;
    121                
    122             // FIXME: When all input elements are native, we should investigate if this extra check is needed
    123             if (!renderer->isWidget()) {
    124                 [Mac(m_frame)->bridge() willMakeFirstResponderForNodeFocus];
    125                 return [Mac(m_frame)->bridge() documentView];
    126             }
    127             if (focusCallResultedInViewBeingCreated)
    128                 *focusCallResultedInViewBeingCreated = true;
    129         }
    130 
    131         if (Widget* widget = static_cast<RenderWidget*>(renderer)->widget()) {
    132             NSView* view;
    133             if (widget->isFrameView())
    134                 view = static_cast<FrameView*>(widget)->frame()->eventHandler()->nextKeyViewInFrame(0, direction);
    135             else
    136                 view = widget->getView();
    137             if (view)
    138                 return view;
    139         }
    140     }
    141 }
    142 
    143 NSView *EventHandler::nextKeyViewInFrameHierarchy(Node* node, FocusDirection direction)
    144 {
    145     bool focusCallResultedInViewBeingCreated = false;
    146     NSView *next = nextKeyViewInFrame(node, direction, &focusCallResultedInViewBeingCreated);
    147     if (!next)
    148         if (Frame* parent = m_frame->tree()->parent())
    149             next = parent->eventHandler()->nextKeyViewInFrameHierarchy(m_frame->ownerElement(), direction);
    150    
    151     // remove focus from currently focused node if we're giving focus to another view
    152     // unless the other view was created as a result of calling focus in nextKeyViewWithFrame.
    153     // FIXME: The focusCallResultedInViewBeingCreated calls can be removed when all input element types
    154     // have been made native.
    155     if (next && (next != [Mac(m_frame)->bridge() documentView] && !focusCallResultedInViewBeingCreated))
    156         if (Document* doc = m_frame->document())
    157             doc->setFocusedNode(0);
    158 
    159     // The common case where a view was created is when an <input> element changed from native
    160     // to non-native. When this happens, HTMLGenericFormElement::attach() method will call setFocus()
    161     // on the widget. For views with a field editor, setFocus() will set the active responder to be the field editor.
    162     // In this case, we want to return the field editor as the next key view. Otherwise, the focus will be lost
    163     // and a blur message will be sent.
    164     // FIXME: This code can be removed when all input element types are native.
    165     if (focusCallResultedInViewBeingCreated) {
    166         if ([[next window] firstResponder] == [[next window] fieldEditor:NO forObject:next])
    167             return [[next window] fieldEditor:NO forObject:next];
    168     }
    169    
    170     return next;
    171 }
    172 
    173 NSView *EventHandler::nextKeyView(Node* node, FocusDirection direction)
    174 {
    175     BEGIN_BLOCK_OBJC_EXCEPTIONS;
    176 
    177     NSView *next = nextKeyViewInFrameHierarchy(node, direction);
    178     if (next)
    179         return next;
    180 
    181     // Look at views from the top level part up, looking for a next key view that we can use.
    182     next = (direction == FocusDirectionForward)
    183         ? [Mac(m_frame)->bridge() nextKeyViewOutsideWebFrameViews]
    184         : [Mac(m_frame)->bridge() previousKeyViewOutsideWebFrameViews];
    185     if (next)
    186         return next;
    187 
    188     END_BLOCK_OBJC_EXCEPTIONS;
    189    
    190     // If all else fails, make a loop by starting from 0.
    191     return nextKeyViewInFrameHierarchy(0, direction);
    192 }
    193 
    194 NSView *EventHandler::nextKeyView(Widget* startingWidget, FocusDirection direction)
    195 {
    196     WidgetClient* client = startingWidget->client();
    197     if (!client)
    198         return nil;
    199     Element* element = client->element(startingWidget);
    200     if (!element)
    201         return nil;
    202     Frame* frame = element->document()->frame();
    203     if (!frame)
    204         return nil;
    205     return frame->eventHandler()->nextKeyView(element, direction);
    20695}
    20796
  • trunk/WebCore/page/mac/WebCoreFrameBridge.h

    r18541 r18614  
    132132- (NSArray*)computePageRectsWithPrintWidthScaleFactor:(float)printWidthScaleFactor printHeight:(float)printHeight;
    133133
    134 - (NSView *)nextKeyView;
    135 - (NSView *)previousKeyView;
    136 
    137 - (NSView *)nextKeyViewInsideWebFrameViews;
    138 - (NSView *)previousKeyViewInsideWebFrameViews;
    139 
    140134- (NSObject *)copyRenderTree:(id <WebCoreRenderTreeCopier>)copier;
    141135- (NSString *)renderTreeAsExternalRepresentation;
     
    295289- (void)formControlIsBecomingFirstResponder:(NSView *)formControl;
    296290- (void)formControlIsResigningFirstResponder:(NSView *)formControl;
    297 
    298 - (NSView *)nextKeyViewOutsideWebFrameViews;
    299 - (NSView *)previousKeyViewOutsideWebFrameViews;
    300291
    301292- (void)setNeedsReapplyStyles;
  • trunk/WebCore/page/mac/WebCoreFrameBridge.mm

    r18610 r18614  
    727727}
    728728
    729 - (NSView *)nextKeyView
    730 {
    731     Document *doc = m_frame->document();
    732     if (!doc)
    733         return nil;
    734     return m_frame->eventHandler()->nextKeyView(doc->focusedNode(), FocusDirectionForward);
    735 }
    736 
    737 - (NSView *)previousKeyView
    738 {
    739     Document *doc = m_frame->document();
    740     if (!doc)
    741         return nil;
    742     return m_frame->eventHandler()->nextKeyView(doc->focusedNode(), FocusDirectionBackward);
    743 }
    744 
    745 - (NSView *)nextKeyViewInsideWebFrameViews
    746 {
    747     Document *doc = m_frame->document();
    748     if (!doc)
    749         return nil;
    750     return m_frame->eventHandler()->nextKeyViewInFrameHierarchy(doc->focusedNode(), FocusDirectionForward);
    751 }
    752 
    753 - (NSView *)previousKeyViewInsideWebFrameViews
    754 {
    755     Document *doc = m_frame->document();
    756     if (!doc)
    757         return nil;
    758     return m_frame->eventHandler()->nextKeyViewInFrameHierarchy(doc->focusedNode(), FocusDirectionBackward);
    759 }
    760 
    761729- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)string
    762730{
  • trunk/WebKit/ChangeLog

    r18613 r18614  
     12007-01-04  Adam Roben  <aroben@apple.com>
     2
     3        Reviewed by Geoff, cheered by others.
     4
     5        Dead code elimination.
     6
     7        * WebView/WebHTMLView.m:
     8
    192007-01-04  Adam Roben  <aroben@apple.com>
    210
  • trunk/WebKit/WebView/WebHTMLView.m

    r18613 r18614  
    29982998}
    29992999
    3000 - (NSView *)previousValidKeyView
    3001 {
    3002     NSView *view = nil;
    3003     if (![self isHiddenOrHasHiddenAncestor])
    3004         view = [[self _bridge] previousKeyViewInsideWebFrameViews];
    3005     if (view == nil)
    3006         view = [super previousValidKeyView];
    3007     return view;
    3008 }
    3009 
    30103000- (BOOL)becomeFirstResponder
    30113001{
Note: See TracChangeset for help on using the changeset viewer.