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

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

Issue 2869213002: Move ExpandToParagraphBoundary to VisibleUnits (Closed)
Patch Set: Created 3 years, 7 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 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 VisiblePosition pos = p; 2136 VisiblePosition pos = p;
2137 do { 2137 do {
2138 VisiblePosition n = NextLinePosition(pos, x); 2138 VisiblePosition n = NextLinePosition(pos, x);
2139 if (n.IsNull() || n.DeepEquivalent() == pos.DeepEquivalent()) 2139 if (n.IsNull() || n.DeepEquivalent() == pos.DeepEquivalent())
2140 break; 2140 break;
2141 pos = n; 2141 pos = n;
2142 } while (InSameParagraph(p, pos)); 2142 } while (InSameParagraph(p, pos));
2143 return pos; 2143 return pos;
2144 } 2144 }
2145 2145
2146 EphemeralRange ExpandToParagraphBoundary(const EphemeralRange& range) {
2147 const VisiblePosition& start = CreateVisiblePosition(range.StartPosition());
2148 DCHECK(start.IsNotNull()) << range.StartPosition();
2149 const Position& paragraph_start = StartOfParagraph(start).DeepEquivalent();
2150 DCHECK(paragraph_start.IsNotNull()) << range.StartPosition();
2151
2152 const VisiblePosition& end = CreateVisiblePosition(range.EndPosition());
2153 DCHECK(end.IsNotNull()) << range.EndPosition();
2154 const Position& paragraph_end = EndOfParagraph(end).DeepEquivalent();
2155 DCHECK(paragraph_end.IsNotNull()) << range.EndPosition();
2156
2157 // TODO(xiaochengh): There are some cases (crbug.com/640112) where we get
2158 // |paragraphStart > paragraphEnd|, which is the reason we cannot directly
2159 // return |EphemeralRange(paragraphStart, paragraphEnd)|. This is not
2160 // desired, though. We should do more investigation to ensure that why
2161 // |paragraphStart <= paragraphEnd| is violated.
2162 const Position& result_start =
2163 paragraph_start.IsNotNull() && paragraph_start <= range.StartPosition()
2164 ? paragraph_start
2165 : range.StartPosition();
2166 const Position& result_end =
2167 paragraph_end.IsNotNull() && paragraph_end >= range.EndPosition()
2168 ? paragraph_end
2169 : range.EndPosition();
2170 return EphemeralRange(result_start, result_end);
2171 }
2172
2146 // --------- 2173 // ---------
2147 2174
2148 VisiblePosition StartOfBlock(const VisiblePosition& visible_position, 2175 VisiblePosition StartOfBlock(const VisiblePosition& visible_position,
2149 EditingBoundaryCrossingRule rule) { 2176 EditingBoundaryCrossingRule rule) {
2150 DCHECK(visible_position.IsValid()) << visible_position; 2177 DCHECK(visible_position.IsValid()) << visible_position;
2151 Position position = visible_position.DeepEquivalent(); 2178 Position position = visible_position.DeepEquivalent();
2152 Element* start_block = 2179 Element* start_block =
2153 position.ComputeContainerNode() 2180 position.ComputeContainerNode()
2154 ? EnclosingBlock(position.ComputeContainerNode(), rule) 2181 ? EnclosingBlock(position.ComputeContainerNode(), rule)
2155 : 0; 2182 : 0;
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after
4072 4099
4073 Position SkipWhitespace(const Position& position) { 4100 Position SkipWhitespace(const Position& position) {
4074 return SkipWhitespaceAlgorithm(position); 4101 return SkipWhitespaceAlgorithm(position);
4075 } 4102 }
4076 4103
4077 PositionInFlatTree SkipWhitespace(const PositionInFlatTree& position) { 4104 PositionInFlatTree SkipWhitespace(const PositionInFlatTree& position) {
4078 return SkipWhitespaceAlgorithm(position); 4105 return SkipWhitespaceAlgorithm(position);
4079 } 4106 }
4080 4107
4081 } // namespace blink 4108 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698