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

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

Issue 624483002: Make TextIterator not stop at IMG element for finding text separating inline image (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 | « Source/core/editing/TextIterator.h ('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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
3 * Copyright (C) 2005 Alexey Proskuryakov. 3 * Copyright (C) 2005 Alexey Proskuryakov.
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh aractersBetweenAllVisiblePositions) 259 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh aractersBetweenAllVisiblePositions)
260 , m_entersTextControls(behavior & TextIteratorEntersTextControls) 260 , m_entersTextControls(behavior & TextIteratorEntersTextControls)
261 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) 261 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText)
262 , m_handledFirstLetter(false) 262 , m_handledFirstLetter(false)
263 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) 263 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility)
264 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls) 264 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls)
265 , m_shouldStop(false) 265 , m_shouldStop(false)
266 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText) 266 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText)
267 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) 267 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots)
268 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac ementCharacter) 268 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac ementCharacter)
269 , m_breaksAtReplacedElement(!(behavior & TextIteratorDoesNotBreakAtReplacedE lement))
269 { 270 {
270 if (range) 271 if (range)
271 initialize(range->startPosition(), range->endPosition()); 272 initialize(range->startPosition(), range->endPosition());
272 } 273 }
273 274
274 TextIterator::TextIterator(const Position& start, const Position& end, TextItera torBehaviorFlags behavior) 275 TextIterator::TextIterator(const Position& start, const Position& end, TextItera torBehaviorFlags behavior)
275 : m_startContainer(nullptr) 276 : m_startContainer(nullptr)
276 , m_startOffset(0) 277 , m_startOffset(0)
277 , m_endContainer(nullptr) 278 , m_endContainer(nullptr)
278 , m_endOffset(0) 279 , m_endOffset(0)
(...skipping 11 matching lines...) Expand all
290 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh aractersBetweenAllVisiblePositions) 291 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh aractersBetweenAllVisiblePositions)
291 , m_entersTextControls(behavior & TextIteratorEntersTextControls) 292 , m_entersTextControls(behavior & TextIteratorEntersTextControls)
292 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) 293 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText)
293 , m_handledFirstLetter(false) 294 , m_handledFirstLetter(false)
294 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) 295 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility)
295 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls) 296 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls)
296 , m_shouldStop(false) 297 , m_shouldStop(false)
297 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText) 298 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText)
298 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) 299 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots)
299 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac ementCharacter) 300 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac ementCharacter)
301 , m_breaksAtReplacedElement(!(behavior & TextIteratorDoesNotBreakAtReplacedE lement))
300 { 302 {
301 initialize(start, end); 303 initialize(start, end);
302 } 304 }
303 305
304 void TextIterator::initialize(const Position& start, const Position& end) 306 void TextIterator::initialize(const Position& start, const Position& end)
305 { 307 {
306 ASSERT(comparePositions(start, end) <= 0); 308 ASSERT(comparePositions(start, end) <= 0);
307 309
308 // Get and validate |start| and |end|. 310 // Get and validate |start| and |end|.
309 Node* startContainer = start.containerNode(); 311 Node* startContainer = start.containerNode();
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 } 1741 }
1740 1742
1741 // exhaust the current m_textIterator run 1743 // exhaust the current m_textIterator run
1742 count -= remaining; 1744 count -= remaining;
1743 m_offset += remaining; 1745 m_offset += remaining;
1744 1746
1745 // move to a subsequent m_textIterator run 1747 // move to a subsequent m_textIterator run
1746 for (m_textIterator.advance(); !atEnd(); m_textIterator.advance()) { 1748 for (m_textIterator.advance(); !atEnd(); m_textIterator.advance()) {
1747 int runLength = m_textIterator.length(); 1749 int runLength = m_textIterator.length();
1748 if (!runLength) { 1750 if (!runLength) {
1749 m_atBreak = true; 1751 m_atBreak = m_textIterator.breaksAtReplacedElement();
1750 } else { 1752 } else {
1751 // see whether this is m_textIterator to use 1753 // see whether this is m_textIterator to use
1752 if (count < runLength) { 1754 if (count < runLength) {
1753 m_runOffset = count; 1755 m_runOffset = count;
1754 m_offset += count; 1756 m_offset += count;
1755 return; 1757 return;
1756 } 1758 }
1757 1759
1758 // exhaust this m_textIterator run 1760 // exhaust this m_textIterator run
1759 count -= runLength; 1761 count -= runLength;
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 } 2371 }
2370 if (it.atBreak() && !buffer.atBreak()) { 2372 if (it.atBreak() && !buffer.atBreak()) {
2371 buffer.reachedBreak(); 2373 buffer.reachedBreak();
2372 goto tryAgain; 2374 goto tryAgain;
2373 } 2375 }
2374 } 2376 }
2375 2377
2376 return matchLength; 2378 return matchLength;
2377 } 2379 }
2378 2380
2379 static const TextIteratorBehaviorFlags iteratorFlagsForFindPlainText = TextItera torEntersTextControls | TextIteratorEntersAuthorShadowRoots; 2381 static const TextIteratorBehaviorFlags iteratorFlagsForFindPlainText = TextItera torEntersTextControls | TextIteratorEntersAuthorShadowRoots | TextIteratorDoesNo tBreakAtReplacedElement;
2380 2382
2381 PassRefPtrWillBeRawPtr<Range> findPlainText(const Range* range, const String& ta rget, FindOptions options) 2383 PassRefPtrWillBeRawPtr<Range> findPlainText(const Range* range, const String& ta rget, FindOptions options)
2382 { 2384 {
2383 // First, find the text. 2385 // First, find the text.
2384 size_t matchStart; 2386 size_t matchStart;
2385 size_t matchLength; 2387 size_t matchLength;
2386 { 2388 {
2387 CharacterIterator findIterator(range, iteratorFlagsForFindPlainText); 2389 CharacterIterator findIterator(range, iteratorFlagsForFindPlainText);
2388 matchLength = findPlainTextInternal(findIterator, target, options, match Start); 2390 matchLength = findPlainTextInternal(findIterator, target, options, match Start);
2389 if (!matchLength) 2391 if (!matchLength)
(...skipping 29 matching lines...) Expand all
2419 resultEnd = collapseTo; 2421 resultEnd = collapseTo;
2420 return; 2422 return;
2421 } 2423 }
2422 } 2424 }
2423 2425
2424 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText); 2426 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText);
2425 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re sultStart, resultEnd); 2427 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re sultStart, resultEnd);
2426 } 2428 }
2427 2429
2428 } 2430 }
OLDNEW
« no previous file with comments | « Source/core/editing/TextIterator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698