| OLD | NEW |
| 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 Loading... |
| 32 #include "sky/engine/core/dom/Document.h" | 32 #include "sky/engine/core/dom/Document.h" |
| 33 #include "sky/engine/core/dom/Element.h" | 33 #include "sky/engine/core/dom/Element.h" |
| 34 #include "sky/engine/core/dom/NodeTraversal.h" | 34 #include "sky/engine/core/dom/NodeTraversal.h" |
| 35 #include "sky/engine/core/dom/Position.h" | 35 #include "sky/engine/core/dom/Position.h" |
| 36 #include "sky/engine/core/dom/Text.h" | 36 #include "sky/engine/core/dom/Text.h" |
| 37 #include "sky/engine/core/editing/RenderedPosition.h" | 37 #include "sky/engine/core/editing/RenderedPosition.h" |
| 38 #include "sky/engine/core/editing/TextIterator.h" | 38 #include "sky/engine/core/editing/TextIterator.h" |
| 39 #include "sky/engine/core/editing/VisiblePosition.h" | 39 #include "sky/engine/core/editing/VisiblePosition.h" |
| 40 #include "sky/engine/core/editing/htmlediting.h" | 40 #include "sky/engine/core/editing/htmlediting.h" |
| 41 #include "sky/engine/core/rendering/InlineTextBox.h" | 41 #include "sky/engine/core/rendering/InlineTextBox.h" |
| 42 #include "sky/engine/core/rendering/RenderBlockFlow.h" | 42 #include "sky/engine/core/rendering/RenderParagraph.h" |
| 43 #include "sky/engine/core/rendering/RenderObject.h" | 43 #include "sky/engine/core/rendering/RenderObject.h" |
| 44 #include "sky/engine/platform/heap/Handle.h" | 44 #include "sky/engine/platform/heap/Handle.h" |
| 45 #include "sky/engine/platform/text/TextBoundaries.h" | 45 #include "sky/engine/platform/text/TextBoundaries.h" |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 using namespace WTF::Unicode; | 49 using namespace WTF::Unicode; |
| 50 | 50 |
| 51 static Node* previousLeafWithSameEditability(Node* node, EditableType editableTy
pe) | 51 static Node* previousLeafWithSameEditability(Node* node, EditableType editableTy
pe) |
| 52 { | 52 { |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 } | 874 } |
| 875 | 875 |
| 876 bool isLogicalEndOfLine(const VisiblePosition &p) | 876 bool isLogicalEndOfLine(const VisiblePosition &p) |
| 877 { | 877 { |
| 878 return p.isNotNull() && p == logicalEndOfLine(p); | 878 return p.isNotNull() && p == logicalEndOfLine(p); |
| 879 } | 879 } |
| 880 | 880 |
| 881 static inline IntPoint absoluteLineDirectionPointToLocalPointInBlock(RootInlineB
ox* root, int lineDirectionPoint) | 881 static inline IntPoint absoluteLineDirectionPointToLocalPointInBlock(RootInlineB
ox* root, int lineDirectionPoint) |
| 882 { | 882 { |
| 883 ASSERT(root); | 883 ASSERT(root); |
| 884 RenderBlockFlow& containingBlock = root->block(); | 884 RenderParagraph& containingBlock = root->block(); |
| 885 FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint()
); | 885 FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint()
); |
| 886 return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), root->blockDire
ctionPointInLine()); | 886 return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), root->blockDire
ctionPointInLine()); |
| 887 } | 887 } |
| 888 | 888 |
| 889 VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
lineDirectionPoint, EditableType editableType) | 889 VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
lineDirectionPoint, EditableType editableType) |
| 890 { | 890 { |
| 891 Position p = visiblePosition.deepEquivalent(); | 891 Position p = visiblePosition.deepEquivalent(); |
| 892 Node* node = p.deprecatedNode(); | 892 Node* node = p.deprecatedNode(); |
| 893 | 893 |
| 894 if (!node) | 894 if (!node) |
| 895 return VisiblePosition(); | 895 return VisiblePosition(); |
| 896 | 896 |
| 897 node->document().updateLayout(); | 897 node->document().updateLayout(); |
| 898 | 898 |
| 899 RenderObject* renderer = node->renderer(); | 899 RenderObject* renderer = node->renderer(); |
| 900 if (!renderer) | 900 if (!renderer) |
| 901 return VisiblePosition(); | 901 return VisiblePosition(); |
| 902 | 902 |
| 903 RootInlineBox* root = 0; | 903 RootInlineBox* root = 0; |
| 904 InlineBox* box; | 904 InlineBox* box; |
| 905 int ignoredCaretOffset; | 905 int ignoredCaretOffset; |
| 906 visiblePosition.getInlineBoxAndOffset(box, ignoredCaretOffset); | 906 visiblePosition.getInlineBoxAndOffset(box, ignoredCaretOffset); |
| 907 if (box) { | 907 if (box) { |
| 908 root = box->root().prevRootBox(); | 908 root = box->root().prevRootBox(); |
| 909 // We want to skip zero height boxes. | 909 // We want to skip zero height boxes. |
| 910 // This could happen in case it is a TrailingFloatsRootInlineBox. | 910 // This use to happen in case it is a TrailingFloatsRootInlineBox. |
| 911 // TODO(ojan): Can this still happen in sky? |
| 911 if (!root || !root->logicalHeight() || !root->firstLeafChild()) | 912 if (!root || !root->logicalHeight() || !root->firstLeafChild()) |
| 912 root = 0; | 913 root = 0; |
| 913 } | 914 } |
| 914 | 915 |
| 915 if (!root) { | 916 if (!root) { |
| 916 Position position = previousRootInlineBoxCandidatePosition(node, visible
Position, editableType); | 917 Position position = previousRootInlineBoxCandidatePosition(node, visible
Position, editableType); |
| 917 if (position.isNotNull()) { | 918 if (position.isNotNull()) { |
| 918 RenderedPosition renderedPosition((VisiblePosition(position))); | 919 RenderedPosition renderedPosition((VisiblePosition(position))); |
| 919 root = renderedPosition.rootBox(); | 920 root = renderedPosition.rootBox(); |
| 920 if (!root) | 921 if (!root) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 if (!renderer) | 958 if (!renderer) |
| 958 return VisiblePosition(); | 959 return VisiblePosition(); |
| 959 | 960 |
| 960 RootInlineBox* root = 0; | 961 RootInlineBox* root = 0; |
| 961 InlineBox* box; | 962 InlineBox* box; |
| 962 int ignoredCaretOffset; | 963 int ignoredCaretOffset; |
| 963 visiblePosition.getInlineBoxAndOffset(box, ignoredCaretOffset); | 964 visiblePosition.getInlineBoxAndOffset(box, ignoredCaretOffset); |
| 964 if (box) { | 965 if (box) { |
| 965 root = box->root().nextRootBox(); | 966 root = box->root().nextRootBox(); |
| 966 // We want to skip zero height boxes. | 967 // We want to skip zero height boxes. |
| 967 // This could happen in case it is a TrailingFloatsRootInlineBox. | 968 // This use to happen in case it is a TrailingFloatsRootInlineBox. |
| 969 // TODO(ojan): Can this still happen in sky? |
| 968 if (!root || !root->logicalHeight() || !root->firstLeafChild()) | 970 if (!root || !root->logicalHeight() || !root->firstLeafChild()) |
| 969 root = 0; | 971 root = 0; |
| 970 } | 972 } |
| 971 | 973 |
| 972 if (!root) { | 974 if (!root) { |
| 973 // FIXME: We need do the same in previousLinePosition. | 975 // FIXME: We need do the same in previousLinePosition. |
| 974 Node* child = NodeTraversal::childAt(*node, p.deprecatedEditingOffset())
; | 976 Node* child = NodeTraversal::childAt(*node, p.deprecatedEditingOffset())
; |
| 975 node = child ? child : &NodeTraversal::lastWithinOrSelf(*node); | 977 node = child ? child : &NodeTraversal::lastWithinOrSelf(*node); |
| 976 Position position = nextRootInlineBoxCandidatePosition(node, visiblePosi
tion, editableType); | 978 Position position = nextRootInlineBoxCandidatePosition(node, visiblePosi
tion, editableType); |
| 977 if (position.isNotNull()) { | 979 if (position.isNotNull()) { |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 int caretOffset; | 1375 int caretOffset; |
| 1374 position.position().getInlineBoxAndOffset(position.affinity(), inlineBox, ca
retOffset); | 1376 position.position().getInlineBoxAndOffset(position.affinity(), inlineBox, ca
retOffset); |
| 1375 | 1377 |
| 1376 if (inlineBox) | 1378 if (inlineBox) |
| 1377 renderer = &inlineBox->renderer(); | 1379 renderer = &inlineBox->renderer(); |
| 1378 | 1380 |
| 1379 return renderer->localCaretRect(inlineBox, caretOffset); | 1381 return renderer->localCaretRect(inlineBox, caretOffset); |
| 1380 } | 1382 } |
| 1381 | 1383 |
| 1382 } | 1384 } |
| OLD | NEW |