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

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

Issue 2941233002: Refactor PreviousRootInlineBoxCandidatePosition() (Closed)
Patch Set: 2017-06-16T17:14:24 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
« no previous file with comments | « no previous file | no next file » | 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) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
3 * reserved. 3 * reserved.
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 DCHECK(visible_position.IsValid()) << visible_position; 224 DCHECK(visible_position.IsValid()) << visible_position;
225 ContainerNode* highest_root = 225 ContainerNode* highest_root =
226 HighestEditableRoot(visible_position.DeepEquivalent(), editable_type); 226 HighestEditableRoot(visible_position.DeepEquivalent(), editable_type);
227 Node* previous_node = PreviousLeafWithSameEditability(node, editable_type); 227 Node* previous_node = PreviousLeafWithSameEditability(node, editable_type);
228 228
229 while (previous_node && InSameLine(*previous_node, visible_position)) { 229 while (previous_node && InSameLine(*previous_node, visible_position)) {
230 previous_node = 230 previous_node =
231 PreviousLeafWithSameEditability(previous_node, editable_type); 231 PreviousLeafWithSameEditability(previous_node, editable_type);
232 } 232 }
233 233
234 while (previous_node && !previous_node->IsShadowRoot()) { 234 for (Node* runner = previous_node; runner && !runner->IsShadowRoot();
235 if (HighestEditableRoot(FirstPositionInOrBeforeNode(previous_node), 235 runner = PreviousLeafWithSameEditability(runner, editable_type)) {
236 if (HighestEditableRoot(FirstPositionInOrBeforeNode(runner),
236 editable_type) != highest_root) 237 editable_type) != highest_root)
237 break; 238 break;
238 239
239 Position pos = isHTMLBRElement(*previous_node) 240 const Position& candidate =
240 ? Position::BeforeNode(previous_node) 241 isHTMLBRElement(*runner)
241 : Position::EditingPositionOf( 242 ? Position::BeforeNode(runner)
242 previous_node, CaretMaxOffset(previous_node)); 243 : Position::EditingPositionOf(runner, CaretMaxOffset(runner));
243 244 if (IsVisuallyEquivalentCandidate(candidate))
244 if (IsVisuallyEquivalentCandidate(pos)) 245 return candidate;
245 return pos;
246
247 previous_node =
248 PreviousLeafWithSameEditability(previous_node, editable_type);
249 } 246 }
250 return Position(); 247 return Position();
251 } 248 }
252 249
253 Position NextRootInlineBoxCandidatePosition( 250 Position NextRootInlineBoxCandidatePosition(
254 Node* node, 251 Node* node,
255 const VisiblePosition& visible_position, 252 const VisiblePosition& visible_position,
256 EditableType editable_type) { 253 EditableType editable_type) {
257 DCHECK(visible_position.IsValid()) << visible_position; 254 DCHECK(visible_position.IsValid()) << visible_position;
258 ContainerNode* highest_root = 255 ContainerNode* highest_root =
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 // to the end of the line we're on. 684 // to the end of the line we're on.
688 Element* root_element = HasEditableStyle(*node, editable_type) 685 Element* root_element = HasEditableStyle(*node, editable_type)
689 ? RootEditableElement(*node, editable_type) 686 ? RootEditableElement(*node, editable_type)
690 : node->GetDocument().documentElement(); 687 : node->GetDocument().documentElement();
691 if (!root_element) 688 if (!root_element)
692 return VisiblePosition(); 689 return VisiblePosition();
693 return VisiblePosition::LastPositionInNode(root_element); 690 return VisiblePosition::LastPositionInNode(root_element);
694 } 691 }
695 692
696 } // namespace blink 693 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698