| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/editing/VisibleSelection.h" | 27 #include "core/editing/VisibleSelection.h" |
| 28 | 28 |
| 29 #include <stdio.h> | 29 #include <stdio.h> |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/dom/Element.h" | 31 #include "core/dom/Element.h" |
| 32 #include "core/dom/Range.h" | 32 #include "core/dom/Range.h" |
| 33 #include "core/editing/TextIterator.h" | 33 #include "core/editing/TextIterator.h" |
| 34 #include "core/editing/VisiblePosition.h" | 34 #include "core/editing/VisiblePosition.h" |
| 35 #include "core/editing/VisibleUnits.h" | 35 #include "core/editing/VisibleUnits.h" |
| 36 #include "core/editing/htmlediting.h" | 36 #include "core/editing/htmlediting.h" |
| 37 #include "core/platform/graphics/LayoutPoint.h" |
| 38 #include "core/rendering/RenderObject.h" |
| 37 #include <wtf/Assertions.h> | 39 #include <wtf/Assertions.h> |
| 38 #include <wtf/text/CString.h> | 40 #include <wtf/text/CString.h> |
| 39 #include <wtf/text/StringBuilder.h> | 41 #include <wtf/text/StringBuilder.h> |
| 40 #include <wtf/unicode/CharacterNames.h> | 42 #include <wtf/unicode/CharacterNames.h> |
| 41 | 43 |
| 42 namespace WebCore { | 44 namespace WebCore { |
| 43 | 45 |
| 44 VisibleSelection::VisibleSelection() | 46 VisibleSelection::VisibleSelection() |
| 45 : m_affinity(DOWNSTREAM) | 47 : m_affinity(DOWNSTREAM) |
| 46 , m_selectionType(NoSelection) | 48 , m_selectionType(NoSelection) |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 } | 619 } |
| 618 m_start = next.deepEquivalent(); | 620 m_start = next.deepEquivalent(); |
| 619 } | 621 } |
| 620 } | 622 } |
| 621 | 623 |
| 622 // Correct the extent if necessary. | 624 // Correct the extent if necessary. |
| 623 if (baseEditableAncestor != lowestEditableAncestor(m_extent.containerNode())
) | 625 if (baseEditableAncestor != lowestEditableAncestor(m_extent.containerNode())
) |
| 624 m_extent = m_baseIsFirst ? m_end : m_start; | 626 m_extent = m_baseIsFirst ? m_end : m_start; |
| 625 } | 627 } |
| 626 | 628 |
| 629 VisiblePosition VisibleSelection::visiblePositionRespectingEditingBoundary(const
LayoutPoint& localPoint, Node* targetNode) const |
| 630 { |
| 631 if (!targetNode->renderer()) |
| 632 return VisiblePosition(); |
| 633 |
| 634 LayoutPoint selectionEndPoint = localPoint; |
| 635 Element* editableElement = rootEditableElement(); |
| 636 |
| 637 if (editableElement && !editableElement->contains(targetNode)) { |
| 638 if (!editableElement->renderer()) |
| 639 return VisiblePosition(); |
| 640 |
| 641 FloatPoint absolutePoint = targetNode->renderer()->localToAbsolute(Float
Point(selectionEndPoint)); |
| 642 selectionEndPoint = roundedLayoutPoint(editableElement->renderer()->abso
luteToLocal(absolutePoint)); |
| 643 targetNode = editableElement; |
| 644 } |
| 645 |
| 646 return targetNode->renderer()->positionForPoint(selectionEndPoint); |
| 647 } |
| 648 |
| 649 |
| 627 bool VisibleSelection::isContentEditable() const | 650 bool VisibleSelection::isContentEditable() const |
| 628 { | 651 { |
| 629 return isEditablePosition(start()); | 652 return isEditablePosition(start()); |
| 630 } | 653 } |
| 631 | 654 |
| 632 bool VisibleSelection::rendererIsEditable() const | 655 bool VisibleSelection::rendererIsEditable() const |
| 633 { | 656 { |
| 634 return isEditablePosition(start(), ContentIsEditable, DoNotUpdateStyle); | 657 return isEditablePosition(start(), ContentIsEditable, DoNotUpdateStyle); |
| 635 } | 658 } |
| 636 | 659 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 sel.showTreeForThis(); | 736 sel.showTreeForThis(); |
| 714 } | 737 } |
| 715 | 738 |
| 716 void showTree(const WebCore::VisibleSelection* sel) | 739 void showTree(const WebCore::VisibleSelection* sel) |
| 717 { | 740 { |
| 718 if (sel) | 741 if (sel) |
| 719 sel->showTreeForThis(); | 742 sel->showTreeForThis(); |
| 720 } | 743 } |
| 721 | 744 |
| 722 #endif | 745 #endif |
| OLD | NEW |