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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 { | 535 { |
536 if (!object) | 536 if (!object) |
537 return 0; | 537 return 0; |
538 | 538 |
539 RenderObject* child = object->childAt(offset); | 539 RenderObject* child = object->childAt(offset); |
540 return child ? child : object->nextInPreOrderAfterChildren(); | 540 return child ? child : object->nextInPreOrderAfterChildren(); |
541 } | 541 } |
542 | 542 |
543 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const | 543 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const |
544 { | 544 { |
545 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap; | 545 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMemb
er<RenderSelectionInfo> > SelectionMap; |
546 SelectionMap selectedObjects; | 546 SelectionMap selectedObjects; |
547 | 547 |
548 RenderObject* os = m_selectionStart; | 548 RenderObject* os = m_selectionStart; |
549 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); | 549 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); |
550 while (os && os != stop) { | 550 while (os && os != stop) { |
551 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 551 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { |
552 // Blocks are responsible for painting line gaps and margin gaps. Th
ey must be examined as well. | 552 // Blocks are responsible for painting line gaps and margin gaps. Th
ey must be examined as well. |
553 selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToV
isibleContent))); | 553 selectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInfo(o
s, clipToVisibleContent))); |
554 RenderBlock* cb = os->containingBlock(); | 554 RenderBlock* cb = os->containingBlock(); |
555 while (cb && !cb->isRenderView()) { | 555 while (cb && !cb->isRenderView()) { |
556 OwnPtr<RenderSelectionInfo>& blockInfo = selectedObjects.add(cb,
nullptr).storedValue->value; | 556 OwnPtrWillBeMember<RenderSelectionInfo>& blockInfo = selectedObj
ects.add(cb, nullptr).storedValue->value; |
557 if (blockInfo) | 557 if (blockInfo) |
558 break; | 558 break; |
559 blockInfo = adoptPtr(new RenderSelectionInfo(cb, clipToVisibleCo
ntent)); | 559 blockInfo = adoptPtrWillBeNoop(new RenderSelectionInfo(cb, clipT
oVisibleContent)); |
560 cb = cb->containingBlock(); | 560 cb = cb->containingBlock(); |
561 } | 561 } |
562 } | 562 } |
563 | 563 |
564 os = os->nextInPreOrder(); | 564 os = os->nextInPreOrder(); |
565 } | 565 } |
566 | 566 |
567 // Now create a single bounding box rect that encloses the whole selection. | 567 // Now create a single bounding box rect that encloses the whole selection. |
568 LayoutRect selRect; | 568 LayoutRect selRect; |
569 SelectionMap::iterator end = selectedObjects.end(); | 569 SelectionMap::iterator end = selectedObjects.end(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 if (m_selectionStart == start && m_selectionStartPos == startPos && | 639 if (m_selectionStart == start && m_selectionStartPos == startPos && |
640 m_selectionEnd == end && m_selectionEndPos == endPos) | 640 m_selectionEnd == end && m_selectionEndPos == endPos) |
641 return; | 641 return; |
642 | 642 |
643 // Record the old selected objects. These will be used later | 643 // Record the old selected objects. These will be used later |
644 // when we compare against the new selected objects. | 644 // when we compare against the new selected objects. |
645 int oldStartPos = m_selectionStartPos; | 645 int oldStartPos = m_selectionStartPos; |
646 int oldEndPos = m_selectionEndPos; | 646 int oldEndPos = m_selectionEndPos; |
647 | 647 |
648 // Objects each have a single selection rect to examine. | 648 // Objects each have a single selection rect to examine. |
649 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectedObjectM
ap; | 649 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMemb
er<RenderSelectionInfo> > SelectedObjectMap; |
650 SelectedObjectMap oldSelectedObjects; | 650 SelectedObjectMap oldSelectedObjects; |
651 SelectedObjectMap newSelectedObjects; | 651 SelectedObjectMap newSelectedObjects; |
652 | 652 |
653 // Blocks contain selected objects and fill gaps between them, either on the
left, right, or in between lines and blocks. | 653 // Blocks contain selected objects and fill gaps between them, either on the
left, right, or in between lines and blocks. |
654 // In order to get the repaint rect right, we have to examine left, middle,
and right rects individually, since otherwise | 654 // In order to get the repaint rect right, we have to examine left, middle,
and right rects individually, since otherwise |
655 // the union of those rects might remain the same even when changes have occ
urred. | 655 // the union of those rects might remain the same even when changes have occ
urred. |
656 typedef HashMap<RenderBlock*, OwnPtr<RenderBlockSelectionInfo> > SelectedBlo
ckMap; | 656 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderBlock>, OwnPtrWillBeMembe
r<RenderBlockSelectionInfo> > SelectedBlockMap; |
657 SelectedBlockMap oldSelectedBlocks; | 657 SelectedBlockMap oldSelectedBlocks; |
658 SelectedBlockMap newSelectedBlocks; | 658 SelectedBlockMap newSelectedBlocks; |
659 | 659 |
660 RenderObject* os = m_selectionStart; | 660 RenderObject* os = m_selectionStart; |
661 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); | 661 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); |
662 bool exploringBackwards = false; | 662 bool exploringBackwards = false; |
663 bool continueExploring = os && (os != stop); | 663 bool continueExploring = os && (os != stop); |
664 while (continueExploring) { | 664 while (continueExploring) { |
665 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 665 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { |
666 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. | 666 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. |
667 oldSelectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, true
))); | 667 oldSelectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInf
o(os, true))); |
668 if (blockRepaintMode == RepaintNewXOROld) { | 668 if (blockRepaintMode == RepaintNewXOROld) { |
669 RenderBlock* cb = os->containingBlock(); | 669 RenderBlock* cb = os->containingBlock(); |
670 while (cb && !cb->isRenderView()) { | 670 while (cb && !cb->isRenderView()) { |
671 OwnPtr<RenderBlockSelectionInfo>& blockInfo = oldSelectedBlo
cks.add(cb, nullptr).storedValue->value; | 671 OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = ol
dSelectedBlocks.add(cb, nullptr).storedValue->value; |
672 if (blockInfo) | 672 if (blockInfo) |
673 break; | 673 break; |
674 blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); | 674 blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(
cb)); |
675 cb = cb->containingBlock(); | 675 cb = cb->containingBlock(); |
676 } | 676 } |
677 } | 677 } |
678 } | 678 } |
679 | 679 |
680 os = getNextOrPrevRenderObjectBasedOnDirection(os, stop, continueExplori
ng, exploringBackwards); | 680 os = getNextOrPrevRenderObjectBasedOnDirection(os, stop, continueExplori
ng, exploringBackwards); |
681 } | 681 } |
682 | 682 |
683 // Now clear the selection. | 683 // Now clear the selection. |
684 SelectedObjectMap::iterator oldObjectsEnd = oldSelectedObjects.end(); | 684 SelectedObjectMap::iterator oldObjectsEnd = oldSelectedObjects.end(); |
(...skipping 28 matching lines...) Expand all Loading... |
713 if (blockRepaintMode != RepaintNothing) | 713 if (blockRepaintMode != RepaintNothing) |
714 layer()->clearBlockSelectionGapsBounds(); | 714 layer()->clearBlockSelectionGapsBounds(); |
715 | 715 |
716 // Now that the selection state has been updated for the new objects, walk t
hem again and | 716 // Now that the selection state has been updated for the new objects, walk t
hem again and |
717 // put them in the new objects list. | 717 // put them in the new objects list. |
718 o = start; | 718 o = start; |
719 exploringBackwards = false; | 719 exploringBackwards = false; |
720 continueExploring = o && (o != stop); | 720 continueExploring = o && (o != stop); |
721 while (continueExploring) { | 721 while (continueExploring) { |
722 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { | 722 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { |
723 newSelectedObjects.set(o, adoptPtr(new RenderSelectionInfo(o, true))
); | 723 newSelectedObjects.set(o, adoptPtrWillBeNoop(new RenderSelectionInfo
(o, true))); |
724 RenderBlock* cb = o->containingBlock(); | 724 RenderBlock* cb = o->containingBlock(); |
725 while (cb && !cb->isRenderView()) { | 725 while (cb && !cb->isRenderView()) { |
726 OwnPtr<RenderBlockSelectionInfo>& blockInfo = newSelectedBlocks.
add(cb, nullptr).storedValue->value; | 726 OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = newSel
ectedBlocks.add(cb, nullptr).storedValue->value; |
727 if (blockInfo) | 727 if (blockInfo) |
728 break; | 728 break; |
729 blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); | 729 blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(cb))
; |
730 cb = cb->containingBlock(); | 730 cb = cb->containingBlock(); |
731 } | 731 } |
732 } | 732 } |
733 | 733 |
734 o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring
, exploringBackwards); | 734 o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring
, exploringBackwards); |
735 } | 735 } |
736 | 736 |
737 if (!m_frameView || blockRepaintMode == RepaintNothing) | 737 if (!m_frameView || blockRepaintMode == RepaintNothing) |
738 return; | 738 return; |
739 | 739 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 return viewWidth(IncludeScrollbars) / scale; | 986 return viewWidth(IncludeScrollbars) / scale; |
987 } | 987 } |
988 | 988 |
989 double RenderView::layoutViewportHeight() const | 989 double RenderView::layoutViewportHeight() const |
990 { | 990 { |
991 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 991 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
992 return viewHeight(IncludeScrollbars) / scale; | 992 return viewHeight(IncludeScrollbars) / scale; |
993 } | 993 } |
994 | 994 |
995 } // namespace blink | 995 } // namespace blink |
OLD | NEW |