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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 static void DispatchEditableContentChangedEvents(Element* start_root, | 910 static void DispatchEditableContentChangedEvents(Element* start_root, |
| 911 Element* end_root) { | 911 Element* end_root) { |
| 912 if (start_root) | 912 if (start_root) |
| 913 start_root->DispatchEvent( | 913 start_root->DispatchEvent( |
| 914 Event::Create(EventTypeNames::webkitEditableContentChanged)); | 914 Event::Create(EventTypeNames::webkitEditableContentChanged)); |
| 915 if (end_root && end_root != start_root) | 915 if (end_root && end_root != start_root) |
| 916 end_root->DispatchEvent( | 916 end_root->DispatchEvent( |
| 917 Event::Create(EventTypeNames::webkitEditableContentChanged)); | 917 Event::Create(EventTypeNames::webkitEditableContentChanged)); |
| 918 } | 918 } |
| 919 | 919 |
| 920 static SelectionInDOMTree CorrectedSelectionAfterCommand( | 920 static SelectionInDOMTree CorrectedSelectionAfterCommand( |
|
yosin_UTC9
2017/05/23 01:46:36
Is it better to pass FrameSelection instead of Doc
| |
| 921 const VisibleSelection& passed_selection, | 921 const VisibleSelection& passed_selection, |
| 922 Document* document) { | 922 Document* document, |
| 923 bool is_handle_visible) { | |
|
yosin_UTC9
2017/05/23 01:46:36
We should use |HandleVisibility|.
| |
| 923 if (!passed_selection.Base().IsConnected() || | 924 if (!passed_selection.Base().IsConnected() || |
| 924 !passed_selection.Extent().IsConnected() || | 925 !passed_selection.Extent().IsConnected() || |
| 925 passed_selection.Base().GetDocument() != document || | 926 passed_selection.Base().GetDocument() != document || |
| 926 passed_selection.Base().GetDocument() != | 927 passed_selection.Base().GetDocument() != |
| 927 passed_selection.Extent().GetDocument()) | 928 passed_selection.Extent().GetDocument()) |
| 928 return SelectionInDOMTree(); | 929 return SelectionInDOMTree(); |
| 929 return passed_selection.AsSelection(); | 930 return passed_selection.AsSelection(is_handle_visible); |
|
yosin_UTC9
2017/05/23 01:46:36
Please use SelectionInDOMTree::Builder as
return
| |
| 930 } | 931 } |
| 931 | 932 |
| 932 void Editor::AppliedEditing(CompositeEditCommand* cmd) { | 933 void Editor::AppliedEditing(CompositeEditCommand* cmd) { |
| 933 DCHECK(!cmd->IsCommandGroupWrapper()); | 934 DCHECK(!cmd->IsCommandGroupWrapper()); |
| 934 EventQueueScope scope; | 935 EventQueueScope scope; |
| 935 | 936 |
| 936 // Request spell checking before any further DOM change. | 937 // Request spell checking before any further DOM change. |
| 937 GetSpellChecker().MarkMisspellingsAfterApplyingCommand(*cmd); | 938 GetSpellChecker().MarkMisspellingsAfterApplyingCommand(*cmd); |
| 938 | 939 |
| 939 UndoStep* undo_step = cmd->GetUndoStep(); | 940 UndoStep* undo_step = cmd->GetUndoStep(); |
| 940 DCHECK(undo_step); | 941 DCHECK(undo_step); |
| 941 DispatchEditableContentChangedEvents(undo_step->StartingRootEditableElement(), | 942 DispatchEditableContentChangedEvents(undo_step->StartingRootEditableElement(), |
| 942 undo_step->EndingRootEditableElement()); | 943 undo_step->EndingRootEditableElement()); |
| 943 // TODO(chongz): Filter empty InputType after spec is finalized. | 944 // TODO(chongz): Filter empty InputType after spec is finalized. |
| 944 DispatchInputEventEditableContentChanged( | 945 DispatchInputEventEditableContentChanged( |
| 945 undo_step->StartingRootEditableElement(), | 946 undo_step->StartingRootEditableElement(), |
| 946 undo_step->EndingRootEditableElement(), cmd->GetInputType(), | 947 undo_step->EndingRootEditableElement(), cmd->GetInputType(), |
| 947 cmd->TextDataForInputEvent(), IsComposingFromCommand(cmd)); | 948 cmd->TextDataForInputEvent(), IsComposingFromCommand(cmd)); |
| 948 | 949 |
| 949 const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand( | 950 const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand( |
| 950 cmd->EndingSelection(), GetFrame().GetDocument()); | 951 cmd->EndingSelection(), GetFrame().GetDocument(), |
| 952 GetFrame().Selection().IsHandleVisible()); | |
| 951 | 953 |
| 952 // Don't clear the typing style with this selection change. We do those things | 954 // Don't clear the typing style with this selection change. We do those things |
| 953 // elsewhere if necessary. | 955 // elsewhere if necessary. |
| 954 ChangeSelectionAfterCommand(new_selection, 0); | 956 ChangeSelectionAfterCommand(new_selection, 0); |
| 955 | 957 |
| 956 if (!cmd->PreservesTypingStyle()) | 958 if (!cmd->PreservesTypingStyle()) |
| 957 ClearTypingStyle(); | 959 ClearTypingStyle(); |
| 958 | 960 |
| 959 // Command will be equal to last edit command only in the case of typing | 961 // Command will be equal to last edit command only in the case of typing |
| 960 if (last_edit_command_.Get() == cmd) { | 962 if (last_edit_command_.Get() == cmd) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 982 EventQueueScope scope; | 984 EventQueueScope scope; |
| 983 | 985 |
| 984 DispatchEditableContentChangedEvents(cmd->StartingRootEditableElement(), | 986 DispatchEditableContentChangedEvents(cmd->StartingRootEditableElement(), |
| 985 cmd->EndingRootEditableElement()); | 987 cmd->EndingRootEditableElement()); |
| 986 DispatchInputEventEditableContentChanged( | 988 DispatchInputEventEditableContentChanged( |
| 987 cmd->StartingRootEditableElement(), cmd->EndingRootEditableElement(), | 989 cmd->StartingRootEditableElement(), cmd->EndingRootEditableElement(), |
| 988 InputEvent::InputType::kHistoryUndo, g_null_atom, | 990 InputEvent::InputType::kHistoryUndo, g_null_atom, |
| 989 InputEvent::EventIsComposing::kNotComposing); | 991 InputEvent::EventIsComposing::kNotComposing); |
| 990 | 992 |
| 991 const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand( | 993 const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand( |
| 992 cmd->StartingSelection(), GetFrame().GetDocument()); | 994 cmd->StartingSelection(), GetFrame().GetDocument(), |
| 995 GetFrame().Selection().IsHandleVisible()); | |
| 993 ChangeSelectionAfterCommand( | 996 ChangeSelectionAfterCommand( |
| 994 new_selection, | 997 new_selection, |
| 995 FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); | 998 FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); |
| 996 | 999 |
| 997 last_edit_command_ = nullptr; | 1000 last_edit_command_ = nullptr; |
| 998 undo_stack_->RegisterRedoStep(cmd); | 1001 undo_stack_->RegisterRedoStep(cmd); |
| 999 RespondToChangedContents(new_selection.Base()); | 1002 RespondToChangedContents(new_selection.Base()); |
| 1000 } | 1003 } |
| 1001 | 1004 |
| 1002 void Editor::ReappliedEditing(UndoStep* cmd) { | 1005 void Editor::ReappliedEditing(UndoStep* cmd) { |
| 1003 EventQueueScope scope; | 1006 EventQueueScope scope; |
| 1004 | 1007 |
| 1005 DispatchEditableContentChangedEvents(cmd->StartingRootEditableElement(), | 1008 DispatchEditableContentChangedEvents(cmd->StartingRootEditableElement(), |
| 1006 cmd->EndingRootEditableElement()); | 1009 cmd->EndingRootEditableElement()); |
| 1007 DispatchInputEventEditableContentChanged( | 1010 DispatchInputEventEditableContentChanged( |
| 1008 cmd->StartingRootEditableElement(), cmd->EndingRootEditableElement(), | 1011 cmd->StartingRootEditableElement(), cmd->EndingRootEditableElement(), |
| 1009 InputEvent::InputType::kHistoryRedo, g_null_atom, | 1012 InputEvent::InputType::kHistoryRedo, g_null_atom, |
| 1010 InputEvent::EventIsComposing::kNotComposing); | 1013 InputEvent::EventIsComposing::kNotComposing); |
| 1011 | 1014 |
| 1012 const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand( | 1015 const SelectionInDOMTree& new_selection = CorrectedSelectionAfterCommand( |
| 1013 cmd->EndingSelection(), GetFrame().GetDocument()); | 1016 cmd->EndingSelection(), GetFrame().GetDocument(), |
| 1017 GetFrame().Selection().IsHandleVisible()); | |
| 1014 ChangeSelectionAfterCommand( | 1018 ChangeSelectionAfterCommand( |
| 1015 new_selection, | 1019 new_selection, |
| 1016 FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); | 1020 FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); |
| 1017 | 1021 |
| 1018 last_edit_command_ = nullptr; | 1022 last_edit_command_ = nullptr; |
| 1019 undo_stack_->RegisterUndoStep(cmd); | 1023 undo_stack_->RegisterUndoStep(cmd); |
| 1020 RespondToChangedContents(new_selection.Base()); | 1024 RespondToChangedContents(new_selection.Base()); |
| 1021 } | 1025 } |
| 1022 | 1026 |
| 1023 Editor* Editor::Create(LocalFrame& frame) { | 1027 Editor* Editor::Create(LocalFrame& frame) { |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1818 | 1822 |
| 1819 DEFINE_TRACE(Editor) { | 1823 DEFINE_TRACE(Editor) { |
| 1820 visitor->Trace(frame_); | 1824 visitor->Trace(frame_); |
| 1821 visitor->Trace(last_edit_command_); | 1825 visitor->Trace(last_edit_command_); |
| 1822 visitor->Trace(undo_stack_); | 1826 visitor->Trace(undo_stack_); |
| 1823 visitor->Trace(mark_); | 1827 visitor->Trace(mark_); |
| 1824 visitor->Trace(typing_style_); | 1828 visitor->Trace(typing_style_); |
| 1825 } | 1829 } |
| 1826 | 1830 |
| 1827 } // namespace blink | 1831 } // namespace blink |
| OLD | NEW |