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

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

Issue 132913002: Harden the machinery around updateWidgetPositions() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add FIXME Created 6 years, 11 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/rendering/RenderView.h ('k') | Source/core/rendering/RenderWidget.h » ('j') | 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 22 matching lines...) Expand all
33 #include "core/rendering/CompositedLayerMapping.h" 33 #include "core/rendering/CompositedLayerMapping.h"
34 #include "core/rendering/FlowThreadController.h" 34 #include "core/rendering/FlowThreadController.h"
35 #include "core/rendering/GraphicsContextAnnotator.h" 35 #include "core/rendering/GraphicsContextAnnotator.h"
36 #include "core/rendering/HitTestResult.h" 36 #include "core/rendering/HitTestResult.h"
37 #include "core/rendering/LayoutRectRecorder.h" 37 #include "core/rendering/LayoutRectRecorder.h"
38 #include "core/rendering/RenderFlowThread.h" 38 #include "core/rendering/RenderFlowThread.h"
39 #include "core/rendering/RenderGeometryMap.h" 39 #include "core/rendering/RenderGeometryMap.h"
40 #include "core/rendering/RenderLayer.h" 40 #include "core/rendering/RenderLayer.h"
41 #include "core/rendering/RenderLayerCompositor.h" 41 #include "core/rendering/RenderLayerCompositor.h"
42 #include "core/rendering/RenderSelectionInfo.h" 42 #include "core/rendering/RenderSelectionInfo.h"
43 #include "core/rendering/RenderWidget.h"
44 #include "core/svg/SVGDocumentExtensions.h" 43 #include "core/svg/SVGDocumentExtensions.h"
45 #include "platform/geometry/FloatQuad.h" 44 #include "platform/geometry/FloatQuad.h"
46 #include "platform/geometry/TransformState.h" 45 #include "platform/geometry/TransformState.h"
47 #include "platform/graphics/GraphicsContext.h" 46 #include "platform/graphics/GraphicsContext.h"
48 47
49 namespace WebCore { 48 namespace WebCore {
50 49
51 RenderView::RenderView(Document* document) 50 RenderView::RenderView(Document* document)
52 : RenderBlockFlow(document) 51 : RenderBlockFlow(document)
53 , m_frameView(document->view()) 52 , m_frameView(document->view())
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 endPos = m_selectionEndPos; 938 endPos = m_selectionEndPos;
940 } 939 }
941 940
942 bool RenderView::shouldUsePrintingLayout() const 941 bool RenderView::shouldUsePrintingLayout() const
943 { 942 {
944 if (!document().printing() || !m_frameView) 943 if (!document().printing() || !m_frameView)
945 return false; 944 return false;
946 return m_frameView->frame().shouldUsePrintingLayout(); 945 return m_frameView->frame().shouldUsePrintingLayout();
947 } 946 }
948 947
949 size_t RenderView::getRetainedWidgets(Vector<RenderWidget*>& renderWidgets)
950 {
951 size_t size = m_widgets.size();
952
953 renderWidgets.reserveCapacity(size);
954
955 RenderWidgetSet::const_iterator end = m_widgets.end();
956 for (RenderWidgetSet::const_iterator it = m_widgets.begin(); it != end; ++it ) {
957 renderWidgets.uncheckedAppend(*it);
958 (*it)->ref();
959 }
960
961 return size;
962 }
963
964 void RenderView::releaseWidgets(Vector<RenderWidget*>& renderWidgets)
965 {
966 size_t size = renderWidgets.size();
967
968 for (size_t i = 0; i < size; ++i)
969 renderWidgets[i]->deref();
970 }
971
972 void RenderView::updateWidgetPositions()
973 {
974 // updateWidgetPosition() can possibly cause layout to be re-entered (via pl ug-ins running
975 // scripts in response to NPP_SetWindow, for example), so we need to keep th e Widgets
976 // alive during enumeration.
977
978 Vector<RenderWidget*> renderWidgets;
979 size_t size = getRetainedWidgets(renderWidgets);
980
981 for (size_t i = 0; i < size; ++i)
982 renderWidgets[i]->updateWidgetPosition();
983
984 for (size_t i = 0; i < size; ++i)
985 renderWidgets[i]->widgetPositionsUpdated();
986
987 releaseWidgets(renderWidgets);
988 }
989
990 void RenderView::addWidget(RenderWidget* o)
991 {
992 m_widgets.add(o);
993 }
994
995 void RenderView::removeWidget(RenderWidget* o)
996 {
997 m_widgets.remove(o);
998 }
999
1000 LayoutRect RenderView::viewRect() const 948 LayoutRect RenderView::viewRect() const
1001 { 949 {
1002 if (shouldUsePrintingLayout()) 950 if (shouldUsePrintingLayout())
1003 return LayoutRect(LayoutPoint(), size()); 951 return LayoutRect(LayoutPoint(), size());
1004 if (m_frameView) 952 if (m_frameView)
1005 return m_frameView->visibleContentRect(); 953 return m_frameView->visibleContentRect();
1006 return LayoutRect(); 954 return LayoutRect();
1007 } 955 }
1008 956
1009 IntRect RenderView::unscaledDocumentRect() const 957 IntRect RenderView::unscaledDocumentRect() const
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 return viewWidth(ScrollableArea::IncludeScrollbars) / scale; 1156 return viewWidth(ScrollableArea::IncludeScrollbars) / scale;
1209 } 1157 }
1210 1158
1211 double RenderView::layoutViewportHeight() const 1159 double RenderView::layoutViewportHeight() const
1212 { 1160 {
1213 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; 1161 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1;
1214 return viewHeight(ScrollableArea::IncludeScrollbars) / scale; 1162 return viewHeight(ScrollableArea::IncludeScrollbars) / scale;
1215 } 1163 }
1216 1164
1217 } // namespace WebCore 1165 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderView.h ('k') | Source/core/rendering/RenderWidget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698