| 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 } | 500 } |
| 501 | 501 |
| 502 PositionInFlatTree toPositionInFlatTree(const Position& pos) { | 502 PositionInFlatTree toPositionInFlatTree(const Position& pos) { |
| 503 if (pos.isNull()) | 503 if (pos.isNull()) |
| 504 return PositionInFlatTree(); | 504 return PositionInFlatTree(); |
| 505 | 505 |
| 506 Node* const anchor = pos.anchorNode(); | 506 Node* const anchor = pos.anchorNode(); |
| 507 if (pos.isOffsetInAnchor()) { | 507 if (pos.isOffsetInAnchor()) { |
| 508 if (anchor->isCharacterDataNode()) | 508 if (anchor->isCharacterDataNode()) |
| 509 return PositionInFlatTree(anchor, pos.computeOffsetInContainerNode()); | 509 return PositionInFlatTree(anchor, pos.computeOffsetInContainerNode()); |
| 510 DCHECK(!anchor->isSlotOrActiveInsertionPoint()); | 510 DCHECK(!anchor->isActiveSlotOrActiveInsertionPoint()); |
| 511 int offset = pos.computeOffsetInContainerNode(); | 511 int offset = pos.computeOffsetInContainerNode(); |
| 512 Node* child = NodeTraversal::childAt(*anchor, offset); | 512 Node* child = NodeTraversal::childAt(*anchor, offset); |
| 513 if (!child) { | 513 if (!child) { |
| 514 if (anchor->isShadowRoot()) | 514 if (anchor->isShadowRoot()) |
| 515 return PositionInFlatTree(anchor->ownerShadowHost(), | 515 return PositionInFlatTree(anchor->ownerShadowHost(), |
| 516 PositionAnchorType::AfterChildren); | 516 PositionAnchorType::AfterChildren); |
| 517 return PositionInFlatTree(anchor, PositionAnchorType::AfterChildren); | 517 return PositionInFlatTree(anchor, PositionAnchorType::AfterChildren); |
| 518 } | 518 } |
| 519 child->updateDistribution(); | 519 child->updateDistribution(); |
| 520 if (child->isSlotOrActiveInsertionPoint()) { | 520 if (child->isActiveSlotOrActiveInsertionPoint()) { |
| 521 if (anchor->isShadowRoot()) | 521 if (anchor->isShadowRoot()) |
| 522 return PositionInFlatTree(anchor->ownerShadowHost(), offset); | 522 return PositionInFlatTree(anchor->ownerShadowHost(), offset); |
| 523 return PositionInFlatTree(anchor, offset); | 523 return PositionInFlatTree(anchor, offset); |
| 524 } | 524 } |
| 525 if (Node* parent = FlatTreeTraversal::parent(*child)) | 525 if (Node* parent = FlatTreeTraversal::parent(*child)) |
| 526 return PositionInFlatTree(parent, FlatTreeTraversal::index(*child)); | 526 return PositionInFlatTree(parent, FlatTreeTraversal::index(*child)); |
| 527 // When |pos| isn't appeared in flat tree, we map |pos| to after | 527 // When |pos| isn't appeared in flat tree, we map |pos| to after |
| 528 // children of shadow host. | 528 // children of shadow host. |
| 529 // e.g. "foo",0 in <progress>foo</progress> | 529 // e.g. "foo",0 in <progress>foo</progress> |
| 530 if (anchor->isShadowRoot()) | 530 if (anchor->isShadowRoot()) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 } | 672 } |
| 673 | 673 |
| 674 void showTree(const blink::Position* pos) { | 674 void showTree(const blink::Position* pos) { |
| 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 |