| 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 UndoStep* composition = cmd->composition(); | 839 UndoStep* undoStep = cmd->undoStep(); |
| 840 DCHECK(composition); | 840 DCHECK(undoStep); |
| 841 dispatchEditableContentChangedEvents( | 841 dispatchEditableContentChangedEvents(undoStep->startingRootEditableElement(), |
| 842 composition->startingRootEditableElement(), | 842 undoStep->endingRootEditableElement()); |
| 843 composition->endingRootEditableElement()); | |
| 844 // TODO(chongz): Filter empty InputType after spec is finalized. | 843 // TODO(chongz): Filter empty InputType after spec is finalized. |
| 845 dispatchInputEventEditableContentChanged( | 844 dispatchInputEventEditableContentChanged( |
| 846 composition->startingRootEditableElement(), | 845 undoStep->startingRootEditableElement(), |
| 847 composition->endingRootEditableElement(), cmd->inputType(), | 846 undoStep->endingRootEditableElement(), cmd->inputType(), |
| 848 cmd->textDataForInputEvent(), isComposingFromCommand(cmd)); | 847 cmd->textDataForInputEvent(), isComposingFromCommand(cmd)); |
| 849 | 848 |
| 850 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 849 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 851 // needs to be audited. See http://crbug.com/590369 for more details. | 850 // needs to be audited. See http://crbug.com/590369 for more details. |
| 852 // The clean layout is consumed by |mostBackwardCaretPosition|, called through | 851 // The clean layout is consumed by |mostBackwardCaretPosition|, called through |
| 853 // |changeSelectionAfterCommand|. In the long term, we should postpone visible | 852 // |changeSelectionAfterCommand|. In the long term, we should postpone visible |
| 854 // selection canonicalization so that selection update does not need layout. | 853 // selection canonicalization so that selection update does not need layout. |
| 855 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 854 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 856 | 855 |
| 857 VisibleSelection newSelection(cmd->endingSelection()); | 856 VisibleSelection newSelection(cmd->endingSelection()); |
| 858 | 857 |
| 859 // Don't clear the typing style with this selection change. We do those things | 858 // Don't clear the typing style with this selection change. We do those things |
| 860 // elsewhere if necessary. | 859 // elsewhere if necessary. |
| 861 changeSelectionAfterCommand(newSelection, 0); | 860 changeSelectionAfterCommand(newSelection, 0); |
| 862 | 861 |
| 863 if (!cmd->preservesTypingStyle()) | 862 if (!cmd->preservesTypingStyle()) |
| 864 frame().selection().clearTypingStyle(); | 863 frame().selection().clearTypingStyle(); |
| 865 | 864 |
| 866 // Command will be equal to last edit command only in the case of typing | 865 // Command will be equal to last edit command only in the case of typing |
| 867 if (m_lastEditCommand.get() == cmd) { | 866 if (m_lastEditCommand.get() == cmd) { |
| 868 DCHECK(cmd->isTypingCommand()); | 867 DCHECK(cmd->isTypingCommand()); |
| 869 } else if (m_lastEditCommand && m_lastEditCommand->isDragAndDropCommand() && | 868 } else if (m_lastEditCommand && m_lastEditCommand->isDragAndDropCommand() && |
| 870 (cmd->inputType() == InputEvent::InputType::DeleteByDrag || | 869 (cmd->inputType() == InputEvent::InputType::DeleteByDrag || |
| 871 cmd->inputType() == InputEvent::InputType::InsertFromDrop)) { | 870 cmd->inputType() == InputEvent::InputType::InsertFromDrop)) { |
| 872 // Only register undo entry when combined with other commands. | 871 // Only register undo entry when combined with other commands. |
| 873 if (!m_lastEditCommand->composition()) | 872 if (!m_lastEditCommand->undoStep()) |
| 874 m_undoStack->registerUndoStep(m_lastEditCommand->ensureComposition()); | 873 m_undoStack->registerUndoStep(m_lastEditCommand->ensureUndoStep()); |
| 875 m_lastEditCommand->appendCommandToComposite(cmd); | 874 m_lastEditCommand->appendCommandToUndoStep(cmd); |
| 876 } else { | 875 } else { |
| 877 // Only register a new undo command if the command passed in is | 876 // Only register a new undo command if the command passed in is |
| 878 // different from the last command | 877 // different from the last command |
| 879 m_lastEditCommand = cmd; | 878 m_lastEditCommand = cmd; |
| 880 m_undoStack->registerUndoStep(m_lastEditCommand->ensureComposition()); | 879 m_undoStack->registerUndoStep(m_lastEditCommand->ensureUndoStep()); |
| 881 } | 880 } |
| 882 | 881 |
| 883 respondToChangedContents(newSelection); | 882 respondToChangedContents(newSelection); |
| 884 } | 883 } |
| 885 | 884 |
| 886 static VisibleSelection correctedVisibleSelection( | 885 static VisibleSelection correctedVisibleSelection( |
| 887 const VisibleSelection& passedSelection) { | 886 const VisibleSelection& passedSelection) { |
| 888 if (!passedSelection.base().isConnected() || | 887 if (!passedSelection.base().isConnected() || |
| 889 !passedSelection.extent().isConnected()) | 888 !passedSelection.extent().isConnected()) |
| 890 return VisibleSelection(); | 889 return VisibleSelection(); |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 } | 1702 } |
| 1704 | 1703 |
| 1705 DEFINE_TRACE(Editor) { | 1704 DEFINE_TRACE(Editor) { |
| 1706 visitor->trace(m_frame); | 1705 visitor->trace(m_frame); |
| 1707 visitor->trace(m_lastEditCommand); | 1706 visitor->trace(m_lastEditCommand); |
| 1708 visitor->trace(m_undoStack); | 1707 visitor->trace(m_undoStack); |
| 1709 visitor->trace(m_mark); | 1708 visitor->trace(m_mark); |
| 1710 } | 1709 } |
| 1711 | 1710 |
| 1712 } // namespace blink | 1711 } // namespace blink |
| OLD | NEW |