OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 2974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2985 return node && node->isElementNode() ? toElement(node) : nullptr; | 2985 return node && node->isElementNode() ? toElement(node) : nullptr; |
2986 } | 2986 } |
2987 | 2987 |
2988 PositionWithAffinity LayoutObject::createPositionWithAffinity(int offset, TextAf
finity affinity) | 2988 PositionWithAffinity LayoutObject::createPositionWithAffinity(int offset, TextAf
finity affinity) |
2989 { | 2989 { |
2990 // If this is a non-anonymous layoutObject in an editable area, then it's si
mple. | 2990 // If this is a non-anonymous layoutObject in an editable area, then it's si
mple. |
2991 if (Node* node = nonPseudoNode()) { | 2991 if (Node* node = nonPseudoNode()) { |
2992 if (!node->hasEditableStyle()) { | 2992 if (!node->hasEditableStyle()) { |
2993 // If it can be found, we prefer a visually equivalent position that
is editable. | 2993 // If it can be found, we prefer a visually equivalent position that
is editable. |
2994 const Position position = Position(node, offset); | 2994 const Position position = Position(node, offset); |
2995 Position candidate = position.downstream(CanCrossEditingBoundary); | 2995 Position candidate = mostForwardCaretPosition(position, CanCrossEdit
ingBoundary); |
2996 if (candidate.anchorNode()->hasEditableStyle()) | 2996 if (candidate.anchorNode()->hasEditableStyle()) |
2997 return PositionWithAffinity(candidate, affinity); | 2997 return PositionWithAffinity(candidate, affinity); |
2998 candidate = position.upstream(CanCrossEditingBoundary); | 2998 candidate = mostBackwardCaretPosition(position, CanCrossEditingBound
ary); |
2999 if (candidate.anchorNode()->hasEditableStyle()) | 2999 if (candidate.anchorNode()->hasEditableStyle()) |
3000 return PositionWithAffinity(candidate, affinity); | 3000 return PositionWithAffinity(candidate, affinity); |
3001 } | 3001 } |
3002 // FIXME: Eliminate legacy editing positions | 3002 // FIXME: Eliminate legacy editing positions |
3003 return PositionWithAffinity(Position::editingPositionOf(node, offset), a
ffinity); | 3003 return PositionWithAffinity(Position::editingPositionOf(node, offset), a
ffinity); |
3004 } | 3004 } |
3005 | 3005 |
3006 // We don't want to cross the boundary between editable and non-editable | 3006 // We don't want to cross the boundary between editable and non-editable |
3007 // regions of the document, but that is either impossible or at least | 3007 // regions of the document, but that is either impossible or at least |
3008 // extremely unlikely in any normal case because we stop as soon as we | 3008 // extremely unlikely in any normal case because we stop as soon as we |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3403 const blink::LayoutObject* root = object1; | 3403 const blink::LayoutObject* root = object1; |
3404 while (root->parent()) | 3404 while (root->parent()) |
3405 root = root->parent(); | 3405 root = root->parent(); |
3406 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3406 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
3407 } else { | 3407 } else { |
3408 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); | 3408 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); |
3409 } | 3409 } |
3410 } | 3410 } |
3411 | 3411 |
3412 #endif | 3412 #endif |
OLD | NEW |