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

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

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 return i - textEnd; 45 return i - textEnd;
46 } 46 }
47 47
48 return length - textEnd; 48 return length - textEnd;
49 } 49 }
50 50
51 static int maxOffsetIncludingCollapsedSpaces(Node* node) 51 static int maxOffsetIncludingCollapsedSpaces(Node* node)
52 { 52 {
53 int offset = caretMaxOffset(node); 53 int offset = caretMaxOffset(node);
54 54
55 if (node->renderer() && node->renderer()->isText()) 55 if (node->layoutObject() && node->layoutObject()->isText())
56 offset += collapsedSpaceLength(toLayoutText(node->renderer()), offset); 56 offset += collapsedSpaceLength(toLayoutText(node->layoutObject()), offse t);
57 57
58 return offset; 58 return offset;
59 } 59 }
60 60
61 SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range* r, TextIteratorBehaviorFlags behavior) 61 SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range* r, TextIteratorBehaviorFlags behavior)
62 : m_node(nullptr) 62 : m_node(nullptr)
63 , m_offset(0) 63 , m_offset(0)
64 , m_handledNode(false) 64 , m_handledNode(false)
65 , m_handledChildren(false) 65 , m_handledChildren(false)
66 , m_startNode(nullptr) 66 , m_startNode(nullptr)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 m_shouldStop = true; 178 m_shouldStop = true;
179 return; 179 return;
180 } 180 }
181 181
182 m_positionNode = nullptr; 182 m_positionNode = nullptr;
183 m_textLength = 0; 183 m_textLength = 0;
184 184
185 while (m_node && !m_havePassedStartNode) { 185 while (m_node && !m_havePassedStartNode) {
186 // Don't handle node if we start iterating at [node, 0]. 186 // Don't handle node if we start iterating at [node, 0].
187 if (!m_handledNode && !(m_node == m_endNode && !m_endOffset)) { 187 if (!m_handledNode && !(m_node == m_endNode && !m_endOffset)) {
188 LayoutObject* renderer = m_node->renderer(); 188 LayoutObject* renderer = m_node->layoutObject();
189 if (renderer && renderer->isText() && m_node->nodeType() == Node::TE XT_NODE) { 189 if (renderer && renderer->isText() && m_node->nodeType() == Node::TE XT_NODE) {
190 // FIXME: What about CDATA_SECTION_NODE? 190 // FIXME: What about CDATA_SECTION_NODE?
191 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) 191 if (renderer->style()->visibility() == VISIBLE && m_offset > 0)
192 m_handledNode = handleTextNode(); 192 m_handledNode = handleTextNode();
193 } else if (renderer && (renderer->isLayoutPart() || TextIterator::su pportsAltText(m_node))) { 193 } else if (renderer && (renderer->isLayoutPart() || TextIterator::su pportsAltText(m_node))) {
194 if (renderer->style()->visibility() == VISIBLE && m_offset > 0) 194 if (renderer->style()->visibility() == VISIBLE && m_offset > 0)
195 m_handledNode = handleReplacedElement(); 195 m_handledNode = handleReplacedElement();
196 } else { 196 } else {
197 m_handledNode = handleNonTextNode(); 197 m_handledNode = handleNonTextNode();
198 } 198 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 m_textOffset = m_positionStartOffset - offsetInNode; 274 m_textOffset = m_positionStartOffset - offsetInNode;
275 m_textContainer = text; 275 m_textContainer = text;
276 m_singleCharacterBuffer = 0; 276 m_singleCharacterBuffer = 0;
277 RELEASE_ASSERT(static_cast<unsigned>(m_textOffset + m_textLength) <= text.le ngth()); 277 RELEASE_ASSERT(static_cast<unsigned>(m_textOffset + m_textLength) <= text.le ngth());
278 278
279 return !m_shouldHandleFirstLetter; 279 return !m_shouldHandleFirstLetter;
280 } 280 }
281 281
282 LayoutText* SimplifiedBackwardsTextIterator::handleFirstLetter(int& startOffset, int& offsetInNode) 282 LayoutText* SimplifiedBackwardsTextIterator::handleFirstLetter(int& startOffset, int& offsetInNode)
283 { 283 {
284 LayoutText* renderer = toLayoutText(m_node->renderer()); 284 LayoutText* renderer = toLayoutText(m_node->layoutObject());
285 startOffset = (m_node == m_startNode) ? m_startOffset : 0; 285 startOffset = (m_node == m_startNode) ? m_startOffset : 0;
286 286
287 if (!renderer->isTextFragment()) { 287 if (!renderer->isTextFragment()) {
288 offsetInNode = 0; 288 offsetInNode = 0;
289 return renderer; 289 return renderer;
290 } 290 }
291 291
292 LayoutTextFragment* fragment = toLayoutTextFragment(renderer); 292 LayoutTextFragment* fragment = toLayoutTextFragment(renderer);
293 int offsetAfterFirstLetter = fragment->start(); 293 int offsetAfterFirstLetter = fragment->start();
294 if (startOffset >= offsetAfterFirstLetter) { 294 if (startOffset >= offsetAfterFirstLetter) {
295 ASSERT(!m_shouldHandleFirstLetter); 295 ASSERT(!m_shouldHandleFirstLetter);
296 offsetInNode = offsetAfterFirstLetter; 296 offsetInNode = offsetAfterFirstLetter;
297 return renderer; 297 return renderer;
298 } 298 }
299 299
300 if (!m_shouldHandleFirstLetter && offsetAfterFirstLetter < m_offset) { 300 if (!m_shouldHandleFirstLetter && offsetAfterFirstLetter < m_offset) {
301 m_shouldHandleFirstLetter = true; 301 m_shouldHandleFirstLetter = true;
302 offsetInNode = offsetAfterFirstLetter; 302 offsetInNode = offsetAfterFirstLetter;
303 return renderer; 303 return renderer;
304 } 304 }
305 305
306 m_shouldHandleFirstLetter = false; 306 m_shouldHandleFirstLetter = false;
307 offsetInNode = 0; 307 offsetInNode = 0;
308 308
309 ASSERT(fragment->isRemainingTextRenderer()); 309 ASSERT(fragment->isRemainingTextRenderer());
310 ASSERT(fragment->firstLetterPseudoElement()); 310 ASSERT(fragment->firstLetterPseudoElement());
311 311
312 LayoutObject* pseudoElementRenderer = fragment->firstLetterPseudoElement()-> renderer(); 312 LayoutObject* pseudoElementRenderer = fragment->firstLetterPseudoElement()-> layoutObject();
313 ASSERT(pseudoElementRenderer); 313 ASSERT(pseudoElementRenderer);
314 ASSERT(pseudoElementRenderer->slowFirstChild()); 314 ASSERT(pseudoElementRenderer->slowFirstChild());
315 LayoutText* firstLetterRenderer = toLayoutText(pseudoElementRenderer->slowFi rstChild()); 315 LayoutText* firstLetterRenderer = toLayoutText(pseudoElementRenderer->slowFi rstChild());
316 316
317 m_offset = firstLetterRenderer->caretMaxOffset(); 317 m_offset = firstLetterRenderer->caretMaxOffset();
318 m_offset += collapsedSpaceLength(firstLetterRenderer, m_offset); 318 m_offset += collapsedSpaceLength(firstLetterRenderer, m_offset);
319 319
320 return firstLetterRenderer; 320 return firstLetterRenderer;
321 } 321 }
322 322
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 396 }
397 397
398 Position SimplifiedBackwardsTextIterator::endPosition() const 398 Position SimplifiedBackwardsTextIterator::endPosition() const
399 { 399 {
400 if (m_positionNode) 400 if (m_positionNode)
401 return createLegacyEditingPosition(m_positionNode, m_positionEndOffset); 401 return createLegacyEditingPosition(m_positionNode, m_positionEndOffset);
402 return createLegacyEditingPosition(m_startNode, m_startOffset); 402 return createLegacyEditingPosition(m_startNode, m_startOffset);
403 } 403 }
404 404
405 } // namespace blink 405 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/iterators/FullyClippedStateStack.cpp ('k') | Source/core/editing/iterators/TextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698