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

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: 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
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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 { 621 {
622 if (!object) 622 if (!object)
623 return 0; 623 return 0;
624 624
625 RenderObject* child = object->childAt(offset); 625 RenderObject* child = object->childAt(offset);
626 return child ? child : object->nextInPreOrderAfterChildren(); 626 return child ? child : object->nextInPreOrderAfterChildren();
627 } 627 }
628 628
629 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const 629 IntRect RenderView::selectionBounds(bool clipToVisibleContent) const
630 { 630 {
631 document().updateStyleIfNeeded();
eseidel 2013/09/27 23:04:27 Should these be ASSERT(!document->needsStylin())
632
633 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap; 631 typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap;
634 SelectionMap selectedObjects; 632 SelectionMap selectedObjects;
635 633
636 RenderObject* os = m_selectionStart; 634 RenderObject* os = m_selectionStart;
637 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos ); 635 RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos );
638 while (os && os != stop) { 636 while (os && os != stop) {
639 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec tionEnd) && os->selectionState() != SelectionNone) { 637 if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selec tionEnd) && os->selectionState() != SelectionNone) {
640 // Blocks are responsible for painting line gaps and margin gaps. Th ey must be examined as well. 638 // Blocks are responsible for painting line gaps and margin gaps. Th ey must be examined as well.
641 selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToV isibleContent))); 639 selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToV isibleContent)));
642 RenderBlock* cb = os->containingBlock(); 640 RenderBlock* cb = os->containingBlock();
(...skipping 20 matching lines...) Expand all
663 FloatQuad absQuad = repaintContainer->localToAbsoluteQuad(FloatRect( currRect)); 661 FloatQuad absQuad = repaintContainer->localToAbsoluteQuad(FloatRect( currRect));
664 currRect = absQuad.enclosingBoundingBox(); 662 currRect = absQuad.enclosingBoundingBox();
665 } 663 }
666 selRect.unite(currRect); 664 selRect.unite(currRect);
667 } 665 }
668 return pixelSnappedIntRect(selRect); 666 return pixelSnappedIntRect(selRect);
669 } 667 }
670 668
671 void RenderView::repaintSelection() const 669 void RenderView::repaintSelection() const
672 { 670 {
673 document().updateStyleIfNeeded();
674
675 HashSet<RenderBlock*> processedBlocks; 671 HashSet<RenderBlock*> processedBlocks;
676 672
677 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ; 673 RenderObject* end = rendererAfterPosition(m_selectionEnd, m_selectionEndPos) ;
678 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) { 674 for (RenderObject* o = m_selectionStart; o && o != end; o = o->nextInPreOrde r()) {
679 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd) 675 if (!o->canBeSelectionLeaf() && o != m_selectionStart && o != m_selectio nEnd)
680 continue; 676 continue;
681 if (o->selectionState() == SelectionNone) 677 if (o->selectionState() == SelectionNone)
682 continue; 678 continue;
683 679
684 RenderSelectionInfo(o, true).repaint(); 680 RenderSelectionInfo(o, true).repaint();
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 #endif 1230 #endif
1235 1231
1236 if (layoutState) 1232 if (layoutState)
1237 layoutState->m_isPaginated = m_fragmenting; 1233 layoutState->m_isPaginated = m_fragmenting;
1238 1234
1239 if (m_flowThreadState != RenderObject::NotInsideFlowThread) 1235 if (m_flowThreadState != RenderObject::NotInsideFlowThread)
1240 m_root->setFlowThreadStateIncludingDescendants(m_flowThreadState); 1236 m_root->setFlowThreadStateIncludingDescendants(m_flowThreadState);
1241 } 1237 }
1242 1238
1243 } // namespace WebCore 1239 } // namespace WebCore
OLDNEW
« Source/core/editing/FrameSelection.cpp ('K') | « Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698