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

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

Issue 1456813002: Calculate Background Image Geometries using sub-pixel values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit fix and moar ref test corrections. Still no expected results. Created 5 years 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) 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 static double maxImageSizeBytes = 0; 115 static double maxImageSizeBytes = 0;
116 if (!maxImageSizeBytes) { 116 if (!maxImageSizeBytes) {
117 size_t size32MaxBytes = 0xFFFFFFFF / 4; // Some platforms don't limit m axDecodedImageBytes. 117 size_t size32MaxBytes = 0xFFFFFFFF / 4; // Some platforms don't limit m axDecodedImageBytes.
118 maxImageSizeBytes = std::min(size32MaxBytes, Platform::current()->maxDec odedImageBytes()); 118 maxImageSizeBytes = std::min(size32MaxBytes, Platform::current()->maxDec odedImageBytes());
119 } 119 }
120 return (rect.width().toFloat() * rect.height().toFloat() * 4.0) < maxImageSi zeBytes; 120 return (rect.width().toFloat() * rect.height().toFloat() * 4.0) < maxImageSi zeBytes;
121 } 121 }
122 122
123 PassOwnPtr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage, float shapeImageThreshold, WritingMode writingMode, float margin) const 123 PassOwnPtr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage, float shapeImageThreshold, WritingMode writingMode, float margin) const
124 { 124 {
125 const IntSize& imageSize = m_layoutBox.calculateImageIntrinsicDimensions(sty leImage, roundedIntSize(m_referenceBoxLogicalSize), LayoutImage::ScaleByEffectiv eZoom); 125 const LayoutSize& imageSize = m_layoutBox.calculateImageIntrinsicDimensions( styleImage, m_referenceBoxLogicalSize, LayoutImage::ScaleByEffectiveZoom);
126
126 const LayoutRect& marginRect = getShapeImageMarginRect(m_layoutBox, m_refere nceBoxLogicalSize); 127 const LayoutRect& marginRect = getShapeImageMarginRect(m_layoutBox, m_refere nceBoxLogicalSize);
127 const LayoutRect& imageRect = (m_layoutBox.isLayoutImage()) 128 const LayoutRect& imageRect = (m_layoutBox.isLayoutImage())
128 ? toLayoutImage(m_layoutBox).replacedContentRect() 129 ? toLayoutImage(m_layoutBox).replacedContentRect()
129 : LayoutRect(LayoutPoint(), LayoutSize(imageSize)); 130 : LayoutRect(LayoutPoint(), imageSize);
130 131
131 if (!isValidRasterShapeRect(marginRect) || !isValidRasterShapeRect(imageRect )) { 132 if (!isValidRasterShapeRect(marginRect) || !isValidRasterShapeRect(imageRect )) {
132 m_layoutBox.document().addConsoleMessage(ConsoleMessage::create(Renderin gMessageSource, ErrorMessageLevel, "The shape-outside image is too large.")); 133 m_layoutBox.document().addConsoleMessage(ConsoleMessage::create(Renderin gMessageSource, ErrorMessageLevel, "The shape-outside image is too large."));
133 return Shape::createEmptyRasterShape(writingMode, margin); 134 return Shape::createEmptyRasterShape(writingMode, margin);
134 } 135 }
135 136
136 ASSERT(!styleImage->isPendingImage()); 137 ASSERT(!styleImage->isPendingImage());
137 RefPtr<Image> image = styleImage->image(const_cast<LayoutBox*>(&m_layoutBox) , imageSize, m_layoutBox.style()->effectiveZoom()); 138 RefPtr<Image> image = styleImage->image(const_cast<LayoutBox*>(&m_layoutBox) , flooredIntSize(imageSize), m_layoutBox.style()->effectiveZoom());
eae 2015/11/25 00:21:05 Not roundedIntSize as before or pixel snapped?
leviw_travelin_and_unemployed 2015/11/25 00:31:56 Same as other comments.
138 139
139 return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, marginRect, writingMode, margin); 140 return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, marginRect, writingMode, margin);
140 } 141 }
141 142
142 const Shape& ShapeOutsideInfo::computedShape() const 143 const Shape& ShapeOutsideInfo::computedShape() const
143 { 144 {
144 if (Shape* shape = m_shape.get()) 145 if (Shape* shape = m_shape.get())
145 return *shape; 146 return *shape;
146 147
147 TemporaryChange<bool> isInComputingShape(m_isComputingShape, true); 148 TemporaryChange<bool> isInComputingShape(m_isComputingShape, true);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 345 }
345 346
346 FloatSize ShapeOutsideInfo::shapeToLayoutObjectSize(FloatSize size) const 347 FloatSize ShapeOutsideInfo::shapeToLayoutObjectSize(FloatSize size) const
347 { 348 {
348 if (!m_layoutBox.style()->isHorizontalWritingMode()) 349 if (!m_layoutBox.style()->isHorizontalWritingMode())
349 return size.transposedSize(); 350 return size.transposedSize();
350 return size; 351 return size;
351 } 352 }
352 353
353 } // namespace blink 354 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698