| 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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 Event::create(EventTypeNames::webkitEditableContentChanged)); | 829 Event::create(EventTypeNames::webkitEditableContentChanged)); |
| 830 } | 830 } |
| 831 | 831 |
| 832 void Editor::appliedEditing(CompositeEditCommand* cmd) { | 832 void Editor::appliedEditing(CompositeEditCommand* cmd) { |
| 833 DCHECK(!cmd->isCommandGroupWrapper()); | 833 DCHECK(!cmd->isCommandGroupWrapper()); |
| 834 EventQueueScope scope; | 834 EventQueueScope scope; |
| 835 | 835 |
| 836 // Request spell checking before any further DOM change. | 836 // Request spell checking before any further DOM change. |
| 837 spellChecker().markMisspellingsAfterApplyingCommand(*cmd); | 837 spellChecker().markMisspellingsAfterApplyingCommand(*cmd); |
| 838 | 838 |
| 839 EditCommandComposition* composition = cmd->composition(); | 839 UndoStep* composition = cmd->composition(); |
| 840 DCHECK(composition); | 840 DCHECK(composition); |
| 841 dispatchEditableContentChangedEvents( | 841 dispatchEditableContentChangedEvents( |
| 842 composition->startingRootEditableElement(), | 842 composition->startingRootEditableElement(), |
| 843 composition->endingRootEditableElement()); | 843 composition->endingRootEditableElement()); |
| 844 // TODO(chongz): Filter empty InputType after spec is finalized. | 844 // TODO(chongz): Filter empty InputType after spec is finalized. |
| 845 dispatchInputEventEditableContentChanged( | 845 dispatchInputEventEditableContentChanged( |
| 846 composition->startingRootEditableElement(), | 846 composition->startingRootEditableElement(), |
| 847 composition->endingRootEditableElement(), cmd->inputType(), | 847 composition->endingRootEditableElement(), cmd->inputType(), |
| 848 cmd->textDataForInputEvent(), isComposingFromCommand(cmd)); | 848 cmd->textDataForInputEvent(), isComposingFromCommand(cmd)); |
| 849 | 849 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 const VisibleSelection& passedSelection) { | 887 const VisibleSelection& passedSelection) { |
| 888 if (!passedSelection.base().isConnected() || | 888 if (!passedSelection.base().isConnected() || |
| 889 !passedSelection.extent().isConnected()) | 889 !passedSelection.extent().isConnected()) |
| 890 return VisibleSelection(); | 890 return VisibleSelection(); |
| 891 DCHECK(!passedSelection.base().document()->needsLayoutTreeUpdate()); | 891 DCHECK(!passedSelection.base().document()->needsLayoutTreeUpdate()); |
| 892 VisibleSelection correctedSelection = passedSelection; | 892 VisibleSelection correctedSelection = passedSelection; |
| 893 correctedSelection.updateIfNeeded(); | 893 correctedSelection.updateIfNeeded(); |
| 894 return correctedSelection; | 894 return correctedSelection; |
| 895 } | 895 } |
| 896 | 896 |
| 897 void Editor::unappliedEditing(EditCommandComposition* cmd) { | 897 void Editor::unappliedEditing(UndoStep* cmd) { |
| 898 EventQueueScope scope; | 898 EventQueueScope scope; |
| 899 | 899 |
| 900 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), | 900 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), |
| 901 cmd->endingRootEditableElement()); | 901 cmd->endingRootEditableElement()); |
| 902 dispatchInputEventEditableContentChanged( | 902 dispatchInputEventEditableContentChanged( |
| 903 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), | 903 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), |
| 904 InputEvent::InputType::HistoryUndo, nullAtom, | 904 InputEvent::InputType::HistoryUndo, nullAtom, |
| 905 InputEvent::EventIsComposing::NotComposing); | 905 InputEvent::EventIsComposing::NotComposing); |
| 906 | 906 |
| 907 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 907 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 908 // needs to be audited. See http://crbug.com/590369 for more details. | 908 // needs to be audited. See http://crbug.com/590369 for more details. |
| 909 // In the long term, we should stop editing commands from storing | 909 // In the long term, we should stop editing commands from storing |
| 910 // VisibleSelections as starting and ending selections. | 910 // VisibleSelections as starting and ending selections. |
| 911 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 911 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 912 | 912 |
| 913 const VisibleSelection& newSelection = | 913 const VisibleSelection& newSelection = |
| 914 correctedVisibleSelection(cmd->startingSelection()); | 914 correctedVisibleSelection(cmd->startingSelection()); |
| 915 DCHECK(newSelection.isValidFor(*frame().document())) << newSelection; | 915 DCHECK(newSelection.isValidFor(*frame().document())) << newSelection; |
| 916 if (!newSelection.isNone()) { | 916 if (!newSelection.isNone()) { |
| 917 changeSelectionAfterCommand( | 917 changeSelectionAfterCommand( |
| 918 newSelection, | 918 newSelection, |
| 919 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle); | 919 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle); |
| 920 } | 920 } |
| 921 | 921 |
| 922 m_lastEditCommand = nullptr; | 922 m_lastEditCommand = nullptr; |
| 923 m_undoStack->registerRedoStep(cmd); | 923 m_undoStack->registerRedoStep(cmd); |
| 924 respondToChangedContents(newSelection); | 924 respondToChangedContents(newSelection); |
| 925 } | 925 } |
| 926 | 926 |
| 927 void Editor::reappliedEditing(EditCommandComposition* cmd) { | 927 void Editor::reappliedEditing(UndoStep* cmd) { |
| 928 EventQueueScope scope; | 928 EventQueueScope scope; |
| 929 | 929 |
| 930 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), | 930 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), |
| 931 cmd->endingRootEditableElement()); | 931 cmd->endingRootEditableElement()); |
| 932 dispatchInputEventEditableContentChanged( | 932 dispatchInputEventEditableContentChanged( |
| 933 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), | 933 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), |
| 934 InputEvent::InputType::HistoryRedo, nullAtom, | 934 InputEvent::InputType::HistoryRedo, nullAtom, |
| 935 InputEvent::EventIsComposing::NotComposing); | 935 InputEvent::EventIsComposing::NotComposing); |
| 936 | 936 |
| 937 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 937 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 } | 1703 } |
| 1704 | 1704 |
| 1705 DEFINE_TRACE(Editor) { | 1705 DEFINE_TRACE(Editor) { |
| 1706 visitor->trace(m_frame); | 1706 visitor->trace(m_frame); |
| 1707 visitor->trace(m_lastEditCommand); | 1707 visitor->trace(m_lastEditCommand); |
| 1708 visitor->trace(m_undoStack); | 1708 visitor->trace(m_undoStack); |
| 1709 visitor->trace(m_mark); | 1709 visitor->trace(m_mark); |
| 1710 } | 1710 } |
| 1711 | 1711 |
| 1712 } // namespace blink | 1712 } // namespace blink |
| OLD | NEW |