| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 | 499 |
| 500 Node* const anchor = pos.anchorNode(); | 500 Node* const anchor = pos.anchorNode(); |
| 501 if (pos.isOffsetInAnchor()) { | 501 if (pos.isOffsetInAnchor()) { |
| 502 if (anchor->isCharacterDataNode()) | 502 if (anchor->isCharacterDataNode()) |
| 503 return PositionInFlatTree(anchor, pos.computeOffsetInContainerNode()
); | 503 return PositionInFlatTree(anchor, pos.computeOffsetInContainerNode()
); |
| 504 DCHECK(!anchor->isSlotOrActiveInsertionPoint()); | 504 DCHECK(!anchor->isSlotOrActiveInsertionPoint()); |
| 505 int offset = pos.computeOffsetInContainerNode(); | 505 int offset = pos.computeOffsetInContainerNode(); |
| 506 Node* child = NodeTraversal::childAt(*anchor, offset); | 506 Node* child = NodeTraversal::childAt(*anchor, offset); |
| 507 if (!child) { | 507 if (!child) { |
| 508 if (anchor->isShadowRoot()) | 508 if (anchor->isShadowRoot()) |
| 509 return PositionInFlatTree(anchor->shadowHost(), PositionAnchorTy
pe::AfterChildren); | 509 return PositionInFlatTree(anchor->ownerShadowHost(), PositionAnc
horType::AfterChildren); |
| 510 return PositionInFlatTree(anchor, PositionAnchorType::AfterChildren)
; | 510 return PositionInFlatTree(anchor, PositionAnchorType::AfterChildren)
; |
| 511 } | 511 } |
| 512 child->updateDistribution(); | 512 child->updateDistribution(); |
| 513 if (child->isSlotOrActiveInsertionPoint()) { | 513 if (child->isSlotOrActiveInsertionPoint()) { |
| 514 if (anchor->isShadowRoot()) | 514 if (anchor->isShadowRoot()) |
| 515 return PositionInFlatTree(anchor->shadowHost(), offset); | 515 return PositionInFlatTree(anchor->ownerShadowHost(), offset); |
| 516 return PositionInFlatTree(anchor, offset); | 516 return PositionInFlatTree(anchor, offset); |
| 517 } | 517 } |
| 518 if (Node* parent = FlatTreeTraversal::parent(*child)) | 518 if (Node* parent = FlatTreeTraversal::parent(*child)) |
| 519 return PositionInFlatTree(parent, FlatTreeTraversal::index(*child)); | 519 return PositionInFlatTree(parent, FlatTreeTraversal::index(*child)); |
| 520 // When |pos| isn't appeared in flat tree, we map |pos| to after | 520 // When |pos| isn't appeared in flat tree, we map |pos| to after |
| 521 // children of shadow host. | 521 // children of shadow host. |
| 522 // e.g. "foo",0 in <progress>foo</progress> | 522 // e.g. "foo",0 in <progress>foo</progress> |
| 523 if (anchor->isShadowRoot()) | 523 if (anchor->isShadowRoot()) |
| 524 return PositionInFlatTree(anchor->shadowHost(), PositionAnchorType::
AfterChildren); | 524 return PositionInFlatTree(anchor->ownerShadowHost(), PositionAnchorT
ype::AfterChildren); |
| 525 return PositionInFlatTree(anchor, PositionAnchorType::AfterChildren); | 525 return PositionInFlatTree(anchor, PositionAnchorType::AfterChildren); |
| 526 } | 526 } |
| 527 | 527 |
| 528 if (anchor->isShadowRoot()) | 528 if (anchor->isShadowRoot()) |
| 529 return PositionInFlatTree(anchor->shadowHost(), pos.anchorType()); | 529 return PositionInFlatTree(anchor->ownerShadowHost(), pos.anchorType()); |
| 530 // TODO(yosin): Once we have a test case for SLOT or active insertion point, | 530 // TODO(yosin): Once we have a test case for SLOT or active insertion point, |
| 531 // this function should handle it. | 531 // this function should handle it. |
| 532 return PositionInFlatTree(anchor, pos.anchorType()); | 532 return PositionInFlatTree(anchor, pos.anchorType()); |
| 533 } | 533 } |
| 534 | 534 |
| 535 Position toPositionInDOMTree(const Position& position) | 535 Position toPositionInDOMTree(const Position& position) |
| 536 { | 536 { |
| 537 return position; | 537 return position; |
| 538 } | 538 } |
| 539 | 539 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 672 |
| 673 void showTree(const blink::Position* pos) | 673 void showTree(const blink::Position* pos) |
| 674 { | 674 { |
| 675 if (pos) | 675 if (pos) |
| 676 pos->showTreeForThis(); | 676 pos->showTreeForThis(); |
| 677 else | 677 else |
| 678 LOG(INFO) << "Cannot showTree for <null>"; | 678 LOG(INFO) << "Cannot showTree for <null>"; |
| 679 } | 679 } |
| 680 | 680 |
| 681 #endif | 681 #endif |
| OLD | NEW |