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

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

Issue 196683003: Use new is*Element() helper functions more in editing code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | Source/core/editing/htmlediting.cpp » ('j') | 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 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 21 matching lines...) Expand all
32 #include "bindings/v8/ExceptionStatePlaceholder.h" 32 #include "bindings/v8/ExceptionStatePlaceholder.h"
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
35 #include "core/dom/NodeTraversal.h" 35 #include "core/dom/NodeTraversal.h"
36 #include "core/dom/Position.h" 36 #include "core/dom/Position.h"
37 #include "core/dom/Text.h" 37 #include "core/dom/Text.h"
38 #include "core/editing/RenderedPosition.h" 38 #include "core/editing/RenderedPosition.h"
39 #include "core/editing/TextIterator.h" 39 #include "core/editing/TextIterator.h"
40 #include "core/editing/VisiblePosition.h" 40 #include "core/editing/VisiblePosition.h"
41 #include "core/editing/htmlediting.h" 41 #include "core/editing/htmlediting.h"
42 #include "core/html/HTMLBRElement.h"
42 #include "core/rendering/InlineTextBox.h" 43 #include "core/rendering/InlineTextBox.h"
43 #include "core/rendering/RenderBlockFlow.h" 44 #include "core/rendering/RenderBlockFlow.h"
44 #include "core/rendering/RenderObject.h" 45 #include "core/rendering/RenderObject.h"
45 #include "platform/text/TextBoundaries.h" 46 #include "platform/text/TextBoundaries.h"
46 47
47 namespace WebCore { 48 namespace WebCore {
48 49
49 using namespace HTMLNames; 50 using namespace HTMLNames;
50 using namespace WTF::Unicode; 51 using namespace WTF::Unicode;
51 52
(...skipping 30 matching lines...) Expand all
82 Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), ed itableType); 83 Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), ed itableType);
83 Node* previousNode = previousLeafWithSameEditability(node, editableType); 84 Node* previousNode = previousLeafWithSameEditability(node, editableType);
84 85
85 while (previousNode && (!previousNode->renderer() || inSameLine(VisiblePosit ion(firstPositionInOrBeforeNode(previousNode)), visiblePosition))) 86 while (previousNode && (!previousNode->renderer() || inSameLine(VisiblePosit ion(firstPositionInOrBeforeNode(previousNode)), visiblePosition)))
86 previousNode = previousLeafWithSameEditability(previousNode, editableTyp e); 87 previousNode = previousLeafWithSameEditability(previousNode, editableTyp e);
87 88
88 while (previousNode && !previousNode->isShadowRoot()) { 89 while (previousNode && !previousNode->isShadowRoot()) {
89 if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), edita bleType) != highestRoot) 90 if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), edita bleType) != highestRoot)
90 break; 91 break;
91 92
92 Position pos = previousNode->hasTagName(brTag) ? positionBeforeNode(prev iousNode) : 93 Position pos = isHTMLBRElement(*previousNode) ? positionBeforeNode(previ ousNode) :
93 createLegacyEditingPosition(previousNode, caretMaxOffset(previousNod e)); 94 createLegacyEditingPosition(previousNode, caretMaxOffset(previousNod e));
94 95
95 if (pos.isCandidate()) 96 if (pos.isCandidate())
96 return pos; 97 return pos;
97 98
98 previousNode = previousLeafWithSameEditability(previousNode, editableTyp e); 99 previousNode = previousLeafWithSameEditability(previousNode, editableTyp e);
99 } 100 }
100 return Position(); 101 return Position();
101 } 102 }
102 103
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 807
807 endNode = endBox->renderer().nonPseudoNode(); 808 endNode = endBox->renderer().nonPseudoNode();
808 if (endNode) 809 if (endNode)
809 break; 810 break;
810 811
811 endBox = endBox->prevLeafChild(); 812 endBox = endBox->prevLeafChild();
812 } 813 }
813 } 814 }
814 815
815 Position pos; 816 Position pos;
816 if (endNode->hasTagName(brTag)) 817 if (isHTMLBRElement(*endNode))
817 pos = positionBeforeNode(endNode); 818 pos = positionBeforeNode(endNode);
818 else if (endBox->isInlineTextBox() && endNode->isTextNode()) { 819 else if (endBox->isInlineTextBox() && endNode->isTextNode()) {
819 InlineTextBox* endTextBox = toInlineTextBox(endBox); 820 InlineTextBox* endTextBox = toInlineTextBox(endBox);
820 int endOffset = endTextBox->start(); 821 int endOffset = endTextBox->start();
821 if (!endTextBox->isLineBreak()) 822 if (!endTextBox->isLineBreak())
822 endOffset += endTextBox->len(); 823 endOffset += endTextBox->len();
823 pos = Position(toText(endNode), endOffset); 824 pos = Position(toText(endNode), endOffset);
824 } else 825 } else
825 pos = positionAfterNode(endNode); 826 pos = positionAfterNode(endNode);
826 827
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 { 1385 {
1385 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); 1386 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c);
1386 } 1387 }
1387 1388
1388 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction) 1389 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction)
1389 { 1390 {
1390 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); 1391 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c);
1391 } 1392 }
1392 1393
1393 } 1394 }
OLDNEW
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | Source/core/editing/htmlediting.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698