yael.aharon@nokia.com | 666f4b8 | 2010-05-15 16:41:06 +0000 | [diff] [blame] | 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" |
tkent@chromium.org | c271a5f | 2013-02-08 09:34:13 +0000 | [diff] [blame] | 22 | #if ENABLE(METER_ELEMENT) |
yael.aharon@nokia.com | 666f4b8 | 2010-05-15 16:41:06 +0000 | [diff] [blame] | 23 | #include "RenderMeter.h" |
| 24 | |
| 25 | #include "HTMLMeterElement.h" |
darin@apple.com | f5247d1 | 2010-06-13 17:29:10 +0000 | [diff] [blame] | 26 | #include "HTMLNames.h" |
yael.aharon@nokia.com | 666f4b8 | 2010-05-15 16:41:06 +0000 | [diff] [blame] | 27 | #include "RenderTheme.h" |
fpizlo@apple.com | d03c594 | 2017-11-07 19:21:52 +0000 | [diff] [blame] | 28 | #include <wtf/IsoMallocInlines.h> |
yael.aharon@nokia.com | 666f4b8 | 2010-05-15 16:41:06 +0000 | [diff] [blame] | 29 | |
yael.aharon@nokia.com | 666f4b8 | 2010-05-15 16:41:06 +0000 | [diff] [blame] | 30 | namespace WebCore { |
| 31 | |
| 32 | using namespace HTMLNames; |
| 33 | |
fpizlo@apple.com | d03c594 | 2017-11-07 19:21:52 +0000 | [diff] [blame] | 34 | WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMeter); |
| 35 | |
antti@apple.com | 454418f | 2016-04-25 19:49:23 +0000 | [diff] [blame] | 36 | RenderMeter::RenderMeter(HTMLElement& element, RenderStyle&& style) |
aestes@apple.com | 13aae08 | 2016-01-02 08:03:08 +0000 | [diff] [blame] | 37 | : RenderBlockFlow(element, WTFMove(style)) |
yael.aharon@nokia.com | 666f4b8 | 2010-05-15 16:41:06 +0000 | [diff] [blame] | 38 | { |
| 39 | } |
| 40 | |
dbates@webkit.org | f21f3ae | 2017-10-19 23:48:45 +0000 | [diff] [blame] | 41 | RenderMeter::~RenderMeter() = default; |
morrita@google.com | 6509cd2 | 2010-06-18 05:13:19 +0000 | [diff] [blame] | 42 | |
shinyak@chromium.org | 037f1cd | 2012-08-15 09:37:32 +0000 | [diff] [blame] | 43 | HTMLMeterElement* RenderMeter::meterElement() const |
| 44 | { |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 45 | ASSERT(element()); |
shinyak@chromium.org | 037f1cd | 2012-08-15 09:37:32 +0000 | [diff] [blame] | 46 | |
cdumez@apple.com | a9c60c9 | 2014-10-02 19:39:41 +0000 | [diff] [blame] | 47 | if (is<HTMLMeterElement>(*element())) |
cdumez@apple.com | 72754ba | 2014-09-23 22:03:15 +0000 | [diff] [blame] | 48 | return downcast<HTMLMeterElement>(element()); |
shinyak@chromium.org | 037f1cd | 2012-08-15 09:37:32 +0000 | [diff] [blame] | 49 | |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 50 | ASSERT(element()->shadowHost()); |
cdumez@apple.com | 72754ba | 2014-09-23 22:03:15 +0000 | [diff] [blame] | 51 | return downcast<HTMLMeterElement>(element()->shadowHost()); |
shinyak@chromium.org | 037f1cd | 2012-08-15 09:37:32 +0000 | [diff] [blame] | 52 | } |
| 53 | |
tony@chromium.org | 5270e66 | 2012-09-10 21:47:50 +0000 | [diff] [blame] | 54 | void RenderMeter::updateLogicalWidth() |
morrita@google.com | a70a8f4 | 2010-06-08 06:26:06 +0000 | [diff] [blame] | 55 | { |
tony@chromium.org | 5270e66 | 2012-09-10 21:47:50 +0000 | [diff] [blame] | 56 | RenderBox::updateLogicalWidth(); |
tony@chromium.org | 845cf6e | 2012-09-24 21:11:48 +0000 | [diff] [blame] | 57 | |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 58 | IntSize frameSize = theme().meterSizeForBounds(*this, snappedIntRect(frameRect())); |
tony@chromium.org | 845cf6e | 2012-09-24 21:11:48 +0000 | [diff] [blame] | 59 | setLogicalWidth(isHorizontalWritingMode() ? frameSize.width() : frameSize.height()); |
morrita@google.com | a70a8f4 | 2010-06-08 06:26:06 +0000 | [diff] [blame] | 60 | } |
| 61 | |
zalan@apple.com | cca4b69 | 2016-12-16 04:37:28 +0000 | [diff] [blame] | 62 | RenderBox::LogicalExtentComputedValues RenderMeter::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const |
morrita@google.com | a70a8f4 | 2010-06-08 06:26:06 +0000 | [diff] [blame] | 63 | { |
zalan@apple.com | cca4b69 | 2016-12-16 04:37:28 +0000 | [diff] [blame] | 64 | auto computedValues = RenderBox::computeLogicalHeight(logicalHeight, logicalTop); |
tony@chromium.org | 845cf6e | 2012-09-24 21:11:48 +0000 | [diff] [blame] | 65 | LayoutRect frame = frameRect(); |
| 66 | if (isHorizontalWritingMode()) |
| 67 | frame.setHeight(computedValues.m_extent); |
| 68 | else |
| 69 | frame.setWidth(computedValues.m_extent); |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 70 | IntSize frameSize = theme().meterSizeForBounds(*this, snappedIntRect(frame)); |
tony@chromium.org | 845cf6e | 2012-09-24 21:11:48 +0000 | [diff] [blame] | 71 | computedValues.m_extent = isHorizontalWritingMode() ? frameSize.height() : frameSize.width(); |
zalan@apple.com | cca4b69 | 2016-12-16 04:37:28 +0000 | [diff] [blame] | 72 | return computedValues; |
morrita@google.com | a70a8f4 | 2010-06-08 06:26:06 +0000 | [diff] [blame] | 73 | } |
| 74 | |
morrita@google.com | f198756 | 2011-09-21 05:41:27 +0000 | [diff] [blame] | 75 | void RenderMeter::updateFromElement() |
| 76 | { |
| 77 | repaint(); |
| 78 | } |
| 79 | |
yael.aharon@nokia.com | 666f4b8 | 2010-05-15 16:41:06 +0000 | [diff] [blame] | 80 | } // namespace WebCore |
darin@apple.com | f5247d1 | 2010-06-13 17:29:10 +0000 | [diff] [blame] | 81 | |
yael.aharon@nokia.com | 666f4b8 | 2010-05-15 16:41:06 +0000 | [diff] [blame] | 82 | #endif |