Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: WebCore/editing/Editor.cpp

Issue 4056004: Merge 69831 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/517/
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 VisibleSelection Editor::selectionForCommand(Event* event) 85 VisibleSelection Editor::selectionForCommand(Event* event)
86 { 86 {
87 VisibleSelection selection = m_frame->selection()->selection(); 87 VisibleSelection selection = m_frame->selection()->selection();
88 if (!event) 88 if (!event)
89 return selection; 89 return selection;
90 // If the target is a text control, and the current selection is outside of its shadow tree, 90 // If the target is a text control, and the current selection is outside of its shadow tree,
91 // then use the saved selection for that text control. 91 // then use the saved selection for that text control.
92 Node* target = event->target()->toNode(); 92 Node* target = event->target()->toNode();
93 Node* selectionStart = selection.start().node(); 93 Node* selectionStart = selection.start().node();
94 if (target && (!selectionStart || target->shadowAncestorNode() != selectionS tart->shadowAncestorNode())) { 94 if (target && (!selectionStart || target->shadowAncestorNode() != selectionS tart->shadowAncestorNode())) {
95 RefPtr<Range> range;
95 if (target->hasTagName(inputTag) && static_cast<HTMLInputElement*>(targe t)->isTextField()) 96 if (target->hasTagName(inputTag) && static_cast<HTMLInputElement*>(targe t)->isTextField())
96 return static_cast<HTMLInputElement*>(target)->selection(); 97 range = static_cast<HTMLInputElement*>(target)->selection();
97 if (target->hasTagName(textareaTag)) 98 else if (target->hasTagName(textareaTag))
98 return static_cast<HTMLTextAreaElement*>(target)->selection(); 99 range = static_cast<HTMLTextAreaElement*>(target)->selection();
100
101 if (range)
102 return VisibleSelection(range.get());
99 } 103 }
100 return selection; 104 return selection;
101 } 105 }
102 106
103 // Function considers Mac editing behavior a fallback when Page or Settings is n ot available. 107 // Function considers Mac editing behavior a fallback when Page or Settings is n ot available.
104 EditingBehavior Editor::behavior() const 108 EditingBehavior Editor::behavior() const
105 { 109 {
106 if (!m_frame || !m_frame->settings()) 110 if (!m_frame || !m_frame->settings())
107 return EditingBehavior(EditingMacBehavior); 111 return EditingBehavior(EditingMacBehavior);
108 112
(...skipping 2989 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 // <div contentEditable="true"><div>^Hello</div></div> 3102 // <div contentEditable="true"><div>^Hello</div></div>
3099 // WebCore inserts <div><br></div> *before* the current block, which correct ly moves the paragraph down but which doesn't 3103 // WebCore inserts <div><br></div> *before* the current block, which correct ly moves the paragraph down but which doesn't
3100 // change the caret's DOM position (["hello", 0]). In these situations the above SelectionController::setSelection call 3104 // change the caret's DOM position (["hello", 0]). In these situations the above SelectionController::setSelection call
3101 // does not call EditorClient::respondToChangedSelection(), which, on the Ma c, sends selection change notifications and 3105 // does not call EditorClient::respondToChangedSelection(), which, on the Ma c, sends selection change notifications and
3102 // starts a new kill ring sequence, but we want to do these things (matches AppKit). 3106 // starts a new kill ring sequence, but we want to do these things (matches AppKit).
3103 if (selectionDidNotChangeDOMPosition) 3107 if (selectionDidNotChangeDOMPosition)
3104 client()->respondToChangedSelection(); 3108 client()->respondToChangedSelection();
3105 } 3109 }
3106 3110
3107 } // namespace WebCore 3111 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/render-text-crash-expected.txt ('k') | WebCore/html/HTMLFormControlElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698