OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 return previousVisuallyDistinctCandidateAlgorithm<EditingStrategy>(position)
; | 526 return previousVisuallyDistinctCandidateAlgorithm<EditingStrategy>(position)
; |
527 } | 527 } |
528 | 528 |
529 PositionInFlatTree previousVisuallyDistinctCandidate(const PositionInFlatTree& p
osition) | 529 PositionInFlatTree previousVisuallyDistinctCandidate(const PositionInFlatTree& p
osition) |
530 { | 530 { |
531 return previousVisuallyDistinctCandidateAlgorithm<EditingInFlatTreeStrategy>
(position); | 531 return previousVisuallyDistinctCandidateAlgorithm<EditingInFlatTreeStrategy>
(position); |
532 } | 532 } |
533 | 533 |
534 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position&
position, ContainerNode& highestRoot) | 534 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position&
position, ContainerNode& highestRoot) |
535 { | 535 { |
536 return createVisiblePosition(firstEditablePositionAfterPositionInRoot(positi
on, highestRoot)); | 536 return createVisiblePositionDeprecated(firstEditablePositionAfterPositionInR
oot(position, highestRoot)); |
537 } | 537 } |
538 | 538 |
539 VisiblePositionInFlatTree firstEditableVisiblePositionAfterPositionInRoot(const
PositionInFlatTree& position, ContainerNode& highestRoot) | 539 VisiblePositionInFlatTree firstEditableVisiblePositionAfterPositionInRoot(const
PositionInFlatTree& position, ContainerNode& highestRoot) |
540 { | 540 { |
541 return createVisiblePosition(firstEditablePositionAfterPositionInRoot(positi
on, highestRoot)); | 541 return createVisiblePositionDeprecated(firstEditablePositionAfterPositionInR
oot(position, highestRoot)); |
542 } | 542 } |
543 | 543 |
544 template <typename Strategy> | 544 template <typename Strategy> |
545 PositionTemplate<Strategy> firstEditablePositionAfterPositionInRootAlgorithm(con
st PositionTemplate<Strategy>& position, Node& highestRoot) | 545 PositionTemplate<Strategy> firstEditablePositionAfterPositionInRootAlgorithm(con
st PositionTemplate<Strategy>& position, Node& highestRoot) |
546 { | 546 { |
547 DCHECK(!needsLayoutTreeUpdate(highestRoot)) << position << ' ' << highestRoo
t; | 547 DCHECK(!needsLayoutTreeUpdate(highestRoot)) << position << ' ' << highestRoo
t; |
548 // position falls before highestRoot. | 548 // position falls before highestRoot. |
549 if (position.compareTo(PositionTemplate<Strategy>::firstPositionInNode(&high
estRoot)) == -1 && hasEditableStyle(highestRoot)) | 549 if (position.compareTo(PositionTemplate<Strategy>::firstPositionInNode(&high
estRoot)) == -1 && hasEditableStyle(highestRoot)) |
550 return PositionTemplate<Strategy>::firstPositionInNode(&highestRoot); | 550 return PositionTemplate<Strategy>::firstPositionInNode(&highestRoot); |
551 | 551 |
(...skipping 29 matching lines...) Expand all Loading... |
581 return firstEditablePositionAfterPositionInRootAlgorithm<EditingStrategy>(po
sition, highestRoot); | 581 return firstEditablePositionAfterPositionInRootAlgorithm<EditingStrategy>(po
sition, highestRoot); |
582 } | 582 } |
583 | 583 |
584 PositionInFlatTree firstEditablePositionAfterPositionInRoot(const PositionInFlat
Tree& position, Node& highestRoot) | 584 PositionInFlatTree firstEditablePositionAfterPositionInRoot(const PositionInFlat
Tree& position, Node& highestRoot) |
585 { | 585 { |
586 return firstEditablePositionAfterPositionInRootAlgorithm<EditingInFlatTreeSt
rategy>(position, highestRoot); | 586 return firstEditablePositionAfterPositionInRootAlgorithm<EditingInFlatTreeSt
rategy>(position, highestRoot); |
587 } | 587 } |
588 | 588 |
589 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position&
position, ContainerNode& highestRoot) | 589 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position&
position, ContainerNode& highestRoot) |
590 { | 590 { |
591 return createVisiblePosition(lastEditablePositionBeforePositionInRoot(positi
on, highestRoot)); | 591 return createVisiblePositionDeprecated(lastEditablePositionBeforePositionInR
oot(position, highestRoot)); |
592 } | 592 } |
593 | 593 |
594 VisiblePositionInFlatTree lastEditableVisiblePositionBeforePositionInRoot(const
PositionInFlatTree& position, ContainerNode& highestRoot) | 594 VisiblePositionInFlatTree lastEditableVisiblePositionBeforePositionInRoot(const
PositionInFlatTree& position, ContainerNode& highestRoot) |
595 { | 595 { |
596 return createVisiblePosition(lastEditablePositionBeforePositionInRoot(positi
on, highestRoot)); | 596 return createVisiblePositionDeprecated(lastEditablePositionBeforePositionInR
oot(position, highestRoot)); |
597 } | 597 } |
598 | 598 |
599 template <typename Strategy> | 599 template <typename Strategy> |
600 PositionTemplate<Strategy> lastEditablePositionBeforePositionInRootAlgorithm(con
st PositionTemplate<Strategy>& position, Node& highestRoot) | 600 PositionTemplate<Strategy> lastEditablePositionBeforePositionInRootAlgorithm(con
st PositionTemplate<Strategy>& position, Node& highestRoot) |
601 { | 601 { |
602 DCHECK(!needsLayoutTreeUpdate(highestRoot)) << position << ' ' << highestRoo
t; | 602 DCHECK(!needsLayoutTreeUpdate(highestRoot)) << position << ' ' << highestRoo
t; |
603 // When position falls after highestRoot, the result is easy to compute. | 603 // When position falls after highestRoot, the result is easy to compute. |
604 if (position.compareTo(PositionTemplate<Strategy>::lastPositionInNode(&highe
stRoot)) == 1) | 604 if (position.compareTo(PositionTemplate<Strategy>::lastPositionInNode(&highe
stRoot)) == 1) |
605 return PositionTemplate<Strategy>::lastPositionInNode(&highestRoot); | 605 return PositionTemplate<Strategy>::lastPositionInNode(&highestRoot); |
606 | 606 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 } | 975 } |
976 | 976 |
977 static HTMLElement* firstInSpecialElement(const Position& pos) | 977 static HTMLElement* firstInSpecialElement(const Position& pos) |
978 { | 978 { |
979 Element* element = rootEditableElement(*pos.computeContainerNode()); | 979 Element* element = rootEditableElement(*pos.computeContainerNode()); |
980 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*pos.anchorNode()))
{ | 980 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*pos.anchorNode()))
{ |
981 if (rootEditableElement(runner) != element) | 981 if (rootEditableElement(runner) != element) |
982 break; | 982 break; |
983 if (isSpecialHTMLElement(runner)) { | 983 if (isSpecialHTMLElement(runner)) { |
984 HTMLElement* specialElement = toHTMLElement(&runner); | 984 HTMLElement* specialElement = toHTMLElement(&runner); |
985 VisiblePosition vPos = createVisiblePosition(pos); | 985 VisiblePosition vPos = createVisiblePositionDeprecated(pos); |
986 VisiblePosition firstInElement = createVisiblePosition(firstPosition
InOrBeforeNode(specialElement)); | 986 VisiblePosition firstInElement = createVisiblePositionDeprecated(fir
stPositionInOrBeforeNode(specialElement)); |
987 if (isDisplayInsideTable(specialElement) && vPos.deepEquivalent() ==
nextPositionOf(firstInElement).deepEquivalent()) | 987 if (isDisplayInsideTable(specialElement) && vPos.deepEquivalent() ==
nextPositionOf(firstInElement).deepEquivalent()) |
988 return specialElement; | 988 return specialElement; |
989 if (vPos.deepEquivalent() == firstInElement.deepEquivalent()) | 989 if (vPos.deepEquivalent() == firstInElement.deepEquivalent()) |
990 return specialElement; | 990 return specialElement; |
991 } | 991 } |
992 } | 992 } |
993 return 0; | 993 return 0; |
994 } | 994 } |
995 | 995 |
996 static HTMLElement* lastInSpecialElement(const Position& pos) | 996 static HTMLElement* lastInSpecialElement(const Position& pos) |
997 { | 997 { |
998 Element* element = rootEditableElement(*pos.computeContainerNode()); | 998 Element* element = rootEditableElement(*pos.computeContainerNode()); |
999 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*pos.anchorNode()))
{ | 999 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*pos.anchorNode()))
{ |
1000 if (rootEditableElement(runner) != element) | 1000 if (rootEditableElement(runner) != element) |
1001 break; | 1001 break; |
1002 if (isSpecialHTMLElement(runner)) { | 1002 if (isSpecialHTMLElement(runner)) { |
1003 HTMLElement* specialElement = toHTMLElement(&runner); | 1003 HTMLElement* specialElement = toHTMLElement(&runner); |
1004 VisiblePosition vPos = createVisiblePosition(pos); | 1004 VisiblePosition vPos = createVisiblePositionDeprecated(pos); |
1005 VisiblePosition lastInElement = createVisiblePosition(lastPositionIn
OrAfterNode(specialElement)); | 1005 VisiblePosition lastInElement = createVisiblePositionDeprecated(last
PositionInOrAfterNode(specialElement)); |
1006 if (isDisplayInsideTable(specialElement) && vPos.deepEquivalent() ==
previousPositionOf(lastInElement).deepEquivalent()) | 1006 if (isDisplayInsideTable(specialElement) && vPos.deepEquivalent() ==
previousPositionOf(lastInElement).deepEquivalent()) |
1007 return specialElement; | 1007 return specialElement; |
1008 if (vPos.deepEquivalent() == lastInElement.deepEquivalent()) | 1008 if (vPos.deepEquivalent() == lastInElement.deepEquivalent()) |
1009 return specialElement; | 1009 return specialElement; |
1010 } | 1010 } |
1011 } | 1011 } |
1012 return 0; | 1012 return 0; |
1013 } | 1013 } |
1014 | 1014 |
1015 Position positionBeforeContainingSpecialElement(const Position& pos, HTMLElement
** containingSpecialElement) | 1015 Position positionBeforeContainingSpecialElement(const Position& pos, HTMLElement
** containingSpecialElement) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 return node; | 1111 return node; |
1112 node = nextNodeConsideringAtomicNodes(*node); | 1112 node = nextNodeConsideringAtomicNodes(*node); |
1113 } | 1113 } |
1114 return nullptr; | 1114 return nullptr; |
1115 } | 1115 } |
1116 | 1116 |
1117 // Returns the visible position at the beginning of a node | 1117 // Returns the visible position at the beginning of a node |
1118 VisiblePosition visiblePositionBeforeNode(Node& node) | 1118 VisiblePosition visiblePositionBeforeNode(Node& node) |
1119 { | 1119 { |
1120 if (node.hasChildren()) | 1120 if (node.hasChildren()) |
1121 return createVisiblePosition(firstPositionInOrBeforeNode(&node)); | 1121 return createVisiblePositionDeprecated(firstPositionInOrBeforeNode(&node
)); |
1122 DCHECK(node.parentNode()) << node; | 1122 DCHECK(node.parentNode()) << node; |
1123 DCHECK(!node.parentNode()->isShadowRoot()) << node.parentNode(); | 1123 DCHECK(!node.parentNode()->isShadowRoot()) << node.parentNode(); |
1124 return VisiblePosition::inParentBeforeNode(node); | 1124 return VisiblePosition::inParentBeforeNode(node); |
1125 } | 1125 } |
1126 | 1126 |
1127 // Returns the visible position at the ending of a node | 1127 // Returns the visible position at the ending of a node |
1128 VisiblePosition visiblePositionAfterNode(Node& node) | 1128 VisiblePosition visiblePositionAfterNode(Node& node) |
1129 { | 1129 { |
1130 if (node.hasChildren()) | 1130 if (node.hasChildren()) |
1131 return createVisiblePosition(lastPositionInOrAfterNode(&node)); | 1131 return createVisiblePositionDeprecated(lastPositionInOrAfterNode(&node))
; |
1132 DCHECK(node.parentNode()) << node.parentNode(); | 1132 DCHECK(node.parentNode()) << node.parentNode(); |
1133 DCHECK(!node.parentNode()->isShadowRoot()) << node.parentNode(); | 1133 DCHECK(!node.parentNode()->isShadowRoot()) << node.parentNode(); |
1134 return VisiblePosition::inParentAfterNode(node); | 1134 return VisiblePosition::inParentAfterNode(node); |
1135 } | 1135 } |
1136 | 1136 |
1137 bool isHTMLListElement(Node* n) | 1137 bool isHTMLListElement(Node* n) |
1138 { | 1138 { |
1139 return (n && (isHTMLUListElement(*n) || isHTMLOListElement(*n) || isHTMLDLis
tElement(*n))); | 1139 return (n && (isHTMLUListElement(*n) || isHTMLOListElement(*n) || isHTMLDLis
tElement(*n))); |
1140 } | 1140 } |
1141 | 1141 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 } | 1313 } |
1314 | 1314 |
1315 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagrap
h | 1315 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagrap
h |
1316 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos) | 1316 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos) |
1317 { | 1317 { |
1318 // Check that position is on a line by itself inside a list item | 1318 // Check that position is on a line by itself inside a list item |
1319 Node* listChildNode = enclosingListChild(visiblePos.deepEquivalent().anchorN
ode()); | 1319 Node* listChildNode = enclosingListChild(visiblePos.deepEquivalent().anchorN
ode()); |
1320 if (!listChildNode || !isStartOfParagraph(visiblePos) || !isEndOfParagraph(v
isiblePos)) | 1320 if (!listChildNode || !isStartOfParagraph(visiblePos) || !isEndOfParagraph(v
isiblePos)) |
1321 return 0; | 1321 return 0; |
1322 | 1322 |
1323 VisiblePosition firstInListChild = createVisiblePosition(firstPositionInOrBe
foreNode(listChildNode)); | 1323 VisiblePosition firstInListChild = createVisiblePositionDeprecated(firstPosi
tionInOrBeforeNode(listChildNode)); |
1324 VisiblePosition lastInListChild = createVisiblePosition(lastPositionInOrAfte
rNode(listChildNode)); | 1324 VisiblePosition lastInListChild = createVisiblePositionDeprecated(lastPositi
onInOrAfterNode(listChildNode)); |
1325 | 1325 |
1326 if (firstInListChild.deepEquivalent() != visiblePos.deepEquivalent() || last
InListChild.deepEquivalent() != visiblePos.deepEquivalent()) | 1326 if (firstInListChild.deepEquivalent() != visiblePos.deepEquivalent() || last
InListChild.deepEquivalent() != visiblePos.deepEquivalent()) |
1327 return 0; | 1327 return 0; |
1328 | 1328 |
1329 return listChildNode; | 1329 return listChildNode; |
1330 } | 1330 } |
1331 | 1331 |
1332 HTMLElement* outermostEnclosingList(Node* node, HTMLElement* rootList) | 1332 HTMLElement* outermostEnclosingList(Node* node, HTMLElement* rootList) |
1333 { | 1333 { |
1334 HTMLElement* list = enclosingList(node); | 1334 HTMLElement* list = enclosingList(node); |
1335 if (!list) | 1335 if (!list) |
1336 return 0; | 1336 return 0; |
1337 | 1337 |
1338 while (HTMLElement* nextList = enclosingList(list)) { | 1338 while (HTMLElement* nextList = enclosingList(list)) { |
1339 if (nextList == rootList) | 1339 if (nextList == rootList) |
1340 break; | 1340 break; |
1341 list = nextList; | 1341 list = nextList; |
1342 } | 1342 } |
1343 | 1343 |
1344 return list; | 1344 return list; |
1345 } | 1345 } |
1346 | 1346 |
1347 // Determines whether two positions are visibly next to each other (first then s
econd) | 1347 // Determines whether two positions are visibly next to each other (first then s
econd) |
1348 // while ignoring whitespaces and unrendered nodes | 1348 // while ignoring whitespaces and unrendered nodes |
1349 static bool isVisiblyAdjacent(const Position& first, const Position& second) | 1349 static bool isVisiblyAdjacent(const Position& first, const Position& second) |
1350 { | 1350 { |
1351 return createVisiblePosition(first).deepEquivalent() == createVisiblePositio
n(mostBackwardCaretPosition(second)).deepEquivalent(); | 1351 return createVisiblePositionDeprecated(first).deepEquivalent() == createVisi
blePositionDeprecated(mostBackwardCaretPosition(second)).deepEquivalent(); |
1352 } | 1352 } |
1353 | 1353 |
1354 bool canMergeLists(Element* firstList, Element* secondList) | 1354 bool canMergeLists(Element* firstList, Element* secondList) |
1355 { | 1355 { |
1356 if (!firstList || !secondList || !firstList->isHTMLElement() || !secondList-
>isHTMLElement()) | 1356 if (!firstList || !secondList || !firstList->isHTMLElement() || !secondList-
>isHTMLElement()) |
1357 return false; | 1357 return false; |
1358 | 1358 |
1359 return firstList->hasTagName(secondList->tagQName()) // make sure the list t
ypes match (ol vs. ul) | 1359 return firstList->hasTagName(secondList->tagQName()) // make sure the list t
ypes match (ol vs. ul) |
1360 && hasEditableStyle(*firstList) && hasEditableStyle(*secondList) // both lis
ts are editable | 1360 && hasEditableStyle(*firstList) && hasEditableStyle(*secondList) // both lis
ts are editable |
1361 && rootEditableElement(*firstList) == rootEditableElement(*secondList) // do
n't cross editing boundaries | 1361 && rootEditableElement(*firstList) == rootEditableElement(*secondList) // do
n't cross editing boundaries |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 } | 1484 } |
1485 | 1485 |
1486 // return first preceding DOM position rendered at a different location, or "thi
s" | 1486 // return first preceding DOM position rendered at a different location, or "thi
s" |
1487 static Position previousCharacterPosition(const Position& position, TextAffinity
affinity) | 1487 static Position previousCharacterPosition(const Position& position, TextAffinity
affinity) |
1488 { | 1488 { |
1489 if (position.isNull()) | 1489 if (position.isNull()) |
1490 return Position(); | 1490 return Position(); |
1491 | 1491 |
1492 Element* fromRootEditableElement = rootEditableElement(*position.anchorNode(
)); | 1492 Element* fromRootEditableElement = rootEditableElement(*position.anchorNode(
)); |
1493 | 1493 |
1494 bool atStartOfLine = isStartOfLine(createVisiblePosition(position, affinity)
); | 1494 bool atStartOfLine = isStartOfLine(createVisiblePositionDeprecated(position,
affinity)); |
1495 bool rendered = isVisuallyEquivalentCandidate(position); | 1495 bool rendered = isVisuallyEquivalentCandidate(position); |
1496 | 1496 |
1497 Position currentPos = position; | 1497 Position currentPos = position; |
1498 while (!currentPos.atStartOfTree()) { | 1498 while (!currentPos.atStartOfTree()) { |
1499 // TODO(yosin) When we use |previousCharacterPosition()| other than | 1499 // TODO(yosin) When we use |previousCharacterPosition()| other than |
1500 // finding leading whitespace, we should use |Character| instead of | 1500 // finding leading whitespace, we should use |Character| instead of |
1501 // |CodePoint|. | 1501 // |CodePoint|. |
1502 currentPos = previousPositionOf(currentPos, PositionMoveType::CodeUnit); | 1502 currentPos = previousPositionOf(currentPos, PositionMoveType::CodeUnit); |
1503 | 1503 |
1504 if (rootEditableElement(*currentPos.anchorNode()) != fromRootEditableEle
ment) | 1504 if (rootEditableElement(*currentPos.anchorNode()) != fromRootEditableEle
ment) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 return prev; | 1543 return prev; |
1544 } | 1544 } |
1545 | 1545 |
1546 // This assumes that it starts in editable content. | 1546 // This assumes that it starts in editable content. |
1547 Position trailingWhitespacePosition(const Position& position, TextAffinity, Whit
espacePositionOption option) | 1547 Position trailingWhitespacePosition(const Position& position, TextAffinity, Whit
espacePositionOption option) |
1548 { | 1548 { |
1549 DCHECK(isEditablePosition(position)) << position; | 1549 DCHECK(isEditablePosition(position)) << position; |
1550 if (position.isNull()) | 1550 if (position.isNull()) |
1551 return Position(); | 1551 return Position(); |
1552 | 1552 |
1553 VisiblePosition visiblePosition = createVisiblePosition(position); | 1553 VisiblePosition visiblePosition = createVisiblePositionDeprecated(position); |
1554 UChar characterAfterVisiblePosition = characterAfter(visiblePosition); | 1554 UChar characterAfterVisiblePosition = characterAfter(visiblePosition); |
1555 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNewlin
e(characterAfterVisiblePosition) || characterAfterVisiblePosition == noBreakSpac
eCharacter) : isCollapsibleWhitespace(characterAfterVisiblePosition); | 1555 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNewlin
e(characterAfterVisiblePosition) || characterAfterVisiblePosition == noBreakSpac
eCharacter) : isCollapsibleWhitespace(characterAfterVisiblePosition); |
1556 // The space must not be in another paragraph and it must be editable. | 1556 // The space must not be in another paragraph and it must be editable. |
1557 if (isSpace && !isEndOfParagraph(visiblePosition) && nextPositionOf(visibleP
osition, CannotCrossEditingBoundary).isNotNull()) | 1557 if (isSpace && !isEndOfParagraph(visiblePosition) && nextPositionOf(visibleP
osition, CannotCrossEditingBoundary).isNotNull()) |
1558 return position; | 1558 return position; |
1559 return Position(); | 1559 return Position(); |
1560 } | 1560 } |
1561 | 1561 |
1562 unsigned numEnclosingMailBlockquotes(const Position& p) | 1562 unsigned numEnclosingMailBlockquotes(const Position& p) |
1563 { | 1563 { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) | 1752 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope) |
1753 { | 1753 { |
1754 if (!scope) | 1754 if (!scope) |
1755 return VisiblePosition(); | 1755 return VisiblePosition(); |
1756 EphemeralRange range = PlainTextRange(index).createRangeForSelection(*scope)
; | 1756 EphemeralRange range = PlainTextRange(index).createRangeForSelection(*scope)
; |
1757 // Check for an invalid index. Certain editing operations invalidate indices | 1757 // Check for an invalid index. Certain editing operations invalidate indices |
1758 // because of problems with | 1758 // because of problems with |
1759 // TextIteratorEmitsCharactersBetweenAllVisiblePositions. | 1759 // TextIteratorEmitsCharactersBetweenAllVisiblePositions. |
1760 if (range.isNull()) | 1760 if (range.isNull()) |
1761 return VisiblePosition(); | 1761 return VisiblePosition(); |
1762 return createVisiblePosition(range.startPosition()); | 1762 return createVisiblePositionDeprecated(range.startPosition()); |
1763 } | 1763 } |
1764 | 1764 |
1765 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. | 1765 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. |
1766 // Call this function to determine whether a node is visibly fit inside selected
Range | 1766 // Call this function to determine whether a node is visibly fit inside selected
Range |
1767 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) | 1767 bool isNodeVisiblyContainedWithin(Node& node, const Range& selectedRange) |
1768 { | 1768 { |
1769 if (selectedRange.isNodeFullyContained(node)) | 1769 if (selectedRange.isNodeFullyContained(node)) |
1770 return true; | 1770 return true; |
1771 | 1771 |
1772 bool startIsVisuallySame = visiblePositionBeforeNode(node).deepEquivalent()
== createVisiblePosition(selectedRange.startPosition()).deepEquivalent(); | 1772 bool startIsVisuallySame = visiblePositionBeforeNode(node).deepEquivalent()
== createVisiblePositionDeprecated(selectedRange.startPosition()).deepEquivalent
(); |
1773 if (startIsVisuallySame && comparePositions(Position::inParentAfterNode(node
), selectedRange.endPosition()) < 0) | 1773 if (startIsVisuallySame && comparePositions(Position::inParentAfterNode(node
), selectedRange.endPosition()) < 0) |
1774 return true; | 1774 return true; |
1775 | 1775 |
1776 bool endIsVisuallySame = visiblePositionAfterNode(node).deepEquivalent() ==
createVisiblePosition(selectedRange.endPosition()).deepEquivalent(); | 1776 bool endIsVisuallySame = visiblePositionAfterNode(node).deepEquivalent() ==
createVisiblePositionDeprecated(selectedRange.endPosition()).deepEquivalent(); |
1777 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), Pos
ition::inParentBeforeNode(node)) < 0) | 1777 if (endIsVisuallySame && comparePositions(selectedRange.startPosition(), Pos
ition::inParentBeforeNode(node)) < 0) |
1778 return true; | 1778 return true; |
1779 | 1779 |
1780 return startIsVisuallySame && endIsVisuallySame; | 1780 return startIsVisuallySame && endIsVisuallySame; |
1781 } | 1781 } |
1782 | 1782 |
1783 bool isRenderedAsNonInlineTableImageOrHR(const Node* node) | 1783 bool isRenderedAsNonInlineTableImageOrHR(const Node* node) |
1784 { | 1784 { |
1785 if (!node) | 1785 if (!node) |
1786 return false; | 1786 return false; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 return node.isElementNode() && layoutObject && layoutObject->isLayoutBlockFl
ow(); | 1829 return node.isElementNode() && layoutObject && layoutObject->isLayoutBlockFl
ow(); |
1830 } | 1830 } |
1831 | 1831 |
1832 Position adjustedSelectionStartForStyleComputation(const VisibleSelection& selec
tion) | 1832 Position adjustedSelectionStartForStyleComputation(const VisibleSelection& selec
tion) |
1833 { | 1833 { |
1834 // This function is used by range style computations to avoid bugs like: | 1834 // This function is used by range style computations to avoid bugs like: |
1835 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a se
lection starting from end of line once | 1835 // <rdar://problem/4017641> REGRESSION (Mail): you can only bold/unbold a se
lection starting from end of line once |
1836 // It is important to skip certain irrelevant content at the start of the se
lection, so we do not wind up | 1836 // It is important to skip certain irrelevant content at the start of the se
lection, so we do not wind up |
1837 // with a spurious "mixed" style. | 1837 // with a spurious "mixed" style. |
1838 | 1838 |
1839 VisiblePosition visiblePosition = createVisiblePosition(selection.start()); | 1839 VisiblePosition visiblePosition = createVisiblePositionDeprecated(selection.
start()); |
1840 if (visiblePosition.isNull()) | 1840 if (visiblePosition.isNull()) |
1841 return Position(); | 1841 return Position(); |
1842 | 1842 |
1843 // if the selection is a caret, just return the position, since the style | 1843 // if the selection is a caret, just return the position, since the style |
1844 // behind us is relevant | 1844 // behind us is relevant |
1845 if (selection.isCaret()) | 1845 if (selection.isCaret()) |
1846 return visiblePosition.deepEquivalent(); | 1846 return visiblePosition.deepEquivalent(); |
1847 | 1847 |
1848 // if the selection starts just before a paragraph break, skip over it | 1848 // if the selection starts just before a paragraph break, skip over it |
1849 if (isEndOfParagraph(visiblePosition)) | 1849 if (isEndOfParagraph(visiblePosition)) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 return InputType::DeleteWordBackward; | 1918 return InputType::DeleteWordBackward; |
1919 if (granularity == LineBoundary) | 1919 if (granularity == LineBoundary) |
1920 return InputType::DeleteLineBackward; | 1920 return InputType::DeleteLineBackward; |
1921 return InputType::DeleteContentBackward; | 1921 return InputType::DeleteContentBackward; |
1922 default: | 1922 default: |
1923 return InputType::None; | 1923 return InputType::None; |
1924 } | 1924 } |
1925 } | 1925 } |
1926 | 1926 |
1927 } // namespace blink | 1927 } // namespace blink |
OLD | NEW |