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

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

Issue 13909006: Merge patch for stacked floats with shape-outside from WebKit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase just to make sure it will submit cleanly Created 7 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
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | no next file » | 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) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 computeAvailableWidthFromLeftAndRight(); 155 computeAvailableWidthFromLeftAndRight();
156 } 156 }
157 157
158 inline void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(RenderBlock::Floa tingObject* newFloat) 158 inline void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(RenderBlock::Floa tingObject* newFloat)
159 { 159 {
160 LayoutUnit height = m_block->logicalHeight(); 160 LayoutUnit height = m_block->logicalHeight();
161 if (height < m_block->logicalTopForFloat(newFloat) || height >= m_block->log icalBottomForFloat(newFloat)) 161 if (height < m_block->logicalTopForFloat(newFloat) || height >= m_block->log icalBottomForFloat(newFloat))
162 return; 162 return;
163 163
164 // When floats with shape outside are stacked, the floats are positioned bas ed on the bounding box of the shape,
165 // not the shape's contour. Since we computed the width based on the shape c ontour when we added the float,
166 // when we add a subsequent float on the same line, we need to undo the shap e delta in order to position
167 // based on the bounding box. In order to do this, we need to walk back thro ugh the floating object list to find
168 // the first previous float that is on the same side as our newFloat.
169 ShapeOutsideInfo* previousShapeOutsideInfo = 0;
170 const RenderBlock::FloatingObjectSet& floatingObjectSet = m_block->m_floatin gObjects->set();
171 RenderBlock::FloatingObjectSetIterator it = floatingObjectSet.end();
172 RenderBlock::FloatingObjectSetIterator begin = floatingObjectSet.begin();
173 while (it != begin) {
174 --it;
175 RenderBlock::FloatingObject* previousFloat = *it;
176 if (previousFloat != newFloat && previousFloat->type() == newFloat->type ()) {
177 previousShapeOutsideInfo = previousFloat->renderer()->shapeOutsideIn fo();
178 if (previousShapeOutsideInfo) {
179 LayoutUnit lineTopInShapeCoordinates = m_block->logicalHeight() - m_block->logicalTopForFloat(previousFloat) + previousShapeOutsideInfo->shapeLo gicalTop();
180 previousShapeOutsideInfo->computeSegmentsForLine(lineTopInShapeC oordinates, logicalHeightForLine(m_block, m_isFirstLine));
181 }
182 break;
183 }
184 }
185
164 ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo( ); 186 ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo( );
165 if (shapeOutsideInfo) 187 if (shapeOutsideInfo)
166 shapeOutsideInfo->computeSegmentsForLine(m_block->logicalHeight() - m_bl ock->logicalTopForFloat(newFloat) + shapeOutsideInfo->shapeLogicalTop(), logical HeightForLine(m_block, m_isFirstLine)); 188 shapeOutsideInfo->computeSegmentsForLine(m_block->logicalHeight() - m_bl ock->logicalTopForFloat(newFloat) + shapeOutsideInfo->shapeLogicalTop(), logical HeightForLine(m_block, m_isFirstLine));
167 189
168 if (newFloat->type() == RenderBlock::FloatingObject::FloatLeft) { 190 if (newFloat->type() == RenderBlock::FloatingObject::FloatLeft) {
169 float newLeft = m_block->logicalRightForFloat(newFloat); 191 float newLeft = m_block->logicalRightForFloat(newFloat);
192 if (previousShapeOutsideInfo)
193 newLeft -= previousShapeOutsideInfo->rightSegmentShapeBoundingBoxDel ta();
170 if (shapeOutsideInfo) 194 if (shapeOutsideInfo)
171 newLeft += shapeOutsideInfo->rightSegmentShapeBoundingBoxDelta(); 195 newLeft += shapeOutsideInfo->rightSegmentShapeBoundingBoxDelta();
172 196
173 if (shouldIndentText() && m_block->style()->isLeftToRightDirection()) 197 if (shouldIndentText() && m_block->style()->isLeftToRightDirection())
174 newLeft += floorToInt(m_block->textIndentOffset()); 198 newLeft += floorToInt(m_block->textIndentOffset());
175 m_left = max<float>(m_left, newLeft); 199 m_left = max<float>(m_left, newLeft);
176 } else { 200 } else {
177 float newRight = m_block->logicalLeftForFloat(newFloat); 201 float newRight = m_block->logicalLeftForFloat(newFloat);
202 if (previousShapeOutsideInfo)
203 newRight -= previousShapeOutsideInfo->leftSegmentShapeBoundingBoxDel ta();
178 if (shapeOutsideInfo) 204 if (shapeOutsideInfo)
179 newRight += shapeOutsideInfo->leftSegmentShapeBoundingBoxDelta(); 205 newRight += shapeOutsideInfo->leftSegmentShapeBoundingBoxDelta();
180 206
181 if (shouldIndentText() && !m_block->style()->isLeftToRightDirection()) 207 if (shouldIndentText() && !m_block->style()->isLeftToRightDirection())
182 newRight -= floorToInt(m_block->textIndentOffset()); 208 newRight -= floorToInt(m_block->textIndentOffset());
183 m_right = min<float>(m_right, newRight); 209 m_right = min<float>(m_right, newRight);
184 } 210 }
185 211
186 computeAvailableWidthFromLeftAndRight(); 212 computeAvailableWidthFromLeftAndRight();
187 } 213 }
(...skipping 3214 matching lines...) Expand 10 before | Expand all | Expand 10 after
3402 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 3428 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
3403 3429
3404 setLineGridBox(lineGridBox); 3430 setLineGridBox(lineGridBox);
3405 3431
3406 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 3432 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
3407 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 3433 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
3408 // to this grid. 3434 // to this grid.
3409 } 3435 }
3410 3436
3411 } 3437 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698