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

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

Issue 22288004: Refactoring code in highestEditableRoot to avoid a redundant call to rendererIsEditable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | no next file » | 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 Node* highestEditableRoot(const Position& position, EditableType editableType) 109 Node* highestEditableRoot(const Position& position, EditableType editableType)
110 { 110 {
111 Node* node = position.deprecatedNode(); 111 Node* node = position.deprecatedNode();
112 if (!node) 112 if (!node)
113 return 0; 113 return 0;
114 114
115 Node* highestRoot = editableRootForPosition(position, editableType); 115 Node* highestRoot = editableRootForPosition(position, editableType);
116 if (!highestRoot) 116 if (!highestRoot)
117 return 0; 117 return 0;
118 118
119 node = highestRoot; 119 if (highestRoot->hasTagName(bodyTag))
120 return highestRoot;
121
122 node = highestRoot->parentNode();
120 while (node) { 123 while (node) {
121 if (node->rendererIsEditable(editableType)) 124 if (node->rendererIsEditable(editableType))
122 highestRoot = node; 125 highestRoot = node;
123 if (node->hasTagName(bodyTag)) 126 if (node->hasTagName(bodyTag))
124 break; 127 break;
125 node = node->parentNode(); 128 node = node->parentNode();
126 } 129 }
127 130
128 return highestRoot; 131 return highestRoot;
129 } 132 }
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 // if the selection starts just before a paragraph break, skip over it 1163 // if the selection starts just before a paragraph break, skip over it
1161 if (isEndOfParagraph(visiblePosition)) 1164 if (isEndOfParagraph(visiblePosition))
1162 return visiblePosition.next().deepEquivalent().downstream(); 1165 return visiblePosition.next().deepEquivalent().downstream();
1163 1166
1164 // otherwise, make sure to be at the start of the first selected node, 1167 // otherwise, make sure to be at the start of the first selected node,
1165 // instead of possibly at the end of the last node before the selection 1168 // instead of possibly at the end of the last node before the selection
1166 return visiblePosition.deepEquivalent().downstream(); 1169 return visiblePosition.deepEquivalent().downstream();
1167 } 1170 }
1168 1171
1169 } // namespace WebCore 1172 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698