| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 605 |
| 606 LayoutUnit logicalTopForRenderer = region->logicalTopOfFlowThreadCon
tentRect(boundingBox); | 606 LayoutUnit logicalTopForRenderer = region->logicalTopOfFlowThreadCon
tentRect(boundingBox); |
| 607 LayoutUnit logicalBottomForRenderer = region->logicalBottomOfFlowThr
eadContentRect(boundingBox); | 607 LayoutUnit logicalBottomForRenderer = region->logicalBottomOfFlowThr
eadContentRect(boundingBox); |
| 608 | 608 |
| 609 // if the bounding box of the current element doesn't intersect the
region box | 609 // if the bounding box of the current element doesn't intersect the
region box |
| 610 // close the current range only if the start element began inside th
e region, | 610 // close the current range only if the start element began inside th
e region, |
| 611 // otherwise just move the start position after this node and keep s
kipping them until we found a proper start position. | 611 // otherwise just move the start position after this node and keep s
kipping them until we found a proper start position. |
| 612 if (!boxIntersectsRegion(logicalTopForRenderer, logicalBottomForRend
erer, logicalTopForRegion, logicalBottomForRegion)) { | 612 if (!boxIntersectsRegion(logicalTopForRenderer, logicalBottomForRend
erer, logicalTopForRegion, logicalBottomForRegion)) { |
| 613 if (foundStartPosition) { | 613 if (foundStartPosition) { |
| 614 if (!startsAboveRegion) { | 614 if (!startsAboveRegion) { |
| 615 if (range->intersectsNode(node, IGNORE_EXCEPTION_STATE)) | 615 if (range->intersectsNode(node, IGNORE_EXCEPTION)) |
| 616 range->setEndBefore(node, IGNORE_EXCEPTION_STATE); | 616 range->setEndBefore(node, IGNORE_EXCEPTION); |
| 617 rangeObjects.append(range->cloneRange(IGNORE_EXCEPTION_S
TATE)); | 617 rangeObjects.append(range->cloneRange(IGNORE_EXCEPTION))
; |
| 618 range = Range::create(contentNode->document()); | 618 range = Range::create(contentNode->document()); |
| 619 startsAboveRegion = true; | 619 startsAboveRegion = true; |
| 620 } else | 620 } else |
| 621 skipOverOutsideNodes = true; | 621 skipOverOutsideNodes = true; |
| 622 } | 622 } |
| 623 if (skipOverOutsideNodes) | 623 if (skipOverOutsideNodes) |
| 624 range->setStartAfter(node, IGNORE_EXCEPTION_STATE); | 624 range->setStartAfter(node, IGNORE_EXCEPTION); |
| 625 foundStartPosition = false; | 625 foundStartPosition = false; |
| 626 continue; | 626 continue; |
| 627 } | 627 } |
| 628 | 628 |
| 629 // start position | 629 // start position |
| 630 if (logicalTopForRenderer < logicalTopForRegion && startsAboveRegion
) { | 630 if (logicalTopForRenderer < logicalTopForRegion && startsAboveRegion
) { |
| 631 if (renderer->isText()) { // Text crosses region top | 631 if (renderer->isText()) { // Text crosses region top |
| 632 // for Text elements, just find the last textbox that is con
tained inside the region and use its start() offset as start position | 632 // for Text elements, just find the last textbox that is con
tained inside the region and use its start() offset as start position |
| 633 RenderText* textRenderer = toRenderText(renderer); | 633 RenderText* textRenderer = toRenderText(renderer); |
| 634 for (InlineTextBox* box = textRenderer->firstTextBox(); box;
box = box->nextTextBox()) { | 634 for (InlineTextBox* box = textRenderer->firstTextBox(); box;
box = box->nextTextBox()) { |
| 635 if (offsetTop + box->logicalBottom() < logicalTopForRegi
on) | 635 if (offsetTop + box->logicalBottom() < logicalTopForRegi
on) |
| 636 continue; | 636 continue; |
| 637 range->setStart(Position(toText(node), box->start())); | 637 range->setStart(Position(toText(node), box->start())); |
| 638 startsAboveRegion = false; | 638 startsAboveRegion = false; |
| 639 break; | 639 break; |
| 640 } | 640 } |
| 641 } else { // node crosses region top | 641 } else { // node crosses region top |
| 642 // for all elements, except Text, just set the start positio
n to be before their children | 642 // for all elements, except Text, just set the start positio
n to be before their children |
| 643 startsAboveRegion = true; | 643 startsAboveRegion = true; |
| 644 range->setStart(Position(node, Position::PositionIsBeforeChi
ldren)); | 644 range->setStart(Position(node, Position::PositionIsBeforeChi
ldren)); |
| 645 } | 645 } |
| 646 } else { // node starts inside region | 646 } else { // node starts inside region |
| 647 // for elements that start inside the region, set the start posi
tion to be before them. If we found one, we will just skip the others until | 647 // for elements that start inside the region, set the start posi
tion to be before them. If we found one, we will just skip the others until |
| 648 // the range is closed. | 648 // the range is closed. |
| 649 if (startsAboveRegion) { | 649 if (startsAboveRegion) { |
| 650 startsAboveRegion = false; | 650 startsAboveRegion = false; |
| 651 range->setStartBefore(node, IGNORE_EXCEPTION_STATE); | 651 range->setStartBefore(node, IGNORE_EXCEPTION); |
| 652 } | 652 } |
| 653 } | 653 } |
| 654 skipOverOutsideNodes = false; | 654 skipOverOutsideNodes = false; |
| 655 foundStartPosition = true; | 655 foundStartPosition = true; |
| 656 | 656 |
| 657 // end position | 657 // end position |
| 658 if (logicalBottomForRegion < logicalBottomForRenderer && (endsBelowR
egion || (!endsBelowRegion && !node->isDescendantOf(lastEndNode)))) { | 658 if (logicalBottomForRegion < logicalBottomForRenderer && (endsBelowR
egion || (!endsBelowRegion && !node->isDescendantOf(lastEndNode)))) { |
| 659 // for Text elements, just find just find the last textbox that
is contained inside the region and use its start()+len() offset as end position | 659 // for Text elements, just find just find the last textbox that
is contained inside the region and use its start()+len() offset as end position |
| 660 if (renderer->isText()) { // Text crosses region bottom | 660 if (renderer->isText()) { // Text crosses region bottom |
| 661 RenderText* textRenderer = toRenderText(renderer); | 661 RenderText* textRenderer = toRenderText(renderer); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 675 } else { // node crosses region bottom | 675 } else { // node crosses region bottom |
| 676 // for all elements, except Text, just set the start positio
n to be after their children | 676 // for all elements, except Text, just set the start positio
n to be after their children |
| 677 range->setEnd(Position(node, Position::PositionIsAfterChildr
en)); | 677 range->setEnd(Position(node, Position::PositionIsAfterChildr
en)); |
| 678 endsBelowRegion = true; | 678 endsBelowRegion = true; |
| 679 lastEndNode = node; | 679 lastEndNode = node; |
| 680 } | 680 } |
| 681 } else { // node ends inside region | 681 } else { // node ends inside region |
| 682 // for elements that ends inside the region, set the end positio
n to be after them | 682 // for elements that ends inside the region, set the end positio
n to be after them |
| 683 // allow this end position to be changed only by other elements
that are not descendants of the current end node | 683 // allow this end position to be changed only by other elements
that are not descendants of the current end node |
| 684 if (endsBelowRegion || (!endsBelowRegion && !node->isDescendantO
f(lastEndNode))) { | 684 if (endsBelowRegion || (!endsBelowRegion && !node->isDescendantO
f(lastEndNode))) { |
| 685 range->setEndAfter(node, IGNORE_EXCEPTION_STATE); | 685 range->setEndAfter(node, IGNORE_EXCEPTION); |
| 686 endsBelowRegion = false; | 686 endsBelowRegion = false; |
| 687 lastEndNode = node; | 687 lastEndNode = node; |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 } | 690 } |
| 691 if (foundStartPosition || skipOverOutsideNodes) | 691 if (foundStartPosition || skipOverOutsideNodes) |
| 692 rangeObjects.append(range); | 692 rangeObjects.append(range); |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 | 695 |
| 696 } | 696 } |
| OLD | NEW |