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

Side by Side Diff: third_party/WebKit/Source/core/editing/spellcheck/TextCheckingParagraph.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
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | 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) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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 15 matching lines...) Expand all
26 26
27 #include "core/editing/spellcheck/TextCheckingParagraph.h" 27 #include "core/editing/spellcheck/TextCheckingParagraph.h"
28 28
29 #include "core/dom/Range.h" 29 #include "core/dom/Range.h"
30 #include "core/editing/VisiblePosition.h" 30 #include "core/editing/VisiblePosition.h"
31 #include "core/editing/VisibleUnits.h" 31 #include "core/editing/VisibleUnits.h"
32 #include "core/editing/iterators/CharacterIterator.h" 32 #include "core/editing/iterators/CharacterIterator.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 static EphemeralRange ExpandToParagraphBoundary(const EphemeralRange& range) {
37 const VisiblePosition& start = CreateVisiblePosition(range.StartPosition());
38 DCHECK(start.IsNotNull()) << range.StartPosition();
39 const Position& paragraph_start = StartOfParagraph(start).DeepEquivalent();
40 DCHECK(paragraph_start.IsNotNull()) << range.StartPosition();
41
42 const VisiblePosition& end = CreateVisiblePosition(range.EndPosition());
43 DCHECK(end.IsNotNull()) << range.EndPosition();
44 const Position& paragraph_end = EndOfParagraph(end).DeepEquivalent();
45 DCHECK(paragraph_end.IsNotNull()) << range.EndPosition();
46
47 // TODO(xiaochengh): There are some cases (crbug.com/640112) where we get
48 // |paragraphStart > paragraphEnd|, which is the reason we cannot directly
49 // return |EphemeralRange(paragraphStart, paragraphEnd)|. This is not
50 // desired, though. We should do more investigation to ensure that why
51 // |paragraphStart <= paragraphEnd| is violated.
52 const Position& result_start =
53 paragraph_start.IsNotNull() && paragraph_start <= range.StartPosition()
54 ? paragraph_start
55 : range.StartPosition();
56 const Position& result_end =
57 paragraph_end.IsNotNull() && paragraph_end >= range.EndPosition()
58 ? paragraph_end
59 : range.EndPosition();
60 return EphemeralRange(result_start, result_end);
61 }
62
63 TextCheckingParagraph::TextCheckingParagraph( 36 TextCheckingParagraph::TextCheckingParagraph(
64 const EphemeralRange& checking_range) 37 const EphemeralRange& checking_range)
65 : checking_range_(checking_range), 38 : checking_range_(checking_range),
66 checking_start_(-1), 39 checking_start_(-1),
67 checking_end_(-1), 40 checking_end_(-1),
68 checking_length_(-1) {} 41 checking_length_(-1) {}
69 42
70 TextCheckingParagraph::TextCheckingParagraph( 43 TextCheckingParagraph::TextCheckingParagraph(
71 const EphemeralRange& checking_range, 44 const EphemeralRange& checking_range,
72 const EphemeralRange& paragraph_range) 45 const EphemeralRange& paragraph_range)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 151
179 int TextCheckingParagraph::CheckingLength() const { 152 int TextCheckingParagraph::CheckingLength() const {
180 DCHECK(checking_range_.IsNotNull()); 153 DCHECK(checking_range_.IsNotNull());
181 if (-1 == checking_length_) 154 if (-1 == checking_length_)
182 checking_length_ = TextIterator::RangeLength( 155 checking_length_ = TextIterator::RangeLength(
183 CheckingRange().StartPosition(), CheckingRange().EndPosition()); 156 CheckingRange().StartPosition(), CheckingRange().EndPosition());
184 return checking_length_; 157 return checking_length_;
185 } 158 }
186 159
187 } // namespace blink 160 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698