| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (C) 2005 Apple Computer, Inc. | 2 * Copyright (C) 2005 Apple Computer, Inc. |
| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/rendering/style/StyleInheritedData.h" | 30 #include "core/rendering/style/StyleInheritedData.h" |
| 31 | 31 |
| 32 namespace WebCore { | 32 namespace WebCore { |
| 33 | 33 |
| 34 using namespace HTMLNames; | 34 using namespace HTMLNames; |
| 35 | 35 |
| 36 RenderButton::RenderButton(Element* element) | 36 RenderButton::RenderButton(Element* element) |
| 37 : RenderFlexibleBox(element) | 37 : RenderFlexibleBox(element) |
| 38 , m_buttonText(0) | 38 , m_buttonText(0) |
| 39 , m_inner(0) | 39 , m_inner(0) |
| 40 , m_default(false) | |
| 41 { | 40 { |
| 42 } | 41 } |
| 43 | 42 |
| 44 RenderButton::~RenderButton() | 43 RenderButton::~RenderButton() |
| 45 { | 44 { |
| 46 } | 45 } |
| 47 | 46 |
| 48 void RenderButton::addChild(RenderObject* newChild, RenderObject* beforeChild) | 47 void RenderButton::addChild(RenderObject* newChild, RenderObject* beforeChild) |
| 49 { | 48 { |
| 50 if (!m_inner) { | 49 if (!m_inner) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 86 } |
| 88 | 87 |
| 89 void RenderButton::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
yle) | 88 void RenderButton::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
yle) |
| 90 { | 89 { |
| 91 RenderBlock::styleDidChange(diff, oldStyle); | 90 RenderBlock::styleDidChange(diff, oldStyle); |
| 92 | 91 |
| 93 if (m_buttonText) | 92 if (m_buttonText) |
| 94 m_buttonText->setStyle(style()); | 93 m_buttonText->setStyle(style()); |
| 95 if (m_inner) // RenderBlock handled updating the anonymous block's style. | 94 if (m_inner) // RenderBlock handled updating the anonymous block's style. |
| 96 setupInnerStyle(m_inner->style()); | 95 setupInnerStyle(m_inner->style()); |
| 97 | |
| 98 if (!m_default && theme()->isDefault(this)) { | |
| 99 if (!m_timer) | |
| 100 m_timer = adoptPtr(new Timer<RenderButton>(this, &RenderButton::time
rFired)); | |
| 101 m_timer->startRepeating(0.03); | |
| 102 m_default = true; | |
| 103 } else if (m_default && !theme()->isDefault(this)) { | |
| 104 m_default = false; | |
| 105 m_timer.clear(); | |
| 106 } | |
| 107 } | 96 } |
| 108 | 97 |
| 109 void RenderButton::setupInnerStyle(RenderStyle* innerStyle) | 98 void RenderButton::setupInnerStyle(RenderStyle* innerStyle) |
| 110 { | 99 { |
| 111 ASSERT(innerStyle->refCount() == 1); | 100 ASSERT(innerStyle->refCount() == 1); |
| 112 // RenderBlock::createAnonymousBlock creates a new RenderStyle, so this is | 101 // RenderBlock::createAnonymousBlock creates a new RenderStyle, so this is |
| 113 // safe to modify. | 102 // safe to modify. |
| 114 innerStyle->setFlexGrow(1.0f); | 103 innerStyle->setFlexGrow(1.0f); |
| 115 // Use margin:auto instead of align-items:center to get safe centering, i.e. | 104 // Use margin:auto instead of align-items:center to get safe centering, i.e. |
| 116 // when the content overflows, treat it the same as align-items: flex-start. | 105 // when the content overflows, treat it the same as align-items: flex-start. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // can also have children. | 148 // can also have children. |
| 160 return !node()->hasTagName(inputTag); | 149 return !node()->hasTagName(inputTag); |
| 161 } | 150 } |
| 162 | 151 |
| 163 LayoutRect RenderButton::controlClipRect(const LayoutPoint& additionalOffset) co
nst | 152 LayoutRect RenderButton::controlClipRect(const LayoutPoint& additionalOffset) co
nst |
| 164 { | 153 { |
| 165 // Clip to the padding box to at least give content the extra padding space. | 154 // Clip to the padding box to at least give content the extra padding space. |
| 166 return LayoutRect(additionalOffset.x() + borderLeft(), additionalOffset.y()
+ borderTop(), width() - borderLeft() - borderRight(), height() - borderTop() -
borderBottom()); | 155 return LayoutRect(additionalOffset.x() + borderLeft(), additionalOffset.y()
+ borderTop(), width() - borderLeft() - borderRight(), height() - borderTop() -
borderBottom()); |
| 167 } | 156 } |
| 168 | 157 |
| 169 void RenderButton::timerFired(Timer<RenderButton>*) | |
| 170 { | |
| 171 repaint(); | |
| 172 } | |
| 173 | |
| 174 } // namespace WebCore | 158 } // namespace WebCore |
| OLD | NEW |