OLD | NEW |
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 RenderProgress::~RenderProgress() | 49 RenderProgress::~RenderProgress() |
50 { | 50 { |
51 if (m_valuePart) | 51 if (m_valuePart) |
52 m_valuePart->detach(); | 52 m_valuePart->detach(); |
53 } | 53 } |
54 | 54 |
55 void RenderProgress::updateFromElement() | 55 void RenderProgress::updateFromElement() |
56 { | 56 { |
| 57 if (!m_valuePart) { |
| 58 m_valuePart = ShadowBlockElement::createForPart(static_cast<HTMLElement*
>(node()), PROGRESS_BAR_VALUE); |
| 59 if (m_valuePart->renderer()) |
| 60 addChild(m_valuePart->renderer()); |
| 61 } |
| 62 |
| 63 if (shouldHaveParts()) |
| 64 style()->setAppearance(NoControlPart); |
| 65 else if (m_valuePart->renderer()) |
| 66 m_valuePart->renderer()->style()->setVisibility(HIDDEN); |
| 67 |
57 HTMLProgressElement* element = progressElement(); | 68 HTMLProgressElement* element = progressElement(); |
58 if (m_position == element->position()) | 69 if (m_position == element->position()) |
59 return; | 70 return; |
60 m_position = element->position(); | 71 m_position = element->position(); |
61 | 72 |
62 updateAnimationState(); | 73 updateAnimationState(); |
63 RenderIndicator::updateFromElement(); | 74 RenderIndicator::updateFromElement(); |
64 } | 75 } |
65 | 76 |
66 double RenderProgress::animationProgress() const | 77 double RenderProgress::animationProgress() const |
(...skipping 16 matching lines...) Expand all Loading... |
83 if (paintInfo.phase == PaintPhaseBlockBackground) { | 94 if (paintInfo.phase == PaintPhaseBlockBackground) { |
84 if (!m_animationTimer.isActive() && m_animating) | 95 if (!m_animationTimer.isActive() && m_animating) |
85 m_animationTimer.startOneShot(m_animationRepeatInterval); | 96 m_animationTimer.startOneShot(m_animationRepeatInterval); |
86 } | 97 } |
87 | 98 |
88 RenderIndicator::paint(paintInfo, tx, ty); | 99 RenderIndicator::paint(paintInfo, tx, ty); |
89 } | 100 } |
90 | 101 |
91 void RenderProgress::layoutParts() | 102 void RenderProgress::layoutParts() |
92 { | 103 { |
93 updatePartsState(); | 104 m_valuePart->layoutAsPart(valuePartRect()); |
94 if (m_valuePart) | |
95 m_valuePart->layoutAsPart(valuePartRect()); | |
96 updateAnimationState(); | 105 updateAnimationState(); |
97 } | 106 } |
98 | 107 |
99 bool RenderProgress::shouldHaveParts() const | 108 bool RenderProgress::shouldHaveParts() const |
100 { | 109 { |
101 if (!style()->hasAppearance()) | 110 if (!style()->hasAppearance()) |
102 return true; | 111 return true; |
103 if (ShadowBlockElement::partShouldHaveStyle(this, PROGRESS_BAR_VALUE)) | 112 if (ShadowBlockElement::partShouldHaveStyle(this, PROGRESS_BAR_VALUE)) |
104 return true; | 113 return true; |
105 return false; | 114 return false; |
106 } | 115 } |
107 | 116 |
108 void RenderProgress::updatePartsState() | |
109 { | |
110 if (shouldHaveParts() && !m_valuePart) { | |
111 style()->setAppearance(NoControlPart); | |
112 m_valuePart = ShadowBlockElement::createForPart(static_cast<HTMLElement*
>(node()), PROGRESS_BAR_VALUE); | |
113 addChild(m_valuePart->renderer()); | |
114 } else if (!shouldHaveParts() && m_valuePart) { | |
115 m_valuePart->detach(); | |
116 m_valuePart = 0; | |
117 } | |
118 } | |
119 | |
120 void RenderProgress::updateAnimationState() | 117 void RenderProgress::updateAnimationState() |
121 { | 118 { |
122 m_animationDuration = theme()->animationDurationForProgressBar(this); | 119 m_animationDuration = theme()->animationDurationForProgressBar(this); |
123 m_animationRepeatInterval = theme()->animationRepeatIntervalForProgressBar(t
his); | 120 m_animationRepeatInterval = theme()->animationRepeatIntervalForProgressBar(t
his); |
124 | 121 |
125 bool animating = style()->hasAppearance() && m_animationDuration > 0; | 122 bool animating = style()->hasAppearance() && m_animationDuration > 0; |
126 if (animating == m_animating) | 123 if (animating == m_animating) |
127 return; | 124 return; |
128 | 125 |
129 m_animating = animating; | 126 m_animating = animating; |
(...skipping 13 matching lines...) Expand all Loading... |
143 } | 140 } |
144 | 141 |
145 HTMLProgressElement* RenderProgress::progressElement() const | 142 HTMLProgressElement* RenderProgress::progressElement() const |
146 { | 143 { |
147 return static_cast<HTMLProgressElement*>(node()); | 144 return static_cast<HTMLProgressElement*>(node()); |
148 } | 145 } |
149 | 146 |
150 } // namespace WebCore | 147 } // namespace WebCore |
151 | 148 |
152 #endif | 149 #endif |
OLD | NEW |