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

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

Issue 404993002: Move fitBorderToLinesIfNeeded and most of deleteLineBoxTree into RenderBlockFlow. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 cache->recomputeIsIgnored(this); 1771 cache->recomputeIsIgnored(this);
1772 } 1772 }
1773 1773
1774 return rootBox; 1774 return rootBox;
1775 } 1775 }
1776 1776
1777 void RenderBlockFlow::deleteLineBoxTree() 1777 void RenderBlockFlow::deleteLineBoxTree()
1778 { 1778 {
1779 if (containsFloats()) 1779 if (containsFloats())
1780 m_floatingObjects->clearLineBoxTreePointers(); 1780 m_floatingObjects->clearLineBoxTreePointers();
1781 RenderBlock::deleteLineBoxTree(); 1781
1782 m_lineBoxes.deleteLineBoxTree();
1783
1784 if (AXObjectCache* cache = document().existingAXObjectCache())
1785 cache->recomputeIsIgnored(this);
1782 } 1786 }
1783 1787
1784 void RenderBlockFlow::markAllDescendantsWithFloatsForLayout(RenderBox* floatToRe move, bool inLayout) 1788 void RenderBlockFlow::markAllDescendantsWithFloatsForLayout(RenderBox* floatToRe move, bool inLayout)
1785 { 1789 {
1786 if (!everHadLayout() && !containsFloats()) 1790 if (!everHadLayout() && !containsFloats())
1787 return; 1791 return;
1788 1792
1789 if (m_descendantsWithFloatsMarkedForLayout && !floatToRemove) 1793 if (m_descendantsWithFloatsMarkedForLayout && !floatToRemove)
1790 return; 1794 return;
1791 m_descendantsWithFloatsMarkedForLayout |= !floatToRemove; 1795 m_descendantsWithFloatsMarkedForLayout |= !floatToRemove;
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 return true; 2647 return true;
2644 } 2648 }
2645 } 2649 }
2646 } 2650 }
2647 2651
2648 return false; 2652 return false;
2649 } 2653 }
2650 2654
2651 void RenderBlockFlow::adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutU nit& right) const 2655 void RenderBlockFlow::adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutU nit& right) const
2652 { 2656 {
2653 RenderBlock::adjustForBorderFit(x, left, right); 2657 if (style()->visibility() != VISIBLE)
2654 if (m_floatingObjects && style()->visibility() == VISIBLE) { 2658 return;
2659
2660 // We don't deal with relative positioning. Our assumption is that you shrin k to fit the lines without accounting
2661 // for either overflow or translations via relative positioning.
2662 if (childrenInline()) {
2663 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) {
2664 if (box->firstChild())
2665 left = std::min(left, x + static_cast<LayoutUnit>(box->firstChil d()->x()));
2666 if (box->lastChild())
2667 right = std::max(right, x + static_cast<LayoutUnit>(ceilf(box->l astChild()->logicalRight())));
2668 }
2669 } else {
2670 for (RenderBox* obj = firstChildBox(); obj; obj = obj->nextSiblingBox()) {
2671 if (!obj->isFloatingOrOutOfFlowPositioned()) {
2672 if (obj->isRenderBlockFlow() && !obj->hasOverflowClip()) {
2673 toRenderBlockFlow(obj)->adjustForBorderFit(x + obj->x(), lef t, right);
2674 } else if (obj->style()->visibility() == VISIBLE) {
2675 // We are a replaced element or some kind of non-block-flow object.
2676 left = std::min(left, x + obj->x());
2677 right = std::max(right, x + obj->x() + obj->width());
2678 }
2679 }
2680 }
2681 }
2682
2683 if (m_floatingObjects) {
2655 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2684 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2656 FloatingObjectSetIterator end = floatingObjectSet.end(); 2685 FloatingObjectSetIterator end = floatingObjectSet.end();
2657 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { 2686 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) {
2658 FloatingObject* floatingObject = it->get(); 2687 FloatingObject* floatingObject = it->get();
2659 // Only examine the object if our m_shouldPaint flag is set. 2688 // Only examine the object if our m_shouldPaint flag is set.
2660 if (floatingObject->shouldPaint()) { 2689 if (floatingObject->shouldPaint()) {
2661 LayoutUnit floatLeft = xPositionForFloatIncludingMargin(floating Object) - floatingObject->renderer()->x(); 2690 LayoutUnit floatLeft = xPositionForFloatIncludingMargin(floating Object) - floatingObject->renderer()->x();
2662 LayoutUnit floatRight = floatLeft + floatingObject->renderer()-> width(); 2691 LayoutUnit floatRight = floatLeft + floatingObject->renderer()-> width();
2663 left = std::min(left, floatLeft); 2692 left = std::min(left, floatLeft);
2664 right = std::max(right, floatRight); 2693 right = std::max(right, floatRight);
2665 } 2694 }
2666 } 2695 }
2667 } 2696 }
2668 } 2697 }
2669 2698
2699 void RenderBlockFlow::fitBorderToLinesIfNeeded()
2700 {
2701 if (style()->borderFit() == BorderFitBorder || hasOverrideWidth())
2702 return;
2703
2704 // Walk any normal flow lines to snugly fit.
2705 LayoutUnit left = LayoutUnit::max();
2706 LayoutUnit right = LayoutUnit::min();
2707 LayoutUnit oldWidth = contentWidth();
2708 adjustForBorderFit(0, left, right);
2709
2710 // Clamp to our existing edges. We can never grow. We only shrink.
2711 LayoutUnit leftEdge = borderLeft() + paddingLeft();
2712 LayoutUnit rightEdge = leftEdge + oldWidth;
2713 left = std::min(rightEdge, std::max(leftEdge, left));
2714 right = std::max(left, std::min(rightEdge, right));
2715
2716 LayoutUnit newContentWidth = right - left;
2717 if (newContentWidth == oldWidth)
2718 return;
2719
2720 setOverrideLogicalContentWidth(newContentWidth);
2721 layoutBlock(false);
2722 clearOverrideLogicalContentWidth();
2723 }
2724
2670 LayoutUnit RenderBlockFlow::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, LayoutUnit logicalHeight) const 2725 LayoutUnit RenderBlockFlow::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, LayoutUnit logicalHeight) const
2671 { 2726 {
2672 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) 2727 if (m_floatingObjects && m_floatingObjects->hasLeftObjects())
2673 return m_floatingObjects->logicalLeftOffset(fixedOffset, logicalTop, log icalHeight); 2728 return m_floatingObjects->logicalLeftOffset(fixedOffset, logicalTop, log icalHeight);
2674 2729
2675 return fixedOffset; 2730 return fixedOffset;
2676 } 2731 }
2677 2732
2678 LayoutUnit RenderBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop , LayoutUnit fixedOffset, LayoutUnit logicalHeight) const 2733 LayoutUnit RenderBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop , LayoutUnit fixedOffset, LayoutUnit logicalHeight) const
2679 { 2734 {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() 2901 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData()
2847 { 2902 {
2848 if (m_rareData) 2903 if (m_rareData)
2849 return *m_rareData; 2904 return *m_rareData;
2850 2905
2851 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 2906 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
2852 return *m_rareData; 2907 return *m_rareData;
2853 } 2908 }
2854 2909
2855 } // namespace blink 2910 } // namespace blink
OLDNEW
« Source/core/rendering/RenderBlock.cpp ('K') | « Source/core/rendering/RenderBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698