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

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

Issue 2940053003: Refactor NextLeafWithSameEditability() (Closed)
Patch Set: 2017-06-15T16:53:53 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 return nullptr; 96 return nullptr;
97 } 97 }
98 98
99 Node* NextLeafWithSameEditability( 99 Node* NextLeafWithSameEditability(
100 Node* node, 100 Node* node,
101 EditableType editable_type = kContentIsEditable) { 101 EditableType editable_type = kContentIsEditable) {
102 if (!node) 102 if (!node)
103 return nullptr; 103 return nullptr;
104 104
105 bool editable = HasEditableStyle(*node, editable_type); 105 const bool editable = HasEditableStyle(*node, editable_type);
106 node = NextAtomicLeafNode(*node); 106 for (Node* runner = NextAtomicLeafNode(*node); runner;
107 while (node) { 107 runner = NextAtomicLeafNode(*runner)) {
108 if (editable == HasEditableStyle(*node, editable_type)) 108 if (editable == HasEditableStyle(*runner, editable_type))
109 return node; 109 return runner;
110 node = NextAtomicLeafNode(*node);
111 } 110 }
112 return nullptr; 111 return nullptr;
113 } 112 }
114 113
115 enum LineEndpointComputationMode { kUseLogicalOrdering, kUseInlineBoxOrdering }; 114 enum LineEndpointComputationMode { kUseLogicalOrdering, kUseInlineBoxOrdering };
116 template <typename Strategy> 115 template <typename Strategy>
117 PositionWithAffinityTemplate<Strategy> StartPositionForLine( 116 PositionWithAffinityTemplate<Strategy> StartPositionForLine(
118 const PositionWithAffinityTemplate<Strategy>& c, 117 const PositionWithAffinityTemplate<Strategy>& c,
119 LineEndpointComputationMode mode) { 118 LineEndpointComputationMode mode) {
120 if (c.IsNull()) 119 if (c.IsNull())
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 // to the end of the line we're on. 679 // to the end of the line we're on.
681 Element* root_element = HasEditableStyle(*node, editable_type) 680 Element* root_element = HasEditableStyle(*node, editable_type)
682 ? RootEditableElement(*node, editable_type) 681 ? RootEditableElement(*node, editable_type)
683 : node->GetDocument().documentElement(); 682 : node->GetDocument().documentElement();
684 if (!root_element) 683 if (!root_element)
685 return VisiblePosition(); 684 return VisiblePosition();
686 return VisiblePosition::LastPositionInNode(root_element); 685 return VisiblePosition::LastPositionInNode(root_element);
687 } 686 }
688 687
689 } // namespace blink 688 } // 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