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

Side by Side Diff: sky/engine/core/rendering/RenderBlock.cpp

Issue 754493002: Start splitting RenderParagraph logic out of RenderBlock (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: preland Created 6 years 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
« no previous file with comments | « sky/engine/core/rendering/RenderBlock.h ('k') | sky/engine/core/rendering/RenderBlockFlow.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 * (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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 394
395 void RenderBlock::layoutBlock(bool) 395 void RenderBlock::layoutBlock(bool)
396 { 396 {
397 ASSERT_NOT_REACHED(); 397 ASSERT_NOT_REACHED();
398 clearNeedsLayout(); 398 clearNeedsLayout();
399 } 399 }
400 400
401 void RenderBlock::addOverflowFromChildren() 401 void RenderBlock::addOverflowFromChildren()
402 { 402 {
403 if (isRenderParagraph()) 403 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
404 toRenderBlockFlow(this)->addOverflowFromInlineChildren(); 404 if (!child->isFloatingOrOutOfFlowPositioned())
405 else 405 addOverflowFromChild(child);
406 addOverflowFromBlockChildren(); 406 }
407 } 407 }
408 408
409 void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool) 409 void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool)
410 { 410 {
411 m_overflow.clear(); 411 m_overflow.clear();
412 412
413 // Add overflow from children. 413 // Add overflow from children.
414 addOverflowFromChildren(); 414 addOverflowFromChildren();
415 415
416 // Add in the overflow from positioned objects. 416 // Add in the overflow from positioned objects.
417 addOverflowFromPositionedObjects(); 417 addOverflowFromPositionedObjects();
418 418
419 if (hasOverflowClip()) { 419 if (hasOverflowClip()) {
420 // When we have overflow clip, propagate the original spillout since it will include collapsed bottom margins 420 // When we have overflow clip, propagate the original spillout since it will include collapsed bottom margins
421 // and bottom padding. Set the axis we don't care about to be 1, since we want this overflow to always 421 // and bottom padding. Set the axis we don't care about to be 1, since we want this overflow to always
422 // be considered reachable. 422 // be considered reachable.
423 LayoutRect clientRect(paddingBoxRect()); 423 LayoutRect clientRect(paddingBoxRect());
424 LayoutRect rectToApply; 424 LayoutRect rectToApply;
425 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, std::max<Lay outUnit>(0, oldClientAfterEdge - clientRect.y())); 425 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, std::max<Lay outUnit>(0, oldClientAfterEdge - clientRect.y()));
426 addLayoutOverflow(rectToApply); 426 addLayoutOverflow(rectToApply);
427 if (hasRenderOverflow()) 427 if (hasRenderOverflow())
428 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); 428 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge);
429 } 429 }
430 430
431 addVisualEffectOverflow(); 431 addVisualEffectOverflow();
432 } 432 }
433 433
434 void RenderBlock::addOverflowFromBlockChildren()
435 {
436 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
437 if (!child->isFloatingOrOutOfFlowPositioned())
438 addOverflowFromChild(child);
439 }
440 }
441
442 void RenderBlock::addOverflowFromPositionedObjects() 434 void RenderBlock::addOverflowFromPositionedObjects()
443 { 435 {
444 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); 436 TrackedRendererListHashSet* positionedDescendants = positionedObjects();
445 if (!positionedDescendants) 437 if (!positionedDescendants)
446 return; 438 return;
447 439
448 RenderBox* positionedObject; 440 RenderBox* positionedObject;
449 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 441 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
450 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) { 442 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
451 positionedObject = *it; 443 positionedObject = *it;
(...skipping 13 matching lines...) Expand all
465 if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView( ))) 457 if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView( )))
466 child->setChildNeedsLayout(MarkOnlyThis); 458 child->setChildNeedsLayout(MarkOnlyThis);
467 459
468 // If relayoutChildren is set and the child has percentage padding or an emb edded content box, we also need to invalidate the childs pref widths. 460 // If relayoutChildren is set and the child has percentage padding or an emb edded content box, we also need to invalidate the childs pref widths.
469 if (relayoutChildren && child->needsPreferredWidthsRecalculation()) 461 if (relayoutChildren && child->needsPreferredWidthsRecalculation())
470 child->setPreferredLogicalWidthsDirty(MarkOnlyThis); 462 child->setPreferredLogicalWidthsDirty(MarkOnlyThis);
471 } 463 }
472 464
473 void RenderBlock::simplifiedNormalFlowLayout() 465 void RenderBlock::simplifiedNormalFlowLayout()
474 { 466 {
475 if (isRenderParagraph()) { 467 for (RenderBox* box = firstChildBox(); box; box = box->nextSiblingBox()) {
476 ListHashSet<RootInlineBox*> lineBoxes; 468 if (!box->isOutOfFlowPositioned())
477 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { 469 box->layoutIfNeeded();
478 RenderObject* o = walker.current();
479 if (!o->isOutOfFlowPositioned() && o->isReplaced()) {
480 o->layoutIfNeeded();
481 if (toRenderBox(o)->inlineBoxWrapper()) {
482 RootInlineBox& box = toRenderBox(o)->inlineBoxWrapper()->roo t();
483 lineBoxes.add(&box);
484 }
485 } else if (o->isText() || (o->isRenderInline() && !walker.atEndOfInl ine())) {
486 o->clearNeedsLayout();
487 }
488 }
489
490 // FIXME: Glyph overflow will get lost in this case, but not really a bi g deal.
491 GlyphOverflowAndFallbackFontsMap textBoxDataMap;
492 for (ListHashSet<RootInlineBox*>::const_iterator it = lineBoxes.begin(); it != lineBoxes.end(); ++it) {
493 RootInlineBox* box = *it;
494 box->computeOverflow(box->lineTop(), box->lineBottom(), textBoxDataM ap);
495 }
496 } else {
497 for (RenderBox* box = firstChildBox(); box; box = box->nextSiblingBox()) {
498 if (!box->isOutOfFlowPositioned())
499 box->layoutIfNeeded();
500 }
501 } 470 }
502 } 471 }
503 472
504 bool RenderBlock::simplifiedLayout() 473 bool RenderBlock::simplifiedLayout()
505 { 474 {
506 // Check if we need to do a full layout. 475 // Check if we need to do a full layout.
507 if (normalChildNeedsLayout() || selfNeedsLayout()) 476 if (normalChildNeedsLayout() || selfNeedsLayout())
508 return false; 477 return false;
509 478
510 // Check that we actually need to do a simplified layout. 479 // Check that we actually need to do a simplified layout.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 613
645 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with 614 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with
646 // z-index. We paint after we painted the background/border, so that the sc rollbars will 615 // z-index. We paint after we painted the background/border, so that the sc rollbars will
647 // sit above the background/border. 616 // sit above the background/border.
648 if (hasOverflowClip() && (phase == PaintPhaseBlockBackground || phase == Pai ntPhaseChildBlockBackground) && paintInfo.shouldPaintWithinRoot(this) && !paintI nfo.paintRootBackgroundOnly()) 617 if (hasOverflowClip() && (phase == PaintPhaseBlockBackground || phase == Pai ntPhaseChildBlockBackground) && paintInfo.shouldPaintWithinRoot(this) && !paintI nfo.paintRootBackgroundOnly())
649 layer()->scrollableArea()->paintOverflowControls(paintInfo.context, roun dedIntPoint(adjustedPaintOffset), paintInfo.rect, false /* paintingOverlayContro ls */); 618 layer()->scrollableArea()->paintOverflowControls(paintInfo.context, roun dedIntPoint(adjustedPaintOffset), paintInfo.rect, false /* paintingOverlayContro ls */);
650 } 619 }
651 620
652 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 621 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
653 { 622 {
654 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC. 623 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? PaintPh aseOutline : paintInfo.phase;
655 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document 624 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChildBl ockBackground : newPhase;
656 // will do a full paint invalidation.
657 if (document().didLayoutWithPendingStylesheets() && !isRenderView())
658 return;
659 625
660 if (isRenderParagraph()) 626 // We don't paint our own background, but we do let the kids paint their bac kgrounds.
661 m_lineBoxes.paint(this, paintInfo, paintOffset); 627 PaintInfo paintInfoForChild(paintInfo);
662 else { 628 paintInfoForChild.phase = newPhase;
663 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai ntPhaseOutline : paintInfo.phase; 629 paintInfoForChild.updatePaintingRootForChildren(this);
664 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase; 630 paintChildren(paintInfoForChild, paintOffset);
665
666 // We don't paint our own background, but we do let the kids paint their backgrounds.
667 PaintInfo paintInfoForChild(paintInfo);
668 paintInfoForChild.phase = newPhase;
669 paintInfoForChild.updatePaintingRootForChildren(this);
670 paintChildren(paintInfoForChild, paintOffset);
671 }
672 } 631 }
673 632
674 void RenderBlock::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 633 void RenderBlock::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
675 { 634 {
676 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) 635 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x())
677 paintChild(child, paintInfo, paintOffset); 636 paintChild(child, paintInfo, paintOffset);
678 } 637 }
679 638
680 void RenderBlock::paintChild(RenderBox* child, PaintInfo& paintInfo, const Layou tPoint& paintOffset) 639 void RenderBlock::paintChild(RenderBox* child, PaintInfo& paintInfo, const Layou tPoint& paintOffset)
681 { 640 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 if (paintPhase == PaintPhaseClippingMask) { 723 if (paintPhase == PaintPhaseClippingMask) {
765 paintClippingMask(paintInfo, paintOffset); 724 paintClippingMask(paintInfo, paintOffset);
766 return; 725 return;
767 } 726 }
768 727
769 // We're done. We don't bother painting any children. 728 // We're done. We don't bother painting any children.
770 if (paintPhase == PaintPhaseBlockBackground || paintInfo.paintRootBackground Only()) 729 if (paintPhase == PaintPhaseBlockBackground || paintInfo.paintRootBackground Only())
771 return; 730 return;
772 731
773 // 2. paint contents 732 // 2. paint contents
774 if (paintPhase != PaintPhaseSelfOutline) 733 if (paintPhase != PaintPhaseSelfOutline) {
775 paintContents(paintInfo, scrolledOffset); 734 // Avoid painting descendants of the root element when stylesheets haven 't loaded. This eliminates FOUC.
735 // It's ok not to draw, because later on, when all the stylesheets do lo ad, styleResolverChanged() on the Document
736 // will do a full paint invalidation.
737 if (!document().didLayoutWithPendingStylesheets() || isRenderView())
738 paintContents(paintInfo, scrolledOffset);
739 }
776 740
777 // 3. paint selection 741 // 3. paint selection
778 // FIXME: Make this work with multi column layouts. For now don't fill gaps . 742 // FIXME: Make this work with multi column layouts. For now don't fill gaps .
779 paintSelection(paintInfo, scrolledOffset); // Fill in gaps in selection on l ines and between blocks. 743 paintSelection(paintInfo, scrolledOffset); // Fill in gaps in selection on l ines and between blocks.
780 744
781 // 5. paint outline. 745 // 5. paint outline.
782 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) 746 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline)
783 && style()->hasOutline() && !style()->outlineStyleIsAuto()) { 747 && style()->hasOutline() && !style()->outlineStyleIsAuto()) {
784 paintOutline(paintInfo, LayoutRect(paintOffset, size())); 748 paintOutline(paintInfo, LayoutRect(paintOffset, size()));
785 } 749 }
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn Container, boundsRect)) 1376 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn Container, boundsRect))
1413 return true; 1377 return true;
1414 } 1378 }
1415 } 1379 }
1416 1380
1417 return false; 1381 return false;
1418 } 1382 }
1419 1383
1420 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat edOffset, HitTestAction hitTestAction) 1384 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat edOffset, HitTestAction hitTestAction)
1421 { 1385 {
1422 if (isRenderParagraph()) { 1386 // Hit test our children.
1423 // We have to hit-test our line boxes. 1387 HitTestAction childHitTest = hitTestAction;
1424 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu mulatedOffset, hitTestAction)) 1388 if (hitTestAction == HitTestChildBlockBackgrounds)
1389 childHitTest = HitTestChildBlockBackground;
1390 for (RenderBox* child = lastChildBox(); child; child = child->previousSiblin gBox()) {
1391 if (!child->hasSelfPaintingLayer() && child->nodeAtPoint(request, result , locationInContainer, accumulatedOffset, childHitTest))
1425 return true; 1392 return true;
1426 } else {
1427 // Hit test our children.
1428 HitTestAction childHitTest = hitTestAction;
1429 if (hitTestAction == HitTestChildBlockBackgrounds)
1430 childHitTest = HitTestChildBlockBackground;
1431 for (RenderBox* child = lastChildBox(); child; child = child->previousSi blingBox()) {
1432 if (!child->hasSelfPaintingLayer() && child->nodeAtPoint(request, re sult, locationInContainer, accumulatedOffset, childHitTest))
1433 return true;
1434 }
1435 } 1393 }
1436 1394
1437 return false; 1395 return false;
1438 } 1396 }
1439 1397
1440 Position RenderBlock::positionForBox(InlineBox *box, bool start) const 1398 Position RenderBlock::positionForBox(InlineBox *box, bool start) const
1441 { 1399 {
1442 if (!box) 1400 if (!box)
1443 return Position(); 1401 return Position();
1444 1402
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 2142 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
2185 { 2143 {
2186 showRenderObject(); 2144 showRenderObject();
2187 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2145 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2188 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2146 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2189 } 2147 }
2190 2148
2191 #endif 2149 #endif
2192 2150
2193 } // namespace blink 2151 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBlock.h ('k') | sky/engine/core/rendering/RenderBlockFlow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698