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

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

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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 28 matching lines...) Expand all
39 39
40 enum TextIteratorBehavior { 40 enum TextIteratorBehavior {
41 TextIteratorDefaultBehavior = 0, 41 TextIteratorDefaultBehavior = 0,
42 TextIteratorEmitsCharactersBetweenAllVisiblePositions = 1 << 0, 42 TextIteratorEmitsCharactersBetweenAllVisiblePositions = 1 << 0,
43 TextIteratorEntersTextControls = 1 << 1, 43 TextIteratorEntersTextControls = 1 << 1,
44 TextIteratorIgnoresStyleVisibility = 1 << 2, 44 TextIteratorIgnoresStyleVisibility = 1 << 2,
45 TextIteratorEmitsOriginalText = 1 << 3, 45 TextIteratorEmitsOriginalText = 1 << 3,
46 TextIteratorStopsOnFormControls = 1 << 4, 46 TextIteratorStopsOnFormControls = 1 << 4,
47 TextIteratorEmitsImageAltText = 1 << 5, 47 TextIteratorEmitsImageAltText = 1 << 5,
48 TextIteratorEntersAuthorShadowRoots = 1 << 6, 48 TextIteratorEntersAuthorShadowRoots = 1 << 6,
49 TextIteratorEmitsObjectReplacementCharacter = 1 << 7 49 TextIteratorEmitsObjectReplacementCharacter = 1 << 7,
50 TextIteratorDoesNotBreakAtReplacedElement = 1 << 8
50 }; 51 };
51 typedef unsigned TextIteratorBehaviorFlags; 52 typedef unsigned TextIteratorBehaviorFlags;
52 53
53 String plainText(const Range*, TextIteratorBehaviorFlags = TextIteratorDefaultBe havior); 54 String plainText(const Range*, TextIteratorBehaviorFlags = TextIteratorDefaultBe havior);
54 String plainText(const Position& start, const Position& end, TextIteratorBehavio rFlags = TextIteratorDefaultBehavior); 55 String plainText(const Position& start, const Position& end, TextIteratorBehavio rFlags = TextIteratorDefaultBehavior);
55 PassRefPtrWillBeRawPtr<Range> findPlainText(const Range*, const String&, FindOpt ions); 56 PassRefPtrWillBeRawPtr<Range> findPlainText(const Range*, const String&, FindOpt ions);
56 void findPlainText(const Position& inputStart, const Position& inputEnd, const S tring&, FindOptions, Position& resultStart, Position& resultEnd); 57 void findPlainText(const Position& inputStart, const Position& inputEnd, const S tring&, FindOptions, Position& resultStart, Position& resultEnd);
57 58
58 class BitStack { 59 class BitStack {
59 public: 60 public:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 Node* node() const; 113 Node* node() const;
113 114
114 Document* ownerDocument() const; 115 Document* ownerDocument() const;
115 Node* startContainer() const; 116 Node* startContainer() const;
116 Node* endContainer() const; 117 Node* endContainer() const;
117 int startOffset() const; 118 int startOffset() const;
118 int endOffset() const; 119 int endOffset() const;
119 Position startPosition() const; 120 Position startPosition() const;
120 Position endPosition() const; 121 Position endPosition() const;
121 122
123 bool breaksAtReplacedElement() { return m_breaksAtReplacedElement; }
124
122 // Computes the length of the given range using a text iterator. The default 125 // Computes the length of the given range using a text iterator. The default
123 // iteration behavior is to always emit object replacement characters for 126 // iteration behavior is to always emit object replacement characters for
124 // replaced elements. When |forSelectionPreservation| is set to true, it 127 // replaced elements. When |forSelectionPreservation| is set to true, it
125 // also emits spaces for other non-text nodes using the 128 // also emits spaces for other non-text nodes using the
126 // |TextIteratorEmitsCharactersBetweenAllVisiblePosition| mode. 129 // |TextIteratorEmitsCharactersBetweenAllVisiblePosition| mode.
127 static int rangeLength(const Range*, bool forSelectionPreservation = false); 130 static int rangeLength(const Range*, bool forSelectionPreservation = false);
128 static int rangeLength(const Position& start, const Position& end, bool forS electionPreservation = false); 131 static int rangeLength(const Position& start, const Position& end, bool forS electionPreservation = false);
129 static PassRefPtrWillBeRawPtr<Range> subrange(Range* entireRange, int charac terOffset, int characterCount); 132 static PassRefPtrWillBeRawPtr<Range> subrange(Range* entireRange, int charac terOffset, int characterCount);
130 static void subrange(Position& start, Position& end, int characterOffset, in t characterCount); 133 static void subrange(Position& start, Position& end, int characterOffset, in t characterCount);
131 134
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // Used when the iteration should stop if form controls are reached. 224 // Used when the iteration should stop if form controls are reached.
222 bool m_stopsOnFormControls; 225 bool m_stopsOnFormControls;
223 // Used when m_stopsOnFormControls is set to determine if the iterator shoul d keep advancing. 226 // Used when m_stopsOnFormControls is set to determine if the iterator shoul d keep advancing.
224 bool m_shouldStop; 227 bool m_shouldStop;
225 228
226 bool m_emitsImageAltText; 229 bool m_emitsImageAltText;
227 230
228 bool m_entersAuthorShadowRoots; 231 bool m_entersAuthorShadowRoots;
229 232
230 bool m_emitsObjectReplacementCharacter; 233 bool m_emitsObjectReplacementCharacter;
234
235 bool m_breaksAtReplacedElement;
231 }; 236 };
232 237
233 // Iterates through the DOM range, returning all the text, and 0-length boundari es 238 // Iterates through the DOM range, returning all the text, and 0-length boundari es
234 // at points where replaced elements break up the text flow. The text comes back in 239 // at points where replaced elements break up the text flow. The text comes back in
235 // chunks so as to optimize for performance of the iteration. 240 // chunks so as to optimize for performance of the iteration.
236 class SimplifiedBackwardsTextIterator { 241 class SimplifiedBackwardsTextIterator {
237 STACK_ALLOCATED(); 242 STACK_ALLOCATED();
238 public: 243 public:
239 explicit SimplifiedBackwardsTextIterator(const Range*, TextIteratorBehaviorF lags = TextIteratorDefaultBehavior); 244 explicit SimplifiedBackwardsTextIterator(const Range*, TextIteratorBehaviorF lags = TextIteratorDefaultBehavior);
240 SimplifiedBackwardsTextIterator(const Position& start, const Position& end, TextIteratorBehaviorFlags = TextIteratorDefaultBehavior); 245 SimplifiedBackwardsTextIterator(const Position& start, const Position& end, TextIteratorBehaviorFlags = TextIteratorDefaultBehavior);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 private: 402 private:
398 Vector<UChar> m_buffer; 403 Vector<UChar> m_buffer;
399 // Did we have to look ahead in the textIterator to confirm the current chun k? 404 // Did we have to look ahead in the textIterator to confirm the current chun k?
400 bool m_didLookAhead; 405 bool m_didLookAhead;
401 TextIterator m_textIterator; 406 TextIterator m_textIterator;
402 }; 407 };
403 408
404 } 409 }
405 410
406 #endif 411 #endif
OLDNEW
« no previous file with comments | « LayoutTests/editing/text-iterator/findString-expected.txt ('k') | Source/core/editing/TextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698