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

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

Issue 2419383007: Remove layout updates from Editor::{applied,unapplied,reapplied}Editing (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp » ('j') | 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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698