Changeset 19049 in webkit
- Timestamp:
- Jan 23, 2007, 11:37:35 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r19047 r19049 1 2007-01-23 Adele Peterson <adele@apple.com> 2 3 Reviewed by Darin. 4 5 WebCore part of fix for <rdar://problem/4946753>REGRESSION: Inserting tabs is broken in Mail 6 7 In addition to this fix, I also reorganized some event handling code for keyPress events to 8 prepare for another fix. There's also just a little bit of unrelated cleanup. 9 10 * dom/EventTargetNode.cpp: (WebCore::EventTargetNode::defaultEventHandler): 11 Move tab focus behavior into new defaultKeyboardEventHandler method. 12 13 * bridge/EditorClient.h: Added handleKeyPress. 14 * editing/Editor.cpp: 15 (WebCore::Editor::handleKeyPress): Added. Calls over to the client method. 16 (WebCore::Editor::deleteRange): Removed unnecessary propogateDOMException. 17 * editing/Editor.h: Added handleKeyPress. 18 (WebCore::Editor::addToKillRing): Formatting cleanup. 19 * editing/mac/EditorMac.mm: Removed unnecessary propogateDOMException. 20 21 * page/EventHandler.cpp: (WebCore::EventHandler::defaultKeyboardEventHandler): Added. Checks 22 the tabKeyCyclesThroughElements setting before advancing focus for tab key events. Calls handleKeyPress. 23 * page/EventHandler.h: Added defaultKeyboardEventHandler. 24 25 * page/Page.cpp: (WebCore::Page::Page): Initialize m_tabKeyCyclesThroughElements to true. 26 * page/Page.h: Added m_tabKeyCyclesThroughElements. 27 (WebCore::Page::setTabKeyCyclesThroughElements): Added. 28 (WebCore::Page::tabKeyCyclesThroughElements): Added. 29 30 * platform/PlatformKeyboardEvent.h: Added ability to get NSEvent from PlatformKeyboardEvent. 31 * platform/mac/KeyEventMac.mm: (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 32 Initialize m_macEvent to the NSEvent. 33 34 * platform/graphics/svg/SVGImageEmptyClients.h: (WebCore::SVGEmptyEditorClient::handleKeyPress): Added. 35 1 36 2007-01-23 George Staikos <staikos@kde.org> 2 37 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r19042 r19049 11089 11089 isa = PBXProject; 11090 11090 buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; 11091 compatibilityVersion = "Xcode 2.4";11092 11091 hasScannedForEncodings = 1; 11093 11092 knownRegions = ( … … 11104 11103 projectDirPath = ""; 11105 11104 projectRoot = ""; 11106 shouldCheckCompatibility = 1;11107 11105 targets = ( 11108 11106 93F198A508245E59001E9ABC /* WebCore */, -
trunk/WebCore/bridge/EditorClient.h
r18931 r19049 40 40 class CSSStyleDeclaration; 41 41 class EditCommand; 42 class EventTargetNode; 42 43 class Frame; 43 44 class HTMLElement; 45 class KeyboardEvent; 44 46 class Node; 45 47 class Range; … … 92 94 virtual void redo() = 0; 93 95 96 virtual void handleKeyPress(EventTargetNode*, KeyboardEvent*) = 0; 97 94 98 #if PLATFORM(MAC) 95 99 // FIXME: This should become SelectionController::toWebArchive() -
trunk/WebCore/dom/EventTargetNode.cpp
r18610 r19049 561 561 { 562 562 const AtomicString& eventType = event->type(); 563 if (eventType == keypressEvent && event->isKeyboardEvent()) { 564 KeyboardEvent* keyEvent = static_cast<KeyboardEvent*>(event); 565 if (keyEvent->keyIdentifier() == "U+000009") { 566 if (Page* page = document()->page()) 567 if (page->focusController()->advanceFocus(keyEvent)) 568 event->setDefaultHandled(); 569 } 563 if (eventType == keypressEvent) { 564 if (event->isKeyboardEvent()) 565 if (Frame* frame = document()->frame()) 566 frame->eventHandler()->defaultKeyboardEventHandler(this, static_cast<KeyboardEvent*>(event)); 570 567 } else if (eventType == clickEvent) { 571 568 int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail() : 0; -
trunk/WebCore/editing/Editor.cpp
r19039 r19049 73 73 } 74 74 75 void Editor::handleKeyPress(EventTargetNode* target, KeyboardEvent* event) 76 { 77 if (EditorClient* c = client()) 78 c->handleKeyPress(target, event); 79 } 80 75 81 bool Editor::canEdit() const 76 82 { … … 163 169 } 164 170 165 void Editor::deleteRange(Range *range, bool killRing, bool prepend, bool smartDeleteOK, EditorDeleteAction deletionAction, TextGranularity granularity)171 void Editor::deleteRange(Range* range, bool killRing, bool prepend, bool smartDeleteOK, EditorDeleteAction deletionAction, TextGranularity granularity) 166 172 { 167 173 if (killRing) 168 174 addToKillRing(range, prepend); 169 175 176 ExceptionCode ec = 0; 177 170 178 SelectionController* selectionController = m_frame->selectionController(); 171 bool smartDelete = smartDeleteOK ? canSmartCopyOrDelete() : false; 172 ExceptionCode ec = 0; 179 bool smartDelete = smartDeleteOK && canSmartCopyOrDelete(); 173 180 switch (deletionAction) { 174 case deleteSelectionAction: 181 case deleteSelectionAction: 175 182 selectionController->setSelectedRange(range, DOWNSTREAM, true, ec); 176 propogateDOMException(ec); 183 if (ec) 184 return; 177 185 deleteSelectionWithSmartDelete(smartDelete); 178 186 break; 179 187 case deleteKeyAction: 180 188 selectionController->setSelectedRange(range, DOWNSTREAM, (granularity != CharacterGranularity), ec); 181 propogateDOMException(ec); 189 if (ec) 190 return; 182 191 if (m_frame->document()) { 183 192 TypingCommand::deleteKeyPressed(m_frame->document(), smartDelete, granularity); … … 187 196 case forwardDeleteKeyAction: 188 197 selectionController->setSelectedRange(range, DOWNSTREAM, (granularity != CharacterGranularity), ec); 189 propogateDOMException(ec); 198 if (ec) 199 return; 190 200 if (m_frame->document()) { 191 201 TypingCommand::forwardDeleteKeyPressed(m_frame->document(), smartDelete, granularity); -
trunk/WebCore/editing/Editor.h
r19039 r19049 48 48 class EditCommand; 49 49 class EditorClient; 50 class EventTargetNode; 50 51 class FontData; 51 52 class Frame; … … 65 66 DeleteButtonController* deleteButtonController() const { return m_deleteButtonController.get(); } 66 67 EditCommand* lastEditCommand() { return m_lastEditCommand.get(); } 67 68 69 void handleKeyPress(EventTargetNode*, KeyboardEvent*); 70 68 71 bool canEdit() const; 69 72 bool canEditRichly() const; … … 115 118 void deleteSelectionWithSmartDelete(bool smartDelete); 116 119 void deleteSelectionWithSmartDelete(); 117 bool dispatchCPPEvent(const AtomicString 120 bool dispatchCPPEvent(const AtomicString&, ClipboardAccessPolicy); 118 121 119 122 Node* removedAnchor() const { return m_removedAnchor.get(); } … … 198 201 199 202 #if PLATFORM(MAC) 200 // propogate DOM exception as an ObjC exception201 void propogateDOMException(ExceptionCode);202 203 203 void addToKillRing(Range*, bool prepend); 204 204 bool m_startNewKillRingSequence; 205 205 #else 206 void propogateDOMException(ExceptionCode){} 207 void addToKillRing(Range*, bool){} 206 void addToKillRing(Range*, bool) { } 208 207 #endif 209 208 -
trunk/WebCore/editing/mac/EditorMac.mm
r18564 r19049 69 69 return client()->userVisibleString(nsURL); 70 70 return nil; 71 }72 73 void Editor::propogateDOMException(ExceptionCode ec)74 {75 if (ec) raiseDOMException(ec);76 71 } 77 72 … … 650 645 [[NSApplication sharedApplication] orderFrontColorPanel:nil]; 651 646 } 652 647 653 648 } // namespace WebCore -
trunk/WebCore/page/EventHandler.cpp
r19029 r19049 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 4 * … … 33 33 #include "Editor.h" 34 34 #include "EventNames.h" 35 #include "FocusController.h" 35 36 #include "Frame.h" 36 37 #include "FrameTree.h" … … 46 47 #include "MouseEvent.h" 47 48 #include "MouseEventWithHitTestResults.h" 49 #include "Page.h" 48 50 #include "PlatformScrollBar.h" 49 51 #include "PlatformWheelEvent.h" … … 1174 1176 } 1175 1177 1176 } 1178 void EventHandler::defaultKeyboardEventHandler(EventTargetNode* target, KeyboardEvent* event) 1179 { 1180 if (target == event->target() && event->type() == keypressEvent) { 1181 if (Page* page = target->document()->page()) 1182 if (page->tabKeyCyclesThroughElements() && event->keyIdentifier() == "U+000009") 1183 if (page->focusController()->advanceFocus(event)) { 1184 event->setDefaultHandled(); 1185 return; 1186 } 1187 m_frame->editor()->handleKeyPress(target, event); 1188 } 1189 } 1190 1191 } -
trunk/WebCore/page/EventHandler.h
r18989 r19049 126 126 void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true; } 127 127 128 void defaultKeyboardEventHandler(EventTargetNode*, KeyboardEvent*); 129 128 130 #if PLATFORM(MAC) 129 131 PassRefPtr<KeyboardEvent> currentKeyboardEvent() const; -
trunk/WebCore/page/Page.cpp
r19039 r19049 62 62 , m_editorClient(editorClient) 63 63 , m_frameCount(0) 64 , m_tabKeyCyclesThroughElements(true) 64 65 , m_defersLoading(false) 65 66 { -
trunk/WebCore/page/Page.h
r19039 r19049 91 91 ProgressTracker* progress() const { return m_progress.get(); } 92 92 93 void setTabKeyCyclesThroughElements(bool b) { m_tabKeyCyclesThroughElements = b; } 94 bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements; } 95 93 96 void setDefersLoading(bool); 94 97 bool defersLoading() const { return m_defersLoading; } … … 116 119 String m_groupName; 117 120 121 bool m_tabKeyCyclesThroughElements; 118 122 bool m_defersLoading; 119 123 -
trunk/WebCore/platform/PlatformKeyboardEvent.h
r18068 r19049 31 31 32 32 #if PLATFORM(MAC) 33 #include "RetainPtr.h" 33 34 #ifdef __OBJC__ 34 35 @class NSEvent; … … 71 72 #if PLATFORM(MAC) 72 73 PlatformKeyboardEvent(NSEvent*, bool forceAutoRepeat = false); 74 NSEvent* macEvent() const { return m_macEvent.get(); } 73 75 #endif 74 76 … … 97 99 bool m_altKey; 98 100 bool m_metaKey; 101 102 #if PLATFORM(MAC) 103 RetainPtr<NSEvent> m_macEvent; 104 #endif 99 105 }; 100 106 -
trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h
r19042 r19049 304 304 virtual void undo() { } 305 305 virtual void redo() { } 306 306 307 virtual void handleKeyPress(EventTargetNode*, KeyboardEvent*) { } 308 307 309 #if PLATFORM(MAC) 308 310 // FIXME: This should become SelectionController::toWebArchive() -
trunk/WebCore/platform/mac/KeyEventMac.mm
r17700 r19049 706 706 707 707 PlatformKeyboardEvent::PlatformKeyboardEvent(NSEvent *event, bool forceAutoRepeat) 708 : m_text([event characters]), 709 m_unmodifiedText([event charactersIgnoringModifiers]), 710 m_keyIdentifier(keyIdentifierForKeyEvent(event)), 711 m_isKeyUp([event type] == NSKeyUp), 712 m_autoRepeat(forceAutoRepeat || [event isARepeat]), 713 m_WindowsKeyCode(WindowsKeyCodeForKeyEvent(event)), 714 m_isKeypad(isKeypadEvent(event)), 715 m_shiftKey([event modifierFlags] & NSShiftKeyMask), 716 m_ctrlKey([event modifierFlags] & NSControlKeyMask), 717 m_altKey([event modifierFlags] & NSAlternateKeyMask), 718 m_metaKey([event modifierFlags] & NSCommandKeyMask) 708 : m_text([event characters]) 709 , m_unmodifiedText([event charactersIgnoringModifiers]) 710 , m_keyIdentifier(keyIdentifierForKeyEvent(event)) 711 , m_isKeyUp([event type] == NSKeyUp) 712 , m_autoRepeat(forceAutoRepeat || [event isARepeat]) 713 , m_WindowsKeyCode(WindowsKeyCodeForKeyEvent(event)) 714 , m_isKeypad(isKeypadEvent(event)) 715 , m_shiftKey([event modifierFlags] & NSShiftKeyMask) 716 , m_ctrlKey([event modifierFlags] & NSControlKeyMask) 717 , m_altKey([event modifierFlags] & NSAlternateKeyMask) 718 , m_metaKey([event modifierFlags] & NSCommandKeyMask) 719 , m_macEvent(event) 719 720 { 720 721 // Turn 0x7F into 8, because backspace needs to always be 8. -
trunk/WebKit/ChangeLog
r19042 r19049 1 2007-01-23 Adele Peterson <adele@apple.com> 2 3 Reviewed by Darin. 4 5 WebKit part of fix for <rdar://problem/4946753>REGRESSION: Inserting tabs is broken in Mail 6 7 In addition to this fix, I also reorganized some event handling code for keyPress events to 8 prepare for another fix. 9 10 * WebCoreSupport/WebEditorClient.h: Added handleKeyPress method. 11 * WebCoreSupport/WebEditorClient.mm: 12 (WebEditorClient::handleKeyPress): Added. Code moved from WebHTMLView keyDown method. 13 This is called from the defaultEventHandler so that in the future, we can make the right 14 decision about which selection the keyPress should apply to. 15 * WebView/WebHTMLView.mm: 16 (-[WebHTMLView keyDown:]): Moved _interceptEditingKeyEvent call to handleKeyPress. 17 (-[WebHTMLView _interceptEditingKeyEvent:]): Prevents intercepting keys for cmd-modified events. Removed tabCycling checks 18 since this is now handled in WebCore. 19 * WebView/WebHTMLViewInternal.h: Made _interceptEditingKeyEvent SPI. 20 * WebView/WebView.mm: Use new tabKeyCyclesThroughElements methods on the page. 21 (-[WebViewPrivate init]): ditto. 22 (-[WebView setTabKeyCyclesThroughElements:]): ditto. 23 (-[WebView tabKeyCyclesThroughElements]): ditto. 24 (-[WebView setEditable:]): ditto 25 1 26 2007-01-23 Lars Knoll <lars@trolltech.com> 2 27 -
trunk/WebKit/WebCoreSupport/WebEditorClient.h
r18931 r19049 82 82 virtual void undo(); 83 83 virtual void redo(); 84 85 virtual void handleKeyPress(WebCore::EventTargetNode*, WebCore::KeyboardEvent*); 86 84 87 private: 85 88 void registerCommandForUndoOrRedo(PassRefPtr<WebCore::EditCommand>, bool isRedo); -
trunk/WebKit/WebCoreSupport/WebEditorClient.mm
r18931 r19049 44 44 #import <WebCore/EditAction.h> 45 45 #import <WebCore/EditCommand.h> 46 #import <WebCore/KeyboardEvent.h> 47 #import <WebCore/PlatformKeyboardEvent.h> 46 48 47 49 using namespace WebCore; … … 386 388 } 387 389 390 void WebEditorClient::handleKeyPress(EventTargetNode* node, KeyboardEvent* event) 391 { 392 WebHTMLView *webHTMLView = [[[m_webView mainFrame] frameView] documentView]; 393 if (const PlatformKeyboardEvent* platformEvent = event->keyEvent()) 394 if ([webHTMLView _canEdit] && [webHTMLView _interceptEditingKeyEvent:platformEvent->macEvent()]) 395 event->setDefaultHandled(); 396 } 397 388 398 /* 389 399 bool WebEditorClient::shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting) { return false; } -
trunk/WebKit/WebKit.xcodeproj/project.pbxproj
r19040 r19049 1281 1281 isa = PBXProject; 1282 1282 buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */; 1283 compatibilityVersion = "Xcode 2.4";1284 1283 hasScannedForEncodings = 1; 1285 1284 knownRegions = ( … … 1296 1295 projectDirPath = ""; 1297 1296 projectRoot = ""; 1298 shouldCheckCompatibility = 1;1299 1297 targets = ( 1300 1298 9398100A0824BF01008DF038 /* WebKit */, -
trunk/WebKit/WebView/WebHTMLView.mm
r19040 r19049 3320 3320 } 3321 3321 3322 - (BOOL)_interceptEditingKeyEvent:(NSEvent *)event3323 {3324 // Use WebView's tabKeyCyclesThroughElements state to determine whether or not3325 // to process tab key events. The idea here is that tabKeyCyclesThroughElements3326 // will be YES when this WebView is being used in a browser, and we desire the3327 // behavior where tab moves to the next element in tab order. If tabKeyCyclesThroughElements3328 // is NO, it is likely that the WebView is being embedded as the whole view, as in Mail,3329 // and tabs should input tabs as expected in a text editor. Using Option-Tab always cycles3330 // through elements.3331 3332 if ([[self _webView] tabKeyCyclesThroughElements] && [event _web_isTabKeyEvent])3333 return NO;3334 3335 if (![[self _webView] tabKeyCyclesThroughElements] && [event _web_isOptionTabKeyEvent])3336 return NO;3337 3338 // Now process the key normally3339 [self interpretKeyEvents:[NSArray arrayWithObject:event]];3340 return YES;3341 }3342 3343 3322 - (void)keyDown:(NSEvent *)event 3344 3323 { … … 3358 3337 // Consumed by complete: popup window 3359 3338 } else { 3360 // We're going to process a key event, bail on any outstanding complete: UI3361 3339 [_private->compController endRevertingChange:YES moveLeft:NO]; 3362 BOOL handledKey = [self _canEdit] && [self _interceptEditingKeyEvent:event]; 3363 if (!handledKey) 3364 callSuper = YES; 3340 callSuper = YES; 3365 3341 } 3366 3342 if (callSuper) … … 5259 5235 { 5260 5236 [self _updateMouseoverWithFakeEvent]; 5237 } 5238 5239 - (BOOL)_interceptEditingKeyEvent:(NSEvent *)event 5240 { 5241 // If the cmd-key is down, then we shouldn't intercept the key since this will 5242 // be handled correctly in performKeyEquivalent 5243 if ([event modifierFlags] & NSCommandKeyMask) 5244 return NO; 5245 5246 // Now process the key normally 5247 [self interpretKeyEvents:[NSArray arrayWithObject:event]]; 5248 return YES; 5261 5249 } 5262 5250 -
trunk/WebKit/WebView/WebHTMLViewInternal.h
r19040 r19049 113 113 - (void)_lookUpInDictionaryFromMenu:(id)sender; 114 114 - (void)_hoverFeedbackSuspendedChanged; 115 - (BOOL)_interceptEditingKeyEvent:(NSEvent *)event; 115 116 - (DOMDocumentFragment*)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard; 116 117 #if !BUILDING_ON_TIGER -
trunk/WebKit/WebView/WebView.mm
r19040 r19049 287 287 BOOL drawsBackground; 288 288 BOOL editable; 289 BOOL tabKeyCyclesThroughElements;290 289 BOOL tabKeyCyclesThroughElementsChanged; 291 290 BOOL becomingFirstResponder; … … 397 396 textSizeMultiplier = 1; 398 397 dashboardBehaviorAllowWheelScrolling = YES; 399 tabKeyCyclesThroughElements = YES;400 398 shouldCloseWithWindow = objc_collecting_enabled(); 401 399 continuousSpellCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebContinuousSpellCheckingEnabled]; … … 2678 2676 { 2679 2677 _private->tabKeyCyclesThroughElementsChanged = YES; 2680 _private-> tabKeyCyclesThroughElements = cyclesElements;2678 _private->page->setTabKeyCyclesThroughElements(cyclesElements); 2681 2679 } 2682 2680 2683 2681 - (BOOL)tabKeyCyclesThroughElements 2684 2682 { 2685 return _private-> tabKeyCyclesThroughElements;2683 return _private->page->tabKeyCyclesThroughElements(); 2686 2684 } 2687 2685 … … 2977 2975 _private->editable = flag; 2978 2976 if (!_private->tabKeyCyclesThroughElementsChanged) 2979 _private-> tabKeyCyclesThroughElements = !flag;2977 _private->page->setTabKeyCyclesThroughElements(!flag); 2980 2978 FrameMac* mainFrame = [[[self mainFrame] _bridge] _frame]; 2981 2979 if (mainFrame) {
Note:
See TracChangeset
for help on using the changeset viewer.