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

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

Issue 204813002: Optimize layout/repaint on FrameView resize (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Is it better to let layout fully control what to repaint? Created 6 years, 9 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) 2006 Apple Computer, Inc. 3 * Copyright (C) 2006 Apple Computer, Inc.
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 #if !ASSERT_DISABLED 126 #if !ASSERT_DISABLED
127 bool layoutDeltaMatches(const LayoutSize& delta) 127 bool layoutDeltaMatches(const LayoutSize& delta)
128 { 128 {
129 ASSERT(!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()); 129 ASSERT(!RuntimeEnabledFeatures::repaintAfterLayoutEnabled());
130 if (!m_layoutState) 130 if (!m_layoutState)
131 return false; 131 return false;
132 return (delta.width() == m_layoutState->m_layoutDelta.width() || m_layou tState->m_layoutDeltaXSaturated) && (delta.height() == m_layoutState->m_layoutDe lta.height() || m_layoutState->m_layoutDeltaYSaturated); 132 return (delta.width() == m_layoutState->m_layoutDelta.width() || m_layou tState->m_layoutDeltaXSaturated) && (delta.height() == m_layoutState->m_layoutDe lta.height() || m_layoutState->m_layoutDeltaYSaturated);
133 } 133 }
134 #endif 134 #endif
135 135
136 bool doingFullRepaint() const { return m_frameView->needsFullRepaint(); }
137
138 // Subtree push 136 // Subtree push
139 void pushLayoutState(RenderObject&); 137 void pushLayoutState(RenderObject&);
140 138
141 void popLayoutState() 139 void popLayoutState()
142 { 140 {
143 LayoutState* state = m_layoutState; 141 LayoutState* state = m_layoutState;
144 m_layoutState = state->m_next; 142 m_layoutState = state->m_next;
145 delete state; 143 delete state;
146 popLayoutStateForCurrentFlowThread(); 144 popLayoutStateForCurrentFlowThread();
147 } 145 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) c onst OVERRIDE; 209 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) c onst OVERRIDE;
212 virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const OVERRIDE; 210 virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const OVERRIDE;
213 211
214 void initializeLayoutState(LayoutState&); 212 void initializeLayoutState(LayoutState&);
215 213
216 bool shouldRepaint(const LayoutRect&) const; 214 bool shouldRepaint(const LayoutRect&) const;
217 215
218 bool rootFillsViewportBackground(RenderBox* rootBox) const; 216 bool rootFillsViewportBackground(RenderBox* rootBox) const;
219 217
220 // These functions may only be accessed by LayoutStateMaintainer. 218 // These functions may only be accessed by LayoutStateMaintainer.
221 bool pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUn it pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0) 219 void pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUn it pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
222 { 220 {
223 // We push LayoutState even if layoutState is disabled because it stores layoutDelta too. 221 pushLayoutStateForCurrentFlowThread(renderer);
224 if (!doingFullRepaint() || m_layoutState->isPaginated() || renderer.hasC olumns() || renderer.flowThreadContainingBlock() 222 m_layoutState = new LayoutState(m_layoutState, renderer, offset, pageHei ght, pageHeightChanged, colInfo);
225 || (renderer.isRenderBlock() && toRenderBlock(renderer).shapeInsideI nfo())
226 || (m_layoutState->shapeInsideInfo() && renderer.isRenderBlock() && !toRenderBlock(renderer).allowsShapeInsideInfoSharing(&m_layoutState->shapeInsid eInfo()->owner()))
227 ) {
228 pushLayoutStateForCurrentFlowThread(renderer);
229 m_layoutState = new LayoutState(m_layoutState, renderer, offset, pag eHeight, pageHeightChanged, colInfo);
230 return true;
231 }
232 return false;
233 } 223 }
234 224
235 void layoutContent(const LayoutState&); 225 void layoutContent(const LayoutState&);
236 #ifndef NDEBUG 226 #ifndef NDEBUG
237 void checkLayoutState(const LayoutState&); 227 void checkLayoutState(const LayoutState&);
238 #endif 228 #endif
239 229
240 void positionDialog(RenderBox*); 230 void positionDialog(RenderBox*);
241 void positionDialogs(); 231 void positionDialogs();
242 232
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // Stack-based class to assist with LayoutState push/pop 266 // Stack-based class to assist with LayoutState push/pop
277 class LayoutStateMaintainer { 267 class LayoutStateMaintainer {
278 WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer); 268 WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer);
279 public: 269 public:
280 // ctor to push now 270 // ctor to push now
281 explicit LayoutStateMaintainer(RenderBox& root, const LayoutSize& offset, La youtUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0 ) 271 explicit LayoutStateMaintainer(RenderBox& root, const LayoutSize& offset, La youtUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0 )
282 : m_view(*root.view()) 272 : m_view(*root.view())
283 , m_disabled(root.shouldDisableLayoutState()) 273 , m_disabled(root.shouldDisableLayoutState())
284 , m_didStart(false) 274 , m_didStart(false)
285 , m_didEnd(false) 275 , m_didEnd(false)
286 , m_didCreateLayoutState(false)
287 { 276 {
288 push(root, offset, pageHeight, pageHeightChanged, colInfo); 277 push(root, offset, pageHeight, pageHeightChanged, colInfo);
289 } 278 }
290 279
291 // ctor to maybe push later 280 // ctor to maybe push later
292 explicit LayoutStateMaintainer(RenderBox& root) 281 explicit LayoutStateMaintainer(RenderBox& root)
293 : m_view(*root.view()) 282 : m_view(*root.view())
294 , m_disabled(false) 283 , m_disabled(false)
295 , m_didStart(false) 284 , m_didStart(false)
296 , m_didEnd(false) 285 , m_didEnd(false)
297 , m_didCreateLayoutState(false)
298 { 286 {
299 } 287 }
300 288
301 ~LayoutStateMaintainer() 289 ~LayoutStateMaintainer()
302 { 290 {
303 ASSERT(m_didStart == m_didEnd); // if this fires, it means that someon e did a push(), but forgot to pop(). 291 ASSERT(m_didStart == m_didEnd); // if this fires, it means that someon e did a push(), but forgot to pop().
304 } 292 }
305 293
306 void push(RenderBox& root, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0) 294 void push(RenderBox& root, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
307 { 295 {
308 ASSERT(!m_didStart); 296 ASSERT(!m_didStart);
309 // We push state even if disabled, because we still need to store layout Delta 297 // We push state even if disabled, because we still need to store layout Delta
310 m_didCreateLayoutState = m_view.pushLayoutState(root, offset, pageHeight , pageHeightChanged, colInfo); 298 m_view.pushLayoutState(root, offset, pageHeight, pageHeightChanged, colI nfo);
311 if (m_disabled && m_didCreateLayoutState) 299 if (m_disabled)
312 m_view.disableLayoutState(); 300 m_view.disableLayoutState();
313 m_didStart = true; 301 m_didStart = true;
314 } 302 }
315 303
316 void pop() 304 void pop()
317 { 305 {
318 if (m_didStart) { 306 if (m_didStart) {
319 ASSERT(!m_didEnd); 307 ASSERT(!m_didEnd);
320 if (m_didCreateLayoutState) { 308 m_view.popLayoutState();
321 m_view.popLayoutState(); 309 if (m_disabled)
322 if (m_disabled) 310 m_view.enableLayoutState();
323 m_view.enableLayoutState();
324 }
325 311
326 m_didEnd = true; 312 m_didEnd = true;
327 } 313 }
328 } 314 }
329 315
330 bool didPush() const { return m_didStart; } 316 bool didPush() const { return m_didStart; }
331 317
332 private: 318 private:
333 RenderView& m_view; 319 RenderView& m_view;
334 bool m_disabled : 1; // true if the offset and clip part of layoutSta te is disabled 320 bool m_disabled : 1; // true if the offset and clip part of layoutSta te is disabled
335 bool m_didStart : 1; // true if we did a push or disable 321 bool m_didStart : 1; // true if we did a push or disable
336 bool m_didEnd : 1; // true if we popped or re-enabled 322 bool m_didEnd : 1; // true if we popped or re-enabled
337 bool m_didCreateLayoutState : 1; // true if we actually made a layout state.
338 }; 323 };
339 324
340 class LayoutStateDisabler { 325 class LayoutStateDisabler {
341 WTF_MAKE_NONCOPYABLE(LayoutStateDisabler); 326 WTF_MAKE_NONCOPYABLE(LayoutStateDisabler);
342 public: 327 public:
343 LayoutStateDisabler(const RenderBox& root) 328 LayoutStateDisabler(const RenderBox& root)
344 : m_view(*root.view()) 329 : m_view(*root.view())
345 { 330 {
346 m_view.disableLayoutState(); 331 m_view.disableLayoutState();
347 } 332 }
348 333
349 ~LayoutStateDisabler() 334 ~LayoutStateDisabler()
350 { 335 {
351 m_view.enableLayoutState(); 336 m_view.enableLayoutState();
352 } 337 }
353 private: 338 private:
354 RenderView& m_view; 339 RenderView& m_view;
355 }; 340 };
356 341
357 } // namespace WebCore 342 } // namespace WebCore
358 343
359 #endif // RenderView_h 344 #endif // RenderView_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698