Changeset 18614 in webkit
- Timestamp:
- Jan 4, 2007 11:44:46 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r18610 r18614 1 2007-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 1 14 2007-01-04 Adam Roben <aroben@apple.com> 2 15 -
trunk/WebCore/page/EventHandler.h
r18610 r18614 27 27 #define EventHandler_h 28 28 29 #include "FocusDirection.h"30 29 #include "PlatformMouseEvent.h" 31 30 #include "ScrollTypes.h" … … 126 125 127 126 #if PLATFORM(MAC) 128 129 NSView *nextKeyView(Node*, FocusDirection);130 NSView *nextKeyViewInFrameHierarchy(Node*, FocusDirection);131 static NSView *nextKeyView(Widget*, FocusDirection);132 133 127 PassRefPtr<KeyboardEvent> currentKeyboardEvent() const; 134 128 … … 221 215 222 216 NSView *mouseDownViewIfStillGood(); 223 NSView *nextKeyViewInFrame(Node*, FocusDirection, bool* focusCallResultedInViewBeingCreated = 0);224 217 #endif 225 218 -
trunk/WebCore/page/mac/EventHandlerMac.mm
r18610 r18614 93 93 94 94 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 the118 // 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 needed123 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 else136 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 view152 // 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 types154 // 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 native160 // 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 lost163 // 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);206 95 } 207 96 -
trunk/WebCore/page/mac/WebCoreFrameBridge.h
r18541 r18614 132 132 - (NSArray*)computePageRectsWithPrintWidthScaleFactor:(float)printWidthScaleFactor printHeight:(float)printHeight; 133 133 134 - (NSView *)nextKeyView;135 - (NSView *)previousKeyView;136 137 - (NSView *)nextKeyViewInsideWebFrameViews;138 - (NSView *)previousKeyViewInsideWebFrameViews;139 140 134 - (NSObject *)copyRenderTree:(id <WebCoreRenderTreeCopier>)copier; 141 135 - (NSString *)renderTreeAsExternalRepresentation; … … 295 289 - (void)formControlIsBecomingFirstResponder:(NSView *)formControl; 296 290 - (void)formControlIsResigningFirstResponder:(NSView *)formControl; 297 298 - (NSView *)nextKeyViewOutsideWebFrameViews;299 - (NSView *)previousKeyViewOutsideWebFrameViews;300 291 301 292 - (void)setNeedsReapplyStyles; -
trunk/WebCore/page/mac/WebCoreFrameBridge.mm
r18610 r18614 727 727 } 728 728 729 - (NSView *)nextKeyView730 {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 *)previousKeyView738 {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 *)nextKeyViewInsideWebFrameViews746 {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 *)previousKeyViewInsideWebFrameViews754 {755 Document *doc = m_frame->document();756 if (!doc)757 return nil;758 return m_frame->eventHandler()->nextKeyViewInFrameHierarchy(doc->focusedNode(), FocusDirectionBackward);759 }760 761 729 - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)string 762 730 { -
trunk/WebKit/ChangeLog
r18613 r18614 1 2007-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 1 9 2007-01-04 Adam Roben <aroben@apple.com> 2 10 -
trunk/WebKit/WebView/WebHTMLView.m
r18613 r18614 2998 2998 } 2999 2999 3000 - (NSView *)previousValidKeyView3001 {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 3010 3000 - (BOOL)becomeFirstResponder 3011 3001 {
Note: See TracChangeset
for help on using the changeset viewer.