Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: Source/core/rendering/RenderView.cpp

Issue 620553009: Move selection invalidations to the invalidation phase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated change after review comments. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 for (SelectionMap::iterator i = selectedObjects.begin(); i != end; ++i) 468 for (SelectionMap::iterator i = selectedObjects.begin(); i != end; ++i)
469 selRect.unite(i->value->absoluteSelectionRect()); 469 selRect.unite(i->value->absoluteSelectionRect());
470 470
471 return pixelSnappedIntRect(selRect); 471 return pixelSnappedIntRect(selRect);
472 } 472 }
473 473
474 void RenderView::invalidatePaintForSelection() const 474 void RenderView::invalidatePaintForSelection() const
475 { 475 {
476 HashSet<RenderBlock*> processedBlocks; 476 HashSet<RenderBlock*> processedBlocks;
477 477
478 // For querying RenderLayer::compositingState()
479 // FIXME: this may be wrong. crbug.com/407416
480 DisableCompositingQueryAsserts disabler;
481
482 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ; 478 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ;
483 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) { 479 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) {
484 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd) 480 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd)
485 continue; 481 continue;
486 if (o->selectionState() == SelectionNone) 482 if (o->selectionState() == SelectionNone)
487 continue; 483 continue;
488 484
489 RenderSelectionInfo(o).invalidatePaint(); 485 o->setShouldInvalidateSelection();
490 486
491 // Blocks are responsible for painting line gaps and margin gaps. They m ust be examined as well. 487 // Blocks are responsible for painting line gaps and margin gaps. They m ust be examined as well.
492 for (RenderBlock* block = o->containingBlock(); block && !block->isRende rView(); block = block->containingBlock()) { 488 for (RenderBlock* block = o->containingBlock(); block && !block->isRende rView(); block = block->containingBlock()) {
493 if (!processedBlocks.add(block).isNewEntry) 489 if (!processedBlocks.add(block).isNewEntry)
494 break; 490 break;
495 RenderSelectionInfo(block).invalidatePaint(); 491 block->setShouldInvalidateSelection();
496 } 492 }
497 } 493 }
498 } 494 }
499 495
500 // When exploring the RenderTree looking for the nodes involved in the Selection , sometimes it's 496 // When exploring the RenderTree looking for the nodes involved in the Selection , sometimes it's
501 // required to change the traversing direction because the "start" position is b elow the "end" one. 497 // required to change the traversing direction because the "start" position is b elow the "end" one.
502 static inline RenderObject* getNextOrPrevRenderObjectBasedOnDirection(const Rend erObject* o, const RenderObject* stop, bool& continueExploring, bool& exploringB ackwards) 498 static inline RenderObject* getNextOrPrevRenderObjectBasedOnDirection(const Rend erObject* o, const RenderObject* stop, bool& continueExploring, bool& exploringB ackwards)
503 { 499 {
504 RenderObject* next; 500 RenderObject* next;
505 if (exploringBackwards) { 501 if (exploringBackwards) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 cb = cb->containingBlock(); 621 cb = cb->containingBlock();
626 } 622 }
627 } 623 }
628 624
629 o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring , exploringBackwards); 625 o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring , exploringBackwards);
630 } 626 }
631 627
632 if (!m_frameView || blockPaintInvalidationMode == PaintInvalidationNothing) 628 if (!m_frameView || blockPaintInvalidationMode == PaintInvalidationNothing)
633 return; 629 return;
634 630
635 // For querying RenderLayer::compositingState()
636 // FIXME: this is wrong, selection should not cause eager invalidation. crbu g.com/407416
637 DisableCompositingQueryAsserts disabler;
638
639 // Have any of the old selected objects changed compared to the new selectio n? 631 // Have any of the old selected objects changed compared to the new selectio n?
640 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj ectsEnd; ++i) { 632 for (SelectedObjectMap::iterator i = oldSelectedObjects.begin(); i != oldObj ectsEnd; ++i) {
641 RenderObject* obj = i->key; 633 RenderObject* obj = i->key;
642 RenderSelectionInfo* newInfo = newSelectedObjects.get(obj); 634 RenderSelectionInfo* newInfo = newSelectedObjects.get(obj);
643 RenderSelectionInfo* oldInfo = i->value.get(); 635 RenderSelectionInfo* oldInfo = i->value.get();
644 if (!newInfo || newInfo->hasChangedFrom(*oldInfo) 636 if (!newInfo || newInfo->hasChangedFrom(*oldInfo)
645 || (m_selectionStart == obj && oldStartPos != m_selectionStartPos) 637 || (m_selectionStart == obj && oldStartPos != m_selectionStartPos)
646 || (m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) { 638 || (m_selectionEnd == obj && oldEndPos != m_selectionEndPos)) {
647 oldInfo->invalidatePaint(); 639 oldInfo->invalidatePaint();
648 if (newInfo) { 640 if (newInfo) {
649 newInfo->invalidatePaint(); 641 newInfo->object()->setShouldInvalidateSelection();
650 newSelectedObjects.remove(obj); 642 newSelectedObjects.remove(obj);
651 } 643 }
652 } 644 }
653 } 645 }
654 646
655 // Any new objects that remain were not found in the old objects dict, and s o they need to be updated. 647 // Any new objects that remain were not found in the old objects dict, and s o they need to be updated.
656 SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end(); 648 SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end();
657 for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObj ectsEnd; ++i) 649 for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); i != newObj ectsEnd; ++i)
658 i->value->invalidatePaint(); 650 i->value->object()->setShouldInvalidateSelection();
659 651
660 // Have any of the old blocks changed? 652 // Have any of the old blocks changed?
661 SelectedBlockMap::iterator oldBlocksEnd = oldSelectedBlocks.end(); 653 SelectedBlockMap::iterator oldBlocksEnd = oldSelectedBlocks.end();
662 for (SelectedBlockMap::iterator i = oldSelectedBlocks.begin(); i != oldBlock sEnd; ++i) { 654 for (SelectedBlockMap::iterator i = oldSelectedBlocks.begin(); i != oldBlock sEnd; ++i) {
663 RenderBlock* block = i->key; 655 RenderBlock* block = i->key;
664 RenderBlockSelectionInfo* newInfo = newSelectedBlocks.get(block); 656 RenderBlockSelectionInfo* newInfo = newSelectedBlocks.get(block);
665 RenderBlockSelectionInfo* oldInfo = i->value.get(); 657 RenderBlockSelectionInfo* oldInfo = i->value.get();
666 if (!newInfo || newInfo->hasChangedFrom(*oldInfo)) { 658 if (!newInfo || newInfo->hasChangedFrom(*oldInfo)) {
667 oldInfo->invalidatePaint(); 659 oldInfo->object()->setShouldInvalidateSelection();
668 if (newInfo) { 660 if (newInfo) {
669 newInfo->invalidatePaint(); 661 newInfo->object()->setShouldInvalidateSelection();
670 newSelectedBlocks.remove(block); 662 newSelectedBlocks.remove(block);
671 } 663 }
672 } 664 }
673 } 665 }
674 666
675 // Any new blocks that remain were not found in the old blocks dict, and so they need to be updated. 667 // Any new blocks that remain were not found in the old blocks dict, and so they need to be updated.
676 SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end(); 668 SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end();
677 for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlock sEnd; ++i) 669 for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); i != newBlock sEnd; ++i)
678 i->value->invalidatePaint(); 670 i->value->object()->setShouldInvalidateSelection();
679 } 671 }
680 672
681 void RenderView::getSelection(RenderObject*& startRenderer, int& startOffset, Re nderObject*& endRenderer, int& endOffset) const 673 void RenderView::getSelection(RenderObject*& startRenderer, int& startOffset, Re nderObject*& endRenderer, int& endOffset) const
682 { 674 {
683 startRenderer = m_selectionStart; 675 startRenderer = m_selectionStart;
684 startOffset = m_selectionStartPos; 676 startOffset = m_selectionStartPos;
685 endRenderer = m_selectionEnd; 677 endRenderer = m_selectionEnd;
686 endOffset = m_selectionEndPos; 678 endOffset = m_selectionEndPos;
687 } 679 }
688 680
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 return viewWidth(IncludeScrollbars) / scale; 881 return viewWidth(IncludeScrollbars) / scale;
890 } 882 }
891 883
892 double RenderView::layoutViewportHeight() const 884 double RenderView::layoutViewportHeight() const
893 { 885 {
894 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; 886 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1;
895 return viewHeight(IncludeScrollbars) / scale; 887 return viewHeight(IncludeScrollbars) / scale;
896 } 888 }
897 889
898 } // namespace blink 890 } // namespace blink
OLDNEW
« Source/core/rendering/RenderText.h ('K') | « Source/core/rendering/RenderText.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698