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

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

Issue 24278008: [oilpan] Handlify Nodes in htmlediting (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 3 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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 return true; 723 return true;
724 } 724 }
725 return false; 725 return false;
726 } 726 }
727 727
728 static bool shouldEmitTabBeforeNode(Node* node) 728 static bool shouldEmitTabBeforeNode(Node* node)
729 { 729 {
730 RenderObject* r = node->renderer(); 730 RenderObject* r = node->renderer();
731 731
732 // Table cells are delimited by tabs. 732 // Table cells are delimited by tabs.
733 if (!r || !isTableCell(node)) 733 if (!r || !isTableCell(adoptRawResult(node)))
734 return false; 734 return false;
735 735
736 // Want a tab before every cell other than the first one 736 // Want a tab before every cell other than the first one
737 RenderTableCell* rc = toRenderTableCell(r); 737 RenderTableCell* rc = toRenderTableCell(r);
738 RenderTable* t = rc->table(); 738 RenderTable* t = rc->table();
739 return t && (t->cellBefore(rc) || t->cellAbove(rc)); 739 return t && (t->cellBefore(rc) || t->cellAbove(rc));
740 } 740 }
741 741
742 static bool shouldEmitNewlineForNode(Node* node, bool emitsOriginalText) 742 static bool shouldEmitNewlineForNode(Node* node, bool emitsOriginalText)
743 { 743 {
(...skipping 26 matching lines...) Expand all
770 || node->hasTagName(listingTag) 770 || node->hasTagName(listingTag)
771 || node->hasTagName(olTag) 771 || node->hasTagName(olTag)
772 || node->hasTagName(pTag) 772 || node->hasTagName(pTag)
773 || node->hasTagName(preTag) 773 || node->hasTagName(preTag)
774 || node->hasTagName(trTag) 774 || node->hasTagName(trTag)
775 || node->hasTagName(ulTag)); 775 || node->hasTagName(ulTag));
776 } 776 }
777 777
778 // Need to make an exception for table cells, because they are blocks, but w e 778 // Need to make an exception for table cells, because they are blocks, but w e
779 // want them tab-delimited rather than having newlines before and after. 779 // want them tab-delimited rather than having newlines before and after.
780 if (isTableCell(node)) 780 if (isTableCell(adoptRawResult(node)))
781 return false; 781 return false;
782 782
783 // Need to make an exception for table row elements, because they are neithe r 783 // Need to make an exception for table row elements, because they are neithe r
784 // "inline" or "RenderBlock", but we want newlines for them. 784 // "inline" or "RenderBlock", but we want newlines for them.
785 if (r->isTableRow()) { 785 if (r->isTableRow()) {
786 RenderTable* t = toRenderTableRow(r)->table(); 786 RenderTable* t = toRenderTableRow(r)->table();
787 if (t && !t->isInline()) 787 if (t && !t->isInline())
788 return true; 788 return true;
789 } 789 }
790 790
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 for (int i = textEnd; i < length; ++i) { 852 for (int i = textEnd; i < length; ++i) {
853 if (!renderer->style()->isCollapsibleWhiteSpace(characters[i])) 853 if (!renderer->style()->isCollapsibleWhiteSpace(characters[i]))
854 return i - textEnd; 854 return i - textEnd;
855 } 855 }
856 856
857 return length - textEnd; 857 return length - textEnd;
858 } 858 }
859 859
860 static int maxOffsetIncludingCollapsedSpaces(Node* node) 860 static int maxOffsetIncludingCollapsedSpaces(Node* node)
861 { 861 {
862 int offset = caretMaxOffset(node); 862 int offset = caretMaxOffset(adoptRawResult(node));
863 863
864 if (node->renderer() && node->renderer()->isText()) 864 if (node->renderer() && node->renderer()->isText())
865 offset += collapsedSpaceLength(toRenderText(node->renderer()), offset); 865 offset += collapsedSpaceLength(toRenderText(node->renderer()), offset);
866 866
867 return offset; 867 return offset;
868 } 868 }
869 869
870 // Whether or not we should emit a character as we enter m_node (if it's a conta iner) or as we hit it (if it's atomic). 870 // Whether or not we should emit a character as we enter m_node (if it's a conta iner) or as we hit it (if it's atomic).
871 bool TextIterator::shouldRepresentNodeOffsetZero() 871 bool TextIterator::shouldRepresentNodeOffsetZero()
872 { 872 {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 return; 1188 return;
1189 } 1189 }
1190 1190
1191 if (!m_handledChildren && m_node->hasChildNodes()) { 1191 if (!m_handledChildren && m_node->hasChildNodes()) {
1192 m_node = m_node->lastChild().handle().raw(); 1192 m_node = m_node->lastChild().handle().raw();
1193 pushFullyClippedState(m_fullyClippedStack, m_node); 1193 pushFullyClippedState(m_fullyClippedStack, m_node);
1194 } else { 1194 } else {
1195 // Exit empty containers as we pass over them or containers 1195 // Exit empty containers as we pass over them or containers
1196 // where [container, 0] is where we started iterating. 1196 // where [container, 0] is where we started iterating.
1197 if (!m_handledNode 1197 if (!m_handledNode
1198 && canHaveChildrenForEditing(m_node) 1198 && canHaveChildrenForEditing(adoptRawResult(m_node))
1199 && m_node->parentNode() 1199 && m_node->parentNode()
1200 && (!m_node->lastChild() || (m_node == m_endNode && !m_endOf fset))) { 1200 && (!m_node->lastChild() || (m_node == m_endNode && !m_endOffset ))) {
1201 exitNode(); 1201 exitNode();
1202 if (m_positionNode) { 1202 if (m_positionNode) {
1203 m_handledNode = true; 1203 m_handledNode = true;
1204 m_handledChildren = true; 1204 m_handledChildren = true;
1205 return; 1205 return;
1206 } 1206 }
1207 } 1207 }
1208 1208
1209 // Exit all other containers. 1209 // Exit all other containers.
1210 while (!m_node->previousSibling()) { 1210 while (!m_node->previousSibling()) {
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 if (!matchLength) 2589 if (!matchLength)
2590 return collapsedToBoundary(range, !(options & Backwards)); 2590 return collapsedToBoundary(range, !(options & Backwards));
2591 } 2591 }
2592 2592
2593 // Then, find the document position of the start and the end of the text. 2593 // Then, find the document position of the start and the end of the text.
2594 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls ); 2594 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls );
2595 return characterSubrange(computeRangeIterator, matchStart, matchLength); 2595 return characterSubrange(computeRangeIterator, matchStart, matchLength);
2596 } 2596 }
2597 2597
2598 } 2598 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698