OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 HTMLElement* element = toHTMLElement(node); | 64 HTMLElement* element = toHTMLElement(node); |
65 if (isHTMLInputElement(*element)) | 65 if (isHTMLInputElement(*element)) |
66 return static_cast<MediaControlInputElement*>(element)->displayType(); | 66 return static_cast<MediaControlInputElement*>(element)->displayType(); |
67 return static_cast<MediaControlDivElement*>(element)->displayType(); | 67 return static_cast<MediaControlDivElement*>(element)->displayType(); |
68 } | 68 } |
69 | 69 |
70 MediaControlElement::MediaControlElement(MediaControls& mediaControls, MediaCont
rolElementType displayType, HTMLElement* element) | 70 MediaControlElement::MediaControlElement(MediaControls& mediaControls, MediaCont
rolElementType displayType, HTMLElement* element) |
71 : m_mediaControls(mediaControls) | 71 : m_mediaControls(mediaControls) |
72 , m_displayType(displayType) | 72 , m_displayType(displayType) |
73 , m_element(element) | 73 , m_element(element) |
| 74 , m_isShown(true) |
| 75 , m_isWanted(true) |
| 76 , m_doesFit(true) |
74 { | 77 { |
75 } | 78 } |
76 | 79 |
77 HTMLMediaElement& MediaControlElement::mediaElement() const | 80 HTMLMediaElement& MediaControlElement::mediaElement() const |
78 { | 81 { |
79 return mediaControls().mediaElement(); | 82 return mediaControls().mediaElement(); |
80 } | 83 } |
81 | 84 |
82 void MediaControlElement::hide() | 85 void MediaControlElement::hide() |
83 { | 86 { |
84 m_element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); | 87 m_element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); |
| 88 m_isShown = false; |
85 } | 89 } |
86 | 90 |
87 void MediaControlElement::show() | 91 void MediaControlElement::show() |
88 { | 92 { |
89 m_element->removeInlineStyleProperty(CSSPropertyDisplay); | 93 m_element->removeInlineStyleProperty(CSSPropertyDisplay); |
| 94 m_isShown = true; |
| 95 } |
| 96 |
| 97 bool MediaControlElement::isShown() |
| 98 { |
| 99 return m_isShown; |
| 100 } |
| 101 |
| 102 void MediaControlElement::updateShownState() |
| 103 { |
| 104 if (m_isWanted && m_doesFit) |
| 105 show(); |
| 106 else |
| 107 hide(); |
| 108 } |
| 109 |
| 110 void MediaControlElement::setDoesFit(bool fits) |
| 111 { |
| 112 m_doesFit = fits; |
| 113 updateShownState(); |
| 114 } |
| 115 |
| 116 void MediaControlElement::setIsWanted(bool wanted) |
| 117 { |
| 118 m_isWanted = wanted; |
| 119 updateShownState(); |
| 120 } |
| 121 |
| 122 bool MediaControlElement::isWanted() |
| 123 { |
| 124 return m_isWanted; |
| 125 } |
| 126 |
| 127 int MediaControlElement::minimumWidth() |
| 128 { |
| 129 // We could check the computed style here, but that depends on whether |
| 130 // we've been shown. Instead, we just assume 48 except for the |
| 131 // timeline bar. |
| 132 if (m_displayType == MediaSlider) |
| 133 return 55; |
| 134 |
| 135 return 48; |
90 } | 136 } |
91 | 137 |
92 void MediaControlElement::setDisplayType(MediaControlElementType displayType) | 138 void MediaControlElement::setDisplayType(MediaControlElementType displayType) |
93 { | 139 { |
94 if (displayType == m_displayType) | 140 if (displayType == m_displayType) |
95 return; | 141 return; |
96 | 142 |
97 m_displayType = displayType; | 143 m_displayType = displayType; |
98 if (LayoutObject* object = m_element->layoutObject()) | 144 if (LayoutObject* object = m_element->layoutObject()) |
99 object->setShouldDoFullPaintInvalidation(); | 145 object->setShouldDoFullPaintInvalidation(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 , m_currentValue(0) | 190 , m_currentValue(0) |
145 { | 191 { |
146 } | 192 } |
147 | 193 |
148 void MediaControlTimeDisplayElement::setCurrentValue(double time) | 194 void MediaControlTimeDisplayElement::setCurrentValue(double time) |
149 { | 195 { |
150 m_currentValue = time; | 196 m_currentValue = time; |
151 } | 197 } |
152 | 198 |
153 } // namespace blink | 199 } // namespace blink |
OLD | NEW |