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

Side by Side Diff: third_party/WebKit/Source/core/editing/EditingUtilities.cpp

Issue 1611953002: Rename editableRootElementForPosition() to rootEditableElementOf() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-01-21T18:23:57 Created 4 years, 11 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
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 int comparePositions(const VisiblePosition& a, const VisiblePosition& b) 214 int comparePositions(const VisiblePosition& a, const VisiblePosition& b)
215 { 215 {
216 return comparePositions(a.deepEquivalent(), b.deepEquivalent()); 216 return comparePositions(a.deepEquivalent(), b.deepEquivalent());
217 } 217 }
218 218
219 ContainerNode* highestEditableRoot(const Position& position, EditableType editab leType) 219 ContainerNode* highestEditableRoot(const Position& position, EditableType editab leType)
220 { 220 {
221 if (position.isNull()) 221 if (position.isNull())
222 return 0; 222 return 0;
223 223
224 ContainerNode* highestRoot = editableRootElementForPosition(position, editab leType); 224 ContainerNode* highestRoot = rootEditableElementOf(position, editableType);
225 if (!highestRoot) 225 if (!highestRoot)
226 return 0; 226 return 0;
227 227
228 if (isHTMLBodyElement(*highestRoot)) 228 if (isHTMLBodyElement(*highestRoot))
229 return highestRoot; 229 return highestRoot;
230 230
231 ContainerNode* node = highestRoot->parentNode(); 231 ContainerNode* node = highestRoot->parentNode();
tkent 2016/01/21 13:19:38 Not related to this CL, but I wonder why we need t
tkent 2016/01/26 04:23:59 I realized this function could return a Document i
232 while (node) { 232 while (node) {
233 if (node->hasEditableStyle(editableType)) 233 if (node->hasEditableStyle(editableType))
234 highestRoot = node; 234 highestRoot = node;
235 if (isHTMLBodyElement(*node)) 235 if (isHTMLBodyElement(*node))
236 break; 236 break;
237 node = node->parentNode(); 237 node = node->parentNode();
238 } 238 }
239 239
240 return highestRoot; 240 return highestRoot;
241 } 241 }
(...skipping 22 matching lines...) Expand all
264 } 264 }
265 265
266 bool isEditablePosition(const PositionInComposedTree& p, EditableType editableTy pe, EUpdateStyle updateStyle) 266 bool isEditablePosition(const PositionInComposedTree& p, EditableType editableTy pe, EUpdateStyle updateStyle)
267 { 267 {
268 return isEditablePosition(toPositionInDOMTree(p), editableType, updateStyle) ; 268 return isEditablePosition(toPositionInDOMTree(p), editableType, updateStyle) ;
269 } 269 }
270 270
271 bool isAtUnsplittableElement(const Position& pos) 271 bool isAtUnsplittableElement(const Position& pos)
272 { 272 {
273 Node* node = pos.anchorNode(); 273 Node* node = pos.anchorNode();
274 return (node == editableRootElementForPosition(pos) || node == enclosingNode OfType(pos, &isTableCell)); 274 return (node == rootEditableElementOf(pos) || node == enclosingNodeOfType(po s, &isTableCell));
275 } 275 }
276 276
277 277
278 bool isRichlyEditablePosition(const Position& p, EditableType editableType) 278 bool isRichlyEditablePosition(const Position& p, EditableType editableType)
279 { 279 {
280 Node* node = p.anchorNode(); 280 Node* node = p.anchorNode();
281 if (!node) 281 if (!node)
282 return false; 282 return false;
283 283
284 if (isRenderedHTMLTableElement(node)) 284 if (isRenderedHTMLTableElement(node))
285 node = node->parentNode(); 285 node = node->parentNode();
286 286
287 return node->layoutObjectIsRichlyEditable(editableType); 287 return node->layoutObjectIsRichlyEditable(editableType);
288 } 288 }
289 289
290 Element* editableRootElementForPosition(const Position& p, EditableType editable Type) 290 Element* rootEditableElementOf(const Position& p, EditableType editableType)
291 { 291 {
292 Node* node = p.computeContainerNode(); 292 Node* node = p.computeContainerNode();
293 if (!node) 293 if (!node)
294 return 0; 294 return 0;
295 295
296 if (isRenderedHTMLTableElement(node)) 296 if (isRenderedHTMLTableElement(node))
297 node = node->parentNode(); 297 node = node->parentNode();
298 298
299 return node->rootEditableElement(editableType); 299 return node->rootEditableElement(editableType);
300 } 300 }
301 301
302 Element* editableRootElementForPosition(const PositionInComposedTree& p, Editabl eType editableType) 302 Element* rootEditableElementOf(const PositionInComposedTree& p, EditableType edi tableType)
303 { 303 {
304 return editableRootElementForPosition(toPositionInDOMTree(p), editableType); 304 return rootEditableElementOf(toPositionInDOMTree(p), editableType);
305 } 305 }
306 306
307 // TODO(yosin) This does not handle [table, 0] correctly. 307 // TODO(yosin) This does not handle [table, 0] correctly.
308 Element* rootEditableElementOf(const VisiblePosition& visiblePosition) 308 Element* rootEditableElementOf(const VisiblePosition& visiblePosition)
309 { 309 {
310 Node* anchorNode = visiblePosition.deepEquivalent().anchorNode(); 310 Node* anchorNode = visiblePosition.deepEquivalent().anchorNode();
311 return anchorNode ? anchorNode->rootEditableElement() : nullptr; 311 return anchorNode ? anchorNode->rootEditableElement() : nullptr;
312 } 312 }
313 313
314 // Finds the enclosing element until which the tree can be split. 314 // Finds the enclosing element until which the tree can be split.
315 // When a user hits ENTER, he/she won't expect this element to be split into two . 315 // When a user hits ENTER, he/she won't expect this element to be split into two .
316 // You may pass it as the second argument of splitTreeToNode. 316 // You may pass it as the second argument of splitTreeToNode.
317 Element* unsplittableElementForPosition(const Position& p) 317 Element* unsplittableElementForPosition(const Position& p)
318 { 318 {
319 // Since enclosingNodeOfType won't search beyond the highest root editable n ode, 319 // Since enclosingNodeOfType won't search beyond the highest root editable n ode,
320 // this code works even if the closest table cell was outside of the root ed itable node. 320 // this code works even if the closest table cell was outside of the root ed itable node.
321 Element* enclosingCell = toElement(enclosingNodeOfType(p, &isTableCell)); 321 Element* enclosingCell = toElement(enclosingNodeOfType(p, &isTableCell));
322 if (enclosingCell) 322 if (enclosingCell)
323 return enclosingCell; 323 return enclosingCell;
324 324
325 return editableRootElementForPosition(p); 325 return rootEditableElementOf(p);
326 } 326 }
327 327
328 template <typename Strategy> 328 template <typename Strategy>
329 PositionTemplate<Strategy> nextCandidateAlgorithm(const PositionTemplate<Strateg y>& position) 329 PositionTemplate<Strategy> nextCandidateAlgorithm(const PositionTemplate<Strateg y>& position)
330 { 330 {
331 TRACE_EVENT0("input", "EditingUtility::nextCandidateAlgorithm"); 331 TRACE_EVENT0("input", "EditingUtility::nextCandidateAlgorithm");
332 PositionIteratorAlgorithm<Strategy> p(position); 332 PositionIteratorAlgorithm<Strategy> p(position);
333 333
334 p.increment(); 334 p.increment();
335 while (!p.atEnd()) { 335 while (!p.atEnd()) {
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 // instead of possibly at the end of the last node before the selection 1651 // instead of possibly at the end of the last node before the selection
1652 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); 1652 return mostForwardCaretPosition(visiblePosition.deepEquivalent());
1653 } 1653 }
1654 1654
1655 bool isTextSecurityNode(const Node* node) 1655 bool isTextSecurityNode(const Node* node)
1656 { 1656 {
1657 return node && node->layoutObject() && node->layoutObject()->style()->textSe curity() != TSNONE; 1657 return node && node->layoutObject() && node->layoutObject()->style()->textSe curity() != TSNONE;
1658 } 1658 }
1659 1659
1660 } // namespace blink 1660 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698