| 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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 Element* enclosingBlock(const PositionInFlatTree& position, EditingBoundaryCross
ingRule rule) | 766 Element* enclosingBlock(const PositionInFlatTree& position, EditingBoundaryCross
ingRule rule) |
| 767 { | 767 { |
| 768 return enclosingBlockAlgorithm<EditingInFlatTreeStrategy>(position, rule); | 768 return enclosingBlockAlgorithm<EditingInFlatTreeStrategy>(position, rule); |
| 769 } | 769 } |
| 770 | 770 |
| 771 Element* enclosingBlockFlowElement(const Node& node) | 771 Element* enclosingBlockFlowElement(const Node& node) |
| 772 { | 772 { |
| 773 if (isBlockFlowElement(node)) | 773 if (isBlockFlowElement(node)) |
| 774 return const_cast<Element*>(&toElement(node)); | 774 return const_cast<Element*>(&toElement(node)); |
| 775 | 775 |
| 776 for (Node* n = node.parentNode(); n; n = n->parentNode()) { | 776 for (Node& runner : NodeTraversal::ancestorsOf(node)) { |
| 777 if (isBlockFlowElement(*n) || isHTMLBodyElement(*n)) | 777 if (isBlockFlowElement(runner) || isHTMLBodyElement(runner)) |
| 778 return toElement(n); | 778 return toElement(&runner); |
| 779 } | 779 } |
| 780 return nullptr; | 780 return nullptr; |
| 781 } | 781 } |
| 782 | 782 |
| 783 bool nodeIsUserSelectAll(const Node* node) | 783 bool nodeIsUserSelectAll(const Node* node) |
| 784 { | 784 { |
| 785 return RuntimeEnabledFeatures::userSelectAllEnabled() && node && node->layou
tObject() && node->layoutObject()->style()->userSelect() == SELECT_ALL; | 785 return RuntimeEnabledFeatures::userSelectAllEnabled() && node && node->layou
tObject() && node->layoutObject()->style()->userSelect() == SELECT_ALL; |
| 786 | 786 |
| 787 } | 787 } |
| 788 | 788 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 | 879 |
| 880 if (layoutObject->style()->isFloating()) | 880 if (layoutObject->style()->isFloating()) |
| 881 return true; | 881 return true; |
| 882 | 882 |
| 883 return false; | 883 return false; |
| 884 } | 884 } |
| 885 | 885 |
| 886 static HTMLElement* firstInSpecialElement(const Position& pos) | 886 static HTMLElement* firstInSpecialElement(const Position& pos) |
| 887 { | 887 { |
| 888 Element* rootEditableElement = pos.computeContainerNode()->rootEditableEleme
nt(); | 888 Element* rootEditableElement = pos.computeContainerNode()->rootEditableEleme
nt(); |
| 889 for (Node* n = pos.anchorNode(); n && n->rootEditableElement() == rootEditab
leElement; n = n->parentNode()) { | 889 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*pos.anchorNode()))
{ |
| 890 if (isSpecialHTMLElement(*n)) { | 890 if (runner.rootEditableElement() != rootEditableElement) |
| 891 HTMLElement* specialElement = toHTMLElement(n); | 891 break; |
| 892 if (isSpecialHTMLElement(runner)) { |
| 893 HTMLElement* specialElement = toHTMLElement(&runner); |
| 892 VisiblePosition vPos = createVisiblePosition(pos); | 894 VisiblePosition vPos = createVisiblePosition(pos); |
| 893 VisiblePosition firstInElement = createVisiblePosition(firstPosition
InOrBeforeNode(specialElement)); | 895 VisiblePosition firstInElement = createVisiblePosition(firstPosition
InOrBeforeNode(specialElement)); |
| 894 if (isDisplayInsideTable(specialElement) && vPos.deepEquivalent() ==
nextPositionOf(firstInElement).deepEquivalent()) | 896 if (isDisplayInsideTable(specialElement) && vPos.deepEquivalent() ==
nextPositionOf(firstInElement).deepEquivalent()) |
| 895 return specialElement; | 897 return specialElement; |
| 896 if (vPos.deepEquivalent() == firstInElement.deepEquivalent()) | 898 if (vPos.deepEquivalent() == firstInElement.deepEquivalent()) |
| 897 return specialElement; | 899 return specialElement; |
| 898 } | 900 } |
| 899 } | 901 } |
| 900 return 0; | 902 return 0; |
| 901 } | 903 } |
| 902 | 904 |
| 903 static HTMLElement* lastInSpecialElement(const Position& pos) | 905 static HTMLElement* lastInSpecialElement(const Position& pos) |
| 904 { | 906 { |
| 905 Element* rootEditableElement = pos.computeContainerNode()->rootEditableEleme
nt(); | 907 Element* rootEditableElement = pos.computeContainerNode()->rootEditableEleme
nt(); |
| 906 for (Node* n = pos.anchorNode(); n && n->rootEditableElement() == rootEditab
leElement; n = n->parentNode()) { | 908 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*pos.anchorNode()))
{ |
| 907 if (isSpecialHTMLElement(*n)) { | 909 if (runner.rootEditableElement() != rootEditableElement) |
| 908 HTMLElement* specialElement = toHTMLElement(n); | 910 break; |
| 911 if (isSpecialHTMLElement(runner)) { |
| 912 HTMLElement* specialElement = toHTMLElement(&runner); |
| 909 VisiblePosition vPos = createVisiblePosition(pos); | 913 VisiblePosition vPos = createVisiblePosition(pos); |
| 910 VisiblePosition lastInElement = createVisiblePosition(lastPositionIn
OrAfterNode(specialElement)); | 914 VisiblePosition lastInElement = createVisiblePosition(lastPositionIn
OrAfterNode(specialElement)); |
| 911 if (isDisplayInsideTable(specialElement) && vPos.deepEquivalent() ==
previousPositionOf(lastInElement).deepEquivalent()) | 915 if (isDisplayInsideTable(specialElement) && vPos.deepEquivalent() ==
previousPositionOf(lastInElement).deepEquivalent()) |
| 912 return specialElement; | 916 return specialElement; |
| 913 if (vPos.deepEquivalent() == lastInElement.deepEquivalent()) | 917 if (vPos.deepEquivalent() == lastInElement.deepEquivalent()) |
| 914 return specialElement; | 918 return specialElement; |
| 915 } | 919 } |
| 916 } | 920 } |
| 917 return 0; | 921 return 0; |
| 918 } | 922 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 return 0; | 1175 return 0; |
| 1172 } | 1176 } |
| 1173 | 1177 |
| 1174 HTMLElement* enclosingList(Node* node) | 1178 HTMLElement* enclosingList(Node* node) |
| 1175 { | 1179 { |
| 1176 if (!node) | 1180 if (!node) |
| 1177 return 0; | 1181 return 0; |
| 1178 | 1182 |
| 1179 ContainerNode* root = highestEditableRoot(firstPositionInOrBeforeNode(node))
; | 1183 ContainerNode* root = highestEditableRoot(firstPositionInOrBeforeNode(node))
; |
| 1180 | 1184 |
| 1181 for (ContainerNode* n = node->parentNode(); n; n = n->parentNode()) { | 1185 for (Node& runner : NodeTraversal::ancestorsOf(*node)) { |
| 1182 if (isHTMLUListElement(*n) || isHTMLOListElement(*n)) | 1186 if (isHTMLUListElement(runner) || isHTMLOListElement(runner)) |
| 1183 return toHTMLElement(n); | 1187 return toHTMLElement(&runner); |
| 1184 if (n == root) | 1188 if (runner == root) |
| 1185 return 0; | 1189 return 0; |
| 1186 } | 1190 } |
| 1187 | 1191 |
| 1188 return 0; | 1192 return 0; |
| 1189 } | 1193 } |
| 1190 | 1194 |
| 1191 Node* enclosingListChild(Node *node) | 1195 Node* enclosingListChild(Node *node) |
| 1192 { | 1196 { |
| 1193 if (!node) | 1197 if (!node) |
| 1194 return 0; | 1198 return 0; |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 { | 1760 { |
| 1757 if (!RuntimeEnabledFeatures::inputEventEnabled()) | 1761 if (!RuntimeEnabledFeatures::inputEventEnabled()) |
| 1758 return DispatchEventResult::NotCanceled; | 1762 return DispatchEventResult::NotCanceled; |
| 1759 if (!target) | 1763 if (!target) |
| 1760 return DispatchEventResult::NotCanceled; | 1764 return DispatchEventResult::NotCanceled; |
| 1761 InputEvent* beforeInputEvent = InputEvent::createBeforeInput(inputType, data
, InputEvent::EventCancelable::IsCancelable); | 1765 InputEvent* beforeInputEvent = InputEvent::createBeforeInput(inputType, data
, InputEvent::EventCancelable::IsCancelable); |
| 1762 return target->dispatchEvent(beforeInputEvent); | 1766 return target->dispatchEvent(beforeInputEvent); |
| 1763 } | 1767 } |
| 1764 | 1768 |
| 1765 } // namespace blink | 1769 } // namespace blink |
| OLD | NEW |