| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/dom/Clipboard.h" | 35 #include "core/dom/Clipboard.h" |
| 36 #include "core/dom/ClipboardEvent.h" | 36 #include "core/dom/ClipboardEvent.h" |
| 37 #include "core/dom/CompositionEvent.h" | 37 #include "core/dom/CompositionEvent.h" |
| 38 #include "core/dom/DocumentFragment.h" | 38 #include "core/dom/DocumentFragment.h" |
| 39 #include "core/dom/DocumentMarkerController.h" | 39 #include "core/dom/DocumentMarkerController.h" |
| 40 #include "core/dom/EventNames.h" | 40 #include "core/dom/EventNames.h" |
| 41 #include "core/dom/ExceptionCodePlaceholder.h" | 41 #include "core/dom/ExceptionCodePlaceholder.h" |
| 42 #include "core/dom/KeyboardEvent.h" | 42 #include "core/dom/KeyboardEvent.h" |
| 43 #include "core/dom/NodeList.h" | 43 #include "core/dom/NodeList.h" |
| 44 #include "core/dom/NodeTraversal.h" | 44 #include "core/dom/NodeTraversal.h" |
| 45 #include "core/dom/ScopedEventQueue.h" |
| 45 #include "core/dom/Text.h" | 46 #include "core/dom/Text.h" |
| 46 #include "core/dom/TextEvent.h" | 47 #include "core/dom/TextEvent.h" |
| 47 #include "core/dom/UserTypingGestureIndicator.h" | 48 #include "core/dom/UserTypingGestureIndicator.h" |
| 48 #include "core/editing/ApplyStyleCommand.h" | 49 #include "core/editing/ApplyStyleCommand.h" |
| 49 #include "core/editing/DeleteSelectionCommand.h" | 50 #include "core/editing/DeleteSelectionCommand.h" |
| 50 #include "core/editing/IndentOutdentCommand.h" | 51 #include "core/editing/IndentOutdentCommand.h" |
| 51 #include "core/editing/InsertListCommand.h" | 52 #include "core/editing/InsertListCommand.h" |
| 52 #include "core/editing/ModifySelectionListLevel.h" | 53 #include "core/editing/ModifySelectionListLevel.h" |
| 53 #include "core/editing/RemoveFormatCommand.h" | 54 #include "core/editing/RemoveFormatCommand.h" |
| 54 #include "core/editing/RenderedPosition.h" | 55 #include "core/editing/RenderedPosition.h" |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 static void dispatchEditableContentChangedEvents(PassRefPtr<Element> startRoot,
PassRefPtr<Element> endRoot) | 710 static void dispatchEditableContentChangedEvents(PassRefPtr<Element> startRoot,
PassRefPtr<Element> endRoot) |
| 710 { | 711 { |
| 711 if (startRoot) | 712 if (startRoot) |
| 712 startRoot->dispatchEvent(Event::create(eventNames().webkitEditableConten
tChangedEvent, false, false), IGNORE_EXCEPTION); | 713 startRoot->dispatchEvent(Event::create(eventNames().webkitEditableConten
tChangedEvent, false, false), IGNORE_EXCEPTION); |
| 713 if (endRoot && endRoot != startRoot) | 714 if (endRoot && endRoot != startRoot) |
| 714 endRoot->dispatchEvent(Event::create(eventNames().webkitEditableContentC
hangedEvent, false, false), IGNORE_EXCEPTION); | 715 endRoot->dispatchEvent(Event::create(eventNames().webkitEditableContentC
hangedEvent, false, false), IGNORE_EXCEPTION); |
| 715 } | 716 } |
| 716 | 717 |
| 717 void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd) | 718 void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd) |
| 718 { | 719 { |
| 720 EventQueueScope scope; |
| 719 m_frame->document()->updateLayout(); | 721 m_frame->document()->updateLayout(); |
| 720 | 722 |
| 721 EditCommandComposition* composition = cmd->composition(); | 723 EditCommandComposition* composition = cmd->composition(); |
| 722 ASSERT(composition); | 724 ASSERT(composition); |
| 725 dispatchEditableContentChangedEvents(composition->startingRootEditableElemen
t(), composition->endingRootEditableElement()); |
| 723 VisibleSelection newSelection(cmd->endingSelection()); | 726 VisibleSelection newSelection(cmd->endingSelection()); |
| 724 | 727 |
| 725 // Don't clear the typing style with this selection change. We do those thi
ngs elsewhere if necessary. | 728 // Don't clear the typing style with this selection change. We do those thi
ngs elsewhere if necessary. |
| 726 changeSelectionAfterCommand(newSelection, 0); | 729 changeSelectionAfterCommand(newSelection, 0); |
| 727 dispatchEditableContentChangedEvents(composition->startingRootEditableElemen
t(), composition->endingRootEditableElement()); | |
| 728 | 730 |
| 729 if (!cmd->preservesTypingStyle()) | 731 if (!cmd->preservesTypingStyle()) |
| 730 m_frame->selection()->clearTypingStyle(); | 732 m_frame->selection()->clearTypingStyle(); |
| 731 | 733 |
| 732 // Command will be equal to last edit command only in the case of typing | 734 // Command will be equal to last edit command only in the case of typing |
| 733 if (m_lastEditCommand.get() == cmd) | 735 if (m_lastEditCommand.get() == cmd) |
| 734 ASSERT(cmd->isTypingCommand()); | 736 ASSERT(cmd->isTypingCommand()); |
| 735 else { | 737 else { |
| 736 // Only register a new undo command if the command passed in is | 738 // Only register a new undo command if the command passed in is |
| 737 // different from the last command | 739 // different from the last command |
| 738 m_lastEditCommand = cmd; | 740 m_lastEditCommand = cmd; |
| 739 if (client()) | 741 if (client()) |
| 740 client()->registerUndoStep(m_lastEditCommand->ensureComposition()); | 742 client()->registerUndoStep(m_lastEditCommand->ensureComposition()); |
| 741 } | 743 } |
| 742 | 744 |
| 743 respondToChangedContents(newSelection); | 745 respondToChangedContents(newSelection); |
| 744 } | 746 } |
| 745 | 747 |
| 746 void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd) | 748 void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd) |
| 747 { | 749 { |
| 750 EventQueueScope scope; |
| 748 m_frame->document()->updateLayout(); | 751 m_frame->document()->updateLayout(); |
| 749 | 752 |
| 753 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd
->endingRootEditableElement()); |
| 754 |
| 750 VisibleSelection newSelection(cmd->startingSelection()); | 755 VisibleSelection newSelection(cmd->startingSelection()); |
| 751 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram
eSelection::ClearTypingStyle); | 756 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram
eSelection::ClearTypingStyle); |
| 752 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd
->endingRootEditableElement()); | |
| 753 | 757 |
| 754 m_lastEditCommand = 0; | 758 m_lastEditCommand = 0; |
| 755 if (client()) | 759 if (client()) |
| 756 client()->registerRedoStep(cmd); | 760 client()->registerRedoStep(cmd); |
| 757 respondToChangedContents(newSelection); | 761 respondToChangedContents(newSelection); |
| 758 } | 762 } |
| 759 | 763 |
| 760 void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd) | 764 void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd) |
| 761 { | 765 { |
| 766 EventQueueScope scope; |
| 762 m_frame->document()->updateLayout(); | 767 m_frame->document()->updateLayout(); |
| 763 | 768 |
| 769 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd
->endingRootEditableElement()); |
| 770 |
| 764 VisibleSelection newSelection(cmd->endingSelection()); | 771 VisibleSelection newSelection(cmd->endingSelection()); |
| 765 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram
eSelection::ClearTypingStyle); | 772 changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | Fram
eSelection::ClearTypingStyle); |
| 766 dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd
->endingRootEditableElement()); | |
| 767 | 773 |
| 768 m_lastEditCommand = 0; | 774 m_lastEditCommand = 0; |
| 769 if (client()) | 775 if (client()) |
| 770 client()->registerUndoStep(cmd); | 776 client()->registerUndoStep(cmd); |
| 771 respondToChangedContents(newSelection); | 777 respondToChangedContents(newSelection); |
| 772 } | 778 } |
| 773 | 779 |
| 774 Editor::Editor(Frame* frame) | 780 Editor::Editor(Frame* frame) |
| 775 : FrameDestructionObserver(frame) | 781 : FrameDestructionObserver(frame) |
| 776 , m_ignoreCompositionSelectionChange(false) | 782 , m_ignoreCompositionSelectionChange(false) |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2340 return WebCore::unifiedTextCheckerEnabled(m_frame); | 2346 return WebCore::unifiedTextCheckerEnabled(m_frame); |
| 2341 } | 2347 } |
| 2342 | 2348 |
| 2343 void Editor::toggleOverwriteModeEnabled() | 2349 void Editor::toggleOverwriteModeEnabled() |
| 2344 { | 2350 { |
| 2345 m_overwriteModeEnabled = !m_overwriteModeEnabled; | 2351 m_overwriteModeEnabled = !m_overwriteModeEnabled; |
| 2346 frame()->selection()->setShouldShowBlockCursor(m_overwriteModeEnabled); | 2352 frame()->selection()->setShouldShowBlockCursor(m_overwriteModeEnabled); |
| 2347 }; | 2353 }; |
| 2348 | 2354 |
| 2349 } // namespace WebCore | 2355 } // namespace WebCore |
| OLD | NEW |