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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 LayoutSize offsetForFixedPosition; | 359 LayoutSize offsetForFixedPosition; |
360 LayoutSize offset; | 360 LayoutSize offset; |
361 LayoutObject* container = nullptr; | 361 LayoutObject* container = nullptr; |
362 | 362 |
363 if (m_frameView) { | 363 if (m_frameView) { |
364 offsetForFixedPosition = LayoutSize(toIntSize(m_frameView->scrollPositio
n())); | 364 offsetForFixedPosition = LayoutSize(toIntSize(m_frameView->scrollPositio
n())); |
365 if (hasOverflowClip()) | 365 if (hasOverflowClip()) |
366 offsetForFixedPosition = LayoutSize(scrolledContentOffset()); | 366 offsetForFixedPosition = LayoutSize(scrolledContentOffset()); |
367 } | 367 } |
368 | 368 |
369 if (geometryMap.mapCoordinatesFlags() & TraverseDocumentBoundaries) { | 369 if (geometryMap.getMapCoordinatesFlags() & TraverseDocumentBoundaries) { |
370 if (LayoutPart* parentDocLayoutObject = frame()->ownerLayoutObject()) { | 370 if (LayoutPart* parentDocLayoutObject = frame()->ownerLayoutObject()) { |
371 offset = -LayoutSize(m_frameView->scrollOffset()); | 371 offset = -LayoutSize(m_frameView->scrollOffset()); |
372 offset += parentDocLayoutObject->contentBoxOffset(); | 372 offset += parentDocLayoutObject->contentBoxOffset(); |
373 container = parentDocLayoutObject; | 373 container = parentDocLayoutObject; |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 // If a container was specified, and was not 0 or the LayoutView, then we | 377 // If a container was specified, and was not 0 or the LayoutView, then we |
378 // should have found it by now unless we're traversing to a parent document. | 378 // should have found it by now unless we're traversing to a parent document. |
379 ASSERT_ARG(ancestorToStopAt, !ancestorToStopAt || ancestorToStopAt == this |
| container); | 379 ASSERT_ARG(ancestorToStopAt, !ancestorToStopAt || ancestorToStopAt == this |
| container); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // Now create a single bounding box rect that encloses the whole selection. | 572 // Now create a single bounding box rect that encloses the whole selection. |
573 LayoutRect selRect; | 573 LayoutRect selRect; |
574 | 574 |
575 typedef HashSet<const LayoutBlock*> VisitedContainingBlockSet; | 575 typedef HashSet<const LayoutBlock*> VisitedContainingBlockSet; |
576 VisitedContainingBlockSet visitedContainingBlocks; | 576 VisitedContainingBlockSet visitedContainingBlocks; |
577 | 577 |
578 commitPendingSelection(); | 578 commitPendingSelection(); |
579 LayoutObject* os = m_selectionStart; | 579 LayoutObject* os = m_selectionStart; |
580 LayoutObject* stop = layoutObjectAfterPosition(m_selectionEnd, m_selectionEn
dPos); | 580 LayoutObject* stop = layoutObjectAfterPosition(m_selectionEnd, m_selectionEn
dPos); |
581 while (os && os != stop) { | 581 while (os && os != stop) { |
582 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 582 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->getSelectionState() != SelectionNone) { |
583 // Blocks are responsible for painting line gaps and margin gaps. Th
ey must be examined as well. | 583 // Blocks are responsible for painting line gaps and margin gaps. Th
ey must be examined as well. |
584 selRect.unite(selectionRectForLayoutObject(os)); | 584 selRect.unite(selectionRectForLayoutObject(os)); |
585 const LayoutBlock* cb = os->containingBlock(); | 585 const LayoutBlock* cb = os->containingBlock(); |
586 while (cb && !cb->isLayoutView()) { | 586 while (cb && !cb->isLayoutView()) { |
587 selRect.unite(selectionRectForLayoutObject(cb)); | 587 selRect.unite(selectionRectForLayoutObject(cb)); |
588 VisitedContainingBlockSet::AddResult addResult = visitedContaini
ngBlocks.add(cb); | 588 VisitedContainingBlockSet::AddResult addResult = visitedContaini
ngBlocks.add(cb); |
589 if (!addResult.isNewEntry) | 589 if (!addResult.isNewEntry) |
590 break; | 590 break; |
591 cb = cb->containingBlock(); | 591 cb = cb->containingBlock(); |
592 } | 592 } |
593 } | 593 } |
594 | 594 |
595 os = os->nextInPreOrder(); | 595 os = os->nextInPreOrder(); |
596 } | 596 } |
597 | 597 |
598 return pixelSnappedIntRect(selRect); | 598 return pixelSnappedIntRect(selRect); |
599 } | 599 } |
600 | 600 |
601 void LayoutView::invalidatePaintForSelection() | 601 void LayoutView::invalidatePaintForSelection() |
602 { | 602 { |
603 HashSet<LayoutBlock*> processedBlocks; | 603 HashSet<LayoutBlock*> processedBlocks; |
604 | 604 |
605 LayoutObject* end = layoutObjectAfterPosition(m_selectionEnd, m_selectionEnd
Pos); | 605 LayoutObject* end = layoutObjectAfterPosition(m_selectionEnd, m_selectionEnd
Pos); |
606 for (LayoutObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde
r()) { | 606 for (LayoutObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde
r()) { |
607 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio
nEnd) | 607 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio
nEnd) |
608 continue; | 608 continue; |
609 if (o->selectionState() == SelectionNone) | 609 if (o->getSelectionState() == SelectionNone) |
610 continue; | 610 continue; |
611 | 611 |
612 o->setShouldInvalidateSelection(); | 612 o->setShouldInvalidateSelection(); |
613 | 613 |
614 // Blocks are responsible for painting line gaps and margin gaps. They m
ust be examined as well. | 614 // Blocks are responsible for painting line gaps and margin gaps. They m
ust be examined as well. |
615 for (LayoutBlock* block = o->containingBlock(); block && !block->isLayou
tView(); block = block->containingBlock()) { | 615 for (LayoutBlock* block = o->containingBlock(); block && !block->isLayou
tView(); block = block->containingBlock()) { |
616 if (!processedBlocks.add(block).isNewEntry) | 616 if (!processedBlocks.add(block).isNewEntry) |
617 break; | 617 break; |
618 block->setShouldInvalidateSelection(); | 618 block->setShouldInvalidateSelection(); |
619 } | 619 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 SelectedBlockMap oldSelectedBlocks; | 677 SelectedBlockMap oldSelectedBlocks; |
678 // FIXME: |newSelectedBlocks| doesn't really need to store the SelectionStat
e, it's just more convenient | 678 // FIXME: |newSelectedBlocks| doesn't really need to store the SelectionStat
e, it's just more convenient |
679 // to have it use the same data structure as |oldSelectedBlocks|. | 679 // to have it use the same data structure as |oldSelectedBlocks|. |
680 SelectedBlockMap newSelectedBlocks; | 680 SelectedBlockMap newSelectedBlocks; |
681 | 681 |
682 LayoutObject* os = m_selectionStart; | 682 LayoutObject* os = m_selectionStart; |
683 LayoutObject* stop = layoutObjectAfterPosition(m_selectionEnd, m_selectionEn
dPos); | 683 LayoutObject* stop = layoutObjectAfterPosition(m_selectionEnd, m_selectionEn
dPos); |
684 bool exploringBackwards = false; | 684 bool exploringBackwards = false; |
685 bool continueExploring = os && (os != stop); | 685 bool continueExploring = os && (os != stop); |
686 while (continueExploring) { | 686 while (continueExploring) { |
687 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 687 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->getSelectionState() != SelectionNone) { |
688 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. | 688 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. |
689 oldSelectedObjects.set(os, os->selectionState()); | 689 oldSelectedObjects.set(os, os->getSelectionState()); |
690 if (blockPaintInvalidationMode == PaintInvalidationNewXOROld) { | 690 if (blockPaintInvalidationMode == PaintInvalidationNewXOROld) { |
691 LayoutBlock* cb = os->containingBlock(); | 691 LayoutBlock* cb = os->containingBlock(); |
692 while (cb && !cb->isLayoutView()) { | 692 while (cb && !cb->isLayoutView()) { |
693 SelectedBlockMap::AddResult result = oldSelectedBlocks.add(c
b, cb->selectionState()); | 693 SelectedBlockMap::AddResult result = oldSelectedBlocks.add(c
b, cb->getSelectionState()); |
694 if (!result.isNewEntry) | 694 if (!result.isNewEntry) |
695 break; | 695 break; |
696 cb = cb->containingBlock(); | 696 cb = cb->containingBlock(); |
697 } | 697 } |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 os = getNextOrPrevLayoutObjectBasedOnDirection(os, stop, continueExplori
ng, exploringBackwards); | 701 os = getNextOrPrevLayoutObjectBasedOnDirection(os, stop, continueExplori
ng, exploringBackwards); |
702 } | 702 } |
703 | 703 |
(...skipping 26 matching lines...) Expand all Loading... |
730 o->setSelectionStateIfNeeded(SelectionInside); | 730 o->setSelectionStateIfNeeded(SelectionInside); |
731 o = o->nextInPreOrder(); | 731 o = o->nextInPreOrder(); |
732 } | 732 } |
733 | 733 |
734 // Now that the selection state has been updated for the new objects, walk t
hem again and | 734 // Now that the selection state has been updated for the new objects, walk t
hem again and |
735 // put them in the new objects list. | 735 // put them in the new objects list. |
736 o = start; | 736 o = start; |
737 exploringBackwards = false; | 737 exploringBackwards = false; |
738 continueExploring = o && (o != stop); | 738 continueExploring = o && (o != stop); |
739 while (continueExploring) { | 739 while (continueExploring) { |
740 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { | 740 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->getSelecti
onState() != SelectionNone) { |
741 newSelectedObjects.set(o, o->selectionState()); | 741 newSelectedObjects.set(o, o->getSelectionState()); |
742 LayoutBlock* cb = o->containingBlock(); | 742 LayoutBlock* cb = o->containingBlock(); |
743 while (cb && !cb->isLayoutView()) { | 743 while (cb && !cb->isLayoutView()) { |
744 SelectedBlockMap::AddResult result = newSelectedBlocks.add(cb, c
b->selectionState()); | 744 SelectedBlockMap::AddResult result = newSelectedBlocks.add(cb, c
b->getSelectionState()); |
745 if (!result.isNewEntry) | 745 if (!result.isNewEntry) |
746 break; | 746 break; |
747 cb = cb->containingBlock(); | 747 cb = cb->containingBlock(); |
748 } | 748 } |
749 } | 749 } |
750 | 750 |
751 o = getNextOrPrevLayoutObjectBasedOnDirection(o, stop, continueExploring
, exploringBackwards); | 751 o = getNextOrPrevLayoutObjectBasedOnDirection(o, stop, continueExploring
, exploringBackwards); |
752 } | 752 } |
753 | 753 |
754 if (!m_frameView) | 754 if (!m_frameView) |
755 return; | 755 return; |
756 | 756 |
757 // Have any of the old selected objects changed compared to the new selectio
n? | 757 // Have any of the old selected objects changed compared to the new selectio
n? |
758 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj
ectsEnd; ++i) { | 758 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj
ectsEnd; ++i) { |
759 LayoutObject* obj = i->key; | 759 LayoutObject* obj = i->key; |
760 SelectionState newSelectionState = obj->selectionState(); | 760 SelectionState newSelectionState = obj->getSelectionState(); |
761 SelectionState oldSelectionState = i->value; | 761 SelectionState oldSelectionState = i->value; |
762 if (newSelectionState != oldSelectionState | 762 if (newSelectionState != oldSelectionState |
763 || (m_selectionStart == obj && oldStartPos != m_selectionStartPos) | 763 || (m_selectionStart == obj && oldStartPos != m_selectionStartPos) |
764 || (m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) { | 764 || (m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) { |
765 obj->setShouldInvalidateSelection(); | 765 obj->setShouldInvalidateSelection(); |
766 newSelectedObjects.remove(obj); | 766 newSelectedObjects.remove(obj); |
767 } | 767 } |
768 } | 768 } |
769 | 769 |
770 // Any new objects that remain were not found in the old objects dict, and s
o they need to be updated. | 770 // Any new objects that remain were not found in the old objects dict, and s
o they need to be updated. |
771 SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end(); | 771 SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end(); |
772 for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObj
ectsEnd; ++i) | 772 for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObj
ectsEnd; ++i) |
773 i->key->setShouldInvalidateSelection(); | 773 i->key->setShouldInvalidateSelection(); |
774 | 774 |
775 // Have any of the old blocks changed? | 775 // Have any of the old blocks changed? |
776 SelectedBlockMap::iterator oldBlocksEnd = oldSelectedBlocks.end(); | 776 SelectedBlockMap::iterator oldBlocksEnd = oldSelectedBlocks.end(); |
777 for (SelectedBlockMap::iterator i = oldSelectedBlocks.begin(); i != oldBlock
sEnd; ++i) { | 777 for (SelectedBlockMap::iterator i = oldSelectedBlocks.begin(); i != oldBlock
sEnd; ++i) { |
778 LayoutBlock* block = i->key; | 778 LayoutBlock* block = i->key; |
779 SelectionState newSelectionState = block->selectionState(); | 779 SelectionState newSelectionState = block->getSelectionState(); |
780 SelectionState oldSelectionState = i->value; | 780 SelectionState oldSelectionState = i->value; |
781 if (newSelectionState != oldSelectionState) { | 781 if (newSelectionState != oldSelectionState) { |
782 block->setShouldInvalidateSelection(); | 782 block->setShouldInvalidateSelection(); |
783 newSelectedBlocks.remove(block); | 783 newSelectedBlocks.remove(block); |
784 } | 784 } |
785 } | 785 } |
786 | 786 |
787 // Any new blocks that remain were not found in the old blocks dict, and so
they need to be updated. | 787 // Any new blocks that remain were not found in the old blocks dict, and so
they need to be updated. |
788 SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end(); | 788 SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end(); |
789 for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlock
sEnd; ++i) | 789 for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlock
sEnd; ++i) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 } | 997 } |
998 | 998 |
999 void LayoutView::sendMediaPositionChangeNotifications(const IntRect& visibleRect
) | 999 void LayoutView::sendMediaPositionChangeNotifications(const IntRect& visibleRect
) |
1000 { | 1000 { |
1001 for (auto& media : m_mediaForPositionNotification) { | 1001 for (auto& media : m_mediaForPositionNotification) { |
1002 media->notifyPositionMayHaveChanged(visibleRect); | 1002 media->notifyPositionMayHaveChanged(visibleRect); |
1003 } | 1003 } |
1004 } | 1004 } |
1005 | 1005 |
1006 } // namespace blink | 1006 } // namespace blink |
OLD | NEW |