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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 if (isNull()) | 430 if (isNull()) |
431 return true; | 431 return true; |
432 // TODO(yosin): Position after anchor shouldn't be considered as at the | 432 // TODO(yosin): Position after anchor shouldn't be considered as at the |
433 // first editing position for node since that position resides outside of | 433 // first editing position for node since that position resides outside of |
434 // the node. | 434 // the node. |
435 // TODO(yosin) We should use |Strategy::lastOffsetForEditing()| instead of | 435 // TODO(yosin) We should use |Strategy::lastOffsetForEditing()| instead of |
436 // DOM tree version. | 436 // DOM tree version. |
437 return isAfterAnchorOrAfterChildren() || m_offset >= EditingStrategy::lastOf
fsetForEditing(anchorNode()); | 437 return isAfterAnchorOrAfterChildren() || m_offset >= EditingStrategy::lastOf
fsetForEditing(anchorNode()); |
438 } | 438 } |
439 | 439 |
440 // A position is considered at editing boundary if one of the following is true: | 440 // Returns true if the visually equivalent positions around have different |
441 // 1. It is the first position in the node and the next visually equivalent posi
tion | 441 // editability. A position is considered at editing boundary if one of the |
442 // is non editable. | 442 // following is true: |
443 // 2. It is the last position in the node and the previous visually equivalent p
osition | 443 // 1. It is the first position in the node and the next visually equivalent |
444 // is non editable. | 444 // position is non editable. |
445 // 3. It is an editable position and both the next and previous visually equival
ent | 445 // 2. It is the last position in the node and the previous visually equivalent |
446 // positions are both non editable. | 446 // position is non editable. |
| 447 // 3. It is an editable position and both the next and previous visually |
| 448 // equivalent positions are both non editable. |
447 template <typename Strategy> | 449 template <typename Strategy> |
448 bool PositionAlgorithm<Strategy>::atEditingBoundary() const | 450 static bool atEditingBoundary(const PositionAlgorithm<Strategy> positions) |
449 { | 451 { |
450 PositionAlgorithm<Strategy> nextPosition = downstream(CanCrossEditingBoundar
y); | 452 PositionAlgorithm<Strategy> nextPosition = positions.downstream(CanCrossEdit
ingBoundary); |
451 if (atFirstEditingPositionForNode() && nextPosition.isNotNull() && !nextPosi
tion.anchorNode()->hasEditableStyle()) | 453 if (positions.atFirstEditingPositionForNode() && nextPosition.isNotNull() &&
!nextPosition.anchorNode()->hasEditableStyle()) |
452 return true; | 454 return true; |
453 | 455 |
454 PositionAlgorithm<Strategy> prevPosition = upstream(CanCrossEditingBoundary)
; | 456 PositionAlgorithm<Strategy> prevPosition = positions.upstream(CanCrossEditin
gBoundary); |
455 if (atLastEditingPositionForNode() && prevPosition.isNotNull() && !prevPosit
ion.anchorNode()->hasEditableStyle()) | 457 if (positions.atLastEditingPositionForNode() && prevPosition.isNotNull() &&
!prevPosition.anchorNode()->hasEditableStyle()) |
456 return true; | 458 return true; |
457 | 459 |
458 return nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableSt
yle() | 460 return nextPosition.isNotNull() && !nextPosition.anchorNode()->hasEditableSt
yle() |
459 && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableSt
yle(); | 461 && prevPosition.isNotNull() && !prevPosition.anchorNode()->hasEditableSt
yle(); |
460 } | 462 } |
461 | 463 |
462 template <typename Strategy> | 464 template <typename Strategy> |
463 static ContainerNode* nonShadowBoundaryParentNode(Node* node) | 465 static ContainerNode* nonShadowBoundaryParentNode(Node* node) |
464 { | 466 { |
465 ContainerNode* parent = Strategy::parent(*node); | 467 ContainerNode* parent = Strategy::parent(*node); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 if (isRenderedHTMLTableElement(anchorNode()) || Strategy::editingIgnoresCont
ent(anchorNode())) | 888 if (isRenderedHTMLTableElement(anchorNode()) || Strategy::editingIgnoresCont
ent(anchorNode())) |
887 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(Strategy::parent(*anchorNode())); | 889 return (atFirstEditingPositionForNode() || atLastEditingPositionForNode(
)) && !nodeIsUserSelectNone(Strategy::parent(*anchorNode())); |
888 | 890 |
889 if (isHTMLHtmlElement(*m_anchorNode)) | 891 if (isHTMLHtmlElement(*m_anchorNode)) |
890 return false; | 892 return false; |
891 | 893 |
892 if (layoutObject->isLayoutBlockFlow() || layoutObject->isFlexibleBox() || la
youtObject->isLayoutGrid()) { | 894 if (layoutObject->isLayoutBlockFlow() || layoutObject->isFlexibleBox() || la
youtObject->isLayoutGrid()) { |
893 if (toLayoutBlock(layoutObject)->logicalHeight() || isHTMLBodyElement(*m
_anchorNode)) { | 895 if (toLayoutBlock(layoutObject)->logicalHeight() || isHTMLBodyElement(*m
_anchorNode)) { |
894 if (!hasRenderedNonAnonymousDescendantsWithHeight(layoutObject)) | 896 if (!hasRenderedNonAnonymousDescendantsWithHeight(layoutObject)) |
895 return atFirstEditingPositionForNode() && !nodeIsUserSelectNone(
anchorNode()); | 897 return atFirstEditingPositionForNode() && !nodeIsUserSelectNone(
anchorNode()); |
896 return m_anchorNode->hasEditableStyle() && !nodeIsUserSelectNone(anc
horNode()) && atEditingBoundary(); | 898 return m_anchorNode->hasEditableStyle() && !nodeIsUserSelectNone(anc
horNode()) && atEditingBoundary(*this); |
897 } | 899 } |
898 } else { | 900 } else { |
899 LocalFrame* frame = m_anchorNode->document().frame(); | 901 LocalFrame* frame = m_anchorNode->document().frame(); |
900 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsi
ngEnabled(); | 902 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsi
ngEnabled(); |
901 return (caretBrowsing || m_anchorNode->hasEditableStyle()) && !nodeIsUse
rSelectNone(anchorNode()) && atEditingBoundary(); | 903 return (caretBrowsing || m_anchorNode->hasEditableStyle()) && !nodeIsUse
rSelectNone(anchorNode()) && atEditingBoundary(*this); |
902 } | 904 } |
903 | 905 |
904 return false; | 906 return false; |
905 } | 907 } |
906 | 908 |
907 template <typename Strategy> | 909 template <typename Strategy> |
908 bool PositionAlgorithm<Strategy>::inRenderedText() const | 910 bool PositionAlgorithm<Strategy>::inRenderedText() const |
909 { | 911 { |
910 if (isNull() || !anchorNode()->isTextNode()) | 912 if (isNull() || !anchorNode()->isTextNode()) |
911 return false; | 913 return false; |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 | 1355 |
1354 void showTree(const blink::Position* pos) | 1356 void showTree(const blink::Position* pos) |
1355 { | 1357 { |
1356 if (pos) | 1358 if (pos) |
1357 pos->showTreeForThis(); | 1359 pos->showTreeForThis(); |
1358 else | 1360 else |
1359 fprintf(stderr, "Cannot showTree for (nil)\n"); | 1361 fprintf(stderr, "Cannot showTree for (nil)\n"); |
1360 } | 1362 } |
1361 | 1363 |
1362 #endif | 1364 #endif |
OLD | NEW |