Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: Source/core/editing/Editor.cpp

Issue 21030005: Editor: Deffer event dispatch after selection change. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove redundant expectation file Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/editing/selection/drag-drop-restore-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "core/editing/SpellCheckRequester.h" 52 #include "core/editing/SpellCheckRequester.h"
53 #include "core/editing/TextCheckingHelper.h" 53 #include "core/editing/TextCheckingHelper.h"
54 #include "core/editing/TextIterator.h" 54 #include "core/editing/TextIterator.h"
55 #include "core/editing/TypingCommand.h" 55 #include "core/editing/TypingCommand.h"
56 #include "core/editing/VisibleUnits.h" 56 #include "core/editing/VisibleUnits.h"
57 #include "core/editing/htmlediting.h" 57 #include "core/editing/htmlediting.h"
58 #include "core/editing/markup.h" 58 #include "core/editing/markup.h"
59 #include "core/events/ClipboardEvent.h" 59 #include "core/events/ClipboardEvent.h"
60 #include "core/events/EventNames.h" 60 #include "core/events/EventNames.h"
61 #include "core/events/KeyboardEvent.h" 61 #include "core/events/KeyboardEvent.h"
62 #include "core/events/ScopedEventQueue.h"
62 #include "core/events/TextEvent.h" 63 #include "core/events/TextEvent.h"
63 #include "core/fetch/ResourceFetcher.h" 64 #include "core/fetch/ResourceFetcher.h"
64 #include "core/html/HTMLImageElement.h" 65 #include "core/html/HTMLImageElement.h"
65 #include "core/html/HTMLInputElement.h" 66 #include "core/html/HTMLInputElement.h"
66 #include "core/html/HTMLTextAreaElement.h" 67 #include "core/html/HTMLTextAreaElement.h"
67 #include "core/loader/EmptyClients.h" 68 #include "core/loader/EmptyClients.h"
68 #include "core/page/EditorClient.h" 69 #include "core/page/EditorClient.h"
69 #include "core/page/EventHandler.h" 70 #include "core/page/EventHandler.h"
70 #include "core/page/FocusController.h" 71 #include "core/page/FocusController.h"
71 #include "core/page/Frame.h" 72 #include "core/page/Frame.h"
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 static void dispatchEditableContentChangedEvents(PassRefPtr<Element> startRoot, PassRefPtr<Element> endRoot) 752 static void dispatchEditableContentChangedEvents(PassRefPtr<Element> startRoot, PassRefPtr<Element> endRoot)
752 { 753 {
753 if (startRoot) 754 if (startRoot)
754 startRoot->dispatchEvent(Event::create(eventNames().webkitEditableConten tChangedEvent), IGNORE_EXCEPTION); 755 startRoot->dispatchEvent(Event::create(eventNames().webkitEditableConten tChangedEvent), IGNORE_EXCEPTION);
755 if (endRoot && endRoot != startRoot) 756 if (endRoot && endRoot != startRoot)
756 endRoot->dispatchEvent(Event::create(eventNames().webkitEditableContentC hangedEvent), IGNORE_EXCEPTION); 757 endRoot->dispatchEvent(Event::create(eventNames().webkitEditableContentC hangedEvent), IGNORE_EXCEPTION);
757 } 758 }
758 759
759 void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd) 760 void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
760 { 761 {
762 EventQueueScope scope;
761 m_frame->document()->updateLayout(); 763 m_frame->document()->updateLayout();
762 764
763 EditCommandComposition* composition = cmd->composition(); 765 EditCommandComposition* composition = cmd->composition();
764 ASSERT(composition); 766 ASSERT(composition);
767 dispatchEditableContentChangedEvents(composition->startingRootEditableElemen t(), composition->endingRootEditableElement());
765 VisibleSelection newSelection(cmd->endingSelection()); 768 VisibleSelection newSelection(cmd->endingSelection());
766 769
767 // Don't clear the typing style with this selection change. We do those thi ngs elsewhere if necessary. 770 // Don't clear the typing style with this selection change. We do those thi ngs elsewhere if necessary.
768 changeSelectionAfterCommand(newSelection, 0); 771 changeSelectionAfterCommand(newSelection, 0);
769 dispatchEditableContentChangedEvents(composition->startingRootEditableElemen t(), composition->endingRootEditableElement());
770 772
771 if (!cmd->preservesTypingStyle()) 773 if (!cmd->preservesTypingStyle())
772 m_frame->selection().clearTypingStyle(); 774 m_frame->selection().clearTypingStyle();
773 775
774 // Command will be equal to last edit command only in the case of typing 776 // Command will be equal to last edit command only in the case of typing
775 if (m_lastEditCommand.get() == cmd) 777 if (m_lastEditCommand.get() == cmd)
776 ASSERT(cmd->isTypingCommand()); 778 ASSERT(cmd->isTypingCommand());
777 else { 779 else {
778 // Only register a new undo command if the command passed in is 780 // Only register a new undo command if the command passed in is
779 // different from the last command 781 // different from the last command
780 m_lastEditCommand = cmd; 782 m_lastEditCommand = cmd;
781 client().registerUndoStep(m_lastEditCommand->ensureComposition()); 783 client().registerUndoStep(m_lastEditCommand->ensureComposition());
782 } 784 }
783 785
784 respondToChangedContents(newSelection); 786 respondToChangedContents(newSelection);
785 } 787 }
786 788
787 void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd) 789 void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd)
788 { 790 {
791 EventQueueScope scope;
789 m_frame->document()->updateLayout(); 792 m_frame->document()->updateLayout();
790 793
794 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd ->endingRootEditableElement());
795
791 VisibleSelection newSelection(cmd->startingSelection()); 796 VisibleSelection newSelection(cmd->startingSelection());
792 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram eSelection::ClearTypingStyle); 797 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram eSelection::ClearTypingStyle);
793 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd ->endingRootEditableElement());
794 798
795 m_lastEditCommand = 0; 799 m_lastEditCommand = 0;
796 client().registerRedoStep(cmd); 800 client().registerRedoStep(cmd);
797 respondToChangedContents(newSelection); 801 respondToChangedContents(newSelection);
798 } 802 }
799 803
800 void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd) 804 void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd)
801 { 805 {
806 EventQueueScope scope;
802 m_frame->document()->updateLayout(); 807 m_frame->document()->updateLayout();
803 808
809 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd ->endingRootEditableElement());
810
804 VisibleSelection newSelection(cmd->endingSelection()); 811 VisibleSelection newSelection(cmd->endingSelection());
805 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram eSelection::ClearTypingStyle); 812 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram eSelection::ClearTypingStyle);
806 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd ->endingRootEditableElement());
807 813
808 m_lastEditCommand = 0; 814 m_lastEditCommand = 0;
809 client().registerUndoStep(cmd); 815 client().registerUndoStep(cmd);
810 respondToChangedContents(newSelection); 816 respondToChangedContents(newSelection);
811 } 817 }
812 818
813 Editor::Editor(Frame& frame) 819 Editor::Editor(Frame& frame)
814 : FrameDestructionObserver(&frame) 820 : FrameDestructionObserver(&frame)
815 , m_preventRevealSelection(0) 821 , m_preventRevealSelection(0)
816 , m_shouldStartNewKillRingSequence(false) 822 , m_shouldStartNewKillRingSequence(false)
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2201 return WebCore::unifiedTextCheckerEnabled(m_frame); 2207 return WebCore::unifiedTextCheckerEnabled(m_frame);
2202 } 2208 }
2203 2209
2204 void Editor::toggleOverwriteModeEnabled() 2210 void Editor::toggleOverwriteModeEnabled()
2205 { 2211 {
2206 m_overwriteModeEnabled = !m_overwriteModeEnabled; 2212 m_overwriteModeEnabled = !m_overwriteModeEnabled;
2207 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); 2213 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled);
2208 }; 2214 };
2209 2215
2210 } // namespace WebCore 2216 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/drag-drop-restore-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698