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

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: Update for review comments Created 7 years, 7 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
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 computeAvailableWidthFromLeftAndRight(); 161 computeAvailableWidthFromLeftAndRight();
162 } 162 }
163 163
164 inline void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(RenderBlock::Floa tingObject* newFloat) 164 inline void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(RenderBlock::Floa tingObject* newFloat)
165 { 165 {
166 LayoutUnit height = m_block->logicalHeight(); 166 LayoutUnit height = m_block->logicalHeight();
167 if (height < m_block->logicalTopForFloat(newFloat) || height >= m_block->log icalBottomForFloat(newFloat)) 167 if (height < m_block->logicalTopForFloat(newFloat) || height >= m_block->log icalBottomForFloat(newFloat))
168 return; 168 return;
169 169
170 // When floats with shape outside are stacked, the floats are positioned bas ed on the bounding box of the shape,
171 // not the shape's contour. Since we computed the width based on the shape c ontour when we added the float,
172 // when we add a subsequent float on the same line, we need to undo the shap e delta in order to position
173 // based on the bounding box. In order to do this, we need to walk back thro ugh the floating object list to find
174 // the first previous float that is on the same side as our newFloat.
175 ExclusionShapeOutsideInfo* previousShapeOutsideInfo = 0;
176 const RenderBlock::FloatingObjectSet& floatingObjectSet = m_block->m_floatin gObjects->set();
177 RenderBlock::FloatingObjectSetIterator it = floatingObjectSet.end();
178 RenderBlock::FloatingObjectSetIterator begin = floatingObjectSet.begin();
179 while (it != begin) {
180 --it;
181 RenderBlock::FloatingObject* previousFloat = *it;
182 if (previousFloat != newFloat && previousFloat->type() == newFloat->type ()) {
183 previousShapeOutsideInfo = previousFloat->renderer()->exclusionShape OutsideInfo();
184 if (previousShapeOutsideInfo) {
185 LayoutUnit lineTopInShapeCoordinates = m_block->logicalHeight() - m_block->logicalTopForFloat(previousFloat) + previousShapeOutsideInfo->shapeLo gicalTop();
186 previousShapeOutsideInfo->computeSegmentsForLine(lineTopInShapeC oordinates, logicalHeightForLine(m_block, m_isFirstLine));
187 }
188 break;
189 }
190 }
191
170 ExclusionShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->exclusio nShapeOutsideInfo(); 192 ExclusionShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->exclusio nShapeOutsideInfo();
171 if (shapeOutsideInfo) 193 if (shapeOutsideInfo)
172 shapeOutsideInfo->computeSegmentsForLine(m_block->logicalHeight() - m_bl ock->logicalTopForFloat(newFloat) + shapeOutsideInfo->shapeLogicalTop(), logical HeightForLine(m_block, m_isFirstLine)); 194 shapeOutsideInfo->computeSegmentsForLine(m_block->logicalHeight() - m_bl ock->logicalTopForFloat(newFloat) + shapeOutsideInfo->shapeLogicalTop(), logical HeightForLine(m_block, m_isFirstLine));
173 195
174 if (newFloat->type() == RenderBlock::FloatingObject::FloatLeft) { 196 if (newFloat->type() == RenderBlock::FloatingObject::FloatLeft) {
175 float newLeft = m_block->logicalRightForFloat(newFloat); 197 float newLeft = m_block->logicalRightForFloat(newFloat);
198 if (previousShapeOutsideInfo)
199 newLeft -= previousShapeOutsideInfo->rightSegmentShapeBoundingBoxDel ta();
176 if (shapeOutsideInfo) 200 if (shapeOutsideInfo)
177 newLeft += shapeOutsideInfo->rightSegmentShapeBoundingBoxDelta(); 201 newLeft += shapeOutsideInfo->rightSegmentShapeBoundingBoxDelta();
178 202
179 if (shouldIndentText() && m_block->style()->isLeftToRightDirection()) 203 if (shouldIndentText() && m_block->style()->isLeftToRightDirection())
180 newLeft += floorToInt(m_block->textIndentOffset()); 204 newLeft += floorToInt(m_block->textIndentOffset());
181 m_left = max<float>(m_left, newLeft); 205 m_left = max<float>(m_left, newLeft);
182 } else { 206 } else {
183 float newRight = m_block->logicalLeftForFloat(newFloat); 207 float newRight = m_block->logicalLeftForFloat(newFloat);
208 if (previousShapeOutsideInfo)
209 newRight -= previousShapeOutsideInfo->leftSegmentShapeBoundingBoxDel ta();
184 if (shapeOutsideInfo) 210 if (shapeOutsideInfo)
185 newRight += shapeOutsideInfo->leftSegmentShapeBoundingBoxDelta(); 211 newRight += shapeOutsideInfo->leftSegmentShapeBoundingBoxDelta();
186 212
187 if (shouldIndentText() && !m_block->style()->isLeftToRightDirection()) 213 if (shouldIndentText() && !m_block->style()->isLeftToRightDirection())
188 newRight -= floorToInt(m_block->textIndentOffset()); 214 newRight -= floorToInt(m_block->textIndentOffset());
189 m_right = min<float>(m_right, newRight); 215 m_right = min<float>(m_right, newRight);
190 } 216 }
191 217
192 computeAvailableWidthFromLeftAndRight(); 218 computeAvailableWidthFromLeftAndRight();
193 } 219 }
(...skipping 3177 matching lines...) Expand 10 before | Expand all | Expand 10 after
3371 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 3397 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
3372 3398
3373 setLineGridBox(lineGridBox); 3399 setLineGridBox(lineGridBox);
3374 3400
3375 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 3401 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
3376 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 3402 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
3377 // to this grid. 3403 // to this grid.
3378 } 3404 }
3379 3405
3380 } 3406 }
OLDNEW
« Source/core/rendering/RenderBlock.cpp ('K') | « Source/core/rendering/RenderBlock.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698