| 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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 Node* node = *it; | 590 Node* node = *it; |
| 591 if (!isContainedInNodes(nodes, node)) | 591 if (!isContainedInNodes(nodes, node)) |
| 592 nodes.append(node); | 592 nodes.append(node); |
| 593 } | 593 } |
| 594 | 594 |
| 595 for (size_t i = 0; i < nodes.size(); i++) { | 595 for (size_t i = 0; i < nodes.size(); i++) { |
| 596 Node* contentNode = nodes.at(i); | 596 Node* contentNode = nodes.at(i); |
| 597 if (!contentNode->renderer()) | 597 if (!contentNode->renderer()) |
| 598 continue; | 598 continue; |
| 599 | 599 |
| 600 RefPtr<Range> range = Range::create(&contentNode->document()); | 600 RefPtr<Range> range = Range::create(contentNode->document()); |
| 601 bool foundStartPosition = false; | 601 bool foundStartPosition = false; |
| 602 bool startsAboveRegion = true; | 602 bool startsAboveRegion = true; |
| 603 bool endsBelowRegion = true; | 603 bool endsBelowRegion = true; |
| 604 bool skipOverOutsideNodes = false; | 604 bool skipOverOutsideNodes = false; |
| 605 Node* lastEndNode = 0; | 605 Node* lastEndNode = 0; |
| 606 | 606 |
| 607 for (Node* node = contentNode; node; node = NodeTraversal::next(node, co
ntentNode)) { | 607 for (Node* node = contentNode; node; node = NodeTraversal::next(node, co
ntentNode)) { |
| 608 RenderObject* renderer = node->renderer(); | 608 RenderObject* renderer = node->renderer(); |
| 609 if (!renderer) | 609 if (!renderer) |
| 610 continue; | 610 continue; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 631 | 631 |
| 632 // if the bounding box of the current element doesn't intersect the
region box | 632 // if the bounding box of the current element doesn't intersect the
region box |
| 633 // close the current range only if the start element began inside th
e region, | 633 // close the current range only if the start element began inside th
e region, |
| 634 // otherwise just move the start position after this node and keep s
kipping them until we found a proper start position. | 634 // otherwise just move the start position after this node and keep s
kipping them until we found a proper start position. |
| 635 if (!boxIntersectsRegion(logicalTopForRenderer, logicalBottomForRend
erer, logicalTopForRegion, logicalBottomForRegion)) { | 635 if (!boxIntersectsRegion(logicalTopForRenderer, logicalBottomForRend
erer, logicalTopForRegion, logicalBottomForRegion)) { |
| 636 if (foundStartPosition) { | 636 if (foundStartPosition) { |
| 637 if (!startsAboveRegion) { | 637 if (!startsAboveRegion) { |
| 638 if (range->intersectsNode(node, IGNORE_EXCEPTION)) | 638 if (range->intersectsNode(node, IGNORE_EXCEPTION)) |
| 639 range->setEndBefore(node, IGNORE_EXCEPTION); | 639 range->setEndBefore(node, IGNORE_EXCEPTION); |
| 640 rangeObjects.append(range->cloneRange(IGNORE_EXCEPTION))
; | 640 rangeObjects.append(range->cloneRange(IGNORE_EXCEPTION))
; |
| 641 range = Range::create(&contentNode->document()); | 641 range = Range::create(contentNode->document()); |
| 642 startsAboveRegion = true; | 642 startsAboveRegion = true; |
| 643 } else | 643 } else |
| 644 skipOverOutsideNodes = true; | 644 skipOverOutsideNodes = true; |
| 645 } | 645 } |
| 646 if (skipOverOutsideNodes) | 646 if (skipOverOutsideNodes) |
| 647 range->setStartAfter(node, IGNORE_EXCEPTION); | 647 range->setStartAfter(node, IGNORE_EXCEPTION); |
| 648 foundStartPosition = false; | 648 foundStartPosition = false; |
| 649 continue; | 649 continue; |
| 650 } | 650 } |
| 651 | 651 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 lastEndNode = node; | 710 lastEndNode = node; |
| 711 } | 711 } |
| 712 } | 712 } |
| 713 } | 713 } |
| 714 if (foundStartPosition || skipOverOutsideNodes) | 714 if (foundStartPosition || skipOverOutsideNodes) |
| 715 rangeObjects.append(range); | 715 rangeObjects.append(range); |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 | 718 |
| 719 } | 719 } |
| OLD | NEW |