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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // children of shadow host. | 537 // children of shadow host. |
538 // e.g. "foo",0 in <progress>foo</progress> | 538 // e.g. "foo",0 in <progress>foo</progress> |
539 if (anchor->IsShadowRoot()) | 539 if (anchor->IsShadowRoot()) |
540 return PositionInFlatTree(anchor->OwnerShadowHost(), | 540 return PositionInFlatTree(anchor->OwnerShadowHost(), |
541 PositionAnchorType::kAfterChildren); | 541 PositionAnchorType::kAfterChildren); |
542 return PositionInFlatTree(anchor, PositionAnchorType::kAfterChildren); | 542 return PositionInFlatTree(anchor, PositionAnchorType::kAfterChildren); |
543 } | 543 } |
544 | 544 |
545 if (anchor->IsShadowRoot()) | 545 if (anchor->IsShadowRoot()) |
546 return PositionInFlatTree(anchor->OwnerShadowHost(), pos.AnchorType()); | 546 return PositionInFlatTree(anchor->OwnerShadowHost(), pos.AnchorType()); |
| 547 if (pos.IsBeforeAnchor() || pos.IsAfterAnchor()) { |
| 548 if (anchor->CanParticipateInFlatTree() && |
| 549 !FlatTreeTraversal::Parent(*anchor)) { |
| 550 // For Before/AfterAnchor, if |anchor| doesn't have parent in the flat |
| 551 // tree, there is no valid corresponding PositionInFlatTree. |
| 552 // Since this function is a primitive function, we do not adjust |pos| |
| 553 // to somewhere else in flat tree. |
| 554 // Reached by unit test |
| 555 // FrameSelectionTest.SelectInvalidPositionInFlatTreeDoesntCrash. |
| 556 return PositionInFlatTree(); |
| 557 } |
| 558 } |
547 // TODO(yosin): Once we have a test case for SLOT or active insertion point, | 559 // TODO(yosin): Once we have a test case for SLOT or active insertion point, |
548 // this function should handle it. | 560 // this function should handle it. |
549 return PositionInFlatTree(anchor, pos.AnchorType()); | 561 return PositionInFlatTree(anchor, pos.AnchorType()); |
550 } | 562 } |
551 | 563 |
552 Position ToPositionInDOMTree(const Position& position) { | 564 Position ToPositionInDOMTree(const Position& position) { |
553 return position; | 565 return position; |
554 } | 566 } |
555 | 567 |
556 Position ToPositionInDOMTree(const PositionInFlatTree& position) { | 568 Position ToPositionInDOMTree(const PositionInFlatTree& position) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 } | 694 } |
683 | 695 |
684 void showTree(const blink::Position* pos) { | 696 void showTree(const blink::Position* pos) { |
685 if (pos) | 697 if (pos) |
686 pos->ShowTreeForThis(); | 698 pos->ShowTreeForThis(); |
687 else | 699 else |
688 LOG(INFO) << "Cannot showTree for <null>"; | 700 LOG(INFO) << "Cannot showTree for <null>"; |
689 } | 701 } |
690 | 702 |
691 #endif | 703 #endif |
OLD | NEW |