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

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

Issue 2920733002: Rename VisibleSelection::end() to End() (Closed)
Patch Set: 2017-06-01T18:31:38 Created 3 years, 6 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) 2005 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 void DeleteSelectionCommand::InitializeStartEnd(Position& start, 114 void DeleteSelectionCommand::InitializeStartEnd(Position& start,
115 Position& end) { 115 Position& end) {
116 DCHECK(!GetDocument().NeedsLayoutTreeUpdate()); 116 DCHECK(!GetDocument().NeedsLayoutTreeUpdate());
117 DocumentLifecycle::DisallowTransitionScope disallow_transition( 117 DocumentLifecycle::DisallowTransitionScope disallow_transition(
118 GetDocument().Lifecycle()); 118 GetDocument().Lifecycle());
119 119
120 HTMLElement* start_special_container = nullptr; 120 HTMLElement* start_special_container = nullptr;
121 HTMLElement* end_special_container = nullptr; 121 HTMLElement* end_special_container = nullptr;
122 122
123 start = selection_to_delete_.Start(); 123 start = selection_to_delete_.Start();
124 end = selection_to_delete_.end(); 124 end = selection_to_delete_.End();
125 125
126 // For HRs, we'll get a position at (HR,1) when hitting delete from the 126 // For HRs, we'll get a position at (HR,1) when hitting delete from the
127 // beginning of the previous line, or (HR,0) when forward deleting, but in 127 // beginning of the previous line, or (HR,0) when forward deleting, but in
128 // these cases, we want to delete it, so manually expand the selection 128 // these cases, we want to delete it, so manually expand the selection
129 if (isHTMLHRElement(*start.AnchorNode())) 129 if (isHTMLHRElement(*start.AnchorNode()))
130 start = Position::BeforeNode(start.AnchorNode()); 130 start = Position::BeforeNode(start.AnchorNode());
131 else if (isHTMLHRElement(*end.AnchorNode())) 131 else if (isHTMLHRElement(*end.AnchorNode()))
132 end = Position::AfterNode(end.AnchorNode()); 132 end = Position::AfterNode(end.AnchorNode());
133 133
134 // FIXME: This is only used so that moveParagraphs can avoid the bugs in 134 // FIXME: This is only used so that moveParagraphs can avoid the bugs in
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Figure out the typing style in effect before the delete is done. 387 // Figure out the typing style in effect before the delete is done.
388 typing_style_ = EditingStyle::Create( 388 typing_style_ = EditingStyle::Create(
389 selection_to_delete_.Start(), EditingStyle::kEditingPropertiesInEffect); 389 selection_to_delete_.Start(), EditingStyle::kEditingPropertiesInEffect);
390 typing_style_->RemoveStyleAddedByElement( 390 typing_style_->RemoveStyleAddedByElement(
391 EnclosingAnchorElement(selection_to_delete_.Start())); 391 EnclosingAnchorElement(selection_to_delete_.Start()));
392 392
393 // If we're deleting into a Mail blockquote, save the style at end() instead 393 // If we're deleting into a Mail blockquote, save the style at end() instead
394 // of start(). We'll use this later in computeTypingStyleAfterDelete if we end 394 // of start(). We'll use this later in computeTypingStyleAfterDelete if we end
395 // up outside of a Mail blockquote 395 // up outside of a Mail blockquote
396 if (EnclosingNodeOfType(selection_to_delete_.Start(), 396 if (EnclosingNodeOfType(selection_to_delete_.Start(),
397 IsMailHTMLBlockquoteElement)) 397 IsMailHTMLBlockquoteElement)) {
yosin_UTC9 2017/06/01 09:42:50 For pass PRESUBMIT
398 delete_into_blockquote_style_ = 398 delete_into_blockquote_style_ =
399 EditingStyle::Create(selection_to_delete_.end()); 399 EditingStyle::Create(selection_to_delete_.End());
400 else 400 return;
401 delete_into_blockquote_style_ = nullptr; 401 }
402 delete_into_blockquote_style_ = nullptr;
402 } 403 }
403 404
404 bool DeleteSelectionCommand::HandleSpecialCaseBRDelete( 405 bool DeleteSelectionCommand::HandleSpecialCaseBRDelete(
405 EditingState* editing_state) { 406 EditingState* editing_state) {
406 Node* node_after_upstream_start = upstream_start_.ComputeNodeAfterPosition(); 407 Node* node_after_upstream_start = upstream_start_.ComputeNodeAfterPosition();
407 Node* node_after_downstream_start = 408 Node* node_after_downstream_start =
408 downstream_start_.ComputeNodeAfterPosition(); 409 downstream_start_.ComputeNodeAfterPosition();
409 // Upstream end will appear before BR due to canonicalization 410 // Upstream end will appear before BR due to canonicalization
410 Node* node_after_upstream_end = upstream_end_.ComputeNodeAfterPosition(); 411 Node* node_after_upstream_end = upstream_end_.ComputeNodeAfterPosition();
411 412
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 } 1067 }
1067 1068
1068 RelocatablePosition relocatable_reference_position(reference_move_position_); 1069 RelocatablePosition relocatable_reference_position(reference_move_position_);
1069 1070
1070 // save this to later make the selection with 1071 // save this to later make the selection with
1071 TextAffinity affinity = selection_to_delete_.Affinity(); 1072 TextAffinity affinity = selection_to_delete_.Affinity();
1072 1073
1073 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 1074 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
1074 1075
1075 Position downstream_end = 1076 Position downstream_end =
1076 MostForwardCaretPosition(selection_to_delete_.end()); 1077 MostForwardCaretPosition(selection_to_delete_.End());
1077 bool root_will_stay_open_without_placeholder = 1078 bool root_will_stay_open_without_placeholder =
1078 downstream_end.ComputeContainerNode() == 1079 downstream_end.ComputeContainerNode() ==
1079 RootEditableElement(*downstream_end.ComputeContainerNode()) || 1080 RootEditableElement(*downstream_end.ComputeContainerNode()) ||
1080 (downstream_end.ComputeContainerNode()->IsTextNode() && 1081 (downstream_end.ComputeContainerNode()->IsTextNode() &&
1081 downstream_end.ComputeContainerNode()->parentNode() == 1082 downstream_end.ComputeContainerNode()->parentNode() ==
1082 RootEditableElement(*downstream_end.ComputeContainerNode())); 1083 RootEditableElement(*downstream_end.ComputeContainerNode()));
1083 bool line_break_at_end_of_selection_to_delete = 1084 bool line_break_at_end_of_selection_to_delete =
1084 LineBreakExistsAtVisiblePosition(selection_to_delete_.VisibleEnd()); 1085 LineBreakExistsAtVisiblePosition(selection_to_delete_.VisibleEnd());
1085 need_placeholder_ = !root_will_stay_open_without_placeholder && 1086 need_placeholder_ = !root_will_stay_open_without_placeholder &&
1086 IsStartOfParagraph(selection_to_delete_.VisibleStart(), 1087 IsStartOfParagraph(selection_to_delete_.VisibleStart(),
1087 kCanCrossEditingBoundary) && 1088 kCanCrossEditingBoundary) &&
1088 IsEndOfParagraph(selection_to_delete_.VisibleEnd(), 1089 IsEndOfParagraph(selection_to_delete_.VisibleEnd(),
1089 kCanCrossEditingBoundary) && 1090 kCanCrossEditingBoundary) &&
1090 !line_break_at_end_of_selection_to_delete; 1091 !line_break_at_end_of_selection_to_delete;
1091 if (need_placeholder_) { 1092 if (need_placeholder_) {
1092 // Don't need a placeholder when deleting a selection that starts just 1093 // Don't need a placeholder when deleting a selection that starts just
1093 // before a table and ends inside it (we do need placeholders to hold 1094 // before a table and ends inside it (we do need placeholders to hold
1094 // open empty cells, but that's handled elsewhere). 1095 // open empty cells, but that's handled elsewhere).
1095 if (Element* table = 1096 if (Element* table =
1096 TableElementJustAfter(selection_to_delete_.VisibleStart())) { 1097 TableElementJustAfter(selection_to_delete_.VisibleStart())) {
1097 if (selection_to_delete_.end().AnchorNode()->IsDescendantOf(table)) 1098 if (selection_to_delete_.End().AnchorNode()->IsDescendantOf(table))
1098 need_placeholder_ = false; 1099 need_placeholder_ = false;
1099 } 1100 }
1100 } 1101 }
1101 1102
1102 // set up our state 1103 // set up our state
1103 InitializePositionData(editing_state); 1104 InitializePositionData(editing_state);
1104 if (editing_state->IsAborted()) 1105 if (editing_state->IsAborted())
1105 return; 1106 return;
1106 1107
1107 bool line_break_before_start = LineBreakExistsAtVisiblePosition( 1108 bool line_break_before_start = LineBreakExistsAtVisiblePosition(
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 visitor->Trace(delete_into_blockquote_style_); 1247 visitor->Trace(delete_into_blockquote_style_);
1247 visitor->Trace(start_root_); 1248 visitor->Trace(start_root_);
1248 visitor->Trace(end_root_); 1249 visitor->Trace(end_root_);
1249 visitor->Trace(start_table_row_); 1250 visitor->Trace(start_table_row_);
1250 visitor->Trace(end_table_row_); 1251 visitor->Trace(end_table_row_);
1251 visitor->Trace(temporary_placeholder_); 1252 visitor->Trace(temporary_placeholder_);
1252 CompositeEditCommand::Trace(visitor); 1253 CompositeEditCommand::Trace(visitor);
1253 } 1254 }
1254 1255
1255 } // namespace blink 1256 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698