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

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

Issue 935283002: Rename {Author,UserAgent}ShadowRoot to {Open,Closed}ShadowRoot. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix inspector tests Created 5 years, 10 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
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 , m_sortedTextBoxesPosition(0) 94 , m_sortedTextBoxesPosition(0)
95 , m_hasEmitted(false) 95 , m_hasEmitted(false)
96 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh aractersBetweenAllVisiblePositions) 96 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh aractersBetweenAllVisiblePositions)
97 , m_entersTextControls(behavior & TextIteratorEntersTextControls) 97 , m_entersTextControls(behavior & TextIteratorEntersTextControls)
98 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) 98 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText)
99 , m_handledFirstLetter(false) 99 , m_handledFirstLetter(false)
100 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) 100 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility)
101 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls) 101 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls)
102 , m_shouldStop(false) 102 , m_shouldStop(false)
103 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText) 103 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText)
104 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) 104 , m_entersOpenShadowRoots(behavior & TextIteratorEntersOpenShadowRoots)
105 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac ementCharacter) 105 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac ementCharacter)
106 , m_breaksAtReplacedElement(!(behavior & TextIteratorDoesNotBreakAtReplacedE lement)) 106 , m_breaksAtReplacedElement(!(behavior & TextIteratorDoesNotBreakAtReplacedE lement))
107 { 107 {
108 if (range) 108 if (range)
109 initialize(range->startPosition(), range->endPosition()); 109 initialize(range->startPosition(), range->endPosition());
110 } 110 }
111 111
112 TextIterator::TextIterator(const Position& start, const Position& end, TextItera torBehaviorFlags behavior) 112 TextIterator::TextIterator(const Position& start, const Position& end, TextItera torBehaviorFlags behavior)
113 : m_startContainer(nullptr) 113 : m_startContainer(nullptr)
114 , m_startOffset(0) 114 , m_startOffset(0)
(...skipping 11 matching lines...) Expand all
126 , m_sortedTextBoxesPosition(0) 126 , m_sortedTextBoxesPosition(0)
127 , m_hasEmitted(false) 127 , m_hasEmitted(false)
128 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh aractersBetweenAllVisiblePositions) 128 , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCh aractersBetweenAllVisiblePositions)
129 , m_entersTextControls(behavior & TextIteratorEntersTextControls) 129 , m_entersTextControls(behavior & TextIteratorEntersTextControls)
130 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) 130 , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText)
131 , m_handledFirstLetter(false) 131 , m_handledFirstLetter(false)
132 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) 132 , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility)
133 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls) 133 , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls)
134 , m_shouldStop(false) 134 , m_shouldStop(false)
135 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText) 135 , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText)
136 , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) 136 , m_entersOpenShadowRoots(behavior & TextIteratorEntersOpenShadowRoots)
137 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac ementCharacter) 137 , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplac ementCharacter)
138 , m_breaksAtReplacedElement(!(behavior & TextIteratorDoesNotBreakAtReplacedE lement)) 138 , m_breaksAtReplacedElement(!(behavior & TextIteratorDoesNotBreakAtReplacedE lement))
139 { 139 {
140 initialize(start, end); 140 initialize(start, end);
141 } 141 }
142 142
143 void TextIterator::initialize(const Position& start, const Position& end) 143 void TextIterator::initialize(const Position& start, const Position& end)
144 { 144 {
145 ASSERT(comparePositions(start, end) <= 0); 145 ASSERT(comparePositions(start, end) <= 0);
146 146
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 LayoutObject* renderer = m_node->renderer(); 262 LayoutObject* renderer = m_node->renderer();
263 if (!renderer) { 263 if (!renderer) {
264 if (m_node->isShadowRoot()) { 264 if (m_node->isShadowRoot()) {
265 // A shadow root doesn't have a renderer, but we want to visit c hildren anyway. 265 // A shadow root doesn't have a renderer, but we want to visit c hildren anyway.
266 m_iterationProgress = m_iterationProgress < HandledNode ? Handle dNode : m_iterationProgress; 266 m_iterationProgress = m_iterationProgress < HandledNode ? Handle dNode : m_iterationProgress;
267 } else { 267 } else {
268 m_iterationProgress = HandledChildren; 268 m_iterationProgress = HandledChildren;
269 } 269 }
270 } else { 270 } else {
271 // Enter author shadow roots, from youngest, if any and if necessary . 271 // Enter author shadow roots, from youngest, if any and if necessary .
272 if (m_iterationProgress < HandledAuthorShadowRoots) { 272 if (m_iterationProgress < HandledOpenShadowRoots) {
273 if (m_entersAuthorShadowRoots && m_node->isElementNode() && toEl ement(m_node)->hasAuthorShadowRoot()) { 273 if (m_entersOpenShadowRoots && m_node->isElementNode() && toElem ent(m_node)->hasOpenShadowRoot()) {
274 ShadowRoot* youngestShadowRoot = toElement(m_node)->shadowRo ot(); 274 ShadowRoot* youngestShadowRoot = toElement(m_node)->shadowRo ot();
275 ASSERT(youngestShadowRoot->type() == ShadowRoot::AuthorShado wRoot); 275 ASSERT(youngestShadowRoot->type() == ShadowRoot::OpenShadowR oot);
276 m_node = youngestShadowRoot; 276 m_node = youngestShadowRoot;
277 m_iterationProgress = HandledNone; 277 m_iterationProgress = HandledNone;
278 ++m_shadowDepth; 278 ++m_shadowDepth;
279 m_fullyClippedStack.pushFullyClippedState(m_node); 279 m_fullyClippedStack.pushFullyClippedState(m_node);
280 continue; 280 continue;
281 } 281 }
282 282
283 m_iterationProgress = HandledAuthorShadowRoots; 283 m_iterationProgress = HandledOpenShadowRoots;
284 } 284 }
285 285
286 // Enter user-agent shadow root, if necessary. 286 // Enter user-agent shadow root, if necessary.
287 if (m_iterationProgress < HandledUserAgentShadowRoot) { 287 if (m_iterationProgress < HandledClosedShadowRoot) {
288 if (m_entersTextControls && renderer->isTextControl()) { 288 if (m_entersTextControls && renderer->isTextControl()) {
289 ShadowRoot* userAgentShadowRoot = toElement(m_node)->userAge ntShadowRoot(); 289 ShadowRoot* closedShadowRoot = toElement(m_node)->closedShad owRoot();
290 ASSERT(userAgentShadowRoot->type() == ShadowRoot::UserAgentS hadowRoot); 290 ASSERT(closedShadowRoot->type() == ShadowRoot::ClosedShadowR oot);
291 m_node = userAgentShadowRoot; 291 m_node = closedShadowRoot;
292 m_iterationProgress = HandledNone; 292 m_iterationProgress = HandledNone;
293 ++m_shadowDepth; 293 ++m_shadowDepth;
294 m_fullyClippedStack.pushFullyClippedState(m_node); 294 m_fullyClippedStack.pushFullyClippedState(m_node);
295 continue; 295 continue;
296 } 296 }
297 m_iterationProgress = HandledUserAgentShadowRoot; 297 m_iterationProgress = HandledClosedShadowRoot;
298 } 298 }
299 299
300 // Handle the current node according to its type. 300 // Handle the current node according to its type.
301 if (m_iterationProgress < HandledNode) { 301 if (m_iterationProgress < HandledNode) {
302 bool handledNode = false; 302 bool handledNode = false;
303 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE) { // FIXME: What about CDATA_SECTION_NODE? 303 if (renderer->isText() && m_node->nodeType() == Node::TEXT_NODE) { // FIXME: What about CDATA_SECTION_NODE?
304 handledNode = handleTextNode(); 304 handledNode = handleTextNode();
305 } else if (renderer && (renderer->isImage() || renderer->isLayou tPart() 305 } else if (renderer && (renderer->isImage() || renderer->isLayou tPart()
306 || (m_node && m_node->isHTMLElement() 306 || (m_node && m_node->isHTMLElement()
307 && (isHTMLFormControlElement(toHTMLElement(*m_node)) 307 && (isHTMLFormControlElement(toHTMLElement(*m_node))
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 m_iterationProgress = HandledChildren; 346 m_iterationProgress = HandledChildren;
347 return; 347 return;
348 } 348 }
349 next = m_node->nextSibling(); 349 next = m_node->nextSibling();
350 } 350 }
351 351
352 if (!next && !parentNode && m_shadowDepth > 0) { 352 if (!next && !parentNode && m_shadowDepth > 0) {
353 // 4. Reached the top of a shadow root. If it's created by a uthor, then try to visit the next 353 // 4. Reached the top of a shadow root. If it's created by a uthor, then try to visit the next
354 // sibling shadow root, if any. 354 // sibling shadow root, if any.
355 ShadowRoot* shadowRoot = toShadowRoot(m_node); 355 ShadowRoot* shadowRoot = toShadowRoot(m_node);
356 if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot) { 356 if (shadowRoot->type() == ShadowRoot::OpenShadowRoot) {
357 ShadowRoot* nextShadowRoot = shadowRoot->olderShadowRoot (); 357 ShadowRoot* nextShadowRoot = shadowRoot->olderShadowRoot ();
358 if (nextShadowRoot && nextShadowRoot->type() == ShadowRo ot::AuthorShadowRoot) { 358 if (nextShadowRoot && nextShadowRoot->type() == ShadowRo ot::OpenShadowRoot) {
359 m_fullyClippedStack.pop(); 359 m_fullyClippedStack.pop();
360 m_node = nextShadowRoot; 360 m_node = nextShadowRoot;
361 m_iterationProgress = HandledNone; 361 m_iterationProgress = HandledNone;
362 // m_shadowDepth is unchanged since we exit from a s hadow root and enter another. 362 // m_shadowDepth is unchanged since we exit from a s hadow root and enter another.
363 m_fullyClippedStack.pushFullyClippedState(m_node); 363 m_fullyClippedStack.pushFullyClippedState(m_node);
364 } else { 364 } else {
365 // We are the last shadow root; exit from here and g o back to where we were. 365 // We are the last shadow root; exit from here and g o back to where we were.
366 m_node = shadowRoot->host(); 366 m_node = shadowRoot->host();
367 m_iterationProgress = HandledAuthorShadowRoots; 367 m_iterationProgress = HandledOpenShadowRoots;
368 --m_shadowDepth; 368 --m_shadowDepth;
369 m_fullyClippedStack.pop(); 369 m_fullyClippedStack.pop();
370 } 370 }
371 } else { 371 } else {
372 // If we are in a user-agent shadow root, then go back t o the host. 372 // If we are in a user-agent shadow root, then go back t o the host.
373 ASSERT(shadowRoot->type() == ShadowRoot::UserAgentShadow Root); 373 ASSERT(shadowRoot->type() == ShadowRoot::ClosedShadowRoo t);
374 m_node = shadowRoot->host(); 374 m_node = shadowRoot->host();
375 m_iterationProgress = HandledUserAgentShadowRoot; 375 m_iterationProgress = HandledClosedShadowRoot;
376 --m_shadowDepth; 376 --m_shadowDepth;
377 m_fullyClippedStack.pop(); 377 m_fullyClippedStack.pop();
378 } 378 }
379 m_handledFirstLetter = false; 379 m_handledFirstLetter = false;
380 m_firstLetterText = nullptr; 380 m_firstLetterText = nullptr;
381 continue; 381 continue;
382 } 382 }
383 } 383 }
384 m_fullyClippedStack.pop(); 384 m_fullyClippedStack.pop();
385 } 385 }
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 return createPlainText(it); 1177 return createPlainText(it);
1178 } 1178 }
1179 1179
1180 String plainText(const Position& start, const Position& end, TextIteratorBehavio rFlags behavior) 1180 String plainText(const Position& start, const Position& end, TextIteratorBehavio rFlags behavior)
1181 { 1181 {
1182 TextIterator it(start, end, behavior); 1182 TextIterator it(start, end, behavior);
1183 return createPlainText(it); 1183 return createPlainText(it);
1184 } 1184 }
1185 1185
1186 } 1186 }
OLDNEW
« no previous file with comments | « Source/core/editing/iterators/TextIterator.h ('k') | Source/core/editing/iterators/TextIteratorFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698