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

Side by Side Diff: Source/WebCore/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: Created 7 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
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 computeAvailableWidthFromLeftAndRight(); 175 computeAvailableWidthFromLeftAndRight();
176 } 176 }
177 177
178 inline void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(RenderBlock::Floa tingObject* newFloat) 178 inline void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(RenderBlock::Floa tingObject* newFloat)
179 { 179 {
180 LayoutUnit height = m_block->logicalHeight(); 180 LayoutUnit height = m_block->logicalHeight();
181 if (height < m_block->logicalTopForFloat(newFloat) || height >= m_block->log icalBottomForFloat(newFloat)) 181 if (height < m_block->logicalTopForFloat(newFloat) || height >= m_block->log icalBottomForFloat(newFloat))
182 return; 182 return;
183 183
184 #if ENABLE(CSS_EXCLUSIONS) 184 #if ENABLE(CSS_EXCLUSIONS)
185 // When floats with shape outside are stacked, the floats are positioned bas ed on the bounding box of the shape,
186 // not the shape's contour. Since we computed the width based on the shape c ontour when we added the float,
187 // when we add a subsequent float on the same line, we need to undo the shap e delta in order to position
188 // based on the bounding box. In order to do this, we need to walk back thro ugh the floating object list to find
189 // the first previous float that is on the same side as our newFloat.
190 ExclusionShapeOutsideInfo* lastShapeOutsideInfo = 0;
191 const RenderBlock::FloatingObjectSet& floatingObjectSet = m_block->m_floatin gObjects->set();
192 RenderBlock::FloatingObjectSetIterator it = floatingObjectSet.end();
193 RenderBlock::FloatingObjectSetIterator begin = floatingObjectSet.begin();
194 for (--it; it != begin; --it) {
Julien - ping for review 2013/04/10 21:33:59 Won't this loop ignore the first float if it is yo
195 RenderBlock::FloatingObject* lastFloat = *it;
196 if (lastFloat != newFloat && lastFloat->type() == newFloat->type()) {
197 lastShapeOutsideInfo = lastFloat->renderer()->exclusionShapeOutsideI nfo();
198 if (lastShapeOutsideInfo)
199 lastShapeOutsideInfo->computeSegmentsForLine(m_block->logicalHei ght() - m_block->logicalTopForFloat(lastFloat) + lastShapeOutsideInfo->shapeLogi calTop(), logicalHeightForLine(m_block, m_isFirstLine));
200 break;
201 }
202 }
203
185 ExclusionShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->exclusio nShapeOutsideInfo(); 204 ExclusionShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->exclusio nShapeOutsideInfo();
186 if (shapeOutsideInfo) 205 if (shapeOutsideInfo)
187 shapeOutsideInfo->computeSegmentsForLine(m_block->logicalHeight() - m_bl ock->logicalTopForFloat(newFloat) + shapeOutsideInfo->shapeLogicalTop(), logical HeightForLine(m_block, m_isFirstLine)); 206 shapeOutsideInfo->computeSegmentsForLine(m_block->logicalHeight() - m_bl ock->logicalTopForFloat(newFloat) + shapeOutsideInfo->shapeLogicalTop(), logical HeightForLine(m_block, m_isFirstLine));
188 #endif 207 #endif
189 208
190 if (newFloat->type() == RenderBlock::FloatingObject::FloatLeft) { 209 if (newFloat->type() == RenderBlock::FloatingObject::FloatLeft) {
191 float newLeft = m_block->logicalRightForFloat(newFloat); 210 float newLeft = m_block->logicalRightForFloat(newFloat);
192 #if ENABLE(CSS_EXCLUSIONS) 211 #if ENABLE(CSS_EXCLUSIONS)
212 if (lastShapeOutsideInfo)
213 newLeft -= lastShapeOutsideInfo->rightSegmentShapeBoundingBoxDelta() ;
193 if (shapeOutsideInfo) 214 if (shapeOutsideInfo)
194 newLeft += shapeOutsideInfo->rightSegmentShapeBoundingBoxDelta(); 215 newLeft += shapeOutsideInfo->rightSegmentShapeBoundingBoxDelta();
195 #endif 216 #endif
196 217
197 if (shouldIndentText() && m_block->style()->isLeftToRightDirection()) 218 if (shouldIndentText() && m_block->style()->isLeftToRightDirection())
198 newLeft += floorToInt(m_block->textIndentOffset()); 219 newLeft += floorToInt(m_block->textIndentOffset());
199 m_left = max<float>(m_left, newLeft); 220 m_left = max<float>(m_left, newLeft);
200 } else { 221 } else {
201 float newRight = m_block->logicalLeftForFloat(newFloat); 222 float newRight = m_block->logicalLeftForFloat(newFloat);
202 #if ENABLE(CSS_EXCLUSIONS) 223 #if ENABLE(CSS_EXCLUSIONS)
224 if (lastShapeOutsideInfo)
225 newRight -= lastShapeOutsideInfo->leftSegmentShapeBoundingBoxDelta() ;
203 if (shapeOutsideInfo) 226 if (shapeOutsideInfo)
204 newRight += shapeOutsideInfo->leftSegmentShapeBoundingBoxDelta(); 227 newRight += shapeOutsideInfo->leftSegmentShapeBoundingBoxDelta();
205 #endif 228 #endif
206 229
207 if (shouldIndentText() && !m_block->style()->isLeftToRightDirection()) 230 if (shouldIndentText() && !m_block->style()->isLeftToRightDirection())
208 newRight -= floorToInt(m_block->textIndentOffset()); 231 newRight -= floorToInt(m_block->textIndentOffset());
209 m_right = min<float>(m_right, newRight); 232 m_right = min<float>(m_right, newRight);
210 } 233 }
211 234
212 computeAvailableWidthFromLeftAndRight(); 235 computeAvailableWidthFromLeftAndRight();
(...skipping 3204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3417 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 3440 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
3418 3441
3419 setLineGridBox(lineGridBox); 3442 setLineGridBox(lineGridBox);
3420 3443
3421 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 3444 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
3422 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 3445 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
3423 // to this grid. 3446 // to this grid.
3424 } 3447 }
3425 3448
3426 } 3449 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698