OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 void RenderView::setMaximalOutlineSize(int o) | 698 void RenderView::setMaximalOutlineSize(int o) |
699 { | 699 { |
700 if (o != m_maximalOutlineSize) { | 700 if (o != m_maximalOutlineSize) { |
701 m_maximalOutlineSize = o; | 701 m_maximalOutlineSize = o; |
702 | 702 |
703 // maximalOutlineSize affects compositing layer dimensions. | 703 // maximalOutlineSize affects compositing layer dimensions. |
704 compositor()->setCompositingLayersNeedRebuild(); // FIXME: this reall
y just needs to be a geometry update. | 704 compositor()->setCompositingLayersNeedRebuild(); // FIXME: this reall
y just needs to be a geometry update. |
705 } | 705 } |
706 } | 706 } |
707 | 707 |
| 708 // When exploring the RenderTree looking for the nodes involved in the Selection
, sometimes it's |
| 709 // required to change the traversing direction because the "start" position is b
elow the "end" one. |
| 710 static inline RenderObject* getNextOrPrevRenderObjectBasedOnDirection(const Rend
erObject* o, const RenderObject* stop, bool& continueExploring, bool& exploringB
ackwards) |
| 711 { |
| 712 RenderObject* next; |
| 713 if (exploringBackwards) { |
| 714 next = o->previousInPreOrder(); |
| 715 continueExploring = next && !(next)->isRenderView(); |
| 716 } else { |
| 717 next = o->nextInPreOrder(); |
| 718 continueExploring = next && next != stop; |
| 719 exploringBackwards = !next && (next != stop); |
| 720 if (exploringBackwards) { |
| 721 next = stop->previousInPreOrder(); |
| 722 continueExploring = next && !next->isRenderView(); |
| 723 } |
| 724 } |
| 725 |
| 726 return next; |
| 727 } |
| 728 |
708 void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
nd, int endPos, SelectionRepaintMode blockRepaintMode) | 729 void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
nd, int endPos, SelectionRepaintMode blockRepaintMode) |
709 { | 730 { |
710 // Make sure both our start and end objects are defined. | 731 // Make sure both our start and end objects are defined. |
711 // Check www.msnbc.com and try clicking around to find the case where this h
appened. | 732 // Check www.msnbc.com and try clicking around to find the case where this h
appened. |
712 if ((start && !end) || (end && !start)) | 733 if ((start && !end) || (end && !start)) |
713 return; | 734 return; |
714 | 735 |
715 // Just return if the selection hasn't changed. | 736 // Just return if the selection hasn't changed. |
716 if (m_selectionStart == start && m_selectionStartPos == startPos && | 737 if (m_selectionStart == start && m_selectionStartPos == startPos && |
717 m_selectionEnd == end && m_selectionEndPos == endPos) | 738 m_selectionEnd == end && m_selectionEndPos == endPos) |
718 return; | 739 return; |
719 | 740 |
720 if ((start && end) && (start->flowThreadContainingBlock() != end->flowThread
ContainingBlock())) | |
721 return; | |
722 | |
723 // Record the old selected objects. These will be used later | 741 // Record the old selected objects. These will be used later |
724 // when we compare against the new selected objects. | 742 // when we compare against the new selected objects. |
725 int oldStartPos = m_selectionStartPos; | 743 int oldStartPos = m_selectionStartPos; |
726 int oldEndPos = m_selectionEndPos; | 744 int oldEndPos = m_selectionEndPos; |
727 | 745 |
728 // Objects each have a single selection rect to examine. | 746 // Objects each have a single selection rect to examine. |
729 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectedObjectM
ap; | 747 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectedObjectM
ap; |
730 SelectedObjectMap oldSelectedObjects; | 748 SelectedObjectMap oldSelectedObjects; |
731 SelectedObjectMap newSelectedObjects; | 749 SelectedObjectMap newSelectedObjects; |
732 | 750 |
733 // Blocks contain selected objects and fill gaps between them, either on the
left, right, or in between lines and blocks. | 751 // Blocks contain selected objects and fill gaps between them, either on the
left, right, or in between lines and blocks. |
734 // In order to get the repaint rect right, we have to examine left, middle,
and right rects individually, since otherwise | 752 // In order to get the repaint rect right, we have to examine left, middle,
and right rects individually, since otherwise |
735 // the union of those rects might remain the same even when changes have occ
urred. | 753 // the union of those rects might remain the same even when changes have occ
urred. |
736 typedef HashMap<RenderBlock*, OwnPtr<RenderBlockSelectionInfo> > SelectedBlo
ckMap; | 754 typedef HashMap<RenderBlock*, OwnPtr<RenderBlockSelectionInfo> > SelectedBlo
ckMap; |
737 SelectedBlockMap oldSelectedBlocks; | 755 SelectedBlockMap oldSelectedBlocks; |
738 SelectedBlockMap newSelectedBlocks; | 756 SelectedBlockMap newSelectedBlocks; |
739 | 757 |
740 RenderObject* os = m_selectionStart; | 758 RenderObject* os = m_selectionStart; |
741 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); | 759 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); |
742 while (os && os != stop) { | 760 bool exploringBackwards = false; |
| 761 bool continueExploring = os && (os != stop); |
| 762 while (continueExploring) { |
743 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 763 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { |
744 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. | 764 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. |
745 oldSelectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, true
))); | 765 oldSelectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, true
))); |
746 if (blockRepaintMode == RepaintNewXOROld) { | 766 if (blockRepaintMode == RepaintNewXOROld) { |
747 RenderBlock* cb = os->containingBlock(); | 767 RenderBlock* cb = os->containingBlock(); |
748 while (cb && !cb->isRenderView()) { | 768 while (cb && !cb->isRenderView()) { |
749 OwnPtr<RenderBlockSelectionInfo>& blockInfo = oldSelectedBlo
cks.add(cb, nullptr).iterator->value; | 769 OwnPtr<RenderBlockSelectionInfo>& blockInfo = oldSelectedBlo
cks.add(cb, nullptr).iterator->value; |
750 if (blockInfo) | 770 if (blockInfo) |
751 break; | 771 break; |
752 blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); | 772 blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); |
753 cb = cb->containingBlock(); | 773 cb = cb->containingBlock(); |
754 } | 774 } |
755 } | 775 } |
756 } | 776 } |
757 | 777 |
758 os = os->nextInPreOrder(); | 778 os = getNextOrPrevRenderObjectBasedOnDirection(os, stop, continueExplori
ng, exploringBackwards); |
759 } | 779 } |
760 | 780 |
761 // Now clear the selection. | 781 // Now clear the selection. |
762 SelectedObjectMap::iterator oldObjectsEnd = oldSelectedObjects.end(); | 782 SelectedObjectMap::iterator oldObjectsEnd = oldSelectedObjects.end(); |
763 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj
ectsEnd; ++i) | 783 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj
ectsEnd; ++i) |
764 i->key->setSelectionStateIfNeeded(SelectionNone); | 784 i->key->setSelectionStateIfNeeded(SelectionNone); |
765 | 785 |
766 // set selection start and end | 786 // set selection start and end |
767 m_selectionStart = start; | 787 m_selectionStart = start; |
768 m_selectionStartPos = startPos; | 788 m_selectionStartPos = startPos; |
(...skipping 18 matching lines...) Expand all Loading... |
787 o->setSelectionStateIfNeeded(SelectionInside); | 807 o->setSelectionStateIfNeeded(SelectionInside); |
788 o = o->nextInPreOrder(); | 808 o = o->nextInPreOrder(); |
789 } | 809 } |
790 | 810 |
791 if (blockRepaintMode != RepaintNothing) | 811 if (blockRepaintMode != RepaintNothing) |
792 layer()->clearBlockSelectionGapsBounds(); | 812 layer()->clearBlockSelectionGapsBounds(); |
793 | 813 |
794 // Now that the selection state has been updated for the new objects, walk t
hem again and | 814 // Now that the selection state has been updated for the new objects, walk t
hem again and |
795 // put them in the new objects list. | 815 // put them in the new objects list. |
796 o = start; | 816 o = start; |
797 while (o && o != stop) { | 817 exploringBackwards = false; |
| 818 continueExploring = o && (o != stop); |
| 819 while (continueExploring) { |
798 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { | 820 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { |
799 newSelectedObjects.set(o, adoptPtr(new RenderSelectionInfo(o, true))
); | 821 newSelectedObjects.set(o, adoptPtr(new RenderSelectionInfo(o, true))
); |
800 RenderBlock* cb = o->containingBlock(); | 822 RenderBlock* cb = o->containingBlock(); |
801 while (cb && !cb->isRenderView()) { | 823 while (cb && !cb->isRenderView()) { |
802 OwnPtr<RenderBlockSelectionInfo>& blockInfo = newSelectedBlocks.
add(cb, nullptr).iterator->value; | 824 OwnPtr<RenderBlockSelectionInfo>& blockInfo = newSelectedBlocks.
add(cb, nullptr).iterator->value; |
803 if (blockInfo) | 825 if (blockInfo) |
804 break; | 826 break; |
805 blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); | 827 blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); |
806 cb = cb->containingBlock(); | 828 cb = cb->containingBlock(); |
807 } | 829 } |
808 } | 830 } |
809 | 831 |
810 o = o->nextInPreOrder(); | 832 o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring
, exploringBackwards); |
811 } | 833 } |
812 | 834 |
813 if (!m_frameView || blockRepaintMode == RepaintNothing) | 835 if (!m_frameView || blockRepaintMode == RepaintNothing) |
814 return; | 836 return; |
815 | 837 |
816 m_frameView->beginDeferredRepaints(); | 838 m_frameView->beginDeferredRepaints(); |
817 | 839 |
818 // Have any of the old selected objects changed compared to the new selectio
n? | 840 // Have any of the old selected objects changed compared to the new selectio
n? |
819 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj
ectsEnd; ++i) { | 841 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj
ectsEnd; ++i) { |
820 RenderObject* obj = i->key; | 842 RenderObject* obj = i->key; |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 #endif | 1212 #endif |
1191 | 1213 |
1192 if (layoutState) | 1214 if (layoutState) |
1193 layoutState->m_isPaginated = m_fragmenting; | 1215 layoutState->m_isPaginated = m_fragmenting; |
1194 | 1216 |
1195 if (m_flowThreadState != RenderObject::NotInsideFlowThread) | 1217 if (m_flowThreadState != RenderObject::NotInsideFlowThread) |
1196 m_root->setFlowThreadStateIncludingDescendants(m_flowThreadState); | 1218 m_root->setFlowThreadStateIncludingDescendants(m_flowThreadState); |
1197 } | 1219 } |
1198 | 1220 |
1199 } // namespace WebCore | 1221 } // namespace WebCore |
OLD | NEW |