1/* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 * 19 */ 20 21#include "config.h" 22#if ENABLE(METER_ELEMENT) 23#include "RenderMeter.h" 24 25#include "HTMLMeterElement.h" 26#include "HTMLNames.h" 27#include "RenderTheme.h" 28 29namespace WebCore { 30 31using namespace HTMLNames; 32 33RenderMeter::RenderMeter(HTMLElement& element, PassRef<RenderStyle> style) 34 : RenderBlockFlow(element, WTF::move(style)) 35{ 36} 37 38RenderMeter::~RenderMeter() 39{ 40} 41 42HTMLMeterElement* RenderMeter::meterElement() const 43{ 44 ASSERT(element()); 45 46 if (isHTMLMeterElement(element())) 47 return toHTMLMeterElement(element()); 48 49 ASSERT(element()->shadowHost()); 50 return toHTMLMeterElement(element()->shadowHost()); 51} 52 53void RenderMeter::updateLogicalWidth() 54{ 55 RenderBox::updateLogicalWidth(); 56 57 IntSize frameSize = theme().meterSizeForBounds(*this, pixelSnappedIntRect(frameRect())); 58 setLogicalWidth(isHorizontalWritingMode() ? frameSize.width() : frameSize.height()); 59} 60 61void RenderMeter::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const 62{ 63 RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); 64 65 LayoutRect frame = frameRect(); 66 if (isHorizontalWritingMode()) 67 frame.setHeight(computedValues.m_extent); 68 else 69 frame.setWidth(computedValues.m_extent); 70 IntSize frameSize = theme().meterSizeForBounds(*this, pixelSnappedIntRect(frame)); 71 computedValues.m_extent = isHorizontalWritingMode() ? frameSize.height() : frameSize.width(); 72} 73 74void RenderMeter::updateFromElement() 75{ 76 repaint(); 77} 78 79} // namespace WebCore 80 81#endif 82