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

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

Issue 25004008: Harden FrameSelection methods against JS running inside recalcStyle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix build Created 7 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
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 { 622 {
623 if (!object) 623 if (!object)
624 return 0; 624 return 0;
625 625
626 RenderObject* child = object->childAt(offset); 626 RenderObject* child = object->childAt(offset);
627 return child ? child : object->nextInPreOrderAfterChildren(); 627 return child ? child : object->nextInPreOrderAfterChildren();
628 } 628 }
629 629
630 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const 630 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const
631 { 631 {
632 document().updateStyleIfNeeded();
633
634 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap; 632 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap;
635 SelectionMap selectedObjects; 633 SelectionMap selectedObjects;
636 634
637 RenderObject* os = m_selectionStart; 635 RenderObject* os = m_selectionStart;
638 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos ); 636 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos );
639 while (os && os != stop) { 637 while (os && os != stop) {
640 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec tionEnd) && os->selectionState() != SelectionNone) { 638 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec tionEnd) && os->selectionState() != SelectionNone) {
641 // Blocks are responsible for painting line gaps and margin gaps. Th ey must be examined as well. 639 // Blocks are responsible for painting line gaps and margin gaps. Th ey must be examined as well.
642 selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToV isibleContent))); 640 selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToV isibleContent)));
643 RenderBlock* cb = os->containingBlock(); 641 RenderBlock* cb = os->containingBlock();
(...skipping 20 matching lines...) Expand all
664 FloatQuad absQuad = repaintContainer->localToAbsoluteQuad(FloatRect( currRect)); 662 FloatQuad absQuad = repaintContainer->localToAbsoluteQuad(FloatRect( currRect));
665 currRect = absQuad.enclosingBoundingBox(); 663 currRect = absQuad.enclosingBoundingBox();
666 } 664 }
667 selRect.unite(currRect); 665 selRect.unite(currRect);
668 } 666 }
669 return pixelSnappedIntRect(selRect); 667 return pixelSnappedIntRect(selRect);
670 } 668 }
671 669
672 void RenderView::repaintSelection() const 670 void RenderView::repaintSelection() const
673 { 671 {
674 document().updateStyleIfNeeded();
675
676 HashSet<RenderBlock*> processedBlocks; 672 HashSet<RenderBlock*> processedBlocks;
677 673
678 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ; 674 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ;
679 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) { 675 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) {
680 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd) 676 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd)
681 continue; 677 continue;
682 if (o->selectionState() == SelectionNone) 678 if (o->selectionState() == SelectionNone)
683 continue; 679 continue;
684 680
685 RenderSelectionInfo(o, true).repaint(); 681 RenderSelectionInfo(o, true).repaint();
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 #endif 1227 #endif
1232 1228
1233 if (layoutState) 1229 if (layoutState)
1234 layoutState->m_isPaginated = m_fragmenting; 1230 layoutState->m_isPaginated = m_fragmenting;
1235 1231
1236 if (m_flowThreadState != RenderObject::NotInsideFlowThread) 1232 if (m_flowThreadState != RenderObject::NotInsideFlowThread)
1237 m_root->setFlowThreadStateIncludingDescendants(m_flowThreadState); 1233 m_root->setFlowThreadStateIncludingDescendants(m_flowThreadState);
1238 } 1234 }
1239 1235
1240 } // namespace WebCore 1236 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698