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

Side by Side Diff: Source/core/layout/LayoutBlockFlow.cpp

Issue 1103883002: Convert Block code to layoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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/layout/LayoutBlock.cpp ('k') | Source/core/layout/LayoutBlockFlowLine.cpp » ('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) 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), "MarginInf o should stay small"); 166 static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), "MarginInf o should stay small");
167 setChildrenInline(true); 167 setChildrenInline(true);
168 } 168 }
169 169
170 LayoutBlockFlow::~LayoutBlockFlow() 170 LayoutBlockFlow::~LayoutBlockFlow()
171 { 171 {
172 } 172 }
173 173
174 LayoutBlockFlow* LayoutBlockFlow::createAnonymous(Document* document) 174 LayoutBlockFlow* LayoutBlockFlow::createAnonymous(Document* document)
175 { 175 {
176 LayoutBlockFlow* renderer = new LayoutBlockFlow(0); 176 LayoutBlockFlow* layoutBlockFlow = new LayoutBlockFlow(0);
177 renderer->setDocumentForAnonymous(document); 177 layoutBlockFlow->setDocumentForAnonymous(document);
178 return renderer; 178 return layoutBlockFlow;
179 } 179 }
180 180
181 LayoutObject* LayoutBlockFlow::layoutSpecialExcludedChild(bool relayoutChildren, SubtreeLayoutScope& layoutScope) 181 LayoutObject* LayoutBlockFlow::layoutSpecialExcludedChild(bool relayoutChildren, SubtreeLayoutScope& layoutScope)
182 { 182 {
183 LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread(); 183 LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread();
184 if (!flowThread) 184 if (!flowThread)
185 return 0; 185 return 0;
186 setLogicalTopForChild(*flowThread, borderBefore() + paddingBefore()); 186 setLogicalTopForChild(*flowThread, borderBefore() + paddingBefore());
187 flowThread->layoutColumns(relayoutChildren, layoutScope); 187 flowThread->layoutColumns(relayoutChildren, layoutScope);
188 determineLogicalLeftPositionForChild(*flowThread); 188 determineLogicalLeftPositionForChild(*flowThread);
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // adjustLinePositionForPagination() for more details. 792 // adjustLinePositionForPagination() for more details.
793 LayoutRect overflow = line->logicalVisualOverflowRect(line->lineTop(), l ine->lineBottom()); 793 LayoutRect overflow = line->logicalVisualOverflowRect(line->lineTop(), l ine->lineBottom());
794 lineTop = std::min(line->lineTopWithLeading(), overflow.y()); 794 lineTop = std::min(line->lineTopWithLeading(), overflow.y());
795 } 795 }
796 return lineBottom - lineTop; 796 return lineBottom - lineTop;
797 } 797 }
798 798
799 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La youtUnit& delta, LayoutFlowThread* flowThread) 799 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La youtUnit& delta, LayoutFlowThread* flowThread)
800 { 800 {
801 // FIXME: For now we paginate using line overflow. This ensures that lines d on't overlap at all when we 801 // FIXME: For now we paginate using line overflow. This ensures that lines d on't overlap at all when we
802 // put a strut between them for pagination purposes. However, this really is n't the desired rendering, since 802 // put a strut between them for pagination purposes. However, this really is n't the desired layout, since
803 // the line on the top of the next page will appear too far down relative to the same kind of line at the top 803 // the line on the top of the next page will appear too far down relative to the same kind of line at the top
804 // of the first column. 804 // of the first column.
805 // 805 //
806 // The rendering we would like to see is one where the lineTopWithLeading is at the top of the column, and any line overflow 806 // The layout we would like to see is one where the lineTopWithLeading is at the top of the column, and any line overflow
807 // simply spills out above the top of the column. This effect would match wh at happens at the top of the first column. 807 // simply spills out above the top of the column. This effect would match wh at happens at the top of the first column.
808 // We can't achieve this rendering, however, until we stop columns from clip ping to the column bounds (thus allowing 808 // We can't achieve this layout, however, until we stop columns from clippin g to the column bounds (thus allowing
809 // for overflow to occur), and then cache visible overflow for each column r ect. 809 // for overflow to occur), and then cache visible overflow for each column r ect.
810 // 810 //
811 // Furthermore, the paint we have to do when a column has overflow has to be special. We need to exclude 811 // Furthermore, the paint we have to do when a column has overflow has to be special. We need to exclude
812 // content that paints in a previous column (and content that paints in the following column). 812 // content that paints in a previous column (and content that paints in the following column).
813 // 813 //
814 // For now we'll at least honor the lineTopWithLeading when paginating if it is above the logical top overflow. This will 814 // For now we'll at least honor the lineTopWithLeading when paginating if it is above the logical top overflow. This will
815 // at least make positive leading work in typical cases. 815 // at least make positive leading work in typical cases.
816 // 816 //
817 // FIXME: Another problem with simply moving lines is that the available lin e width may change (because of floats). 817 // FIXME: Another problem with simply moving lines is that the available lin e width may change (because of floats).
818 // Technically if the location we move the line to has a different line widt h than our old position, then we need to dirty the 818 // Technically if the location we move the line to has a different line widt h than our old position, then we need to dirty the
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 LayoutBlockFlow* parentBlockFlow = this; 1958 LayoutBlockFlow* parentBlockFlow = this;
1959 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1959 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
1960 FloatingObjectSetIterator end = floatingObjectSet.end(); 1960 FloatingObjectSetIterator end = floatingObjectSet.end();
1961 1961
1962 for (LayoutObject* curr = parent(); curr && !curr->isLayoutView(); curr = curr->parent()) { 1962 for (LayoutObject* curr = parent(); curr && !curr->isLayoutView(); curr = curr->parent()) {
1963 if (curr->isLayoutBlockFlow()) { 1963 if (curr->isLayoutBlockFlow()) {
1964 LayoutBlockFlow* currBlock = toLayoutBlockFlow(curr); 1964 LayoutBlockFlow* currBlock = toLayoutBlockFlow(curr);
1965 1965
1966 if (currBlock->hasOverhangingFloats()) { 1966 if (currBlock->hasOverhangingFloats()) {
1967 for (FloatingObjectSetIterator it = floatingObjectSet.begin( ); it != end; ++it) { 1967 for (FloatingObjectSetIterator it = floatingObjectSet.begin( ); it != end; ++it) {
1968 LayoutBox* renderer = (*it)->layoutObject(); 1968 LayoutBox* layoutBox = (*it)->layoutObject();
1969 if (currBlock->hasOverhangingFloat(renderer)) { 1969 if (currBlock->hasOverhangingFloat(layoutBox)) {
1970 parentBlockFlow = currBlock; 1970 parentBlockFlow = currBlock;
1971 break; 1971 break;
1972 } 1972 }
1973 } 1973 }
1974 } 1974 }
1975 } 1975 }
1976 } 1976 }
1977 1977
1978 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); 1978 parentBlockFlow->markAllDescendantsWithFloatsForLayout();
1979 parentBlockFlow->markSiblingsWithFloatsForLayout(); 1979 parentBlockFlow->markSiblingsWithFloatsForLayout();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 return; 2025 return;
2026 } 2026 }
2027 LayoutBlock::addChild(newChild, beforeChild); 2027 LayoutBlock::addChild(newChild, beforeChild);
2028 } 2028 }
2029 2029
2030 void LayoutBlockFlow::moveAllChildrenIncludingFloatsTo(LayoutBlock* toBlock, boo l fullRemoveInsert) 2030 void LayoutBlockFlow::moveAllChildrenIncludingFloatsTo(LayoutBlock* toBlock, boo l fullRemoveInsert)
2031 { 2031 {
2032 LayoutBlockFlow* toBlockFlow = toLayoutBlockFlow(toBlock); 2032 LayoutBlockFlow* toBlockFlow = toLayoutBlockFlow(toBlock);
2033 moveAllChildrenTo(toBlockFlow, fullRemoveInsert); 2033 moveAllChildrenTo(toBlockFlow, fullRemoveInsert);
2034 2034
2035 // When a portion of the render tree is being detached, anonymous blocks 2035 // When a portion of the layout tree is being detached, anonymous blocks
2036 // will be combined as their children are deleted. In this process, the 2036 // will be combined as their children are deleted. In this process, the
2037 // anonymous block later in the tree is merged into the one preceeding it. 2037 // anonymous block later in the tree is merged into the one preceeding it.
2038 // It can happen that the later block (this) contains floats that the 2038 // It can happen that the later block (this) contains floats that the
2039 // previous block (toBlockFlow) did not contain, and thus are not in the 2039 // previous block (toBlockFlow) did not contain, and thus are not in the
2040 // floating objects list for toBlockFlow. This can result in toBlockFlow con taining 2040 // floating objects list for toBlockFlow. This can result in toBlockFlow con taining
2041 // floats that are not in it's floating objects list, but are in the 2041 // floats that are not in it's floating objects list, but are in the
2042 // floating objects lists of siblings and parents. This can cause problems 2042 // floating objects lists of siblings and parents. This can cause problems
2043 // when the float itself is deleted, since the deletion code assumes that 2043 // when the float itself is deleted, since the deletion code assumes that
2044 // if a float is not in it's containing block's floating objects list, it 2044 // if a float is not in it's containing block's floating objects list, it
2045 // isn't in any floating objects list. In order to preserve this condition 2045 // isn't in any floating objects list. In order to preserve this condition
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 FloatingObjectSetIterator end = floatingObjectSet.end(); 2080 FloatingObjectSetIterator end = floatingObjectSet.end();
2081 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { 2081 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) {
2082 FloatingObject* floatingObject = it->get(); 2082 FloatingObject* floatingObject = it->get();
2083 // Only issue paint invaldiations for the object if it is overhanging, i s not in its own layer, and 2083 // Only issue paint invaldiations for the object if it is overhanging, i s not in its own layer, and
2084 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter 2084 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter
2085 // condition is replaced with being a descendant of us. 2085 // condition is replaced with being a descendant of us.
2086 if (logicalBottomForFloat(floatingObject) > logicalHeight() 2086 if (logicalBottomForFloat(floatingObject) > logicalHeight()
2087 && !floatingObject->layoutObject()->hasSelfPaintingLayer() 2087 && !floatingObject->layoutObject()->hasSelfPaintingLayer()
2088 && (floatingObject->shouldPaint() || (paintAllDescendants && floatin gObject->layoutObject()->isDescendantOf(this)))) { 2088 && (floatingObject->shouldPaint() || (paintAllDescendants && floatin gObject->layoutObject()->isDescendantOf(this)))) {
2089 2089
2090 LayoutBox* floatingRenderer = floatingObject->layoutObject(); 2090 LayoutBox* floatingLayoutBox = floatingObject->layoutObject();
2091 floatingRenderer->setShouldDoFullPaintInvalidation(); 2091 floatingLayoutBox->setShouldDoFullPaintInvalidation();
2092 floatingRenderer->invalidatePaintForOverhangingFloats(false); 2092 floatingLayoutBox->invalidatePaintForOverhangingFloats(false);
2093 } 2093 }
2094 } 2094 }
2095 } 2095 }
2096 2096
2097 void LayoutBlockFlow::invalidatePaintForOverflow() 2097 void LayoutBlockFlow::invalidatePaintForOverflow()
2098 { 2098 {
2099 // FIXME: We could tighten up the left and right invalidation points if we l et layoutInlineChildren fill them in based off the particular lines 2099 // FIXME: We could tighten up the left and right invalidation points if we l et layoutInlineChildren fill them in based off the particular lines
2100 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca se either. 2100 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca se either.
2101 LayoutUnit paintInvalidationLogicalLeft = logicalLeftVisualOverflow(); 2101 LayoutUnit paintInvalidationLogicalLeft = logicalLeftVisualOverflow();
2102 LayoutUnit paintInvalidationLogicalRight = logicalRightVisualOverflow(); 2102 LayoutUnit paintInvalidationLogicalRight = logicalRightVisualOverflow();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 break; 2182 break;
2183 case CBOTH: 2183 case CBOTH:
2184 newY = lowestFloatLogicalBottom(); 2184 newY = lowestFloatLogicalBottom();
2185 default: 2185 default:
2186 break; 2186 break;
2187 } 2187 }
2188 if (size().height() < newY) 2188 if (size().height() < newY)
2189 setLogicalHeight(newY); 2189 setLogicalHeight(newY);
2190 } 2190 }
2191 2191
2192 bool LayoutBlockFlow::containsFloat(LayoutBox* renderer) const 2192 bool LayoutBlockFlow::containsFloat(LayoutBox* layoutBox) const
2193 { 2193 {
2194 return m_floatingObjects && m_floatingObjects->set().contains<FloatingObject HashTranslator>(renderer); 2194 return m_floatingObjects && m_floatingObjects->set().contains<FloatingObject HashTranslator>(layoutBox);
2195 } 2195 }
2196 2196
2197 void LayoutBlockFlow::removeFloatingObjects() 2197 void LayoutBlockFlow::removeFloatingObjects()
2198 { 2198 {
2199 if (!m_floatingObjects) 2199 if (!m_floatingObjects)
2200 return; 2200 return;
2201 2201
2202 markSiblingsWithFloatsForLayout(); 2202 markSiblingsWithFloatsForLayout();
2203 2203
2204 m_floatingObjects->clear(); 2204 m_floatingObjects->clear();
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 2500
2501 if (ShapeOutsideInfo* shapeOutside = childBox->shapeOutsideInfo()) 2501 if (ShapeOutsideInfo* shapeOutside = childBox->shapeOutsideInfo())
2502 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(*childB ox)); 2502 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(*childB ox));
2503 2503
2504 if (width) 2504 if (width)
2505 width->shrinkAvailableWidthForNewFloatIfNeeded(floatingObject); 2505 width->shrinkAvailableWidthForNewFloatIfNeeded(floatingObject);
2506 } 2506 }
2507 return true; 2507 return true;
2508 } 2508 }
2509 2509
2510 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* renderer) 2510 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* layoutBox)
2511 { 2511 {
2512 if (!m_floatingObjects || hasColumns() || !parent()) 2512 if (!m_floatingObjects || hasColumns() || !parent())
2513 return false; 2513 return false;
2514 2514
2515 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2515 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2516 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran slator>(renderer); 2516 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran slator>(layoutBox);
2517 if (it == floatingObjectSet.end()) 2517 if (it == floatingObjectSet.end())
2518 return false; 2518 return false;
2519 2519
2520 return logicalBottomForFloat(it->get()) > logicalHeight(); 2520 return logicalBottomForFloat(it->get()) > logicalHeight();
2521 } 2521 }
2522 2522
2523 void LayoutBlockFlow::addIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logic alLeftOffset, LayoutUnit logicalTopOffset) 2523 void LayoutBlockFlow::addIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logic alLeftOffset, LayoutUnit logicalTopOffset)
2524 { 2524 {
2525 ASSERT(!avoidsFloats()); 2525 ASSERT(!avoidsFloats());
2526 2526
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
3160 if (isAnonymousBlock()) 3160 if (isAnonymousBlock())
3161 return "LayoutBlockFlow (anonymous)"; 3161 return "LayoutBlockFlow (anonymous)";
3162 } 3162 }
3163 if (isAnonymous()) 3163 if (isAnonymous())
3164 return "LayoutBlockFlow (anonymous)"; 3164 return "LayoutBlockFlow (anonymous)";
3165 return "LayoutBlockFlow"; 3165 return "LayoutBlockFlow";
3166 } 3166 }
3167 3167
3168 3168
3169 } // namespace blink 3169 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlock.cpp ('k') | Source/core/layout/LayoutBlockFlowLine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698