15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2008 Apple Inc. 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) * 1. Redistributions of source code must retain the above copyright 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer in the 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * documentation and/or other materials provided with the distribution. 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2302772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef RenderScrollbarPart_h 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define RenderScrollbarPart_h 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/rendering/RenderBlock.h" 301e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/scroll/ScrollTypes.h" 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 32c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class RenderScrollbar; 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class RenderScrollbarPart FINAL : public RenderBlock { 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public: 38926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) static RenderScrollbarPart* createAnonymous(Document*, RenderScrollbar* = 0, ScrollbarPart = NoPart); 3902772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual ~RenderScrollbarPart(); 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual const char* renderName() const OVERRIDE { return "RenderScrollbarPart"; } 4302772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 4409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual LayerType layerTypeRequired() const OVERRIDE { return NoLayer; } 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void layout() OVERRIDE; 4702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void paintIntoRect(GraphicsContext*, const LayoutPoint&, const LayoutRect&); 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Scrollbar parts needs to be rendered at device pixel boundaries. 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual LayoutUnit marginTop() const OVERRIDE { ASSERT(isIntegerValue(m_marginBox.top())); return m_marginBox.top(); } 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual LayoutUnit marginBottom() const OVERRIDE { ASSERT(isIntegerValue(m_marginBox.bottom())); return m_marginBox.bottom(); } 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual LayoutUnit marginLeft() const OVERRIDE { ASSERT(isIntegerValue(m_marginBox.left())); return m_marginBox.left(); } 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual LayoutUnit marginRight() const OVERRIDE { ASSERT(isIntegerValue(m_marginBox.right())); return m_marginBox.right(); } 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual bool isRenderScrollbarPart() const OVERRIDE { return true; } 575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) RenderObject* rendererOwningScrollbar() const; 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)protected: 60aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle) OVERRIDE; 6109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE; 6209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE; 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private: 65926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) RenderScrollbarPart(RenderScrollbar*, ScrollbarPart); 66926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 6709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void computePreferredLogicalWidths() OVERRIDE; 68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 69d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Have all padding getters return 0. The important point here is to avoid resolving percents 70d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // against the containing block, since scroll bar corners don't always have one (so it would 71d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // crash). Scroll bar corners are not actually laid out, and they don't have child content, so 72d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // what we return here doesn't really matter. 73d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual LayoutUnit paddingTop() const OVERRIDE { return LayoutUnit(); } 74d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual LayoutUnit paddingBottom() const OVERRIDE { return LayoutUnit(); } 75d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual LayoutUnit paddingLeft() const OVERRIDE { return LayoutUnit(); } 76d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual LayoutUnit paddingRight() const OVERRIDE { return LayoutUnit(); } 77d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual LayoutUnit paddingBefore() const OVERRIDE { return LayoutUnit(); } 78d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual LayoutUnit paddingAfter() const OVERRIDE { return LayoutUnit(); } 79d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual LayoutUnit paddingStart() const OVERRIDE { return LayoutUnit(); } 80d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual LayoutUnit paddingEnd() const OVERRIDE { return LayoutUnit(); } 818abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) 825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void layoutHorizontalPart(); 835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void layoutVerticalPart(); 845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void computeScrollbarWidth(); 865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void computeScrollbarHeight(); 8702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) RenderScrollbar* m_scrollbar; 895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ScrollbarPart m_part; 905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 92bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderScrollbarPart, isRenderScrollbarPart()); 935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 94c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // RenderScrollbarPart_h 97