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

Side by Side Diff: Source/core/layout/shapes/ShapeOutsideInfo.cpp

Issue 1008893002: [CSS Shapes] Normalize margin box size (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use std::max instead of clamp Created 5 years, 9 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 | « LayoutTests/fast/shapes/shape-outside-floats/shape-outside-floats-ellipse-negative-margins-expected.txt ('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) 2012 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012 Adobe Systems Incorporated. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (isHorizontalWritingMode) 69 if (isHorizontalWritingMode)
70 newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingWidth() , m_renderer.borderAndPaddingHeight()); 70 newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingWidth() , m_renderer.borderAndPaddingHeight());
71 else 71 else
72 newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingHeight( ), m_renderer.borderAndPaddingWidth()); 72 newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingHeight( ), m_renderer.borderAndPaddingWidth());
73 break; 73 break;
74 case BoxMissing: 74 case BoxMissing:
75 ASSERT_NOT_REACHED(); 75 ASSERT_NOT_REACHED();
76 break; 76 break;
77 } 77 }
78 78
79 newReferenceBoxLogicalSize.clampNegativeToZero();
80
79 if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize) 81 if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize)
80 return; 82 return;
81 markShapeAsDirty(); 83 markShapeAsDirty();
82 m_referenceBoxLogicalSize = newReferenceBoxLogicalSize; 84 m_referenceBoxLogicalSize = newReferenceBoxLogicalSize;
83 } 85 }
84 86
85 static bool checkShapeImageOrigin(Document& document, const StyleImage& styleIma ge) 87 static bool checkShapeImageOrigin(Document& document, const StyleImage& styleIma ge)
86 { 88 {
87 if (styleImage.isGeneratedImage()) 89 if (styleImage.isGeneratedImage())
88 return true; 90 return true;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 282 }
281 ShapeOutsideDeltas ShapeOutsideInfo::computeDeltasForContainingBlockLine(const L ayoutBlockFlow& containingBlock, const FloatingObject& floatingObject, LayoutUni t lineTop, LayoutUnit lineHeight) 283 ShapeOutsideDeltas ShapeOutsideInfo::computeDeltasForContainingBlockLine(const L ayoutBlockFlow& containingBlock, const FloatingObject& floatingObject, LayoutUni t lineTop, LayoutUnit lineHeight)
282 { 284 {
283 ASSERT(lineHeight >= 0); 285 ASSERT(lineHeight >= 0);
284 286
285 LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(&floatingObject ) + containingBlock.marginBeforeForChild(m_renderer); 287 LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(&floatingObject ) + containingBlock.marginBeforeForChild(m_renderer);
286 LayoutUnit borderBoxLineTop = lineTop - borderBoxTop; 288 LayoutUnit borderBoxLineTop = lineTop - borderBoxTop;
287 289
288 if (isShapeDirty() || !m_shapeOutsideDeltas.isForLine(borderBoxLineTop, line Height)) { 290 if (isShapeDirty() || !m_shapeOutsideDeltas.isForLine(borderBoxLineTop, line Height)) {
289 LayoutUnit referenceBoxLineTop = borderBoxLineTop - logicalTopOffset(); 291 LayoutUnit referenceBoxLineTop = borderBoxLineTop - logicalTopOffset();
290 LayoutUnit floatMarginBoxWidth = containingBlock.logicalWidthForFloat(&f loatingObject); 292 LayoutUnit floatMarginBoxWidth = std::max(containingBlock.logicalWidthFo rFloat(&floatingObject), LayoutUnit());
291 293
292 if (computedShape().lineOverlapsShapeMarginBounds(referenceBoxLineTop, l ineHeight)) { 294 if (computedShape().lineOverlapsShapeMarginBounds(referenceBoxLineTop, l ineHeight)) {
293 LineSegment segment = computedShape().getExcludedInterval((borderBox LineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - borde rBoxLineTop)); 295 LineSegment segment = computedShape().getExcludedInterval((borderBox LineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - borde rBoxLineTop));
294 if (segment.isValid) { 296 if (segment.isValid) {
295 LayoutUnit logicalLeftMargin = containingBlock.style()->isLeftTo RightDirection() ? containingBlock.marginStartForChild(m_renderer) : containingB lock.marginEndForChild(m_renderer); 297 LayoutUnit logicalLeftMargin = containingBlock.style()->isLeftTo RightDirection() ? containingBlock.marginStartForChild(m_renderer) : containingB lock.marginEndForChild(m_renderer);
296 LayoutUnit rawLeftMarginBoxDelta = segment.logicalLeft + logical LeftOffset() + logicalLeftMargin; 298 LayoutUnit rawLeftMarginBoxDelta = segment.logicalLeft + logical LeftOffset() + logicalLeftMargin;
297 LayoutUnit leftMarginBoxDelta = clampTo<LayoutUnit>(rawLeftMargi nBoxDelta, LayoutUnit(), floatMarginBoxWidth); 299 LayoutUnit leftMarginBoxDelta = clampTo<LayoutUnit>(rawLeftMargi nBoxDelta, LayoutUnit(), floatMarginBoxWidth);
298 300
299 LayoutUnit logicalRightMargin = containingBlock.style()->isLeftT oRightDirection() ? containingBlock.marginEndForChild(m_renderer) : containingBl ock.marginStartForChild(m_renderer); 301 LayoutUnit logicalRightMargin = containingBlock.style()->isLeftT oRightDirection() ? containingBlock.marginEndForChild(m_renderer) : containingBl ock.marginStartForChild(m_renderer);
300 LayoutUnit rawRightMarginBoxDelta = segment.logicalRight + logic alLeftOffset() - containingBlock.logicalWidthForChild(m_renderer) - logicalRight Margin; 302 LayoutUnit rawRightMarginBoxDelta = segment.logicalRight + logic alLeftOffset() - containingBlock.logicalWidthForChild(m_renderer) - logicalRight Margin;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 345 }
344 346
345 FloatSize ShapeOutsideInfo::shapeToRendererSize(FloatSize size) const 347 FloatSize ShapeOutsideInfo::shapeToRendererSize(FloatSize size) const
346 { 348 {
347 if (!m_renderer.style()->isHorizontalWritingMode()) 349 if (!m_renderer.style()->isHorizontalWritingMode())
348 return size.transposedSize(); 350 return size.transposedSize();
349 return size; 351 return size;
350 } 352 }
351 353
352 } // namespace blink 354 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/shapes/shape-outside-floats/shape-outside-floats-ellipse-negative-margins-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698