Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 m_editor->frame().selection().revealSelection( | 149 m_editor->frame().selection().revealSelection( |
| 150 ScrollAlignment::alignToEdgeIfNeeded, RevealExtent); | 150 ScrollAlignment::alignToEdgeIfNeeded, RevealExtent); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 // When an event handler has moved the selection outside of a text control | 154 // When an event handler has moved the selection outside of a text control |
| 155 // we should use the target control's selection for this editing operation. | 155 // we should use the target control's selection for this editing operation. |
| 156 // TODO(yosin): We should make |Editor::selectionForCommand()| to return | 156 // TODO(yosin): We should make |Editor::selectionForCommand()| to return |
| 157 // |SelectionInDOMTree| instead of |VisibleSelection|. | 157 // |SelectionInDOMTree| instead of |VisibleSelection|. |
| 158 VisibleSelection Editor::selectionForCommand(Event* event) { | 158 VisibleSelection Editor::selectionForCommand(Event* event) { |
| 159 frame().selection().updateIfNeeded(); | |
|
Xiaocheng
2017/02/24 18:06:06
Is this a mis-removal?
yosin_UTC9
2017/02/25 01:02:03
Yes, good catch!
This is over removal. I should mo
| |
| 160 VisibleSelection selection = | 159 VisibleSelection selection = |
| 161 frame().selection().computeVisibleSelectionInDOMTreeDeprecated(); | 160 frame().selection().computeVisibleSelectionInDOMTreeDeprecated(); |
| 162 if (!event) | 161 if (!event) |
| 163 return selection; | 162 return selection; |
| 164 // If the target is a text control, and the current selection is outside of | 163 // If the target is a text control, and the current selection is outside of |
| 165 // its shadow tree, then use the saved selection for that text control. | 164 // its shadow tree, then use the saved selection for that text control. |
| 166 TextControlElement* textControlOfSelectionStart = | 165 TextControlElement* textControlOfSelectionStart = |
| 167 enclosingTextControl(selection.start()); | 166 enclosingTextControl(selection.start()); |
| 168 TextControlElement* textControlOfTarget = | 167 TextControlElement* textControlOfTarget = |
| 169 isTextControlElement(*event->target()->toNode()) | 168 isTextControlElement(*event->target()->toNode()) |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 | 918 |
| 920 respondToChangedContents(newSelection); | 919 respondToChangedContents(newSelection); |
| 921 } | 920 } |
| 922 | 921 |
| 923 static VisibleSelection correctedVisibleSelection( | 922 static VisibleSelection correctedVisibleSelection( |
| 924 const VisibleSelection& passedSelection) { | 923 const VisibleSelection& passedSelection) { |
| 925 if (!passedSelection.base().isConnected() || | 924 if (!passedSelection.base().isConnected() || |
| 926 !passedSelection.extent().isConnected()) | 925 !passedSelection.extent().isConnected()) |
| 927 return VisibleSelection(); | 926 return VisibleSelection(); |
| 928 DCHECK(!passedSelection.base().document()->needsLayoutTreeUpdate()); | 927 DCHECK(!passedSelection.base().document()->needsLayoutTreeUpdate()); |
| 929 VisibleSelection correctedSelection = passedSelection; | 928 return createVisibleSelection(passedSelection.asSelection()); |
| 930 correctedSelection.updateIfNeeded(); | |
| 931 return correctedSelection; | |
| 932 } | 929 } |
| 933 | 930 |
| 934 void Editor::unappliedEditing(UndoStep* cmd) { | 931 void Editor::unappliedEditing(UndoStep* cmd) { |
| 935 EventQueueScope scope; | 932 EventQueueScope scope; |
| 936 | 933 |
| 937 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), | 934 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), |
| 938 cmd->endingRootEditableElement()); | 935 cmd->endingRootEditableElement()); |
| 939 dispatchInputEventEditableContentChanged( | 936 dispatchInputEventEditableContentChanged( |
| 940 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), | 937 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), |
| 941 InputEvent::InputType::HistoryUndo, nullAtom, | 938 InputEvent::InputType::HistoryUndo, nullAtom, |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1766 | 1763 |
| 1767 DEFINE_TRACE(Editor) { | 1764 DEFINE_TRACE(Editor) { |
| 1768 visitor->trace(m_frame); | 1765 visitor->trace(m_frame); |
| 1769 visitor->trace(m_lastEditCommand); | 1766 visitor->trace(m_lastEditCommand); |
| 1770 visitor->trace(m_undoStack); | 1767 visitor->trace(m_undoStack); |
| 1771 visitor->trace(m_mark); | 1768 visitor->trace(m_mark); |
| 1772 visitor->trace(m_typingStyle); | 1769 visitor->trace(m_typingStyle); |
| 1773 } | 1770 } |
| 1774 | 1771 |
| 1775 } // namespace blink | 1772 } // namespace blink |
| OLD | NEW |