1+ /*
2+ * Copyright (C) 2022-present The WebF authors. All rights reserved.
3+ */
4+
5+ #include " hashchange_event.h"
6+ #include " qjs_hashchange_event.h"
7+
8+ namespace webf {
9+
10+ HashchangeEvent* HashchangeEvent::Create (webf::ExecutingContext* context,
11+ const webf::AtomicString& type,
12+ webf::ExceptionState& exception_state) {
13+ return MakeGarbageCollected<HashchangeEvent>(context, type, exception_state);
14+ }
15+
16+ HashchangeEvent* HashchangeEvent::Create (webf::ExecutingContext* context,
17+ const webf::AtomicString& type,
18+ const std::shared_ptr<HashchangeEventInit>& initializer,
19+ webf::ExceptionState& exception_state) {
20+ return MakeGarbageCollected<HashchangeEvent>(context, type, initializer, exception_state);
21+ }
22+
23+ HashchangeEvent::HashchangeEvent (webf::ExecutingContext* context,
24+ const webf::AtomicString& type,
25+ webf::ExceptionState& exception_state)
26+ : Event(context, type) {}
27+
28+ HashchangeEvent::HashchangeEvent (webf::ExecutingContext* context,
29+ const webf::AtomicString& type,
30+ const std::shared_ptr<HashchangeEventInit>& initializer,
31+ webf::ExceptionState& exception_state)
32+ : Event(context, type),
33+ new_url_ (initializer->hasNewURL () ? initializer->newURL() : AtomicString::Empty()),
34+ old_url_(initializer->hasOldURL () ? initializer->oldURL() : AtomicString::Empty()) {}
35+
36+ HashchangeEvent::HashchangeEvent (webf::ExecutingContext* context,
37+ const webf::AtomicString& type,
38+ webf::NativeHashchangeEvent* native_hash_change_event)
39+ : Event(context, type, &native_hash_change_event->native_event),
40+ #if ANDROID_32_BIT
41+ new_url_ (AtomicString(ctx(),
42+ std::unique_ptr<AutoFreeNativeString>(
43+ reinterpret_cast <AutoFreeNativeString*>(native_hash_change_event->newURL)))),
44+ old_url_(AtomicString(ctx(),
45+ std::unique_ptr<AutoFreeNativeString>(
46+ reinterpret_cast <AutoFreeNativeString*>(native_hash_change_event->oldURL))))
47+ #else
48+ new_url_ (AtomicString(ctx(),
49+ std::unique_ptr<AutoFreeNativeString>(
50+ reinterpret_cast <AutoFreeNativeString*>(native_hash_change_event->newURL)))),
51+ old_url_(AtomicString(ctx(),
52+ std::unique_ptr<AutoFreeNativeString>(
53+ reinterpret_cast <AutoFreeNativeString*>(native_hash_change_event->oldURL))))
54+ #endif
55+ {
56+ }
57+
58+ bool HashchangeEvent::IsHashChangeEvent () const {
59+ return true ;
60+ }
61+
62+ const AtomicString& HashchangeEvent::newURL () const {
63+ return new_url_;
64+ }
65+
66+ const AtomicString& HashchangeEvent::oldURL () const {
67+ return old_url_;
68+ }
69+
70+ } // namespace webf
0 commit comments