 Chromium Code Reviews
 Chromium Code Reviews Issue 2767823002:
  Media Remoting: Add interstitial elements to media element shadow dom.  (Closed)
    
  
    Issue 2767823002:
  Media Remoting: Add interstitial elements to media element shadow dom.  (Closed) 
  | 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 MouseEventsListener(MediaRemotingDisableButtonElement& element) | |
| 
miu
2017/03/22 21:26:48
nit: explicit
 
xjz
2017/03/22 22:25:09
Done.
 | |
| 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 double x = mouseEvent->x(); | |
| 1131 double y = mouseEvent->y(); | |
| 1132 if (x < clientRect->left() || y < clientRect->top() || | |
| 1133 x > clientRect->left() + clientRect->width() || | |
| 
miu
2017/03/22 21:26:48
nit: x > clientRect->right()
 
xjz
2017/03/22 22:25:09
Done.
 | |
| 1134 y > clientRect->top() + clientRect->height()) | |
| 
miu
2017/03/22 21:26:48
nit: y > clientRect->bottom()
 
xjz
2017/03/22 22:25:09
Done.
 | |
| 1135 return; | |
| 1136 | |
| 1137 m_element->mediaElement().disableMediaRemoting(); | |
| 1138 event->setDefaultHandled(); | |
| 1139 event->stopPropagation(); | |
| 1140 m_element->document().removeEventListener(EventTypeNames::click, this, | |
| 1141 true); | |
| 1142 } | |
| 1143 | |
| 1144 Member<MediaRemotingDisableButtonElement> m_element; | |
| 1145 }; | |
| 1146 | |
| 1147 MediaRemotingDisableButtonElement::MediaRemotingDisableButtonElement( | |
| 1148 MediaRemotingInterstitial& remotingInterstitial) | |
| 1149 : HTMLInputElement(remotingInterstitial.document(), false), | |
| 1150 m_interstitial(remotingInterstitial) { | |
| 1151 m_listener = new MouseEventsListener(*this); | |
| 1152 ensureUserAgentShadowRoot(); | |
| 1153 setType(InputTypeNames::button); | |
| 1154 setShadowPseudoId(AtomicString("-webkit-media-remoting-disable-button")); | |
| 1155 } | |
| 1156 | |
| 1157 void MediaRemotingDisableButtonElement::show() { | |
| 1158 removeInlineStyleProperty(CSSPropertyDisplay); | |
| 1159 document().addEventListener(EventTypeNames::click, m_listener, true); | |
| 1160 } | |
| 1161 | |
| 1162 void MediaRemotingDisableButtonElement::hide() { | |
| 1163 setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); | |
| 1164 document().removeEventListener(EventTypeNames::click, m_listener, true); | |
| 1165 } | |
| 1166 | |
| 1167 DEFINE_TRACE(MediaRemotingDisableButtonElement) { | |
| 1168 visitor->trace(m_interstitial); | |
| 1169 visitor->trace(m_listener); | |
| 1170 HTMLInputElement::trace(visitor); | |
| 1171 } | |
| 1172 | |
| 1107 } // namespace blink | 1173 } // namespace blink | 
| OLD | NEW |