| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 if (m_selectionStart == start && m_selectionStartPos == startPos && | 530 if (m_selectionStart == start && m_selectionStartPos == startPos && |
| 531 m_selectionEnd == end && m_selectionEndPos == endPos) | 531 m_selectionEnd == end && m_selectionEndPos == endPos) |
| 532 return; | 532 return; |
| 533 | 533 |
| 534 // Record the old selected objects. These will be used later | 534 // Record the old selected objects. These will be used later |
| 535 // when we compare against the new selected objects. | 535 // when we compare against the new selected objects. |
| 536 int oldStartPos = m_selectionStartPos; | 536 int oldStartPos = m_selectionStartPos; |
| 537 int oldEndPos = m_selectionEndPos; | 537 int oldEndPos = m_selectionEndPos; |
| 538 | 538 |
| 539 // Objects each have a single selection rect to examine. | 539 // Objects each have a single selection rect to examine. |
| 540 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMemb
er<RenderSelectionInfo> > SelectedObjectMap; | 540 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, SelectionState >
SelectedObjectMap; |
| 541 SelectedObjectMap oldSelectedObjects; | 541 SelectedObjectMap oldSelectedObjects; |
| 542 // FIXME: |newSelectedObjects| doesn't really need to store the SelectionSta
te, it's just more convenient |
| 543 // to have it use the same data structure as |oldSelectedObjects|. |
| 542 SelectedObjectMap newSelectedObjects; | 544 SelectedObjectMap newSelectedObjects; |
| 543 | 545 |
| 544 // Blocks contain selected objects and fill gaps between them, either on the
left, right, or in between lines and blocks. | 546 // Blocks contain selected objects and fill gaps between them, either on the
left, right, or in between lines and blocks. |
| 545 // In order to get the paint invalidation rect right, we have to examine lef
t, middle, and right rects individually, since otherwise | 547 // In order to get the paint invalidation rect right, we have to examine lef
t, middle, and right rects individually, since otherwise |
| 546 // the union of those rects might remain the same even when changes have occ
urred. | 548 // the union of those rects might remain the same even when changes have occ
urred. |
| 547 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderBlock>, OwnPtrWillBeMembe
r<RenderBlockSelectionInfo> > SelectedBlockMap; | 549 typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderBlock>, SelectionState >
SelectedBlockMap; |
| 548 SelectedBlockMap oldSelectedBlocks; | 550 SelectedBlockMap oldSelectedBlocks; |
| 551 // FIXME: |newSelectedBlocks| doesn't really need to store the SelectionStat
e, it's just more convenient |
| 552 // to have it use the same data structure as |oldSelectedBlocks|. |
| 549 SelectedBlockMap newSelectedBlocks; | 553 SelectedBlockMap newSelectedBlocks; |
| 550 | 554 |
| 551 RenderObject* os = m_selectionStart; | 555 RenderObject* os = m_selectionStart; |
| 552 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); | 556 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos
); |
| 553 bool exploringBackwards = false; | 557 bool exploringBackwards = false; |
| 554 bool continueExploring = os && (os != stop); | 558 bool continueExploring = os && (os != stop); |
| 555 while (continueExploring) { | 559 while (continueExploring) { |
| 556 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { | 560 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec
tionEnd) && os->selectionState() != SelectionNone) { |
| 557 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. | 561 // Blocks are responsible for painting line gaps and margin gaps. T
hey must be examined as well. |
| 558 oldSelectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInf
o(os))); | 562 oldSelectedObjects.set(os, os->selectionState()); |
| 559 if (blockPaintInvalidationMode == PaintInvalidationNewXOROld) { | 563 if (blockPaintInvalidationMode == PaintInvalidationNewXOROld) { |
| 560 RenderBlock* cb = os->containingBlock(); | 564 RenderBlock* cb = os->containingBlock(); |
| 561 while (cb && !cb->isRenderView()) { | 565 while (cb && !cb->isRenderView()) { |
| 562 OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = ol
dSelectedBlocks.add(cb, nullptr).storedValue->value; | 566 SelectedBlockMap::AddResult result = oldSelectedBlocks.add(c
b, cb->selectionState()); |
| 563 if (blockInfo) | 567 if (!result.isNewEntry) |
| 564 break; | 568 break; |
| 565 blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(
cb)); | |
| 566 cb = cb->containingBlock(); | 569 cb = cb->containingBlock(); |
| 567 } | 570 } |
| 568 } | 571 } |
| 569 } | 572 } |
| 570 | 573 |
| 571 os = getNextOrPrevRenderObjectBasedOnDirection(os, stop, continueExplori
ng, exploringBackwards); | 574 os = getNextOrPrevRenderObjectBasedOnDirection(os, stop, continueExplori
ng, exploringBackwards); |
| 572 } | 575 } |
| 573 | 576 |
| 574 // Now clear the selection. | 577 // Now clear the selection. |
| 575 SelectedObjectMap::iterator oldObjectsEnd = oldSelectedObjects.end(); | 578 SelectedObjectMap::iterator oldObjectsEnd = oldSelectedObjects.end(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 603 | 606 |
| 604 layer()->clearBlockSelectionGapsBounds(); | 607 layer()->clearBlockSelectionGapsBounds(); |
| 605 | 608 |
| 606 // Now that the selection state has been updated for the new objects, walk t
hem again and | 609 // Now that the selection state has been updated for the new objects, walk t
hem again and |
| 607 // put them in the new objects list. | 610 // put them in the new objects list. |
| 608 o = start; | 611 o = start; |
| 609 exploringBackwards = false; | 612 exploringBackwards = false; |
| 610 continueExploring = o && (o != stop); | 613 continueExploring = o && (o != stop); |
| 611 while (continueExploring) { | 614 while (continueExploring) { |
| 612 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { | 615 if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionS
tate() != SelectionNone) { |
| 613 newSelectedObjects.set(o, adoptPtrWillBeNoop(new RenderSelectionInfo
(o))); | 616 newSelectedObjects.set(o, o->selectionState()); |
| 614 RenderBlock* cb = o->containingBlock(); | 617 RenderBlock* cb = o->containingBlock(); |
| 615 while (cb && !cb->isRenderView()) { | 618 while (cb && !cb->isRenderView()) { |
| 616 OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = newSel
ectedBlocks.add(cb, nullptr).storedValue->value; | 619 SelectedBlockMap::AddResult result = newSelectedBlocks.add(cb, c
b->selectionState()); |
| 617 if (blockInfo) | 620 if (!result.isNewEntry) |
| 618 break; | 621 break; |
| 619 blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(cb))
; | |
| 620 cb = cb->containingBlock(); | 622 cb = cb->containingBlock(); |
| 621 } | 623 } |
| 622 } | 624 } |
| 623 | 625 |
| 624 o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring
, exploringBackwards); | 626 o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring
, exploringBackwards); |
| 625 } | 627 } |
| 626 | 628 |
| 627 if (!m_frameView) | 629 if (!m_frameView) |
| 628 return; | 630 return; |
| 629 | 631 |
| 630 // Have any of the old selected objects changed compared to the new selectio
n? | 632 // Have any of the old selected objects changed compared to the new selectio
n? |
| 631 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj
ectsEnd; ++i) { | 633 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj
ectsEnd; ++i) { |
| 632 RenderObject* obj = i->key; | 634 RenderObject* obj = i->key; |
| 633 RenderSelectionInfo* newInfo = newSelectedObjects.get(obj); | 635 SelectionState newSelectionState = obj->selectionState(); |
| 634 RenderSelectionInfo* oldInfo = i->value.get(); | 636 SelectionState oldSelectionState = i->value; |
| 635 if (!newInfo || newInfo->hasChangedFrom(*oldInfo) | 637 if (newSelectionState != oldSelectionState |
| 636 || (m_selectionStart == obj && oldStartPos != m_selectionStartPos) | 638 || (m_selectionStart == obj && oldStartPos != m_selectionStartPos) |
| 637 || (m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) { | 639 || (m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) { |
| 638 oldInfo->invalidatePaint(); | 640 obj->setShouldInvalidateSelection(); |
| 639 if (newInfo) { | 641 newSelectedObjects.remove(obj); |
| 640 newInfo->object()->setShouldInvalidateSelection(); | |
| 641 newSelectedObjects.remove(obj); | |
| 642 } | |
| 643 } | 642 } |
| 644 } | 643 } |
| 645 | 644 |
| 646 // Any new objects that remain were not found in the old objects dict, and s
o they need to be updated. | 645 // Any new objects that remain were not found in the old objects dict, and s
o they need to be updated. |
| 647 SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end(); | 646 SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end(); |
| 648 for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObj
ectsEnd; ++i) | 647 for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObj
ectsEnd; ++i) |
| 649 i->value->object()->setShouldInvalidateSelection(); | 648 i->key->setShouldInvalidateSelection(); |
| 650 | 649 |
| 651 // Have any of the old blocks changed? | 650 // Have any of the old blocks changed? |
| 652 SelectedBlockMap::iterator oldBlocksEnd = oldSelectedBlocks.end(); | 651 SelectedBlockMap::iterator oldBlocksEnd = oldSelectedBlocks.end(); |
| 653 for (SelectedBlockMap::iterator i = oldSelectedBlocks.begin(); i != oldBlock
sEnd; ++i) { | 652 for (SelectedBlockMap::iterator i = oldSelectedBlocks.begin(); i != oldBlock
sEnd; ++i) { |
| 654 RenderBlock* block = i->key; | 653 RenderBlock* block = i->key; |
| 655 RenderBlockSelectionInfo* newInfo = newSelectedBlocks.get(block); | 654 SelectionState newSelectionState = block->selectionState(); |
| 656 RenderBlockSelectionInfo* oldInfo = i->value.get(); | 655 SelectionState oldSelectionState = i->value; |
| 657 if (!newInfo || newInfo->hasChangedFrom(*oldInfo)) { | 656 if (newSelectionState != oldSelectionState) { |
| 658 oldInfo->invalidatePaint(); | 657 block->setShouldInvalidateSelection(); |
| 659 if (newInfo) { | 658 newSelectedBlocks.remove(block); |
| 660 newInfo->object()->setShouldInvalidateSelection(); | |
| 661 newSelectedBlocks.remove(block); | |
| 662 } | |
| 663 } | 659 } |
| 664 } | 660 } |
| 665 | 661 |
| 666 // Any new blocks that remain were not found in the old blocks dict, and so
they need to be updated. | 662 // Any new blocks that remain were not found in the old blocks dict, and so
they need to be updated. |
| 667 SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end(); | 663 SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end(); |
| 668 for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlock
sEnd; ++i) | 664 for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlock
sEnd; ++i) |
| 669 i->value->object()->setShouldInvalidateSelection(); | 665 i->key->setShouldInvalidateSelection(); |
| 670 } | 666 } |
| 671 | 667 |
| 672 void RenderView::clearSelection() | 668 void RenderView::clearSelection() |
| 673 { | 669 { |
| 674 // For querying RenderLayer::compositingState() | 670 // For querying RenderLayer::compositingState() |
| 675 // This is correct, since destroying render objects needs to cause eager pai
nt invalidations. | 671 // This is correct, since destroying render objects needs to cause eager pai
nt invalidations. |
| 676 DisableCompositingQueryAsserts disabler; | 672 DisableCompositingQueryAsserts disabler; |
| 677 | 673 |
| 678 layer()->invalidatePaintForBlockSelectionGaps(); | 674 layer()->invalidatePaintForBlockSelectionGaps(); |
| 679 setSelection(0, -1, 0, -1, PaintInvalidationNewMinusOld); | 675 setSelection(0, -1, 0, -1, PaintInvalidationNewMinusOld); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 return viewWidth(IncludeScrollbars) / scale; | 868 return viewWidth(IncludeScrollbars) / scale; |
| 873 } | 869 } |
| 874 | 870 |
| 875 double RenderView::layoutViewportHeight() const | 871 double RenderView::layoutViewportHeight() const |
| 876 { | 872 { |
| 877 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 873 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
| 878 return viewHeight(IncludeScrollbars) / scale; | 874 return viewHeight(IncludeScrollbars) / scale; |
| 879 } | 875 } |
| 880 | 876 |
| 881 } // namespace blink | 877 } // namespace blink |
| OLD | NEW |