1 /**
2 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
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
23 #if ENABLE(WML)
24 #include "WMLFormControlElement.h"
25
26 #include "RenderBox.h"
27 #include "RenderObject.h"
28 #include "RenderStyle.h"
29
30 namespace WebCore {
31
WMLFormControlElement(const QualifiedName & tagName,Document * document)32 WMLFormControlElement::WMLFormControlElement(const QualifiedName& tagName, Document* document)
33 : WMLElement(tagName, document)
34 , m_valueMatchesRenderer(false)
35 {
36 }
37
~WMLFormControlElement()38 WMLFormControlElement::~WMLFormControlElement()
39 {
40 }
41
isFocusable() const42 bool WMLFormControlElement::isFocusable() const
43 {
44 if (!renderer() || !renderer()->isBox())
45 return false;
46
47 if (toRenderBox(renderer())->size().isEmpty())
48 return false;
49
50 if (RenderStyle* style = renderer()->style()) {
51 if (style->visibility() != VISIBLE)
52 return false;
53 }
54
55 return true;
56 }
57
attach()58 void WMLFormControlElement::attach()
59 {
60 ASSERT(!attached());
61 WMLElement::attach();
62
63 // The call to updateFromElement() needs to go after the call through
64 // to the base class's attach() because that can sometimes do a close
65 // on the renderer.
66 if (renderer())
67 renderer()->updateFromElement();
68 }
69
recalcStyle(StyleChange change)70 void WMLFormControlElement::recalcStyle(StyleChange change)
71 {
72 WMLElement::recalcStyle(change);
73
74 if (renderer())
75 renderer()->updateFromElement();
76 }
77
78 }
79
80 #endif
81