| 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 | 736 |
| 737 if (continuesOnNextLine) | 737 if (continuesOnNextLine) |
| 738 return currentPos; | 738 return currentPos; |
| 739 } | 739 } |
| 740 } | 740 } |
| 741 } | 741 } |
| 742 | 742 |
| 743 return lastVisible; | 743 return lastVisible; |
| 744 } | 744 } |
| 745 | 745 |
| 746 bool Position::hasRenderedNonAnonymousDescendantsWithHeight(RenderObject* render
er) | 746 bool Position::hasRenderedDescendantsWithHeight(RenderObject* renderer) |
| 747 { | 747 { |
| 748 RenderObject* stop = renderer->nextInPreOrderAfterChildren(); | 748 RenderObject* stop = renderer->nextInPreOrderAfterChildren(); |
| 749 for (RenderObject *o = renderer->slowFirstChild(); o && o != stop; o = o->ne
xtInPreOrder()) | 749 for (RenderObject *o = renderer->slowFirstChild(); o && o != stop; o = o->ne
xtInPreOrder()) |
| 750 if (o->node()) { | 750 if (o->node()) { |
| 751 if ((o->isText() && toRenderText(o)->linesBoundingBox().height()) | 751 if ((o->isText() && toRenderText(o)->linesBoundingBox().height()) |
| 752 || (o->isBox() && toRenderBox(o)->pixelSnappedLogicalHeight()) | 752 || (o->isBox() && toRenderBox(o)->pixelSnappedLogicalHeight()) |
| 753 || (o->isRenderInline() && isEmptyInline(o) && toRenderInline(o)
->linesBoundingBox().height())) | 753 || (o->isRenderInline() && isEmptyInline(o) && toRenderInline(o)
->linesBoundingBox().height())) |
| 754 return true; | 754 return true; |
| 755 } | 755 } |
| 756 return false; | 756 return false; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 return false; | 798 return false; |
| 799 | 799 |
| 800 if (renderer->isText()) | 800 if (renderer->isText()) |
| 801 return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText(); | 801 return !nodeIsUserSelectNone(deprecatedNode()) && inRenderedText(); |
| 802 | 802 |
| 803 if (editingIgnoresContent(deprecatedNode())) | 803 if (editingIgnoresContent(deprecatedNode())) |
| 804 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); | 804 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(deprecatedNode()->parentNode()); |
| 805 | 805 |
| 806 if (renderer->isRenderParagraph()) { | 806 if (renderer->isRenderParagraph()) { |
| 807 if (toRenderParagraph(renderer)->logicalHeight()) { | 807 if (toRenderParagraph(renderer)->logicalHeight()) { |
| 808 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer
)) | 808 if (!Position::hasRenderedDescendantsWithHeight(renderer)) |
| 809 return atFirstEditingPositionForNode() && !Position::nodeIsUserS
electNone(deprecatedNode()); | 809 return atFirstEditingPositionForNode() && !Position::nodeIsUserS
electNone(deprecatedNode()); |
| 810 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSele
ctNone(deprecatedNode()) && atEditingBoundary(); | 810 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSele
ctNone(deprecatedNode()) && atEditingBoundary(); |
| 811 } | 811 } |
| 812 } else { | 812 } else { |
| 813 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNo
ne(deprecatedNode()) && atEditingBoundary(); | 813 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNo
ne(deprecatedNode()) && atEditingBoundary(); |
| 814 } | 814 } |
| 815 | 815 |
| 816 return false; | 816 return false; |
| 817 } | 817 } |
| 818 | 818 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 return position; | 997 return position; |
| 998 } | 998 } |
| 999 | 999 |
| 1000 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 |
| 1001 { | 1001 { |
| 1002 caretOffset = deprecatedEditingOffset(); | 1002 caretOffset = deprecatedEditingOffset(); |
| 1003 RenderObject* renderer = deprecatedNode()->renderer(); | 1003 RenderObject* renderer = deprecatedNode()->renderer(); |
| 1004 | 1004 |
| 1005 if (!renderer->isText()) { | 1005 if (!renderer->isText()) { |
| 1006 inlineBox = 0; | 1006 inlineBox = 0; |
| 1007 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderPar
agraph() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) { | 1007 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderPar
agraph() && hasRenderedDescendantsWithHeight(renderer)) { |
| 1008 // 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 |
| 1009 // 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 |
| 1010 // of RenderObject::createVisiblePosition(). | 1010 // of RenderObject::createVisiblePosition(). |
| 1011 Position equivalent = downstreamIgnoringEditingBoundaries(*this); | 1011 Position equivalent = downstreamIgnoringEditingBoundaries(*this); |
| 1012 if (equivalent == *this) { | 1012 if (equivalent == *this) { |
| 1013 equivalent = upstreamIgnoringEditingBoundaries(*this); | 1013 equivalent = upstreamIgnoringEditingBoundaries(*this); |
| 1014 if (equivalent == *this || downstreamIgnoringEditingBoundaries(e
quivalent) == *this) | 1014 if (equivalent == *this || downstreamIgnoringEditingBoundaries(e
quivalent) == *this) |
| 1015 return; | 1015 return; |
| 1016 } | 1016 } |
| 1017 | 1017 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 pos.showTreeForThis(); | 1234 pos.showTreeForThis(); |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 void showTree(const blink::Position* pos) | 1237 void showTree(const blink::Position* pos) |
| 1238 { | 1238 { |
| 1239 if (pos) | 1239 if (pos) |
| 1240 pos->showTreeForThis(); | 1240 pos->showTreeForThis(); |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 #endif | 1243 #endif |
| OLD | NEW |