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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo ckFlowOrTableElement are used. | 327 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo ckFlowOrTableElement are used. |
328 // FIXME: Pass a position to this function. The enclosing block of [table, x] fo r example, should be the | 328 // FIXME: Pass a position to this function. The enclosing block of [table, x] fo r example, should be the |
329 // block that contains the table and not the table, and this function should be the only one responsible for | 329 // block that contains the table and not the table, and this function should be the only one responsible for |
330 // knowing about these kinds of special cases. | 330 // knowing about these kinds of special cases. |
331 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) | 331 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) |
332 { | 332 { |
333 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node), isBlock, rule); | 333 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node), isBlock, rule); |
334 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing Node) : 0; | 334 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing Node) : 0; |
335 } | 335 } |
336 | 336 |
337 Element* enclosingBlockFlowElement(Node& node) | |
338 { | |
339 if (node.isBlockFlowElement()) | |
340 return &toElement(node); | |
341 | |
342 for (Node* n = node.parentNode(); n; n = n->parentNode()) { | |
343 if (n->isBlockFlowElement() || isHTMLBodyElement(*n)) | |
344 return toElement(n); | |
345 } | |
346 return 0; | |
347 } | |
348 | |
349 bool inSameContainingBlockFlowElement(Node* a, Node* b) | |
350 { | |
351 return a && b ? enclosingBlockFlowElement(*a) == enclosingBlockFlowElement(* b) : false; | |
leviw_travelin_and_unemployed
2014/07/28 21:39:56
a && b && enclosingBlockFlowElement(*a) == enclosi
Inactive
2014/07/28 21:47:11
Done.
| |
352 } | |
353 | |
337 TextDirection directionOfEnclosingBlock(const Position& position) | 354 TextDirection directionOfEnclosingBlock(const Position& position) |
338 { | 355 { |
339 Element* enclosingBlockElement = enclosingBlock(position.containerNode()); | 356 Element* enclosingBlockElement = enclosingBlock(position.containerNode()); |
340 if (!enclosingBlockElement) | 357 if (!enclosingBlockElement) |
341 return LTR; | 358 return LTR; |
342 RenderObject* renderer = enclosingBlockElement->renderer(); | 359 RenderObject* renderer = enclosingBlockElement->renderer(); |
343 return renderer ? renderer->style()->direction() : LTR; | 360 return renderer ? renderer->style()->direction() : LTR; |
344 } | 361 } |
345 | 362 |
346 // This method is used to create positions in the DOM. It returns the maximum va lid offset | 363 // This method is used to create positions in the DOM. It returns the maximum va lid offset |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
926 Position leadingWhitespacePosition(const Position& position, EAffinity affinity, WhitespacePositionOption option) | 943 Position leadingWhitespacePosition(const Position& position, EAffinity affinity, WhitespacePositionOption option) |
927 { | 944 { |
928 ASSERT(isEditablePosition(position, ContentIsEditable, DoNotUpdateStyle)); | 945 ASSERT(isEditablePosition(position, ContentIsEditable, DoNotUpdateStyle)); |
929 if (position.isNull()) | 946 if (position.isNull()) |
930 return Position(); | 947 return Position(); |
931 | 948 |
932 if (isHTMLBRElement(*position.upstream().anchorNode())) | 949 if (isHTMLBRElement(*position.upstream().anchorNode())) |
933 return Position(); | 950 return Position(); |
934 | 951 |
935 Position prev = previousCharacterPosition(position, affinity); | 952 Position prev = previousCharacterPosition(position, affinity); |
936 if (prev != position && prev.anchorNode()->inSameContainingBlockFlowElement( position.anchorNode()) && prev.anchorNode()->isTextNode()) { | 953 if (prev != position && inSameContainingBlockFlowElement(prev.anchorNode(), position.anchorNode()) && prev.anchorNode()->isTextNode()) { |
937 String string = toText(prev.anchorNode())->data(); | 954 String string = toText(prev.anchorNode())->data(); |
938 UChar previousCharacter = string[prev.deprecatedEditingOffset()]; | 955 UChar previousCharacter = string[prev.deprecatedEditingOffset()]; |
939 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNe wline(previousCharacter) || previousCharacter == noBreakSpace) : isCollapsibleWh itespace(previousCharacter); | 956 bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNe wline(previousCharacter) || previousCharacter == noBreakSpace) : isCollapsibleWh itespace(previousCharacter); |
940 if (isSpace && isEditablePosition(prev)) | 957 if (isSpace && isEditablePosition(prev)) |
941 return prev; | 958 return prev; |
942 } | 959 } |
943 | 960 |
944 return Position(); | 961 return Position(); |
945 } | 962 } |
946 | 963 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 // if the selection starts just before a paragraph break, skip over it | 1213 // if the selection starts just before a paragraph break, skip over it |
1197 if (isEndOfParagraph(visiblePosition)) | 1214 if (isEndOfParagraph(visiblePosition)) |
1198 return visiblePosition.next().deepEquivalent().downstream(); | 1215 return visiblePosition.next().deepEquivalent().downstream(); |
1199 | 1216 |
1200 // otherwise, make sure to be at the start of the first selected node, | 1217 // otherwise, make sure to be at the start of the first selected node, |
1201 // instead of possibly at the end of the last node before the selection | 1218 // instead of possibly at the end of the last node before the selection |
1202 return visiblePosition.deepEquivalent().downstream(); | 1219 return visiblePosition.deepEquivalent().downstream(); |
1203 } | 1220 } |
1204 | 1221 |
1205 } // namespace blink | 1222 } // namespace blink |
OLD | NEW |