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

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

Issue 2702403004: Expand FrameSeleciton::start() to increase chances of hoisting update layout (Closed)
Patch Set: 2017-02-22T12:32:36 Created 3 years, 10 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (Page* page = frame().page()) 201 if (Page* page = frame().page())
202 return page->editorClient(); 202 return page->editorClient();
203 return emptyEditorClient(); 203 return emptyEditorClient();
204 } 204 }
205 205
206 static bool isCaretAtStartOfWrappedLine(const FrameSelection& selection) { 206 static bool isCaretAtStartOfWrappedLine(const FrameSelection& selection) {
207 if (!selection.computeVisibleSelectionInDOMTreeDeprecated().isCaret()) 207 if (!selection.computeVisibleSelectionInDOMTreeDeprecated().isCaret())
208 return false; 208 return false;
209 if (selection.selectionInDOMTree().affinity() != TextAffinity::Downstream) 209 if (selection.selectionInDOMTree().affinity() != TextAffinity::Downstream)
210 return false; 210 return false;
211 const Position& position = selection.start(); 211 const Position& position =
212 selection.computeVisibleSelectionInDOMTreeDeprecated().start();
212 return !inSameLine(PositionWithAffinity(position, TextAffinity::Upstream), 213 return !inSameLine(PositionWithAffinity(position, TextAffinity::Upstream),
213 PositionWithAffinity(position, TextAffinity::Downstream)); 214 PositionWithAffinity(position, TextAffinity::Downstream));
214 } 215 }
215 216
216 bool Editor::handleTextEvent(TextEvent* event) { 217 bool Editor::handleTextEvent(TextEvent* event) {
217 // Default event handling for Drag and Drop will be handled by DragController 218 // Default event handling for Drag and Drop will be handled by DragController
218 // so we leave the event for it. 219 // so we leave the event for it.
219 if (event->isDrop()) 220 if (event->isDrop())
220 return false; 221 return false;
221 222
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1090
1090 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 1091 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1091 // needs to be audited. See http://crbug.com/590369 for more details. 1092 // needs to be audited. See http://crbug.com/590369 for more details.
1092 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we 1093 // |tryDHTMLCut| dispatches cut event, which may make layout dirty, but we
1093 // need clean layout to obtain the selected content. 1094 // need clean layout to obtain the selected content.
1094 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1095 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
1095 1096
1096 // TODO(yosin) We should use early return style here. 1097 // TODO(yosin) We should use early return style here.
1097 if (canDeleteRange(selectedRange())) { 1098 if (canDeleteRange(selectedRange())) {
1098 spellChecker().updateMarkersForWordsAffectedByEditing(true); 1099 spellChecker().updateMarkersForWordsAffectedByEditing(true);
1099 if (enclosingTextControl(frame().selection().start())) { 1100 if (enclosingTextControl(frame()
1101 .selection()
1102 .computeVisibleSelectionInDOMTreeDeprecated()
1103 .start())) {
1100 String plainText = frame().selectedTextForClipboard(); 1104 String plainText = frame().selectedTextForClipboard();
1101 Pasteboard::generalPasteboard()->writePlainText( 1105 Pasteboard::generalPasteboard()->writePlainText(
1102 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace 1106 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace
1103 : Pasteboard::CannotSmartReplace); 1107 : Pasteboard::CannotSmartReplace);
1104 } else { 1108 } else {
1105 writeSelectionToPasteboard(); 1109 writeSelectionToPasteboard();
1106 } 1110 }
1107 1111
1108 if (source == CommandFromMenuOrKeyBinding) { 1112 if (source == CommandFromMenuOrKeyBinding) {
1109 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), 1113 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(),
(...skipping 16 matching lines...) Expand all
1126 return; // DHTML did the whole operation 1130 return; // DHTML did the whole operation
1127 if (!canCopy()) 1131 if (!canCopy())
1128 return; 1132 return;
1129 1133
1130 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 1134 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1131 // needs to be audited. See http://crbug.com/590369 for more details. 1135 // needs to be audited. See http://crbug.com/590369 for more details.
1132 // |tryDHTMLCopy| dispatches copy event, which may make layout dirty, but 1136 // |tryDHTMLCopy| dispatches copy event, which may make layout dirty, but
1133 // we need clean layout to obtain the selected content. 1137 // we need clean layout to obtain the selected content.
1134 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1138 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
1135 1139
1136 if (enclosingTextControl(frame().selection().start())) { 1140 if (enclosingTextControl(frame()
1141 .selection()
1142 .computeVisibleSelectionInDOMTreeDeprecated()
1143 .start())) {
1137 Pasteboard::generalPasteboard()->writePlainText( 1144 Pasteboard::generalPasteboard()->writePlainText(
1138 frame().selectedTextForClipboard(), 1145 frame().selectedTextForClipboard(),
1139 canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace 1146 canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace
1140 : Pasteboard::CannotSmartReplace); 1147 : Pasteboard::CannotSmartReplace);
1141 } else { 1148 } else {
1142 Document* document = frame().document(); 1149 Document* document = frame().document();
1143 if (HTMLImageElement* imageElement = 1150 if (HTMLImageElement* imageElement =
1144 imageElementFromImageDocument(document)) 1151 imageElementFromImageDocument(document))
1145 writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), imageElement, 1152 writeImageNodeToPasteboard(Pasteboard::generalPasteboard(), imageElement,
1146 document->title()); 1153 document->title());
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 1747
1741 DEFINE_TRACE(Editor) { 1748 DEFINE_TRACE(Editor) {
1742 visitor->trace(m_frame); 1749 visitor->trace(m_frame);
1743 visitor->trace(m_lastEditCommand); 1750 visitor->trace(m_lastEditCommand);
1744 visitor->trace(m_undoStack); 1751 visitor->trace(m_undoStack);
1745 visitor->trace(m_mark); 1752 visitor->trace(m_mark);
1746 visitor->trace(m_typingStyle); 1753 visitor->trace(m_typingStyle);
1747 } 1754 }
1748 1755
1749 } // namespace blink 1756 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698