Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Side by Side Diff: Source/core/html/HTMLMeterElement.cpp

Issue 948063002: Move rendering/RenderMeter to layout/LayoutMeter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLMeterElement.h ('k') | Source/core/html/shadow/MeterShadowElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 13 matching lines...) Expand all
24 24
25 #include "bindings/core/v8/ExceptionMessages.h" 25 #include "bindings/core/v8/ExceptionMessages.h"
26 #include "bindings/core/v8/ExceptionState.h" 26 #include "bindings/core/v8/ExceptionState.h"
27 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 27 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
28 #include "core/HTMLNames.h" 28 #include "core/HTMLNames.h"
29 #include "core/dom/ExceptionCode.h" 29 #include "core/dom/ExceptionCode.h"
30 #include "core/dom/shadow/ShadowRoot.h" 30 #include "core/dom/shadow/ShadowRoot.h"
31 #include "core/frame/UseCounter.h" 31 #include "core/frame/UseCounter.h"
32 #include "core/html/parser/HTMLParserIdioms.h" 32 #include "core/html/parser/HTMLParserIdioms.h"
33 #include "core/html/shadow/MeterShadowElement.h" 33 #include "core/html/shadow/MeterShadowElement.h"
34 #include "core/layout/LayoutMeter.h"
34 #include "core/layout/LayoutTheme.h" 35 #include "core/layout/LayoutTheme.h"
35 #include "core/rendering/RenderMeter.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 using namespace HTMLNames; 39 using namespace HTMLNames;
40 40
41 HTMLMeterElement::HTMLMeterElement(Document& document) 41 HTMLMeterElement::HTMLMeterElement(Document& document)
42 : LabelableElement(meterTag, document) 42 : LabelableElement(meterTag, document)
43 { 43 {
44 UseCounter::count(document, UseCounter::MeterElement); 44 UseCounter::count(document, UseCounter::MeterElement);
45 } 45 }
46 46
47 HTMLMeterElement::~HTMLMeterElement() 47 HTMLMeterElement::~HTMLMeterElement()
48 { 48 {
49 } 49 }
50 50
51 PassRefPtrWillBeRawPtr<HTMLMeterElement> HTMLMeterElement::create(Document& docu ment) 51 PassRefPtrWillBeRawPtr<HTMLMeterElement> HTMLMeterElement::create(Document& docu ment)
52 { 52 {
53 RefPtrWillBeRawPtr<HTMLMeterElement> meter = adoptRefWillBeNoop(new HTMLMete rElement(document)); 53 RefPtrWillBeRawPtr<HTMLMeterElement> meter = adoptRefWillBeNoop(new HTMLMete rElement(document));
54 meter->ensureClosedShadowRoot(); 54 meter->ensureClosedShadowRoot();
55 return meter.release(); 55 return meter.release();
56 } 56 }
57 57
58 LayoutObject* HTMLMeterElement::createRenderer(const LayoutStyle& style) 58 LayoutObject* HTMLMeterElement::createRenderer(const LayoutStyle& style)
59 { 59 {
60 if (hasOpenShadowRoot() || !LayoutTheme::theme().supportsMeter(style.appeara nce())) 60 if (hasOpenShadowRoot() || !LayoutTheme::theme().supportsMeter(style.appeara nce()))
61 return LayoutObject::createObject(this, style); 61 return LayoutObject::createObject(this, style);
62 return new RenderMeter(this); 62 return new LayoutMeter(this);
63 } 63 }
64 64
65 void HTMLMeterElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 65 void HTMLMeterElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
66 { 66 {
67 if (name == valueAttr || name == minAttr || name == maxAttr || name == lowAt tr || name == highAttr || name == optimumAttr) 67 if (name == valueAttr || name == minAttr || name == maxAttr || name == lowAt tr || name == highAttr || name == optimumAttr)
68 didElementStateChange(); 68 didElementStateChange();
69 else 69 else
70 LabelableElement::parseAttribute(name, value); 70 LabelableElement::parseAttribute(name, value);
71 } 71 }
72 72
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 if (max <= min) 176 if (max <= min)
177 return 0; 177 return 0;
178 return (value - min) / (max - min); 178 return (value - min) / (max - min);
179 } 179 }
180 180
181 void HTMLMeterElement::didElementStateChange() 181 void HTMLMeterElement::didElementStateChange()
182 { 182 {
183 m_value->setWidthPercentage(valueRatio()*100); 183 m_value->setWidthPercentage(valueRatio()*100);
184 m_value->updatePseudo(); 184 m_value->updatePseudo();
185 if (RenderMeter* render = renderMeter()) 185 if (LayoutMeter* render = layoutMeter())
186 render->updateFromElement(); 186 render->updateFromElement();
187 } 187 }
188 188
189 RenderMeter* HTMLMeterElement::renderMeter() const 189 LayoutMeter* HTMLMeterElement::layoutMeter() const
190 { 190 {
191 if (renderer() && renderer()->isMeter()) 191 if (renderer() && renderer()->isMeter())
192 return toRenderMeter(renderer()); 192 return toLayoutMeter(renderer());
193 193
194 LayoutObject* layoutObject = closedShadowRoot()->firstChild()->renderer(); 194 LayoutObject* layoutObject = closedShadowRoot()->firstChild()->renderer();
195 return toRenderMeter(layoutObject); 195 return toLayoutMeter(layoutObject);
196 } 196 }
197 197
198 void HTMLMeterElement::didAddClosedShadowRoot(ShadowRoot& root) 198 void HTMLMeterElement::didAddClosedShadowRoot(ShadowRoot& root)
199 { 199 {
200 ASSERT(!m_value); 200 ASSERT(!m_value);
201 201
202 RefPtrWillBeRawPtr<MeterInnerElement> inner = MeterInnerElement::create(docu ment()); 202 RefPtrWillBeRawPtr<MeterInnerElement> inner = MeterInnerElement::create(docu ment());
203 root.appendChild(inner); 203 root.appendChild(inner);
204 204
205 RefPtrWillBeRawPtr<MeterBarElement> bar = MeterBarElement::create(document() ); 205 RefPtrWillBeRawPtr<MeterBarElement> bar = MeterBarElement::create(document() );
(...skipping 11 matching lines...) Expand all
217 lazyReattachIfAttached(); 217 lazyReattachIfAttached();
218 } 218 }
219 219
220 DEFINE_TRACE(HTMLMeterElement) 220 DEFINE_TRACE(HTMLMeterElement)
221 { 221 {
222 visitor->trace(m_value); 222 visitor->trace(m_value);
223 LabelableElement::trace(visitor); 223 LabelableElement::trace(visitor);
224 } 224 }
225 225
226 } // namespace 226 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMeterElement.h ('k') | Source/core/html/shadow/MeterShadowElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698