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

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

Issue 2326593003: Audit the use of UpdateStyleAndLayoutIgnorePendingStylesheets in FrameSelection::revealSelection (Closed)
Patch Set: Created 4 years, 3 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
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 Editor::RevealSelectionScope::RevealSelectionScope(Editor* editor) 130 Editor::RevealSelectionScope::RevealSelectionScope(Editor* editor)
131 : m_editor(editor) 131 : m_editor(editor)
132 { 132 {
133 ++m_editor->m_preventRevealSelection; 133 ++m_editor->m_preventRevealSelection;
134 } 134 }
135 135
136 Editor::RevealSelectionScope::~RevealSelectionScope() 136 Editor::RevealSelectionScope::~RevealSelectionScope()
137 { 137 {
138 DCHECK(m_editor->m_preventRevealSelection); 138 DCHECK(m_editor->m_preventRevealSelection);
139 --m_editor->m_preventRevealSelection; 139 --m_editor->m_preventRevealSelection;
140 if (!m_editor->m_preventRevealSelection) 140 if (!m_editor->m_preventRevealSelection) {
141 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesh eets
142 // needs to be audited. See http://crbug.com/590369 for more details.
143 m_editor->frame().document()->updateStyleAndLayoutIgnorePendingStyleshee ts();
144
141 m_editor->frame().selection().revealSelection(ScrollAlignment::alignToEd geIfNeeded, RevealExtent); 145 m_editor->frame().selection().revealSelection(ScrollAlignment::alignToEd geIfNeeded, RevealExtent);
146 }
142 } 147 }
143 148
144 // When an event handler has moved the selection outside of a text control 149 // When an event handler has moved the selection outside of a text control
145 // we should use the target control's selection for this editing operation. 150 // we should use the target control's selection for this editing operation.
146 VisibleSelection Editor::selectionForCommand(Event* event) 151 VisibleSelection Editor::selectionForCommand(Event* event)
147 { 152 {
148 frame().selection().updateIfNeeded(); 153 frame().selection().updateIfNeeded();
149 VisibleSelection selection = frame().selection().selection(); 154 VisibleSelection selection = frame().selection().selection();
150 if (!event) 155 if (!event)
151 return selection; 156 return selection;
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 825
821 spellChecker().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[ 0])); 826 spellChecker().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[ 0]));
822 827
823 // Insert the text 828 // Insert the text
824 TypingCommand::insertText(*selection.start().document(), text, selection, 829 TypingCommand::insertText(*selection.start().document(), text, selection,
825 selectInsertedText ? TypingCommand::SelectInsertedText : 0, 830 selectInsertedText ? TypingCommand::SelectInsertedText : 0,
826 triggeringEvent && triggeringEvent->isComposition() ? TypingCommand::Tex tCompositionConfirm : TypingCommand::TextCompositionNone); 831 triggeringEvent && triggeringEvent->isComposition() ? TypingCommand::Tex tCompositionConfirm : TypingCommand::TextCompositionNone);
827 832
828 // Reveal the current selection 833 // Reveal the current selection
829 if (LocalFrame* editedFrame = selection.start().document()->frame()) { 834 if (LocalFrame* editedFrame = selection.start().document()->frame()) {
830 if (Page* page = editedFrame->page()) 835 if (Page* page = editedFrame->page()) {
831 toLocalFrame(page->focusController().focusedOrMainFrame())->selectio n().revealSelection(ScrollAlignment::alignCenterIfNeeded); 836 LocalFrame* focusedOrMainFrame = toLocalFrame(page->focusController( ).focusedOrMainFrame());
837
838 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingSty lesheets
839 // needs to be audited. See http://crbug.com/590369 for more detail s.
840 focusedOrMainFrame->document()->updateStyleAndLayoutIgnorePendingSty lesheets();
841
842 focusedOrMainFrame->selection().revealSelection(ScrollAlignment::ali gnCenterIfNeeded);
843 }
832 } 844 }
833 845
834 return true; 846 return true;
835 } 847 }
836 848
837 bool Editor::insertLineBreak() 849 bool Editor::insertLineBreak()
838 { 850 {
839 if (!canEdit()) 851 if (!canEdit())
840 return false; 852 return false;
841 853
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 MutableStylePropertySet* style = MutableStylePropertySet::create(HTMLQuirksM ode); 1087 MutableStylePropertySet* style = MutableStylePropertySet::create(HTMLQuirksM ode);
1076 style->setProperty(CSSPropertyDirection, direction == LeftToRightWritingDire ction ? "ltr" : direction == RightToLeftWritingDirection ? "rtl" : "inherit", fa lse); 1088 style->setProperty(CSSPropertyDirection, direction == LeftToRightWritingDire ction ? "ltr" : direction == RightToLeftWritingDirection ? "rtl" : "inherit", fa lse);
1077 applyParagraphStyleToSelection(style, InputEvent::InputType::SetWritingDirec tion); 1089 applyParagraphStyleToSelection(style, InputEvent::InputType::SetWritingDirec tion);
1078 } 1090 }
1079 1091
1080 void Editor::revealSelectionAfterEditingOperation(const ScrollAlignment& alignme nt, RevealExtentOption revealExtentOption) 1092 void Editor::revealSelectionAfterEditingOperation(const ScrollAlignment& alignme nt, RevealExtentOption revealExtentOption)
1081 { 1093 {
1082 if (m_preventRevealSelection) 1094 if (m_preventRevealSelection)
1083 return; 1095 return;
1084 1096
1097 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1098 // needs to be audited. See http://crbug.com/590369 for more details.
1099 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
1100
1085 frame().selection().revealSelection(alignment, revealExtentOption); 1101 frame().selection().revealSelection(alignment, revealExtentOption);
1086 } 1102 }
1087 1103
1088 void Editor::transpose() 1104 void Editor::transpose()
1089 { 1105 {
1090 if (!canEdit()) 1106 if (!canEdit())
1091 return; 1107 return;
1092 1108
1093 VisibleSelection selection = frame().selection().selection(); 1109 VisibleSelection selection = frame().selection().selection();
1094 if (!selection.isCaret()) 1110 if (!selection.isCaret())
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 1429
1414 DEFINE_TRACE(Editor) 1430 DEFINE_TRACE(Editor)
1415 { 1431 {
1416 visitor->trace(m_frame); 1432 visitor->trace(m_frame);
1417 visitor->trace(m_lastEditCommand); 1433 visitor->trace(m_lastEditCommand);
1418 visitor->trace(m_undoStack); 1434 visitor->trace(m_undoStack);
1419 visitor->trace(m_mark); 1435 visitor->trace(m_mark);
1420 } 1436 }
1421 1437
1422 } // namespace blink 1438 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.cpp ('k') | third_party/WebKit/Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698