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
3 // found in the LICENSE file.
6 #include "core/paint/BackgroundImageGeometry.h"
10 void BackgroundImageGeometry::setNoRepeatX(int xOffset)
12 m_destRect.move(std::max(xOffset, 0), 0);
13 m_phase.setX(-std::min(xOffset, 0));
14 m_destRect.setWidth(m_tileSize.width() + std::min(xOffset, 0));
16 void BackgroundImageGeometry::setNoRepeatY(int yOffset)
18 m_destRect.move(0, std::max(yOffset, 0));
19 m_phase.setY(-std::min(yOffset, 0));
20 m_destRect.setHeight(m_tileSize.height() + std::min(yOffset, 0));
23 void BackgroundImageGeometry::useFixedAttachment(const IntPoint& attachmentPoint)
25 IntPoint alignedPoint = attachmentPoint;
26 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), 0), std::max(alignedPoint.y() - m_destRect.y(), 0));
29 void BackgroundImageGeometry::clip(const IntRect& clipRect)
31 m_destRect.intersect(clipRect);
34 IntPoint BackgroundImageGeometry::relativePhase() const
36 IntPoint phase = m_phase;
37 phase += m_destRect.location() - m_destOrigin;