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

Side by Side Diff: Source/core/editing/TextCheckingHelper.cpp

Issue 252783002: Make Range.detach() a no-op (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/SpellChecker.cpp ('k') | Source/core/editing/TextIterator.cpp » ('j') | 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 misspelling.replacement = client.getAutoCorrectSuggestionForMisspell edWord(String(text + misspelling.location, misspelling.length)); 93 misspelling.replacement = client.getAutoCorrectSuggestionForMisspell edWord(String(text + misspelling.location, misspelling.length));
94 results.append(misspelling); 94 results.append(misspelling);
95 } 95 }
96 96
97 wordStart = wordEnd; 97 wordStart = wordEnd;
98 } 98 }
99 } 99 }
100 100
101 static PassRefPtrWillBeRawPtr<Range> expandToParagraphBoundary(PassRefPtrWillBeR awPtr<Range> range) 101 static PassRefPtrWillBeRawPtr<Range> expandToParagraphBoundary(PassRefPtrWillBeR awPtr<Range> range)
102 { 102 {
103 RefPtrWillBeRawPtr<Range> paragraphRange = range->cloneRange(IGNORE_EXCEPTIO N); 103 RefPtrWillBeRawPtr<Range> paragraphRange = range->cloneRange();
104 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(range->start Position()))); 104 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(range->start Position())));
105 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(range->endPositi on()))); 105 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(range->endPositi on())));
106 return paragraphRange; 106 return paragraphRange;
107 } 107 }
108 108
109 TextCheckingParagraph::TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> check ingRange) 109 TextCheckingParagraph::TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> check ingRange)
110 : m_checkingRange(checkingRange) 110 : m_checkingRange(checkingRange)
111 , m_checkingStart(-1) 111 , m_checkingStart(-1)
112 , m_checkingEnd(-1) 112 , m_checkingEnd(-1)
113 , m_checkingLength(-1) 113 , m_checkingLength(-1)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 PassRefPtrWillBeRawPtr<Range> TextCheckingParagraph::subrange(int characterOffse t, int characterCount) const 158 PassRefPtrWillBeRawPtr<Range> TextCheckingParagraph::subrange(int characterOffse t, int characterCount) const
159 { 159 {
160 ASSERT(m_checkingRange); 160 ASSERT(m_checkingRange);
161 return TextIterator::subrange(paragraphRange().get(), characterOffset, chara cterCount); 161 return TextIterator::subrange(paragraphRange().get(), characterOffset, chara cterCount);
162 } 162 }
163 163
164 int TextCheckingParagraph::offsetTo(const Position& position, ExceptionState& ex ceptionState) const 164 int TextCheckingParagraph::offsetTo(const Position& position, ExceptionState& ex ceptionState) const
165 { 165 {
166 ASSERT(m_checkingRange); 166 ASSERT(m_checkingRange);
167 RefPtrWillBeRawPtr<Range> range = offsetAsRange()->cloneRange(ASSERT_NO_EXCE PTION); 167 RefPtrWillBeRawPtr<Range> range = offsetAsRange()->cloneRange();
168 range->setEnd(position.containerNode(), position.computeOffsetInContainerNod e(), exceptionState); 168 range->setEnd(position.containerNode(), position.computeOffsetInContainerNod e(), exceptionState);
169 if (exceptionState.hadException()) 169 if (exceptionState.hadException())
170 return 0; 170 return 0;
171 return TextIterator::rangeLength(range.get()); 171 return TextIterator::rangeLength(range.get());
172 } 172 }
173 173
174 bool TextCheckingParagraph::isEmpty() const 174 bool TextCheckingParagraph::isEmpty() const
175 { 175 {
176 // Both predicates should have same result, but we check both just for sure. 176 // Both predicates should have same result, but we check both just for sure.
177 // We need to investigate to remove this redundancy. 177 // We need to investigate to remove this redundancy.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 outIsSpelling = true; 299 outIsSpelling = true;
300 outFirstFoundOffset = 0; 300 outFirstFoundOffset = 0;
301 outGrammarDetail.location = -1; 301 outGrammarDetail.location = -1;
302 outGrammarDetail.length = 0; 302 outGrammarDetail.length = 0;
303 outGrammarDetail.guesses.clear(); 303 outGrammarDetail.guesses.clear();
304 outGrammarDetail.userDescription = ""; 304 outGrammarDetail.userDescription = "";
305 305
306 // Expand the search range to encompass entire paragraphs, since text checki ng needs that much context. 306 // Expand the search range to encompass entire paragraphs, since text checki ng needs that much context.
307 // Determine the character offset from the start of the paragraph to the sta rt of the original search range, 307 // Determine the character offset from the start of the paragraph to the sta rt of the original search range,
308 // since we will want to ignore results in this area. 308 // since we will want to ignore results in this area.
309 RefPtrWillBeRawPtr<Range> paragraphRange = m_range->cloneRange(IGNORE_EXCEPT ION); 309 RefPtrWillBeRawPtr<Range> paragraphRange = m_range->cloneRange();
310 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(m_range->sta rtPosition()))); 310 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(m_range->sta rtPosition())));
311 int totalRangeLength = TextIterator::rangeLength(paragraphRange.get()); 311 int totalRangeLength = TextIterator::rangeLength(paragraphRange.get());
312 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(m_range->startPo sition()))); 312 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(m_range->startPo sition())));
313 313
314 RefPtrWillBeRawPtr<Range> offsetAsRange = Range::create(paragraphRange->star tContainer()->document(), paragraphRange->startPosition(), m_range->startPositio n()); 314 RefPtrWillBeRawPtr<Range> offsetAsRange = Range::create(paragraphRange->star tContainer()->document(), paragraphRange->startPosition(), m_range->startPositio n());
315 int rangeStartOffset = TextIterator::rangeLength(offsetAsRange.get()); 315 int rangeStartOffset = TextIterator::rangeLength(offsetAsRange.get());
316 int totalLengthProcessed = 0; 316 int totalLengthProcessed = 0;
317 317
318 bool firstIteration = true; 318 bool firstIteration = true;
319 bool lastIteration = false; 319 bool lastIteration = false;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return false; 569 return false;
570 570
571 const Settings* settings = frame->settings(); 571 const Settings* settings = frame->settings();
572 if (!settings) 572 if (!settings)
573 return false; 573 return false;
574 574
575 return settings->unifiedTextCheckerEnabled(); 575 return settings->unifiedTextCheckerEnabled();
576 } 576 }
577 577
578 } 578 }
OLDNEW
« no previous file with comments | « Source/core/editing/SpellChecker.cpp ('k') | Source/core/editing/TextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698