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 29using namespace std; 30 31namespace WebCore { 32 33using namespace HTMLNames; 34 35RenderMeter::RenderMeter(HTMLElement* element) 36 : RenderBlock(element) 37{ 38} 39 40RenderMeter::~RenderMeter() 41{ 42} 43 44HTMLMeterElement* RenderMeter::meterElement() const 45{ 46 ASSERT(node()); 47 48 if (isHTMLMeterElement(node())) 49 return toHTMLMeterElement(node()); 50 51 ASSERT(node()->shadowHost()); 52 return toHTMLMeterElement(node()->shadowHost()); 53} 54 55void RenderMeter::updateLogicalWidth() 56{ 57 RenderBox::updateLogicalWidth(); 58 59 IntSize frameSize = theme()->meterSizeForBounds(this, pixelSnappedIntRect(frameRect())); 60 setLogicalWidth(isHorizontalWritingMode() ? frameSize.width() : frameSize.height()); 61} 62 63void RenderMeter::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const 64{ 65 RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); 66 67 LayoutRect frame = frameRect(); 68 if (isHorizontalWritingMode()) 69 frame.setHeight(computedValues.m_extent); 70 else 71 frame.setWidth(computedValues.m_extent); 72 IntSize frameSize = theme()->meterSizeForBounds(this, pixelSnappedIntRect(frame)); 73 computedValues.m_extent = isHorizontalWritingMode() ? frameSize.height() : frameSize.width(); 74} 75 76void RenderMeter::updateFromElement() 77{ 78 repaint(); 79} 80 81} // namespace WebCore 82 83#endif 84