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

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

Issue 2950053002: Make Position::BeforeNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-21T17:56:36 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) 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 start_box = FindRightNonPseudoNodeInlineBox(*root_box); 209 start_box = FindRightNonPseudoNodeInlineBox(*root_box);
210 if (!start_box) 210 if (!start_box)
211 return PositionWithAffinityTemplate<Strategy>(); 211 return PositionWithAffinityTemplate<Strategy>();
212 start_node = start_box->GetLineLayoutItem().NonPseudoNode(); 212 start_node = start_box->GetLineLayoutItem().NonPseudoNode();
213 } 213 }
214 214
215 return PositionWithAffinityTemplate<Strategy>( 215 return PositionWithAffinityTemplate<Strategy>(
216 start_node->IsTextNode() 216 start_node->IsTextNode()
217 ? PositionTemplate<Strategy>(ToText(start_node), 217 ? PositionTemplate<Strategy>(ToText(start_node),
218 ToInlineTextBox(start_box)->Start()) 218 ToInlineTextBox(start_box)->Start())
219 : PositionTemplate<Strategy>::BeforeNode(start_node)); 219 : PositionTemplate<Strategy>::BeforeNode(*start_node));
220 } 220 }
221 221
222 template <typename Strategy> 222 template <typename Strategy>
223 PositionWithAffinityTemplate<Strategy> StartOfLineAlgorithm( 223 PositionWithAffinityTemplate<Strategy> StartOfLineAlgorithm(
224 const PositionWithAffinityTemplate<Strategy>& c) { 224 const PositionWithAffinityTemplate<Strategy>& c) {
225 // TODO: this is the current behavior that might need to be fixed. 225 // TODO: this is the current behavior that might need to be fixed.
226 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. 226 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail.
227 PositionWithAffinityTemplate<Strategy> vis_pos = 227 PositionWithAffinityTemplate<Strategy> vis_pos =
228 StartPositionForLine(c, kUseInlineBoxOrdering); 228 StartPositionForLine(c, kUseInlineBoxOrdering);
229 return HonorEditingBoundaryAtOrBefore(vis_pos, c.GetPosition()); 229 return HonorEditingBoundaryAtOrBefore(vis_pos, c.GetPosition());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 HighestEditableRoot(visible_position.DeepEquivalent(), editable_type); 294 HighestEditableRoot(visible_position.DeepEquivalent(), editable_type);
295 Node* const previous_node = 295 Node* const previous_node =
296 FindNodeInPreviousLine(*node, visible_position, editable_type); 296 FindNodeInPreviousLine(*node, visible_position, editable_type);
297 for (Node* runner = previous_node; runner && !runner->IsShadowRoot(); 297 for (Node* runner = previous_node; runner && !runner->IsShadowRoot();
298 runner = PreviousLeafWithSameEditability(runner, editable_type)) { 298 runner = PreviousLeafWithSameEditability(runner, editable_type)) {
299 if (HighestEditableRootOfNode(*runner, editable_type) != highest_root) 299 if (HighestEditableRootOfNode(*runner, editable_type) != highest_root)
300 break; 300 break;
301 301
302 const Position& candidate = 302 const Position& candidate =
303 isHTMLBRElement(*runner) 303 isHTMLBRElement(*runner)
304 ? Position::BeforeNode(runner) 304 ? Position::BeforeNode(*runner)
305 : Position::EditingPositionOf(runner, CaretMaxOffset(runner)); 305 : Position::EditingPositionOf(runner, CaretMaxOffset(runner));
306 if (IsVisuallyEquivalentCandidate(candidate)) 306 if (IsVisuallyEquivalentCandidate(candidate))
307 return candidate; 307 return candidate;
308 } 308 }
309 return Position(); 309 return Position();
310 } 310 }
311 311
312 Position NextRootInlineBoxCandidatePosition( 312 Position NextRootInlineBoxCandidatePosition(
313 Node* node, 313 Node* node,
314 const VisiblePosition& visible_position, 314 const VisiblePosition& visible_position,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // TODO(editing-dev): We should consider text-direction of line to 422 // TODO(editing-dev): We should consider text-direction of line to
423 // find non-pseudo node. 423 // find non-pseudo node.
424 end_box = FindLeftNonPseudoNodeInlineBox(*root_box); 424 end_box = FindLeftNonPseudoNodeInlineBox(*root_box);
425 if (!end_box) 425 if (!end_box)
426 return VisiblePositionTemplate<Strategy>(); 426 return VisiblePositionTemplate<Strategy>();
427 end_node = end_box->GetLineLayoutItem().NonPseudoNode(); 427 end_node = end_box->GetLineLayoutItem().NonPseudoNode();
428 } 428 }
429 429
430 if (isHTMLBRElement(*end_node)) { 430 if (isHTMLBRElement(*end_node)) {
431 return CreateVisiblePosition( 431 return CreateVisiblePosition(
432 PositionTemplate<Strategy>::BeforeNode(end_node), 432 PositionTemplate<Strategy>::BeforeNode(*end_node),
433 VP_UPSTREAM_IF_POSSIBLE); 433 VP_UPSTREAM_IF_POSSIBLE);
434 } 434 }
435 if (end_box->IsInlineTextBox() && end_node->IsTextNode()) { 435 if (end_box->IsInlineTextBox() && end_node->IsTextNode()) {
436 InlineTextBox* end_text_box = ToInlineTextBox(end_box); 436 InlineTextBox* end_text_box = ToInlineTextBox(end_box);
437 int end_offset = end_text_box->Start(); 437 int end_offset = end_text_box->Start();
438 if (!end_text_box->IsLineBreak()) 438 if (!end_text_box->IsLineBreak())
439 end_offset += end_text_box->Len(); 439 end_offset += end_text_box->Len();
440 return CreateVisiblePosition( 440 return CreateVisiblePosition(
441 PositionTemplate<Strategy>(ToText(end_node), end_offset), 441 PositionTemplate<Strategy>(ToText(end_node), end_offset),
442 VP_UPSTREAM_IF_POSSIBLE); 442 VP_UPSTREAM_IF_POSSIBLE);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 // to the end of the line we're on. 747 // to the end of the line we're on.
748 Element* root_element = HasEditableStyle(*node, editable_type) 748 Element* root_element = HasEditableStyle(*node, editable_type)
749 ? RootEditableElement(*node, editable_type) 749 ? RootEditableElement(*node, editable_type)
750 : node->GetDocument().documentElement(); 750 : node->GetDocument().documentElement();
751 if (!root_element) 751 if (!root_element)
752 return VisiblePosition(); 752 return VisiblePosition();
753 return VisiblePosition::LastPositionInNode(root_element); 753 return VisiblePosition::LastPositionInNode(root_element);
754 } 754 }
755 755
756 } // namespace blink 756 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698