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

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

Issue 360833002: Divorce PaintInvalidationState from LayoutState (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ToT again... Created 6 years, 5 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 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // If the style has unloaded images, want to notify the ResourceLoadPriority Optimizer so that 355 // If the style has unloaded images, want to notify the ResourceLoadPriority Optimizer so that
356 // network priorities can be set. 356 // network priorities can be set.
357 Vector<ImageResource*> images; 357 Vector<ImageResource*> images;
358 appendImagesFromStyle(images, *newStyle); 358 appendImagesFromStyle(images, *newStyle);
359 if (images.isEmpty()) 359 if (images.isEmpty())
360 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeRe nderObject(this); 360 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeRe nderObject(this);
361 else 361 else
362 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addRende rObject(this); 362 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addRende rObject(this);
363 } 363 }
364 364
365 void RenderBlock::invalidateTreeAfterLayout(const RenderLayerModelObject& invali dationContainer) 365 void RenderBlock::invalidateTreeAfterLayout(const PaintInvalidationState& paintI nvalidationState)
366 { 366 {
367 // Note, we don't want to early out here using shouldCheckForInvalidationAft erLayout as 367 // Note, we don't want to early out here using shouldCheckForInvalidationAft erLayout as
368 // we have to make sure we go through any positioned objects as they won't b e seen in 368 // we have to make sure we go through any positioned objects as they won't b e seen in
369 // the normal tree walk. 369 // the normal tree walk.
370 370
371 if (shouldCheckForPaintInvalidationAfterLayout()) 371 if (shouldCheckForPaintInvalidationAfterLayout())
372 RenderBox::invalidateTreeAfterLayout(invalidationContainer); 372 RenderBox::invalidateTreeAfterLayout(paintInvalidationState);
373 373
374 // Take care of positioned objects. This is required as LayoutState keeps a single clip rect. 374 // Take care of positioned objects. This is required as PaintInvalidationSta te keeps a single clip rect.
375 if (TrackedRendererListHashSet* positionedObjects = this->positionedObjects( )) { 375 if (TrackedRendererListHashSet* positionedObjects = this->positionedObjects( )) {
376 TrackedRendererListHashSet::iterator end = positionedObjects->end(); 376 TrackedRendererListHashSet::iterator end = positionedObjects->end();
377 LayoutState state(*this, isTableRow() ? LayoutSize() : locationOffset()) ; 377 bool establishesNewPaintInvalidationContainer = isPaintInvalidationConta iner();
378 const RenderLayerModelObject& newPaintInvalidationContainer = *adjustCom positedContainerForSpecialAncestors(establishesNewPaintInvalidationContainer ? t his : &paintInvalidationState.paintInvalidationContainer());
379 PaintInvalidationState childPaintInvalidationState(paintInvalidationStat e, *this, newPaintInvalidationContainer);
378 for (TrackedRendererListHashSet::iterator it = positionedObjects->begin( ); it != end; ++it) { 380 for (TrackedRendererListHashSet::iterator it = positionedObjects->begin( ); it != end; ++it) {
379 RenderBox* box = *it; 381 RenderBox* box = *it;
380 382
381 // One of the renderers we're skipping over here may be the child's repaint container, 383 // One of the renderers we're skipping over here may be the child's repaint container,
382 // so we can't pass our own repaint container along. 384 // so we can't pass our own repaint container along.
383 const RenderLayerModelObject& repaintContainerForChild = *box->conta inerForPaintInvalidation(); 385 const RenderLayerModelObject& repaintContainerForChild = *box->conta inerForPaintInvalidation();
384 386
387 // If it's a new paint invalidation container, we won't have properl y accumulated the offset into the
388 // PaintInvalidationState.
389 // FIXME: Teach PaintInvalidationState to handle this case. crbug.co m/371485
390 if (&repaintContainerForChild != newPaintInvalidationContainer) {
391 ForceHorriblySlowRectMapping slowRectMapping(&childPaintInvalida tionState);
392 PaintInvalidationState disabledPaintInvalidationState(childPaint InvalidationState, *this, repaintContainerForChild);
393 box->invalidateTreeAfterLayout(disabledPaintInvalidationState);
394 continue;
395 }
396
385 // If the positioned renderer is absolutely positioned and it is ins ide 397 // If the positioned renderer is absolutely positioned and it is ins ide
386 // a relatively positioend inline element, we need to account for 398 // a relatively positioned inline element, we need to account for
387 // the inline elements position in LayoutState. 399 // the inline elements position in PaintInvalidationState.
388 if (box->style()->position() == AbsolutePosition) { 400 if (box->style()->position() == AbsolutePosition) {
389 RenderObject* container = box->container(&repaintContainerForChi ld, 0); 401 RenderObject* container = box->container(&repaintContainerForChi ld, 0);
390 if (container->isRelPositioned() && container->isRenderInline()) { 402 if (container->isRelPositioned() && container->isRenderInline()) {
391 // FIXME: We should be able to use layout-state for this. 403 // FIXME: We should be able to use PaintInvalidationState fo r this.
392 // Currently, we will place absolutly positioned elements in side 404 // Currently, we will place absolutely positioned elements i nside
393 // relatively positioned inline blocks in the wrong location . crbug.com/371485 405 // relatively positioned inline blocks in the wrong location . crbug.com/371485
394 ForceHorriblySlowRectMapping slowRectMapping(*this); 406 ForceHorriblySlowRectMapping slowRectMapping(&childPaintInva lidationState);
395 box->invalidateTreeAfterLayout(repaintContainerForChild); 407 PaintInvalidationState disabledPaintInvalidationState(childP aintInvalidationState, *this, repaintContainerForChild);
408 box->invalidateTreeAfterLayout(disabledPaintInvalidationStat e);
396 continue; 409 continue;
397 } 410 }
398 } 411 }
399 412
400 box->invalidateTreeAfterLayout(repaintContainerForChild); 413 box->invalidateTreeAfterLayout(childPaintInvalidationState);
401 } 414 }
402 } 415 }
403 } 416 }
404 417
405 RenderBlock* RenderBlock::continuationBefore(RenderObject* beforeChild) 418 RenderBlock* RenderBlock::continuationBefore(RenderObject* beforeChild)
406 { 419 {
407 if (beforeChild && beforeChild->parent() == this) 420 if (beforeChild && beforeChild->parent() == this)
408 return this; 421 return this;
409 422
410 RenderBlock* curr = toRenderBlock(continuation()); 423 RenderBlock* curr = toRenderBlock(continuation());
(...skipping 3585 matching lines...) Expand 10 before | Expand all | Expand 10 after
3996 return 0; 4009 return 0;
3997 } 4010 }
3998 4011
3999 void RenderBlock::updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderO bject* currentChild) 4012 void RenderBlock::updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderO bject* currentChild)
4000 { 4013 {
4001 RenderObject* firstLetter = currentChild->parent(); 4014 RenderObject* firstLetter = currentChild->parent();
4002 RenderObject* firstLetterContainer = firstLetter->parent(); 4015 RenderObject* firstLetterContainer = firstLetter->parent();
4003 RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetter Container); 4016 RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetter Container);
4004 ASSERT(firstLetter->isFloating() || firstLetter->isInline()); 4017 ASSERT(firstLetter->isFloating() || firstLetter->isInline());
4005 4018
4006 ForceHorriblySlowRectMapping slowRectMapping(*this);
4007
4008 if (RenderStyle::stylePropagationDiff(firstLetter->style(), pseudoStyle) == Reattach) { 4019 if (RenderStyle::stylePropagationDiff(firstLetter->style(), pseudoStyle) == Reattach) {
4009 // The first-letter renderer needs to be replaced. Create a new renderer of the right type. 4020 // The first-letter renderer needs to be replaced. Create a new renderer of the right type.
4010 RenderBoxModelObject* newFirstLetter; 4021 RenderBoxModelObject* newFirstLetter;
4011 if (pseudoStyle->display() == INLINE) 4022 if (pseudoStyle->display() == INLINE)
4012 newFirstLetter = RenderInline::createAnonymous(&document()); 4023 newFirstLetter = RenderInline::createAnonymous(&document());
4013 else 4024 else
4014 newFirstLetter = RenderBlockFlow::createAnonymous(&document()); 4025 newFirstLetter = RenderBlockFlow::createAnonymous(&document());
4015 newFirstLetter->setStyle(pseudoStyle); 4026 newFirstLetter->setStyle(pseudoStyle);
4016 4027
4017 // Move the first letter into the new renderer. 4028 // Move the first letter into the new renderer.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
4178 if (currChild->parent()->style()->styleType() == FIRST_LETTER) { 4189 if (currChild->parent()->style()->styleType() == FIRST_LETTER) {
4179 updateFirstLetterStyle(firstLetterBlock, currChild); 4190 updateFirstLetterStyle(firstLetterBlock, currChild);
4180 return; 4191 return;
4181 } 4192 }
4182 4193
4183 // FIXME: This black-list of disallowed RenderText subclasses is fragile. 4194 // FIXME: This black-list of disallowed RenderText subclasses is fragile.
4184 // Should counter be on this list? What about RenderTextFragment? 4195 // Should counter be on this list? What about RenderTextFragment?
4185 if (!currChild->isText() || currChild->isBR() || toRenderText(currChild)->is WordBreak()) 4196 if (!currChild->isText() || currChild->isBR() || toRenderText(currChild)->is WordBreak())
4186 return; 4197 return;
4187 4198
4188 // Our layout state is not valid for the repaints we are going to trigger by
4189 // adding and removing children of firstLetterContainer.
4190 ForceHorriblySlowRectMapping slowRectMapping(*this);
4191
4192 createFirstLetterRenderer(firstLetterBlock, currChild, length); 4199 createFirstLetterRenderer(firstLetterBlock, currChild, length);
4193 } 4200 }
4194 4201
4195 // Helper methods for obtaining the last line, computing line counts and heights for line counts 4202 // Helper methods for obtaining the last line, computing line counts and heights for line counts
4196 // (crawling into blocks). 4203 // (crawling into blocks).
4197 static bool shouldCheckLines(RenderObject* obj) 4204 static bool shouldCheckLines(RenderObject* obj)
4198 { 4205 {
4199 return !obj->isFloatingOrOutOfFlowPositioned() 4206 return !obj->isFloatingOrOutOfFlowPositioned()
4200 && obj->isRenderBlock() && obj->style()->height().isAuto() 4207 && obj->isRenderBlock() && obj->style()->height().isAuto()
4201 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT ICAL); 4208 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT ICAL);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
4440 // https://bugs.webkit.org/show_bug.cgi?id=46781 4447 // https://bugs.webkit.org/show_bug.cgi?id=46781
4441 FloatRect localRect(0, -collapsedMarginBefore().toFloat(), 4448 FloatRect localRect(0, -collapsedMarginBefore().toFloat(),
4442 width().toFloat(), (height() + collapsedMarginBefore() + collapsedMa rginAfter()).toFloat()); 4449 width().toFloat(), (height() + collapsedMarginBefore() + collapsedMa rginAfter()).toFloat());
4443 quads.append(localToAbsoluteQuad(localRect, 0 /* mode */, wasFixed)); 4450 quads.append(localToAbsoluteQuad(localRect, 0 /* mode */, wasFixed));
4444 continuation()->absoluteQuads(quads, wasFixed); 4451 continuation()->absoluteQuads(quads, wasFixed);
4445 } else { 4452 } else {
4446 quads.append(RenderBox::localToAbsoluteQuad(FloatRect(0, 0, width().toFl oat(), height().toFloat()), 0 /* mode */, wasFixed)); 4453 quads.append(RenderBox::localToAbsoluteQuad(FloatRect(0, 0, width().toFl oat(), height().toFloat()), 0 /* mode */, wasFixed));
4447 } 4454 }
4448 } 4455 }
4449 4456
4450 LayoutRect RenderBlock::rectWithOutlineForPaintInvalidation(const RenderLayerMod elObject* paintInvalidationContainer, LayoutUnit outlineWidth) const 4457 LayoutRect RenderBlock::rectWithOutlineForPaintInvalidation(const RenderLayerMod elObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvali dationState* paintInvalidationState) const
4451 { 4458 {
4452 LayoutRect r(RenderBox::rectWithOutlineForPaintInvalidation(paintInvalidatio nContainer, outlineWidth)); 4459 LayoutRect r(RenderBox::rectWithOutlineForPaintInvalidation(paintInvalidatio nContainer, outlineWidth, paintInvalidationState));
4453 if (isAnonymousBlockContinuation()) 4460 if (isAnonymousBlockContinuation())
4454 r.inflateY(collapsedMarginBefore()); // FIXME: This is wrong for block-f lows that are horizontal. 4461 r.inflateY(collapsedMarginBefore()); // FIXME: This is wrong for block-f lows that are horizontal.
4455 return r; 4462 return r;
4456 } 4463 }
4457 4464
4458 RenderObject* RenderBlock::hoverAncestor() const 4465 RenderObject* RenderBlock::hoverAncestor() const
4459 { 4466 {
4460 return isAnonymousBlockContinuation() ? continuation() : RenderBox::hoverAnc estor(); 4467 return isAnonymousBlockContinuation() ? continuation() : RenderBox::hoverAnc estor();
4461 } 4468 }
4462 4469
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
5049 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5056 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5050 { 5057 {
5051 showRenderObject(); 5058 showRenderObject();
5052 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5059 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5053 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5060 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5054 } 5061 }
5055 5062
5056 #endif 5063 #endif
5057 5064
5058 } // namespace WebCore 5065 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698