| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "core/html/HTMLLIElement.h" | 48 #include "core/html/HTMLLIElement.h" |
| 49 #include "core/html/HTMLParagraphElement.h" | 49 #include "core/html/HTMLParagraphElement.h" |
| 50 #include "core/html/HTMLSpanElement.h" | 50 #include "core/html/HTMLSpanElement.h" |
| 51 #include "core/html/HTMLTableCellElement.h" | 51 #include "core/html/HTMLTableCellElement.h" |
| 52 #include "core/html/HTMLUListElement.h" | 52 #include "core/html/HTMLUListElement.h" |
| 53 #include "core/layout/LayoutObject.h" | 53 #include "core/layout/LayoutObject.h" |
| 54 #include "core/layout/LayoutTableCell.h" | 54 #include "core/layout/LayoutTableCell.h" |
| 55 #include "wtf/Assertions.h" | 55 #include "wtf/Assertions.h" |
| 56 #include "wtf/StdLibExtras.h" | 56 #include "wtf/StdLibExtras.h" |
| 57 #include "wtf/text/StringBuilder.h" | 57 #include "wtf/text/StringBuilder.h" |
| 58 #include "wtf/text/Unicode.h" |
| 58 | 59 |
| 59 namespace blink { | 60 namespace blink { |
| 60 | 61 |
| 61 using namespace HTMLNames; | 62 using namespace HTMLNames; |
| 62 | 63 |
| 63 // Atomic means that the node has no children, or has children which are ignored
for the | 64 // Atomic means that the node has no children, or has children which are ignored
for the |
| 64 // purposes of editing. | 65 // purposes of editing. |
| 65 bool isAtomicNode(const Node *node) | 66 bool isAtomicNode(const Node *node) |
| 66 { | 67 { |
| 67 return node && (!node->hasChildren() || editingIgnoresContent(node)); | 68 return node && (!node->hasChildren() || editingIgnoresContent(node)); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 const String& text = toText(node)->data(); | 550 const String& text = toText(node)->data(); |
| 550 if (text.is8Bit()) | 551 if (text.is8Bit()) |
| 551 return current - 1; // TODO(nona): Good to support CR x LF. | 552 return current - 1; // TODO(nona): Good to support CR x LF. |
| 552 TextBreakIterator* iterator = cursorMovementIterator(text.characters16(), te
xt.length()); | 553 TextBreakIterator* iterator = cursorMovementIterator(text.characters16(), te
xt.length()); |
| 553 if (!iterator) | 554 if (!iterator) |
| 554 return current - 1; | 555 return current - 1; |
| 555 const int result = iterator->preceding(current); | 556 const int result = iterator->preceding(current); |
| 556 return result == TextBreakDone ? current - 1 : result; | 557 return result == TextBreakDone ? current - 1 : result; |
| 557 } | 558 } |
| 558 | 559 |
| 559 static int uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int current
) | 560 static int uncheckedPreviousOffsetForBackwardDeletion(const Node* node, int curr
ent) |
| 560 { | 561 { |
| 561 return n->layoutObject() ? n->layoutObject()->previousOffsetForBackwardDelet
ion(current) : current - 1; | 562 DCHECK_GE(current, 0); |
| 563 if (current <= 1) |
| 564 return 0; |
| 565 if (!node->isTextNode()) |
| 566 return current - 1; |
| 567 |
| 568 const String& text = toText(node)->data(); |
| 569 DCHECK(static_cast<unsigned>(current - 1) < text.length()); |
| 570 if (U16_IS_TRAIL(text[--current])) |
| 571 --current; |
| 572 if (current < 0) |
| 573 current = 0; |
| 574 return current; |
| 562 } | 575 } |
| 563 | 576 |
| 564 int uncheckedNextOffset(const Node* node, int current) | 577 int uncheckedNextOffset(const Node* node, int current) |
| 565 { | 578 { |
| 566 if (!node->isTextNode()) | 579 if (!node->isTextNode()) |
| 567 return current + 1; | 580 return current + 1; |
| 568 const String& text = toText(node)->data(); | 581 const String& text = toText(node)->data(); |
| 569 if (text.is8Bit()) | 582 if (text.is8Bit()) |
| 570 return current + 1; // TODO(nona): Good to support CR x LF. | 583 return current + 1; // TODO(nona): Good to support CR x LF. |
| 571 TextBreakIterator* iterator = cursorMovementIterator(text.characters16(), te
xt.length()); | 584 TextBreakIterator* iterator = cursorMovementIterator(text.characters16(), te
xt.length()); |
| (...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 // instead of possibly at the end of the last node before the selection | 1677 // instead of possibly at the end of the last node before the selection |
| 1665 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1678 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
| 1666 } | 1679 } |
| 1667 | 1680 |
| 1668 bool isTextSecurityNode(const Node* node) | 1681 bool isTextSecurityNode(const Node* node) |
| 1669 { | 1682 { |
| 1670 return node && node->layoutObject() && node->layoutObject()->style()->textSe
curity() != TSNONE; | 1683 return node && node->layoutObject() && node->layoutObject()->style()->textSe
curity() != TSNONE; |
| 1671 } | 1684 } |
| 1672 | 1685 |
| 1673 } // namespace blink | 1686 } // namespace blink |
| OLD | NEW |