| OLD | NEW |
| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 node = node->parentNode(); | 296 node = node->parentNode(); |
| 297 | 297 |
| 298 return node->rootEditableElement(editableType); | 298 return node->rootEditableElement(editableType); |
| 299 } | 299 } |
| 300 | 300 |
| 301 Element* editableRootForPosition(const PositionInComposedTree& p, EditableType e
ditableType) | 301 Element* editableRootForPosition(const PositionInComposedTree& p, EditableType e
ditableType) |
| 302 { | 302 { |
| 303 return editableRootForPosition(toPositionInDOMTree(p), editableType); | 303 return editableRootForPosition(toPositionInDOMTree(p), editableType); |
| 304 } | 304 } |
| 305 | 305 |
| 306 // TODO(yosin) This does not handle [table, 0] correctly. |
| 307 Element* rootEditableElementOf(const VisiblePosition& visiblePosition) |
| 308 { |
| 309 Node* anchorNode = visiblePosition.deepEquivalent().anchorNode(); |
| 310 return anchorNode ? anchorNode->rootEditableElement() : nullptr; |
| 311 } |
| 312 |
| 306 // Finds the enclosing element until which the tree can be split. | 313 // Finds the enclosing element until which the tree can be split. |
| 307 // When a user hits ENTER, he/she won't expect this element to be split into two
. | 314 // When a user hits ENTER, he/she won't expect this element to be split into two
. |
| 308 // You may pass it as the second argument of splitTreeToNode. | 315 // You may pass it as the second argument of splitTreeToNode. |
| 309 Element* unsplittableElementForPosition(const Position& p) | 316 Element* unsplittableElementForPosition(const Position& p) |
| 310 { | 317 { |
| 311 // Since enclosingNodeOfType won't search beyond the highest root editable n
ode, | 318 // Since enclosingNodeOfType won't search beyond the highest root editable n
ode, |
| 312 // this code works even if the closest table cell was outside of the root ed
itable node. | 319 // this code works even if the closest table cell was outside of the root ed
itable node. |
| 313 Element* enclosingCell = toElement(enclosingNodeOfType(p, &isTableCell)); | 320 Element* enclosingCell = toElement(enclosingNodeOfType(p, &isTableCell)); |
| 314 if (enclosingCell) | 321 if (enclosingCell) |
| 315 return enclosingCell; | 322 return enclosingCell; |
| (...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 // if the selection starts just before a paragraph break, skip over it | 1627 // if the selection starts just before a paragraph break, skip over it |
| 1621 if (isEndOfParagraph(visiblePosition)) | 1628 if (isEndOfParagraph(visiblePosition)) |
| 1622 return mostForwardCaretPosition(nextPositionOf(visiblePosition).deepEqui
valent()); | 1629 return mostForwardCaretPosition(nextPositionOf(visiblePosition).deepEqui
valent()); |
| 1623 | 1630 |
| 1624 // otherwise, make sure to be at the start of the first selected node, | 1631 // otherwise, make sure to be at the start of the first selected node, |
| 1625 // instead of possibly at the end of the last node before the selection | 1632 // instead of possibly at the end of the last node before the selection |
| 1626 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1633 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
| 1627 } | 1634 } |
| 1628 | 1635 |
| 1629 } // namespace blink | 1636 } // namespace blink |
| OLD | NEW |