1 /*
2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3  * Copyright (C) 2013 Intel Corporation. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #include "third_party/blink/renderer/core/events/transition_event.h"
28 
29 #include "third_party/blink/renderer/bindings/core/v8/v8_transition_event_init.h"
30 #include "third_party/blink/renderer/core/event_interface_names.h"
31 
32 namespace blink {
33 
34 TransitionEvent::TransitionEvent() = default;
35 
TransitionEvent(const AtomicString & type,const String & property_name,const AnimationTimeDelta & elapsed_time,const String & pseudo_element)36 TransitionEvent::TransitionEvent(const AtomicString& type,
37                                  const String& property_name,
38                                  const AnimationTimeDelta& elapsed_time,
39                                  const String& pseudo_element)
40     : Event(type, Bubbles::kYes, Cancelable::kYes),
41       property_name_(property_name),
42       elapsed_time_(elapsed_time),
43       pseudo_element_(pseudo_element) {}
44 
TransitionEvent(const AtomicString & type,const TransitionEventInit * initializer)45 TransitionEvent::TransitionEvent(const AtomicString& type,
46                                  const TransitionEventInit* initializer)
47     : Event(type, initializer) {
48   if (initializer->hasPropertyName())
49     property_name_ = initializer->propertyName();
50   if (initializer->hasElapsedTime()) {
51     elapsed_time_ =
52         AnimationTimeDelta::FromSecondsD(initializer->elapsedTime());
53   }
54   if (initializer->hasPseudoElement())
55     pseudo_element_ = initializer->pseudoElement();
56 }
57 
58 TransitionEvent::~TransitionEvent() = default;
59 
propertyName() const60 const String& TransitionEvent::propertyName() const {
61   return property_name_;
62 }
63 
elapsedTime() const64 double TransitionEvent::elapsedTime() const {
65   return elapsed_time_.InSecondsF();
66 }
67 
pseudoElement() const68 const String& TransitionEvent::pseudoElement() const {
69   return pseudo_element_;
70 }
71 
InterfaceName() const72 const AtomicString& TransitionEvent::InterfaceName() const {
73   return event_interface_names::kTransitionEvent;
74 }
75 
Trace(Visitor * visitor)76 void TransitionEvent::Trace(Visitor* visitor) {
77   Event::Trace(visitor);
78 }
79 
80 }  // namespace blink
81