| 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
|
|
|