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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 378 } |
379 | 379 |
380 fprintf(stderr, "Position [%s]: %s [%p] %s at %d\n", msg, anchorNode()->node
Name().utf8().data(), anchorNode(), anchorType, m_offset); | 380 fprintf(stderr, "Position [%s]: %s [%p] %s at %d\n", msg, anchorNode()->node
Name().utf8().data(), anchorNode(), anchorType, m_offset); |
381 } | 381 } |
382 | 382 |
383 PositionInComposedTree toPositionInComposedTree(const Position& pos) | 383 PositionInComposedTree toPositionInComposedTree(const Position& pos) |
384 { | 384 { |
385 if (pos.isNull()) | 385 if (pos.isNull()) |
386 return PositionInComposedTree(); | 386 return PositionInComposedTree(); |
387 | 387 |
388 PositionInComposedTree position; | |
389 if (pos.isOffsetInAnchor()) { | 388 if (pos.isOffsetInAnchor()) { |
390 Node* anchor = pos.anchorNode(); | 389 Node* anchor = pos.anchorNode(); |
391 if (anchor->offsetInCharacters()) | 390 if (anchor->offsetInCharacters()) |
392 return PositionInComposedTree(anchor, pos.computeOffsetInContainerNo
de()); | 391 return PositionInComposedTree(anchor, pos.computeOffsetInContainerNo
de()); |
393 ASSERT(!isActiveInsertionPoint(*anchor)); | 392 ASSERT(!isActiveInsertionPoint(*anchor)); |
394 int offset = pos.computeOffsetInContainerNode(); | 393 int offset = pos.computeOffsetInContainerNode(); |
395 Node* child = NodeTraversal::childAt(*anchor, offset); | 394 Node* child = NodeTraversal::childAt(*anchor, offset); |
396 if (!child) { | 395 if (!child) { |
397 if (anchor->isShadowRoot()) | 396 if (anchor->isShadowRoot()) |
398 return PositionInComposedTree(anchor->shadowHost(), PositionAnch
orType::AfterChildren); | 397 return PositionInComposedTree(anchor->shadowHost(), PositionAnch
orType::AfterChildren); |
399 return PositionInComposedTree(anchor, PositionAnchorType::AfterChild
ren); | 398 return PositionInComposedTree(anchor, PositionAnchorType::AfterChild
ren); |
400 } | 399 } |
401 child->updateDistribution(); | 400 child->updateDistribution(); |
402 if (isActiveInsertionPoint(*child)) { | 401 if (isActiveInsertionPoint(*child)) { |
403 if (anchor->isShadowRoot()) | 402 if (anchor->isShadowRoot()) |
404 return PositionInComposedTree(anchor->shadowHost(), offset); | 403 return PositionInComposedTree(anchor->shadowHost(), offset); |
405 return PositionInComposedTree(anchor, offset); | 404 return PositionInComposedTree(anchor, offset); |
406 } | 405 } |
407 return PositionInComposedTree(ComposedTreeTraversal::parent(*child), Com
posedTreeTraversal::index(*child)); | 406 if (Node* parent = ComposedTreeTraversal::parent(*child)) |
| 407 return PositionInComposedTree(parent, ComposedTreeTraversal::index(*
child)); |
| 408 // When |pos| isn't appeared in composed tree, we map |pos| to after |
| 409 // children of shadow host. |
| 410 // e.g. "foo",0 in <progress>foo</progress> |
| 411 if (anchor->isShadowRoot()) |
| 412 return PositionInComposedTree(anchor->shadowHost(), PositionAnchorTy
pe::AfterChildren); |
| 413 return PositionInComposedTree(anchor, PositionAnchorType::AfterChildren)
; |
408 } | 414 } |
409 | 415 |
410 return PositionInComposedTree(pos.anchorNode(), pos.anchorType()); | 416 return PositionInComposedTree(pos.anchorNode(), pos.anchorType()); |
411 } | 417 } |
412 | 418 |
413 Position toPositionInDOMTree(const Position& position) | 419 Position toPositionInDOMTree(const Position& position) |
414 { | 420 { |
415 return position; | 421 return position; |
416 } | 422 } |
417 | 423 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 536 |
531 void showTree(const blink::Position* pos) | 537 void showTree(const blink::Position* pos) |
532 { | 538 { |
533 if (pos) | 539 if (pos) |
534 pos->showTreeForThis(); | 540 pos->showTreeForThis(); |
535 else | 541 else |
536 fprintf(stderr, "Cannot showTree for (nil)\n"); | 542 fprintf(stderr, "Cannot showTree for (nil)\n"); |
537 } | 543 } |
538 | 544 |
539 #endif | 545 #endif |
OLD | NEW |