| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 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 22 matching lines...) Expand all Loading... |
| 33 #include "sky/engine/core/editing/TextIterator.h" | 33 #include "sky/engine/core/editing/TextIterator.h" |
| 34 #include "sky/engine/core/editing/VisiblePosition.h" | 34 #include "sky/engine/core/editing/VisiblePosition.h" |
| 35 #include "sky/engine/core/editing/VisibleUnits.h" | 35 #include "sky/engine/core/editing/VisibleUnits.h" |
| 36 #include "sky/engine/core/editing/htmlediting.h" | 36 #include "sky/engine/core/editing/htmlediting.h" |
| 37 #include "sky/engine/core/frame/LocalFrame.h" | 37 #include "sky/engine/core/frame/LocalFrame.h" |
| 38 #include "sky/engine/core/frame/Settings.h" | 38 #include "sky/engine/core/frame/Settings.h" |
| 39 #include "sky/engine/core/rendering/InlineIterator.h" | 39 #include "sky/engine/core/rendering/InlineIterator.h" |
| 40 #include "sky/engine/core/rendering/InlineTextBox.h" | 40 #include "sky/engine/core/rendering/InlineTextBox.h" |
| 41 #include "sky/engine/core/rendering/RenderBlock.h" | 41 #include "sky/engine/core/rendering/RenderBlock.h" |
| 42 #include "sky/engine/core/rendering/RenderInline.h" | 42 #include "sky/engine/core/rendering/RenderInline.h" |
| 43 #include "sky/engine/core/rendering/RenderParagraph.h" |
| 43 #include "sky/engine/core/rendering/RenderText.h" | 44 #include "sky/engine/core/rendering/RenderText.h" |
| 44 #include "sky/engine/platform/Logging.h" | 45 #include "sky/engine/platform/Logging.h" |
| 45 #include "sky/engine/wtf/text/CString.h" | 46 #include "sky/engine/wtf/text/CString.h" |
| 46 #include "sky/engine/wtf/unicode/CharacterNames.h" | 47 #include "sky/engine/wtf/unicode/CharacterNames.h" |
| 47 | 48 |
| 48 namespace blink { | 49 namespace blink { |
| 49 | 50 |
| 50 static Node* nextRenderedEditable(Node* node) | 51 static Node* nextRenderedEditable(Node* node) |
| 51 { | 52 { |
| 52 for (node = node->nextLeafNode(); node; node = node->nextLeafNode()) { | 53 for (node = node->nextLeafNode(); node; node = node->nextLeafNode()) { |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 RenderObject* renderer = deprecatedNode()->renderer(); | 796 RenderObject* renderer = deprecatedNode()->renderer(); |
| 796 if (!renderer) | 797 if (!renderer) |
| 797 return false; | 798 return false; |
| 798 | 799 |
| 799 if (renderer->isText()) | 800 if (renderer->isText()) |
| 800 return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText(); | 801 return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText(); |
| 801 | 802 |
| 802 if (editingIgnoresContent(deprecatedNode())) | 803 if (editingIgnoresContent(deprecatedNode())) |
| 803 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); | 804 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); |
| 804 | 805 |
| 805 if (renderer->isRenderBlockFlow()) { | 806 if (renderer->isRenderParagraph()) { |
| 806 if (toRenderBlock(renderer)->logicalHeight()) { | 807 if (toRenderParagraph(renderer)->logicalHeight()) { |
| 807 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) | 808 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) |
| 808 return atFirstEditingPositionForNode() && !Position::nodeIsUserS
electNone(deprecatedNode()); | 809 return atFirstEditingPositionForNode() && !Position::nodeIsUserS
electNone(deprecatedNode()); |
| 809 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSele
ctNone(deprecatedNode()) && atEditingBoundary(); | 810 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSele
ctNone(deprecatedNode()) && atEditingBoundary(); |
| 810 } | 811 } |
| 811 } else { | 812 } else { |
| 812 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNo
ne(deprecatedNode()) && atEditingBoundary(); | 813 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNo
ne(deprecatedNode()) && atEditingBoundary(); |
| 813 } | 814 } |
| 814 | 815 |
| 815 return false; | 816 return false; |
| 816 } | 817 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 return position; | 997 return position; |
| 997 } | 998 } |
| 998 | 999 |
| 999 void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi
rection, InlineBox*& inlineBox, int& caretOffset) const | 1000 void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi
rection, InlineBox*& inlineBox, int& caretOffset) const |
| 1000 { | 1001 { |
| 1001 caretOffset = deprecatedEditingOffset(); | 1002 caretOffset = deprecatedEditingOffset(); |
| 1002 RenderObject* renderer = deprecatedNode()->renderer(); | 1003 RenderObject* renderer = deprecatedNode()->renderer(); |
| 1003 | 1004 |
| 1004 if (!renderer->isText()) { | 1005 if (!renderer->isText()) { |
| 1005 inlineBox = 0; | 1006 inlineBox = 0; |
| 1006 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderBlo
ckFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) { | 1007 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderPar
agraph() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) { |
| 1007 // Try a visually equivalent position with possibly opposite editabi
lity. This helps in case |this| is in | 1008 // Try a visually equivalent position with possibly opposite editabi
lity. This helps in case |this| is in |
| 1008 // an editable block but surrounded by non-editable positions. It ac
ts to negate the logic at the beginning | 1009 // an editable block but surrounded by non-editable positions. It ac
ts to negate the logic at the beginning |
| 1009 // of RenderObject::createVisiblePosition(). | 1010 // of RenderObject::createVisiblePosition(). |
| 1010 Position equivalent = downstreamIgnoringEditingBoundaries(*this); | 1011 Position equivalent = downstreamIgnoringEditingBoundaries(*this); |
| 1011 if (equivalent == *this) { | 1012 if (equivalent == *this) { |
| 1012 equivalent = upstreamIgnoringEditingBoundaries(*this); | 1013 equivalent = upstreamIgnoringEditingBoundaries(*this); |
| 1013 if (equivalent == *this || downstreamIgnoringEditingBoundaries(e
quivalent) == *this) | 1014 if (equivalent == *this || downstreamIgnoringEditingBoundaries(e
quivalent) == *this) |
| 1014 return; | 1015 return; |
| 1015 } | 1016 } |
| 1016 | 1017 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 } | 1145 } |
| 1145 caretOffset = inlineBox->caretRightmostOffset(); | 1146 caretOffset = inlineBox->caretRightmostOffset(); |
| 1146 } | 1147 } |
| 1147 } | 1148 } |
| 1148 } | 1149 } |
| 1149 | 1150 |
| 1150 TextDirection Position::primaryDirection() const | 1151 TextDirection Position::primaryDirection() const |
| 1151 { | 1152 { |
| 1152 TextDirection primaryDirection = LTR; | 1153 TextDirection primaryDirection = LTR; |
| 1153 for (const RenderObject* r = m_anchorNode->renderer(); r; r = r->parent()) { | 1154 for (const RenderObject* r = m_anchorNode->renderer(); r; r = r->parent()) { |
| 1154 if (r->isRenderBlockFlow()) { | 1155 if (r->isRenderParagraph()) { |
| 1155 primaryDirection = r->style()->direction(); | 1156 primaryDirection = r->style()->direction(); |
| 1156 break; | 1157 break; |
| 1157 } | 1158 } |
| 1158 } | 1159 } |
| 1159 | 1160 |
| 1160 return primaryDirection; | 1161 return primaryDirection; |
| 1161 } | 1162 } |
| 1162 | 1163 |
| 1163 void Position::debugPosition(const char* msg) const | 1164 void Position::debugPosition(const char* msg) const |
| 1164 { | 1165 { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 pos.showTreeForThis(); | 1234 pos.showTreeForThis(); |
| 1234 } | 1235 } |
| 1235 | 1236 |
| 1236 void showTree(const blink::Position* pos) | 1237 void showTree(const blink::Position* pos) |
| 1237 { | 1238 { |
| 1238 if (pos) | 1239 if (pos) |
| 1239 pos->showTreeForThis(); | 1240 pos->showTreeForThis(); |
| 1240 } | 1241 } |
| 1241 | 1242 |
| 1242 #endif | 1243 #endif |
| OLD | NEW |