| 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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 startRoot->dispatchEvent( | 789 startRoot->dispatchEvent( |
| 790 Event::create(EventTypeNames::webkitEditableContentChanged)); | 790 Event::create(EventTypeNames::webkitEditableContentChanged)); |
| 791 if (endRoot && endRoot != startRoot) | 791 if (endRoot && endRoot != startRoot) |
| 792 endRoot->dispatchEvent( | 792 endRoot->dispatchEvent( |
| 793 Event::create(EventTypeNames::webkitEditableContentChanged)); | 793 Event::create(EventTypeNames::webkitEditableContentChanged)); |
| 794 } | 794 } |
| 795 | 795 |
| 796 void Editor::appliedEditing(CompositeEditCommand* cmd) { | 796 void Editor::appliedEditing(CompositeEditCommand* cmd) { |
| 797 DCHECK(!cmd->isCommandGroupWrapper()); | 797 DCHECK(!cmd->isCommandGroupWrapper()); |
| 798 EventQueueScope scope; | 798 EventQueueScope scope; |
| 799 frame().document()->updateStyleAndLayout(); | |
| 800 | 799 |
| 801 // Request spell checking before any further DOM change. | 800 // Request spell checking before any further DOM change. |
| 802 spellChecker().markMisspellingsAfterApplyingCommand(*cmd); | 801 spellChecker().markMisspellingsAfterApplyingCommand(*cmd); |
| 803 | 802 |
| 804 EditCommandComposition* composition = cmd->composition(); | 803 EditCommandComposition* composition = cmd->composition(); |
| 805 DCHECK(composition); | 804 DCHECK(composition); |
| 806 dispatchEditableContentChangedEvents( | 805 dispatchEditableContentChangedEvents( |
| 807 composition->startingRootEditableElement(), | 806 composition->startingRootEditableElement(), |
| 808 composition->endingRootEditableElement()); | 807 composition->endingRootEditableElement()); |
| 809 // TODO(chongz): Filter empty InputType after spec is finalized. | 808 // TODO(chongz): Filter empty InputType after spec is finalized. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 !passedSelection.extent().isConnected()) | 845 !passedSelection.extent().isConnected()) |
| 847 return VisibleSelection(); | 846 return VisibleSelection(); |
| 848 DCHECK(!passedSelection.base().document()->needsLayoutTreeUpdate()); | 847 DCHECK(!passedSelection.base().document()->needsLayoutTreeUpdate()); |
| 849 VisibleSelection correctedSelection = passedSelection; | 848 VisibleSelection correctedSelection = passedSelection; |
| 850 correctedSelection.updateIfNeeded(); | 849 correctedSelection.updateIfNeeded(); |
| 851 return correctedSelection; | 850 return correctedSelection; |
| 852 } | 851 } |
| 853 | 852 |
| 854 void Editor::unappliedEditing(EditCommandComposition* cmd) { | 853 void Editor::unappliedEditing(EditCommandComposition* cmd) { |
| 855 EventQueueScope scope; | 854 EventQueueScope scope; |
| 856 frame().document()->updateStyleAndLayout(); | |
| 857 | 855 |
| 858 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), | 856 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), |
| 859 cmd->endingRootEditableElement()); | 857 cmd->endingRootEditableElement()); |
| 860 dispatchInputEventEditableContentChanged( | 858 dispatchInputEventEditableContentChanged( |
| 861 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), | 859 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), |
| 862 InputEvent::InputType::Undo, nullAtom, | 860 InputEvent::InputType::Undo, nullAtom, |
| 863 InputEvent::EventIsComposing::NotComposing); | 861 InputEvent::EventIsComposing::NotComposing); |
| 864 | 862 |
| 865 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 863 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 866 // needs to be audited. See http://crbug.com/590369 for more details. | 864 // needs to be audited. See http://crbug.com/590369 for more details. |
| 867 // In the long term, we should stop editing commands from storing | 865 // In the long term, we should stop editing commands from storing |
| 868 // VisibleSelections as starting and ending selections. | 866 // VisibleSelections as starting and ending selections. |
| 869 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 867 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 870 | 868 |
| 871 VisibleSelection newSelection = | 869 VisibleSelection newSelection = |
| 872 correctedVisibleSelection(cmd->startingSelection()); | 870 correctedVisibleSelection(cmd->startingSelection()); |
| 873 if (newSelection.start().document() == frame().document() && | 871 if (newSelection.start().document() == frame().document() && |
| 874 newSelection.end().document() == frame().document()) | 872 newSelection.end().document() == frame().document()) |
| 875 changeSelectionAfterCommand( | 873 changeSelectionAfterCommand( |
| 876 newSelection, | 874 newSelection, |
| 877 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle); | 875 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle); |
| 878 | 876 |
| 879 m_lastEditCommand = nullptr; | 877 m_lastEditCommand = nullptr; |
| 880 m_undoStack->registerRedoStep(cmd); | 878 m_undoStack->registerRedoStep(cmd); |
| 881 respondToChangedContents(newSelection); | 879 respondToChangedContents(newSelection); |
| 882 } | 880 } |
| 883 | 881 |
| 884 void Editor::reappliedEditing(EditCommandComposition* cmd) { | 882 void Editor::reappliedEditing(EditCommandComposition* cmd) { |
| 885 EventQueueScope scope; | 883 EventQueueScope scope; |
| 886 frame().document()->updateStyleAndLayout(); | |
| 887 | 884 |
| 888 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), | 885 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), |
| 889 cmd->endingRootEditableElement()); | 886 cmd->endingRootEditableElement()); |
| 890 dispatchInputEventEditableContentChanged( | 887 dispatchInputEventEditableContentChanged( |
| 891 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), | 888 cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), |
| 892 InputEvent::InputType::Redo, nullAtom, | 889 InputEvent::InputType::Redo, nullAtom, |
| 893 InputEvent::EventIsComposing::NotComposing); | 890 InputEvent::EventIsComposing::NotComposing); |
| 894 | 891 |
| 895 // TODO(yosin): Since |dispatchEditableContentChangedEvents()| and | 892 // TODO(yosin): Since |dispatchEditableContentChangedEvents()| and |
| 896 // |dispatchInputEventEditableContentChanged()|, we would like to know | 893 // |dispatchInputEventEditableContentChanged()|, we would like to know |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 } | 1641 } |
| 1645 | 1642 |
| 1646 DEFINE_TRACE(Editor) { | 1643 DEFINE_TRACE(Editor) { |
| 1647 visitor->trace(m_frame); | 1644 visitor->trace(m_frame); |
| 1648 visitor->trace(m_lastEditCommand); | 1645 visitor->trace(m_lastEditCommand); |
| 1649 visitor->trace(m_undoStack); | 1646 visitor->trace(m_undoStack); |
| 1650 visitor->trace(m_mark); | 1647 visitor->trace(m_mark); |
| 1651 } | 1648 } |
| 1652 | 1649 |
| 1653 } // namespace blink | 1650 } // namespace blink |
| OLD | NEW |