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

Side by Side Diff: third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp

Issue 1427943002: Wrap SVGImage for container during paint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use IntSize for SVGImageForContainer Created 5 years, 1 month 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/BackgroundImageGeometry.h" 6 #include "core/paint/BackgroundImageGeometry.h"
7 7
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/layout/LayoutBox.h" 9 #include "core/layout/LayoutBox.h"
10 #include "core/layout/LayoutBoxModelObject.h" 10 #include "core/layout/LayoutBoxModelObject.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 IntPoint alignedPoint = attachmentPoint; 163 IntPoint alignedPoint = attachmentPoint;
164 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), 0), std::max(aligne dPoint.y() - m_destRect.y(), 0)); 164 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), 0), std::max(aligne dPoint.y() - m_destRect.y(), 0));
165 } 165 }
166 166
167 void BackgroundImageGeometry::clip(const IntRect& clipRect) 167 void BackgroundImageGeometry::clip(const IntRect& clipRect)
168 { 168 {
169 m_destRect.intersect(clipRect); 169 m_destRect.intersect(clipRect);
170 } 170 }
171 171
172 void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L ayoutBoxModelObject* paintContainer, 172 void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L ayoutBoxModelObject* paintContainer,
173 const GlobalPaintFlags globalPaintFlags, const FillLayer& fillLayer, const L ayoutRect& paintRect, 173 const GlobalPaintFlags globalPaintFlags, const FillLayer& fillLayer, const L ayoutRect& paintRect)
174 const LayoutObject* backgroundObject)
175 { 174 {
176 LayoutUnit left = 0; 175 LayoutUnit left = 0;
177 LayoutUnit top = 0; 176 LayoutUnit top = 0;
178 IntSize positioningAreaSize; 177 IntSize positioningAreaSize;
179 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); 178 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect);
180 bool isLayoutView = obj.isLayoutView(); 179 bool isLayoutView = obj.isLayoutView();
181 const LayoutBox* rootBox = nullptr; 180 const LayoutBox* rootBox = nullptr;
182 if (isLayoutView) { 181 if (isLayoutView) {
183 // It is only possible reach here when root element has a box. 182 // It is only possible reach here when root element has a box.
184 Element* documentElement = obj.document().documentElement(); 183 Element* documentElement = obj.document().documentElement();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 249
251 if (paintContainer) { 250 if (paintContainer) {
252 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint())); 251 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint()));
253 viewportRect.moveBy(-absoluteContainerOffset); 252 viewportRect.moveBy(-absoluteContainerOffset);
254 } 253 }
255 254
256 setDestRect(viewportRect); 255 setDestRect(viewportRect);
257 positioningAreaSize = destRect().size(); 256 positioningAreaSize = destRect().size();
258 } 257 }
259 258
260 const LayoutObject* clientForBackgroundImage = backgroundObject ? background Object : &obj;
261 IntSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, posi tioningAreaSize); 259 IntSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, posi tioningAreaSize);
262 fillLayer.image()->setContainerSizeForLayoutObject(clientForBackgroundImage, fillTileSize, obj.style()->effectiveZoom());
263 setTileSize(fillTileSize); 260 setTileSize(fillTileSize);
261 setImageContainerSize(fillTileSize);
264 262
265 EFillRepeat backgroundRepeatX = fillLayer.repeatX(); 263 EFillRepeat backgroundRepeatX = fillLayer.repeatX();
266 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); 264 EFillRepeat backgroundRepeatY = fillLayer.repeatY();
267 int availableWidth = positioningAreaSize.width() - tileSize().width(); 265 int availableWidth = positioningAreaSize.width() - tileSize().width();
268 int availableHeight = positioningAreaSize.height() - tileSize().height(); 266 int availableHeight = positioningAreaSize.height() - tileSize().height();
269 267
270 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit ion(), availableWidth); 268 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit ion(), availableWidth);
271 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil lTileSize.width() > 0) { 269 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil lTileSize.width() > 0) {
272 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.width() / fillTileSize.width())); 270 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.width() / fillTileSize.width()));
273 271
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 setSpaceSize(IntSize(spaceSize().width(), 0)); 343 setSpaceSize(IntSize(spaceSize().width(), 0));
346 } 344 }
347 345
348 if (fixedAttachment) 346 if (fixedAttachment)
349 useFixedAttachment(snappedPaintRect.location()); 347 useFixedAttachment(snappedPaintRect.location());
350 348
351 clip(snappedPaintRect); 349 clip(snappedPaintRect);
352 } 350 }
353 351
354 } // namespace blink 352 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BackgroundImageGeometry.h ('k') | third_party/WebKit/Source/core/paint/BoxPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698