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 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 | 1097 |
1098 MediaControlCurrentTimeDisplayElement* | 1098 MediaControlCurrentTimeDisplayElement* |
1099 MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls) { | 1099 MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls) { |
1100 MediaControlCurrentTimeDisplayElement* element = | 1100 MediaControlCurrentTimeDisplayElement* element = |
1101 new MediaControlCurrentTimeDisplayElement(mediaControls); | 1101 new MediaControlCurrentTimeDisplayElement(mediaControls); |
1102 element->setShadowPseudoId( | 1102 element->setShadowPseudoId( |
1103 AtomicString("-webkit-media-controls-current-time-display")); | 1103 AtomicString("-webkit-media-controls-current-time-display")); |
1104 return element; | 1104 return element; |
1105 } | 1105 } |
1106 | 1106 |
| 1107 // ---------------------------- |
| 1108 |
| 1109 class MediaRemotingDisableButtonElement::MouseEventsListener final |
| 1110 : public EventListener { |
| 1111 public: |
| 1112 explicit MouseEventsListener(MediaRemotingDisableButtonElement& element) |
| 1113 : EventListener(CPPEventListenerType), m_element(element) {} |
| 1114 |
| 1115 bool operator==(const EventListener& other) const override { |
| 1116 return this == &other; |
| 1117 } |
| 1118 |
| 1119 void trace(blink::Visitor* visitor) { |
| 1120 visitor->trace(m_element); |
| 1121 EventListener::trace(visitor); |
| 1122 } |
| 1123 |
| 1124 private: |
| 1125 void handleEvent(ExecutionContext* context, Event* event) override { |
| 1126 DCHECK(event->type() == EventTypeNames::click); |
| 1127 |
| 1128 MouseEvent* mouseEvent = toMouseEvent(event); |
| 1129 ClientRect* clientRect = m_element->getBoundingClientRect(); |
| 1130 const double x = mouseEvent->x(); |
| 1131 const double y = mouseEvent->y(); |
| 1132 if (x < clientRect->left() || x > clientRect->right() || |
| 1133 y < clientRect->top() || y > clientRect->bottom()) |
| 1134 return; |
| 1135 |
| 1136 m_element->mediaElement().disableMediaRemoting(); |
| 1137 event->setDefaultHandled(); |
| 1138 event->stopPropagation(); |
| 1139 m_element->document().removeEventListener(EventTypeNames::click, this, |
| 1140 true); |
| 1141 } |
| 1142 |
| 1143 Member<MediaRemotingDisableButtonElement> m_element; |
| 1144 }; |
| 1145 |
| 1146 MediaRemotingDisableButtonElement::MediaRemotingDisableButtonElement( |
| 1147 MediaRemotingInterstitialElements& interstitialElements) |
| 1148 : HTMLInputElement(interstitialElements.document(), false), |
| 1149 m_interstitialElements(interstitialElements) { |
| 1150 m_listener = new MouseEventsListener(*this); |
| 1151 ensureUserAgentShadowRoot(); |
| 1152 setType(InputTypeNames::text); |
| 1153 setValue(interstitialElements.mediaElement().locale().queryString( |
| 1154 WebLocalizedString::MediaRemotingDisableText)); |
| 1155 setShadowPseudoId(AtomicString("-internal-media-remoting-disable-button")); |
| 1156 } |
| 1157 |
| 1158 void MediaRemotingDisableButtonElement::show() { |
| 1159 removeInlineStyleProperty(CSSPropertyDisplay); |
| 1160 document().addEventListener(EventTypeNames::click, m_listener, true); |
| 1161 } |
| 1162 |
| 1163 void MediaRemotingDisableButtonElement::hide() { |
| 1164 setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); |
| 1165 document().removeEventListener(EventTypeNames::click, m_listener, true); |
| 1166 } |
| 1167 |
| 1168 DEFINE_TRACE(MediaRemotingDisableButtonElement) { |
| 1169 visitor->trace(m_interstitialElements); |
| 1170 visitor->trace(m_listener); |
| 1171 HTMLInputElement::trace(visitor); |
| 1172 } |
| 1173 |
| 1174 // ---------------------------- |
| 1175 |
| 1176 MediaRemotingCastIconElement::MediaRemotingCastIconElement( |
| 1177 MediaRemotingInterstitialElements& remotingInterstitial) |
| 1178 : HTMLInputElement(remotingInterstitial.document(), false) { |
| 1179 ensureUserAgentShadowRoot(); |
| 1180 setType(InputTypeNames::button); |
| 1181 setShadowPseudoId(AtomicString("-internal-media-remoting-cast-icon")); |
| 1182 } |
| 1183 |
| 1184 void MediaRemotingCastIconElement::show() { |
| 1185 removeInlineStyleProperty(CSSPropertyDisplay); |
| 1186 } |
| 1187 |
| 1188 void MediaRemotingCastIconElement::hide() { |
| 1189 setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); |
| 1190 } |
| 1191 |
| 1192 // ---------------------------- |
| 1193 |
| 1194 MediaRemotingCastMessageElement::MediaRemotingCastMessageElement( |
| 1195 MediaRemotingInterstitialElements& remotingInterstitial) |
| 1196 : HTMLInputElement(remotingInterstitial.document(), false) { |
| 1197 ensureUserAgentShadowRoot(); |
| 1198 setType(InputTypeNames::text); |
| 1199 setValue(remotingInterstitial.mediaElement().locale().queryString( |
| 1200 WebLocalizedString::MediaRemotingCastingVideoText)); |
| 1201 setShadowPseudoId(AtomicString("-internal-media-remoting-cast-text")); |
| 1202 } |
| 1203 |
| 1204 void MediaRemotingCastMessageElement::show() { |
| 1205 removeInlineStyleProperty(CSSPropertyDisplay); |
| 1206 } |
| 1207 |
| 1208 void MediaRemotingCastMessageElement::hide() { |
| 1209 setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); |
| 1210 } |
| 1211 |
| 1212 // ---------------------------- |
| 1213 |
| 1214 MediaRemotingBackgroundImageElement::MediaRemotingBackgroundImageElement( |
| 1215 MediaRemotingInterstitial& remotingInterstitial) |
| 1216 : HTMLInputElement(remotingInterstitial.document(), false), |
| 1217 m_interstitial(remotingInterstitial) { |
| 1218 ensureUserAgentShadowRoot(); |
| 1219 setType(InputTypeNames::image); |
| 1220 setShadowPseudoId(AtomicString("-internal-media-remoting-background-image")); |
| 1221 } |
| 1222 |
| 1223 void MediaRemotingBackgroundImageElement::show() { |
| 1224 setAttribute(srcAttr, |
| 1225 m_interstitial->mediaElement().getAttribute(posterAttr)); |
| 1226 removeInlineStyleProperty(CSSPropertyDisplay); |
| 1227 } |
| 1228 |
| 1229 void MediaRemotingBackgroundImageElement::hide() { |
| 1230 setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); |
| 1231 } |
| 1232 |
| 1233 DEFINE_TRACE(MediaRemotingBackgroundImageElement) { |
| 1234 visitor->trace(m_interstitial); |
| 1235 HTMLInputElement::trace(visitor); |
| 1236 } |
| 1237 |
1107 } // namespace blink | 1238 } // namespace blink |
OLD | NEW |