Changeset 19579 in webkit
- Timestamp:
- Feb 12, 2007, 11:05:07 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r19578 r19579 1 2007-02-12 Darin Adler <darin@apple.com> 2 3 Reviewed by Oliver. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=12677 6 <rdar://problem/4759563> REGRESSION: Return key is always sent when you confirm 7 a clause in kotoeri (12677) 8 9 - fix http://bugs.webkit.org/show_bug.cgi?id=12596 10 <rdar://problem/4794346> REGRESSION: Tab key shifts form field focus instead of 11 navigating prediction window (12596) 12 13 - fix http://bugs.webkit.org/show_bug.cgi?id=10010 14 <rdar://problem/4822935> REGRESSION: Pressing Return with unconfirmed text in 15 Hangul inserts carriage return (10010) 16 17 - fix http://bugs.webkit.org/show_bug.cgi?id=12531 18 <rdar://problem/4975126> REGRESSION: Inline text input types repeated keys in 19 latest nightly (r19336) (12531) 20 21 - fix http://bugs.webkit.org/show_bug.cgi?id=12539 22 <rdar://problem/4975130> REGRESSION: Pressing Backspace while in inline input 23 area moves to the previous page in history (12539) 24 25 This area still needs work because keypress events are being sent for all the 26 events before they go to the input methods, and it seems that this is not 27 compatible with what other browsers do and with what sites assume. That's covered 28 by this bug: 29 30 http://bugs.webkit.org/show_bug.cgi?id=10871 31 <rdar://problem/4823129> REGRESSION: IME key events different in nightly (10871) 32 33 which is still open. 34 35 * bindings/objc/ExceptionHandlers.h: Remove selectRange helper that doesn't really 36 belong here, and also isn't needed since the callers don't want to raise ObjC 37 exceptions. 38 * bindings/objc/ExceptionHandlers.mm: Ditto. Also removed unneeded external globals 39 that aren't exported anyway and unneeded includes. 40 41 * bridge/EditorClient.h: Added Mac-specific function, markedTextAbandoned. Long term 42 this might move into platform instead, but it's fine to have it on the client for now 43 as long as it doesn't cause trouble for platforms other than Mac. 44 45 * dom/EventTargetNode.cpp: (WebCore::EventTargetNode::defaultEventHandler): Since 46 all the event handling code in this function is intended to run on the node itself, 47 not parent nodes, check and do nothing if this event is bubbling up from another 48 node. Added code to call a function on EventHandler for default handling of text 49 input events. 50 51 * dom/KeyboardEvent.h: 52 * dom/KeyboardEvent.cpp: (WebCore::findKeyboardEvent): Added. Just like the 53 findUIEventWithKeyState function, but specific to keyboard events. 54 55 * dom/TextEvent.h: Added isLineBreak and isBackTab flags so that we can carry 56 additional information about what a text input event is trying to do, but still 57 go through the DOM event machinery. 58 * dom/TextEvent.cpp: Ditto. 59 60 * editing/Editor.h: 61 * editing/Editor.cpp: 62 (WebCore::Editor::handleKeyPress): Removed unneeded check of isCaretOrRange, since 63 isContentEditable already checks that. 64 (WebCore::Editor::canEdit): Ditto. 65 (WebCore::Editor::canEditRichly): Ditto. 66 (WebCore::Editor::canPaste): Changed to call canEdit for brevity. 67 (WebCore::Editor::replaceSelectionWithText): Changed to take a const String&. 68 (WebCore::Editor::shouldInsertText): Ditto. 69 (WebCore::hasEditableSelection): Removed unneeded check of isCaretOrRange, since 70 isContentEditable already checks that. 71 (WebCore::Editor::Editor): Initialize the new m_ignoreMarkedTextSelectionChange 72 flag. Moved here from WebHTMLView. 73 (WebCore::Editor::insertText): Moved most of the code from -[WebHTMLView insertText:] 74 here, since this needs to be done in response to a text input event and we don't want 75 to go back over the WebKit side for that. 76 (WebCore::Editor::insertLineBreak): Added. Moved here from -[WebHTMLView insertLineBreak:] 77 for the same reason -- needs to be done in response to text input events. 78 (WebCore::Editor::insertParagraphSeparator): Ditto. 79 (WebCore::Editor::selectMarkedText): Added. Used by insertText. 80 (WebCore::Editor::discardMarkedText): Added. Used by insertText. 81 (WebCore::Editor::unmarkText): Added. Used by insertText. 82 * editing/mac/EditorMac.mm: 83 (WebCore::Editor::unmarkText): Added. Used by insertText. 84 85 * html/HTMLInputElement.cpp: 86 (WebCore::HTMLInputElement::canHaveSelection): Changed to use isTextField to avoid repeating 87 the switch statement. 88 (WebCore::HTMLInputElement::selectionStart): Ditto. 89 (WebCore::HTMLInputElement::selectionEnd): Ditto. 90 (WebCore::HTMLInputElement::setSelectionStart): Ditto. 91 (WebCore::HTMLInputElement::setSelectionEnd): Ditto. 92 (WebCore::HTMLInputElement::select): Ditto. 93 (WebCore::HTMLInputElement::setSelectionRange): Ditto. 94 (WebCore::HTMLInputElement::createRenderer): Resorted cases alphaebtically. 95 (WebCore::HTMLInputElement::defaultEventHandler): Added code to make hitting return cause the 96 form to be submitted when it comes through as a text input event. This is now the normal case 97 on Macintosh, because enter key presses normally turn into this. In addition, change the other 98 event handling to run only after trying the base defaultEventHandler. That makes the key 99 handling done in EventTargetNode take precedence over the event handling here for editable text 100 fields, which is what we want. This gets rid of the need for the hack where we check 101 inputManagerHasMarkedText and suppress the handling of the enter key. 102 103 * page/EventHandler.h: Removed unneeded includes. Moved EventHandlerDragState down into the 104 private part of the class. Changed sendContextMenuEvent to take a const&. Added new 105 handleTextInputEvent and defaultTextInputEventHandler functions. Made eventLoopHandleMouseUp 106 and eventLoopHandleMouseDragged private. Added private defaultTabEventHandler function. 107 * page/EventHandler.cpp: 108 (WebCore::EventHandler::sendContextMenuEvent): Changed parameter to be a const&. 109 (WebCore::EventHandler::defaultKeyboardEventHandler): Rearranged things so that the key bindings 110 handling in handleKeyPress comes before special tab event handling. In cases where the tab turns 111 into text to insert, we now handle it in the text input event handler. 112 (WebCore::EventHandler::handleTextInputEvent): Added. Creates and dispatches a text input event. 113 (WebCore::EventHandler::defaultTextInputEventHandler): Added. Inserts text, but has special cases 114 for the tab and newline character cases. 115 (WebCore::EventHandler::defaultTabEventHandler): Added. Shared by the tab-handling code in 116 the keyboard event and text input event handlers. 117 * page/mac/EventHandlerMac.mm: Tweak formatting, remove some unused functions. 118 119 * page/FocusController.h: Removed unnneded includes and forwards, and added an overload of 120 advanceFocus that takes a FocusDirection parameter. 121 * page/FocusController.cpp: (WebCore::FocusController::advanceFocus): Changed to allow a 0 for 122 the event pointer. Also added a version where the direction is passed explicitly, to be used 123 for cases where we want to tab backward even if the event doesn't have a shift modifier key set. 124 125 * platform/graphics/svg/SVGImageEmptyClients.h: Updated for change to EditorClient. 126 This should really probably just use 0 for the EditorClient. 127 128 * WebCore.exp: Update both for newly used and no-longer-used entry points. 129 130 * page/mac/WebCoreFrameBridge.h: 131 * page/mac/WebCoreFrameBridge.mm: Removed two unused methods. 132 1 133 2007-02-12 Antti Koivisto <antti@apple.com> 2 134 -
trunk/WebCore/WebCore.exp
r19538 r19579 128 128 __ZN7WebCore10EventNames12keydownEventE 129 129 __ZN7WebCore10MouseEventC1ERKNS_12AtomicStringEbbPNS_9DOMWindowEiiiiibbbbtPNS_15EventTargetNodeEPNS_9ClipboardEb 130 __ZN7WebCore10StringImpl7replaceEtt 130 131 __ZN7WebCore10StringImplD1Ev 131 132 __ZN7WebCore11ContextMenu22setPlatformDescriptionEP14NSMutableArray … … 191 192 __ZN7WebCore11RenderLayer18gAlignCenterAlwaysE 192 193 __ZN7WebCore11globalPointERK8_NSPointP8NSWindow 193 __ZN7WebCore11selectRangeEPNS_19SelectionControllerEPNS_5RangeENS_9EAffinityEb194 194 __ZN7WebCore11toUserSpaceERK7_NSRectP8NSWindow 195 195 __ZN7WebCore12AtomicString3addEPKc … … 198 198 __ZN7WebCore12EventHandler10wheelEventEP7NSEvent 199 199 __ZN7WebCore12EventHandler12mouseDraggedEP7NSEvent 200 __ZN7WebCore12EventHandler20handleTextInputEventERKNS_6StringEPNS_5EventEbb 200 201 __ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_8IntPointEb 201 __ZN7WebCore12EventHandler20sendContextMenuEventE NS_18PlatformMouseEventE202 __ZN7WebCore12EventHandler20sendContextMenuEventERKNS_18PlatformMouseEventE 202 203 __ZN7WebCore12EventHandler7mouseUpEP7NSEvent 203 204 __ZN7WebCore12EventHandler8keyEventEP7NSEvent … … 290 291 __ZN7WebCore16NavigationActionC1Ev 291 292 __ZN7WebCore18PlatformMouseEventC1EP7NSEvent 293 __ZN7WebCore19SelectionController16setSelectedRangeEPNS_5RangeENS_9EAffinityEbRi 292 294 __ZN7WebCore19SelectionController5clearEv 293 295 __ZN7WebCore19SelectionController9selectAllEv … … 332 334 __ZN7WebCore6Editor10applyStyleEPNS_19CSSStyleDeclarationENS_10EditActionE 333 335 __ZN7WebCore6Editor10insertTextERKNS_6StringEbPNS_5EventE 336 __ZN7WebCore6Editor10unmarkTextEv 334 337 __ZN7WebCore6Editor11canDHTMLCutEv 335 338 __ZN7WebCore6Editor11deleteRangeEPNS_5RangeEbbbNS_18EditorDeleteActionENS_15TextGranularityE … … 341 344 __ZN7WebCore6Editor13performDeleteEv 342 345 __ZN7WebCore6Editor13tryDHTMLPasteEv 346 __ZN7WebCore6Editor16selectMarkedTextEv 347 __ZN7WebCore6Editor17discardMarkedTextEv 343 348 __ZN7WebCore6Editor19deleteWithDirectionENS_19SelectionController10EDirectionENS_15TextGranularityEbb 344 349 __ZN7WebCore6Editor21applyStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r19548 r19579 11153 11153 isa = PBXProject; 11154 11154 buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; 11155 compatibilityVersion = "Xcode 2.4";11156 11155 hasScannedForEncodings = 1; 11157 11156 knownRegions = ( … … 11168 11167 projectDirPath = ""; 11169 11168 projectRoot = ""; 11170 shouldCheckCompatibility = 1;11171 11169 targets = ( 11172 11170 93F198A508245E59001E9ABC /* WebCore */, -
trunk/WebCore/bindings/objc/ExceptionHandlers.h
r19503 r19579 1 1 /* 2 * Copyright (C) 2004 -2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #define ExceptionHandlers_h 28 28 29 #include "TextAffinity.h"30 29 #include <JavaScriptCore/Assertions.h> 31 30 … … 55 54 } 56 55 57 void selectRange(SelectionController*, Range*, EAffinity, bool closeTyping);58 59 56 } // namespace WebCore 60 57 -
trunk/WebCore/bindings/objc/ExceptionHandlers.mm
r17455 r19579 1 1 /* 2 * Copyright (C) 2004, 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #include "ExceptionHandlers.h" 28 28 29 #include "Document.h" 30 #include "Node.h" 31 #include "SelectionController.h" 32 #include "PlatformString.h" 29 #include "Event.h" 33 30 #include "RangeException.h" 34 #include "Event.h"35 31 #include "SVGException.h" 36 32 #include "XPathEvaluator.h" 37 38 NSString * const DOMException = @"DOMException";39 NSString * const DOMRangeException = @"DOMRangeException";40 NSString * const DOMEventException = @"DOMEventException";41 #ifdef SVG_SUPPORT42 NSString * const DOMSVGException = @"DOMSVGException";43 #endif // SVG_SUPPORT44 #ifdef XPATH_SUPPORT45 NSString * const DOMXPathException = @"DOMXPathException";46 #endif // XPATH_SUPPORT47 33 48 34 namespace WebCore { … … 52 38 ASSERT(ec); 53 39 54 NSString *name = ::DOMException;40 NSString *name = @"DOMException"; 55 41 56 42 int code = ec; 57 43 if (ec >= RangeExceptionOffset && ec <= RangeExceptionMax) { 58 name = DOMRangeException;44 name = @"DOMRangeException"; 59 45 code -= RangeExceptionOffset; 60 46 } else if (ec >= EventExceptionOffset && ec <= EventExceptionMax) { 61 name = DOMEventException;47 name = @"DOMEventException"; 62 48 code -= EventExceptionOffset; 63 49 #ifdef SVG_SUPPORT 64 50 } else if (ec >= SVGExceptionOffset && ec <= SVGExceptionMax) { 65 name = DOMSVGException;51 name = @"DOMSVGException"; 66 52 code -= SVGExceptionOffset; 67 #endif // SVG_SUPPORT53 #endif 68 54 #ifdef XPATH_SUPPORT 69 55 } else if (ec >= XPathExceptionOffset && ec <= XPathExceptionMax) { 70 name = DOMXPathException;56 name = @"DOMXPathException"; 71 57 code -= XPathExceptionOffset; 72 #endif // XPATH_SUPPORT58 #endif 73 59 } 74 60 … … 79 65 } 80 66 81 void selectRange(SelectionController* selectionController, Range* range, EAffinity affinity, bool closeTyping)82 {83 ExceptionCode ec = 0;84 selectionController->setSelectedRange(range, affinity, closeTyping, ec);85 raiseOnDOMError(ec);86 }87 88 67 } // namespace WebCore -
trunk/WebCore/bridge/EditorClient.h
r19237 r19579 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #include "EditorInsertAction.h" 30 30 #include <wtf/Forward.h> 31 31 32 #if PLATFORM(MAC) 32 33 class NSArray; … … 40 41 class CSSStyleDeclaration; 41 42 class EditCommand; 42 class EventTargetNode;43 43 class Frame; 44 44 class HTMLElement; … … 68 68 virtual bool shouldEndEditing(Range*) = 0; 69 69 virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction) = 0; 70 // virtual bool shouldInsertNode(Node*, Range* replacingRange, WebViewInsertAction) = 0;71 70 virtual bool shouldInsertText(String, Range*, EditorInsertAction) = 0; 72 71 // virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, NSSelectionAffinity, bool stillSelecting) = 0; … … 74 73 // virtual bool shouldChangeTypingStyle(CSSStyleDeclaration* fromStyle, CSSStyleDeclaration* toStyle) = 0; 75 74 // virtual bool doCommandBySelector(SEL selector) = 0; 76 // 75 77 76 virtual void didBeginEditing() = 0; 78 77 virtual void respondToChangedContents() = 0; … … 80 79 virtual void didWriteSelectionToPasteboard() = 0; 81 80 virtual void didSetSelectionTypesForPasteboard() = 0; 82 // virtual void webViewDidChangeTypingStyle:(NSNotification *)notification = 0;83 // virtual void webViewDidChangeSelection:(NSNotification *)notification = 0;84 // virtual NSUndoManager* undoManager ForWebView:(WebView *)webView = 0;81 // virtual void didChangeTypingStyle:(NSNotification *)notification = 0; 82 // virtual void didChangeSelection:(NSNotification *)notification = 0; 83 // virtual NSUndoManager* undoManager:(WebView *)webView = 0; 85 84 86 85 virtual void registerCommandForUndo(PassRefPtr<EditCommand>) = 0; … … 97 96 98 97 #if PLATFORM(MAC) 98 virtual void markedTextAbandoned(Frame*) = 0; 99 99 100 // FIXME: This should become SelectionController::toWebArchive() 100 101 virtual NSData* dataForArchivedSelection(Frame*) = 0; -
trunk/WebCore/dom/EventTargetNode.cpp
r19378 r19579 1 1 /* 2 * This file is part of the DOM implementation for KDE.3 *4 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 5 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 7 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 8 6 * 9 7 * This library is free software; you can redistribute it and/or … … 46 44 #include "PlatformWheelEvent.h" 47 45 #include "RegisteredEventListener.h" 46 #include "TextEvent.h" 48 47 #include "UIEvent.h" 49 48 #include "WheelEvent.h" … … 572 571 void EventTargetNode::defaultEventHandler(Event* event) 573 572 { 573 if (event->target() != this) 574 return; 574 575 const AtomicString& eventType = event->type(); 575 576 if (eventType == keypressEvent) { … … 584 585 if (Page* page = frame->page()) 585 586 page->contextMenuController()->handleContextMenuEvent(event); 587 } else if (eventType == textInputEvent) { 588 if (event->isTextEvent()) 589 if (Frame* frame = document()->frame()) 590 frame->eventHandler()->defaultTextInputEventHandler(static_cast<TextEvent*>(event)); 586 591 } 587 592 } -
trunk/WebCore/dom/KeyboardEvent.cpp
r17064 r19579 1 1 /** 2 * This file is part of the DOM implementation for KDE.3 *4 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 5 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 6 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 7 * Copyright (C) 2003, 2005, 2006 Apple Computer, Inc.5 * Copyright (C) 2003, 2005, 2006, 2007 Apple Inc. All rights reserved. 8 6 * 9 7 * This library is free software; you can redistribute it and/or … … 22 20 * Boston, MA 02111-1307, USA. 23 21 */ 22 24 23 #include "config.h" 25 24 #include "KeyboardEvent.h" … … 127 126 } 128 127 128 KeyboardEvent* findKeyboardEvent(Event* event) 129 { 130 for (Event* e = event; e; e = e->underlyingEvent()) 131 if (e->isKeyboardEvent()) 132 return static_cast<KeyboardEvent*>(e); 133 return 0; 134 } 135 129 136 } // namespace WebCore -
trunk/WebCore/dom/KeyboardEvent.h
r17064 r19579 5 5 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 6 6 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 7 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.7 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 8 8 * 9 9 * This library is free software; you can redistribute it and/or … … 45 45 KeyboardEvent(); 46 46 KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*); 47 KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view,47 KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView*, 48 48 const String& keyIdentifier, unsigned keyLocation, 49 49 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey); 50 50 virtual ~KeyboardEvent(); 51 51 52 void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view,52 void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView*, 53 53 const String& keyIdentifier, unsigned keyLocation, 54 54 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey = false); … … 76 76 }; 77 77 78 KeyboardEvent* findKeyboardEvent(Event*); 79 78 80 } // namespace WebCore 79 81 -
trunk/WebCore/dom/TextEvent.cpp
r19538 r19579 35 35 36 36 TextEvent::TextEvent() 37 : m_isLineBreak(false) 38 , m_isBackTab(false) 37 39 { 38 40 } … … 41 43 : UIEvent(textInputEvent, true, true, view, 0) 42 44 , m_data(data) 45 , m_isLineBreak(false) 46 , m_isBackTab(false) 43 47 { 44 48 } -
trunk/WebCore/dom/TextEvent.h
r19538 r19579 44 44 virtual bool isTextEvent() const; 45 45 46 // If true, any newline characters in the text are line breaks only, not paragraph separators. 47 bool isLineBreak() const { return m_isLineBreak; } 48 void setIsLineBreak(bool isLineBreak) { m_isLineBreak = isLineBreak; } 49 50 // If true, any tab characters in the text are backtabs. 51 bool isBackTab() const { return m_isBackTab; } 52 void setIsBackTab(bool isBackTab) { m_isBackTab = isBackTab; } 53 46 54 private: 47 55 String m_data; 56 bool m_isLineBreak; 57 bool m_isBackTab; 48 58 }; 49 59 -
trunk/WebCore/editing/Editor.cpp
r19463 r19579 1 1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 103 103 void Editor::handleKeyPress(KeyboardEvent* event) 104 104 { 105 if (EditorClient* c = client()) { 106 Selection selection = selectionForEvent(m_frame, event); 107 if (selection.isCaretOrRange() && selection.isContentEditable()) 105 if (EditorClient* c = client()) 106 if (selectionForEvent(m_frame, event).isContentEditable()) 108 107 c->handleKeyPress(event); 109 }110 108 } 111 109 112 110 bool Editor::canEdit() const 113 111 { 114 SelectionController* selectionController = m_frame->selectionController(); 115 return selectionController->isCaretOrRange() && selectionController->isContentEditable(); 112 return m_frame->selectionController()->isContentEditable(); 116 113 } 117 114 118 115 bool Editor::canEditRichly() const 119 116 { 120 SelectionController* selectionController = m_frame->selectionController(); 121 return canEdit() && selectionController->isContentRichlyEditable(); 117 return m_frame->selectionController()->isContentRichlyEditable(); 122 118 } 123 119 … … 155 151 bool Editor::canPaste() const 156 152 { 157 SelectionController* selectionController = m_frame->selectionController(); 158 return selectionController->isCaretOrRange() && selectionController->isContentEditable(); 153 return canEdit(); 159 154 } 160 155 … … 333 328 } 334 329 335 void Editor::replaceSelectionWithText( Stringtext, bool selectReplacement, bool smartReplace)330 void Editor::replaceSelectionWithText(const String& text, bool selectReplacement, bool smartReplace) 336 331 { 337 332 replaceSelectionWithFragment(createFragmentFromText(selectedRange().get(), text), selectReplacement, smartReplace, true); … … 393 388 } 394 389 395 bool Editor::shouldInsertText( Stringtext, Range* range, EditorInsertAction action) const390 bool Editor::shouldInsertText(const String& text, Range* range, EditorInsertAction action) const 396 391 { 397 392 if (client()) … … 1103 1098 static bool hasEditableSelection(Frame* frame) 1104 1099 { 1105 return frame->selectionController()->isC aretOrRange() && frame->selectionController()->isContentEditable();1100 return frame->selectionController()->isContentEditable(); 1106 1101 } 1107 1102 … … 1214 1209 : m_frame(frame) 1215 1210 , m_deleteButtonController(new DeleteButtonController(frame)) 1211 , m_ignoreMarkedTextSelectionChange(false) 1216 1212 { 1217 1213 } … … 1242 1238 bool Editor::insertText(const String& text, bool selectInsertedText, Event* triggeringEvent) 1243 1239 { 1240 if (text.isEmpty()) 1241 return false; 1242 1243 RefPtr<Range> range = m_frame->markedTextRange(); 1244 if (!range) { 1245 Selection selection = selectionForEvent(m_frame, triggeringEvent); 1246 if (!selection.isContentEditable()) 1247 return false; 1248 range = selection.toRange(); 1249 } 1250 1251 if (!shouldInsertText(text, range.get(), EditorInsertActionTyped)) { 1252 discardMarkedText(); 1253 return true; 1254 } 1255 1256 setIgnoreMarkedTextSelectionChange(true); 1257 1258 // If we had marked text, replace that instead of the selection/caret. 1259 selectMarkedText(); 1260 1244 1261 // Get the selection to use for the event that triggered this insertText. 1245 1262 // If the event handler changed the selection, we may want to use a different selection 1246 1263 // that is contained in the event target. 1247 1264 Selection selection = selectionForEvent(m_frame, triggeringEvent); 1248 if (!selection.isCaretOrRange() || !selection.isContentEditable()) 1265 if (selection.isContentEditable()) { 1266 if (Node* selectionStart = selection.start().node()) { 1267 RefPtr<Document> document = selectionStart->document(); 1268 1269 // Insert the text 1270 TypingCommand::insertText(document.get(), text, selection, selectInsertedText); 1271 1272 // Reveal the current selection 1273 if (Frame* editedFrame = document->frame()) 1274 if (Page* page = editedFrame->page()) 1275 page->focusController()->focusedOrMainFrame()->revealSelection(RenderLayer::gAlignToEdgeIfNeeded); 1276 } 1277 } 1278 1279 setIgnoreMarkedTextSelectionChange(false); 1280 1281 // Inserting unmarks any marked text. 1282 unmarkText(); 1283 1284 return true; 1285 } 1286 1287 bool Editor::insertLineBreak() 1288 { 1289 if (!canEdit()) 1249 1290 return false; 1250 Node* selectionStart = selection.start().node(); 1251 if (!selectionStart) 1291 1292 if (!shouldInsertText("\n", m_frame->selectionController()->toRange().get(), EditorInsertActionTyped)) 1293 return true; 1294 1295 TypingCommand::insertLineBreak(m_frame->document()); 1296 m_frame->revealSelection(RenderLayer::gAlignToEdgeIfNeeded); 1297 return true; 1298 } 1299 1300 bool Editor::insertParagraphSeparator() 1301 { 1302 if (!canEdit()) 1252 1303 return false; 1253 RefPtr<Document> document = selectionStart->document(); 1254 1255 // Insert the text1256 TypingCommand::insertText(document.get(), text, selection, selectInsertedText); 1257 1258 // Reveal the current selection1259 if (Frame* editedFrame = document->frame()) 1260 if (Page* page = editedFrame->page())1261 page->focusController()->focusedOrMainFrame()->revealSelection(RenderLayer::gAlignToEdgeIfNeeded);1304 1305 if (!canEditRichly()) 1306 return insertLineBreak(); 1307 1308 if (!shouldInsertText("\n", m_frame->selectionController()->toRange().get(), EditorInsertActionTyped)) 1309 return true; 1310 1311 TypingCommand::insertParagraphSeparator(m_frame->document()); 1312 m_frame->revealSelection(RenderLayer::gAlignToEdgeIfNeeded); 1262 1313 return true; 1263 1314 } … … 1439 1490 } 1440 1491 1492 void Editor::selectMarkedText() 1493 { 1494 Range* range = m_frame->markedTextRange(); 1495 if (!range) 1496 return; 1497 ExceptionCode ec = 0; 1498 m_frame->selectionController()->setSelectedRange(m_frame->markedTextRange(), DOWNSTREAM, false, ec); 1499 } 1500 1501 void Editor::discardMarkedText() 1502 { 1503 if (!m_frame->markedTextRange()) 1504 return; 1505 1506 setIgnoreMarkedTextSelectionChange(true); 1507 1508 selectMarkedText(); 1509 unmarkText(); 1510 #if PLATFORM(MAC) 1511 if (EditorClient* c = client()) 1512 c->markedTextAbandoned(m_frame); 1513 #endif 1514 deleteSelectionWithSmartDelete(false); 1515 1516 setIgnoreMarkedTextSelectionChange(false); 1517 } 1518 1519 #if !PLATFORM(MAC) 1520 void Editor::unmarkText() 1521 { 1522 } 1523 #endif 1524 1441 1525 } // namespace WebCore -
trunk/WebCore/editing/Editor.h
r19237 r19579 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 95 95 96 96 bool shouldInsertFragment(PassRefPtr<DocumentFragment> fragment, PassRefPtr<Range> replacingDOMRange, EditorInsertAction givenAction); 97 bool shouldInsertText( String, Range*, EditorInsertAction) const;97 bool shouldInsertText(const String&, Range*, EditorInsertAction) const; 98 98 bool shouldShowDeleteInterface(HTMLElement*) const; 99 99 bool shouldDeleteRange(Range*) const; … … 140 140 141 141 bool insertText(const String&, bool selectInsertedText, Event* triggeringEvent = 0); 142 bool insertLineBreak(); 143 bool insertParagraphSeparator(); 142 144 143 145 bool isContinuousSpellCheckingEnabled(); … … 158 160 bool spellingPanelIsShowing(); 159 161 160 bool shouldBeginEditing(Range* range);161 bool shouldEndEditing(Range* range);162 bool shouldBeginEditing(Range*); 163 bool shouldEndEditing(Range*); 162 164 163 165 void clearUndoRedoOperations(); … … 180 182 bool smartInsertDeleteEnabled(); 181 183 184 void selectMarkedText(); 185 void unmarkText(); 186 void discardMarkedText(); 187 188 bool ignoreMarkedTextSelectionChange() const { return m_ignoreMarkedTextSelectionChange; } 189 void setIgnoreMarkedTextSelectionChange(bool ignore) { m_ignoreMarkedTextSelectionChange = ignore; } 190 182 191 #if PLATFORM(MAC) 183 192 NSString* userVisibleString(NSURL*); … … 190 199 RefPtr<EditCommand> m_lastEditCommand; 191 200 RefPtr<Node> m_removedAnchor; 201 bool m_ignoreMarkedTextSelectionChange; 192 202 193 203 bool canDeleteRange(Range*) const; 194 204 bool canSmartCopyOrDelete(); 195 bool canSmartReplaceWithPasteboard(Pasteboard* pasteboard);196 PassRefPtr<Clipboard> newGeneralClipboard(ClipboardAccessPolicy policy);205 bool canSmartReplaceWithPasteboard(Pasteboard*); 206 PassRefPtr<Clipboard> newGeneralClipboard(ClipboardAccessPolicy); 197 207 PassRefPtr<Range> selectedRange(); 198 208 void pasteAsPlainTextWithPasteboard(Pasteboard*); 199 209 void pasteWithPasteboard(Pasteboard*, bool allowPlainText); 200 void replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle);201 void replaceSelectionWithText( String text, bool selectReplacement, bool smartReplace);210 void replaceSelectionWithFragment(PassRefPtr<DocumentFragment>, bool selectReplacement, bool smartReplace, bool matchStyle); 211 void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace); 202 212 void writeSelectionToPasteboard(Pasteboard*); 203 213 -
trunk/WebCore/editing/mac/EditorMac.mm
r19049 r19579 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 #import "Element.h" 35 35 #import "ExceptionHandlers.h" 36 #import "FrameMac.h" 36 37 #import "PlatformString.h" 37 38 #import "Selection.h" … … 646 647 } 647 648 649 void Editor::unmarkText() 650 { 651 Mac(m_frame)->setMarkedTextRange(0, nil, nil); 652 } 653 648 654 } // namespace WebCore -
trunk/WebCore/html/HTMLInputElement.cpp
r19418 r19579 1 1 /* 2 * This file is part of the DOM implementation for KDE.3 *4 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 5 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 7 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 8 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 9 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) … … 52 50 #include "SelectionController.h" 53 51 #include "TextBreakIterator.h" 52 #include "TextEvent.h" 54 53 55 54 using namespace std; … … 453 452 bool HTMLInputElement::canHaveSelection() const 454 453 { 455 switch (inputType()) { 456 case BUTTON: 457 case CHECKBOX: 458 case FILE: 459 case HIDDEN: 460 case IMAGE: 461 case RADIO: 462 case RANGE: 463 case RESET: 464 case SUBMIT: 465 return false; 466 case PASSWORD: 467 case SEARCH: 468 case ISINDEX: 469 case TEXT: 470 return true; 471 } 472 return false; 454 return isTextField(); 473 455 } 474 456 475 457 int HTMLInputElement::selectionStart() const 476 458 { 459 if (!isTextField()) 460 return 0; 461 if (document()->focusedNode() != this && cachedSelStart != -1) 462 return cachedSelStart; 477 463 if (!renderer()) 478 464 return 0; 479 480 switch (inputType()) { 481 case BUTTON: 482 case CHECKBOX: 483 case FILE: 484 case HIDDEN: 485 case IMAGE: 486 case RADIO: 487 case RANGE: 488 case RESET: 489 case SUBMIT: 490 break; 491 case ISINDEX: 492 case PASSWORD: 493 case SEARCH: 494 case TEXT: 495 if (document()->focusedNode() != this && cachedSelStart != -1) 496 return cachedSelStart; 497 return static_cast<RenderTextControl*>(renderer())->selectionStart(); 498 } 499 return 0; 465 return static_cast<RenderTextControl*>(renderer())->selectionStart(); 500 466 } 501 467 502 468 int HTMLInputElement::selectionEnd() const 503 469 { 470 if (!isTextField()) 471 return 0; 472 if (document()->focusedNode() != this && cachedSelEnd != -1) 473 return cachedSelEnd; 504 474 if (!renderer()) 505 475 return 0; 506 507 switch (inputType()) { 508 case BUTTON: 509 case CHECKBOX: 510 case FILE: 511 case HIDDEN: 512 case IMAGE: 513 case RADIO: 514 case RANGE: 515 case RESET: 516 case SUBMIT: 517 break; 518 case ISINDEX: 519 case PASSWORD: 520 case TEXT: 521 case SEARCH: 522 if (document()->focusedNode() != this && cachedSelEnd != -1) 523 return cachedSelEnd; 524 return static_cast<RenderTextControl*>(renderer())->selectionEnd(); 525 } 526 return 0; 476 return static_cast<RenderTextControl*>(renderer())->selectionEnd(); 527 477 } 528 478 529 479 void HTMLInputElement::setSelectionStart(int start) 530 480 { 481 if (!isTextField()) 482 return; 531 483 if (!renderer()) 532 484 return; 533 534 switch (inputType()) { 535 case BUTTON: 536 case CHECKBOX: 537 case FILE: 538 case HIDDEN: 539 case IMAGE: 540 case RADIO: 541 case RANGE: 542 case RESET: 543 case SUBMIT: 544 break; 545 case ISINDEX: 546 case PASSWORD: 547 case TEXT: 548 case SEARCH: 549 static_cast<RenderTextControl*>(renderer())->setSelectionStart(start); 550 break; 551 } 485 static_cast<RenderTextControl*>(renderer())->setSelectionStart(start); 552 486 } 553 487 554 488 void HTMLInputElement::setSelectionEnd(int end) 555 489 { 490 if (!isTextField()) 491 return; 556 492 if (!renderer()) 557 493 return; 558 559 switch (inputType()) { 560 case BUTTON: 561 case CHECKBOX: 562 case FILE: 563 case HIDDEN: 564 case IMAGE: 565 case RADIO: 566 case RANGE: 567 case RESET: 568 case SUBMIT: 569 break; 570 case ISINDEX: 571 case PASSWORD: 572 case TEXT: 573 case SEARCH: 574 static_cast<RenderTextControl*>(renderer())->setSelectionEnd(end); 575 break; 576 } 494 static_cast<RenderTextControl*>(renderer())->setSelectionEnd(end); 577 495 } 578 496 579 497 void HTMLInputElement::select() 580 498 { 499 if (!isTextField()) 500 return; 581 501 if (!renderer()) 582 502 return; 583 584 switch (inputType()) { 585 case BUTTON: 586 case CHECKBOX: 587 case HIDDEN: 588 case IMAGE: 589 case RADIO: 590 case RANGE: 591 case RESET: 592 case SUBMIT: 593 case FILE: 594 break; 595 case ISINDEX: 596 case PASSWORD: 597 case TEXT: 598 case SEARCH: 599 static_cast<RenderTextControl*>(renderer())->select(); 600 break; 601 } 503 static_cast<RenderTextControl*>(renderer())->select(); 602 504 } 603 505 604 506 void HTMLInputElement::setSelectionRange(int start, int end) 605 507 { 508 if (!isTextField()) 509 return; 606 510 if (!renderer()) 607 511 return; 608 609 switch (inputType()) { 610 case BUTTON: 611 case CHECKBOX: 612 case FILE: 613 case HIDDEN: 614 case IMAGE: 615 case RADIO: 616 case RANGE: 617 case RESET: 618 case SUBMIT: 619 break; 620 case ISINDEX: 621 case PASSWORD: 622 case TEXT: 623 case SEARCH: 624 static_cast<RenderTextControl*>(renderer())->setSelectionRange(start, end); 625 break; 626 } 512 static_cast<RenderTextControl*>(renderer())->setSelectionRange(start, end); 627 513 } 628 514 … … 826 712 case ISINDEX: 827 713 case PASSWORD: 714 case SEARCH: 828 715 case TEXT: 829 case SEARCH:830 716 return new (arena) RenderTextControl(this, false); 831 717 } … … 1213 1099 void HTMLInputElement::defaultEventHandler(Event* evt) 1214 1100 { 1101 bool clickDefaultFormButton = false; 1102 1103 if (isTextField() && evt->type() == textInputEvent && evt->isTextEvent() && static_cast<TextEvent*>(evt)->data() == "\n") 1104 clickDefaultFormButton = true; 1105 1215 1106 if (inputType() == IMAGE && evt->isMouseEvent() && evt->type() == clickEvent) { 1216 1107 // record the mouse position for when we get the DOMActivate event … … 1225 1116 renderer()->absolutePosition(offsetX, offsetY); 1226 1117 xPos = me->pageX() - offsetX; 1118 // FIXME: Why is yPos a short? 1227 1119 yPos = me->pageY() - offsetY; 1228 1120 } 1121 } 1122 1123 if (!clickDefaultFormButton) { 1124 HTMLGenericFormElement::defaultEventHandler(evt); 1125 if (evt->defaultHandled()) 1126 return; 1229 1127 } 1230 1128 … … 1241 1139 else { 1242 1140 m_activeSubmit = true; 1141 // FIXME: Would be cleaner to get xPos and yPos out of the underlying mouse 1142 // event (if any) here instead of relying on the variables set above when 1143 // processing the click event. Even better, appendFormData could pass the 1144 // event in, and then we could get rid of xPos and yPos altogether! 1243 1145 if (!form()->prepareSubmit(evt)) { 1244 1146 xPos = 0; … … 1255 1157 if (evt->type() == keypressEvent && evt->isKeyboardEvent()) { 1256 1158 bool clickElement = false; 1257 bool clickDefaultFormButton = false; 1258 1159 1259 1160 if (isTextField() && document()->frame() 1260 1161 && document()->frame()->doTextFieldCommandFromEvent(this, static_cast<KeyboardEvent*>(evt))) { … … 1263 1164 } 1264 1165 1265 String key = static_cast<KeyboardEvent 1166 String key = static_cast<KeyboardEvent*>(evt)->keyIdentifier(); 1266 1167 1267 1168 if (key == "U+000020") { … … 1298 1199 case CHECKBOX: 1299 1200 case HIDDEN: 1201 case ISINDEX: 1202 case PASSWORD: 1300 1203 case RANGE: 1204 case SEARCH: 1205 case TEXT: 1301 1206 // Simulate mouse click on the default form button for enter for these types of elements. 1302 1207 clickDefaultFormButton = true; 1303 case ISINDEX:1304 case PASSWORD:1305 case SEARCH:1306 case TEXT:1307 if (!document()->frame()->eventHandler()->inputManagerHasMarkedText())1308 // Simulate mouse click on the default form button for enter for these types of elements.1309 clickDefaultFormButton = true;1310 1208 break; 1311 1209 case FILE: … … 1359 1257 dispatchSimulatedClick(evt); 1360 1258 evt->setDefaultHandled(); 1361 } else if (clickDefaultFormButton) { 1362 if (isSearchField()) { 1363 addSearchResult(); 1364 onSearch(); 1365 } 1366 blur(); 1367 // Form may never have been present, or may have been destroyed by the blur event. 1368 if (form()) 1369 form()->submitClick(evt); 1370 evt->setDefaultHandled(); 1371 } 1259 return; 1260 } 1261 } 1262 1263 if (clickDefaultFormButton) { 1264 if (isSearchField()) { 1265 addSearchResult(); 1266 onSearch(); 1267 } 1268 blur(); 1269 // Form may never have been present, or may have been destroyed by the blur event. 1270 if (form()) 1271 form()->submitClick(evt); 1272 evt->setDefaultHandled(); 1273 return; 1372 1274 } 1373 1275 … … 1399 1301 slider->forwardEvent(evt); 1400 1302 } 1401 1402 if (!evt->defaultHandled())1403 HTMLGenericFormElement::defaultEventHandler(evt);1404 1303 } 1405 1304 -
trunk/WebCore/page/EventHandler.cpp
r19500 r19579 56 56 #include "SelectionController.h" 57 57 #include "Settings.h" 58 #include "TextEvent.h" 58 59 59 60 #ifdef SVG_SUPPORT … … 1170 1171 } 1171 1172 1172 bool EventHandler::sendContextMenuEvent( PlatformMouseEventevent)1173 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event) 1173 1174 { 1174 1175 Document* doc = m_frame->document(); … … 1215 1216 return true; 1216 1217 } 1217 1218 #if !PLATFORM(MAC)1219 bool EventHandler::inputManagerHasMarkedText() const1220 {1221 return false;1222 }1223 #endif1224 1218 1225 1219 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) … … 1289 1283 { 1290 1284 if (event->type() == keypressEvent) { 1291 if (Page* page = event->target()->toNode()->document()->page())1292 if (page->tabKeyCyclesThroughElements() && event->keyIdentifier() == "U+000009")1293 if (page->focusController()->advanceFocus(event)) {1294 event->setDefaultHandled();1295 return;1296 }1297 1285 m_frame->editor()->handleKeyPress(event); 1298 } 1299 } 1300 1286 if (event->defaultHandled()) 1287 return; 1288 if (event->keyIdentifier() == "U+000009") 1289 defaultTabEventHandler(event, false); 1290 } 1291 } 1292 1301 1293 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLocation) const 1302 1294 { … … 1359 1351 } 1360 1352 1361 } 1353 bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEvent, 1354 bool isLineBreak, bool isBackTab) 1355 { 1356 if (!m_frame) 1357 return false; 1358 EventTargetNode* target = eventTargetNodeForDocument(m_frame->document()); 1359 if (!target) 1360 return false; 1361 RefPtr<TextEvent> event = new TextEvent(m_frame->domWindow(), text); 1362 event->setUnderlyingEvent(underlyingEvent); 1363 event->setIsLineBreak(isLineBreak); 1364 event->setIsBackTab(isBackTab); 1365 ExceptionCode ec; 1366 return target->dispatchEvent(event.release(), ec, true); 1367 } 1368 1369 void EventHandler::defaultTextInputEventHandler(TextEvent* event) 1370 { 1371 String data = event->data(); 1372 if (data == "\t") 1373 defaultTabEventHandler(event, event->isBackTab()); 1374 else if (data == "\n") { 1375 if (event->isLineBreak()) { 1376 if (m_frame->editor()->insertLineBreak()) 1377 event->setDefaultHandled(); 1378 } else { 1379 if (m_frame->editor()->insertParagraphSeparator()) 1380 event->setDefaultHandled(); 1381 } 1382 } else { 1383 if (m_frame->editor()->insertText(data, false, event)) 1384 event->setDefaultHandled(); 1385 } 1386 } 1387 1388 void EventHandler::defaultTabEventHandler(Event* event, bool isBackTab) 1389 { 1390 Page* page = m_frame->page(); 1391 if (!page ||! page->tabKeyCyclesThroughElements()) 1392 return; 1393 FocusController* focus = page->focusController(); 1394 KeyboardEvent* keyboardEvent = findKeyboardEvent(event); 1395 bool handled; 1396 if (isBackTab) 1397 handled = focus->advanceFocus(FocusDirectionBackward, keyboardEvent); 1398 else 1399 handled = focus->advanceFocus(keyboardEvent); // get direction from keyboard event 1400 if (handled) 1401 event->setDefaultHandled(); 1402 } 1403 1404 } -
trunk/WebCore/page/EventHandler.h
r19416 r19579 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #include "DragActions.h" 30 #include "FocusDirection.h" 30 31 #include "PlatformMouseEvent.h" 31 32 #include "ScrollTypes.h" … … 39 40 #include "WebCoreKeyboardUIMode.h" 40 41 #ifndef __OBJC__ 41 typedef unsigned NSDragOperation;42 class NSEvent; 42 43 class NSView; 43 44 #endif … … 64 65 class RenderObject; 65 66 class RenderWidget; 67 class String; 68 class TextEvent; 66 69 class VisiblePosition; 67 70 class Widget; … … 76 79 77 80 class EventHandler : Noncopyable { 81 public: 82 EventHandler(Frame*); 83 ~EventHandler(); 84 85 void clear(); 86 87 void updateSelectionForMouseDragOverPosition(const VisiblePosition&); 88 89 Node* mousePressNode() const; 90 void setMousePressNode(PassRefPtr<Node>); 91 92 void stopAutoscrollTimer(bool rendererIsBeingDestroyed = false); 93 RenderObject* autoscrollRenderer() const; 94 95 HitTestResult hitTestResultAtPoint(const IntPoint&, bool allowShadowContent); 96 97 bool mousePressed() const { return m_mousePressed; } 98 void setMousePressed(bool pressed) { m_mousePressed = pressed; } 99 100 void setCapturingMouseEventsNode(PassRefPtr<Node>); 101 102 bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*); 103 void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*); 104 bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*); 105 106 void scheduleHoverStateUpdate(); 107 108 void setResizingFrameSet(HTMLFrameSetElement*); 109 110 IntPoint currentMousePosition() const; 111 112 void setIgnoreWheelEvents(bool); 113 114 bool scrollOverflow(ScrollDirection, ScrollGranularity); 115 116 bool shouldDragAutoNode(Node*, const IntPoint&) const; // -webkit-user-drag == auto 117 118 bool tabsToLinks(KeyboardEvent*) const; 119 bool tabsToAllControls(KeyboardEvent*) const; 120 121 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; } 122 123 bool handleMousePressEvent(const PlatformMouseEvent&); 124 bool handleMouseMoveEvent(const PlatformMouseEvent&); 125 bool handleMouseReleaseEvent(const PlatformMouseEvent&); 126 bool handleWheelEvent(PlatformWheelEvent&); 127 128 bool sendContextMenuEvent(const PlatformMouseEvent&); 129 130 void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true; } 131 132 bool keyEvent(const PlatformKeyboardEvent&); 133 void defaultKeyboardEventHandler(KeyboardEvent*); 134 135 bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, 136 bool isLineBreak = false, bool isBackTab = false); 137 void defaultTextInputEventHandler(TextEvent*); 138 139 bool eventMayStartDrag(const PlatformMouseEvent&) const; 140 141 void dragSourceMovedTo(const PlatformMouseEvent&); 142 void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation); 143 144 #if PLATFORM(MAC) 145 PassRefPtr<KeyboardEvent> currentKeyboardEvent() const; 146 147 void mouseDown(NSEvent*); 148 void mouseDragged(NSEvent*); 149 void mouseUp(NSEvent*); 150 void mouseMoved(NSEvent*); 151 bool keyEvent(NSEvent*); 152 bool wheelEvent(NSEvent*); 153 154 void sendFakeEventsAfterWidgetTracking(NSEvent* initiatingEvent); 155 156 void setActivationEventNumber(int num) { m_activationEventNumber = num; } 157 158 NSEvent *currentNSEvent(); 159 #endif 160 161 private: 78 162 struct EventHandlerDragState { 79 163 RefPtr<Node> m_dragSrc; // element that may be a drag source, for the current mouse gesture … … 87 171 }; 88 172 static EventHandlerDragState& dragState(); 89 public: 90 EventHandler(Frame*); 91 ~EventHandler(); 92 93 void clear(); 94 95 void updateSelectionForMouseDragOverPosition(const VisiblePosition&); 96 97 Node* mousePressNode() const; 98 void setMousePressNode(PassRefPtr<Node>); 99 100 void stopAutoscrollTimer(bool rendererIsBeingDestroyed = false); 101 RenderObject* autoscrollRenderer() const; 102 103 HitTestResult hitTestResultAtPoint(const IntPoint&, bool allowShadowContent); 104 105 bool mousePressed() const { return m_mousePressed; } 106 void setMousePressed(bool pressed) { m_mousePressed = pressed; } 107 108 void setCapturingMouseEventsNode(PassRefPtr<Node>); 109 110 bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*); 111 void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*); 112 bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*); 113 114 void scheduleHoverStateUpdate(); 115 116 void setResizingFrameSet(HTMLFrameSetElement*); 117 118 IntPoint currentMousePosition() const; 119 120 void setIgnoreWheelEvents(bool); 121 122 bool scrollOverflow(ScrollDirection, ScrollGranularity); 123 124 bool shouldDragAutoNode(Node*, const IntPoint&) const; // -webkit-user-drag == auto 125 126 bool tabsToLinks(KeyboardEvent*) const; 127 bool tabsToAllControls(KeyboardEvent*) const; 128 129 bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; } 130 bool inputManagerHasMarkedText() const; 131 132 bool handleMousePressEvent(const PlatformMouseEvent&); 133 bool handleMouseMoveEvent(const PlatformMouseEvent&); 134 bool handleMouseReleaseEvent(const PlatformMouseEvent&); 135 bool handleWheelEvent(PlatformWheelEvent&); 136 137 bool sendContextMenuEvent(PlatformMouseEvent); 138 139 void setMouseDownMayStartAutoscroll() { m_mouseDownMayStartAutoscroll = true; } 140 141 bool keyEvent(const PlatformKeyboardEvent&); 142 143 void defaultKeyboardEventHandler(KeyboardEvent*); 144 145 bool eventMayStartDrag(const PlatformMouseEvent&) const; 146 147 void dragSourceMovedTo(const PlatformMouseEvent&); 148 void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation); 149 150 //The following methods are needed to allow correct event modelling on Mac 151 //they are called at the beginning of handleMouseUp and handleDrag. 152 //If they return true it indicates that they have consumed the event 153 #if PLATFORM(MAC) 154 bool eventLoopHandleMouseUp(const MouseEventWithHitTestResults&); 155 bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&); 156 #else 157 bool eventLoopHandleMouseUp(const MouseEventWithHitTestResults&) { return false; } 158 bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&) { return false; } 159 #endif 160 161 162 #if PLATFORM(MAC) 163 PassRefPtr<KeyboardEvent> currentKeyboardEvent() const; 164 165 void mouseDown(NSEvent*); 166 void mouseDragged(NSEvent*); 167 void mouseUp(NSEvent*); 168 void mouseMoved(NSEvent*); 169 bool keyEvent(NSEvent*); 170 bool wheelEvent(NSEvent*); 171 172 173 void sendFakeEventsAfterWidgetTracking(NSEvent* initiatingEvent); 174 175 void setActivationEventNumber(int num) { m_activationEventNumber = num; } 176 177 NSEvent *currentNSEvent(); 178 #endif 179 180 private: 173 181 174 bool eventActivatedView(const PlatformMouseEvent&) const; 182 175 void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults& event); … … 205 198 Node* nodeUnderMouse() const; 206 199 207 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest& hitTestRequest, const PlatformMouseEvent& mev);200 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const PlatformMouseEvent&); 208 201 209 202 bool dispatchMouseEvent(const AtomicString& eventType, Node* target, … … 238 231 bool passMouseDownEventToWidget(Widget*); 239 232 bool passWheelEventToWidget(Widget*); 240 233 234 void defaultTabEventHandler(Event*, bool isBackTab); 235 241 236 void allowDHTMLDrag(bool& flagDHTML, bool& flagUA) const; 242 237 238 // The following are called at the beginning of handleMouseUp and handleDrag. 239 // If they return true it indicates that they have consumed the event. 243 240 #if PLATFORM(MAC) 244 KeyboardUIMode keyboardUIMode() const;245 241 bool eventLoopHandleMouseUp(const MouseEventWithHitTestResults&); 242 bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&); 246 243 NSView *mouseDownViewIfStillGood(); 244 #else 245 bool eventLoopHandleMouseUp(const MouseEventWithHitTestResults&) { return false; } 247 246 #endif 248 247 -
trunk/WebCore/page/FocusController.cpp
r19207 r19579 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 #include "EventHandler.h" 36 36 #include "EventNames.h" 37 #include "FocusDirection.h"38 37 #include "Frame.h" 39 38 #include "FrameView.h" … … 109 108 } 110 109 111 112 110 bool FocusController::advanceFocus(KeyboardEvent* event) 113 111 { 114 ASSERT(event); 115 112 return advanceFocus((event && event->shiftKey()) ? FocusDirectionBackward : FocusDirectionForward, event); 113 } 114 115 bool FocusController::advanceFocus(FocusDirection direction, KeyboardEvent* event) 116 { 116 117 Frame* frame = focusedOrMainFrame(); 117 118 ASSERT(frame); … … 119 120 if (!document) 120 121 return false; 121 122 FocusDirection direction = event->shiftKey() ? FocusDirectionBackward : FocusDirectionForward;123 122 124 123 Node* node = (direction == FocusDirectionForward) -
trunk/WebCore/page/FocusController.h
r18610 r19579 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #define FocusController_h 28 28 29 #include " Shared.h"29 #include "FocusDirection.h" 30 30 #include <wtf/Forward.h> 31 31 #include <wtf/RefPtr.h> … … 35 35 class Frame; 36 36 class KeyboardEvent; 37 class Node;38 37 class Page; 39 38 … … 47 46 48 47 bool advanceFocus(KeyboardEvent*); 48 bool advanceFocus(FocusDirection, KeyboardEvent*); 49 49 50 50 private: -
trunk/WebCore/page/mac/EventHandlerMac.mm
r19396 r19579 56 56 using namespace EventNames; 57 57 58 59 58 static NSEvent *currentEvent; 60 59 … … 436 435 437 436 m_mouseDownMayStartDrag = dispatchDragSrcEvent(dragstartEvent, m_mouseDown) 438 && !m_frame->selectionController()->isInPasswordField();437 && !m_frame->selectionController()->isInPasswordField(); 439 438 440 439 // Invalidate clipboard here against anymore pasteboard writing for security. The drag … … 742 741 } 743 742 744 KeyboardUIMode EventHandler::keyboardUIMode() const745 {746 BEGIN_BLOCK_OBJC_EXCEPTIONS;747 return [Mac(m_frame)->bridge() keyboardUIMode];748 END_BLOCK_OBJC_EXCEPTIONS;749 750 return KeyboardAccessDefault;751 }752 753 bool EventHandler::inputManagerHasMarkedText() const754 {755 BEGIN_BLOCK_OBJC_EXCEPTIONS;756 return [[NSInputManager currentInputManager] hasMarkedText];757 END_BLOCK_OBJC_EXCEPTIONS758 return false;759 }760 761 743 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) 762 744 { -
trunk/WebCore/page/mac/WebCoreFrameBridge.h
r19546 r19579 223 223 - (void)decreaseSelectionListLevel; 224 224 225 - (void)insertLineBreak;226 - (void)insertParagraphSeparator;227 225 - (void)insertParagraphSeparatorInQuotedContent; 228 226 -
trunk/WebCore/page/mac/WebCoreFrameBridge.mm
r19396 r19579 1154 1154 } 1155 1155 1156 - (void)insertLineBreak1157 {1158 if (m_frame->selectionController()->isNone())1159 return;1160 1161 TypingCommand::insertLineBreak(m_frame->document());1162 m_frame->revealSelection(RenderLayer::gAlignToEdgeIfNeeded);1163 }1164 1165 - (void)insertParagraphSeparator1166 {1167 if (m_frame->selectionController()->isNone())1168 return;1169 1170 TypingCommand::insertParagraphSeparator(m_frame->document());1171 m_frame->revealSelection(RenderLayer::gAlignToEdgeIfNeeded);1172 }1173 1174 1156 - (void)insertParagraphSeparatorInQuotedContent 1175 1157 { -
trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h
r19487 r19579 310 310 311 311 #if PLATFORM(MAC) 312 virtual void markedTextAbandoned(Frame*) { } 313 312 314 // FIXME: This should become SelectionController::toWebArchive() 313 315 virtual NSData* dataForArchivedSelection(Frame*) { return 0; } -
trunk/WebKit/ChangeLog
r19568 r19579 1 2007-02-12 Darin Adler <darin@apple.com> 2 3 Reviewed by Oliver. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=12677 6 <rdar://problem/4759563> REGRESSION: Return key is always sent when you confirm 7 a clause in kotoeri (12677) 8 9 - fix http://bugs.webkit.org/show_bug.cgi?id=12596 10 <rdar://problem/4794346> REGRESSION: Tab key shifts form field focus instead of 11 navigating prediction window (12596) 12 13 - fix http://bugs.webkit.org/show_bug.cgi?id=10010 14 <rdar://problem/4822935> REGRESSION: Pressing Return with unconfirmed text in 15 Hangul inserts carriage return (10010) 16 17 - fix http://bugs.webkit.org/show_bug.cgi?id=12531 18 <rdar://problem/4975126> REGRESSION: Inline text input types repeated keys in 19 latest nightly (r19336) (12531) 20 21 - fix http://bugs.webkit.org/show_bug.cgi?id=12539 22 <rdar://problem/4975130> REGRESSION: Pressing Backspace while in inline input 23 area moves to the previous page in history (12539) 24 25 * WebCoreSupport/WebEditorClient.h: 26 * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::markedTextAbandoned): 27 Added. 28 29 * WebView/WebHTMLView.mm: 30 (-[WebHTMLView menuForEvent:]): Added explicit constructor needed now that the 31 function takes a const&. 32 (-[WebHTMLView becomeFirstResponder]): Removed fake event code, no longer needed 33 since advanceFocus now works fine with 0 for a DOM event. 34 (-[WebHTMLView _expandSelectionToGranularity:]): Changed to use the normal 35 selection controller function instead of selectRange. 36 (-[WebHTMLView insertTab:]): Changed to call bottleneck that receives the DOM 37 event. 38 (-[WebHTMLView insertBacktab:]): Ditto. 39 (-[WebHTMLView insertNewline:]): Ditto. 40 (-[WebHTMLView insertLineBreak:]): Ditto. 41 (-[WebHTMLView insertParagraphSeparator:]): Ditto. 42 (-[WebHTMLView insertNewlineIgnoringFieldEditor:]): Ditto. 43 (-[WebHTMLView insertTabIgnoringFieldEditor:]): Ditto. 44 (-[WebHTMLView yank:]): Updated to call Editor directly since the insertText 45 code now works via a text input event which is not what we want for paste-like 46 things such as yank. 47 (-[WebHTMLView yankAndSelect:]): Ditto. 48 (-[WebHTMLView selectToMark:]): Changed to use the normal selection controller 49 function instead of selectRange, which also allows us to remove the ObjC exception 50 handling code. 51 (-[WebHTMLView swapWithMark:]): Ditto. 52 (-[WebHTMLView transpose:]): Ditto. 53 (-[WebHTMLView unmarkText]): Since this is one of the calls back from the input 54 manager, added code to set the "event was handled" flag. Moved the actual work 55 into the Editor class in WebCore and just call that from here. 56 (-[WebHTMLView _selectRangeInMarkedText:]): Changed to use the normal selection 57 controller function instead of selectRange. 58 (-[WebHTMLView setMarkedText:selectedRange:]): Since this is one of the calls 59 back from the input manager, added code to set the "event was handled" flag. 60 Also changed the ignoreMarkedTextSelectionChange to use the flag over on the 61 WebCore side, since we moved it there and to call selectMarkedText over on 62 the WebCore side too. 63 (-[WebHTMLView doCommandBySelector:]): Added special cases for newline and tab 64 selectors so that the event is passed along. These selectors are special because 65 they are ones that turn into text input events. 66 (-[WebHTMLView _discardMarkedText]): Moved the body of this function into the 67 Editor class in WebCore and just call that from here. 68 (-[WebHTMLView insertText:]): Added code to send a text input event instead of 69 calling the editor to do text insertion. The insertion is then done in the 70 default handler for the text input event. 71 (-[WebHTMLView _insertNewlineWithEvent:isLineBreak:]): Added. Sends a text 72 input event. 73 (-[WebHTMLView _insertTabWithEvent:isBackTab:]): Ditto. 74 (-[WebHTMLView _updateSelectionForInputManager]): Changed to use the 75 ignoreMarkedTextSelectionChange flag in Editor now that the one here is gone. 76 77 * WebView/WebHTMLViewInternal.h: Remove ignoreMarkedTextSelectionChange field. 78 79 * WebView/WebView.mm: (-[WebView setSelectedDOMRange:affinity:]): Changed to 80 use the normal selection controller function instead of selectRange. 81 1 82 2007-02-11 Sam Weinig <sam@webkit.org> 2 83 -
trunk/WebKit/WebCoreSupport/WebEditorClient.h
r19237 r19579 85 85 virtual void handleKeyPress(WebCore::KeyboardEvent*); 86 86 87 virtual void markedTextAbandoned(WebCore::Frame*); 88 87 89 private: 88 90 void registerCommandForUndoOrRedo(PassRefPtr<WebCore::EditCommand>, bool isRedo); -
trunk/WebKit/WebCoreSupport/WebEditorClient.mm
r19313 r19579 397 397 } 398 398 399 /* 400 bool WebEditorClient::shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting) { return false; } 401 bool WebEditorClient::shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle) { return false; } 402 bool WebEditorClient::doCommandBySelector(SEL selector) { return false; } 403 404 void WebEditorClient::webViewDidBeginEditing:(NSNotification *)notification { } 405 void WebEditorClient::webViewDidChange:(NSNotification *)notification { } 406 void WebEditorClient::webViewDidEndEditing:(NSNotification *)notification { } 407 void WebEditorClient::webViewDidChangeTypingStyle:(NSNotification *)notification { } 408 void WebEditorClient::webViewDidChangeSelection:(NSNotification *)notification { } 409 NSUndoManager* WebEditorClient::undoManagerForWebView:(WebView *)webView { return NULL; } 410 */ 399 void WebEditorClient::markedTextAbandoned(Frame* frame) 400 { 401 WebHTMLView *webHTMLView = [[kit(frame) frameView] documentView]; 402 [[NSInputManager currentInputManager] markedTextAbandoned:webHTMLView]; 403 } -
trunk/WebKit/WebView/WebHTMLView.mm
r19546 r19579 86 86 #import <WebCore/Page.h> 87 87 #import <WebCore/PlatformKeyboardEvent.h> 88 #import <WebCore/PlatformMouseEvent.h> 88 89 #import <WebCore/Range.h> 89 90 #import <WebCore/SelectionController.h> … … 232 233 @interface WebHTMLView (WebNSTextInputSupport) <NSTextInput> 233 234 - (void)_updateSelectionForInputManager; 234 - (BOOL)_insertText:(NSString *)text selectInsertedText:(BOOL)selectText triggeringEvent:(KeyboardEvent*)event; 235 - (BOOL)_insertNewlineWithEvent:(KeyboardEvent*)event isLineBreak:(BOOL)isLineBreak; 236 - (BOOL)_insertTabWithEvent:(KeyboardEvent*)event isBackTab:(BOOL)isBackTab; 235 237 @end 236 238 … … 2566 2568 } 2567 2569 2568 handledEvent = coreFrame->eventHandler()->sendContextMenuEvent( event);2570 handledEvent = coreFrame->eventHandler()->sendContextMenuEvent(PlatformMouseEvent(event)); 2569 2571 _private->handlingMouseDownEvent = NO; 2570 2572 … … 3053 3055 if (Document* document = frame->document()) 3054 3056 document->setFocusedNode(0); 3055 3056 BOOL createdFakeEvent = NO; 3057 KeyboardEvent* currentEvent = frame->eventHandler()->currentKeyboardEvent().get(); 3058 if (!currentEvent) { 3059 // If we didn't get an event (for example, when using eventSender.keyDown() under DumpRenderTree), just fake a Tab keydown. 3060 currentEvent = new KeyboardEvent(EventNames::keydownEvent, true, true, 3061 frame->document() ? frame->document()->defaultView() : 0, 3062 "U+000009", KeyboardEvent::DOM_KEY_LOCATION_STANDARD, false, false, false, false, false); 3063 createdFakeEvent = YES; 3064 } 3065 3066 page->focusController()->advanceFocus(currentEvent); 3067 3068 if (createdFakeEvent) 3069 delete currentEvent; 3070 3057 page->focusController()->advanceFocus(frame->eventHandler()->currentKeyboardEvent().get()); 3071 3058 return YES; 3072 3059 } … … 3702 3689 EAffinity affinity = coreFrame->selectionController()->affinity(); 3703 3690 WebView *webView = [self _webView]; 3704 if ([[webView _editingDelegateForwarder] webView:webView shouldChangeSelectedDOMRange:[self _selectedRange] toDOMRange:domRange affinity:kit(affinity) stillSelecting:NO]) 3705 selectRange(coreFrame->selectionController(), range.get(), affinity, true); 3691 if ([[webView _editingDelegateForwarder] webView:webView shouldChangeSelectedDOMRange:[self _selectedRange] toDOMRange:domRange affinity:kit(affinity) stillSelecting:NO]) { 3692 ExceptionCode ec = 0; 3693 coreFrame->selectionController()->setSelectedRange(range.get(), affinity, true, ec); 3694 } 3706 3695 } 3707 3696 … … 4256 4245 - (void)insertTab:(id)sender 4257 4246 { 4258 [self insertText:@"\t"];4247 [self _insertTabWithEvent:0 isBackTab:NO]; 4259 4248 } 4260 4249 4261 4250 - (void)insertBacktab:(id)sender 4262 4251 { 4263 // Doing nothing matches normal NSTextView behavior. If we ever use WebView for a field-editor-type purpose 4264 // we might add code here. 4252 [self _insertTabWithEvent:0 isBackTab:YES]; 4265 4253 } 4266 4254 4267 4255 - (void)insertNewline:(id)sender 4268 4256 { 4269 if (![self _canEdit]) 4270 return; 4271 4272 // Perhaps we should make this delegate call sensitive to the real DOM operation we actually do. 4273 WebFrameBridge *bridge = [self _bridge]; 4274 if ([self _shouldReplaceSelectionWithText:@"\n" givenAction:WebViewInsertActionTyped]) { 4275 if ([self _canEditRichly]) 4276 [bridge insertParagraphSeparator]; 4277 else 4278 [bridge insertLineBreak]; 4279 } 4257 [self _insertNewlineWithEvent:0 isLineBreak:NO]; 4280 4258 } 4281 4259 4282 4260 - (void)insertLineBreak:(id)sender 4283 4261 { 4284 if (![self _canEdit]) 4285 return; 4286 4287 // Perhaps we should make this delegate call sensitive to the real DOM operation we actually do. 4288 WebFrameBridge *bridge = [self _bridge]; 4289 if ([self _shouldReplaceSelectionWithText:@"\n" givenAction:WebViewInsertActionTyped]) 4290 [bridge insertLineBreak]; 4262 [self _insertNewlineWithEvent:0 isLineBreak:YES]; 4291 4263 } 4292 4264 4293 4265 - (void)insertParagraphSeparator:(id)sender 4294 4266 { 4295 if (![self _canEdit]) 4296 return; 4297 4298 // Perhaps we should make this delegate call sensitive to the real DOM operation we actually do. 4299 WebFrameBridge *bridge = [self _bridge]; 4300 if ([self _shouldReplaceSelectionWithText:@"\n" givenAction:WebViewInsertActionTyped]) { 4301 if ([self _canEditRichly]) 4302 [bridge insertParagraphSeparator]; 4303 else 4304 [bridge insertLineBreak]; 4305 } 4267 [self _insertNewlineWithEvent:0 isLineBreak:NO]; 4306 4268 } 4307 4269 … … 4513 4475 - (void)insertNewlineIgnoringFieldEditor:(id)sender 4514 4476 { 4515 [self insertNewline:sender];4477 [self _insertNewlineWithEvent:0 isLineBreak:NO]; 4516 4478 } 4517 4479 4518 4480 - (void)insertTabIgnoringFieldEditor:(id)sender 4519 4481 { 4520 [self insertTab:sender];4482 [self _insertTabWithEvent:0 isBackTab:NO]; 4521 4483 } 4522 4484 … … 4562 4524 4563 4525 NSString* yankee = _NSYankFromKillRing(); 4564 if ([yankee length]) 4565 [self insertText:yankee]; 4566 else 4526 if ([yankee length]) { 4527 if (Frame* coreFrame = core([self _frame])) 4528 coreFrame->editor()->insertText(yankee, false); 4529 } else 4567 4530 [self deleteBackward:nil]; 4568 4531 … … 4576 4539 4577 4540 NSString* yankee = _NSYankPreviousFromKillRing(); 4578 if ([yankee length]) 4579 [self _insertText:yankee selectInsertedText:YES triggeringEvent:0]; 4580 else 4541 if ([yankee length]) { 4542 if (Frame* coreFrame = core([self _frame])) 4543 coreFrame->editor()->insertText(yankee, true); 4544 } else 4581 4545 [self deleteBackward:nil]; 4582 4546 … … 4629 4593 WebFrameBridge *bridge = [self _bridge]; 4630 4594 DOMRange *mark = [bridge markDOMRange]; 4631 if (mark == nil) {4632 NSBeep();4633 return;4634 }4635 4595 DOMRange *selection = [self _selectedRange]; 4636 4596 Frame* coreFrame = core([self _frame]); 4637 NS_DURING 4638 if (coreFrame) 4639 selectRange(coreFrame->selectionController(), core(unionDOMRanges(mark, selection)), DOWNSTREAM, true); 4640 NS_HANDLER 4597 if (!mark || !selection || !coreFrame) { 4641 4598 NSBeep(); 4642 NS_ENDHANDLER 4599 return; 4600 } 4601 ExceptionCode ec = 0; 4602 coreFrame->selectionController()->setSelectedRange(core(unionDOMRanges(mark, [self _selectedRange])), DOWNSTREAM, true, ec); 4643 4603 } 4644 4604 … … 4647 4607 WebFrameBridge *bridge = [self _bridge]; 4648 4608 DOMRange *mark = [bridge markDOMRange]; 4649 4650 if (mark == nil) {4651 NSBeep();4652 return;4653 }4654 4655 4609 DOMRange *selection = [self _selectedRange]; 4656 4610 Frame* coreFrame = core([self _frame]); 4657 NS_DURING 4658 if (coreFrame) 4659 selectRange(coreFrame->selectionController(), core(mark), DOWNSTREAM, true); 4660 NS_HANDLER 4611 if (!mark || !selection || !coreFrame) { 4661 4612 NSBeep(); 4662 4613 return; 4663 NS_ENDHANDLER 4664 [bridge setMarkDOMRange:selection]; 4614 } 4615 4616 ExceptionCode ec = 0; 4617 coreFrame->selectionController()->setSelectedRange(core(mark), DOWNSTREAM, true, ec); 4618 if (ec == 0) 4619 [bridge setMarkDOMRange:selection]; 4665 4620 } 4666 4621 … … 4684 4639 4685 4640 Frame* coreFrame = core([self _frame]); 4686 if (coreFrame) 4687 selectRange(coreFrame->selectionController(), core(r), DOWNSTREAM, true); 4641 if (!coreFrame) 4642 return; 4643 4644 ExceptionCode ec = 0; 4645 coreFrame->selectionController()->setSelectedRange(core(r), DOWNSTREAM, true, ec); 4688 4646 if ([self _shouldReplaceSelectionWithText:transposed givenAction:WebViewInsertActionTyped]) 4689 4647 [bridge replaceSelectionWithText:transposed selectReplacement:NO smartReplace:NO]; … … 5329 5287 - (void)unmarkText 5330 5288 { 5331 [[self _bridge] setMarkedTextDOMRange:nil customAttributes:nil ranges:nil]; 5332 } 5333 5334 - (void)_selectMarkedText 5335 { 5336 if ([self hasMarkedText]) { 5337 WebFrameBridge *bridge = [self _bridge]; 5338 DOMRange *markedTextRange = [bridge markedTextDOMRange]; 5339 Frame* coreFrame = core([self _frame]); 5340 if (coreFrame) 5341 selectRange(coreFrame->selectionController(), core(markedTextRange), DOWNSTREAM, false); 5342 } 5289 // Use pointer to get parameters passed to us by the caller of interpretKeyEvents. 5290 WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters; 5291 _private->interpretKeyEventsParameters = 0; 5292 5293 if (parameters) 5294 parameters->eventWasHandled = YES; 5295 5296 if (Frame* coreFrame = core([self _frame])) 5297 coreFrame->editor()->unmarkText(); 5343 5298 } 5344 5299 … … 5360 5315 5361 5316 Frame* coreFrame = core([self _frame]); 5362 if (coreFrame) 5363 selectRange(coreFrame->selectionController(), core(selectedRange), DOWNSTREAM, false); 5317 if (coreFrame) { 5318 ExceptionCode ec = 0; 5319 coreFrame->selectionController()->setSelectedRange(core(selectedRange), DOWNSTREAM, false, ec); 5320 } 5364 5321 } 5365 5322 … … 5383 5340 - (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange 5384 5341 { 5342 // Use pointer to get parameters passed to us by the caller of interpretKeyEvents. 5343 WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters; 5344 _private->interpretKeyEventsParameters = 0; 5345 5346 if (parameters) 5347 parameters->eventWasHandled = YES; 5348 5349 Frame* coreFrame = core([self _frame]); 5350 if (!coreFrame) 5351 return; 5352 5385 5353 WebFrameBridge *bridge = [self _bridge]; 5386 5354 … … 5400 5368 } 5401 5369 5402 _private->ignoreMarkedTextSelectionChange = YES;5370 coreFrame->editor()->setIgnoreMarkedTextSelectionChange(true); 5403 5371 5404 5372 // if we had marked text already, we need to make sure to replace 5405 5373 // that, instead of the selection/caret 5406 [self _selectMarkedText];5374 coreFrame->editor()->selectMarkedText(); 5407 5375 5408 5376 NSString *text = string; … … 5419 5387 [self _selectRangeInMarkedText:newSelRange]; 5420 5388 5421 _private->ignoreMarkedTextSelectionChange = NO;5389 coreFrame->editor()->setIgnoreMarkedTextSelectionChange(false); 5422 5390 } 5423 5391 … … 5431 5399 return; 5432 5400 5401 KeyboardEvent* event = parameters ? parameters->event : 0; 5402 bool eventWasHandled = true; 5403 5433 5404 WebView *webView = [self _webView]; 5434 if (![[webView _editingDelegateForwarder] webView:webView doCommandBySelector:aSelector]) 5435 [super doCommandBySelector:aSelector]; 5405 if (![[webView _editingDelegateForwarder] webView:webView doCommandBySelector:aSelector]) { 5406 if (aSelector == @selector(insertNewline:) || aSelector == @selector(insertParagraphSeparator:) || aSelector == @selector(insertNewlineIgnoringFieldEditor:)) 5407 eventWasHandled = [self _insertNewlineWithEvent:event isLineBreak:NO]; 5408 else if (aSelector == @selector(insertLineBreak:)) 5409 eventWasHandled = [self _insertNewlineWithEvent:event isLineBreak:YES]; 5410 else if (aSelector == @selector(insertTab:) || aSelector == @selector(insertTabIgnoringFieldEditor:)) 5411 eventWasHandled = [self _insertTabWithEvent:event isBackTab:NO]; 5412 else if (aSelector == @selector(insertBacktab:)) 5413 eventWasHandled = [self _insertTabWithEvent:event isBackTab:YES]; 5414 else 5415 [super doCommandBySelector:aSelector]; 5416 } 5436 5417 5437 5418 if (parameters) 5438 parameters->eventWasHandled = YES; 5439 } 5440 5441 - (void)_discardMarkedText 5442 { 5443 if (![self hasMarkedText]) 5444 return; 5445 5446 _private->ignoreMarkedTextSelectionChange = YES; 5447 5448 [self _selectMarkedText]; 5449 [self unmarkText]; 5450 [[NSInputManager currentInputManager] markedTextAbandoned:self]; 5451 // FIXME: Should we be calling the delegate here? 5452 if (Frame* coreFrame = core([self _frame])) 5453 coreFrame->editor()->deleteSelectionWithSmartDelete(false); 5454 5455 _private->ignoreMarkedTextSelectionChange = NO; 5456 } 5457 5458 - (BOOL)_insertText:(NSString *)text selectInsertedText:(BOOL)selectText triggeringEvent:(KeyboardEvent*)event 5459 { 5460 if (text == nil || [text length] == 0 || (![self _isEditable] && ![self hasMarkedText])) 5461 return NO; 5462 5463 if (![self _shouldReplaceSelectionWithText:text givenAction:WebViewInsertActionTyped]) { 5464 [self _discardMarkedText]; 5465 return NO; 5466 } 5467 5468 _private->ignoreMarkedTextSelectionChange = YES; 5469 5470 // If we had marked text, we replace that, instead of the selection/caret. 5471 [self _selectMarkedText]; 5472 5473 bool eventHandled = false; 5474 5475 if (Frame* coreFrame = core([self _frame])) 5476 eventHandled = coreFrame->editor()->insertText(text, selectText, event); 5477 5478 _private->ignoreMarkedTextSelectionChange = NO; 5479 5480 // Inserting unmarks any marked text. 5481 [self unmarkText]; 5482 5483 return eventHandled; 5419 parameters->eventWasHandled = eventWasHandled; 5484 5420 } 5485 5421 … … 5490 5426 _private->interpretKeyEventsParameters = 0; 5491 5427 5492 // We don't yetsupport inserting an attributed string but input methods don't appear to require this.5428 // We don't support inserting an attributed string but input methods don't appear to require this. 5493 5429 NSString *text; 5494 5430 if ([string isKindOfClass:[NSAttributedString class]]) … … 5496 5432 else 5497 5433 text = string; 5498 BOOL eventHandled = [self _insertText:text selectInsertedText:NO 5499 triggeringEvent:parameters ? parameters->event : 0]; 5434 5435 bool eventHandled = false; 5436 if ([text length]) { 5437 Frame* coreFrame = core([self _frame]); 5438 KeyboardEvent* event = parameters ? parameters->event : 0; 5439 String eventText = text; 5440 eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore 5441 eventHandled = coreFrame && coreFrame->eventHandler()->handleTextInputEvent(eventText, event); 5442 } 5500 5443 5501 5444 if (parameters) 5502 5445 parameters->eventWasHandled = eventHandled; 5446 } 5447 5448 - (BOOL)_insertNewlineWithEvent:(KeyboardEvent*)event isLineBreak:(BOOL)isLineBreak 5449 { 5450 Frame* coreFrame = core([self _frame]); 5451 return coreFrame && coreFrame->eventHandler()->handleTextInputEvent("\n", event, isLineBreak); 5452 } 5453 5454 - (BOOL)_insertTabWithEvent:(KeyboardEvent*)event isBackTab:(BOOL)isBackTab 5455 { 5456 Frame* coreFrame = core([self _frame]); 5457 return coreFrame && coreFrame->eventHandler()->handleTextInputEvent("\t", event, false, isBackTab); 5503 5458 } 5504 5459 … … 5528 5483 - (void)_updateSelectionForInputManager 5529 5484 { 5530 if (![self hasMarkedText] || _private->ignoreMarkedTextSelectionChange) 5485 if (![self hasMarkedText]) 5486 return; 5487 5488 Frame* coreFrame = core([self _frame]); 5489 if (!coreFrame) 5490 return; 5491 5492 if (coreFrame->editor()->ignoreMarkedTextSelectionChange()) 5531 5493 return; 5532 5494 -
trunk/WebKit/WebView/WebHTMLViewInternal.h
r19546 r19579 78 78 79 79 BOOL resigningFirstResponder; 80 BOOL ignoreMarkedTextSelectionChange;81 80 BOOL nextResponderDisabledOnce; 82 81 BOOL willBecomeFirstResponderForNodeFocus; -
trunk/WebKit/WebView/WebView.mm
r19536 r19579 2980 2980 return; 2981 2981 2982 selectRange(coreFrame->selectionController(), [range _range], core(selectionAffinity), true); 2982 ExceptionCode ec = 0; 2983 coreFrame->selectionController()->setSelectedRange([range _range], core(selectionAffinity), true, ec); 2983 2984 } 2984 2985 }
Note:
See TracChangeset
for help on using the changeset viewer.