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

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp

Issue 2767823002: Media Remoting: Add interstitial elements to media element shadow dom. (Closed)
Patch Set: Rebased. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp b/third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c53bc9d89a9bc70e4e54f558e73914a91e81f0cd
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp
@@ -0,0 +1,103 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/shadow/MediaRemotingElements.h"
+
+#include "core/dom/ClientRect.h"
+#include "core/dom/shadow/ShadowRoot.h"
+#include "core/events/MouseEvent.h"
+#include "core/html/HTMLVideoElement.h"
+#include "core/input/EventHandler.h"
+#include "platform/text/PlatformLocale.h"
+#include "public/platform/WebLocalizedString.h"
+
+namespace blink {
+
+using namespace HTMLNames;
+
+// ----------------------------
+
+class MediaRemotingExitButtonElement::MouseEventsListener final
+ : public EventListener {
+ public:
+ explicit MouseEventsListener(MediaRemotingExitButtonElement& element)
+ : EventListener(kCPPEventListenerType), element_(element) {}
+
+ bool operator==(const EventListener& other) const override {
+ return this == &other;
+ }
+
+ void Trace(blink::Visitor* visitor) {
+ visitor->Trace(element_);
+ EventListener::Trace(visitor);
+ }
+
+ private:
+ void handleEvent(ExecutionContext* context, Event* event) override {
+ DCHECK_EQ(event->type(), EventTypeNames::click);
+
+ MouseEvent* mouse_event = ToMouseEvent(event);
+ ClientRect* client_rect = element_->getBoundingClientRect();
+ const double x = mouse_event->x();
+ const double y = mouse_event->y();
+ if (x < client_rect->left() || x > client_rect->right() ||
+ y < client_rect->top() || y > client_rect->bottom())
+ return;
+
+ element_->GetVideoElement().DisableMediaRemoting();
+ event->SetDefaultHandled();
+ event->stopPropagation();
+ }
+
+ Member<MediaRemotingExitButtonElement> element_;
+};
+
+MediaRemotingExitButtonElement::MediaRemotingExitButtonElement(
+ MediaRemotingInterstitial& interstitial)
+ : HTMLDivElement(interstitial.GetDocument()), interstitial_(interstitial) {
+ listener_ = new MouseEventsListener(*this);
+ SetShadowPseudoId(AtomicString("-internal-media-remoting-disable-button"));
+ setInnerText(interstitial.GetVideoElement().GetLocale().QueryString(
+ WebLocalizedString::kMediaRemotingDisableText),
+ ASSERT_NO_EXCEPTION);
+}
+
+void MediaRemotingExitButtonElement::OnShown() {
+ GetDocument().addEventListener(EventTypeNames::click, listener_, true);
+}
+
+void MediaRemotingExitButtonElement::OnHidden() {
+ GetDocument().removeEventListener(EventTypeNames::click, listener_, true);
+}
+
+HTMLVideoElement& MediaRemotingExitButtonElement::GetVideoElement() const {
+ return interstitial_->GetVideoElement();
+}
+
+DEFINE_TRACE(MediaRemotingExitButtonElement) {
+ visitor->Trace(interstitial_);
+ visitor->Trace(listener_);
+ HTMLDivElement::Trace(visitor);
+}
+
+// ----------------------------
+
+MediaRemotingCastMessageElement::MediaRemotingCastMessageElement(
+ MediaRemotingInterstitial& interstitial)
+ : HTMLDivElement(interstitial.GetDocument()) {
+ SetShadowPseudoId(AtomicString("-internal-media-remoting-cast-text-message"));
+ setInnerText(interstitial.GetVideoElement().GetLocale().QueryString(
+ WebLocalizedString::kMediaRemotingCastText),
+ ASSERT_NO_EXCEPTION);
+}
+
+// ----------------------------
+
+MediaRemotingCastIconElement::MediaRemotingCastIconElement(
+ MediaRemotingInterstitial& interstitial)
+ : HTMLDivElement(interstitial.GetDocument()) {
+ SetShadowPseudoId(AtomicString("-internal-media-remoting-cast-icon"));
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698