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

Side by Side Diff: Source/core/html/shadow/MediaControlElementTypes.cpp

Issue 185363011: Merge/rename two MediaControlElements into their parent classes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nit/oops Created 6 years, 9 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
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 : MediaControlDivElement(document, displayType) 119 : MediaControlDivElement(document, displayType)
120 , m_currentValue(0) 120 , m_currentValue(0)
121 { 121 {
122 } 122 }
123 123
124 void MediaControlTimeDisplayElement::setCurrentValue(double time) 124 void MediaControlTimeDisplayElement::setCurrentValue(double time)
125 { 125 {
126 m_currentValue = time; 126 m_currentValue = time;
127 } 127 }
128 128
129 // ----------------------------
130
131 MediaControlMuteButtonElement::MediaControlMuteButtonElement(Document& document, MediaControlElementType displayType)
132 : MediaControlInputElement(document, displayType)
133 {
134 }
135
136 void MediaControlMuteButtonElement::defaultEventHandler(Event* event)
137 {
138 if (event->type() == EventTypeNames::click) {
139 mediaController()->setMuted(!mediaController()->muted());
140 event->setDefaultHandled();
141 }
142
143 HTMLInputElement::defaultEventHandler(event);
144 }
145
146 void MediaControlMuteButtonElement::changedMute()
147 {
148 updateDisplayType();
149 }
150
151 void MediaControlMuteButtonElement::updateDisplayType()
152 {
153 setDisplayType(mediaController()->muted() ? MediaUnMuteButton : MediaMuteBut ton);
154 }
155
156 // ----------------------------
157
158 MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(Document& docum ent)
159 : MediaControlInputElement(document, MediaVolumeSlider)
160 {
161 }
162
163 void MediaControlVolumeSliderElement::defaultEventHandler(Event* event)
164 {
165 // Left button is 0. Rejects mouse events not from left button.
166 if (event->isMouseEvent() && toMouseEvent(event)->button())
167 return;
168
169 if (!inDocument() || !document().isActive())
170 return;
171
172 MediaControlInputElement::defaultEventHandler(event);
173
174 if (event->type() == EventTypeNames::mouseover || event->type() == EventType Names::mouseout || event->type() == EventTypeNames::mousemove)
175 return;
176
177 double volume = value().toDouble();
178 mediaController()->setVolume(volume, ASSERT_NO_EXCEPTION);
179 mediaController()->setMuted(false);
180 }
181
182 bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents()
183 {
184 if (!inDocument() || !document().isActive())
185 return false;
186
187 return MediaControlInputElement::willRespondToMouseMoveEvents();
188 }
189
190 bool MediaControlVolumeSliderElement::willRespondToMouseClickEvents()
191 {
192 if (!inDocument() || !document().isActive())
193 return false;
194
195 return MediaControlInputElement::willRespondToMouseClickEvents();
196 }
197
198 void MediaControlVolumeSliderElement::setVolume(double volume)
199 {
200 if (value().toDouble() != volume)
201 setValue(String::number(volume));
202 }
203
204 } // namespace WebCore 129 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/shadow/MediaControlElementTypes.h ('k') | Source/core/html/shadow/MediaControlElements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698