15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met:
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    copyright notice, this list of conditions and the following
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    disclaimer.
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    copyright notice, this list of conditions and the following
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    disclaimer in the documentation and/or other materials
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    provided with the distribution.
1553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) *
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THE POSSIBILITY OF SUCH DAMAGE.
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
30591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#ifndef RectangleShape_h
31591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#define RectangleShape_h
325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
33591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "core/rendering/shapes/Shape.h"
341e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/FloatPoint.h"
351e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/FloatRect.h"
361e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/FloatSize.h"
37591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "wtf/Assertions.h"
385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
39c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
4109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class RectangleShape FINAL : public Shape {
425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public:
43591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    RectangleShape(const FloatRect& bounds, const FloatSize& radii)
44591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch        : Shape()
4509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        , m_bounds(bounds)
4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        , m_radii(radii)
475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    {
485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
5081a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)    virtual LayoutRect shapeMarginLogicalBoundingBox() const OVERRIDE { return static_cast<LayoutRect>(shapeMarginBounds()); }
51926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual bool isEmpty() const OVERRIDE { return m_bounds.isEmpty(); }
52e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const OVERRIDE;
53323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    virtual void buildDisplayPaths(DisplayPaths&) const OVERRIDE;
54926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
5581a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)private:
5609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    FloatRect shapeMarginBounds() const;
5751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
5809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    float rx() const { return m_radii.width(); }
5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    float ry() const { return m_radii.height(); }
6009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    float x() const { return m_bounds.x(); }
6109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    float y() const { return m_bounds.y(); }
6209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    float width() const { return m_bounds.width(); }
6309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    float height() const { return m_bounds.height(); }
6451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
6509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    FloatRect m_bounds;
6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    FloatSize m_radii;
675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)};
685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
69c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
71591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#endif // RectangleShape_h
72