diff --git a/sky/engine/bindings/BUILD.gn b/sky/engine/bindings/BUILD.gn index d929fb7e5e48e..d8133936962b1 100644 --- a/sky/engine/bindings/BUILD.gn +++ b/sky/engine/bindings/BUILD.gn @@ -13,11 +13,8 @@ source_set("bindings") { "builtin_natives.h", "builtin_sky.cc", "builtin_sky.h", - "custom/dart_element_custom.cc", "dart_callback.cc", "dart_callback.h", - "dart_event_listener.cc", - "dart_event_listener.h", "exception_messages.cc", "exception_messages.h", "exception_state.cc", diff --git a/sky/engine/bindings/IDLExtendedAttributes.txt b/sky/engine/bindings/IDLExtendedAttributes.txt index 7033ba28ec253..6717f24d76966 100644 --- a/sky/engine/bindings/IDLExtendedAttributes.txt +++ b/sky/engine/bindings/IDLExtendedAttributes.txt @@ -35,11 +35,8 @@ ActiveDOMObject CachedAttribute=* -CallWith=ExecutionContext|ScriptState|ScriptArguments|ActiveWindow|FirstWindow|ThisValue +CallWith=ScriptState|ScriptArguments|ActiveWindow|FirstWindow|ThisValue Constructor -# FIXME: remove [ConstructorCallWith=Document], as can instead use -# [ConstructorCallWith=ExecutionContext] + toDocument(executionContext) -ConstructorCallWith=ExecutionContext|Document Custom=|Getter|Setter|VisitDOMWrapper|Wrap|PropertyGetter|PropertyEnumerator|PropertyQuery CustomConstructor CustomElementCallbacks diff --git a/sky/engine/bindings/builtin_sky.cc b/sky/engine/bindings/builtin_sky.cc index 7dbe011df7710..7ccd266bc3eb1 100644 --- a/sky/engine/bindings/builtin_sky.cc +++ b/sky/engine/bindings/builtin_sky.cc @@ -20,13 +20,6 @@ BuiltinSky::BuiltinSky(DOMDartState* dart_state) { BuiltinSky::~BuiltinSky() { } -void BuiltinSky::InstallWindow(DOMDartState* dart_state) { - CHECK(!LogIfError(Dart_SetField(library_.value(), - ToDart("window"), - ToDart(dart_state->CurrentWindow())))); - // TODO(abarth): Retain the document wrapper. -} - void BuiltinSky::InstallView(View* view) { CHECK(!LogIfError( Dart_SetField(library_.value(), ToDart("view"), ToDart(view)))); diff --git a/sky/engine/bindings/builtin_sky.h b/sky/engine/bindings/builtin_sky.h index cbeb54c89068f..25bdcbd5b91da 100644 --- a/sky/engine/bindings/builtin_sky.h +++ b/sky/engine/bindings/builtin_sky.h @@ -19,7 +19,6 @@ class BuiltinSky : public DartClassProvider { explicit BuiltinSky(DOMDartState* dart_state); ~BuiltinSky(); - void InstallWindow(DOMDartState* dart_state); void InstallView(View* view); // DartClassProvider: diff --git a/sky/engine/bindings/custom/dart_element_custom.cc b/sky/engine/bindings/custom/dart_element_custom.cc deleted file mode 100644 index aec8a2f56dcbd..0000000000000 --- a/sky/engine/bindings/custom/dart_element_custom.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 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 "sky/engine/core/dom/Element.h" - -#include "dart/runtime/include/dart_api.h" -#include "sky/engine/core/script/dom_dart_state.h" -#include "sky/engine/tonic/dart_converter.h" - -namespace blink { -namespace DartElementInternal { - -void constructorCallback(Dart_NativeArguments args) { - Dart_Handle receiver = Dart_GetNativeArgument(args, 0); - DCHECK(!LogIfError(receiver)); - - Dart_Handle tag_name = Dart_GetField(receiver, - Dart_NewStringFromCString("tagName")); - if (!Dart_IsString(tag_name)) { - Dart_ThrowException(Dart_NewStringFromCString("tagName is not a string")); - return; - } - - RefPtr element = Element::create( - QualifiedName(StringFromDart(tag_name)), DOMDartState::CurrentDocument()); - - // TODO(abarth): We should remove these states because elements are never - // waiting for upgrades. - element->setCustomElementState(Element::WaitingForUpgrade); - element->setCustomElementState(Element::Upgraded); - element->AssociateWithDartWrapper(args); -} - -} // namespace DartElementInternal -} // namespace blink diff --git a/sky/engine/bindings/dart_event_listener.cc b/sky/engine/bindings/dart_event_listener.cc deleted file mode 100644 index d65b3437bb86c..0000000000000 --- a/sky/engine/bindings/dart_event_listener.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2015 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 "sky/engine/bindings/dart_event_listener.h" - -#include "sky/engine/core/events/Event.h" -#include "sky/engine/tonic/dart_api_scope.h" -#include "sky/engine/tonic/dart_error.h" -#include "sky/engine/tonic/dart_exception_factory.h" -#include "sky/engine/tonic/dart_gc_visitor.h" -#include "sky/engine/tonic/dart_invoke.h" -#include "sky/engine/tonic/dart_isolate_scope.h" - -namespace blink { - -PassRefPtr DartEventListener::FromDart(Dart_Handle handle) { - if (!Dart_IsClosure(handle)) - return nullptr; - void* peer = nullptr; - CHECK(!Dart_IsError(Dart_GetPeer(handle, &peer))); - if (DartEventListener* listener = static_cast(peer)) - return listener; - RefPtr listener = adoptRef(new DartEventListener(handle)); - listener->data_state_ = DartState::Current()->GetWeakPtr(); - DCHECK(Dart_IsClosure(handle)); - listener->ref(); // Balanced in Finalize - listener->closure_ = Dart_NewPrologueWeakPersistentHandle( - handle, listener.get(), sizeof(*listener), &DartEventListener::Finalize); - CHECK(!Dart_IsError(Dart_SetPeer(handle, listener.get()))); - return listener.release(); -} - -DartEventListener::DartEventListener(Dart_Handle handle) : closure_(nullptr) { -} - -DartEventListener::~DartEventListener() { -} - -void DartEventListener::handleEvent(ExecutionContext* context, Event* event) { - if (!closure_ || !data_state_) - return; - - DartIsolateScope scope(data_state_->isolate()); - DartApiScope api_scope; - - // Notice that we protect ourselves as well as the closure object in the VM. - RefPtr protect(this); - Dart_Handle closure_handle = Dart_HandleFromWeakPersistent(closure_); - Dart_Handle event_handle = ToDart(event); - DCHECK(event_handle); - - Dart_Handle params[] = {event_handle}; - DartInvokeAppClosure(closure_handle, arraysize(params), params); -} - -void DartEventListener::AcceptDartGCVisitor(DartGCVisitor& visitor) const { - CHECK(!Dart_IsError(Dart_AppendValueToWeakReferenceSet( - visitor.current_set(), closure_))); -} - -void DartEventListener::Finalize(void* isolate_callback_data, - Dart_WeakPersistentHandle handle, - void* peer) { - DartEventListener* listener = static_cast(peer); - listener->closure_ = nullptr; - listener->deref(); // Balances ref in DartEventListener::DartEventListener -} - -PassRefPtr -DartConverter::FromArgumentsWithNullCheck( - Dart_NativeArguments args, - int index, - Dart_Handle& exception) { - Dart_Handle handle = Dart_GetNativeArgument(args, index); - if (Dart_IsNull(handle)) { - DartState* state = DartState::Current(); - exception = state->exception_factory().CreateNullArgumentException(index); - return nullptr; - } - return FromDart(handle); -} - -} // namespace blink diff --git a/sky/engine/bindings/dart_event_listener.h b/sky/engine/bindings/dart_event_listener.h deleted file mode 100644 index cb29315668325..0000000000000 --- a/sky/engine/bindings/dart_event_listener.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2015 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. - -#ifndef SKY_ENGINE_BINDINGS_DART_EVENT_LISTENER_H_ -#define SKY_ENGINE_BINDINGS_DART_EVENT_LISTENER_H_ - -#include "dart/runtime/include/dart_api.h" -#include "sky/engine/core/events/EventListener.h" -#include "sky/engine/wtf/PassRefPtr.h" -#include "sky/engine/tonic/dart_converter.h" - -namespace blink { - -class DartEventListener : public EventListener { - public: - static PassRefPtr FromDart(Dart_Handle handle); - - ~DartEventListener() override; - - bool operator==(const EventListener& other) override { - return this == &other; - } - void handleEvent(ExecutionContext*, Event*) override; - - void AcceptDartGCVisitor(DartGCVisitor& visitor) const override; - - private: - explicit DartEventListener(Dart_Handle handle); - - static void Finalize(void* isolate_callback_data, - Dart_WeakPersistentHandle handle, - void* peer); - - base::WeakPtr data_state_; - Dart_WeakPersistentHandle closure_; -}; - -template <> -struct DartConverter { - static PassRefPtr FromDart(Dart_Handle handle) { - return DartEventListener::FromDart(handle); - } - - static PassRefPtr FromArguments(Dart_NativeArguments args, - int index, - Dart_Handle& exception) { - return FromDart(Dart_GetNativeArgument(args, index)); - } - - static PassRefPtr FromArgumentsWithNullCheck( - Dart_NativeArguments args, - int index, - Dart_Handle& exception); -}; - -} // namespace blink - -#endif // SKY_ENGINE_BINDINGS_DART_EVENT_LISTENER_H_ diff --git a/sky/engine/bindings/scheduled_action.cc b/sky/engine/bindings/scheduled_action.cc index 06d465a2e958c..ed3ad42c322e5 100644 --- a/sky/engine/bindings/scheduled_action.cc +++ b/sky/engine/bindings/scheduled_action.cc @@ -19,7 +19,7 @@ ScheduledAction::ScheduledAction(DartState* dart_state, Dart_Handle closure) ScheduledAction::~ScheduledAction() { } -void ScheduledAction::Execute(ExecutionContext*) { +void ScheduledAction::Execute() { if (!closure_.dart_state()) return; DartIsolateScope scope(closure_.dart_state()->isolate()); diff --git a/sky/engine/bindings/scheduled_action.h b/sky/engine/bindings/scheduled_action.h index 4ee40dd913bf7..59e8a311f7114 100644 --- a/sky/engine/bindings/scheduled_action.h +++ b/sky/engine/bindings/scheduled_action.h @@ -24,7 +24,7 @@ class ScheduledAction { ~ScheduledAction(); - void Execute(ExecutionContext*); + void Execute(); private: ScheduledAction(DartState* dart_state, Dart_Handle closure); diff --git a/sky/engine/bindings/scripts/dart_methods.py b/sky/engine/bindings/scripts/dart_methods.py index 8fd541569b622..6f8dbd6622218 100644 --- a/sky/engine/bindings/scripts/dart_methods.py +++ b/sky/engine/bindings/scripts/dart_methods.py @@ -158,13 +158,6 @@ def cpp_argument(argument): if idl_type.name == 'MojoDataPipeConsumer': return '%s.Pass()' % argument_name - if idl_type.name == 'EventListener': - if (interface.name == 'EventTarget' and - method.name == 'removeEventListener'): - # FIXME: remove this special case by moving get() into - # EventTarget::removeEventListener - return '%s.get()' % argument_name - return argument.name if idl_type.is_callback_interface: return '%s.release()' % argument_name return argument_name @@ -235,11 +228,8 @@ def dart_value_to_local_cpp_value(interface, has_type_checking_interface, idl_type = argument.idl_type name = argument.name - # FIXME: V8 has some special logic around the addEventListener and - # removeEventListener methods that should be added in somewhere. - # There is also some logic in systemnative.py to force a null check - # for the useCapture argument of those same methods that we may need to - # pull over. + # TODO(ianh): why don't we need to null-check everything? + # https://github.com/domokit/mojo/issues/280 null_check = ((argument.is_optional and idl_type.is_callback_interface) or (argument.default_value and argument.default_value.is_null)) diff --git a/sky/engine/bindings/scripts/dart_types.py b/sky/engine/bindings/scripts/dart_types.py index ccbfd2404cff2..c1cf1043ee16b 100644 --- a/sky/engine/bindings/scripts/dart_types.py +++ b/sky/engine/bindings/scripts/dart_types.py @@ -52,8 +52,6 @@ class methods. NON_WRAPPER_TYPES = frozenset([ 'CompareHow', 'DartValue', - 'EventHandler', - 'EventListener', 'MediaQueryListListener', 'NodeFilter', ]) @@ -106,7 +104,6 @@ class methods. CPP_SPECIAL_CONVERSION_RULES = { 'CompareHow': 'Range::CompareHow', 'Date': 'double', - 'EventHandler': 'EventListener*', 'MediaQueryListListener': 'RefPtrWillBeRawPtr', 'Promise': 'ScriptPromise', # FIXME: Eliminate custom bindings for XPathNSResolver http://crbug.com/345529 @@ -257,8 +254,6 @@ def includes_for_cpp_class(class_name, relative_dir_posix): INCLUDES_FOR_TYPE = { 'object': set(), 'CompareHow': set(), - 'EventHandler': set(), - 'EventListener': set(), 'MediaQueryListListener': set(['sky/engine/core/css/MediaQueryListListener.h']), 'NodeList': set(['sky/engine/core/dom/NodeList.h', 'sky/engine/core/dom/StaticNodeList.h']), @@ -358,7 +353,6 @@ def pass_by_value_format(typename, null_check="{null_check}"): 'unsigned long long': 'DartConverter::FromArguments(args, {index}, exception)', # Interface types 'CompareHow': 'static_cast(0) /* FIXME, DART_TO_CPP_VALUE[CompareHow] */', - 'EventTarget': '0 /* FIXME, DART_TO_CPP_VALUE[EventTarget] */', 'MediaQueryListListener': 'nullptr /* FIXME, DART_TO_CPP_VALUE[MediaQueryListener] */', 'NodeFilter': 'nullptr /* FIXME, DART_TO_CPP_VALUE[NodeFilter] */', 'Promise': 'DartUtilities::dartToScriptPromise{null_check}(args, {index})', @@ -645,7 +639,6 @@ def dart_conversion_type(idl_type, extended_attributes): # and then use general Dart_SetReturnValue. 'array': 'Dart_SetReturnValue(args, {cpp_value})', 'Date': 'Dart_SetReturnValue(args, {cpp_value})', - 'EventHandler': DART_FIX_ME, 'ScriptPromise': 'Dart_SetReturnValue(args, {cpp_value})', 'DartValue': 'DartConverter::SetReturnValue(args, {cpp_value})', # DOMWrapper @@ -678,7 +671,7 @@ def dom_wrapper_conversion_type(): idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes) this_dart_conversion_type = idl_type.dart_conversion_type(extended_attributes) # SetReturn-specific overrides - if this_dart_conversion_type in ['Date', 'EventHandler', 'ScriptPromise', 'SerializedScriptValue', 'array']: + if this_dart_conversion_type in ['Date', 'ScriptPromise', 'SerializedScriptValue', 'array']: # Convert value to Dart and then use general Dart_SetReturnValue # FIXME(vsm): Why do we differ from V8 here? It doesn't have a # creation_context. @@ -753,8 +746,6 @@ def dart_set_return_value_union(idl_type, cpp_value, extended_attributes=None, 'unrestricted double': 'DartConverter::ToDart({cpp_value})', # FIXME(vsm): Dart_Null? 'void': '', - # Special cases - 'EventHandler': '-----OOPS TO DART-EVENT---', # We need to generate the NullCheck version in some cases. 'ScriptPromise': 'DartUtilities::scriptPromiseToDart({cpp_value})', 'DartValue': 'DartConverter::ToDart({cpp_value})', diff --git a/sky/engine/bindings/scripts/v8_methods.py b/sky/engine/bindings/scripts/v8_methods.py index c1b9834cdf785..5cd6bf8eeb9a1 100644 --- a/sky/engine/bindings/scripts/v8_methods.py +++ b/sky/engine/bindings/scripts/v8_methods.py @@ -200,8 +200,6 @@ def argument_context(interface, method, argument, index): def cpp_value(interface, method, number_of_arguments): def cpp_argument(argument): idl_type = argument.idl_type - if idl_type.name == 'EventListener': - return argument.name if (idl_type.is_callback_interface or idl_type.name in ['NodeFilter', 'NodeFilterOrNull']): # FIXME: remove this special case diff --git a/sky/engine/bindings/scripts/v8_types.py b/sky/engine/bindings/scripts/v8_types.py index 7b54d2d055427..4420f0ed3f849 100644 --- a/sky/engine/bindings/scripts/v8_types.py +++ b/sky/engine/bindings/scripts/v8_types.py @@ -50,8 +50,6 @@ class methods. NON_WRAPPER_TYPES = frozenset([ 'CompareHow', - 'EventHandler', - 'EventListener', 'NodeFilter', 'SerializedScriptValue', ]) @@ -102,7 +100,6 @@ class methods. CPP_SPECIAL_CONVERSION_RULES = { 'CompareHow': 'Range::CompareHow', 'Date': 'double', - 'EventHandler': 'EventListener*', 'Promise': 'ScriptPromise', 'ScriptValue': 'ScriptValue', 'boolean': 'bool', @@ -201,11 +198,6 @@ def includes_for_cpp_class(class_name, relative_dir_posix): INCLUDES_FOR_TYPE = { 'object': set(), 'CompareHow': set(), - 'EventHandler': set(['bindings/core/v8/V8AbstractEventListener.h', - 'bindings/core/v8/V8EventListenerList.h']), - 'EventListener': set(['bindings/core/v8/BindingSecurity.h', - 'bindings/core/v8/V8EventListenerList.h', - 'core/frame/LocalDOMWindow.h']), 'NodeList': set(['bindings/core/v8/V8NodeList.h', 'core/dom/NodeList.h', 'core/dom/StaticNodeList.h']), diff --git a/sky/engine/core/BUILD.gn b/sky/engine/core/BUILD.gn index 0cd1329a539a9..69624dc08bb01 100644 --- a/sky/engine/core/BUILD.gn +++ b/sky/engine/core/BUILD.gn @@ -110,8 +110,6 @@ source_set("testing") { sources = [ "testing/DummyPageHolder.cpp", "testing/DummyPageHolder.h", - "testing/NullExecutionContext.cpp", - "testing/NullExecutionContext.h", "testing/URLTestHelpers.cpp", "testing/URLTestHelpers.h", ] @@ -227,8 +225,6 @@ group("core_names") { deps = [ ":make_core_generated_css_property_names", ":make_core_generated_event_names", - ":make_core_generated_event_target_factory", - ":make_core_generated_event_target_names", ":make_core_generated_event_type_names", ":make_core_generated_html_element_factory", ":make_core_generated_media_type_names", @@ -401,16 +397,6 @@ process_in_files("make_core_generated_media_feature_names") { ] } -# make_event_factory ----------------------------------------------------------- - -make_event_factory("make_core_generated_event_target_factory") { - in_files = [ "events/EventTargetFactory.in" ] - outputs = [ - "$sky_core_output_dir/EventTargetHeaders.h", - "$sky_core_output_dir/EventTargetInterfaces.h", - ] -} - # make_names ------------------------------------------------------------------- make_names("make_core_generated_media_type_names") { @@ -429,14 +415,6 @@ make_names("make_core_generated_event_names") { ] } -make_names("make_core_generated_event_target_names") { - in_files = [ "events/EventTargetFactory.in" ] - outputs = [ - "$sky_core_output_dir/EventTargetNames.cpp", - "$sky_core_output_dir/EventTargetNames.h", - ] -} - make_names("make_core_generated_event_type_names") { in_files = [ "events/EventTypeNames.in" ] outputs = [ diff --git a/sky/engine/core/Init.cpp b/sky/engine/core/Init.cpp index 4694701c9a744..27c40771d0505 100644 --- a/sky/engine/core/Init.cpp +++ b/sky/engine/core/Init.cpp @@ -31,7 +31,6 @@ #include "sky/engine/core/Init.h" #include "gen/sky/core/EventNames.h" -#include "gen/sky/core/EventTargetNames.h" #include "gen/sky/core/EventTypeNames.h" #include "gen/sky/core/HTMLNames.h" #include "gen/sky/core/MediaFeatureNames.h" @@ -52,7 +51,6 @@ void CoreInitializer::init() HTMLNames::init(); EventNames::init(); - EventTargetNames::init(); EventTypeNames::init(); FontFamilyNames::init(); MediaFeatureNames::init(); diff --git a/sky/engine/core/core.gni b/sky/engine/core/core.gni index 7d21c3d7dc919..1399a4f304a6a 100644 --- a/sky/engine/core/core.gni +++ b/sky/engine/core/core.gni @@ -199,8 +199,6 @@ sky_core_files = [ "css/resolver/StyleResolverStats.h", "css/resolver/TransformBuilder.cpp", "css/resolver/TransformBuilder.h", - "dom/ActiveDOMObject.cpp", - "dom/ActiveDOMObject.h", "dom/Attr.cpp", "dom/Attr.h", "dom/Attribute.h", @@ -215,10 +213,6 @@ sky_core_files = [ "dom/ClientRectList.h", "dom/ContainerNode.cpp", "dom/ContainerNode.h", - "dom/ContextLifecycleNotifier.cpp", - "dom/ContextLifecycleNotifier.h", - "dom/ContextLifecycleObserver.cpp", - "dom/ContextLifecycleObserver.h", "dom/DOMError.cpp", "dom/DOMError.h", "dom/DOMException.cpp", @@ -237,12 +231,6 @@ sky_core_files = [ "dom/DocumentFragment.h", "dom/DocumentInit.cpp", "dom/DocumentInit.h", - "dom/DocumentLifecycle.cpp", - "dom/DocumentLifecycle.h", - "dom/DocumentLifecycleNotifier.cpp", - "dom/DocumentLifecycleNotifier.h", - "dom/DocumentLifecycleObserver.cpp", - "dom/DocumentLifecycleObserver.h", "dom/DocumentMarker.cpp", "dom/DocumentMarker.h", "dom/DocumentMarkerController.cpp", @@ -264,9 +252,6 @@ sky_core_files = [ "dom/ElementRareData.h", "dom/ElementTraversal.h", "dom/ExceptionCode.h", - "dom/ExecutionContext.cpp", - "dom/ExecutionContext.h", - "dom/ExecutionContextClient.h", "dom/IncrementLoadEventDelayCount.cpp", "dom/IncrementLoadEventDelayCount.h", "dom/Microtask.cpp", @@ -442,74 +427,36 @@ sky_core_files = [ "events/BeforeTextInsertedEvent.h", "events/CompositionEvent.cpp", "events/CompositionEvent.h", - "events/DOMWindowEventQueue.cpp", - "events/DOMWindowEventQueue.h", "events/ErrorEvent.cpp", "events/ErrorEvent.h", "events/Event.cpp", "events/Event.h", - "events/EventDispatchMediator.cpp", - "events/EventDispatchMediator.h", - "events/EventDispatcher.cpp", - "events/EventDispatcher.h", - "events/EventListener.h", - "events/EventListenerMap.cpp", - "events/EventListenerMap.h", - "events/EventPath.cpp", - "events/EventPath.h", - "events/EventQueue.h", "events/EventSender.h", - "events/EventTarget.cpp", - "events/EventTarget.h", - "events/FocusEvent.cpp", - "events/FocusEvent.h", - "events/GenericEventQueue.cpp", - "events/GenericEventQueue.h", "events/GestureEvent.cpp", "events/GestureEvent.h", - "events/HashChangeEvent.h", "events/KeyboardEvent.cpp", "events/KeyboardEvent.h", - "events/NodeEventContext.cpp", - "events/NodeEventContext.h", "events/PageTransitionEvent.cpp", "events/PageTransitionEvent.h", "events/PointerEvent.cpp", "events/PointerEvent.h", - "events/RegisteredEventListener.h", - "events/ScopedEventQueue.cpp", - "events/ScopedEventQueue.h", "events/TextEvent.cpp", "events/TextEvent.h", "events/TextEventInputType.h", - "events/TreeScopeEventContext.cpp", - "events/TreeScopeEventContext.h", "events/UIEvent.cpp", "events/UIEvent.h", "events/UIEventWithKeyState.cpp", "events/UIEventWithKeyState.h", "events/WheelEvent.cpp", "events/WheelEvent.h", - "events/WindowEventContext.cpp", - "events/WindowEventContext.h", "frame/ConsoleTypes.h", - "frame/DOMTimer.cpp", - "frame/DOMTimer.h", "frame/DOMWindowBase64.cpp", "frame/DOMWindowBase64.h", - "frame/DOMWindowLifecycleNotifier.cpp", - "frame/DOMWindowLifecycleNotifier.h", - "frame/DOMWindowLifecycleObserver.cpp", - "frame/DOMWindowLifecycleObserver.h", "frame/DOMWindowProperty.cpp", "frame/DOMWindowProperty.h", - "frame/DOMWindowTimers.cpp", - "frame/DOMWindowTimers.h", "frame/Frame.cpp", "frame/Frame.h", "frame/FrameClient.h", - "frame/FrameConsole.cpp", - "frame/FrameConsole.h", "frame/FrameDestructionObserver.cpp", "frame/FrameDestructionObserver.h", "frame/FrameHost.cpp", @@ -523,16 +470,12 @@ sky_core_files = [ "frame/LocalFrame.h", "frame/Location.cpp", "frame/Location.h", - "frame/NewEventHandler.cpp", - "frame/NewEventHandler.h", "frame/Screen.cpp", "frame/Screen.h", "frame/Settings.cpp", "frame/Settings.h", "frame/SettingsDelegate.cpp", "frame/SettingsDelegate.h", - "frame/SuspendableTimer.cpp", - "frame/SuspendableTimer.h", "frame/Tracing.cpp", "frame/Tracing.h", "html/parser/HTMLParserIdioms.cpp", @@ -558,7 +501,6 @@ sky_core_files = [ "inspector/ScriptCallFrame.h", "inspector/ScriptCallStack.cpp", "inspector/ScriptCallStack.h", - "inspector/ScriptGCEventListener.h", "layout/LayoutCallback.h", "loader/CanvasImageDecoder.cpp", "loader/CanvasImageDecoder.h", @@ -576,17 +518,11 @@ sky_core_files = [ "loader/UniqueIdentifier.h", "page/ChromeClient.h", "page/EditorClient.h", - "page/EventHandler.cpp", - "page/EventHandler.h", "page/FocusController.cpp", "page/FocusController.h", "page/FocusType.h", "page/Page.cpp", "page/Page.h", - "page/PageLifecycleNotifier.cpp", - "page/PageLifecycleNotifier.h", - "page/PageLifecycleObserver.cpp", - "page/PageLifecycleObserver.h", "page/SpellCheckerClient.h", "painting/Canvas.cpp", "painting/Canvas.h", @@ -813,7 +749,6 @@ core_idl_files = get_path_info([ "css/CSS.idl", "css/CSSMatrix.idl", "css/CSSStyleDeclaration.idl", - "css/FontFace.idl", "css/MediaQueryList.idl", "css/MediaQueryListEvent.idl", "dom/Attr.idl", @@ -840,10 +775,7 @@ core_idl_files = get_path_info([ "events/CompositionEvent.idl", "events/ErrorEvent.idl", "events/Event.idl", - "events/EventTarget.idl", - "events/FocusEvent.idl", "events/GestureEvent.idl", - "events/HashChangeEvent.idl", "events/KeyboardEvent.idl", "events/PageTransitionEvent.idl", "events/PointerEvent.idl", @@ -907,9 +839,7 @@ core_dart_files = get_path_info([ core_dependency_idl_files = get_path_info([ "dom/URLUtils.idl", "dom/URLUtilsReadOnly.idl", - "events/EventListener.idl", "frame/WindowBase64.idl", - "frame/WindowTimers.idl", ], "abspath") @@ -919,9 +849,7 @@ core_event_idl_files = get_path_info([ "events/CompositionEvent.idl", "events/ErrorEvent.idl", "events/Event.idl", - "events/FocusEvent.idl", "events/GestureEvent.idl", - "events/HashChangeEvent.idl", "events/KeyboardEvent.idl", "events/PageTransitionEvent.idl", "events/PointerEvent.idl", diff --git a/sky/engine/core/css/CSSStyleSheet.cpp b/sky/engine/core/css/CSSStyleSheet.cpp index 12b337059fdab..f607f345752f3 100644 --- a/sky/engine/core/css/CSSStyleSheet.cpp +++ b/sky/engine/core/css/CSSStyleSheet.cpp @@ -67,9 +67,6 @@ CSSStyleSheet::~CSSStyleSheet() void CSSStyleSheet::setMediaQueries(PassRefPtr mediaQueries) { m_mediaQueries = mediaQueries; - - // Add warning message to inspector whenever dpi/dpcm values are used for "screen" media. - reportMediaQueryWarningIfNeeded(ownerDocument(), m_mediaQueries.get()); } void CSSStyleSheet::clearOwnerNode() diff --git a/sky/engine/core/css/FontFace.cpp b/sky/engine/core/css/FontFace.cpp index 5f678114bce65..2d3d0111d7fb2 100644 --- a/sky/engine/core/css/FontFace.cpp +++ b/sky/engine/core/css/FontFace.cpp @@ -63,32 +63,6 @@ static PassRefPtr parseCSSValue(const Document* document, const String return parsedStyle->getPropertyCSSValue(propertyID); } -PassRefPtr FontFace::create(ExecutionContext* context, const AtomicString& family, const String& source) -{ - RefPtr fontFace = adoptRef(new FontFace(context, family)); - - RefPtr src = parseCSSValue(toDocument(context), source, CSSPropertySrc); - if (!src || !src->isValueList()) - fontFace->setError(DOMException::create(SyntaxError, "The source provided ('" + source + "') could not be parsed as a value list.")); - - fontFace->initCSSFontFace(toDocument(context), src); - return fontFace.release(); -} - -PassRefPtr FontFace::create(ExecutionContext* context, const AtomicString& family, PassRefPtr source) -{ - RefPtr fontFace = adoptRef(new FontFace(context, family)); - fontFace->initCSSFontFace(static_cast(source->data()), source->byteLength()); - return fontFace.release(); -} - -PassRefPtr FontFace::create(ExecutionContext* context, const AtomicString& family, PassRefPtr source) -{ - RefPtr fontFace = adoptRef(new FontFace(context, family)); - fontFace->initCSSFontFace(static_cast(source->baseAddress()), source->byteLength()); - return fontFace.release(); -} - PassRefPtr FontFace::create(Document* document, const StyleRuleFontFace* fontFaceRule) { const StylePropertySet& properties = fontFaceRule->properties(); @@ -123,7 +97,7 @@ FontFace::FontFace() { } -FontFace::FontFace(ExecutionContext* context, const AtomicString& family) +FontFace::FontFace(const AtomicString& family) : m_family(family) , m_status(Unloaded) { @@ -163,36 +137,6 @@ String FontFace::featureSettings() const return m_featureSettings ? m_featureSettings->cssText() : "normal"; } -void FontFace::setStyle(ExecutionContext* context, const String& s, ExceptionState& exceptionState) -{ - setPropertyFromString(toDocument(context), s, CSSPropertyFontStyle, &exceptionState); -} - -void FontFace::setWeight(ExecutionContext* context, const String& s, ExceptionState& exceptionState) -{ - setPropertyFromString(toDocument(context), s, CSSPropertyFontWeight, &exceptionState); -} - -void FontFace::setStretch(ExecutionContext* context, const String& s, ExceptionState& exceptionState) -{ - setPropertyFromString(toDocument(context), s, CSSPropertyFontStretch, &exceptionState); -} - -void FontFace::setUnicodeRange(ExecutionContext* context, const String& s, ExceptionState& exceptionState) -{ - setPropertyFromString(toDocument(context), s, CSSPropertyUnicodeRange, &exceptionState); -} - -void FontFace::setVariant(ExecutionContext* context, const String& s, ExceptionState& exceptionState) -{ - setPropertyFromString(toDocument(context), s, CSSPropertyFontVariant, &exceptionState); -} - -void FontFace::setFeatureSettings(ExecutionContext* context, const String& s, ExceptionState& exceptionState) -{ - setPropertyFromString(toDocument(context), s, CSSPropertyWebkitFontFeatureSettings, &exceptionState); -} - void FontFace::setPropertyFromString(const Document* document, const String& s, CSSPropertyID propertyID, ExceptionState* exceptionState) { RefPtr value = parseCSSValue(document, s, propertyID); @@ -322,9 +266,8 @@ void FontFace::setError(PassRefPtr error) setLoadStatus(Error); } -void FontFace::loadWithCallback(PassRefPtr callback, ExecutionContext* context) +void FontFace::loadWithCallback(PassRefPtr callback) { - loadInternal(context); if (m_status == Loaded) callback->notifyLoaded(this); else if (m_status == Error) @@ -333,14 +276,6 @@ void FontFace::loadWithCallback(PassRefPtr callback, Execution m_callbacks.append(callback); } -void FontFace::loadInternal(ExecutionContext* context) -{ - if (m_status != Unloaded) - return; - - m_cssFontFace->load(); -} - FontTraits FontFace::traits() const { FontStyle style = FontStyleNormal; diff --git a/sky/engine/core/css/FontFace.h b/sky/engine/core/css/FontFace.h index f8effd95e0004..871b66ba1180c 100644 --- a/sky/engine/core/css/FontFace.h +++ b/sky/engine/core/css/FontFace.h @@ -46,19 +46,14 @@ class CSSFontFace; class CSSValueList; class Document; class ExceptionState; -class ExecutionContext; class FontFaceReadyPromiseResolver; class StylePropertySet; class StyleRuleFontFace; -class FontFace : public RefCounted, public DartWrappable { - DEFINE_WRAPPERTYPEINFO(); +class FontFace : public RefCounted { public: enum LoadStatus { Unloaded, Loading, Loaded, Error }; - static PassRefPtr create(ExecutionContext*, const AtomicString& family, PassRefPtr source); - static PassRefPtr create(ExecutionContext*, const AtomicString& family, PassRefPtr); - static PassRefPtr create(ExecutionContext*, const AtomicString& family, const String& source); static PassRefPtr create(Document*, const StyleRuleFontFace*); ~FontFace(); @@ -71,15 +66,6 @@ class FontFace : public RefCounted, public DartWrappable { String variant() const; String featureSettings() const; - // FIXME: Changing these attributes should affect font matching. - void setFamily(ExecutionContext*, const AtomicString& s, ExceptionState&) { m_family = s; } - void setStyle(ExecutionContext*, const String&, ExceptionState&); - void setWeight(ExecutionContext*, const String&, ExceptionState&); - void setStretch(ExecutionContext*, const String&, ExceptionState&); - void setUnicodeRange(ExecutionContext*, const String&, ExceptionState&); - void setVariant(ExecutionContext*, const String&, ExceptionState&); - void setFeatureSettings(ExecutionContext*, const String&, ExceptionState&); - String status() const; LoadStatus loadStatus() const { return m_status; } @@ -97,11 +83,11 @@ class FontFace : public RefCounted, public DartWrappable { virtual void notifyLoaded(FontFace*) = 0; virtual void notifyError(FontFace*) = 0; }; - void loadWithCallback(PassRefPtr, ExecutionContext*); + void loadWithCallback(PassRefPtr); private: FontFace(); - FontFace(ExecutionContext*, const AtomicString& family); + FontFace(const AtomicString& family); void initCSSFontFace(Document*, PassRefPtr src); void initCSSFontFace(const unsigned char* data, unsigned size); @@ -109,7 +95,6 @@ class FontFace : public RefCounted, public DartWrappable { bool setPropertyFromStyle(const StylePropertySet&, CSSPropertyID); bool setPropertyValue(PassRefPtr, CSSPropertyID); bool setFamilyValue(CSSValueList*); - void loadInternal(ExecutionContext*); AtomicString m_family; RefPtr m_src; diff --git a/sky/engine/core/css/FontFace.idl b/sky/engine/core/css/FontFace.idl deleted file mode 100644 index 96fbd3d7c8195..0000000000000 --- a/sky/engine/core/css/FontFace.idl +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// http://dev.w3.org/csswg/css-font-loading/#dom-fontface - -enum FontFaceLoadStatus { - "unloaded", - "loading", - "loaded", - "error" -}; - -[ - // FIXME: should be union type http://crbug.com/240176 - // FIXME(Dictionary): descriptors - Constructor(DOMString family, DOMString source), - ConstructorCallWith=ExecutionContext, -] interface FontFace { - - [RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString family; - [RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString style; - [RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString weight; - [RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString stretch; - [RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString unicodeRange; - [RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString variant; - [RaisesException=Setter, SetterCallWith=ExecutionContext] attribute DOMString featureSettings; - - readonly attribute FontFaceLoadStatus status; -}; diff --git a/sky/engine/core/css/MediaList.cpp b/sky/engine/core/css/MediaList.cpp index 2dd76d787bd6b..1720450eb5b30 100644 --- a/sky/engine/core/css/MediaList.cpp +++ b/sky/engine/core/css/MediaList.cpp @@ -28,7 +28,6 @@ #include "sky/engine/core/css/parser/MediaQueryParser.h" #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/frame/LocalDOMWindow.h" -#include "sky/engine/core/inspector/ConsoleMessage.h" #include "sky/engine/wtf/text/StringBuilder.h" namespace blink { @@ -174,29 +173,6 @@ MediaList::~MediaList() { } -static void addResolutionWarningMessageToConsole(Document* document, const String& serializedExpression, CSSPrimitiveValue::UnitType type) -{ - ASSERT(document); - - DEFINE_STATIC_LOCAL(String, mediaQueryMessage, ("Consider using 'dppx' units, as in CSS '%replacementUnits%' means dots-per-CSS-%lengthUnit%, not dots-per-physical-%lengthUnit%, so does not correspond to the actual '%replacementUnits%' of a screen. In media query expression: ")); - DEFINE_STATIC_LOCAL(String, mediaValueDPI, ("dpi")); - DEFINE_STATIC_LOCAL(String, mediaValueDPCM, ("dpcm")); - DEFINE_STATIC_LOCAL(String, lengthUnitInch, ("inch")); - DEFINE_STATIC_LOCAL(String, lengthUnitCentimeter, ("centimeter")); - - StringBuilder message; - if (CSSPrimitiveValue::isDotsPerInch(type)) - message.append(String(mediaQueryMessage).replace("%replacementUnits%", mediaValueDPI).replace("%lengthUnit%", lengthUnitInch)); - else if (CSSPrimitiveValue::isDotsPerCentimeter(type)) - message.append(String(mediaQueryMessage).replace("%replacementUnits%", mediaValueDPCM).replace("%lengthUnit%", lengthUnitCentimeter)); - else - ASSERT_NOT_REACHED(); - - message.append(serializedExpression); - - document->addConsoleMessage(ConsoleMessage::create(CSSMessageSource, DebugMessageLevel, message.toString())); -} - static inline bool isResolutionMediaFeature(const String& mediaFeature) { return mediaFeature == MediaFeatureNames::resolutionMediaFeature @@ -236,9 +212,6 @@ void reportMediaQueryWarningIfNeeded(Document* document, const MediaQuerySet* me } } } - - if (suspiciousType && !dotsPerPixelUsed) - addResolutionWarningMessageToConsole(document, mediaQuerySet->mediaText(), suspiciousType); } } diff --git a/sky/engine/core/css/MediaList.h b/sky/engine/core/css/MediaList.h index 1981783148417..e4e98694b1da5 100644 --- a/sky/engine/core/css/MediaList.h +++ b/sky/engine/core/css/MediaList.h @@ -96,9 +96,6 @@ class MediaList : public RefCounted { RawPtr m_parentStyleSheet; }; -// Adds message to inspector console whenever dpi or dpcm values are used for "screen" media. -void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*); - } // namespace blink #endif // SKY_ENGINE_CORE_CSS_MEDIALIST_H_ diff --git a/sky/engine/core/css/MediaQueryList.cpp b/sky/engine/core/css/MediaQueryList.cpp index e9bae9f85556a..891559540c2af 100644 --- a/sky/engine/core/css/MediaQueryList.cpp +++ b/sky/engine/core/css/MediaQueryList.cpp @@ -18,7 +18,7 @@ */ #include "sky/engine/core/css/MediaQueryList.h" - +#include "gen/sky/core/EventTargetNames.h" #include "sky/engine/core/css/MediaList.h" #include "sky/engine/core/css/MediaQueryEvaluator.h" #include "sky/engine/core/css/MediaQueryListListener.h" @@ -27,16 +27,14 @@ namespace blink { -PassRefPtr MediaQueryList::create(ExecutionContext* context, PassRefPtr matcher, PassRefPtr media) +PassRefPtr MediaQueryList::create(PassRefPtr matcher, PassRefPtr media) { - RefPtr list = adoptRef(new MediaQueryList(context, matcher, media)); - list->suspendIfNeeded(); + RefPtr list = adoptRef(new MediaQueryList(matcher, media)); return list.release(); } -MediaQueryList::MediaQueryList(ExecutionContext* context, PassRefPtr matcher, PassRefPtr media) - : ActiveDOMObject(context) - , m_matcher(matcher) +MediaQueryList::MediaQueryList(PassRefPtr matcher, PassRefPtr media) + : m_matcher(matcher) , m_media(media) , m_matchesDirty(true) , m_matches(false) @@ -47,9 +45,7 @@ MediaQueryList::MediaQueryList(ExecutionContext* context, PassRefPtrremoveMediaQueryList(this); -#endif } String MediaQueryList::media() const @@ -57,16 +53,6 @@ String MediaQueryList::media() const return m_media->mediaText(); } -void MediaQueryList::addDeprecatedListener(PassRefPtr listener) -{ - addEventListener(EventTypeNames::change, listener, false); -} - -void MediaQueryList::removeDeprecatedListener(PassRefPtr listener) -{ - removeEventListener(EventTypeNames::change, listener, false); -} - void MediaQueryList::addListener(PassRefPtr listener) { if (!listener) @@ -84,19 +70,6 @@ void MediaQueryList::removeListener(PassRefPtr listener) m_listeners.remove(listener); } -bool MediaQueryList::hasPendingActivity() const -{ - return m_listeners.size() || hasEventListeners(EventTypeNames::change); -} - -void MediaQueryList::stop() -{ - // m_listeners.clear() can drop the last ref to this MediaQueryList. - RefPtr protect(this); - m_listeners.clear(); - removeAllEventListeners(); -} - bool MediaQueryList::mediaFeaturesChanged(Vector >* listenersToNotify) { m_matchesDirty = true; @@ -105,7 +78,7 @@ bool MediaQueryList::mediaFeaturesChanged(Vector for (ListenerList::const_iterator it = m_listeners.begin(), end = m_listeners.end(); it != end; ++it) { listenersToNotify->append(*it); } - return hasEventListeners(EventTypeNames::change); + return false; } bool MediaQueryList::updateMatches() @@ -124,14 +97,4 @@ bool MediaQueryList::matches() return m_matches; } -const AtomicString& MediaQueryList::interfaceName() const -{ - return EventTargetNames::MediaQueryList; -} - -ExecutionContext* MediaQueryList::executionContext() const -{ - return ActiveDOMObject::executionContext(); -} - } diff --git a/sky/engine/core/css/MediaQueryList.h b/sky/engine/core/css/MediaQueryList.h index 60189033eb83f..4e4d725d5c758 100644 --- a/sky/engine/core/css/MediaQueryList.h +++ b/sky/engine/core/css/MediaQueryList.h @@ -20,10 +20,8 @@ #ifndef SKY_ENGINE_CORE_CSS_MEDIAQUERYLIST_H_ #define SKY_ENGINE_CORE_CSS_MEDIAQUERYLIST_H_ -#include "sky/engine/tonic/dart_wrappable.h" -#include "sky/engine/core/dom/ActiveDOMObject.h" -#include "sky/engine/core/events/EventTarget.h" #include "sky/engine/platform/heap/Handle.h" +#include "sky/engine/tonic/dart_wrappable.h" #include "sky/engine/wtf/Forward.h" #include "sky/engine/wtf/LinkedHashSet.h" #include "sky/engine/wtf/ListHashSet.h" @@ -44,21 +42,15 @@ class MediaQuerySet; // retrieve the current value of the given media query and to add/remove listeners that // will be called whenever the value of the query changes. -class MediaQueryList final : public RefCounted, public EventTargetWithInlineData, public ActiveDOMObject { - DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCounted); +class MediaQueryList final : public DartWrappable, public RefCounted { DEFINE_WRAPPERTYPEINFO(); public: - static PassRefPtr create(ExecutionContext*, PassRefPtr, PassRefPtr); + static PassRefPtr create(PassRefPtr, PassRefPtr); virtual ~MediaQueryList(); String media() const; bool matches(); - // These two functions are provided for compatibility with JS code - // written before the change listener became a DOM event. - void addDeprecatedListener(PassRefPtr); - void removeDeprecatedListener(PassRefPtr); - // C++ code can use these functions to listen to changes instead of having to use DOM event listeners. void addListener(PassRefPtr); void removeListener(PassRefPtr); @@ -66,15 +58,8 @@ class MediaQueryList final : public RefCounted, public EventTarg // Will return true if a DOM event should be scheduled. bool mediaFeaturesChanged(Vector >* listenersToNotify); - // From ActiveDOMObject - virtual bool hasPendingActivity() const override; - virtual void stop() override; - - virtual const AtomicString& interfaceName() const override; - virtual ExecutionContext* executionContext() const override; - private: - MediaQueryList(ExecutionContext*, PassRefPtr, PassRefPtr); + MediaQueryList(PassRefPtr, PassRefPtr); bool updateMatches(); diff --git a/sky/engine/core/css/MediaQueryList.idl b/sky/engine/core/css/MediaQueryList.idl index 8418e4a4443d0..099ef25cf40cb 100644 --- a/sky/engine/core/css/MediaQueryList.idl +++ b/sky/engine/core/css/MediaQueryList.idl @@ -19,9 +19,8 @@ // http://dev.w3.org/csswg/cssom-view/#mediaquerylist [ - ActiveDOMObject, NoInterfaceObject, -] interface MediaQueryList : EventTarget { +] interface MediaQueryList { readonly attribute DOMString media; readonly attribute boolean matches; }; diff --git a/sky/engine/core/css/MediaQueryListEvent.h b/sky/engine/core/css/MediaQueryListEvent.h index 11bb71ce1ace2..a8b66053d9a9e 100644 --- a/sky/engine/core/css/MediaQueryListEvent.h +++ b/sky/engine/core/css/MediaQueryListEvent.h @@ -5,6 +5,8 @@ #ifndef SKY_ENGINE_CORE_CSS_MEDIAQUERYLISTEVENT_H_ #define SKY_ENGINE_CORE_CSS_MEDIAQUERYLISTEVENT_H_ +#include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" #include "sky/engine/core/css/MediaQueryList.h" #include "sky/engine/core/events/Event.h" diff --git a/sky/engine/core/css/MediaQueryListTest.cpp b/sky/engine/core/css/MediaQueryListTest.cpp index 47868aa8e5ba9..fa529e06e600e 100644 --- a/sky/engine/core/css/MediaQueryListTest.cpp +++ b/sky/engine/core/css/MediaQueryListTest.cpp @@ -24,7 +24,7 @@ namespace blink { TEST(MediaQueryListTest, CrashInStop) { RefPtr document = Document::create(); - RefPtr list = MediaQueryList::create(document.get(), MediaQueryMatcher::create(*document), MediaQuerySet::create()); + RefPtr list = MediaQueryList::create(MediaQueryMatcher::create(*document), MediaQuerySet::create()); list->addListener(adoptRef(new TestListener())); list->stop(); // This test passes if it's not crashed. diff --git a/sky/engine/core/css/MediaQueryMatcher.cpp b/sky/engine/core/css/MediaQueryMatcher.cpp index 9303ffcb28df6..2232bc93688ab 100644 --- a/sky/engine/core/css/MediaQueryMatcher.cpp +++ b/sky/engine/core/css/MediaQueryMatcher.cpp @@ -30,6 +30,10 @@ #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/wtf/Vector.h" +// Note: when removing EventTarget, the MediaQuery logic was +// disconnected from Documents, and as part of that, the +// viewportChanged and mediaFeaturesChanged methods were dropped. + namespace blink { PassRefPtr MediaQueryMatcher::create(Document& document) @@ -82,9 +86,7 @@ PassRefPtr MediaQueryMatcher::matchMedia(const String& query) return nullptr; RefPtr media = MediaQuerySet::create(query); - // Add warning message to inspector whenever dpi/dpcm values are used for "screen" media. - reportMediaQueryWarningIfNeeded(m_document, media.get()); - return MediaQueryList::create(m_document, this, media); + return MediaQueryList::create(this, media); } void MediaQueryMatcher::addMediaQueryList(MediaQueryList* query) @@ -115,32 +117,4 @@ void MediaQueryMatcher::removeViewportListener(MediaQueryListListener* listener) m_viewportListeners.remove(listener); } -void MediaQueryMatcher::mediaFeaturesChanged() -{ - if (!m_document) - return; - - Vector > listenersToNotify; - for (MediaQueryListSet::iterator it = m_mediaLists.begin(); it != m_mediaLists.end(); ++it) { - if ((*it)->mediaFeaturesChanged(&listenersToNotify)) { - RefPtr event(MediaQueryListEvent::create(*it)); - event->setTarget(*it); - m_document->enqueueUniqueAnimationFrameEvent(event); - } - } - m_document->enqueueMediaQueryChangeListeners(listenersToNotify); -} - -void MediaQueryMatcher::viewportChanged() -{ - if (!m_document) - return; - - Vector > listenersToNotify; - for (ViewportListenerSet::iterator it = m_viewportListeners.begin(); it != m_viewportListeners.end(); ++it) - listenersToNotify.append(*it); - - m_document->enqueueMediaQueryChangeListeners(listenersToNotify); -} - } diff --git a/sky/engine/core/css/MediaQueryMatcher.h b/sky/engine/core/css/MediaQueryMatcher.h index 7ab5701bdc894..85aac147d6932 100644 --- a/sky/engine/core/css/MediaQueryMatcher.h +++ b/sky/engine/core/css/MediaQueryMatcher.h @@ -54,7 +54,6 @@ class MediaQueryMatcher final : public RefCounted { PassRefPtr matchMedia(const String&); - void mediaFeaturesChanged(); void viewportChanged(); bool evaluate(const MediaQuerySet*); diff --git a/sky/engine/core/css/parser/BisonCSSParser-in.cpp b/sky/engine/core/css/parser/BisonCSSParser-in.cpp index 60f99ac98f7d1..22f409a6ca337 100644 --- a/sky/engine/core/css/parser/BisonCSSParser-in.cpp +++ b/sky/engine/core/css/parser/BisonCSSParser-in.cpp @@ -56,7 +56,6 @@ #include "sky/engine/core/css/StyleSheetContents.h" #include "sky/engine/core/css/parser/CSSParserIdioms.h" #include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/frame/FrameConsole.h" #include "sky/engine/core/frame/FrameHost.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" @@ -66,6 +65,7 @@ #include "sky/engine/platform/FloatConversion.h" #include "sky/engine/wtf/BitArray.h" #include "sky/engine/wtf/HexNumber.h" +#include "sky/engine/wtf/TemporaryChange.h" #include "sky/engine/wtf/text/StringBuffer.h" #include "sky/engine/wtf/text/StringBuilder.h" #include "sky/engine/wtf/text/StringImpl.h" diff --git a/sky/engine/core/dom/ActiveDOMObject.cpp b/sky/engine/core/dom/ActiveDOMObject.cpp deleted file mode 100644 index c050b5aa0e6c7..0000000000000 --- a/sky/engine/core/dom/ActiveDOMObject.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/dom/ActiveDOMObject.h" - -#include "sky/engine/core/dom/ExecutionContext.h" - -namespace blink { - -ActiveDOMObject::ActiveDOMObject(ExecutionContext* executionContext) - : ContextLifecycleObserver(executionContext, ActiveDOMObjectType) -#if ENABLE(ASSERT) - , m_suspendIfNeededCalled(false) -#endif -{ - ASSERT(!executionContext || executionContext->isContextThread()); -} - -ActiveDOMObject::~ActiveDOMObject() -{ - // ActiveDOMObject may be inherited by a sub-class whose life-cycle - // exceeds that of the associated ExecutionContext. In those cases, - // m_executionContext would/should have been nullified by - // ContextLifecycleObserver::contextDestroyed() (which we implement / - // inherit). Hence, we should ensure that this is not 0 before use it - // here. - if (!executionContext()) - return; - - ASSERT(m_suspendIfNeededCalled); - ASSERT(executionContext()->isContextThread()); -} - -void ActiveDOMObject::suspendIfNeeded() -{ -#if ENABLE(ASSERT) - ASSERT(!m_suspendIfNeededCalled); - m_suspendIfNeededCalled = true; -#endif - if (ExecutionContext* context = executionContext()) - context->suspendActiveDOMObjectIfNeeded(this); -} - -bool ActiveDOMObject::hasPendingActivity() const -{ - return false; -} - -void ActiveDOMObject::suspend() -{ -} - -void ActiveDOMObject::resume() -{ -} - -void ActiveDOMObject::stop() -{ -} - -void ActiveDOMObject::didMoveToNewExecutionContext(ExecutionContext* context) -{ - observeContext(context); - - if (context->activeDOMObjectsAreStopped()) { - stop(); - return; - } - - if (context->activeDOMObjectsAreSuspended()) { - suspend(); - return; - } - - resume(); -} - -} // namespace blink diff --git a/sky/engine/core/dom/ActiveDOMObject.h b/sky/engine/core/dom/ActiveDOMObject.h deleted file mode 100644 index dcb7b58825282..0000000000000 --- a/sky/engine/core/dom/ActiveDOMObject.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_DOM_ACTIVEDOMOBJECT_H_ -#define SKY_ENGINE_CORE_DOM_ACTIVEDOMOBJECT_H_ - -#include "sky/engine/core/dom/ContextLifecycleObserver.h" -#include "sky/engine/wtf/Assertions.h" - -namespace blink { - -class ActiveDOMObject : public ContextLifecycleObserver { -public: - ActiveDOMObject(ExecutionContext*); - - // suspendIfNeeded() should be called exactly once after object construction to synchronize - // the suspend state with that in ExecutionContext. - void suspendIfNeeded(); -#if ENABLE(ASSERT) - bool suspendIfNeededCalled() const { return m_suspendIfNeededCalled; } -#endif - - // Should return true if there's any pending asynchronous activity, and so - // this object must not be garbage collected. - virtual bool hasPendingActivity() const; - - // These methods have an empty default implementation so that subclasses - // which don't need special treatment can skip implementation. - virtual void suspend(); - virtual void resume(); - virtual void stop(); - - void didMoveToNewExecutionContext(ExecutionContext*); - -protected: - virtual ~ActiveDOMObject(); - -private: -#if ENABLE(ASSERT) - bool m_suspendIfNeededCalled; -#endif -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_ACTIVEDOMOBJECT_H_ diff --git a/sky/engine/core/dom/ActiveDOMObjectTest.cpp b/sky/engine/core/dom/ActiveDOMObjectTest.cpp deleted file mode 100644 index 072527b05f02a..0000000000000 --- a/sky/engine/core/dom/ActiveDOMObjectTest.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2014, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include -#include -#include "core/testing/DummyPageHolder.h" -#include "sky/engine/core/dom/Document.h" - -using namespace blink; - -namespace { - -class MockActiveDOMObject : public ActiveDOMObject { -public: - MockActiveDOMObject(ExecutionContext* context) : ActiveDOMObject(context) { } - - MOCK_METHOD0(suspend, void()); - MOCK_METHOD0(resume, void()); - MOCK_METHOD0(stop, void()); -}; - -class ActiveDOMObjectTest : public ::testing::Test { -protected: - ActiveDOMObjectTest(); - - Document& srcDocument() const { return m_srcPageHolder->document(); } - Document& destDocument() const { return m_destPageHolder->document(); } - MockActiveDOMObject& activeDOMObject() { return m_activeDOMObject; } - -private: - OwnPtr m_srcPageHolder; - OwnPtr m_destPageHolder; - MockActiveDOMObject m_activeDOMObject; -}; - -ActiveDOMObjectTest::ActiveDOMObjectTest() - : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600))) - , m_destPageHolder(DummyPageHolder::create(IntSize(800, 600))) - , m_activeDOMObject(&m_srcPageHolder->document()) -{ - m_activeDOMObject.suspendIfNeeded(); -} - -TEST_F(ActiveDOMObjectTest, NewContextObserved) -{ - unsigned initialSrcCount = srcDocument().activeDOMObjectCount(); - unsigned initialDestCount = destDocument().activeDOMObjectCount(); - - EXPECT_CALL(activeDOMObject(), resume()); - activeDOMObject().didMoveToNewExecutionContext(&destDocument()); - - EXPECT_EQ(initialSrcCount - 1, srcDocument().activeDOMObjectCount()); - EXPECT_EQ(initialDestCount + 1, destDocument().activeDOMObjectCount()); -} - -TEST_F(ActiveDOMObjectTest, MoveToActiveDocument) -{ - EXPECT_CALL(activeDOMObject(), resume()); - activeDOMObject().didMoveToNewExecutionContext(&destDocument()); -} - -TEST_F(ActiveDOMObjectTest, MoveToStoppedDocument) -{ - destDocument().detach(); - - EXPECT_CALL(activeDOMObject(), stop()); - activeDOMObject().didMoveToNewExecutionContext(&destDocument()); -} - -} // unnamed namespace diff --git a/sky/engine/core/dom/ContextLifecycleNotifier.cpp b/sky/engine/core/dom/ContextLifecycleNotifier.cpp deleted file mode 100644 index 9ace492db6dff..0000000000000 --- a/sky/engine/core/dom/ContextLifecycleNotifier.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/dom/ContextLifecycleNotifier.h" - -#include "sky/engine/core/dom/ExecutionContext.h" -#include "sky/engine/wtf/TemporaryChange.h" - -namespace blink { - -ContextLifecycleNotifier::ContextLifecycleNotifier(ExecutionContext* context) - : LifecycleNotifier(context) -{ -} - -ContextLifecycleNotifier::~ContextLifecycleNotifier() -{ -} - -void ContextLifecycleNotifier::addObserver(ContextLifecycleNotifier::Observer* observer) -{ - LifecycleNotifier::addObserver(observer); - - RELEASE_ASSERT(m_iterating != IteratingOverContextObservers); - if (observer->observerType() == Observer::ActiveDOMObjectType) { - RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects); - m_activeDOMObjects.add(static_cast(observer)); - } -} - -void ContextLifecycleNotifier::removeObserver(ContextLifecycleNotifier::Observer* observer) -{ - LifecycleNotifier::removeObserver(observer); - - RELEASE_ASSERT(m_iterating != IteratingOverContextObservers); - if (observer->observerType() == Observer::ActiveDOMObjectType) { - m_activeDOMObjects.remove(static_cast(observer)); - } -} - -void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() -{ - TemporaryChange scope(this->m_iterating, IteratingOverActiveDOMObjects); - Vector snapshotOfActiveDOMObjects; - copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); - for (Vector::iterator iter = snapshotOfActiveDOMObjects.begin(); iter != snapshotOfActiveDOMObjects.end(); iter++) { - // FIXME: Oilpan: At the moment, it's possible that the ActiveDOMObject is destructed - // during the iteration. Once we move ActiveDOMObject to the heap and - // make m_activeDOMObjects a HeapHashSet>, - // it's no longer possible that ActiveDOMObject is destructed during the iteration, - // so we can remove the hack (i.e., we can just iterate m_activeDOMObjects without - // taking a snapshot). For more details, see https://codereview.chromium.org/247253002/. - if (m_activeDOMObjects.contains(*iter)) { - ASSERT((*iter)->executionContext() == context()); - ASSERT((*iter)->suspendIfNeededCalled()); - (*iter)->resume(); - } - } -} - -void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects() -{ - TemporaryChange scope(this->m_iterating, IteratingOverActiveDOMObjects); - Vector snapshotOfActiveDOMObjects; - copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); - for (Vector::iterator iter = snapshotOfActiveDOMObjects.begin(); iter != snapshotOfActiveDOMObjects.end(); iter++) { - // It's possible that the ActiveDOMObject is already destructed. - // See a FIXME above. - if (m_activeDOMObjects.contains(*iter)) { - ASSERT((*iter)->executionContext() == context()); - ASSERT((*iter)->suspendIfNeededCalled()); - (*iter)->suspend(); - } - } -} - -void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects() -{ - TemporaryChange scope(this->m_iterating, IteratingOverActiveDOMObjects); - Vector snapshotOfActiveDOMObjects; - copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); - for (Vector::iterator iter = snapshotOfActiveDOMObjects.begin(); iter != snapshotOfActiveDOMObjects.end(); iter++) { - // It's possible that the ActiveDOMObject is already destructed. - // See a FIXME above. - if (m_activeDOMObjects.contains(*iter)) { - ASSERT((*iter)->executionContext() == context()); - ASSERT((*iter)->suspendIfNeededCalled()); - (*iter)->stop(); - } - } -} - -bool ContextLifecycleNotifier::hasPendingActivity() const -{ - for (ActiveDOMObjectSet::const_iterator iter = m_activeDOMObjects.begin(); iter != m_activeDOMObjects.end(); ++iter) { - if ((*iter)->hasPendingActivity()) - return true; - } - return false; -} - -} // namespace blink diff --git a/sky/engine/core/dom/ContextLifecycleNotifier.h b/sky/engine/core/dom/ContextLifecycleNotifier.h deleted file mode 100644 index d35f26f2108dc..0000000000000 --- a/sky/engine/core/dom/ContextLifecycleNotifier.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#ifndef SKY_ENGINE_CORE_DOM_CONTEXTLIFECYCLENOTIFIER_H_ -#define SKY_ENGINE_CORE_DOM_CONTEXTLIFECYCLENOTIFIER_H_ - -#include "sky/engine/core/dom/ActiveDOMObject.h" -#include "sky/engine/platform/LifecycleNotifier.h" -#include "sky/engine/wtf/HashSet.h" -#include "sky/engine/wtf/PassOwnPtr.h" - -namespace blink { - -class ActiveDOMObject; -class ExecutionContext; - -class ContextLifecycleNotifier : public LifecycleNotifier { -public: - static PassOwnPtr create(ExecutionContext*); - - virtual ~ContextLifecycleNotifier(); - - typedef HashSet ActiveDOMObjectSet; - - const ActiveDOMObjectSet& activeDOMObjects() const { return m_activeDOMObjects; } - - virtual void addObserver(Observer*) override; - virtual void removeObserver(Observer*) override; - - void notifyResumingActiveDOMObjects(); - void notifySuspendingActiveDOMObjects(); - void notifyStoppingActiveDOMObjects(); - - bool contains(ActiveDOMObject* object) const { return m_activeDOMObjects.contains(object); } - bool hasPendingActivity() const; - -protected: - explicit ContextLifecycleNotifier(ExecutionContext*); - -private: - ActiveDOMObjectSet m_activeDOMObjects; -}; - -inline PassOwnPtr ContextLifecycleNotifier::create(ExecutionContext* context) -{ - return adoptPtr(new ContextLifecycleNotifier(context)); -} - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_CONTEXTLIFECYCLENOTIFIER_H_ diff --git a/sky/engine/core/dom/ContextLifecycleObserver.cpp b/sky/engine/core/dom/ContextLifecycleObserver.cpp deleted file mode 100644 index 8403e832dbbdd..0000000000000 --- a/sky/engine/core/dom/ContextLifecycleObserver.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/dom/ContextLifecycleObserver.h" - -#include "sky/engine/core/dom/ExecutionContext.h" - -namespace blink { - -template<> void observerContext(ExecutionContext* context, LifecycleObserver* observer) -{ - context->wasObservedBy(observer); -} - -template<> void unobserverContext(ExecutionContext* context, LifecycleObserver* observer) -{ - context->wasUnobservedBy(observer); -} - -ContextLifecycleObserver::ContextLifecycleObserver(ExecutionContext* executionContext, Type type) - : LifecycleObserver(executionContext, type) -{ -} - -ContextLifecycleObserver::~ContextLifecycleObserver() -{ -} - -} // namespace blink diff --git a/sky/engine/core/dom/ContextLifecycleObserver.h b/sky/engine/core/dom/ContextLifecycleObserver.h deleted file mode 100644 index a3bf3252f9558..0000000000000 --- a/sky/engine/core/dom/ContextLifecycleObserver.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_DOM_CONTEXTLIFECYCLEOBSERVER_H_ -#define SKY_ENGINE_CORE_DOM_CONTEXTLIFECYCLEOBSERVER_H_ - -#include "sky/engine/platform/LifecycleContext.h" - -namespace blink { - -class ExecutionContext; - -template<> void observerContext(ExecutionContext*, LifecycleObserver*); -template<> void unobserverContext(ExecutionContext*, LifecycleObserver*); - -class ContextLifecycleObserver : public LifecycleObserver { -public: - explicit ContextLifecycleObserver(ExecutionContext*, Type = GenericType); - ExecutionContext* executionContext() const { return lifecycleContext(); } -protected: - virtual ~ContextLifecycleObserver(); -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_CONTEXTLIFECYCLEOBSERVER_H_ diff --git a/sky/engine/core/dom/DOMURL.cpp b/sky/engine/core/dom/DOMURL.cpp index e48b8bba8d451..876d8f4ec4717 100644 --- a/sky/engine/core/dom/DOMURL.cpp +++ b/sky/engine/core/dom/DOMURL.cpp @@ -29,7 +29,6 @@ #include "sky/engine/bindings/exception_messages.h" #include "sky/engine/bindings/exception_state.h" #include "sky/engine/core/dom/ExceptionCode.h" -#include "sky/engine/core/dom/ExecutionContext.h" #include "sky/engine/wtf/MainThread.h" namespace blink { diff --git a/sky/engine/core/dom/DOMURL.h b/sky/engine/core/dom/DOMURL.h index cc1a9c740316e..0c37ca778f9d7 100644 --- a/sky/engine/core/dom/DOMURL.h +++ b/sky/engine/core/dom/DOMURL.h @@ -37,7 +37,6 @@ namespace blink { class Blob; class ExceptionState; -class ExecutionContext; class URLRegistrable; class DOMURL final : public RefCounted, public DartWrappable, public DOMURLUtils { diff --git a/sky/engine/core/dom/Document.cpp b/sky/engine/core/dom/Document.cpp index 3d4343b796889..9fa0be1b1bdff 100644 --- a/sky/engine/core/dom/Document.cpp +++ b/sky/engine/core/dom/Document.cpp @@ -28,6 +28,7 @@ #include "sky/engine/core/dom/Document.h" #include "gen/sky/core/HTMLElementFactory.h" +#include "gen/sky/core/EventNames.h" #include "gen/sky/platform/RuntimeEnabledFeatures.h" #include "sky/engine/bindings/exception_messages.h" #include "sky/engine/bindings/exception_state.h" @@ -44,8 +45,6 @@ #include "sky/engine/core/css/resolver/StyleResolverStats.h" #include "sky/engine/core/dom/Attr.h" #include "sky/engine/core/dom/DocumentFragment.h" -#include "sky/engine/core/dom/DocumentLifecycleNotifier.h" -#include "sky/engine/core/dom/DocumentLifecycleObserver.h" #include "sky/engine/core/dom/DocumentMarkerController.h" #include "sky/engine/core/dom/Element.h" #include "sky/engine/core/dom/ElementDataCache.h" @@ -69,11 +68,7 @@ #include "sky/engine/core/editing/FrameSelection.h" #include "sky/engine/core/editing/SpellChecker.h" #include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/EventListener.h" -#include "sky/engine/core/events/HashChangeEvent.h" #include "sky/engine/core/events/PageTransitionEvent.h" -#include "sky/engine/core/events/ScopedEventQueue.h" -#include "sky/engine/core/frame/FrameConsole.h" #include "sky/engine/core/frame/FrameHost.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalDOMWindow.h" @@ -83,7 +78,6 @@ #include "sky/engine/core/inspector/InspectorCounters.h" #include "sky/engine/core/loader/FrameLoaderClient.h" #include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/FocusController.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/painting/PaintingTasks.h" @@ -184,13 +178,6 @@ static inline bool isValidNamePart(UChar32 c) return true; } -static bool acceptsEditingFocus(const Element& element) -{ - ASSERT(element.hasEditableStyle()); - - return element.document().frame() && element.rootEditableElement(); -} - #ifndef NDEBUG typedef HashSet > WeakDocumentSet; static WeakDocumentSet& liveDocumentSet() @@ -203,13 +190,15 @@ static WeakDocumentSet& liveDocumentSet() Document::Document(const DocumentInit& initializer) : ContainerNode(0, CreateDocument) , TreeScope(*this) + , m_active(false) + , m_visualUpdatePending(true) + , m_inStyleRecalc(false) + , m_stopped(false) , m_module(nullptr) , m_evaluateMediaQueriesOnStyleRecalc(false) , m_frame(initializer.frame()) , m_domWindow(m_frame ? m_frame->domWindow() : 0) , m_activeParserCount(0) - , m_resumeParserWaitingForResourcesTimer(this, &Document::resumeParserWaitingForResourcesTimerFired) - , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired) , m_listenerTypes(0) , m_mutationObserverTypes(0) , m_readyState(Complete) @@ -222,20 +211,14 @@ Document::Document(const DocumentInit& initializer) #if !ENABLE(OILPAN) , m_weakFactory(this) #endif - , m_contextDocument(initializer.contextDocument()) - , m_loadEventDelayCount(0) - , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) , m_didSetReferrerPolicy(false) , m_referrerPolicy(ReferrerPolicyDefault) , m_elementRegistry(initializer.elementRegistry()) - , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFired) , m_templateDocumentHost(nullptr) , m_hasViewportUnits(false) , m_styleRecalcElementCounter(0) , m_frameView(nullptr) { - setClient(this); - if (!m_elementRegistry) m_elementRegistry = CustomElementRegistry::Create(); @@ -249,8 +232,6 @@ Document::Document(const DocumentInit& initializer) InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter); - m_lifecycle.advanceTo(DocumentLifecycle::Inactive); - #ifndef NDEBUG liveDocumentSet().add(this); #endif @@ -260,22 +241,12 @@ Document::~Document() { ASSERT(!renderView()); ASSERT(!parentTreeScope()); -#if !ENABLE(OILPAN) ASSERT(m_ranges.isEmpty()); ASSERT(!hasGuardRefCount()); if (m_templateDocument) m_templateDocument->m_templateDocumentHost = nullptr; // balanced in ensureTemplateDocument(). - // FIXME: Oilpan: Not removing event listeners here also means that we do - // not notify the inspector instrumentation that the event listeners are - // gone. The Document and all the nodes in the document are gone, so maybe - // that is OK? - removeAllEventListenersRecursively(); -#endif - -#if !ENABLE(OILPAN) - if (m_elemSheet) m_elemSheet->clearOwnerNode(); @@ -286,11 +257,8 @@ Document::~Document() #ifndef NDEBUG liveDocumentSet().remove(this); -#endif #endif - setClient(0); - InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter); } @@ -318,13 +286,9 @@ void Document::dispose() m_markers->clear(); - // FIXME: consider using ActiveDOMObject. if (m_scriptedAnimationController) m_scriptedAnimationController->clearDocumentPointer(); m_scriptedAnimationController.clear(); - - m_lifecycle.advanceTo(DocumentLifecycle::Disposed); - lifecycleNotifier().notifyDocumentWasDisposed(); } #endif @@ -376,21 +340,6 @@ void Document::registerElement(const AtomicString& name, PassRefPtr t m_elementRegistry->RegisterElement(name, type); } -LocalDOMWindow* Document::executingWindow() -{ - if (LocalDOMWindow* owningWindow = domWindow()) - return owningWindow; - return 0; -} - -LocalFrame* Document::executingFrame() -{ - LocalDOMWindow* window = executingWindow(); - if (!window) - return 0; - return window->frame(); -} - PassRefPtr Document::createDocumentFragment() { return DocumentFragment::create(*this); @@ -458,8 +407,6 @@ PassRefPtr Document::importNode(Node* importedNode, bool deep, ExceptionSt PassRefPtr Document::adoptNode(PassRefPtr source, ExceptionState& exceptionState) { - EventQueueScope scope; - switch (source->nodeType()) { case DOCUMENT_NODE: exceptionState.ThrowDOMException(NotSupportedError, "The node provided is of type '" + source->nodeName() + "', which may not be adopted."); @@ -514,7 +461,6 @@ void Document::setReadyState(ReadyState readyState) if (readyState == m_readyState) return; m_readyState = readyState; - dispatchEvent(Event::create(EventTypeNames::readystatechange)); } bool Document::isLoadCompleted() @@ -718,9 +664,6 @@ bool Document::shouldScheduleRenderTreeUpdate() const return false; if (inStyleRecalc()) return false; - // InPreLayout will recalc style itself. There's no reason to schedule another recalc. - if (m_lifecycle.state() == DocumentLifecycle::InPreLayout) - return false; return true; } @@ -731,10 +674,7 @@ void Document::scheduleRenderTreeUpdate() ASSERT(needsRenderTreeUpdate()); scheduleVisualUpdate(); - - // TODO(esprehn): We should either rename this state, or change the other - // users of scheduleVisualUpdate() so they don't expect different states. - m_lifecycle.ensureStateAtMost(DocumentLifecycle::VisualUpdatePending); + m_visualUpdatePending = true; } void Document::scheduleVisualUpdate() @@ -817,16 +757,13 @@ void Document::updateRenderTree(StyleRecalcChange change) // hits a null-dereference due to security code always assuming the document has a SecurityOrigin. updateStyle(change); - - if (m_focusedElement && !m_focusedElement->isFocusable()) - clearFocusedElementSoon(); } void Document::updateStyle(StyleRecalcChange change) { TRACE_EVENT0("blink", "Document::updateStyle"); - m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); + m_inStyleRecalc = true; if (styleChangeType() >= SubtreeStyleChange) change = Force; @@ -867,10 +804,11 @@ void Document::updateStyle(StyleRecalcChange change) m_styleEngine->resolver().clearStyleSharingList(); + m_visualUpdatePending = false; + m_inStyleRecalc = false; + ASSERT(!needsStyleRecalc()); ASSERT(!childNeedsStyleRecalc()); - ASSERT(inStyleRecalc()); - m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); } void Document::updateRenderTreeForNodeIfNeeded(Node* node) @@ -904,9 +842,6 @@ void Document::updateLayout() if (frameView->needsLayout()) frameView->layout(); - - if (lifecycle().state() < DocumentLifecycle::LayoutClean) - lifecycle().advanceTo(DocumentLifecycle::LayoutClean); } void Document::setNeedsFocusedElementCheck() @@ -914,21 +849,6 @@ void Document::setNeedsFocusedElementCheck() setNeedsStyleRecalc(LocalStyleChange); } -void Document::clearFocusedElementSoon() -{ - if (!m_clearFocusedElementTimer.isActive()) - m_clearFocusedElementTimer.startOneShot(0, FROM_HERE); -} - -void Document::clearFocusedElementTimerFired(Timer*) -{ - updateRenderTreeIfNeeded(); - m_clearFocusedElementTimer.stop(); - - if (m_focusedElement && !m_focusedElement->isFocusable()) - m_focusedElement->blur(); -} - StyleResolver& Document::styleResolver() const { ASSERT(isActive()); @@ -937,8 +857,6 @@ StyleResolver& Document::styleResolver() const void Document::attach(const AttachContext& context) { - ASSERT(m_lifecycle.state() == DocumentLifecycle::Inactive); - m_styleEngine = StyleEngine::create(*this); m_renderView = new RenderView(this); @@ -948,28 +866,23 @@ void Document::attach(const AttachContext& context) ContainerNode::attach(context); - m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); + m_active = true; } void Document::detach(const AttachContext& context) { ASSERT(isActive()); - m_lifecycle.advanceTo(DocumentLifecycle::Stopping); + + m_active = false; + m_stopped = true; if (page()) page()->documentDetached(this); - stopActiveDOMObjects(); - - // FIXME: consider using ActiveDOMObject. if (m_scriptedAnimationController) m_scriptedAnimationController->clearDocumentPointer(); m_scriptedAnimationController.clear(); - // FIXME: This shouldn't be needed once LocalDOMWindow becomes ExecutionContext. - if (m_domWindow) - m_domWindow->clearEventQueue(); - m_hoverNode = nullptr; m_focusedElement = nullptr; m_activeHoverElement = nullptr; @@ -988,14 +901,6 @@ void Document::detach(const AttachContext& context) if (m_mediaQueryMatcher) m_mediaQueryMatcher->documentDetached(); - - lifecycleNotifier().notifyDocumentWasDetached(); - m_lifecycle.advanceTo(DocumentLifecycle::Stopped); -#if ENABLE(OILPAN) - // Done with the window, explicitly clear to hasten its - // destruction. - clearDOMWindow(); -#endif } void Document::prepareForDestruction() @@ -1011,14 +916,6 @@ void Document::prepareForDestruction() detach(); } -void Document::removeAllEventListeners() -{ - ContainerNode::removeAllEventListeners(); - - if (LocalDOMWindow* domWindow = this->domWindow()) - domWindow->removeAllEventListeners(); -} - void Document::detachParser() { } @@ -1055,12 +952,6 @@ void Document::implicitClose() // onLoad event handler, as in Radar 3206524. detachParser(); - // JS running below could remove the frame or destroy the RenderView so we call - // those two functions repeatedly and don't save them on the stack. - - if (protectedWindow) - protectedWindow->documentWasClosed(); - if (frame()) frame()->loaderClient()->dispatchDidHandleOnloadEvents(); @@ -1128,26 +1019,6 @@ KURL Document::virtualCompleteURL(const String& url) const return completeURL(url); } -double Document::timerAlignmentInterval() const -{ - Page* p = page(); - if (!p) - return DOMTimer::visiblePageAlignmentInterval(); - return p->timerAlignmentInterval(); -} - -EventTarget* Document::errorEventTarget() -{ - return domWindow(); -} - -void Document::logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr callStack) -{ - RefPtr consoleMessage = ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber); - consoleMessage->setScriptId(scriptId); - addMessage(consoleMessage.release()); -} - void Document::setURL(const KURL& url) { const KURL& newURL = url.isEmpty() ? blankURL() : url; @@ -1168,11 +1039,6 @@ void Document::updateBaseURL() } void Document::didLoadAllParserBlockingResources() -{ - m_resumeParserWaitingForResourcesTimer.startOneShot(0, FROM_HERE); -} - -void Document::resumeParserWaitingForResourcesTimerFired(Timer*) { } @@ -1219,14 +1085,10 @@ void Document::evaluateMediaQueryListIfNeeded() void Document::evaluateMediaQueryList() { - if (m_mediaQueryMatcher) - m_mediaQueryMatcher->mediaFeaturesChanged(); } void Document::notifyResizeForViewportUnits() { - if (m_mediaQueryMatcher) - m_mediaQueryMatcher->viewportChanged(); if (!hasViewportUnits()) return; styleResolver().notifyResizeForViewportUnits(); @@ -1300,106 +1162,7 @@ void Document::activeChainNodeDetached(Node* node) bool Document::setFocusedElement(PassRefPtr prpNewFocusedElement, FocusType type) { - m_clearFocusedElementTimer.stop(); - - RefPtr newFocusedElement = prpNewFocusedElement; - - // Make sure newFocusedNode is actually in this document - if (newFocusedElement && (newFocusedElement->document() != this)) - return true; - - if (m_focusedElement == newFocusedElement) - return true; - - bool focusChangeBlocked = false; - RefPtr oldFocusedElement = m_focusedElement; - m_focusedElement = nullptr; - - // Remove focus from the existing focus node (if any) - if (oldFocusedElement) { - if (oldFocusedElement->active()) - oldFocusedElement->setActive(false); - - oldFocusedElement->setFocus(false); - - // Dispatch the blur event and let the node do any other blur related activities (important for text fields) - // If page lost focus, blur event will have already been dispatched - if (page() && (page()->focusController().isFocused())) { - oldFocusedElement->dispatchBlurEvent(newFocusedElement.get()); - - if (m_focusedElement) { - // handler shifted focus - focusChangeBlocked = true; - newFocusedElement = nullptr; - } - - oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, newFocusedElement.get()); // DOM level 3 name for the bubbling blur event. - // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends - // on it, probably when is resolved. - oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut, newFocusedElement.get()); // DOM level 2 name for compatibility. - - if (m_focusedElement) { - // handler shifted focus - focusChangeBlocked = true; - newFocusedElement = nullptr; - } - } - } - - if (newFocusedElement && newFocusedElement->isFocusable()) { - if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*newFocusedElement)) { - // delegate blocks focus change - focusChangeBlocked = true; - goto SetFocusedElementDone; - } - // Set focus on the new node - m_focusedElement = newFocusedElement; - - // Dispatch the focus event and let the node do any other focus related activities (important for text fields) - // If page lost focus, event will be dispatched on page focus, don't duplicate - if (page() && (page()->focusController().isFocused())) { - m_focusedElement->dispatchFocusEvent(oldFocusedElement.get(), type); - - - if (m_focusedElement != newFocusedElement) { - // handler shifted focus - focusChangeBlocked = true; - goto SetFocusedElementDone; - } - - m_focusedElement->dispatchFocusInEvent(EventTypeNames::focusin, oldFocusedElement.get()); // DOM level 3 bubbling focus event. - - if (m_focusedElement != newFocusedElement) { - // handler shifted focus - focusChangeBlocked = true; - goto SetFocusedElementDone; - } - - // FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends - // on it, probably when is m. - m_focusedElement->dispatchFocusInEvent(EventTypeNames::DOMFocusIn, oldFocusedElement.get()); // DOM level 2 for compatibility. - - if (m_focusedElement != newFocusedElement) { - // handler shifted focus - focusChangeBlocked = true; - goto SetFocusedElementDone; - } - } - - m_focusedElement->setFocus(true); - - if (m_focusedElement->isRootEditableElement()) - frame()->spellChecker().didBeginEditing(m_focusedElement.get()); - } - - if (!focusChangeBlocked && frameHost()) - page()->focusedNodeChanged(m_focusedElement.get()); - -SetFocusedElementDone: - updateRenderTreeIfNeeded(); - if (LocalFrame* frame = this->frame()) - frame->selection().didChangeFocus(); - return !focusChangeBlocked; + return false; } void Document::updateRangesAfterChildrenChanged(ContainerNode* container) @@ -1433,7 +1196,6 @@ void Document::nodeChildrenWillBeRemoved(ContainerNode& container) if (LocalFrame* frame = this->frame()) { for (Node* n = container.firstChild(); n; n = n->nextSibling()) { - frame->eventHandler().nodeWillBeRemoved(*n); frame->selection().nodeWillBeRemoved(*n); frame->page()->dragCaretController().nodeWillBeRemoved(*n); } @@ -1449,7 +1211,6 @@ void Document::nodeWillBeRemoved(Node& n) } if (LocalFrame* frame = this->frame()) { - frame->eventHandler().nodeWillBeRemoved(n); frame->selection().nodeWillBeRemoved(n); frame->page()->dragCaretController().nodeWillBeRemoved(n); } @@ -1509,35 +1270,6 @@ void Document::didSplitTextNode(Text& oldNode) // FIXME: This should update markers for spelling and grammar checking. } -EventQueue* Document::eventQueue() const -{ - if (!m_domWindow) - return 0; - return m_domWindow->eventQueue(); -} - -void Document::enqueueAnimationFrameEvent(PassRefPtr event) -{ - ensureScriptedAnimationController().enqueueEvent(event); -} - -void Document::enqueueUniqueAnimationFrameEvent(PassRefPtr event) -{ - ensureScriptedAnimationController().enqueuePerFrameEvent(event); -} - -void Document::enqueueResizeEvent() -{ - RefPtr event = Event::create(EventTypeNames::resize); - event->setTarget(domWindow()); - ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); -} - -void Document::enqueueMediaQueryChangeListeners(Vector >& listeners) -{ - ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listeners); -} - const AtomicString& Document::referrer() const { return nullAtom; @@ -1716,15 +1448,6 @@ Document& Document::topDocument() const WeakPtr Document::contextDocument() { - if (m_contextDocument) - return m_contextDocument; - if (m_frame) { -#if ENABLE(OILPAN) - return this; -#else - return m_weakFactory.createWeakPtr(); -#endif - } return WeakPtr(nullptr); } @@ -1732,27 +1455,9 @@ void Document::finishedParsing() { } -void Document::elementDataCacheClearTimerFired(Timer*) -{ - m_elementDataCache.clear(); -} - bool Document::allowExecutingScripts(Node* node) { - // FIXME: Eventually we'd like to evaluate scripts which are inserted into a - // viewless document but this'll do for now. - // See http://bugs.webkit.org/show_bug.cgi?id=5727 - LocalFrame* frame = executingFrame(); - if (!frame) - return false; - if (!node->document().executingFrame()) - return false; - return true; -} - -bool Document::isContextThread() const -{ - return isMainThread(); + return false; } void Document::attachRange(Range* range) @@ -1772,39 +1477,20 @@ void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe { } -void Document::addMessage(PassRefPtr consoleMessage) -{ - if (!m_frame) - return; - m_frame->console().addMessage(consoleMessage); -} - void Document::decrementLoadEventDelayCount() { - ASSERT(m_loadEventDelayCount); - --m_loadEventDelayCount; - - if (!m_loadEventDelayCount) - checkLoadEventSoon(); } void Document::checkLoadEventSoon() { - if (frame() && !m_loadEventDelayTimer.isActive()) - m_loadEventDelayTimer.startOneShot(0, FROM_HERE); } bool Document::isDelayingLoadEvent() { - return m_loadEventDelayCount; + return false; } -void Document::loadEventDelayTimerFired(Timer*) -{ - checkCompleted(); -} - ScriptedAnimationController& Document::ensureScriptedAnimationController() { if (!m_scriptedAnimationController) { @@ -1875,16 +1561,6 @@ float Document::devicePixelRatio() const return m_frame ? m_frame->devicePixelRatio() : 1.0; } -PassOwnPtr > Document::createLifecycleNotifier() -{ - return DocumentLifecycleNotifier::create(this); -} - -DocumentLifecycleNotifier& Document::lifecycleNotifier() -{ - return static_cast(LifecycleContext::lifecycleNotifier()); -} - Element* Document::activeElement() const { if (Element* element = treeScope().adjustedFocusedElement()) diff --git a/sky/engine/core/dom/Document.h b/sky/engine/core/dom/Document.h index 1a129b78729bf..0608533a9863d 100644 --- a/sky/engine/core/dom/Document.h +++ b/sky/engine/core/dom/Document.h @@ -28,24 +28,22 @@ #ifndef SKY_ENGINE_CORE_DOM_DOCUMENT_H_ #define SKY_ENGINE_CORE_DOM_DOCUMENT_H_ -#include "sky/engine/tonic/dart_value.h" #include "sky/engine/bindings/exception_state_placeholder.h" #include "sky/engine/core/dom/ContainerNode.h" #include "sky/engine/core/dom/DocumentInit.h" -#include "sky/engine/core/dom/DocumentLifecycle.h" #include "sky/engine/core/dom/DocumentSupplementable.h" -#include "sky/engine/core/dom/ExecutionContext.h" #include "sky/engine/core/dom/MutationObserver.h" #include "sky/engine/core/dom/TextLinkColors.h" #include "sky/engine/core/dom/TreeScope.h" #include "sky/engine/core/dom/UserActionElementSet.h" +#include "sky/engine/core/inspector/ScriptCallStack.h" #include "sky/engine/core/loader/DocumentLoadTiming.h" #include "sky/engine/core/page/FocusType.h" #include "sky/engine/platform/Length.h" -#include "sky/engine/platform/Timer.h" #include "sky/engine/platform/heap/Handle.h" #include "sky/engine/platform/weborigin/KURL.h" #include "sky/engine/platform/weborigin/ReferrerPolicy.h" +#include "sky/engine/tonic/dart_value.h" #include "sky/engine/wtf/HashSet.h" #include "sky/engine/wtf/OwnPtr.h" #include "sky/engine/wtf/PassOwnPtr.h" @@ -64,14 +62,12 @@ class CSSStyleDeclaration; class CSSStyleSheet; class CustomElementRegistry; class DocumentFragment; -class DocumentLifecycleNotifier; class DocumentLoadTiming; class DocumentMarkerController; class DocumentParser; class Element; class ElementDataCache; class Event; -class EventListener; class ExceptionState; class FloatQuad; class FloatRect; @@ -108,8 +104,7 @@ typedef int ExceptionCode; class Document; -class Document : public ContainerNode, public TreeScope, public ExecutionContext, public ExecutionContextClient - , public DocumentSupplementable, public LifecycleContext { +class Document : public ContainerNode, public TreeScope, public DocumentSupplementable { DEFINE_WRAPPERTYPEINFO(); public: static PassRefPtr create(const DocumentInit& initializer = DocumentInit()) @@ -126,7 +121,6 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext using ContainerNode::ref; using ContainerNode::deref; #endif - using ExecutionContextClient::addConsoleMessage; using TreeScope::getElementById; virtual bool canContainRangeEndPoint() const override { return true; } @@ -355,8 +349,6 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext const WTF::TextEncoding& encoding() const { return WTF::UTF8Encoding(); } - virtual void removeAllEventListeners() override final; - bool allowExecutingScripts(Node*); enum LoadEventProgress { @@ -373,8 +365,6 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext bool loadEventFinished() const { return m_loadEventProgress >= LoadEventCompleted; } bool unloadStarted() const { return m_loadEventProgress >= PageHideInProgress; } - virtual bool isContextThread() const override final; - bool containsValidityStyleRules() const { return m_containsValidityStyleRules; } void setContainsValidityStyleRules() { m_containsValidityStyleRules = true; } @@ -382,10 +372,9 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext void enqueueAnimationFrameEvent(PassRefPtr); // Only one event for a target/event type combination will be dispatched per frame. void enqueueUniqueAnimationFrameEvent(PassRefPtr); - void enqueueMediaQueryChangeListeners(Vector >&); // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event. - void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; } + void incrementLoadEventDelayCount() { } void decrementLoadEventDelayCount(); void checkLoadEventSoon(); bool isDelayingLoadEvent(); @@ -394,9 +383,6 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext void cancelAnimationFrame(int id); void serviceScriptedAnimations(double monotonicAnimationStartTime); - virtual EventTarget* errorEventTarget() override final; - virtual void logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr) override final; - IntSize initialViewportSize() const; void registerElement(const AtomicString& name, PassRefPtr type, ExceptionState&); @@ -410,23 +396,18 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext void didLoadAllParserBlockingResources(); - bool inStyleRecalc() const { return m_lifecycle.state() == DocumentLifecycle::InStyleRecalc; } + bool inStyleRecalc() const { return m_inStyleRecalc; } // A non-null m_templateDocumentHost implies that |this| was created by ensureTemplateDocument(). bool isTemplateDocument() const { return !!m_templateDocumentHost; } Document& ensureTemplateDocument(); Document* templateDocumentHost() { return m_templateDocumentHost; } - virtual void addMessage(PassRefPtr) override final; - - virtual LocalDOMWindow* executingWindow() override final; LocalFrame* executingFrame(); - DocumentLifecycleNotifier& lifecycleNotifier(); - DocumentLifecycle& lifecycle() { return m_lifecycle; } - bool isActive() const { return m_lifecycle.isActive(); } - bool isStopped() const { return m_lifecycle.state() == DocumentLifecycle::Stopped; } - bool isDisposed() const { return m_lifecycle.state() == DocumentLifecycle::Disposed; } + bool isActive() const { return m_active; } + bool isStopped() const { return m_stopped; } + bool isDisposed() const { return m_stopped; } enum HttpRefreshType { HttpRefreshFromHeader, @@ -434,8 +415,6 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext }; void maybeHandleHttpRefresh(const String&, HttpRefreshType); - PassOwnPtr > createLifecycleNotifier(); - void setHasViewportUnits() { m_hasViewportUnits = true; } bool hasViewportUnits() const { return m_hasViewportUnits; } void notifyResizeForViewportUnits(); @@ -467,10 +446,8 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext bool isElementNode() const = delete; // This will catch anyone doing an unnecessary check. ScriptedAnimationController& ensureScriptedAnimationController(); - virtual EventQueue* eventQueue() const override final; - // FIXME: Rename the StyleRecalc state to RenderTreeUpdate. - bool hasPendingStyleRecalc() const { return m_lifecycle.state() == DocumentLifecycle::VisualUpdatePending; } + bool hasPendingStyleRecalc() const { return m_visualUpdatePending; } bool shouldScheduleRenderTreeUpdate() const; void scheduleRenderTreeUpdate(); @@ -486,44 +463,26 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext void detachParser(); - virtual bool isDocument() const override final { return true; } - virtual String nodeName() const override final; virtual NodeType nodeType() const override final; virtual PassRefPtr cloneNode(bool deep = true) override final; -#if !ENABLE(OILPAN) - virtual void refExecutionContext() override final { ref(); } - virtual void derefExecutionContext() override final { deref(); } -#endif - - virtual const KURL& virtualURL() const override final; // Same as url(), but needed for ExecutionContext to implement it without a performance loss for direct calls. - virtual KURL virtualCompleteURL(const String&) const override final; // Same as completeURL() for the same reason as above. + virtual const KURL& virtualURL() const final; // Same as url(), but without virtual call + virtual KURL virtualCompleteURL(const String&) const final; // Same as completeURL() for the same reason as above. - virtual void reportBlockedScriptExecutionToInspector(const String& directiveText) override final; - - virtual double timerAlignmentInterval() const override final; + virtual void reportBlockedScriptExecutionToInspector(const String& directiveText) final; void updateBaseURL(); - void resumeParserWaitingForResourcesTimerFired(Timer*); - - void loadEventDelayTimerFired(Timer*); - - // Note that dispatching a window load event may cause the LocalDOMWindow to be detached from - // the LocalFrame, so callers should take a reference to the LocalDOMWindow (which owns us) to - // prevent the Document from getting blown away from underneath them. - void dispatchWindowLoadEvent(); - void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; } - void clearFocusedElementSoon(); - void clearFocusedElementTimerFired(Timer*); - void setHoverNode(PassRefPtr); Node* hoverNode() const { return m_hoverNode.get(); } - DocumentLifecycle m_lifecycle; + bool m_active; + bool m_visualUpdatePending; + bool m_inStyleRecalc; + bool m_stopped; AbstractModule* m_module; @@ -543,9 +502,6 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext RefPtr m_elemSheet; - Timer m_resumeParserWaitingForResourcesTimer; - - Timer m_clearFocusedElementTimer; RefPtr m_focusedElement; RefPtr m_hoverNode; RefPtr m_activeHoverElement; @@ -579,13 +535,7 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext RenderView* m_renderView; -#if !ENABLE(OILPAN) WeakPtrFactory m_weakFactory; -#endif - WeakPtr m_contextDocument; - - int m_loadEventDelayCount; - Timer m_loadEventDelayTimer; Length m_viewportDefaultMinWidth; @@ -598,9 +548,6 @@ class Document : public ContainerNode, public TreeScope, public ExecutionContext RefPtr m_elementRegistry; - void elementDataCacheClearTimerFired(Timer*); - Timer m_elementDataCacheClearTimer; - OwnPtr m_elementDataCache; RefPtr m_templateDocument; @@ -628,8 +575,6 @@ inline void Document::scheduleRenderTreeUpdateIfNeeded() scheduleRenderTreeUpdate(); } -DEFINE_TYPE_CASTS(Document, ExecutionContextClient, client, client->isDocument(), client.isDocument()); -DEFINE_TYPE_CASTS(Document, ExecutionContext, context, context->isDocument(), context.isDocument()); DEFINE_NODE_TYPE_CASTS(Document, isDocumentNode()); #define DEFINE_DOCUMENT_TYPE_CASTS(thisType) \ diff --git a/sky/engine/core/dom/Document.idl b/sky/engine/core/dom/Document.idl index 8b265fb06461c..70030b718b71b 100644 --- a/sky/engine/core/dom/Document.idl +++ b/sky/engine/core/dom/Document.idl @@ -38,8 +38,6 @@ callback CustomElementConstructor = Element (); Range createRange(); - [ImplementedAs=executingWindow] readonly attribute Window defaultView; - readonly attribute DOMString contentType; [TreatNullAs=NullString, CustomElementCallbacks] attribute DOMString dir; diff --git a/sky/engine/core/dom/DocumentFragment.idl b/sky/engine/core/dom/DocumentFragment.idl index febab1d9c4c53..d22c27a3872c3 100644 --- a/sky/engine/core/dom/DocumentFragment.idl +++ b/sky/engine/core/dom/DocumentFragment.idl @@ -17,10 +17,7 @@ * Boston, MA 02110-1301, USA. */ -[ - Constructor, - ConstructorCallWith=Document, -] interface DocumentFragment : ParentNode { +interface DocumentFragment : ParentNode { // NonElementParentNode API. Element getElementById(DOMString elementId); }; diff --git a/sky/engine/core/dom/DocumentLifecycle.cpp b/sky/engine/core/dom/DocumentLifecycle.cpp deleted file mode 100644 index 3c48c87775339..0000000000000 --- a/sky/engine/core/dom/DocumentLifecycle.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/dom/DocumentLifecycle.h" - -#include "sky/engine/wtf/Assertions.h" - -namespace blink { - -static DocumentLifecycle::DeprecatedTransition* s_deprecatedTransitionStack = 0; - -DocumentLifecycle::Scope::Scope(DocumentLifecycle& lifecycle, State finalState) - : m_lifecycle(lifecycle) - , m_finalState(finalState) -{ -} - -DocumentLifecycle::Scope::~Scope() -{ - m_lifecycle.advanceTo(m_finalState); -} - -DocumentLifecycle::DeprecatedTransition::DeprecatedTransition(State from, State to) - : m_previous(s_deprecatedTransitionStack) - , m_from(from) - , m_to(to) -{ - s_deprecatedTransitionStack = this; -} - -DocumentLifecycle::DeprecatedTransition::~DeprecatedTransition() -{ - s_deprecatedTransitionStack = m_previous; -} - -DocumentLifecycle::DocumentLifecycle() - : m_state(Uninitialized) - , m_detachCount(0) -{ -} - -DocumentLifecycle::~DocumentLifecycle() -{ -} - -#if ENABLE(ASSERT) - -bool DocumentLifecycle::canAdvanceTo(State state) const -{ - if (state > m_state) - return true; - if (m_state == Disposed) { - // FIXME: We can dispose a document multiple times. This seems wrong. - // See https://code.google.com/p/chromium/issues/detail?id=301668. - return state == Disposed; - } - if (m_state == StyleClean) { - // We can synchronously recalc style. - if (state == InStyleRecalc) - return true; - // We can synchronously perform layout. - if (state == InPreLayout) - return true; - if (state == InPerformLayout) - return true; - // We can redundant arrive in the style clean state. - if (state == StyleClean) - return true; - return false; - } - if (m_state == InPreLayout) { - if (state == InStyleRecalc) - return true; - if (state == StyleClean) - return true; - if (state == InPreLayout) - return true; - return false; - } - if (m_state == AfterPerformLayout) { - // We can synchronously recompute layout in AfterPerformLayout. - // FIXME: Ideally, we would unnest this recursion into a loop. - return state == InPreLayout; - } - if (m_state == LayoutClean) { - // We can synchronously recalc style. - if (state == InStyleRecalc) - return true; - // We can synchronously perform layout. - if (state == InPreLayout) - return true; - if (state == InPerformLayout) - return true; - // We can redundant arrive in the layout clean state. This situation - // can happen when we call layout recursively and we unwind the stack. - if (state == LayoutClean) - return true; - if (state == StyleClean) - return true; - return false; - } - if (m_state == StyleAndLayoutClean) { - if (state == InStyleRecalc) - return true; - if (state == InPreLayout) - return true; - if (state == LayoutClean) - return true; - // We can pump frames without style or layout needing updating. - if (state == StyleAndLayoutClean) - return true; - return false; - } - return false; -} - -bool DocumentLifecycle::canRewindTo(State state) const -{ - // This transition is bogus, but we've whitelisted it anyway. - if (s_deprecatedTransitionStack && m_state == s_deprecatedTransitionStack->from() && state == s_deprecatedTransitionStack->to()) - return true; - return m_state == StyleClean || m_state == AfterPerformLayout || m_state == LayoutClean || m_state == StyleAndLayoutClean; -} - -#endif - -void DocumentLifecycle::advanceTo(State state) -{ - ASSERT(canAdvanceTo(state)); - m_state = state; -} - -void DocumentLifecycle::ensureStateAtMost(State state) -{ - ASSERT(state == VisualUpdatePending || state == StyleClean || state == LayoutClean); - if (m_state <= state) - return; - ASSERT(canRewindTo(state)); - m_state = state; -} - -} diff --git a/sky/engine/core/dom/DocumentLifecycle.h b/sky/engine/core/dom/DocumentLifecycle.h deleted file mode 100644 index fd3026444595a..0000000000000 --- a/sky/engine/core/dom/DocumentLifecycle.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLE_H_ -#define SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLE_H_ - -#include "sky/engine/wtf/Assertions.h" -#include "sky/engine/wtf/Noncopyable.h" - -namespace blink { - -class DocumentLifecycle { - WTF_MAKE_NONCOPYABLE(DocumentLifecycle); -public: - enum State { - Uninitialized, - Inactive, - - // When the document is active, it traverses these states. - VisualUpdatePending, - - InStyleRecalc, - StyleClean, - - InPreLayout, - InPerformLayout, - AfterPerformLayout, - LayoutClean, - - StyleAndLayoutClean, - - // Once the document starts shuting down, we cannot return - // to the style/layout/rendering states. - Stopping, - Stopped, - Disposed, - }; - - class Scope { - WTF_MAKE_NONCOPYABLE(Scope); - public: - Scope(DocumentLifecycle&, State finalState); - ~Scope(); - - void setFinalState(State finalState) { m_finalState = finalState; } - - private: - DocumentLifecycle& m_lifecycle; - State m_finalState; - }; - - class DeprecatedTransition { - WTF_MAKE_NONCOPYABLE(DeprecatedTransition); - public: - DeprecatedTransition(State from, State to); - ~DeprecatedTransition(); - - State from() const { return m_from; } - State to() const { return m_to; } - - private: - DeprecatedTransition* m_previous; - State m_from; - State m_to; - }; - - class DetachScope { - WTF_MAKE_NONCOPYABLE(DetachScope); - public: - explicit DetachScope(DocumentLifecycle& documentLifecycle) - : m_documentLifecycle(documentLifecycle) - { - m_documentLifecycle.incrementDetachCount(); - } - - ~DetachScope() - { - m_documentLifecycle.decrementDetachCount(); - } - - private: - DocumentLifecycle& m_documentLifecycle; - }; - - DocumentLifecycle(); - ~DocumentLifecycle(); - - bool isActive() const { return m_state > Inactive && m_state < Stopping; } - State state() const { return m_state; } - - bool stateAllowsTreeMutations() const; - bool stateAllowsRenderTreeMutations() const; - bool stateAllowsDetach() const; - - void advanceTo(State); - void ensureStateAtMost(State); - - void incrementDetachCount() { m_detachCount++; } - void decrementDetachCount() - { - ASSERT(m_detachCount > 0); - m_detachCount--; - } - -private: -#if ENABLE(ASSERT) - bool canAdvanceTo(State) const; - bool canRewindTo(State) const; -#endif - - State m_state; - int m_detachCount; -}; - -inline bool DocumentLifecycle::stateAllowsTreeMutations() const -{ - return m_state != InStyleRecalc && m_state != InPerformLayout; -} - -inline bool DocumentLifecycle::stateAllowsRenderTreeMutations() const -{ - return m_detachCount || m_state == InStyleRecalc; -} - -inline bool DocumentLifecycle::stateAllowsDetach() const -{ - return m_state == VisualUpdatePending - || m_state == InStyleRecalc - || m_state == StyleClean - || m_state == InPreLayout - || m_state == LayoutClean - || m_state == StyleAndLayoutClean - || m_state == Stopping; -} - -} - -#endif // SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLE_H_ diff --git a/sky/engine/core/dom/DocumentLifecycleNotifier.cpp b/sky/engine/core/dom/DocumentLifecycleNotifier.cpp deleted file mode 100644 index 81dde4e3f7ef5..0000000000000 --- a/sky/engine/core/dom/DocumentLifecycleNotifier.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "sky/engine/core/dom/DocumentLifecycleNotifier.h" - -#include "sky/engine/wtf/Assertions.h" - -namespace blink { - -DocumentLifecycleNotifier::DocumentLifecycleNotifier(Document* document) - : LifecycleNotifier(document) -{ -} - -void DocumentLifecycleNotifier::addObserver(DocumentLifecycleNotifier::Observer* observer) -{ - if (observer->observerType() == Observer::DocumentLifecycleObserverType) { - RELEASE_ASSERT(m_iterating != IteratingOverDocumentObservers); - m_documentObservers.add(static_cast(observer)); - } - - LifecycleNotifier::addObserver(observer); -} - -void DocumentLifecycleNotifier::removeObserver(DocumentLifecycleNotifier::Observer* observer) -{ - if (observer->observerType() == Observer::DocumentLifecycleObserverType) { - RELEASE_ASSERT(m_iterating != IteratingOverDocumentObservers); - m_documentObservers.remove(static_cast(observer)); - } - - LifecycleNotifier::removeObserver(observer); -} - -} // namespace blink diff --git a/sky/engine/core/dom/DocumentLifecycleNotifier.h b/sky/engine/core/dom/DocumentLifecycleNotifier.h deleted file mode 100644 index 7b71baf6cc17a..0000000000000 --- a/sky/engine/core/dom/DocumentLifecycleNotifier.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLENOTIFIER_H_ -#define SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLENOTIFIER_H_ - -#include "sky/engine/core/dom/DocumentLifecycleObserver.h" -#include "sky/engine/wtf/PassOwnPtr.h" -#include "sky/engine/wtf/TemporaryChange.h" - -namespace blink { - -class Document; - -class DocumentLifecycleNotifier : public LifecycleNotifier { -public: - static PassOwnPtr create(Document*); - - void notifyDocumentWasDetached(); -#if !ENABLE(OILPAN) - void notifyDocumentWasDisposed(); -#endif - - virtual void addObserver(Observer*) override final; - virtual void removeObserver(Observer*) override final; - -private: - explicit DocumentLifecycleNotifier(Document*); - - typedef HashSet DocumentObserverSet; - DocumentObserverSet m_documentObservers; -}; - -inline PassOwnPtr DocumentLifecycleNotifier::create(Document* document) -{ - return adoptPtr(new DocumentLifecycleNotifier(document)); -} - -inline void DocumentLifecycleNotifier::notifyDocumentWasDetached() -{ - TemporaryChange scope(this->m_iterating, IteratingOverDocumentObservers); - for (DocumentObserverSet::iterator i = m_documentObservers.begin(); i != m_documentObservers.end(); ++i) - (*i)->documentWasDetached(); -} - -#if !ENABLE(OILPAN) -inline void DocumentLifecycleNotifier::notifyDocumentWasDisposed() -{ - TemporaryChange scope(this->m_iterating, IteratingOverDocumentObservers); - for (DocumentObserverSet::iterator i = m_documentObservers.begin(); i != m_documentObservers.end(); ++i) - (*i)->documentWasDisposed(); -} -#endif - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLENOTIFIER_H_ diff --git a/sky/engine/core/dom/DocumentLifecycleObserver.cpp b/sky/engine/core/dom/DocumentLifecycleObserver.cpp deleted file mode 100644 index 831fc3b897796..0000000000000 --- a/sky/engine/core/dom/DocumentLifecycleObserver.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "sky/engine/core/dom/DocumentLifecycleObserver.h" - -#include "sky/engine/core/dom/Document.h" - -namespace blink { - -template<> void observerContext(Document* context, LifecycleObserver* observer) -{ - static_cast*>(context)->wasObservedBy(observer); -} - -template<> void unobserverContext(Document* context, LifecycleObserver* observer) -{ - static_cast*>(context)->wasUnobservedBy(observer); -} - -DocumentLifecycleObserver::DocumentLifecycleObserver(Document* document) - : LifecycleObserver(document, DocumentLifecycleObserverType) -{ -} - -DocumentLifecycleObserver::~DocumentLifecycleObserver() -{ -} - -} // namespace blink diff --git a/sky/engine/core/dom/DocumentLifecycleObserver.h b/sky/engine/core/dom/DocumentLifecycleObserver.h deleted file mode 100644 index 7ca6df0aaea96..0000000000000 --- a/sky/engine/core/dom/DocumentLifecycleObserver.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLEOBSERVER_H_ -#define SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLEOBSERVER_H_ - -#include "sky/engine/platform/LifecycleContext.h" - -namespace blink { - -class Document; - -template<> void observerContext(Document*, LifecycleObserver*); -template<> void unobserverContext(Document*, LifecycleObserver*); - -class DocumentLifecycleObserver : public LifecycleObserver { -public: - explicit DocumentLifecycleObserver(Document*); - virtual ~DocumentLifecycleObserver(); - virtual void documentWasDetached() { } -#if !ENABLE(OILPAN) - virtual void documentWasDisposed() { } -#endif -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_DOCUMENTLIFECYCLEOBSERVER_H_ diff --git a/sky/engine/core/dom/Element.cpp b/sky/engine/core/dom/Element.cpp index 4a9546406976a..f071f191192cf 100644 --- a/sky/engine/core/dom/Element.cpp +++ b/sky/engine/core/dom/Element.cpp @@ -59,8 +59,6 @@ #include "sky/engine/core/editing/FrameSelection.h" #include "sky/engine/core/editing/TextIterator.h" #include "sky/engine/core/editing/htmlediting.h" -#include "sky/engine/core/events/EventDispatcher.h" -#include "sky/engine/core/events/FocusEvent.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" @@ -1143,32 +1141,6 @@ bool Element::isKeyboardFocusable() const return isFocusable() && tabIndex() >= 0; } -void Element::dispatchFocusEvent(Element* oldFocusedElement, FocusType type) -{ - RefPtr event = FocusEvent::create(EventTypeNames::focus, false, false, document().domWindow(), 0, oldFocusedElement); - EventDispatcher::dispatchEvent(this, FocusEventDispatchMediator::create(event.release())); -} - -void Element::dispatchBlurEvent(Element* newFocusedElement) -{ - RefPtr event = FocusEvent::create(EventTypeNames::blur, false, false, document().domWindow(), 0, newFocusedElement); - EventDispatcher::dispatchEvent(this, BlurEventDispatchMediator::create(event.release())); -} - -void Element::dispatchFocusInEvent(const AtomicString& eventType, Element* oldFocusedElement) -{ - ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - ASSERT(eventType == EventTypeNames::focusin || eventType == EventTypeNames::DOMFocusIn); - dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(FocusEvent::create(eventType, true, false, document().domWindow(), 0, oldFocusedElement))); -} - -void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newFocusedElement) -{ - ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - ASSERT(eventType == EventTypeNames::focusout || eventType == EventTypeNames::DOMFocusOut); - dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(FocusEvent::create(eventType, true, false, document().domWindow(), 0, newFocusedElement))); -} - RenderStyle* Element::computedStyle() { // FIXME: Find and use the renderer from the pseudo element instead of the actual element so that the 'length' diff --git a/sky/engine/core/dom/Element.idl b/sky/engine/core/dom/Element.idl index 28f2168295d97..ffd15e8ab654b 100644 --- a/sky/engine/core/dom/Element.idl +++ b/sky/engine/core/dom/Element.idl @@ -2,9 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -[ - CustomConstructor, -] interface Element : ParentNode { +interface Element : ParentNode { readonly attribute DOMString tagName; boolean hasAttribute(DOMString name); diff --git a/sky/engine/core/dom/ExecutionContext.cpp b/sky/engine/core/dom/ExecutionContext.cpp deleted file mode 100644 index cd8c11b8a68ee..0000000000000 --- a/sky/engine/core/dom/ExecutionContext.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2012 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/dom/ExecutionContext.h" - -#include "sky/engine/core/dom/ContextLifecycleNotifier.h" -#include "sky/engine/core/events/ErrorEvent.h" -#include "sky/engine/core/events/EventTarget.h" -#include "sky/engine/core/inspector/ScriptCallStack.h" -#include "sky/engine/wtf/MainThread.h" - -namespace blink { - -class ExecutionContext::PendingException { - WTF_MAKE_NONCOPYABLE(PendingException); -public: - PendingException(const String& errorMessage, int lineNumber, int columnNumber, int scriptId, const String& sourceURL, PassRefPtr callStack) - : m_errorMessage(errorMessage) - , m_lineNumber(lineNumber) - , m_columnNumber(columnNumber) - , m_scriptId(scriptId) - , m_sourceURL(sourceURL) - , m_callStack(callStack) - { - } - String m_errorMessage; - int m_lineNumber; - int m_columnNumber; - int m_scriptId; - String m_sourceURL; - RefPtr m_callStack; -}; - -ExecutionContext::ExecutionContext() - : m_client(0) - , m_circularSequentialID(0) - , m_inDispatchErrorEvent(false) - , m_activeDOMObjectsAreSuspended(false) - , m_activeDOMObjectsAreStopped(false) -{ -} - -ExecutionContext::~ExecutionContext() -{ -} - -bool ExecutionContext::hasPendingActivity() -{ - return lifecycleNotifier().hasPendingActivity(); -} - -void ExecutionContext::stopActiveDOMObjects() -{ - m_activeDOMObjectsAreStopped = true; - lifecycleNotifier().notifyStoppingActiveDOMObjects(); -} - -unsigned ExecutionContext::activeDOMObjectCount() -{ - return lifecycleNotifier().activeDOMObjects().size(); -} - -void ExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* object) -{ - ASSERT(lifecycleNotifier().contains(object)); - // Ensure all ActiveDOMObjects are suspended also newly created ones. - if (m_activeDOMObjectsAreSuspended) - object->suspend(); -} - -void ExecutionContext::reportException(PassRefPtr event, int scriptId, PassRefPtr callStack) -{ - RefPtr errorEvent = event; - if (m_inDispatchErrorEvent) { - if (!m_pendingExceptions) - m_pendingExceptions = adoptPtr(new Vector >()); - m_pendingExceptions->append(adoptPtr(new PendingException(errorEvent->messageForConsole(), errorEvent->lineno(), errorEvent->colno(), scriptId, errorEvent->filename(), callStack))); - return; - } - - // First report the original exception and only then all the nested ones. - if (!dispatchErrorEvent(errorEvent) && m_client) - m_client->logExceptionToConsole(errorEvent->messageForConsole(), scriptId, errorEvent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack); - - if (!m_pendingExceptions) - return; - - for (size_t i = 0; i < m_pendingExceptions->size(); i++) { - PendingException* e = m_pendingExceptions->at(i).get(); - if (m_client) - m_client->logExceptionToConsole(e->m_errorMessage, e->m_scriptId, e->m_sourceURL, e->m_lineNumber, e->m_columnNumber, e->m_callStack); - } - m_pendingExceptions.clear(); -} - -void ExecutionContext::addConsoleMessage(PassRefPtr consoleMessage) -{ - if (!m_client) - return; - m_client->addMessage(consoleMessage); -} - -bool ExecutionContext::dispatchErrorEvent(PassRefPtr event) -{ - if (!m_client) - return false; - EventTarget* target = m_client->errorEventTarget(); - if (!target) - return false; - - RefPtr errorEvent = event; - ASSERT(!m_inDispatchErrorEvent); - m_inDispatchErrorEvent = true; - target->dispatchEvent(errorEvent); - m_inDispatchErrorEvent = false; - return errorEvent->defaultPrevented(); -} - -int ExecutionContext::circularSequentialID() -{ - ++m_circularSequentialID; - if (m_circularSequentialID <= 0) - m_circularSequentialID = 1; - return m_circularSequentialID; -} - -int ExecutionContext::installNewTimeout(PassOwnPtr action, int timeout, bool singleShot) -{ - int timeoutID; - while (true) { - timeoutID = circularSequentialID(); - if (!m_timeouts.contains(timeoutID)) - break; - } - TimeoutMap::AddResult result = m_timeouts.add(timeoutID, DOMTimer::create(this, action, timeout, singleShot, timeoutID)); - ASSERT(result.isNewEntry); - DOMTimer* timer = result.storedValue->value.get(); - - timer->suspendIfNeeded(); - - return timer->timeoutID(); -} - -void ExecutionContext::removeTimeoutByID(int timeoutID) -{ - if (timeoutID <= 0) - return; - m_timeouts.remove(timeoutID); -} - -void ExecutionContext::didChangeTimerAlignmentInterval() -{ - for (TimeoutMap::iterator iter = m_timeouts.begin(); iter != m_timeouts.end(); ++iter) - iter->value->didChangeAlignmentInterval(); -} - -const KURL& ExecutionContext::url() const -{ - if (!m_client) { - DEFINE_STATIC_LOCAL(KURL, emptyURL, ()); - return emptyURL; - } - - return virtualURL(); -} - -KURL ExecutionContext::completeURL(const String& url) const -{ - - if (!m_client) { - DEFINE_STATIC_LOCAL(KURL, emptyURL, ()); - return emptyURL; - } - - return virtualCompleteURL(url); -} - -LocalDOMWindow* ExecutionContext::executingWindow() const -{ - RELEASE_ASSERT(m_client); - return m_client->executingWindow(); -} - -double ExecutionContext::timerAlignmentInterval() const -{ - if (!m_client) - return DOMTimer::visiblePageAlignmentInterval(); - return m_client->timerAlignmentInterval(); -} - -PassOwnPtr > ExecutionContext::createLifecycleNotifier() -{ - return ContextLifecycleNotifier::create(this); -} - -ContextLifecycleNotifier& ExecutionContext::lifecycleNotifier() -{ - return static_cast(LifecycleContext::lifecycleNotifier()); -} - -bool ExecutionContext::isIteratingOverObservers() const -{ - return m_lifecycleNotifier && m_lifecycleNotifier->isIteratingOverObservers(); -} - -} // namespace blink diff --git a/sky/engine/core/dom/ExecutionContext.h b/sky/engine/core/dom/ExecutionContext.h deleted file mode 100644 index 6037a77b788aa..0000000000000 --- a/sky/engine/core/dom/ExecutionContext.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2012 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_DOM_EXECUTIONCONTEXT_H_ -#define SKY_ENGINE_CORE_DOM_EXECUTIONCONTEXT_H_ - -#include "sky/engine/core/dom/ActiveDOMObject.h" -#include "sky/engine/core/dom/ExecutionContextClient.h" -#include "sky/engine/core/frame/ConsoleTypes.h" -#include "sky/engine/core/frame/DOMTimer.h" -#include "sky/engine/core/inspector/ConsoleMessage.h" -#include "sky/engine/platform/LifecycleContext.h" -#include "sky/engine/platform/Supplementable.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/platform/weborigin/KURL.h" -#include "sky/engine/wtf/OwnPtr.h" -#include "sky/engine/wtf/PassOwnPtr.h" - -namespace blink { - -class ContextLifecycleNotifier; -class LocalDOMWindow; -class ErrorEvent; -class EventQueue; -class ScriptState; -class ScriptCallStack; - -class ExecutionContext - : public LifecycleContext - , public Supplementable { -public: - // Delegating to ExecutionContextClient - bool isDocument() const { return m_client && m_client->isDocument(); } - const KURL& url() const; - KURL completeURL(const String& url) const; - LocalDOMWindow* executingWindow() const; - double timerAlignmentInterval() const; - - virtual void reportBlockedScriptExecutionToInspector(const String& directiveText) = 0; - - KURL contextURL() const { return virtualURL(); } - KURL contextCompleteURL(const String& url) const { return virtualCompleteURL(url); } - - void reportException(PassRefPtr, int scriptId, PassRefPtr); - - void addConsoleMessage(PassRefPtr); - - // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked. - bool hasPendingActivity(); - - void stopActiveDOMObjects(); - unsigned activeDOMObjectCount(); - - bool activeDOMObjectsAreSuspended() const { return m_activeDOMObjectsAreSuspended; } - bool activeDOMObjectsAreStopped() const { return m_activeDOMObjectsAreStopped; } - bool isIteratingOverObservers() const; - - // Called after the construction of an ActiveDOMObject to synchronize suspend state. - void suspendActiveDOMObjectIfNeeded(ActiveDOMObject*); -#if !ENABLE(OILPAN) - void ref() { refExecutionContext(); } - void deref() { derefExecutionContext(); } -#endif - - // Gets the next id in a circular sequence from 1 to 2^31-1. - int circularSequentialID(); - - void didChangeTimerAlignmentInterval(); - - PassOwnPtr > createLifecycleNotifier(); - - virtual EventQueue* eventQueue() const = 0; - -protected: - ExecutionContext(); - virtual ~ExecutionContext(); - - void setClient(ExecutionContextClient* client) { m_client = client; } - - virtual const KURL& virtualURL() const = 0; - virtual KURL virtualCompleteURL(const String&) const = 0; - - ContextLifecycleNotifier& lifecycleNotifier(); - -private: - friend class DOMTimer; // For installNewTimeout() and removeTimeoutByID() below. - - bool dispatchErrorEvent(PassRefPtr); - -#if !ENABLE(OILPAN) - virtual void refExecutionContext() = 0; - virtual void derefExecutionContext() = 0; -#endif - // LifecycleContext implementation. - - // Implementation details for DOMTimer. No other classes should call these functions. - int installNewTimeout(PassOwnPtr, int timeout, bool singleShot); - void removeTimeoutByID(int timeoutID); // This makes underlying DOMTimer instance destructed. - - ExecutionContextClient* m_client; - - int m_circularSequentialID; - typedef HashMap > TimeoutMap; - TimeoutMap m_timeouts; - - bool m_inDispatchErrorEvent; - class PendingException; - OwnPtr > > m_pendingExceptions; - - bool m_activeDOMObjectsAreSuspended; - bool m_activeDOMObjectsAreStopped; - - // The location of this member is important; to make sure contextDestroyed() notification on - // ExecutionContext's members (notably m_timeouts) is called before they are destructed, - // m_lifecycleNotifer should be placed *after* such members. - OwnPtr m_lifecycleNotifier; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_EXECUTIONCONTEXT_H_ diff --git a/sky/engine/core/dom/ExecutionContextClient.h b/sky/engine/core/dom/ExecutionContextClient.h deleted file mode 100644 index 164d3537229ba..0000000000000 --- a/sky/engine/core/dom/ExecutionContextClient.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_DOM_EXECUTIONCONTEXTCLIENT_H_ -#define SKY_ENGINE_CORE_DOM_EXECUTIONCONTEXTCLIENT_H_ - -#include "sky/engine/core/frame/ConsoleTypes.h" -#include "sky/engine/core/inspector/ConsoleMessage.h" -#include "sky/engine/platform/LifecycleNotifier.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/platform/weborigin/KURL.h" -#include "sky/engine/wtf/Forward.h" - -namespace blink { - -class EventTarget; -class KURL; -class LocalDOMWindow; -class ScriptCallStack; -class ScriptState; - -class ExecutionContextClient { -public: - virtual bool isDocument() const { return false; } - virtual LocalDOMWindow* executingWindow() { return 0; } - virtual void addMessage(PassRefPtr) = 0; - virtual EventTarget* errorEventTarget() = 0; - virtual void logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr) = 0; - virtual double timerAlignmentInterval() const = 0; - - virtual void tasksWereSuspended() { } - virtual void tasksWereResumed() { } - - void addConsoleMessage(PassRefPtr consoleMessage) { addMessage(consoleMessage); } - -protected: - virtual ~ExecutionContextClient() { } - -}; - - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_EXECUTIONCONTEXTCLIENT_H_ diff --git a/sky/engine/core/dom/MutationCallback.h b/sky/engine/core/dom/MutationCallback.h index 8394046f86b08..466ff51afb2ac 100644 --- a/sky/engine/core/dom/MutationCallback.h +++ b/sky/engine/core/dom/MutationCallback.h @@ -45,7 +45,6 @@ class MutationCallback { virtual ~MutationCallback() { } virtual void call(const Vector >&, MutationObserver*) = 0; - virtual ExecutionContext* executionContext() const = 0; }; } diff --git a/sky/engine/core/dom/MutationObserver.cpp b/sky/engine/core/dom/MutationObserver.cpp index 417ba0e86a013..fcccbccf73cb5 100644 --- a/sky/engine/core/dom/MutationObserver.cpp +++ b/sky/engine/core/dom/MutationObserver.cpp @@ -34,7 +34,6 @@ #include "base/bind.h" #include "sky/engine/bindings/exception_state.h" #include "sky/engine/core/dom/ExceptionCode.h" -#include "sky/engine/core/dom/ExecutionContext.h" #include "sky/engine/core/dom/Microtask.h" #include "sky/engine/core/dom/MutationCallback.h" #include "sky/engine/core/dom/MutationObserverRegistration.h" @@ -156,7 +155,7 @@ HashSet > MutationObserver::getObservedNodes() const bool MutationObserver::canDeliver() { - return !m_callback->executionContext()->activeDOMObjectsAreSuspended(); + return true; } void MutationObserver::deliver() diff --git a/sky/engine/core/dom/Node.cpp b/sky/engine/core/dom/Node.cpp index b5654c504ec9a..44e35d55d15ab 100644 --- a/sky/engine/core/dom/Node.cpp +++ b/sky/engine/core/dom/Node.cpp @@ -52,19 +52,10 @@ #include "sky/engine/core/dom/shadow/InsertionPoint.h" #include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/htmlediting.h" -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/EventDispatchMediator.h" -#include "sky/engine/core/events/EventDispatcher.h" -#include "sky/engine/core/events/EventListener.h" -#include "sky/engine/core/events/KeyboardEvent.h" -#include "sky/engine/core/events/TextEvent.h" -#include "sky/engine/core/events/UIEvent.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/RenderBox.h" -#include "sky/engine/platform/EventDispatchForbiddenScope.h" #include "sky/engine/platform/JSONValues.h" #include "sky/engine/platform/Partitions.h" #include "sky/engine/platform/TraceEvent.h" @@ -78,14 +69,6 @@ namespace blink { -struct SameSizeAsNode : public EventTarget, public TreeShared { - uint32_t m_nodeFlags; - void* m_pointer[5]; -}; - -COMPILE_ASSERT(sizeof(Node) <= sizeof(SameSizeAsNode), Node_should_stay_small); - -#if !ENABLE(OILPAN) void* Node::operator new(size_t size) { ASSERT(isMainThread()); @@ -97,7 +80,6 @@ void Node::operator delete(void* ptr) ASSERT(isMainThread()); partitionFree(ptr); } -#endif #if DUMP_NODE_STATISTICS typedef HashSet > WeakNodeSet; @@ -272,9 +254,6 @@ void Node::willBeDeletedFromDocument() Document& document = this->document(); - if (hasEventTargetData()) - clearEventTargetData(); - document.markers().removeMarkers(this); } #endif @@ -327,12 +306,6 @@ static const Node* rootForGC(const Node* node) void Node::AcceptDartGCVisitor(DartGCVisitor& visitor) const { visitor.AddToSetForRoot(rootForGC(this), dart_wrapper()); - EventTarget::AcceptDartGCVisitor(visitor); -} - -Node* Node::toNode() -{ - return this; } short Node::tabIndex() const @@ -715,9 +688,6 @@ void Node::attach(const AttachContext&) void Node::detach(const AttachContext& context) { - ASSERT(document().lifecycle().stateAllowsDetach()); - DocumentLifecycle::DetachScope willDetach(document().lifecycle()); - if (renderer()) renderer()->destroy(); setRenderer(0); @@ -1215,34 +1185,10 @@ static void showSubTreeAcrossFrame(const Node* node, const Node* markedNode, con // -------- -Element* Node::enclosingLinkEventParentOrSelf() -{ - return 0; -} - -const AtomicString& Node::interfaceName() const -{ - return EventTargetNames::Node; -} - -ExecutionContext* Node::executionContext() const -{ - return document().contextDocument().get(); -} - void Node::didMoveToNewDocument(Document& oldDocument) { TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument); - if (const EventTargetData* eventTargetData = this->eventTargetData()) { - const EventListenerMap& listenerMap = eventTargetData->eventListenerMap; - if (!listenerMap.isEmpty()) { - Vector types = listenerMap.eventTypes(); - for (unsigned i = 0; i < types.size(); ++i) - document().addListenerTypeIfNeeded(types[i]); - } - } - oldDocument.markers().removeMarkers(this); oldDocument.updateRangesAfterNodeMovedToAnotherDocument(*this); @@ -1259,53 +1205,6 @@ void Node::didMoveToNewDocument(Document& oldDocument) } } -bool Node::addEventListener(const AtomicString& eventType, PassRefPtr listener, bool useCapture) -{ - if (!EventTarget::addEventListener(eventType, listener, useCapture)) - return false; - - document().addListenerTypeIfNeeded(eventType); - - return true; -} - -void Node::removeAllEventListenersRecursively() -{ - for (Node* node = this; node; node = NodeTraversal::next(*node)) { - node->removeAllEventListeners(); - if (ShadowRoot* root = node->shadowRoot()) - root->removeAllEventListenersRecursively(); - } -} - -typedef HashMap, OwnPtr > EventTargetDataMap; - -static EventTargetDataMap& eventTargetDataMap() -{ - DEFINE_STATIC_LOCAL(OwnPtr, map, (adoptPtr(new EventTargetDataMap()))); - return *map; -} - -EventTargetData* Node::eventTargetData() -{ - return hasEventTargetData() ? eventTargetDataMap().get(this) : 0; -} - -EventTargetData& Node::ensureEventTargetData() -{ - if (hasEventTargetData()) - return *eventTargetDataMap().get(this); - setHasEventTargetData(true); - EventTargetData* data = new EventTargetData; - eventTargetDataMap().set(this, adoptPtr(data)); - return *data; -} - -void Node::clearEventTargetData() -{ - eventTargetDataMap().remove(this); -} - Vector >* Node::mutationObserverRegistry() { if (!hasRareData()) @@ -1426,66 +1325,6 @@ void Node::notifyMutationObserversNodeWillDetach() } } -void Node::handleLocalEvents(Event* event) -{ - if (!hasEventTargetData()) - return; - fireEventListeners(event); -} - -void Node::dispatchScopedEvent(PassRefPtr event) -{ - dispatchScopedEventDispatchMediator(EventDispatchMediator::create(event)); -} - -void Node::dispatchScopedEventDispatchMediator(PassRefPtr eventDispatchMediator) -{ - EventDispatcher::dispatchScopedEvent(this, eventDispatchMediator); -} - -bool Node::dispatchEvent(PassRefPtr event) -{ - return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(event)); -} - -bool Node::dispatchDOMActivateEvent(int detail, PassRefPtr underlyingEvent) -{ - ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - RefPtr event = UIEvent::create(EventTypeNames::DOMActivate, true, true, document().domWindow(), detail); - event->setUnderlyingEvent(underlyingEvent); - dispatchScopedEvent(event); - return event->defaultHandled(); -} - -void Node::dispatchInputEvent() -{ - dispatchScopedEvent(Event::createBubble(EventTypeNames::input)); -} - -void Node::defaultEventHandler(Event* event) -{ - if (event->target() != this) - return; - const AtomicString& eventType = event->type(); - if (eventType == EventTypeNames::keydown || eventType == EventTypeNames::keypress) { - if (event->isKeyboardEvent()) { - if (LocalFrame* frame = document().frame()) - frame->eventHandler().defaultKeyboardEventHandler(toKeyboardEvent(event)); - } - } else if (eventType == EventTypeNames::click) { - int detail = event->isUIEvent() ? static_cast(event)->detail() : 0; - if (dispatchDOMActivateEvent(detail, event)) - event->setDefaultHandled(); - } else if (eventType == EventTypeNames::textInput) { - if (event->hasInterface(EventNames::TextEvent)) { - if (LocalFrame* frame = document().frame()) - frame->eventHandler().defaultTextInputEventHandler(toTextEvent(event)); - } - } else if (event->type() == EventTypeNames::webkitEditableContentChanged) { - dispatchInputEvent(); - } -} - #if !ENABLE(OILPAN) // This is here for inlining inline void TreeScope::removedLastRefToScope() diff --git a/sky/engine/core/dom/Node.h b/sky/engine/core/dom/Node.h index ac5dfdf75ef32..83c7e2c41bd10 100644 --- a/sky/engine/core/dom/Node.h +++ b/sky/engine/core/dom/Node.h @@ -30,7 +30,6 @@ #include "sky/engine/core/dom/TreeScope.h" #include "sky/engine/core/dom/TreeShared.h" #include "sky/engine/core/editing/EditingBoundary.h" -#include "sky/engine/core/events/EventTarget.h" #include "sky/engine/core/inspector/InspectorCounters.h" #include "sky/engine/core/rendering/style/RenderStyleConstants.h" #include "sky/engine/platform/geometry/LayoutRect.h" @@ -56,7 +55,6 @@ class LocalFrame; class IntRect; class KeyboardEvent; class NSResolver; -class NodeEventContext; class NodeList; class NodeRareData; class QualifiedName; @@ -96,8 +94,7 @@ class NodeRareDataBase { // TreeShared should be the last to pack TreeShared::m_refCount and // Node::m_nodeFlags on 64bit platforms. -class Node : public EventTarget, public TreeShared { - DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(TreeShared); +class Node : public DartWrappable, public TreeShared { DEFINE_WRAPPERTYPEINFO(); friend class Document; friend class TreeScope; @@ -281,9 +278,6 @@ class Node : public EventTarget, public TreeShared { void setIsLink(bool f); - bool hasEventTargetData() const { return getFlag(HasEventTargetDataFlag); } - void setHasEventTargetData(bool flag) { setFlag(flag, HasEventTargetDataFlag); } - bool isV8CollectableDuringMinorGC() const { return getFlag(V8CollectableDuringMinorGCFlag); } void markV8CollectableDuringMinorGC() { setFlag(true, V8CollectableDuringMinorGCFlag); } void clearV8CollectableDuringMinorGC() { setFlag(false, V8CollectableDuringMinorGCFlag); } @@ -446,32 +440,8 @@ class Node : public EventTarget, public TreeShared { unsigned short compareDocumentPosition(const Node*, ShadowTreesTreatment = TreatShadowTreesAsDisconnected) const; - virtual Node* toNode() override final; void AcceptDartGCVisitor(DartGCVisitor& visitor) const override; - virtual const AtomicString& interfaceName() const override; - virtual ExecutionContext* executionContext() const override final; - - virtual bool addEventListener(const AtomicString& eventType, PassRefPtr, bool useCapture = false) override; - void removeAllEventListenersRecursively(); - - using EventTarget::dispatchEvent; - virtual bool dispatchEvent(PassRefPtr) override; - - void dispatchScopedEvent(PassRefPtr); - void dispatchScopedEventDispatchMediator(PassRefPtr); - - virtual void handleLocalEvents(Event*); - - bool dispatchDOMActivateEvent(int detail, PassRefPtr underlyingEvent); - void dispatchInputEvent(); - - // Perform the default action for an event. - virtual void defaultEventHandler(Event*); - - virtual EventTargetData* eventTargetData() override; - virtual EventTargetData& ensureEventTargetData() override; - void getRegisteredMutationObserversOfType(HashMap, MutationRecordDeliveryOptions>&, MutationObserver::MutationType, const QualifiedName* attributeName); void registerMutationObserver(MutationObserver&, MutationObserverOptions, const HashSet& attributeFilter); void unregisterMutationObserver(MutationObserverRegistration*); @@ -525,8 +495,7 @@ class Node : public EventTarget, public TreeShared { IsEditingTextFlag = 1 << 23, HasWeakReferencesFlag = 1 << 24, V8CollectableDuringMinorGCFlag = 1 << 25, - HasEventTargetDataFlag = 1 << 26, - AlreadySpellCheckedFlag = 1 << 27, + AlreadySpellCheckedFlag = 1 << 26, DefaultNodeFlags = ChildNeedsStyleRecalcFlag | NeedsReattachStyleChange }; @@ -556,20 +525,14 @@ class Node : public EventTarget, public TreeShared { virtual void didMoveToNewDocument(Document& oldDocument); -#if !ENABLE(OILPAN) void willBeDeletedFromDocument(); -#endif bool hasRareData() const { return getFlag(HasRareDataFlag); } NodeRareData* rareData() const; NodeRareData& ensureRareData(); -#if !ENABLE(OILPAN) void clearRareData(); - void clearEventTargetData(); -#endif - void setTreeScope(TreeScope* scope) { m_treeScope = scope; } // isTreeScopeInitialized() can be false diff --git a/sky/engine/core/dom/Node.idl b/sky/engine/core/dom/Node.idl index 432d717d1ca28..3e67baa70fb18 100644 --- a/sky/engine/core/dom/Node.idl +++ b/sky/engine/core/dom/Node.idl @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -interface Node : EventTarget { +interface Node { Node cloneNode([Named] optional boolean deep = true); readonly attribute ParentNode owner; diff --git a/sky/engine/core/dom/Range.cpp b/sky/engine/core/dom/Range.cpp index 7e4c53c3c2ce5..d274ed0986ede 100644 --- a/sky/engine/core/dom/Range.cpp +++ b/sky/engine/core/dom/Range.cpp @@ -36,7 +36,6 @@ #include "sky/engine/core/editing/TextIterator.h" #include "sky/engine/core/editing/VisiblePosition.h" #include "sky/engine/core/editing/VisibleUnits.h" -#include "sky/engine/core/events/ScopedEventQueue.h" #include "sky/engine/core/html/HTMLElement.h" #include "sky/engine/core/rendering/RenderBoxModelObject.h" #include "sky/engine/core/rendering/RenderText.h" @@ -69,6 +68,11 @@ PassRefPtr Range::create(Document& ownerDocument) return adoptRef(new Range(ownerDocument)); } +PassRefPtr Range::create(Document* ownerDocument) +{ + return adoptRef(new Range(*ownerDocument)); +} + inline Range::Range(Document& ownerDocument, Node* startContainer, int startOffset, Node* endContainer, int endOffset) : m_ownerDocument(&ownerDocument) , m_start(m_ownerDocument) @@ -458,7 +462,6 @@ void Range::deleteContents(ExceptionState& exceptionState) ASSERT(boundaryPointsValid()); { - EventQueueScope eventQueueScope; processContents(DELETE_CONTENTS, exceptionState); } } @@ -840,7 +843,6 @@ void Range::insertNode(PassRefPtr prpNewNode, ExceptionState& exceptionSta break; } - EventQueueScope scope; bool collapsed = m_start == m_end; RefPtr container = nullptr; if (startIsText) { @@ -855,8 +857,7 @@ void Range::insertNode(PassRefPtr prpNewNode, ExceptionState& exceptionSta return; if (collapsed) { - // The load event would be fired regardless of EventQueueScope; - // e.g. by ContainerNode::updateTreeAfterInsertion + // The load event would be fired e.g. by ContainerNode::updateTreeAfterInsertion // Given circumstance may mutate the tree so newText->parentNode() may become null if (!newText->parentNode()) { exceptionState.ThrowDOMException(HierarchyRequestError, "This operation would set range's end to parent with new offset, but there's no parent into which to continue."); diff --git a/sky/engine/core/dom/Range.h b/sky/engine/core/dom/Range.h index 210ddb9ef84ce..81e3c5dc68814 100644 --- a/sky/engine/core/dom/Range.h +++ b/sky/engine/core/dom/Range.h @@ -49,7 +49,8 @@ class Text; class Range final : public RefCounted, public DartWrappable { DEFINE_WRAPPERTYPEINFO(); -public: + public: + static PassRefPtr create(Document*); static PassRefPtr create(Document&); static PassRefPtr create(Document&, Node* startContainer, int startOffset, Node* endContainer, int endOffset); static PassRefPtr create(Document&, const Position&, const Position&); diff --git a/sky/engine/core/dom/Range.idl b/sky/engine/core/dom/Range.idl index 30d49a5b39be4..042f2959c8028 100644 --- a/sky/engine/core/dom/Range.idl +++ b/sky/engine/core/dom/Range.idl @@ -20,8 +20,7 @@ // Introduced in DOM Level 2: [ - Constructor, - ConstructorCallWith=Document, + Constructor(Document document), ] interface Range { readonly attribute Node startContainer; diff --git a/sky/engine/core/dom/ScriptedAnimationController.cpp b/sky/engine/core/dom/ScriptedAnimationController.cpp index d2a6fe379c38e..703284780ab82 100644 --- a/sky/engine/core/dom/ScriptedAnimationController.cpp +++ b/sky/engine/core/dom/ScriptedAnimationController.cpp @@ -36,11 +36,6 @@ namespace blink { -std::pair eventTargetKey(const Event* event) -{ - return std::make_pair(event->target(), event->type().impl()); -} - ScriptedAnimationController::ScriptedAnimationController(Document* document) : m_document(document) , m_nextCallbackId(0) @@ -101,18 +96,6 @@ void ScriptedAnimationController::dispatchEvents() { Vector > events; events.swap(m_eventQueue); - m_perFrameEvents.clear(); - - for (size_t i = 0; i < events.size(); ++i) { - EventTarget* eventTarget = events[i]->target(); - // FIXME: we should figure out how to make dispatchEvent properly virtual to avoid - // special casting window. - // FIXME: We should not fire events for nodes that are no longer in the tree. - if (LocalDOMWindow* window = eventTarget->toDOMWindow()) - window->dispatchEvent(events[i], nullptr); - else - eventTarget->dispatchEvent(events[i]); - } } void ScriptedAnimationController::executeCallbacks(double monotonicTimeNow) @@ -179,8 +162,6 @@ void ScriptedAnimationController::enqueueEvent(PassRefPtr event) void ScriptedAnimationController::enqueuePerFrameEvent(PassRefPtr event) { - if (!m_perFrameEvents.add(eventTargetKey(event.get())).isNewEntry) - return; enqueueEvent(event); } diff --git a/sky/engine/core/dom/ScriptedAnimationController.h b/sky/engine/core/dom/ScriptedAnimationController.h index f98a2338dc97c..37e350b6053e5 100644 --- a/sky/engine/core/dom/ScriptedAnimationController.h +++ b/sky/engine/core/dom/ScriptedAnimationController.h @@ -37,7 +37,6 @@ namespace blink { class Document; class Event; -class EventTarget; class MediaQueryListListener; class RequestAnimationFrameCallback; @@ -80,7 +79,6 @@ class ScriptedAnimationController : public RefCounted > m_eventQueue; - ListHashSet, const StringImpl*> > m_perFrameEvents; typedef ListHashSet > MediaQueryListListeners; MediaQueryListListeners m_mediaQueryListListeners; }; diff --git a/sky/engine/core/dom/Text.cpp b/sky/engine/core/dom/Text.cpp index 532bb6e891766..1e124961f4747 100644 --- a/sky/engine/core/dom/Text.cpp +++ b/sky/engine/core/dom/Text.cpp @@ -30,7 +30,6 @@ #include "sky/engine/core/dom/NodeTraversal.h" #include "sky/engine/core/dom/RenderTreeBuilder.h" #include "sky/engine/core/dom/shadow/ShadowRoot.h" -#include "sky/engine/core/events/ScopedEventQueue.h" #include "sky/engine/core/rendering/RenderText.h" #include "sky/engine/wtf/text/CString.h" #include "sky/engine/wtf/text/StringBuilder.h" @@ -56,7 +55,6 @@ PassRefPtr Text::splitText(unsigned offset, ExceptionState& exceptionState return nullptr; } - EventQueueScope scope; String oldStr = data(); RefPtr newText = cloneWithData(oldStr.substring(offset)); setDataWithoutUpdate(oldStr.substring(0, offset)); diff --git a/sky/engine/core/dom/Text.idl b/sky/engine/core/dom/Text.idl index 518f49f8d1699..f46eaee86dacc 100644 --- a/sky/engine/core/dom/Text.idl +++ b/sky/engine/core/dom/Text.idl @@ -16,10 +16,7 @@ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -[ - Constructor(optional DOMString data = ""), - ConstructorCallWith=Document, -] interface Text : CharacterData { +interface Text : CharacterData { [RaisesException] Text splitText(unsigned long offset); sequence getDestinationInsertionPoints(); }; diff --git a/sky/engine/core/dom/TreeScope.cpp b/sky/engine/core/dom/TreeScope.cpp index 13ede6e16e8ba..256818a49c56f 100644 --- a/sky/engine/core/dom/TreeScope.cpp +++ b/sky/engine/core/dom/TreeScope.cpp @@ -37,7 +37,6 @@ #include "sky/engine/core/dom/shadow/ElementShadow.h" #include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/DOMSelection.h" -#include "sky/engine/core/events/EventPath.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/page/FocusController.h" @@ -222,22 +221,6 @@ void TreeScope::adoptIfNeeded(Node& node) Element* TreeScope::adjustedFocusedElement() const { - Document& document = rootNode().document(); - Element* element = document.focusedElement(); - if (!element) - return 0; - - EventPath eventPath(element); - for (size_t i = 0; i < eventPath.size(); ++i) { - if (eventPath[i].node() == rootNode()) { - // eventPath.at(i).target() is one of the followings: - // - InsertionPoint - // - shadow host - // - Document::focusedElement() - // So, it's safe to do toElement(). - return toElement(eventPath[i].target()->toNode()); - } - } return 0; } diff --git a/sky/engine/core/editing/CompositeEditCommand.cpp b/sky/engine/core/editing/CompositeEditCommand.cpp index e2947a999a1f9..a09ad2dc895a6 100644 --- a/sky/engine/core/editing/CompositeEditCommand.cpp +++ b/sky/engine/core/editing/CompositeEditCommand.cpp @@ -51,7 +51,6 @@ #include "sky/engine/core/editing/TextIterator.h" #include "sky/engine/core/editing/VisibleUnits.h" #include "sky/engine/core/editing/htmlediting.h" -#include "sky/engine/core/events/ScopedEventQueue.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/html/HTMLElement.h" #include "sky/engine/core/rendering/InlineTextBox.h" @@ -175,7 +174,6 @@ void CompositeEditCommand::apply() LocalFrame* frame = document().frame(); ASSERT(frame); { - EventQueueScope eventQueueScope; doApply(); } diff --git a/sky/engine/core/editing/DOMSelection.cpp b/sky/engine/core/editing/DOMSelection.cpp index 8ae860b5c5e19..62d82ed6fa266 100644 --- a/sky/engine/core/editing/DOMSelection.cpp +++ b/sky/engine/core/editing/DOMSelection.cpp @@ -386,17 +386,6 @@ void DOMSelection::addRange(Range* newRange) if (!m_frame) return; - // FIXME: Should we throw DOMException for error cases below? - if (!newRange) { - addConsoleError("The given range is null."); - return; - } - - if (!newRange->startContainer()) { - addConsoleError("The given range has no container. Perhaps 'detach()' has been invoked on it?"); - return; - } - FrameSelection& selection = m_frame->selection(); if (selection.isNone()) { @@ -406,21 +395,6 @@ void DOMSelection::addRange(Range* newRange) RefPtr originalRange = selection.firstRange(); - if (originalRange->startContainer()->document() != newRange->startContainer()->document()) { - addConsoleError("The given range does not belong to the current selection's document."); - return; - } - if (originalRange->startContainer()->treeScope() != newRange->startContainer()->treeScope()) { - addConsoleError("The given range and the current selection belong to two different document fragments."); - return; - } - - if (originalRange->compareBoundaryPoints(Range::START_TO_END, newRange, ASSERT_NO_EXCEPTION) < 0 - || newRange->compareBoundaryPoints(Range::START_TO_END, originalRange.get(), ASSERT_NO_EXCEPTION) < 0) { - addConsoleError("Discontiguous selection is not supported."); - return; - } - // FIXME: "Merge the ranges if they intersect" is Blink-specific behavior; other browsers supporting discontiguous // selection (obviously) keep each Range added and return it in getRangeAt(). But it's unclear if we can really // do the same, since we don't support discontiguous selection. Further discussions at @@ -546,10 +520,4 @@ bool DOMSelection::isValidForPosition(Node* node) const return node->document() == m_frame->document(); } -void DOMSelection::addConsoleError(const String& message) -{ - if (m_treeScope) - m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); -} - } // namespace blink diff --git a/sky/engine/core/editing/DOMSelection.h b/sky/engine/core/editing/DOMSelection.h index feb237173c30d..5f477f0abcf26 100644 --- a/sky/engine/core/editing/DOMSelection.h +++ b/sky/engine/core/editing/DOMSelection.h @@ -107,8 +107,6 @@ class DOMSelection final : public RefCounted, public DartWrappable bool isValidForPosition(Node*) const; - void addConsoleError(const String& message); - RawPtr m_treeScope; }; diff --git a/sky/engine/core/editing/Editor.cpp b/sky/engine/core/editing/Editor.cpp index 0ae4fa536eebc..f26102ba4fa8c 100644 --- a/sky/engine/core/editing/Editor.cpp +++ b/sky/engine/core/editing/Editor.cpp @@ -28,6 +28,7 @@ #include "gen/sky/core/CSSPropertyNames.h" #include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" #include "sky/engine/bindings/exception_state_placeholder.h" #include "sky/engine/core/css/CSSComputedStyleDeclaration.h" #include "sky/engine/core/css/StylePropertySet.h" @@ -45,20 +46,21 @@ #include "sky/engine/core/editing/VisibleUnits.h" #include "sky/engine/core/editing/htmlediting.h" #include "sky/engine/core/events/KeyboardEvent.h" -#include "sky/engine/core/events/ScopedEventQueue.h" #include "sky/engine/core/events/TextEvent.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/loader/EmptyClients.h" #include "sky/engine/core/page/EditorClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/FocusController.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/HitTestResult.h" #include "sky/engine/platform/weborigin/KURL.h" #include "sky/engine/wtf/unicode/CharacterNames.h" +// This file is in tatters. It didn't survive the EventTarget removal at all well. +// TODO(ianh): It should be next to go. + namespace blink { using namespace WTF::Unicode; @@ -269,7 +271,6 @@ void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace) ContainerNode* target = findEventTargetFromSelection(); if (!target) return; - target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame.domWindow(), pastingText, smartReplace), IGNORE_EXCEPTION); } void Editor::pasteAsFragment(PassRefPtr pastingFragment, bool smartReplace, bool matchStyle) @@ -277,7 +278,6 @@ void Editor::pasteAsFragment(PassRefPtr pastingFragment, bool ContainerNode* target = findEventTargetFromSelection(); if (!target) return; - target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame.domWindow(), pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION); } bool Editor::tryDHTMLCopy() @@ -357,22 +357,12 @@ ContainerNode* Editor::findEventTargetFromSelection() const return findEventTargetFrom(m_frame.selection().selection()); } -static void dispatchEditableContentChangedEvents(PassRefPtr startRoot, PassRefPtr endRoot) -{ - if (startRoot) - startRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableContentChanged), IGNORE_EXCEPTION); - if (endRoot && endRoot != startRoot) - endRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableContentChanged), IGNORE_EXCEPTION); -} - void Editor::appliedEditing(PassRefPtr cmd) { - EventQueueScope scope; m_frame.document()->updateLayout(); EditCommandComposition* composition = cmd->composition(); ASSERT(composition); - dispatchEditableContentChangedEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement()); VisibleSelection newSelection(cmd->endingSelection()); // Don't clear the typing style with this selection change. We do those things elsewhere if necessary. @@ -397,11 +387,8 @@ void Editor::appliedEditing(PassRefPtr cmd) void Editor::unappliedEditing(PassRefPtr cmd) { - EventQueueScope scope; m_frame.document()->updateLayout(); - dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement()); - VisibleSelection newSelection(cmd->startingSelection()); newSelection.validatePositionsIfNeeded(); if (newSelection.start().document() == m_frame.document() && newSelection.end().document() == m_frame.document()) @@ -415,11 +402,8 @@ void Editor::unappliedEditing(PassRefPtr cmd) void Editor::reappliedEditing(PassRefPtr cmd) { - EventQueueScope scope; m_frame.document()->updateLayout(); - dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement()); - VisibleSelection newSelection(cmd->endingSelection()); changeSelectionAfterCommand(newSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle); @@ -458,7 +442,7 @@ void Editor::clear() bool Editor::insertText(const String& text, KeyboardEvent* triggeringEvent) { - return m_frame.eventHandler().handleTextInputEvent(text, triggeringEvent); + return false; } bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectInsertedText, TextEvent* triggeringEvent) @@ -551,10 +535,6 @@ void Editor::performDelete() deleteSelectionWithSmartDelete(canSmartCopyOrDelete()); } -void Editor::countEvent(ExecutionContext* executionContext, const Event* event) -{ -} - void Editor::copyImage(const HitTestResult& result) { } diff --git a/sky/engine/core/editing/Editor.h b/sky/engine/core/editing/Editor.h index d9e0cef70e232..0aedd6c70c8ec 100644 --- a/sky/engine/core/editing/Editor.h +++ b/sky/engine/core/editing/Editor.h @@ -92,7 +92,6 @@ class Editor final { void pasteAsPlainText(); void performDelete(); - static void countEvent(ExecutionContext*, const Event*); void copyImage(const HitTestResult&); void transpose(); diff --git a/sky/engine/core/editing/EditorCommand.cpp b/sky/engine/core/editing/EditorCommand.cpp index 36aecb621e7ff..b20ce0c13c3cc 100644 --- a/sky/engine/core/editing/EditorCommand.cpp +++ b/sky/engine/core/editing/EditorCommand.cpp @@ -45,7 +45,6 @@ #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/page/EditorClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/rendering/RenderBox.h" #include "sky/engine/public/platform/Platform.h" #include "sky/engine/wtf/text/AtomicString.h" @@ -74,19 +73,6 @@ static const bool doNotAllowExecutionWhenDisabled = false; static const float kMinFractionToStepWhenPaging = 0.875f; -// Related to Editor::selectionForCommand. -// Certain operations continue to use the target control's selection even if the event handler -// already moved the selection outside of the text control. -static LocalFrame* targetFrame(LocalFrame& frame, Event* event) -{ - if (!event) - return &frame; - Node* node = event->target()->toNode(); - if (!node) - return &frame; - return node->document().frame(); -} - static unsigned verticalScrollDistance(LocalFrame& frame) { Element* focusedElement = frame.document()->focusedElement(); @@ -144,8 +130,7 @@ static bool executeDeleteWordForward(LocalFrame& frame, Event*, EditorCommandSou static bool executeInsertNewline(LocalFrame& frame, Event* event, EditorCommandSource, const String&) { - LocalFrame* targetFrame = blink::targetFrame(frame, event); - return targetFrame->eventHandler().handleTextInputEvent("\n", event, targetFrame->editor().canEditRichly() ? TextEventInputKeyboard : TextEventInputLineBreak); + return false; } static bool executeMoveDown(LocalFrame& frame, Event*, EditorCommandSource, const String&) diff --git a/sky/engine/core/editing/FrameSelection.cpp b/sky/engine/core/editing/FrameSelection.cpp index cfdc2dc6eb286..6ef8483f47f0e 100644 --- a/sky/engine/core/editing/FrameSelection.cpp +++ b/sky/engine/core/editing/FrameSelection.cpp @@ -48,7 +48,6 @@ #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/page/EditorClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/FocusController.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/HitTestRequest.h" @@ -265,8 +264,6 @@ void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelec } notifyAccessibilityForSelectionChange(); - - m_frame->domWindow()->enqueueDocumentEvent(Event::create(EventTypeNames::selectionchange)); } static bool removingNodeRemovesPosition(Node& node, const Position& position) @@ -1257,9 +1254,6 @@ void FrameSelection::selectAll() if (!root) return; - if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart))) - return; - VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(root.get())); setSelection(newSelection); notifyRendererOfSelectionChange(UserTriggered); @@ -1315,9 +1309,6 @@ void FrameSelection::focusedOrActiveStateChanged() m_frame->spellChecker().spellCheckAfterBlur(); setCaretVisibility(activeAndFocused ? Visible : Hidden); - // Update for caps lock state - m_frame->eventHandler().capsLockStateMayHaveChanged(); - // We may have lost active status even though the focusElement hasn't changed // give the element a chance to recalc style if its affected by focus. if (Element* element = document->focusedElement()) @@ -1537,7 +1528,7 @@ bool FrameSelection::dispatchSelectStart() if (!selectStartTarget) return true; - return selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart)); + return false; } void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor) diff --git a/sky/engine/core/editing/InputMethodController.cpp b/sky/engine/core/editing/InputMethodController.cpp index 3a5b2f2f5b240..4e6ab456fa614 100644 --- a/sky/engine/core/editing/InputMethodController.cpp +++ b/sky/engine/core/editing/InputMethodController.cpp @@ -26,6 +26,7 @@ #include "sky/engine/core/editing/InputMethodController.h" +#include "gen/sky/core/EventTypeNames.h" #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/Element.h" #include "sky/engine/core/dom/Range.h" @@ -35,9 +36,11 @@ #include "sky/engine/core/events/CompositionEvent.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/rendering/RenderObject.h" +// This file is new missing the logic it had relating to firing events, since EventTarget is gone. +// TODO(ianh): This makes it essentially useless, and it should probably be removed soon. + namespace blink { InputMethodController::SelectionOffsetsScope::SelectionOffsetsScope(InputMethodController* inputMethodController) @@ -87,7 +90,7 @@ void InputMethodController::clear() bool InputMethodController::insertTextForConfirmedComposition(const String& text) { - return m_frame.eventHandler().handleTextInputEvent(text, 0, TextEventInputComposition); + return false; } void InputMethodController::selectComposition() const @@ -180,22 +183,6 @@ bool InputMethodController::finishComposition(const String& text, FinishComposit if (m_frame.selection().isNone()) return false; - // Dispatch a compositionend event to the focused node. - // We should send this event before sending a TextEvent as written in Section 6.2.2 and 6.2.3 of - // the DOM Event specification. - if (Element* target = m_frame.document()->focusedElement()) { - unsigned baseOffset = m_frame.selection().base().downstream().deprecatedEditingOffset(); - Vector underlines; - for (size_t i = 0; i < m_customCompositionUnderlines.size(); ++i) { - CompositionUnderline underline = m_customCompositionUnderlines[i]; - underline.startOffset -= baseOffset; - underline.endOffset -= baseOffset; - underlines.append(underline); - } - RefPtr event = CompositionEvent::create(EventTypeNames::compositionend, m_frame.domWindow(), text, underlines); - target->dispatchEvent(event, IGNORE_EXCEPTION); - } - // If text is empty, then delete the old composition here. If text is non-empty, InsertTextCommand::input // will delete the old composition with an optimized replace operation. if (text.isEmpty() && mode != CancelComposition) { @@ -230,40 +217,6 @@ void InputMethodController::setComposition(const String& text, const VectorfocusedElement()) { - // Dispatch an appropriate composition event to the focused node. - // We check the composition status and choose an appropriate composition event since this - // function is used for three purposes: - // 1. Starting a new composition. - // Send a compositionstart and a compositionupdate event when this function creates - // a new composition node, i.e. - // m_compositionNode == 0 && !text.isEmpty(). - // Sending a compositionupdate event at this time ensures that at least one - // compositionupdate event is dispatched. - // 2. Updating the existing composition node. - // Send a compositionupdate event when this function updates the existing composition - // node, i.e. m_compositionNode != 0 && !text.isEmpty(). - // 3. Canceling the ongoing composition. - // Send a compositionend event when function deletes the existing composition node, i.e. - // m_compositionNode != 0 && test.isEmpty(). - RefPtr event = nullptr; - if (!hasComposition()) { - // We should send a compositionstart event only when the given text is not empty because this - // function doesn't create a composition node when the text is empty. - if (!text.isEmpty()) { - target->dispatchEvent(CompositionEvent::create(EventTypeNames::compositionstart, m_frame.domWindow(), m_frame.selectedText(), underlines)); - event = CompositionEvent::create(EventTypeNames::compositionupdate, m_frame.domWindow(), text, underlines); - } - } else { - if (!text.isEmpty()) - event = CompositionEvent::create(EventTypeNames::compositionupdate, m_frame.domWindow(), text, underlines); - else - event = CompositionEvent::create(EventTypeNames::compositionend, m_frame.domWindow(), text, underlines); - } - if (event.get()) - target->dispatchEvent(event, IGNORE_EXCEPTION); - } - // If text is empty, then delete the old composition here. If text is non-empty, InsertTextCommand::input // will delete the old composition with an optimized replace operation. if (text.isEmpty()) { diff --git a/sky/engine/core/editing/ReplaceSelectionCommand.cpp b/sky/engine/core/editing/ReplaceSelectionCommand.cpp index bfd1a6d7b580c..82db9278fa914 100644 --- a/sky/engine/core/editing/ReplaceSelectionCommand.cpp +++ b/sky/engine/core/editing/ReplaceSelectionCommand.cpp @@ -154,7 +154,6 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f // Give the root a chance to change the text. RefPtr evt = BeforeTextInsertedEvent::create(text); - editableRoot->dispatchEvent(evt, ASSERT_NO_EXCEPTION); if (text != evt->text() || !editableRoot->rendererIsRichlyEditable()) { restoreAndRemoveTestRenderingNodesToFragment(holder.get()); m_fragment = nullptr; diff --git a/sky/engine/core/editing/TextInsertionBaseCommand.cpp b/sky/engine/core/editing/TextInsertionBaseCommand.cpp index 82620e9659ed0..b4436dbfe2b29 100644 --- a/sky/engine/core/editing/TextInsertionBaseCommand.cpp +++ b/sky/engine/core/editing/TextInsertionBaseCommand.cpp @@ -53,32 +53,13 @@ void TextInsertionBaseCommand::applyTextInsertionCommand(LocalFrame* frame, Pass } } -String dispatchBeforeTextInsertedEvent(const String& text, const VisibleSelection& selectionForInsertion, bool insertionIsForUpdatingComposition) -{ - if (insertionIsForUpdatingComposition) - return text; - - String newText = text; - if (Node* startNode = selectionForInsertion.start().containerNode()) { - if (startNode->rootEditableElement()) { - // Send BeforeTextInsertedEvent. The event handler will update text if necessary. - RefPtr evt = BeforeTextInsertedEvent::create(text); - startNode->rootEditableElement()->dispatchEvent(evt, IGNORE_EXCEPTION); - newText = evt->text(); - } - } - return newText; -} - bool canAppendNewLineFeedToSelection(const VisibleSelection& selection) { Element* element = selection.rootEditableElement(); if (!element) return false; - RefPtr event = BeforeTextInsertedEvent::create(String("\n")); - element->dispatchEvent(event, IGNORE_EXCEPTION); - return event->text().length(); + return false; } } diff --git a/sky/engine/core/editing/TextInsertionBaseCommand.h b/sky/engine/core/editing/TextInsertionBaseCommand.h index f9d5f53ae4774..7dc9d48e1de37 100644 --- a/sky/engine/core/editing/TextInsertionBaseCommand.h +++ b/sky/engine/core/editing/TextInsertionBaseCommand.h @@ -43,7 +43,6 @@ class TextInsertionBaseCommand : public CompositeEditCommand { static void applyTextInsertionCommand(LocalFrame*, PassRefPtr, const VisibleSelection& selectionForInsertion, const VisibleSelection& endingSelection); }; -String dispatchBeforeTextInsertedEvent(const String& text, const VisibleSelection& selectionForInsertion, bool insertionIsForUpdatingComposition); bool canAppendNewLineFeedToSelection(const VisibleSelection&); // LineOperation should define member function "opeartor (size_t lineOffset, size_t lineLength, bool isLastLine)". diff --git a/sky/engine/core/editing/TypingCommand.cpp b/sky/engine/core/editing/TypingCommand.cpp index 7a47fbbeafcb4..bbeae5997ef40 100644 --- a/sky/engine/core/editing/TypingCommand.cpp +++ b/sky/engine/core/editing/TypingCommand.cpp @@ -162,31 +162,7 @@ void TypingCommand::insertText(Document& document, const String& text, Options o // FIXME: We shouldn't need to take selectionForInsertion. It should be identical to FrameSelection's current selection. void TypingCommand::insertText(Document& document, const String& text, const VisibleSelection& selectionForInsertion, Options options, TextCompositionType compositionType) { - RefPtr frame = document.frame(); - ASSERT(frame); - - VisibleSelection currentSelection = frame->selection().selection(); - - String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion, compositionType == TextCompositionUpdate); - - // Set the starting and ending selection appropriately if we are using a selection - // that is different from the current selection. In the future, we should change EditCommand - // to deal with custom selections in a general way that can be used by all of the commands. - if (RefPtr lastTypingCommand = lastTypingCommandIfStillOpenForTyping(frame.get())) { - if (lastTypingCommand->endingSelection() != selectionForInsertion) { - lastTypingCommand->setStartingSelection(selectionForInsertion); - lastTypingCommand->setEndingSelection(selectionForInsertion); - } - - lastTypingCommand->setCompositionType(compositionType); - lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & RetainAutocorrectionIndicator); - lastTypingCommand->setShouldPreventSpellChecking(options & PreventSpellChecking); - lastTypingCommand->insertText(newText, options & SelectInsertedText); - return; - } - - RefPtr cmd = TypingCommand::create(document, InsertText, newText, options, compositionType); - applyTextInsertionCommand(frame.get(), cmd, selectionForInsertion, currentSelection); + ASSERT_NOT_REACHED(); } void TypingCommand::insertLineBreak(Document& document, Options options) @@ -365,6 +341,7 @@ void TypingCommand::insertParagraphSeparator() void TypingCommand::insertParagraphSeparatorInQuotedContent() { + ASSERT_NOT_REACHED(); } bool TypingCommand::makeEditableRootEmpty() diff --git a/sky/engine/core/events/BeforeTextInsertedEvent.cpp b/sky/engine/core/events/BeforeTextInsertedEvent.cpp index eafc93f7ad5cc..9839736f19e6f 100644 --- a/sky/engine/core/events/BeforeTextInsertedEvent.cpp +++ b/sky/engine/core/events/BeforeTextInsertedEvent.cpp @@ -23,6 +23,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" #include "sky/engine/core/events/BeforeTextInsertedEvent.h" namespace blink { diff --git a/sky/engine/core/events/CompositionEvent.cpp b/sky/engine/core/events/CompositionEvent.cpp index 1874b7cc125ae..7b28d470671a4 100644 --- a/sky/engine/core/events/CompositionEvent.cpp +++ b/sky/engine/core/events/CompositionEvent.cpp @@ -24,6 +24,7 @@ * */ +#include "gen/sky/core/EventNames.h" #include "sky/engine/core/events/CompositionEvent.h" namespace blink { @@ -63,9 +64,6 @@ CompositionEvent::~CompositionEvent() void CompositionEvent::initCompositionEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr view, const String& data) { - if (dispatched()) - return; - initUIEvent(type, canBubble, cancelable, view, 0); m_data = data; diff --git a/sky/engine/core/events/DOMWindowEventQueue.cpp b/sky/engine/core/events/DOMWindowEventQueue.cpp deleted file mode 100644 index 9a1e56c6bdfac..0000000000000 --- a/sky/engine/core/events/DOMWindowEventQueue.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/events/DOMWindowEventQueue.h" - -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/frame/LocalDOMWindow.h" -#include "sky/engine/core/frame/SuspendableTimer.h" - -namespace blink { - -class DOMWindowEventQueueTimer : public SuspendableTimer { - WTF_MAKE_NONCOPYABLE(DOMWindowEventQueueTimer); -public: - DOMWindowEventQueueTimer(DOMWindowEventQueue* eventQueue, ExecutionContext* context) - : SuspendableTimer(context) - , m_eventQueue(eventQueue) { } - -private: - virtual void fired() { m_eventQueue->pendingEventTimerFired(); } - - RawPtr m_eventQueue; -}; - -PassRefPtr DOMWindowEventQueue::create(ExecutionContext* context) -{ - return adoptRef(new DOMWindowEventQueue(context)); -} - -DOMWindowEventQueue::DOMWindowEventQueue(ExecutionContext* context) - : m_pendingEventTimer(adoptPtr(new DOMWindowEventQueueTimer(this, context))) - , m_isClosed(false) -{ - m_pendingEventTimer->suspendIfNeeded(); -} - -DOMWindowEventQueue::~DOMWindowEventQueue() -{ -} - -bool DOMWindowEventQueue::enqueueEvent(PassRefPtr event) -{ - if (m_isClosed) - return false; - - ASSERT(event->target()); - - bool wasAdded = m_queuedEvents.add(event).isNewEntry; - ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. - - if (!m_pendingEventTimer->isActive()) - m_pendingEventTimer->startOneShot(0, FROM_HERE); - - return true; -} - -bool DOMWindowEventQueue::cancelEvent(Event* event) -{ - ListHashSet, 16>::iterator it = m_queuedEvents.find(event); - bool found = it != m_queuedEvents.end(); - if (found) { - m_queuedEvents.remove(it); - } - if (m_queuedEvents.isEmpty()) - m_pendingEventTimer->stop(); - return found; -} - -void DOMWindowEventQueue::close() -{ - m_isClosed = true; - m_pendingEventTimer->stop(); - m_queuedEvents.clear(); -} - -void DOMWindowEventQueue::pendingEventTimerFired() -{ - ASSERT(!m_pendingEventTimer->isActive()); - ASSERT(!m_queuedEvents.isEmpty()); - - // Insert a marker for where we should stop. - ASSERT(!m_queuedEvents.contains(nullptr)); - bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry; - ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. - - RefPtr protector(this); - - while (!m_queuedEvents.isEmpty()) { - ListHashSet, 16>::iterator iter = m_queuedEvents.begin(); - RefPtr event = *iter; - m_queuedEvents.remove(iter); - if (!event) - break; - dispatchEvent(event.get()); - } -} - -void DOMWindowEventQueue::dispatchEvent(PassRefPtr event) -{ - EventTarget* eventTarget = event->target(); - if (eventTarget->toDOMWindow()) - eventTarget->toDOMWindow()->dispatchEvent(event, nullptr); - else - eventTarget->dispatchEvent(event); -} - -} diff --git a/sky/engine/core/events/DOMWindowEventQueue.h b/sky/engine/core/events/DOMWindowEventQueue.h deleted file mode 100644 index 7d4584e507d4b..0000000000000 --- a/sky/engine/core/events/DOMWindowEventQueue.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_DOMWINDOWEVENTQUEUE_H_ -#define SKY_ENGINE_CORE_EVENTS_DOMWINDOWEVENTQUEUE_H_ - -#include "sky/engine/core/events/EventQueue.h" -#include "sky/engine/wtf/HashSet.h" -#include "sky/engine/wtf/ListHashSet.h" -#include "sky/engine/wtf/OwnPtr.h" -#include "sky/engine/wtf/RefCounted.h" - -namespace blink { - -class Event; -class DOMWindowEventQueueTimer; -class Node; -class ExecutionContext; - -#if ENABLE(OILPAN) -#define DOMWINDOWEVENTQUEUE_BASE_CLASSES public EventQueue -#else -#define DOMWINDOWEVENTQUEUE_BASE_CLASSES public RefCounted, public EventQueue -#endif - -class DOMWindowEventQueue final : DOMWINDOWEVENTQUEUE_BASE_CLASSES { -public: - static PassRefPtr create(ExecutionContext*); - virtual ~DOMWindowEventQueue(); - - // EventQueue - virtual bool enqueueEvent(PassRefPtr) override; - virtual bool cancelEvent(Event*) override; - virtual void close() override; - -private: - explicit DOMWindowEventQueue(ExecutionContext*); - - void pendingEventTimerFired(); - void dispatchEvent(PassRefPtr); - - OwnPtr m_pendingEventTimer; - ListHashSet, 16> m_queuedEvents; - bool m_isClosed; - - friend class DOMWindowEventQueueTimer; -}; - -} - -#endif // SKY_ENGINE_CORE_EVENTS_DOMWINDOWEVENTQUEUE_H_ diff --git a/sky/engine/core/events/ErrorEvent.cpp b/sky/engine/core/events/ErrorEvent.cpp index de5a72b3fc8de..b6ad075fd33b8 100644 --- a/sky/engine/core/events/ErrorEvent.cpp +++ b/sky/engine/core/events/ErrorEvent.cpp @@ -28,6 +28,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" #include "sky/engine/core/events/ErrorEvent.h" namespace blink { diff --git a/sky/engine/core/events/Event.cpp b/sky/engine/core/events/Event.cpp index ffacc3fe76e99..70a39ad290362 100644 --- a/sky/engine/core/events/Event.cpp +++ b/sky/engine/core/events/Event.cpp @@ -25,7 +25,6 @@ #include "gen/sky/core/EventHeaders.h" #include "gen/sky/core/EventInterfaces.h" #include "sky/engine/core/dom/StaticNodeList.h" -#include "sky/engine/core/events/EventTarget.h" #include "sky/engine/wtf/CurrentTime.h" namespace blink { @@ -40,7 +39,6 @@ Event::Event() , m_defaultHandled(false) , m_cancelBubble(false) , m_eventPhase(0) - , m_currentTarget(nullptr) { } @@ -55,7 +53,6 @@ Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr , m_defaultHandled(false) , m_cancelBubble(false) , m_eventPhase(0) - , m_currentTarget(nullptr) { } @@ -70,7 +67,6 @@ Event::Event(const AtomicString& eventType, const EventInit& initializer) , m_defaultHandled(false) , m_cancelBubble(false) , m_eventPhase(0) - , m_currentTarget(nullptr) { } @@ -80,9 +76,6 @@ Event::~Event() void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg) { - if (dispatched()) - return; - m_propagationStopped = false; m_immediatePropagationStopped = false; m_defaultPrevented = false; @@ -92,12 +85,12 @@ void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool m_cancelable = cancelableArg; } -bool Event::legacyReturnValue(ExecutionContext* executionContext) const +bool Event::legacyReturnValue() const { return !defaultPrevented(); } -void Event::setLegacyReturnValue(ExecutionContext* executionContext, bool returnValue) +void Event::setLegacyReturnValue(bool returnValue) { setDefaultPrevented(!returnValue); } @@ -107,11 +100,6 @@ const AtomicString& Event::interfaceName() const return EventNames::Event; } -bool Event::hasInterface(const AtomicString& name) const -{ - return interfaceName() == name; -} - bool Event::isUIEvent() const { return false; @@ -142,20 +130,6 @@ bool Event::isBeforeTextInsertedEvent() const return false; } -void Event::setTarget(PassRefPtr target) -{ - if (m_target == target) - return; - - m_target = target; - if (m_target) - receivedTarget(); -} - -void Event::receivedTarget() -{ -} - void Event::setUnderlyingEvent(PassRefPtr ue) { // Prohibit creation of a cycle -- just do nothing in that case. @@ -165,40 +139,4 @@ void Event::setUnderlyingEvent(PassRefPtr ue) m_underlyingEvent = ue; } -EventPath& Event::ensureEventPath() -{ - if (!m_eventPath) - m_eventPath = adoptPtr(new EventPath(this)); - return *m_eventPath; -} - -PassRefPtr Event::path() const -{ - if (!m_currentTarget) { - ASSERT(m_eventPhase == Event::NONE); - if (!m_eventPath) { - // Before dispatching the event - return StaticNodeList::createEmpty(); - } - ASSERT(!m_eventPath->isEmpty()); - // After dispatching the event - return m_eventPath->last().treeScopeEventContext().ensureEventPath(*m_eventPath); - } - if (!m_currentTarget->toNode()) - return StaticNodeList::createEmpty(); - Node* node = m_currentTarget->toNode(); - size_t eventPathSize = m_eventPath->size(); - for (size_t i = 0; i < eventPathSize; ++i) { - if (node == (*m_eventPath)[i].node()) { - return (*m_eventPath)[i].treeScopeEventContext().ensureEventPath(*m_eventPath); - } - } - return StaticNodeList::createEmpty(); -} - -EventTarget* Event::currentTarget() const -{ - return m_currentTarget.get(); -} - } // namespace blink diff --git a/sky/engine/core/events/Event.h b/sky/engine/core/events/Event.h index 5d3efb9f3b5d7..8d5bb8eba8d59 100644 --- a/sky/engine/core/events/Event.h +++ b/sky/engine/core/events/Event.h @@ -25,14 +25,12 @@ #define SKY_ENGINE_CORE_EVENTS_EVENT_H_ #include "sky/engine/tonic/dart_wrappable.h" -#include "sky/engine/core/events/EventPath.h" #include "sky/engine/platform/heap/Handle.h" #include "sky/engine/wtf/RefCounted.h" #include "sky/engine/wtf/text/AtomicString.h" namespace blink { -class EventTarget; class EventDispatcher; class ExecutionContext; @@ -44,7 +42,7 @@ struct EventInit { STACK_ALLOCATED(); }; -class Event : public RefCounted, public DartWrappable { +class Event : public RefCounted, public DartWrappable { DEFINE_WRAPPERTYPEINFO(); public: enum PhaseType { @@ -91,12 +89,6 @@ class Event : public RefCounted, public DartWrappable { const AtomicString& type() const { return m_type; } void setType(const AtomicString& type) { m_type = type; } - EventTarget* target() const { return m_target.get(); } - void setTarget(PassRefPtr); - - EventTarget* currentTarget() const; - void setCurrentTarget(EventTarget* currentTarget) { m_currentTarget = currentTarget; } - unsigned short eventPhase() const { return m_eventPhase; } void setEventPhase(unsigned short eventPhase) { m_eventPhase = eventPhase; } @@ -107,14 +99,10 @@ class Event : public RefCounted, public DartWrappable { void stopPropagation() { m_propagationStopped = true; } void stopImmediatePropagation() { m_immediatePropagationStopped = true; } - // IE Extensions - EventTarget* srcElement() const { return target(); } // MSIE extension - "the object that fired the event" - - bool legacyReturnValue(ExecutionContext*) const; - void setLegacyReturnValue(ExecutionContext*, bool returnValue); + bool legacyReturnValue() const; + void setLegacyReturnValue(bool returnValue); virtual const AtomicString& interfaceName() const; - bool hasInterface(const AtomicString&) const; // These events are general classes of events. virtual bool isUIEvent() const; @@ -148,11 +136,6 @@ class Event : public RefCounted, public DartWrappable { Event* underlyingEvent() const { return m_underlyingEvent.get(); } void setUnderlyingEvent(PassRefPtr); - EventPath& eventPath() { ASSERT(m_eventPath); return *m_eventPath; } - EventPath& ensureEventPath(); - - PassRefPtr path() const; - bool isBeingDispatched() const { return eventPhase(); } protected: @@ -160,9 +143,6 @@ class Event : public RefCounted, public DartWrappable { Event(const AtomicString& type, bool canBubble, bool cancelable); Event(const AtomicString& type, const EventInit&); - virtual void receivedTarget(); - bool dispatched() const { return m_target; } - double m_timeStamp; private: @@ -177,10 +157,7 @@ class Event : public RefCounted, public DartWrappable { bool m_cancelBubble; unsigned short m_eventPhase; - RefPtr m_currentTarget; - RefPtr m_target; RefPtr m_underlyingEvent; - OwnPtr m_eventPath; }; #define DEFINE_EVENT_TYPE_CASTS(typeName) \ diff --git a/sky/engine/core/events/Event.idl b/sky/engine/core/events/Event.idl index 9f9c3d100bfe1..770d79c7ad6c6 100644 --- a/sky/engine/core/events/Event.idl +++ b/sky/engine/core/events/Event.idl @@ -18,6 +18,10 @@ * Boston, MA 02110-1301, USA. */ +// This is the object that Sky's C++ code uses to send events to Sky's +// Dart code. +// TODO(ianh): It needs much work still. + [ // TODO(eseidel): Type is optional to appease dart analyzer: // The class 'Event' does not have a default constructor @@ -30,8 +34,6 @@ const unsigned short BUBBLING_PHASE = 3; readonly attribute DOMString type; - readonly attribute EventTarget target; - readonly attribute EventTarget currentTarget; readonly attribute unsigned short eventPhase; [InitializedByEventConstructor] readonly attribute boolean bubbles; [InitializedByEventConstructor] readonly attribute boolean cancelable; @@ -45,8 +47,6 @@ void stopImmediatePropagation(); // IE Extensions - readonly attribute EventTarget srcElement; - [CallWith=ExecutionContext, ImplementedAs=legacyReturnValue] attribute boolean returnValue; + [ImplementedAs=legacyReturnValue] attribute boolean returnValue; attribute boolean cancelBubble; - readonly attribute NodeList path; }; diff --git a/sky/engine/core/events/EventDispatchMediator.cpp b/sky/engine/core/events/EventDispatchMediator.cpp deleted file mode 100644 index 938b09bf83813..0000000000000 --- a/sky/engine/core/events/EventDispatchMediator.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/events/EventDispatchMediator.h" - -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/EventDispatcher.h" - -namespace blink { - -PassRefPtr EventDispatchMediator::create(PassRefPtr event) -{ - return adoptRef(new EventDispatchMediator(event)); -} - -EventDispatchMediator::EventDispatchMediator(PassRefPtr event) - : m_event(event) -{ -} - -bool EventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const -{ - ASSERT(m_event.get() == dispatcher->event()); - return dispatcher->dispatch(); -} - -} // namespace blink diff --git a/sky/engine/core/events/EventDispatchMediator.h b/sky/engine/core/events/EventDispatchMediator.h deleted file mode 100644 index d34ed029a1617..0000000000000 --- a/sky/engine/core/events/EventDispatchMediator.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_EVENTDISPATCHMEDIATOR_H_ -#define SKY_ENGINE_CORE_EVENTS_EVENTDISPATCHMEDIATOR_H_ - -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/PassRefPtr.h" -#include "sky/engine/wtf/RefCounted.h" -#include "sky/engine/wtf/RefPtr.h" - -namespace blink { - -class Event; -class EventDispatcher; -class Node; - -class EventDispatchMediator : public RefCounted { -public: - static PassRefPtr create(PassRefPtr); - virtual ~EventDispatchMediator() { }; - virtual bool dispatchEvent(EventDispatcher*) const; - Event* event() const { return m_event.get(); }; - -protected: - explicit EventDispatchMediator(PassRefPtr); - EventDispatchMediator() { }; - void setEvent(PassRefPtr event) { m_event = event; }; - -private: - RefPtr m_event; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_EVENTS_EVENTDISPATCHMEDIATOR_H_ diff --git a/sky/engine/core/events/EventDispatcher.cpp b/sky/engine/core/events/EventDispatcher.cpp deleted file mode 100644 index 5f06094c2fa00..0000000000000 --- a/sky/engine/core/events/EventDispatcher.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "sky/engine/core/events/EventDispatcher.h" - -#include "sky/engine/core/dom/ContainerNode.h" -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/Element.h" -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/EventDispatchMediator.h" -#include "sky/engine/core/events/ScopedEventQueue.h" -#include "sky/engine/core/events/WindowEventContext.h" -#include "sky/engine/core/frame/FrameView.h" -#include "sky/engine/core/frame/LocalDOMWindow.h" -#include "sky/engine/platform/EventDispatchForbiddenScope.h" -#include "sky/engine/platform/TraceEvent.h" -#include "sky/engine/wtf/RefPtr.h" - -namespace blink { - -bool EventDispatcher::dispatchEvent(Node* node, PassRefPtr mediator) -{ - TRACE_EVENT0("blink", "EventDispatcher::dispatchEvent"); - ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - if (!mediator->event()) - return true; - EventDispatcher dispatcher(node, mediator->event()); - return mediator->dispatchEvent(&dispatcher); -} - -EventDispatcher::EventDispatcher(Node* node, PassRefPtr event) - : m_node(node) - , m_event(event) -#if ENABLE(ASSERT) - , m_eventDispatched(false) -#endif -{ - ASSERT(node); - ASSERT(m_event.get()); - ASSERT(!m_event->type().isNull()); // JavaScript code can create an event with an empty name, but not null. - m_view = node->document().view(); - m_event->ensureEventPath().resetWith(m_node.get()); -} - -void EventDispatcher::dispatchScopedEvent(Node* node, PassRefPtr mediator) -{ - // We need to set the target here because it can go away by the time we actually fire the event. - mediator->event()->setTarget(EventPath::eventTargetRespectingTargetRules(node)); - ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator); -} - -bool EventDispatcher::dispatch() -{ - TRACE_EVENT0("blink", "EventDispatcher::dispatch"); - -#if ENABLE(ASSERT) - ASSERT(!m_eventDispatched); - m_eventDispatched = true; -#endif - - m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())); - ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - ASSERT(m_event->target()); - WindowEventContext windowEventContext(m_event.get(), m_node.get(), topNodeEventContext()); - - if (dispatchEventPreProcess() == ContinueDispatching) - if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching) - if (dispatchEventAtTarget() == ContinueDispatching) - dispatchEventAtBubbling(windowEventContext); - dispatchEventPostProcess(); - - // Ensure that after event dispatch, the event's target object is the - // outermost shadow DOM boundary. - m_event->setTarget(windowEventContext.target()); - m_event->setCurrentTarget(0); - - return !m_event->defaultPrevented(); -} - -inline EventDispatchContinuation EventDispatcher::dispatchEventPreProcess() -{ - return (m_event->eventPath().isEmpty() || m_event->propagationStopped()) ? DoneDispatching : ContinueDispatching; -} - -inline EventDispatchContinuation EventDispatcher::dispatchEventAtCapturing(WindowEventContext& windowEventContext) -{ - // Trigger capturing event handlers, starting at the top and working our way down. - m_event->setEventPhase(Event::CAPTURING_PHASE); - - if (windowEventContext.handleLocalEvents(m_event.get()) && m_event->propagationStopped()) - return DoneDispatching; - - for (size_t i = m_event->eventPath().size() - 1; i > 0; --i) { - const NodeEventContext& eventContext = m_event->eventPath()[i]; - if (eventContext.currentTargetSameAsTarget()) - continue; - eventContext.handleLocalEvents(m_event.get()); - if (m_event->propagationStopped()) - return DoneDispatching; - } - - return ContinueDispatching; -} - -inline EventDispatchContinuation EventDispatcher::dispatchEventAtTarget() -{ - m_event->setEventPhase(Event::AT_TARGET); - m_event->eventPath()[0].handleLocalEvents(m_event.get()); - return m_event->propagationStopped() ? DoneDispatching : ContinueDispatching; -} - -inline void EventDispatcher::dispatchEventAtBubbling(WindowEventContext& windowContext) -{ - // Trigger bubbling event handlers, starting at the bottom and working our way up. - size_t size = m_event->eventPath().size(); - for (size_t i = 1; i < size; ++i) { - const NodeEventContext& eventContext = m_event->eventPath()[i]; - if (eventContext.currentTargetSameAsTarget()) - m_event->setEventPhase(Event::AT_TARGET); - else if (m_event->bubbles() && !m_event->cancelBubble()) - m_event->setEventPhase(Event::BUBBLING_PHASE); - else - continue; - eventContext.handleLocalEvents(m_event.get()); - if (m_event->propagationStopped()) - return; - } - if (m_event->bubbles() && !m_event->cancelBubble()) { - m_event->setEventPhase(Event::BUBBLING_PHASE); - windowContext.handleLocalEvents(m_event.get()); - } -} - -inline void EventDispatcher::dispatchEventPostProcess() -{ - m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())); - m_event->setCurrentTarget(0); - m_event->setEventPhase(0); - - // Call default event handlers. While the DOM does have a concept of preventing - // default handling, the detail of which handlers are called is an internal - // implementation detail and not part of the DOM. - if (!m_event->defaultPrevented() && !m_event->defaultHandled()) { - // Non-bubbling events call only one default event handler, the one for the target. - m_node->defaultEventHandler(m_event.get()); - ASSERT(!m_event->defaultPrevented()); - if (m_event->defaultHandled()) - return; - // For bubbling events, call default event handlers on the same targets in the - // same order as the bubbling phase. - if (m_event->bubbles()) { - size_t size = m_event->eventPath().size(); - for (size_t i = 1; i < size; ++i) { - m_event->eventPath()[i].node()->defaultEventHandler(m_event.get()); - ASSERT(!m_event->defaultPrevented()); - if (m_event->defaultHandled()) - return; - } - } - } -} - -const NodeEventContext* EventDispatcher::topNodeEventContext() -{ - return m_event->eventPath().isEmpty() ? 0 : &m_event->eventPath().last(); -} - -} diff --git a/sky/engine/core/events/EventDispatcher.h b/sky/engine/core/events/EventDispatcher.h deleted file mode 100644 index db3567f867845..0000000000000 --- a/sky/engine/core/events/EventDispatcher.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) - * Copyright (C) 2011 Google Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_EVENTDISPATCHER_H_ -#define SKY_ENGINE_CORE_EVENTS_EVENTDISPATCHER_H_ - -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/PassRefPtr.h" -#include "sky/engine/wtf/RefPtr.h" - -namespace blink { - -class Event; -class EventDispatchMediator; -class FrameView; -class Node; -class NodeEventContext; -class WindowEventContext; - -enum EventDispatchContinuation { - ContinueDispatching, - DoneDispatching -}; - -class EventDispatcher { - STACK_ALLOCATED(); -public: - static bool dispatchEvent(Node*, PassRefPtr); - static void dispatchScopedEvent(Node*, PassRefPtr); - - bool dispatch(); - Node* node() const { return m_node.get(); } - Event* event() const { return m_event.get(); } - -private: - EventDispatcher(Node*, PassRefPtr); - const NodeEventContext* topNodeEventContext(); - - EventDispatchContinuation dispatchEventPreProcess(); - EventDispatchContinuation dispatchEventAtCapturing(WindowEventContext&); - EventDispatchContinuation dispatchEventAtTarget(); - void dispatchEventAtBubbling(WindowEventContext&); - void dispatchEventPostProcess(); - - RefPtr m_node; - RefPtr m_event; - RefPtr m_view; -#if ENABLE(ASSERT) - bool m_eventDispatched; -#endif -}; - -} - -#endif // SKY_ENGINE_CORE_EVENTS_EVENTDISPATCHER_H_ diff --git a/sky/engine/core/events/EventListener.h b/sky/engine/core/events/EventListener.h deleted file mode 100644 index 38c55aefe308a..0000000000000 --- a/sky/engine/core/events/EventListener.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_EVENTLISTENER_H_ -#define SKY_ENGINE_CORE_EVENTS_EVENTLISTENER_H_ - -#include "sky/engine/wtf/RefCounted.h" - -typedef struct _Dart_WeakReferenceSet* Dart_WeakReferenceSet; - -namespace blink { -class DartGCVisitor; -class Event; -class ExecutionContext; - -class EventListener : public RefCounted { -public: - virtual ~EventListener() { } - virtual bool operator==(const EventListener&) = 0; - virtual void handleEvent(ExecutionContext*, Event*) = 0; - - virtual void AcceptDartGCVisitor(DartGCVisitor& visitor) const = 0; - - -protected: - explicit EventListener() - { - } -}; - -} - -#endif // SKY_ENGINE_CORE_EVENTS_EVENTLISTENER_H_ diff --git a/sky/engine/core/events/EventListener.idl b/sky/engine/core/events/EventListener.idl deleted file mode 100644 index fc4b8bc62b4ed..0000000000000 --- a/sky/engine/core/events/EventListener.idl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. - * Copyright (C) 2006 Samuel Weinig - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -callback interface EventListener { - void handleEvent(Event event); -}; - diff --git a/sky/engine/core/events/EventListenerMap.cpp b/sky/engine/core/events/EventListenerMap.cpp deleted file mode 100644 index 1b2d3fcaa2e3e..0000000000000 --- a/sky/engine/core/events/EventListenerMap.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) - * (C) 2007, 2008 Nikolas Zimmermann - * Copyright (C) 2011 Andreas Kling (kling@webkit.org) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/events/EventListenerMap.h" - -#include "sky/engine/core/events/EventTarget.h" -#include "sky/engine/wtf/StdLibExtras.h" -#include "sky/engine/wtf/Vector.h" - -#if ENABLE(ASSERT) -#include "sky/engine/wtf/ThreadingPrimitives.h" -#endif - -using namespace WTF; - -namespace blink { - -#if ENABLE(ASSERT) -static Mutex& activeIteratorCountMutex() -{ - DEFINE_STATIC_LOCAL(Mutex, mutex, ()); - return mutex; -} - -void EventListenerMap::assertNoActiveIterators() -{ - MutexLocker locker(activeIteratorCountMutex()); - ASSERT(!m_activeIteratorCount); -} -#endif - -EventListenerMap::EventListenerMap() -#if ENABLE(ASSERT) - : m_activeIteratorCount(0) -#endif -{ -} - -bool EventListenerMap::contains(const AtomicString& eventType) const -{ - for (unsigned i = 0; i < m_entries.size(); ++i) { - if (m_entries[i].first == eventType) - return true; - } - return false; -} - -bool EventListenerMap::containsCapturing(const AtomicString& eventType) const -{ - for (unsigned i = 0; i < m_entries.size(); ++i) { - if (m_entries[i].first == eventType) { - const EventListenerVector* vector = m_entries[i].second.get(); - for (unsigned j = 0; j < vector->size(); ++j) { - if (vector->at(j).useCapture) - return true; - } - } - } - return false; -} - -void EventListenerMap::clear() -{ - assertNoActiveIterators(); - - m_entries.clear(); -} - -Vector EventListenerMap::eventTypes() const -{ - Vector types; - types.reserveInitialCapacity(m_entries.size()); - - for (unsigned i = 0; i < m_entries.size(); ++i) - types.uncheckedAppend(m_entries[i].first); - - return types; -} - -static bool addListenerToVector(EventListenerVector* vector, PassRefPtr listener, bool useCapture) -{ - RegisteredEventListener registeredListener(listener, useCapture); - - if (vector->find(registeredListener) != kNotFound) - return false; // Duplicate listener. - - vector->append(registeredListener); - return true; -} - -bool EventListenerMap::add(const AtomicString& eventType, PassRefPtr listener, bool useCapture) -{ - assertNoActiveIterators(); - - for (unsigned i = 0; i < m_entries.size(); ++i) { - if (m_entries[i].first == eventType) - return addListenerToVector(m_entries[i].second.get(), listener, useCapture); - } - - m_entries.append(std::make_pair(eventType, adoptPtr(new EventListenerVector))); - return addListenerToVector(m_entries.last().second.get(), listener, useCapture); -} - -static bool removeListenerFromVector(EventListenerVector* listenerVector, EventListener* listener, bool useCapture, size_t& indexOfRemovedListener) -{ - RegisteredEventListener registeredListener(listener, useCapture); - indexOfRemovedListener = listenerVector->find(registeredListener); - if (indexOfRemovedListener == kNotFound) - return false; - listenerVector->remove(indexOfRemovedListener); - return true; -} - -bool EventListenerMap::remove(const AtomicString& eventType, EventListener* listener, bool useCapture, size_t& indexOfRemovedListener) -{ - assertNoActiveIterators(); - - for (unsigned i = 0; i < m_entries.size(); ++i) { - if (m_entries[i].first == eventType) { - bool wasRemoved = removeListenerFromVector(m_entries[i].second.get(), listener, useCapture, indexOfRemovedListener); - if (m_entries[i].second->isEmpty()) - m_entries.remove(i); - return wasRemoved; - } - } - - return false; -} - -EventListenerVector* EventListenerMap::find(const AtomicString& eventType) -{ - assertNoActiveIterators(); - - for (unsigned i = 0; i < m_entries.size(); ++i) { - if (m_entries[i].first == eventType) - return m_entries[i].second.get(); - } - - return 0; -} - -EventListenerIterator::EventListenerIterator() - : m_map(0) - , m_entryIndex(0) - , m_index(0) -{ -} - -EventListenerIterator::EventListenerIterator(const EventTarget* target) - : m_map(0) - , m_entryIndex(0) - , m_index(0) -{ - ASSERT(target); - EventTargetData* data = const_cast(target)->eventTargetData(); - - if (!data) - return; - - m_map = &data->eventListenerMap; - -#if ENABLE(ASSERT) - { - MutexLocker locker(activeIteratorCountMutex()); - m_map->m_activeIteratorCount++; - } -#endif -} - -#if ENABLE(ASSERT) -EventListenerIterator::~EventListenerIterator() -{ - if (m_map) { - MutexLocker locker(activeIteratorCountMutex()); - m_map->m_activeIteratorCount--; - } -} -#endif - -EventListener* EventListenerIterator::nextListener() -{ - if (!m_map) - return 0; - - for (; m_entryIndex < m_map->m_entries.size(); ++m_entryIndex) { - EventListenerVector& listeners = *m_map->m_entries[m_entryIndex].second; - if (m_index < listeners.size()) - return listeners[m_index++].listener.get(); - m_index = 0; - } - - return 0; -} - -} // namespace blink diff --git a/sky/engine/core/events/EventListenerMap.h b/sky/engine/core/events/EventListenerMap.h deleted file mode 100644 index 6770c674627d5..0000000000000 --- a/sky/engine/core/events/EventListenerMap.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2012 Apple Inc. All rights reserved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) - * (C) 2007, 2008 Nikolas Zimmermann - * Copyright (C) 2011 Andreas Kling (kling@webkit.org) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_EVENTLISTENERMAP_H_ -#define SKY_ENGINE_CORE_EVENTS_EVENTLISTENERMAP_H_ - -#include "sky/engine/core/events/RegisteredEventListener.h" -#include "sky/engine/wtf/PassOwnPtr.h" -#include "sky/engine/wtf/text/AtomicStringHash.h" - -namespace blink { - -class EventTarget; - -typedef Vector EventListenerVector; - -class EventListenerMap { -public: - EventListenerMap(); - - bool isEmpty() const { return m_entries.isEmpty(); } - bool contains(const AtomicString& eventType) const; - bool containsCapturing(const AtomicString& eventType) const; - - void clear(); - bool add(const AtomicString& eventType, PassRefPtr, bool useCapture); - bool remove(const AtomicString& eventType, EventListener*, bool useCapture, size_t& indexOfRemovedListener); - EventListenerVector* find(const AtomicString& eventType); - Vector eventTypes() const; - -private: - friend class EventListenerIterator; - - void assertNoActiveIterators(); - - Vector >, 2> m_entries; - -#if ENABLE(ASSERT) - int m_activeIteratorCount; -#endif -}; - -class EventListenerIterator { - WTF_MAKE_NONCOPYABLE(EventListenerIterator); -public: - EventListenerIterator(); - EventListenerIterator(const EventTarget*); -#if ENABLE(ASSERT) - ~EventListenerIterator(); -#endif - - EventListener* nextListener(); - -private: - EventListenerMap* m_map; - unsigned m_entryIndex; - unsigned m_index; -}; - -#if !ENABLE(ASSERT) -inline void EventListenerMap::assertNoActiveIterators() { } -#endif - -} // namespace blink - -#endif // SKY_ENGINE_CORE_EVENTS_EVENTLISTENERMAP_H_ diff --git a/sky/engine/core/events/EventPath.cpp b/sky/engine/core/events/EventPath.cpp deleted file mode 100644 index fae32f341d0b1..0000000000000 --- a/sky/engine/core/events/EventPath.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/events/EventPath.h" - -#include "gen/sky/core/EventNames.h" -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/shadow/InsertionPoint.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" -#include "sky/engine/core/events/Event.h" - -namespace blink { - -EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode) -{ - ASSERT(referenceNode); - return referenceNode; -} - -static inline bool shouldStopAtShadowRoot(Event& event, ShadowRoot& shadowRoot, EventTarget& target) -{ - // WebKit never allowed selectstart event to cross the the shadow DOM boundary. - // Changing this breaks existing sites. - // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. - const AtomicString eventType = event.type(); - return target.toNode() && target.toNode()->shadowHost() == shadowRoot.host() - && (eventType == EventTypeNames::abort - || eventType == EventTypeNames::change - || eventType == EventTypeNames::error - || eventType == EventTypeNames::load - || eventType == EventTypeNames::reset - || eventType == EventTypeNames::resize - || eventType == EventTypeNames::scroll - || eventType == EventTypeNames::select - || eventType == EventTypeNames::selectstart); -} - -EventPath::EventPath(Event* event) - : m_node(nullptr) - , m_event(event) -{ -} - -EventPath::EventPath(Node* node) - : m_node(node) - , m_event(nullptr) -{ - resetWith(node); -} - -void EventPath::resetWith(Node* node) -{ - ASSERT(node); - m_node = node; - m_nodeEventContexts.clear(); - m_treeScopeEventContexts.clear(); - calculatePath(); - calculateAdjustedTargets(); - calculateTreeScopePrePostOrderNumbers(); -} - -void EventPath::addNodeEventContext(Node* node) -{ - m_nodeEventContexts.append(NodeEventContext(node, eventTargetRespectingTargetRules(node))); -} - -void EventPath::calculatePath() -{ - ASSERT(m_node); - ASSERT(m_nodeEventContexts.isEmpty()); - m_node->document().updateDistributionForNodeIfNeeded(const_cast(m_node.get())); - - Node* current = m_node; - addNodeEventContext(current); - if (!m_node->inDocument()) - return; - while (current) { - if (m_event && current->keepEventInNode(m_event)) - break; - Vector, 8> insertionPoints; - collectDestinationInsertionPoints(*current, insertionPoints); - if (!insertionPoints.isEmpty()) { - for (size_t i = 0; i < insertionPoints.size(); ++i) { - InsertionPoint* insertionPoint = insertionPoints[i]; - addNodeEventContext(insertionPoint); - } - current = insertionPoints.last(); - continue; - } - if (current->isShadowRoot()) { - if (m_event && shouldStopAtShadowRoot(*m_event, *toShadowRoot(current), *m_node)) - break; - current = current->shadowHost(); - addNodeEventContext(current); - } else { - current = current->parentNode(); - if (current) - addNodeEventContext(current); - } - } -} - -void EventPath::calculateTreeScopePrePostOrderNumbers() -{ - // Precondition: - // - TreeScopes in m_treeScopeEventContexts must be *connected* in the same tree of trees. - // - The root tree must be included. - HashMap, RawPtr > treeScopeEventContextMap; - for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) - treeScopeEventContextMap.add(&m_treeScopeEventContexts[i]->treeScope(), m_treeScopeEventContexts[i].get()); - TreeScopeEventContext* rootTree = 0; - for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { - TreeScopeEventContext* treeScopeEventContext = m_treeScopeEventContexts[i].get(); - // Use parentTreeScope here for parent-child relationships. - // See the definition of trees of trees in the Shado DOM spec: http://w3c.github.io/webcomponents/spec/shadow/ - TreeScope* parent = treeScopeEventContext->treeScope().parentTreeScope(); - if (!parent) { - ASSERT(!rootTree); - rootTree = treeScopeEventContext; - continue; - } - ASSERT(treeScopeEventContextMap.find(parent) != treeScopeEventContextMap.end()); - treeScopeEventContextMap.find(parent)->value->addChild(*treeScopeEventContext); - } - ASSERT(rootTree); - rootTree->calculatePrePostOrderNumber(0); -} - -TreeScopeEventContext* EventPath::ensureTreeScopeEventContext(Node* currentTarget, TreeScope* treeScope, TreeScopeEventContextMap& treeScopeEventContextMap) -{ - if (!treeScope) - return 0; - TreeScopeEventContext* treeScopeEventContext; - bool isNewEntry; - { - TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap.add(treeScope, nullptr); - isNewEntry = addResult.isNewEntry; - if (isNewEntry) - addResult.storedValue->value = TreeScopeEventContext::create(*treeScope); - treeScopeEventContext = addResult.storedValue->value.get(); - } - if (isNewEntry) { - TreeScopeEventContext* parentTreeScopeEventContext = ensureTreeScopeEventContext(0, treeScope->parentTreeScope(), treeScopeEventContextMap); - if (parentTreeScopeEventContext && parentTreeScopeEventContext->target()) { - treeScopeEventContext->setTarget(parentTreeScopeEventContext->target()); - } else if (currentTarget) { - treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(currentTarget)); - } - } else if (!treeScopeEventContext->target() && currentTarget) { - treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(currentTarget)); - } - return treeScopeEventContext; -} - -void EventPath::calculateAdjustedTargets() -{ - const TreeScope* lastTreeScope = 0; - - TreeScopeEventContextMap treeScopeEventContextMap; - TreeScopeEventContext* lastTreeScopeEventContext = 0; - - for (size_t i = 0; i < size(); ++i) { - Node* currentNode = at(i).node(); - TreeScope& currentTreeScope = currentNode->treeScope(); - if (lastTreeScope != ¤tTreeScope) { - lastTreeScopeEventContext = ensureTreeScopeEventContext(currentNode, ¤tTreeScope, treeScopeEventContextMap); - } - ASSERT(lastTreeScopeEventContext); - at(i).setTreeScopeEventContext(lastTreeScopeEventContext); - lastTreeScope = ¤tTreeScope; - } - m_treeScopeEventContexts.appendRange(treeScopeEventContextMap.values().begin(), treeScopeEventContextMap.values().end()); -} - -void EventPath::buildRelatedNodeMap(const Node* relatedNode, RelatedTargetMap& relatedTargetMap) -{ - EventPath relatedTargetEventPath(const_cast(relatedNode)); - for (size_t i = 0; i < relatedTargetEventPath.m_treeScopeEventContexts.size(); ++i) { - TreeScopeEventContext* treeScopeEventContext = relatedTargetEventPath.m_treeScopeEventContexts[i].get(); - relatedTargetMap.add(&treeScopeEventContext->treeScope(), treeScopeEventContext->target()); - } -} - -EventTarget* EventPath::findRelatedNode(TreeScope* scope, RelatedTargetMap& relatedTargetMap) -{ - Vector, 32> parentTreeScopes; - EventTarget* relatedNode = 0; - while (scope) { - parentTreeScopes.append(scope); - RelatedTargetMap::const_iterator iter = relatedTargetMap.find(scope); - if (iter != relatedTargetMap.end() && iter->value) { - relatedNode = iter->value; - break; - } - scope = scope->parentTreeScope(); - } - ASSERT(relatedNode); - for (Vector, 32>::iterator iter = parentTreeScopes.begin(); iter < parentTreeScopes.end(); ++iter) - relatedTargetMap.add(*iter, relatedNode); - return relatedNode; -} - -void EventPath::adjustForRelatedTarget(Node* target, EventTarget* relatedTarget) -{ - if (!target) - return; - if (!relatedTarget) - return; - Node* relatedNode = relatedTarget->toNode(); - if (!relatedNode) - return; - if (target->document() != relatedNode->document()) - return; - if (!target->inDocument() || !relatedNode->inDocument()) - return; - - RelatedTargetMap relatedNodeMap; - buildRelatedNodeMap(relatedNode, relatedNodeMap); - - for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { - TreeScopeEventContext* treeScopeEventContext = m_treeScopeEventContexts[i].get(); - EventTarget* adjustedRelatedTarget = findRelatedNode(&treeScopeEventContext->treeScope(), relatedNodeMap); - ASSERT(adjustedRelatedTarget); - treeScopeEventContext->setRelatedTarget(adjustedRelatedTarget); - } - - shrinkIfNeeded(target, relatedTarget); -} - -void EventPath::shrinkIfNeeded(const Node* target, const EventTarget* relatedTarget) -{ - // Synthetic mouse events can have a relatedTarget which is identical to the target. - bool targetIsIdenticalToToRelatedTarget = (target == relatedTarget); - - for (size_t i = 0; i < size(); ++i) { - if (targetIsIdenticalToToRelatedTarget) { - if (target->treeScope().rootNode() == at(i).node()) { - shrink(i + 1); - break; - } - } else if (at(i).target() == at(i).relatedTarget()) { - // Event dispatching should be stopped here. - shrink(i); - break; - } - } -} - -} // namespace diff --git a/sky/engine/core/events/EventPath.h b/sky/engine/core/events/EventPath.h deleted file mode 100644 index a3ca9626741d6..0000000000000 --- a/sky/engine/core/events/EventPath.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_EVENTPATH_H_ -#define SKY_ENGINE_CORE_EVENTS_EVENTPATH_H_ - -#include "sky/engine/core/events/NodeEventContext.h" -#include "sky/engine/core/events/TreeScopeEventContext.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/HashMap.h" -#include "sky/engine/wtf/Vector.h" - -namespace blink { - -class Event; -class EventTarget; -class Node; -class TreeScope; - -class EventPath final { -public: - explicit EventPath(Event*); - explicit EventPath(Node*); - void resetWith(Node*); - - NodeEventContext& operator[](size_t index) { return m_nodeEventContexts[index]; } - const NodeEventContext& operator[](size_t index) const { return m_nodeEventContexts[index]; } - NodeEventContext& last() { return m_nodeEventContexts[size() - 1]; } - - bool isEmpty() const { return m_nodeEventContexts.isEmpty(); } - size_t size() const { return m_nodeEventContexts.size(); } - - void adjustForRelatedTarget(Node*, EventTarget* relatedTarget); - - static EventTarget* eventTargetRespectingTargetRules(Node*); - -private: - EventPath(); - - NodeEventContext& at(size_t index) { return m_nodeEventContexts[index]; } - - void addNodeEventContext(Node*); - - void calculatePath(); - void calculateAdjustedTargets(); - void calculateTreeScopePrePostOrderNumbers(); - - void shrink(size_t newSize) { m_nodeEventContexts.shrink(newSize); } - void shrinkIfNeeded(const Node* target, const EventTarget* relatedTarget); - - typedef HashMap, RefPtr > TreeScopeEventContextMap; - TreeScopeEventContext* ensureTreeScopeEventContext(Node* currentTarget, TreeScope*, TreeScopeEventContextMap&); - - typedef HashMap, RawPtr > RelatedTargetMap; - - static void buildRelatedNodeMap(const Node*, RelatedTargetMap&); - static EventTarget* findRelatedNode(TreeScope*, RelatedTargetMap&); - - Vector m_nodeEventContexts; - RawPtr m_node; - RawPtr m_event; - Vector > m_treeScopeEventContexts; -}; - -} // namespace - -#endif // SKY_ENGINE_CORE_EVENTS_EVENTPATH_H_ diff --git a/sky/engine/core/events/EventQueue.h b/sky/engine/core/events/EventQueue.h deleted file mode 100644 index 4ede733197b3b..0000000000000 --- a/sky/engine/core/events/EventQueue.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_EVENTQUEUE_H_ -#define SKY_ENGINE_CORE_EVENTS_EVENTQUEUE_H_ - -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/HashMap.h" -#include "sky/engine/wtf/HashSet.h" -#include "sky/engine/wtf/PassOwnPtr.h" - -namespace blink { - -class Event; - -class EventQueue { -public: - virtual ~EventQueue() { } - virtual bool enqueueEvent(PassRefPtr) = 0; - virtual bool cancelEvent(Event*) = 0; - // The accumulated and all the future events will be discarded, no events will be dispatched anymore. - virtual void close() = 0; -}; - -} - -#endif // SKY_ENGINE_CORE_EVENTS_EVENTQUEUE_H_ diff --git a/sky/engine/core/events/EventTarget.cpp b/sky/engine/core/events/EventTarget.cpp deleted file mode 100644 index 84de2c8f870b3..0000000000000 --- a/sky/engine/core/events/EventTarget.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) - * (C) 2007, 2008 Nikolas Zimmermann - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/events/EventTarget.h" - -#include "gen/sky/platform/RuntimeEnabledFeatures.h" -#include "sky/engine/bindings/exception_state.h" -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/ExceptionCode.h" -#include "sky/engine/core/dom/ExecutionContext.h" -#include "sky/engine/core/editing/Editor.h" -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/frame/LocalDOMWindow.h" -#include "sky/engine/platform/EventDispatchForbiddenScope.h" -#include "sky/engine/tonic/dart_gc_visitor.h" -#include "sky/engine/wtf/StdLibExtras.h" -#include "sky/engine/wtf/Vector.h" - -using namespace WTF; - -namespace blink { - -EventTargetData::EventTargetData() -{ -} - -EventTargetData::~EventTargetData() -{ -} - -EventTarget::EventTarget() -{ -} - -EventTarget::~EventTarget() -{ -} - -void EventTarget::AcceptDartGCVisitor(DartGCVisitor& visitor) const -{ - if (!visitor.have_found_set()) - visitor.AddToSetForRoot(this, dart_wrapper()); - EventListenerIterator iterator(this); - while (EventListener* listener = iterator.nextListener()) - listener->AcceptDartGCVisitor(visitor); - DartWrappable::AcceptDartGCVisitor(visitor); -} - -Node* EventTarget::toNode() -{ - return 0; -} - -LocalDOMWindow* EventTarget::toDOMWindow() -{ - return 0; -} - -inline LocalDOMWindow* EventTarget::executingWindow() -{ - if (ExecutionContext* context = executionContext()) - return context->executingWindow(); - return 0; -} - -bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtr listener, bool useCapture) -{ - // FIXME: listener null check should throw TypeError (and be done in - // generated bindings), but breaks legacy content. http://crbug.com/249598 - if (!listener) - return false; - return ensureEventTargetData().eventListenerMap.add(eventType, listener, useCapture); -} - -bool EventTarget::removeEventListener(const AtomicString& eventType, PassRefPtr listener, bool useCapture) -{ - EventTargetData* d = eventTargetData(); - if (!d) - return false; - - size_t indexOfRemovedListener; - - if (!d->eventListenerMap.remove(eventType, listener.get(), useCapture, indexOfRemovedListener)) - return false; - - // Notify firing events planning to invoke the listener at 'index' that - // they have one less listener to invoke. - if (!d->firingEventIterators) - return true; - for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { - FiringEventIterator& firingIterator = d->firingEventIterators->at(i); - if (eventType != firingIterator.eventType) - continue; - - if (indexOfRemovedListener >= firingIterator.end) - continue; - - --firingIterator.end; - if (indexOfRemovedListener <= firingIterator.iterator) - --firingIterator.iterator; - } - - return true; -} - -bool EventTarget::dispatchEvent(PassRefPtr event, ExceptionState& exceptionState) -{ - if (!event) { - exceptionState.ThrowDOMException(InvalidStateError, "The event provided is null."); - return false; - } - if (event->type().isEmpty()) { - exceptionState.ThrowDOMException(InvalidStateError, "The event provided is uninitialized."); - return false; - } - if (event->isBeingDispatched()) { - exceptionState.ThrowDOMException(InvalidStateError, "The event is already being dispatched."); - return false; - } - - if (!executionContext()) - return false; - - return dispatchEvent(event); -} - -bool EventTarget::dispatchEvent(PassRefPtr event) -{ - event->setTarget(this); - event->setCurrentTarget(this); - event->setEventPhase(Event::AT_TARGET); - bool defaultPrevented = fireEventListeners(event.get()); - event->setEventPhase(0); - return defaultPrevented; -} - -bool EventTarget::fireEventListeners(Event* event) -{ - ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - ASSERT(event && !event->type().isEmpty()); - - EventTargetData* data = eventTargetData(); - if (!data) - return true; - - if (EventListenerVector* listeners = data->eventListenerMap.find(event->type())) - fireEventListeners(event, data, *listeners); - - Editor::countEvent(executionContext(), event); - return !event->defaultPrevented(); -} - -void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventListenerVector& entry) -{ - RefPtr protect(this); - - // Fire all listeners registered for this event. Don't fire listeners removed - // during event dispatch. Also, don't fire event listeners added during event - // dispatch. Conveniently, all new event listeners will be added after or at - // index |size|, so iterating up to (but not including) |size| naturally excludes - // new event listeners. - - size_t i = 0; - size_t size = entry.size(); - if (!d->firingEventIterators) - d->firingEventIterators = adoptPtr(new FiringEventIteratorVector); - d->firingEventIterators->append(FiringEventIterator(event->type(), i, size)); - for ( ; i < size; ++i) { - RegisteredEventListener& registeredListener = entry[i]; - if (event->eventPhase() == Event::CAPTURING_PHASE && !registeredListener.useCapture) - continue; - if (event->eventPhase() == Event::BUBBLING_PHASE && registeredListener.useCapture) - continue; - - // If stopImmediatePropagation has been called, we just break out immediately, without - // handling any more events on this target. - if (event->immediatePropagationStopped()) - break; - - ExecutionContext* context = executionContext(); - if (!context) - break; - - // To match Mozilla, the AT_TARGET phase fires both capturing and bubbling - // event listeners, even though that violates some versions of the DOM spec. - registeredListener.listener->handleEvent(context, event); - } - d->firingEventIterators->removeLast(); -} - -const EventListenerVector& EventTarget::getEventListeners(const AtomicString& eventType) -{ - DEFINE_STATIC_LOCAL(EventListenerVector, emptyVector, ()); - - EventTargetData* d = eventTargetData(); - if (!d) - return emptyVector; - - EventListenerVector* listenerVector = d->eventListenerMap.find(eventType); - if (!listenerVector) - return emptyVector; - - return *listenerVector; -} - -Vector EventTarget::eventTypes() -{ - EventTargetData* d = eventTargetData(); - return d ? d->eventListenerMap.eventTypes() : Vector(); -} - -void EventTarget::removeAllEventListeners() -{ - EventTargetData* d = eventTargetData(); - if (!d) - return; - d->eventListenerMap.clear(); - - // Notify firing events planning to invoke the listener at 'index' that - // they have one less listener to invoke. - if (d->firingEventIterators) { - for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { - d->firingEventIterators->at(i).iterator = 0; - d->firingEventIterators->at(i).end = 0; - } - } -} - -} // namespace blink diff --git a/sky/engine/core/events/EventTarget.h b/sky/engine/core/events/EventTarget.h deleted file mode 100644 index 79134b5ecb123..0000000000000 --- a/sky/engine/core/events/EventTarget.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) - * (C) 2007, 2008 Nikolas Zimmermann - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_EVENTTARGET_H_ -#define SKY_ENGINE_CORE_EVENTS_EVENTTARGET_H_ - -#include "gen/sky/core/EventInterfaces.h" -#include "gen/sky/core/EventNames.h" -#include "gen/sky/core/EventTargetInterfaces.h" -#include "gen/sky/core/EventTargetNames.h" -#include "gen/sky/core/EventTypeNames.h" -#include "sky/engine/tonic/dart_wrappable.h" -#include "sky/engine/core/events/EventListenerMap.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/text/AtomicString.h" - -namespace blink { - -class LocalDOMWindow; -class Event; -class ExceptionState; -class Node; - -struct FiringEventIterator { - FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& end) - : eventType(eventType) - , iterator(iterator) - , end(end) - { - } - - const AtomicString& eventType; - size_t& iterator; - size_t& end; -}; -typedef Vector FiringEventIteratorVector; - -struct EventTargetData { - WTF_MAKE_NONCOPYABLE(EventTargetData); WTF_MAKE_FAST_ALLOCATED; -public: - EventTargetData(); - ~EventTargetData(); - - EventListenerMap eventListenerMap; - OwnPtr firingEventIterators; -}; - -// This is the base class for all DOM event targets. To make your class an -// EventTarget, follow these steps: -// - Make your IDL interface inherit from EventTarget. -// - Inherit from EventTargetWithInlineData (only in rare cases should you use -// EventTarget directly). -// - Figure out if you now need to inherit from ActiveDOMObject as well. -// - In your class declaration, you will typically use -// REFCOUNTED_EVENT_TARGET(YourClassName). -// - Override EventTarget::interfaceName() and executionContext(). The former -// will typically return EventTargetNames::YourClassName. The latter will -// return ActiveDOMObject::executionContext (if you are an ActiveDOMObject) -// or the document you're in. -// - Your trace() method will need to call EventTargetWithInlineData::trace. -// -// Optionally, add a FooEvent.idl class, but that's outside the scope of this -// comment (and much more straightforward). -class EventTarget : public DartWrappable { - DEFINE_WRAPPERTYPEINFO(); -public: -#if !ENABLE(OILPAN) - void ref() { refEventTarget(); } - void deref() { derefEventTarget(); } -#endif - - void AcceptDartGCVisitor(DartGCVisitor& visitor) const override; - - virtual const AtomicString& interfaceName() const = 0; - virtual ExecutionContext* executionContext() const = 0; - - virtual Node* toNode(); - virtual LocalDOMWindow* toDOMWindow(); - - // FIXME: first 2 args to addEventListener and removeEventListener should - // be required (per spec), but throwing TypeError breaks legacy content. - // http://crbug.com/353484 - bool addEventListener() { return false; } - bool addEventListener(const AtomicString& eventType) { return false; } - virtual bool addEventListener(const AtomicString& eventType, PassRefPtr, bool useCapture = false); - bool removeEventListener() { return false; } - bool removeEventListener(const AtomicString& eventType) { return false; } - virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr, bool useCapture = false); - virtual void removeAllEventListeners(); - virtual bool dispatchEvent(PassRefPtr); - bool dispatchEvent(PassRefPtr, ExceptionState&); // DOM API - - bool hasEventListeners() const; - bool hasEventListeners(const AtomicString& eventType) const; - bool hasCapturingEventListeners(const AtomicString& eventType); - const EventListenerVector& getEventListeners(const AtomicString& eventType); - Vector eventTypes(); - - bool fireEventListeners(Event*); - - virtual bool keepEventInNode(Event*) { return false; }; - -protected: - EventTarget(); - virtual ~EventTarget(); - - // Subclasses should likely not override these themselves; instead, they should subclass EventTargetWithInlineData. - virtual EventTargetData* eventTargetData() = 0; - virtual EventTargetData& ensureEventTargetData() = 0; - -private: -#if !ENABLE(OILPAN) - // Subclasses should likely not override these themselves; instead, they should use the REFCOUNTED_EVENT_TARGET() macro. - virtual void refEventTarget() = 0; - virtual void derefEventTarget() = 0; -#endif - - LocalDOMWindow* executingWindow(); - void fireEventListeners(Event*, EventTargetData*, EventListenerVector&); - - friend class EventListenerIterator; -}; - -class EventTargetWithInlineData : public EventTarget { -protected: - virtual EventTargetData* eventTargetData() override final { return &m_eventTargetData; } - virtual EventTargetData& ensureEventTargetData() override final { return m_eventTargetData; } -private: - EventTargetData m_eventTargetData; -}; - -inline bool EventTarget::hasEventListeners() const -{ - // FIXME: We should have a const version of eventTargetData. - if (const EventTargetData* d = const_cast(this)->eventTargetData()) - return !d->eventListenerMap.isEmpty(); - return false; -} - -inline bool EventTarget::hasEventListeners(const AtomicString& eventType) const -{ - // FIXME: We should have const version of eventTargetData. - if (const EventTargetData* d = const_cast(this)->eventTargetData()) - return d->eventListenerMap.contains(eventType); - return false; -} - -inline bool EventTarget::hasCapturingEventListeners(const AtomicString& eventType) -{ - EventTargetData* d = eventTargetData(); - if (!d) - return false; - return d->eventListenerMap.containsCapturing(eventType); -} - -} // namespace blink - -#if ENABLE(OILPAN) -#define DEFINE_EVENT_TARGET_REFCOUNTING(baseClass) \ -public: \ - using baseClass::ref; \ - using baseClass::deref; \ -private: \ - typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro -#define DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(baseClass) -#else -#define DEFINE_EVENT_TARGET_REFCOUNTING(baseClass) \ -public: \ - using baseClass::ref; \ - using baseClass::deref; \ -private: \ - virtual void refEventTarget() override final { ref(); } \ - virtual void derefEventTarget() override final { deref(); } \ - typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro -#define DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(baseClass) -#endif - -// Use this macro if your EventTarget subclass is also a subclass of WTF::RefCounted. -// A ref-counted class that uses a different method of refcounting should use DEFINE_EVENT_TARGET_REFCOUNTING directly. -// Both of these macros are meant to be placed just before the "public:" section of the class declaration. -#define REFCOUNTED_EVENT_TARGET(className) DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCounted) - -#endif // SKY_ENGINE_CORE_EVENTS_EVENTTARGET_H_ diff --git a/sky/engine/core/events/EventTarget.idl b/sky/engine/core/events/EventTarget.idl deleted file mode 100644 index 6fa30555981a8..0000000000000 --- a/sky/engine/core/events/EventTarget.idl +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Samuel Weinig - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -interface EventTarget { - void addEventListener(DOMString? type, - EventListener listener, - optional boolean useCapture); - void removeEventListener(DOMString? type, - EventListener listener, - optional boolean useCapture); - [RaisesException] boolean dispatchEvent(Event event); -}; diff --git a/sky/engine/core/events/EventTargetFactory.in b/sky/engine/core/events/EventTargetFactory.in deleted file mode 100644 index 46462536eae30..0000000000000 --- a/sky/engine/core/events/EventTargetFactory.in +++ /dev/null @@ -1,6 +0,0 @@ -namespace="EventTarget" - -core/animation/AnimationPlayer -core/css/MediaQueryList -core/dom/Node -core/frame/Window ImplementedAs=LocalDOMWindow diff --git a/sky/engine/core/events/FocusEvent.cpp b/sky/engine/core/events/FocusEvent.cpp deleted file mode 100644 index 28ad144c3157a..0000000000000 --- a/sky/engine/core/events/FocusEvent.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/events/FocusEvent.h" - -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/EventDispatcher.h" - -namespace blink { - -FocusEventInit::FocusEventInit() - : relatedTarget(nullptr) -{ -} - -const AtomicString& FocusEvent::interfaceName() const -{ - return EventNames::FocusEvent; -} - -bool FocusEvent::isFocusEvent() const -{ - return true; -} - -FocusEvent::FocusEvent() -{ -} - -FocusEvent::FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr view, int detail, EventTarget* relatedTarget) - : UIEvent(type, canBubble, cancelable, view, detail) - , m_relatedTarget(relatedTarget) -{ -} - -FocusEvent::FocusEvent(const AtomicString& type, const FocusEventInit& initializer) - : UIEvent(type, initializer) - , m_relatedTarget(initializer.relatedTarget) -{ -} - -PassRefPtr FocusEventDispatchMediator::create(PassRefPtr focusEvent) -{ - return adoptRef(new FocusEventDispatchMediator(focusEvent)); -} - -FocusEventDispatchMediator::FocusEventDispatchMediator(PassRefPtr focusEvent) - : EventDispatchMediator(focusEvent) -{ -} - -bool FocusEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const -{ - event()->eventPath().adjustForRelatedTarget(dispatcher->node(), event()->relatedTarget()); - return EventDispatchMediator::dispatchEvent(dispatcher); -} - -PassRefPtr BlurEventDispatchMediator::create(PassRefPtr focusEvent) -{ - return adoptRef(new BlurEventDispatchMediator(focusEvent)); -} - -BlurEventDispatchMediator::BlurEventDispatchMediator(PassRefPtr focusEvent) - : EventDispatchMediator(focusEvent) -{ -} - -bool BlurEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const -{ - event()->eventPath().adjustForRelatedTarget(dispatcher->node(), event()->relatedTarget()); - return EventDispatchMediator::dispatchEvent(dispatcher); -} - -PassRefPtr FocusInEventDispatchMediator::create(PassRefPtr focusEvent) -{ - return adoptRef(new FocusInEventDispatchMediator(focusEvent)); -} - -FocusInEventDispatchMediator::FocusInEventDispatchMediator(PassRefPtr focusEvent) - : EventDispatchMediator(focusEvent) -{ -} - -bool FocusInEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const -{ - event()->eventPath().adjustForRelatedTarget(dispatcher->node(), event()->relatedTarget()); - return EventDispatchMediator::dispatchEvent(dispatcher); -} - -PassRefPtr FocusOutEventDispatchMediator::create(PassRefPtr focusEvent) -{ - return adoptRef(new FocusOutEventDispatchMediator(focusEvent)); -} - -FocusOutEventDispatchMediator::FocusOutEventDispatchMediator(PassRefPtr focusEvent) - : EventDispatchMediator(focusEvent) -{ -} - -bool FocusOutEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const -{ - event()->eventPath().adjustForRelatedTarget(dispatcher->node(), event()->relatedTarget()); - return EventDispatchMediator::dispatchEvent(dispatcher); -} - -} // namespace blink diff --git a/sky/engine/core/events/FocusEvent.h b/sky/engine/core/events/FocusEvent.h deleted file mode 100644 index 2432ec9f8ffad..0000000000000 --- a/sky/engine/core/events/FocusEvent.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_FOCUSEVENT_H_ -#define SKY_ENGINE_CORE_EVENTS_FOCUSEVENT_H_ - -#include "sky/engine/core/events/EventTarget.h" -#include "sky/engine/core/events/UIEvent.h" - -namespace blink { - -class Node; - -struct FocusEventInit : public UIEventInit { - FocusEventInit(); - - RefPtr relatedTarget; -}; - -class FocusEvent final : public UIEvent { - DEFINE_WRAPPERTYPEINFO(); -public: - static PassRefPtr create() - { - return adoptRef(new FocusEvent); - } - - static PassRefPtr create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr view, int detail, EventTarget* relatedTarget) - { - return adoptRef(new FocusEvent(type, canBubble, cancelable, view, detail, relatedTarget)); - } - - static PassRefPtr create(const AtomicString& type, const FocusEventInit& initializer) - { - return adoptRef(new FocusEvent(type, initializer)); - } - - EventTarget* relatedTarget() const { return m_relatedTarget.get(); } - void setRelatedTarget(EventTarget* relatedTarget) { m_relatedTarget = relatedTarget; } - - virtual const AtomicString& interfaceName() const override; - virtual bool isFocusEvent() const override; - -private: - FocusEvent(); - FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr, int, EventTarget*); - FocusEvent(const AtomicString& type, const FocusEventInit&); - - RefPtr m_relatedTarget; -}; - -DEFINE_EVENT_TYPE_CASTS(FocusEvent); - -class FocusEventDispatchMediator final : public EventDispatchMediator { -public: - static PassRefPtr create(PassRefPtr); -private: - explicit FocusEventDispatchMediator(PassRefPtr); - FocusEvent* event() const { return static_cast(EventDispatchMediator::event()); } - virtual bool dispatchEvent(EventDispatcher*) const override; -}; - -class BlurEventDispatchMediator final : public EventDispatchMediator { -public: - static PassRefPtr create(PassRefPtr); -private: - explicit BlurEventDispatchMediator(PassRefPtr); - FocusEvent* event() const { return static_cast(EventDispatchMediator::event()); } - virtual bool dispatchEvent(EventDispatcher*) const override; -}; - -class FocusInEventDispatchMediator final : public EventDispatchMediator { -public: - static PassRefPtr create(PassRefPtr); -private: - explicit FocusInEventDispatchMediator(PassRefPtr); - FocusEvent* event() const { return static_cast(EventDispatchMediator::event()); } - virtual bool dispatchEvent(EventDispatcher*) const override; -}; - -class FocusOutEventDispatchMediator final : public EventDispatchMediator { -public: - static PassRefPtr create(PassRefPtr); -private: - explicit FocusOutEventDispatchMediator(PassRefPtr); - FocusEvent* event() const { return static_cast(EventDispatchMediator::event()); } - virtual bool dispatchEvent(EventDispatcher*) const override; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_EVENTS_FOCUSEVENT_H_ diff --git a/sky/engine/core/events/FocusEvent.idl b/sky/engine/core/events/FocusEvent.idl deleted file mode 100644 index 0a189d3f05e10..0000000000000 --- a/sky/engine/core/events/FocusEvent.idl +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -[ - EventConstructor, -] interface FocusEvent : UIEvent { - [InitializedByEventConstructor] readonly attribute EventTarget? relatedTarget; -}; diff --git a/sky/engine/core/events/GenericEventQueue.cpp b/sky/engine/core/events/GenericEventQueue.cpp deleted file mode 100644 index 4a7bf4c98ed42..0000000000000 --- a/sky/engine/core/events/GenericEventQueue.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2012 Victor Carbune (victor@rosedu.org) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "sky/engine/core/events/GenericEventQueue.h" - -#include "sky/engine/core/events/Event.h" -#include "sky/engine/platform/TraceEvent.h" - -namespace blink { - -PassOwnPtr GenericEventQueue::create(EventTarget* owner) -{ - return adoptPtr(new GenericEventQueue(owner)); -} - -GenericEventQueue::GenericEventQueue(EventTarget* owner) - : m_owner(owner) - , m_timer(this, &GenericEventQueue::timerFired) - , m_isClosed(false) -{ -} - -GenericEventQueue::~GenericEventQueue() -{ -} - -bool GenericEventQueue::enqueueEvent(PassRefPtr event) -{ - if (m_isClosed) - return false; - - if (event->target() == m_owner) - event->setTarget(nullptr); - - TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", - event.get(), "type", - TRACE_STR_COPY(event->type().ascii().data())); - m_pendingEvents.append(event); - - if (!m_timer.isActive()) - m_timer.startOneShot(0, FROM_HERE); - - return true; -} - -bool GenericEventQueue::cancelEvent(Event* event) -{ - bool found = m_pendingEvents.contains(event); - - if (found) { - m_pendingEvents.remove(m_pendingEvents.find(event)); - TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, - "type", - TRACE_STR_COPY(event->type().ascii().data()), - "status", "cancelled"); - } - - if (m_pendingEvents.isEmpty()) - m_timer.stop(); - - return found; -} - -void GenericEventQueue::timerFired(Timer*) -{ - ASSERT(!m_timer.isActive()); - ASSERT(!m_pendingEvents.isEmpty()); - - Vector > pendingEvents; - m_pendingEvents.swap(pendingEvents); - - RefPtr protect(m_owner.get()); - for (size_t i = 0; i < pendingEvents.size(); ++i) { - Event* event = pendingEvents[i].get(); - EventTarget* target = event->target() ? event->target() : m_owner.get(); - CString type(event->type().ascii()); - TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent", event, "dispatch", "type", type.data()); - target->dispatchEvent(pendingEvents[i]); - TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event, "type", type.data()); - } -} - -void GenericEventQueue::close() -{ - m_isClosed = true; - cancelAllEvents(); -} - -void GenericEventQueue::cancelAllEvents() -{ - m_timer.stop(); - - for (size_t i = 0; i < m_pendingEvents.size(); ++i) { - Event* event = m_pendingEvents[i].get(); - TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, - "type", - TRACE_STR_COPY(event->type().ascii().data()), - "status", "cancelled"); - } - m_pendingEvents.clear(); -} - -bool GenericEventQueue::hasPendingEvents() const -{ - return m_pendingEvents.size(); -} - -} diff --git a/sky/engine/core/events/GenericEventQueue.h b/sky/engine/core/events/GenericEventQueue.h deleted file mode 100644 index b14503150115e..0000000000000 --- a/sky/engine/core/events/GenericEventQueue.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2012 Victor Carbune (victor@rosedu.org) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_GENERICEVENTQUEUE_H_ -#define SKY_ENGINE_CORE_EVENTS_GENERICEVENTQUEUE_H_ - -#include "sky/engine/core/events/EventQueue.h" -#include "sky/engine/core/events/EventTarget.h" -#include "sky/engine/platform/Timer.h" -#include "sky/engine/wtf/PassOwnPtr.h" -#include "sky/engine/wtf/RefPtr.h" -#include "sky/engine/wtf/Vector.h" - -namespace blink { - -class GenericEventQueue final : public EventQueue { - WTF_MAKE_FAST_ALLOCATED; -public: - static PassOwnPtr create(EventTarget*); - virtual ~GenericEventQueue(); - - // EventQueue - virtual bool enqueueEvent(PassRefPtr) override; - virtual bool cancelEvent(Event*) override; - virtual void close() override; - - void cancelAllEvents(); - bool hasPendingEvents() const; - -private: - explicit GenericEventQueue(EventTarget*); - void timerFired(Timer*); - - RawPtr m_owner; - Vector > m_pendingEvents; - Timer m_timer; - - bool m_isClosed; -}; - -} - -#endif // SKY_ENGINE_CORE_EVENTS_GENERICEVENTQUEUE_H_ diff --git a/sky/engine/core/events/GestureEvent.cpp b/sky/engine/core/events/GestureEvent.cpp index 9a7d6bbc5096c..403cee40ec923 100644 --- a/sky/engine/core/events/GestureEvent.cpp +++ b/sky/engine/core/events/GestureEvent.cpp @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" #include "sky/engine/core/dom/Element.h" #include "sky/engine/core/events/GestureEvent.h" #include "sky/engine/wtf/text/AtomicString.h" diff --git a/sky/engine/core/events/HashChangeEvent.h b/sky/engine/core/events/HashChangeEvent.h deleted file mode 100644 index 7f96e93cc6f03..0000000000000 --- a/sky/engine/core/events/HashChangeEvent.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_HASHCHANGEEVENT_H_ -#define SKY_ENGINE_CORE_EVENTS_HASHCHANGEEVENT_H_ - -#include "sky/engine/core/events/Event.h" - -namespace blink { - -struct HashChangeEventInit : public EventInit { - HashChangeEventInit() - { - }; - - String oldURL; - String newURL; -}; - -class HashChangeEvent final : public Event { - DEFINE_WRAPPERTYPEINFO(); -public: - static PassRefPtr create() - { - return adoptRef(new HashChangeEvent); - } - - static PassRefPtr create(const String& oldURL, const String& newURL) - { - return adoptRef(new HashChangeEvent(oldURL, newURL)); - } - - static PassRefPtr create(const AtomicString& type, const HashChangeEventInit& initializer) - { - return adoptRef(new HashChangeEvent(type, initializer)); - } - - void initHashChangeEvent(const AtomicString& eventType, bool canBubble, bool cancelable, const String& oldURL, const String& newURL) - { - if (dispatched()) - return; - - initEvent(eventType, canBubble, cancelable); - - m_oldURL = oldURL; - m_newURL = newURL; - } - - const String& oldURL() const { return m_oldURL; } - const String& newURL() const { return m_newURL; } - - virtual const AtomicString& interfaceName() const override { return EventNames::HashChangeEvent; } - -private: - HashChangeEvent() - { - } - - HashChangeEvent(const String& oldURL, const String& newURL) - : Event(EventTypeNames::hashchange, false, false) - , m_oldURL(oldURL) - , m_newURL(newURL) - { - } - - HashChangeEvent(const AtomicString& type, const HashChangeEventInit& initializer) - : Event(type, initializer) - , m_oldURL(initializer.oldURL) - , m_newURL(initializer.newURL) - { - } - - String m_oldURL; - String m_newURL; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_EVENTS_HASHCHANGEEVENT_H_ diff --git a/sky/engine/core/events/HashChangeEvent.idl b/sky/engine/core/events/HashChangeEvent.idl deleted file mode 100644 index e5101b8d99186..0000000000000 --- a/sky/engine/core/events/HashChangeEvent.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// Introduced in http://www.whatwg.org/specs/web-apps/current-work/multiframe/History.html#event-hashchange -[ - EventConstructor, -] interface HashChangeEvent : Event { - void initHashChangeEvent([Default=Undefined] optional DOMString type, - [Default=Undefined] optional boolean canBubble, - [Default=Undefined] optional boolean cancelable, - [Default=Undefined] optional DOMString oldURL, - [Default=Undefined] optional DOMString newURL); - [InitializedByEventConstructor] readonly attribute DOMString oldURL; - [InitializedByEventConstructor] readonly attribute DOMString newURL; -}; - diff --git a/sky/engine/core/events/KeyboardEvent.cpp b/sky/engine/core/events/KeyboardEvent.cpp index 4c3531fa3eff6..5556fc79e467d 100644 --- a/sky/engine/core/events/KeyboardEvent.cpp +++ b/sky/engine/core/events/KeyboardEvent.cpp @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "sky/engine/core/events/KeyboardEvent.h" +#include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" namespace blink { diff --git a/sky/engine/core/events/NodeEventContext.cpp b/sky/engine/core/events/NodeEventContext.cpp deleted file mode 100644 index b23ed5bcf90ee..0000000000000 --- a/sky/engine/core/events/NodeEventContext.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2014 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/events/NodeEventContext.h" - -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/FocusEvent.h" - -namespace blink { - -DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(NodeEventContext) - -NodeEventContext::NodeEventContext(PassRefPtr node, PassRefPtr currentTarget) - : m_node(node) - , m_currentTarget(currentTarget) -{ - ASSERT(m_node); -} - -void NodeEventContext::handleLocalEvents(Event* event) const -{ - if (relatedTarget()) { - if (event->isFocusEvent()) - toFocusEvent(event)->setRelatedTarget(relatedTarget()); - } - event->setTarget(target()); - event->setCurrentTarget(m_currentTarget.get()); - m_node->handleLocalEvents(event); -} - -} diff --git a/sky/engine/core/events/NodeEventContext.h b/sky/engine/core/events/NodeEventContext.h deleted file mode 100644 index 1bbecad5603de..0000000000000 --- a/sky/engine/core/events/NodeEventContext.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2014 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_NODEEVENTCONTEXT_H_ -#define SKY_ENGINE_CORE_EVENTS_NODEEVENTCONTEXT_H_ - -#include "sky/engine/core/events/TreeScopeEventContext.h" -#include "sky/engine/wtf/PassRefPtr.h" -#include "sky/engine/wtf/RefPtr.h" - -namespace blink { - -class EventTarget; -class Node; - -class NodeEventContext { - ALLOW_ONLY_INLINE_ALLOCATION(); - DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(NodeEventContext); -public: - // FIXME: Use ContainerNode instead of Node. - NodeEventContext(PassRefPtr, PassRefPtr currentTarget); - - Node* node() const { return m_node.get(); } - - void setTreeScopeEventContext(PassRefPtr prpTreeScopeEventContext) { m_treeScopeEventContext = prpTreeScopeEventContext; } - TreeScopeEventContext& treeScopeEventContext() { ASSERT(m_treeScopeEventContext); return *m_treeScopeEventContext; } - - EventTarget* target() const { return m_treeScopeEventContext->target(); } - EventTarget* relatedTarget() const { return m_treeScopeEventContext->relatedTarget(); } - - bool currentTargetSameAsTarget() const { return m_currentTarget.get() == target(); } - void handleLocalEvents(Event*) const; - -private: - RefPtr m_node; - RefPtr m_currentTarget; - RefPtr m_treeScopeEventContext; -}; - -} // namespace blink - -#if !ENABLE(OILPAN) -WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::NodeEventContext); -#else -namespace WTF { -template <> struct VectorTraits : SimpleClassVectorTraits { - static const bool needsDestruction = false; -}; -} -#endif - -#endif // SKY_ENGINE_CORE_EVENTS_NODEEVENTCONTEXT_H_ diff --git a/sky/engine/core/events/PageTransitionEvent.cpp b/sky/engine/core/events/PageTransitionEvent.cpp index 55fed64da7fb5..366fb56005c38 100644 --- a/sky/engine/core/events/PageTransitionEvent.cpp +++ b/sky/engine/core/events/PageTransitionEvent.cpp @@ -23,6 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "gen/sky/core/EventNames.h" #include "sky/engine/core/events/PageTransitionEvent.h" namespace blink { diff --git a/sky/engine/core/events/PointerEvent.cpp b/sky/engine/core/events/PointerEvent.cpp index 1cb2140d73b23..e660146c98281 100644 --- a/sky/engine/core/events/PointerEvent.cpp +++ b/sky/engine/core/events/PointerEvent.cpp @@ -4,6 +4,9 @@ #include "sky/engine/core/events/PointerEvent.h" +#include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" + namespace blink { static AtomicString stringForType(WebInputEvent::Type type) diff --git a/sky/engine/core/events/RegisteredEventListener.h b/sky/engine/core/events/RegisteredEventListener.h deleted file mode 100644 index 47ad99f9c41d1..0000000000000 --- a/sky/engine/core/events/RegisteredEventListener.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) - * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) - * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_REGISTEREDEVENTLISTENER_H_ -#define SKY_ENGINE_CORE_EVENTS_REGISTEREDEVENTLISTENER_H_ - -#include "sky/engine/core/events/EventListener.h" -#include "sky/engine/wtf/RefPtr.h" - -namespace blink { - - class RegisteredEventListener { - public: - RegisteredEventListener(PassRefPtr listener, bool useCapture) - : listener(listener) - , useCapture(useCapture) - { - } - - RefPtr listener; - bool useCapture; - }; - - inline bool operator==(const RegisteredEventListener& a, const RegisteredEventListener& b) - { - return *a.listener == *b.listener && a.useCapture == b.useCapture; - } - -} // namespace blink - -#endif // SKY_ENGINE_CORE_EVENTS_REGISTEREDEVENTLISTENER_H_ diff --git a/sky/engine/core/events/ScopedEventQueue.cpp b/sky/engine/core/events/ScopedEventQueue.cpp deleted file mode 100644 index b7a8c1e7853df..0000000000000 --- a/sky/engine/core/events/ScopedEventQueue.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/events/ScopedEventQueue.h" - -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/EventDispatchMediator.h" -#include "sky/engine/core/events/EventDispatcher.h" -#include "sky/engine/core/events/EventTarget.h" -#include "sky/engine/wtf/OwnPtr.h" - -namespace blink { - -ScopedEventQueue* ScopedEventQueue::s_instance = 0; - -ScopedEventQueue::ScopedEventQueue() - : m_scopingLevel(0) -{ -} - -ScopedEventQueue::~ScopedEventQueue() -{ - ASSERT(!m_scopingLevel); - ASSERT(!m_queuedEventDispatchMediators.size()); -} - -void ScopedEventQueue::initialize() -{ - ASSERT(!s_instance); - OwnPtr instance = adoptPtr(new ScopedEventQueue); - s_instance = instance.leakPtr(); -} - -void ScopedEventQueue::enqueueEventDispatchMediator(PassRefPtr mediator) -{ - if (m_scopingLevel) - m_queuedEventDispatchMediators.append(mediator); - else - dispatchEvent(mediator); -} - -void ScopedEventQueue::dispatchAllEvents() -{ - Vector > queuedEventDispatchMediators; - queuedEventDispatchMediators.swap(m_queuedEventDispatchMediators); - - for (size_t i = 0; i < queuedEventDispatchMediators.size(); i++) - dispatchEvent(queuedEventDispatchMediators[i].release()); -} - -void ScopedEventQueue::dispatchEvent(PassRefPtr mediator) const -{ - ASSERT(mediator->event()->target()); - Node* node = mediator->event()->target()->toNode(); - EventDispatcher::dispatchEvent(node, mediator); -} - -ScopedEventQueue* ScopedEventQueue::instance() -{ - if (!s_instance) - initialize(); - - return s_instance; -} - -void ScopedEventQueue::incrementScopingLevel() -{ - m_scopingLevel++; -} - -void ScopedEventQueue::decrementScopingLevel() -{ - ASSERT(m_scopingLevel); - m_scopingLevel--; - if (!m_scopingLevel) - dispatchAllEvents(); -} - -} diff --git a/sky/engine/core/events/ScopedEventQueue.h b/sky/engine/core/events/ScopedEventQueue.h deleted file mode 100644 index f09fe75430405..0000000000000 --- a/sky/engine/core/events/ScopedEventQueue.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_SCOPEDEVENTQUEUE_H_ -#define SKY_ENGINE_CORE_EVENTS_SCOPEDEVENTQUEUE_H_ - -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/Noncopyable.h" -#include "sky/engine/wtf/PassRefPtr.h" -#include "sky/engine/wtf/RefPtr.h" -#include "sky/engine/wtf/Vector.h" - -namespace blink { - -class EventDispatchMediator; - -class ScopedEventQueue { - WTF_MAKE_NONCOPYABLE(ScopedEventQueue); WTF_MAKE_FAST_ALLOCATED; -public: - ~ScopedEventQueue(); - - void enqueueEventDispatchMediator(PassRefPtr); - void dispatchAllEvents(); - static ScopedEventQueue* instance(); - - void incrementScopingLevel(); - void decrementScopingLevel(); - -private: - ScopedEventQueue(); - static void initialize(); - void dispatchEvent(PassRefPtr) const; - - Vector > m_queuedEventDispatchMediators; - unsigned m_scopingLevel; - - static ScopedEventQueue* s_instance; -}; - -class EventQueueScope { - WTF_MAKE_NONCOPYABLE(EventQueueScope); - -public: - EventQueueScope() { ScopedEventQueue::instance()->incrementScopingLevel(); } - ~EventQueueScope() { ScopedEventQueue::instance()->decrementScopingLevel(); } -}; - -} - -#endif // SKY_ENGINE_CORE_EVENTS_SCOPEDEVENTQUEUE_H_ diff --git a/sky/engine/core/events/TextEvent.cpp b/sky/engine/core/events/TextEvent.cpp index 1e911ca7a0a2f..f4be59ef66030 100644 --- a/sky/engine/core/events/TextEvent.cpp +++ b/sky/engine/core/events/TextEvent.cpp @@ -24,9 +24,10 @@ * */ -#include "sky/engine/core/events/TextEvent.h" - +#include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" #include "sky/engine/core/dom/DocumentFragment.h" +#include "sky/engine/core/events/TextEvent.h" namespace blink { @@ -89,9 +90,6 @@ TextEvent::~TextEvent() void TextEvent::initTextEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr view, const String& data) { - if (dispatched()) - return; - initUIEvent(type, canBubble, cancelable, view, 0); m_data = data; diff --git a/sky/engine/core/events/TextEvent.h b/sky/engine/core/events/TextEvent.h index 930214b36b2b9..6196051b93621 100644 --- a/sky/engine/core/events/TextEvent.h +++ b/sky/engine/core/events/TextEvent.h @@ -74,13 +74,6 @@ class TextEvent final : public UIEvent { bool m_shouldMatchStyle; }; -inline bool isTextEvent(const Event& event) -{ - return event.type() == EventTypeNames::textInput && event.hasInterface(EventNames::TextEvent); -} - -DEFINE_TYPE_CASTS(TextEvent, Event, event, isTextEvent(*event), isTextEvent(event)); - } // namespace blink #endif // SKY_ENGINE_CORE_EVENTS_TEXTEVENT_H_ diff --git a/sky/engine/core/events/TreeScopeEventContext.cpp b/sky/engine/core/events/TreeScopeEventContext.cpp deleted file mode 100644 index 81d0ba143adae..0000000000000 --- a/sky/engine/core/events/TreeScopeEventContext.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2014 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/events/TreeScopeEventContext.h" - -#include "sky/engine/core/dom/StaticNodeList.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" -#include "sky/engine/core/events/EventPath.h" - -namespace blink { - -PassRefPtr TreeScopeEventContext::ensureEventPath(EventPath& path) -{ - if (m_eventPath) - return m_eventPath; - - Vector > nodes; - nodes.reserveInitialCapacity(path.size()); - for (size_t i = 0; i < path.size(); ++i) { - TreeScope& treeScope = path[i].treeScopeEventContext().treeScope(); - if (treeScope.rootNode().isShadowRoot()) - nodes.append(path[i].node()); - else if (path[i].treeScopeEventContext().isInclusiveAncestorOf(*this)) - nodes.append(path[i].node()); - } - m_eventPath = StaticNodeList::adopt(nodes); - return m_eventPath; -} - -PassRefPtr TreeScopeEventContext::create(TreeScope& treeScope) -{ - return adoptRef(new TreeScopeEventContext(treeScope)); -} - -TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope) - : m_treeScope(treeScope) - , m_preOrder(-1) - , m_postOrder(-1) -{ -} - -DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext) - -int TreeScopeEventContext::calculatePrePostOrderNumber(int orderNumber) -{ - m_preOrder = orderNumber; - for (size_t i = 0; i < m_children.size(); ++i) - orderNumber = m_children[i]->calculatePrePostOrderNumber(orderNumber + 1); - m_postOrder = orderNumber + 1; - return orderNumber + 1; -} - -} diff --git a/sky/engine/core/events/TreeScopeEventContext.h b/sky/engine/core/events/TreeScopeEventContext.h deleted file mode 100644 index 25abc89a961bf..0000000000000 --- a/sky/engine/core/events/TreeScopeEventContext.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2014 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_TREESCOPEEVENTCONTEXT_H_ -#define SKY_ENGINE_CORE_EVENTS_TREESCOPEEVENTCONTEXT_H_ - -#include "sky/engine/core/dom/Node.h" -#include "sky/engine/core/dom/TreeScope.h" -#include "sky/engine/core/events/EventTarget.h" -#include "sky/engine/wtf/PassRefPtr.h" -#include "sky/engine/wtf/RefPtr.h" -#include "sky/engine/wtf/Vector.h" - -namespace blink { - -class EventPath; -class EventTarget; -class Node; -template class StaticNodeTypeList; -typedef StaticNodeTypeList StaticNodeList; -class TreeScope; - -class TreeScopeEventContext final : public RefCounted { - DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext); -public: - static PassRefPtr create(TreeScope&); - - TreeScope& treeScope() const { return *m_treeScope; } - - EventTarget* target() const { return m_target.get(); } - void setTarget(PassRefPtr); - - EventTarget* relatedTarget() const { return m_relatedTarget.get(); } - void setRelatedTarget(PassRefPtr); - - PassRefPtr ensureEventPath(EventPath&); - - bool isInclusiveAncestorOf(const TreeScopeEventContext&); - void addChild(TreeScopeEventContext& child) { m_children.append(&child); } - - // For ancestor-descendant relationship check in Q(1). - // Preprocessing takes O(N). - int calculatePrePostOrderNumber(int orderNumber); - -private: - TreeScopeEventContext(TreeScope&); - -#if ENABLE(ASSERT) - bool isUnreachableNode(EventTarget&); -#endif - - RawPtr m_treeScope; - RefPtr m_target; - RefPtr m_relatedTarget; - RefPtr m_eventPath; - - Vector > m_children; - int m_preOrder; - int m_postOrder; -}; - -#if ENABLE(ASSERT) -inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) -{ - // FIXME: Checks also for SVG elements. - return target.toNode() && !target.toNode()->treeScope().isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(treeScope()); -} -#endif - -inline void TreeScopeEventContext::setTarget(PassRefPtr target) -{ - ASSERT(target); - ASSERT(!isUnreachableNode(*target)); - m_target = target; -} - -inline void TreeScopeEventContext::setRelatedTarget(PassRefPtr relatedTarget) -{ - ASSERT(relatedTarget); - ASSERT(!isUnreachableNode(*relatedTarget)); - m_relatedTarget = relatedTarget; -} - -inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventContext& other) -{ - ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && other.m_postOrder != -1); - return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; -} - -} - -#endif // SKY_ENGINE_CORE_EVENTS_TREESCOPEEVENTCONTEXT_H_ diff --git a/sky/engine/core/events/UIEvent.cpp b/sky/engine/core/events/UIEvent.cpp index 2652966a325ba..019c186d8be6d 100644 --- a/sky/engine/core/events/UIEvent.cpp +++ b/sky/engine/core/events/UIEvent.cpp @@ -21,7 +21,7 @@ */ #include "sky/engine/core/events/UIEvent.h" - +#include "gen/sky/core/EventNames.h" namespace blink { @@ -56,9 +56,6 @@ UIEvent::~UIEvent() void UIEvent::initUIEvent(const AtomicString& typeArg, bool canBubbleArg, bool cancelableArg, PassRefPtr viewArg, int detailArg) { - if (dispatched()) - return; - initEvent(typeArg, canBubbleArg, cancelableArg); m_view = viewArg; diff --git a/sky/engine/core/events/UIEvent.h b/sky/engine/core/events/UIEvent.h index 914af225632c1..98ffb7f800dd9 100644 --- a/sky/engine/core/events/UIEvent.h +++ b/sky/engine/core/events/UIEvent.h @@ -25,7 +25,6 @@ #define SKY_ENGINE_CORE_EVENTS_UIEVENT_H_ #include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/EventDispatchMediator.h" #include "sky/engine/core/frame/LocalDOMWindow.h" namespace blink { diff --git a/sky/engine/core/events/WheelEvent.cpp b/sky/engine/core/events/WheelEvent.cpp index 5b6397c52b4fe..21eca6ad1c924 100644 --- a/sky/engine/core/events/WheelEvent.cpp +++ b/sky/engine/core/events/WheelEvent.cpp @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "sky/engine/core/events/WheelEvent.h" +#include "gen/sky/core/EventNames.h" +#include "gen/sky/core/EventTypeNames.h" namespace blink { diff --git a/sky/engine/core/events/WindowEventContext.cpp b/sky/engine/core/events/WindowEventContext.cpp deleted file mode 100644 index 576fb7005df28..0000000000000 --- a/sky/engine/core/events/WindowEventContext.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/events/WindowEventContext.h" - -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/Node.h" -#include "sky/engine/core/events/Event.h" -#include "sky/engine/core/events/NodeEventContext.h" -#include "sky/engine/core/frame/LocalDOMWindow.h" - -namespace blink { - -WindowEventContext::WindowEventContext(Event* event, PassRefPtr node, const NodeEventContext* topNodeEventContext) -{ - // We don't dispatch load events to the window. This quirk was originally - // added because Mozilla doesn't propagate load events to the window object. - if (event->type() == EventTypeNames::load) - return; - - Node* topLevelContainer = topNodeEventContext ? topNodeEventContext->node() : node.get(); - if (!topLevelContainer->isDocumentNode()) - return; - - m_window = toDocument(topLevelContainer)->domWindow(); - m_target = topNodeEventContext ? topNodeEventContext->target() : node.get(); -} - -bool WindowEventContext::handleLocalEvents(Event* event) -{ - if (!m_window) - return false; - - event->setTarget(target()); - event->setCurrentTarget(window()); - m_window->fireEventListeners(event); - return true; -} - -} diff --git a/sky/engine/core/events/WindowEventContext.h b/sky/engine/core/events/WindowEventContext.h deleted file mode 100644 index bc58c86a72494..0000000000000 --- a/sky/engine/core/events/WindowEventContext.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_EVENTS_WINDOWEVENTCONTEXT_H_ -#define SKY_ENGINE_CORE_EVENTS_WINDOWEVENTCONTEXT_H_ - -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/RefPtr.h" - -namespace blink { - -class LocalDOMWindow; -class EventTarget; -class Event; -class Node; -class NodeEventContext; - -class WindowEventContext { - STACK_ALLOCATED(); -public: - WindowEventContext(Event*, PassRefPtr, const NodeEventContext*); - - LocalDOMWindow* window() const; - EventTarget* target() const; - bool handleLocalEvents(Event* event); - -private: - RefPtr m_window; - RefPtr m_target; -}; - -inline LocalDOMWindow* WindowEventContext::window() const -{ - return m_window.get(); -} - -inline EventTarget* WindowEventContext::target() const -{ - return m_target.get(); -} - -} - -#endif // SKY_ENGINE_CORE_EVENTS_WINDOWEVENTCONTEXT_H_ diff --git a/sky/engine/core/frame/DOMTimer.cpp b/sky/engine/core/frame/DOMTimer.cpp deleted file mode 100644 index 59f1c8fb8a3ff..0000000000000 --- a/sky/engine/core/frame/DOMTimer.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/frame/DOMTimer.h" - -#include "sky/engine/core/dom/ExecutionContext.h" -#include "sky/engine/platform/Logging.h" -#include "sky/engine/platform/TraceEvent.h" -#include "sky/engine/wtf/CurrentTime.h" - -namespace blink { - -static const int maxTimerNestingLevel = 5; -static const double oneMillisecond = 0.001; -// Chromium uses a minimum timer interval of 4ms. We'd like to go -// lower; however, there are poorly coded websites out there which do -// create CPU-spinning loops. Using 4ms prevents the CPU from -// spinning too busily and provides a balance between CPU spinning and -// the smallest possible interval timer. -static const double minimumInterval = 0.004; - -static int timerNestingLevel = 0; - -double DOMTimer::hiddenPageAlignmentInterval() -{ - // Timers on hidden pages are aligned so that they fire once per - // second at most. - return 1.0; -} - -double DOMTimer::visiblePageAlignmentInterval() -{ - // Alignment does not apply to timers on visible pages. - return 0; -} - -int DOMTimer::install(ExecutionContext* context, PassOwnPtr action, int timeout, bool singleShot) -{ - int timeoutID = context->installNewTimeout(action, timeout, singleShot); - WTF_LOG(Timers, "DOMTimer::install: timeoutID = %d, timeout = %d, singleShot = %d", timeoutID, timeout, singleShot ? 1 : 0); - return timeoutID; -} - -void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) -{ - WTF_LOG(Timers, "DOMTimer::removeByID: timeoutID = %d", timeoutID); - context->removeTimeoutByID(timeoutID); -} - -DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtr action, int interval, bool singleShot, int timeoutID) - : SuspendableTimer(context) - , m_timeoutID(timeoutID) - , m_nestingLevel(timerNestingLevel + 1) - , m_action(action) -{ - ASSERT(timeoutID > 0); - - double intervalMilliseconds = std::max(oneMillisecond, interval * oneMillisecond); - if (intervalMilliseconds < minimumInterval && m_nestingLevel >= maxTimerNestingLevel) - intervalMilliseconds = minimumInterval; - if (singleShot) - startOneShot(intervalMilliseconds, FROM_HERE); - else - startRepeating(intervalMilliseconds, FROM_HERE); -} - -DOMTimer::~DOMTimer() -{ -} - -int DOMTimer::timeoutID() const -{ - return m_timeoutID; -} - -void DOMTimer::fired() -{ - ExecutionContext* context = executionContext(); - timerNestingLevel = m_nestingLevel; - ASSERT(!context->activeDOMObjectsAreSuspended()); - - // Simple case for non-one-shot timers. - if (isActive()) { - if (repeatInterval() && repeatInterval() < minimumInterval) { - m_nestingLevel++; - if (m_nestingLevel >= maxTimerNestingLevel) - augmentRepeatInterval(minimumInterval - repeatInterval()); - } - - WTF_LOG(Timers, "DOMTimer::fired: m_timeoutID = %d, repeatInterval = %f, m_action = %p", m_timeoutID, repeatInterval(), m_action.get()); - - // No access to member variables after this point, it can delete the timer. - m_action->Execute(context); - return; - } - - WTF_LOG(Timers, "DOMTimer::fired: m_timeoutID = %d, one-shot, m_action = %p", m_timeoutID, m_action.get()); - - // Delete timer before executing the action for one-shot timers. - OwnPtr action = m_action.release(); - - // This timer is being deleted; no access to member variables allowed after this point. - context->removeTimeoutByID(m_timeoutID); - - action->Execute(context); - - timerNestingLevel = 0; -} - -void DOMTimer::contextDestroyed() -{ - SuspendableTimer::contextDestroyed(); -} - -void DOMTimer::stop() -{ - SuspendableTimer::stop(); - // Need to release JS objects potentially protected by ScheduledAction - // because they can form circular references back to the ExecutionContext - // which will cause a memory leak. - m_action.clear(); -} - -double DOMTimer::alignedFireTime(double fireTime) const -{ - double alignmentInterval = executionContext()->timerAlignmentInterval(); - if (alignmentInterval) { - double currentTime = monotonicallyIncreasingTime(); - if (fireTime <= currentTime) - return fireTime; - - // When a repeating timer is scheduled for exactly the - // background page alignment interval, because it's impossible - // for the timer to be rescheduled instantaneously, it misses - // every other fire time. Avoid this by looking at the next - // fire time rounded both down and up. - - double alignedTimeRoundedDown = floor(fireTime / alignmentInterval) * alignmentInterval; - double alignedTimeRoundedUp = ceil(fireTime / alignmentInterval) * alignmentInterval; - - // If the version rounded down is in the past, discard it - // immediately. - - if (alignedTimeRoundedDown <= currentTime) - return alignedTimeRoundedUp; - - // Only use the rounded-down time if it's within a certain - // tolerance of the fire time. This avoids speeding up timers - // on background pages in the common case. - - if (fireTime - alignedTimeRoundedDown < minimumInterval) - return alignedTimeRoundedDown; - - return alignedTimeRoundedUp; - } - - return fireTime; -} - -} // namespace blink diff --git a/sky/engine/core/frame/DOMTimer.h b/sky/engine/core/frame/DOMTimer.h deleted file mode 100644 index 3c82180c35800..0000000000000 --- a/sky/engine/core/frame/DOMTimer.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_FRAME_DOMTIMER_H_ -#define SKY_ENGINE_CORE_FRAME_DOMTIMER_H_ - -#include "sky/engine/bindings/scheduled_action.h" -#include "sky/engine/core/frame/SuspendableTimer.h" -#include "sky/engine/wtf/Compiler.h" -#include "sky/engine/wtf/OwnPtr.h" -#include "sky/engine/wtf/PassOwnPtr.h" - -namespace blink { - -class ExecutionContext; - -class DOMTimer final : public SuspendableTimer { -public: - // Creates a new timer owned by the ExecutionContext, starts it and returns its ID. - static int install(ExecutionContext*, PassOwnPtr, int timeout, bool singleShot); - static void removeByID(ExecutionContext*, int timeoutID); - - virtual ~DOMTimer(); - - int timeoutID() const; - - // ActiveDOMObject - virtual void contextDestroyed() override; - virtual void stop() override; - - // The following are essentially constants. All intervals are in seconds. - static double hiddenPageAlignmentInterval(); - static double visiblePageAlignmentInterval(); - -private: - friend class ExecutionContext; // For create(). - - // Should only be used by ExecutionContext. - static PassOwnPtr create(ExecutionContext* context, PassOwnPtr action, int timeout, bool singleShot, int timeoutID) - { - return adoptPtr(new DOMTimer(context, action, timeout, singleShot, timeoutID)); - } - - DOMTimer(ExecutionContext*, PassOwnPtr, int interval, bool singleShot, int timeoutID); - virtual void fired() override; - - // Retuns timer fire time rounded to the next multiple of timer alignment interval. - virtual double alignedFireTime(double) const override; - - int m_timeoutID; - int m_nestingLevel; - OwnPtr m_action; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_FRAME_DOMTIMER_H_ diff --git a/sky/engine/core/frame/DOMWindowLifecycleNotifier.cpp b/sky/engine/core/frame/DOMWindowLifecycleNotifier.cpp deleted file mode 100644 index d4798fb1322e2..0000000000000 --- a/sky/engine/core/frame/DOMWindowLifecycleNotifier.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "sky/engine/core/frame/DOMWindowLifecycleNotifier.h" - -namespace blink { - -DOMWindowLifecycleNotifier::DOMWindowLifecycleNotifier(LocalDOMWindow* context) - : LifecycleNotifier(context) -{ -} - -void DOMWindowLifecycleNotifier::addObserver(DOMWindowLifecycleNotifier::Observer* observer) -{ - if (observer->observerType() == Observer::DOMWindowLifecycleObserverType) { - RELEASE_ASSERT(m_iterating != IteratingOverDOMWindowObservers); - m_windowObservers.add(static_cast(observer)); - } - - LifecycleNotifier::addObserver(observer); -} - -void DOMWindowLifecycleNotifier::removeObserver(DOMWindowLifecycleNotifier::Observer* observer) -{ - if (observer->observerType() == Observer::DOMWindowLifecycleObserverType) { - RELEASE_ASSERT(m_iterating != IteratingOverDOMWindowObservers); - m_windowObservers.remove(static_cast(observer)); - } - - LifecycleNotifier::removeObserver(observer); -} - -PassOwnPtr DOMWindowLifecycleNotifier::create(LocalDOMWindow* context) -{ - return adoptPtr(new DOMWindowLifecycleNotifier(context)); -} - -void DOMWindowLifecycleNotifier::notifyAddEventListener(LocalDOMWindow* window, const AtomicString& eventType) -{ - TemporaryChange scope(this->m_iterating, IteratingOverDOMWindowObservers); - for (DOMWindowObserverSet::iterator it = m_windowObservers.begin(); it != m_windowObservers.end(); ++it) - (*it)->didAddEventListener(window, eventType); -} - -void DOMWindowLifecycleNotifier::notifyRemoveEventListener(LocalDOMWindow* window, const AtomicString& eventType) -{ - TemporaryChange scope(this->m_iterating, IteratingOverDOMWindowObservers); - for (DOMWindowObserverSet::iterator it = m_windowObservers.begin(); it != m_windowObservers.end(); ++it) - (*it)->didRemoveEventListener(window, eventType); -} - -void DOMWindowLifecycleNotifier::notifyRemoveAllEventListeners(LocalDOMWindow* window) -{ - TemporaryChange scope(this->m_iterating, IteratingOverDOMWindowObservers); - for (DOMWindowObserverSet::iterator it = m_windowObservers.begin(); it != m_windowObservers.end(); ++it) - (*it)->didRemoveAllEventListeners(window); -} - -} // namespace blink diff --git a/sky/engine/core/frame/DOMWindowLifecycleNotifier.h b/sky/engine/core/frame/DOMWindowLifecycleNotifier.h deleted file mode 100644 index 3ecef60792b1b..0000000000000 --- a/sky/engine/core/frame/DOMWindowLifecycleNotifier.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_FRAME_DOMWINDOWLIFECYCLENOTIFIER_H_ -#define SKY_ENGINE_CORE_FRAME_DOMWINDOWLIFECYCLENOTIFIER_H_ - -#include "sky/engine/core/frame/DOMWindowLifecycleObserver.h" -#include "sky/engine/platform/LifecycleNotifier.h" -#include "sky/engine/wtf/PassOwnPtr.h" -#include "sky/engine/wtf/TemporaryChange.h" -#include "sky/engine/wtf/text/WTFString.h" - -namespace blink { - -class LocalDOMWindow; - -class DOMWindowLifecycleNotifier final : public LifecycleNotifier { -public: - static PassOwnPtr create(LocalDOMWindow*); - - void notifyAddEventListener(LocalDOMWindow*, const AtomicString& eventType); - void notifyRemoveEventListener(LocalDOMWindow*, const AtomicString& eventType); - void notifyRemoveAllEventListeners(LocalDOMWindow*); - - virtual void addObserver(Observer*) override; - virtual void removeObserver(Observer*) override; - -private: - explicit DOMWindowLifecycleNotifier(LocalDOMWindow*); - - typedef HashSet DOMWindowObserverSet; - DOMWindowObserverSet m_windowObservers; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_FRAME_DOMWINDOWLIFECYCLENOTIFIER_H_ diff --git a/sky/engine/core/frame/DOMWindowLifecycleObserver.cpp b/sky/engine/core/frame/DOMWindowLifecycleObserver.cpp deleted file mode 100644 index bfb811e489c81..0000000000000 --- a/sky/engine/core/frame/DOMWindowLifecycleObserver.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "sky/engine/core/frame/DOMWindowLifecycleObserver.h" - -#include "sky/engine/core/frame/LocalDOMWindow.h" - -namespace blink { - -template<> void observerContext(LocalDOMWindow* context, LifecycleObserver* observer) -{ - context->wasObservedBy(observer); -} - -template<> void unobserverContext(LocalDOMWindow* context, LifecycleObserver* observer) -{ - context->wasUnobservedBy(observer); -} - -DOMWindowLifecycleObserver::DOMWindowLifecycleObserver(LocalDOMWindow* window) - : LifecycleObserver(window, DOMWindowLifecycleObserverType) -{ -} - -DOMWindowLifecycleObserver::~DOMWindowLifecycleObserver() -{ -} - -LocalDOMWindow* DOMWindowLifecycleObserver::window() const -{ - return static_cast(lifecycleContext()); -} - -} // namespace blink diff --git a/sky/engine/core/frame/DOMWindowLifecycleObserver.h b/sky/engine/core/frame/DOMWindowLifecycleObserver.h deleted file mode 100644 index 9a019d11c18f1..0000000000000 --- a/sky/engine/core/frame/DOMWindowLifecycleObserver.h +++ /dev/null @@ -1,54 +0,0 @@ - -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_FRAME_DOMWINDOWLIFECYCLEOBSERVER_H_ -#define SKY_ENGINE_CORE_FRAME_DOMWINDOWLIFECYCLEOBSERVER_H_ - -#include "sky/engine/platform/LifecycleObserver.h" -#include "sky/engine/wtf/text/WTFString.h" - -namespace blink { - -class LocalDOMWindow; - -template<> void observerContext(LocalDOMWindow*, LifecycleObserver*); -template<> void unobserverContext(LocalDOMWindow*, LifecycleObserver*); - -class DOMWindowLifecycleObserver : public LifecycleObserver { -public: - explicit DOMWindowLifecycleObserver(LocalDOMWindow*); - virtual ~DOMWindowLifecycleObserver(); - - LocalDOMWindow* window() const; - - virtual void didAddEventListener(LocalDOMWindow*, const AtomicString&) { } - virtual void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) { } - virtual void didRemoveAllEventListeners(LocalDOMWindow*) { } -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_FRAME_DOMWINDOWLIFECYCLEOBSERVER_H_ diff --git a/sky/engine/core/frame/DOMWindowTimers.cpp b/sky/engine/core/frame/DOMWindowTimers.cpp deleted file mode 100644 index e0b192e7ae2bb..0000000000000 --- a/sky/engine/core/frame/DOMWindowTimers.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - * Copyright (C) 2013 Samsung Electronics. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/frame/DOMWindowTimers.h" - -#include "sky/engine/core/events/EventTarget.h" -#include "sky/engine/core/frame/DOMTimer.h" - -namespace blink { - -namespace DOMWindowTimers { - -int setTimeout(EventTarget& eventTarget, PassOwnPtr action, int timeout) -{ - return DOMTimer::install(eventTarget.executionContext(), action, timeout, true); -} - -int setInterval(EventTarget& eventTarget, PassOwnPtr action, int timeout) -{ - return DOMTimer::install(eventTarget.executionContext(), action, timeout, false); -} - -void clearTimeout(EventTarget& eventTarget, int timeoutID) -{ - if (ExecutionContext* context = eventTarget.executionContext()) - DOMTimer::removeByID(context, timeoutID); -} - -void clearInterval(EventTarget& eventTarget, int timeoutID) -{ - if (ExecutionContext* context = eventTarget.executionContext()) - DOMTimer::removeByID(context, timeoutID); -} - -} // namespace DOMWindowTimers - -} // namespace blink diff --git a/sky/engine/core/frame/DOMWindowTimers.h b/sky/engine/core/frame/DOMWindowTimers.h deleted file mode 100644 index 2a880462129d8..0000000000000 --- a/sky/engine/core/frame/DOMWindowTimers.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - * Copyright (C) 2013 Samsung Electronics. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_FRAME_DOMWINDOWTIMERS_H_ -#define SKY_ENGINE_CORE_FRAME_DOMWINDOWTIMERS_H_ - -#include "sky/engine/wtf/Forward.h" - -namespace blink { - -class EventTarget; -class ScheduledAction; - -namespace DOMWindowTimers { -int setTimeout(EventTarget&, PassOwnPtr, int timeout); -int setInterval(EventTarget&, PassOwnPtr, int timeout); -void clearTimeout(EventTarget&, int timeoutId); -void clearInterval(EventTarget&, int timeoutId); -} - -} // namespace blink - -#endif // SKY_ENGINE_CORE_FRAME_DOMWINDOWTIMERS_H_ diff --git a/sky/engine/core/frame/Frame.cpp b/sky/engine/core/frame/Frame.cpp index 314dedb1523bd..25be72be6c1f1 100644 --- a/sky/engine/core/frame/Frame.cpp +++ b/sky/engine/core/frame/Frame.cpp @@ -36,7 +36,6 @@ #include "sky/engine/core/loader/EmptyClients.h" #include "sky/engine/core/loader/FrameLoaderClient.h" #include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/FocusController.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/RenderLayer.h" diff --git a/sky/engine/core/frame/FrameConsole.cpp b/sky/engine/core/frame/FrameConsole.cpp deleted file mode 100644 index 01a4e489f6950..0000000000000 --- a/sky/engine/core/frame/FrameConsole.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/frame/FrameConsole.h" - -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/frame/FrameHost.h" -#include "sky/engine/core/inspector/ConsoleAPITypes.h" -#include "sky/engine/core/inspector/ConsoleMessage.h" -#include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/Page.h" -#include "sky/engine/wtf/text/StringBuilder.h" - -namespace blink { - -FrameConsole::FrameConsole(LocalFrame& frame) - : m_frame(frame) -{ -} - -DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(FrameConsole); - -void FrameConsole::addMessage(PassRefPtr prpConsoleMessage) -{ - RefPtr consoleMessage = prpConsoleMessage; - - // FIXME: This should not need to reach for the main-frame. - // Inspector code should just take the current frame and know how to walk itself. - ExecutionContext* context = m_frame.document(); - if (!context) - return; - - String messageURL = consoleMessage->url(); - unsigned lineNumber = consoleMessage->lineNumber(); - m_frame.page()->addMessageToConsole(&m_frame, consoleMessage->source(), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, String()); -} - -} // namespace blink diff --git a/sky/engine/core/frame/FrameConsole.h b/sky/engine/core/frame/FrameConsole.h deleted file mode 100644 index 4e1b7fadd8dd1..0000000000000 --- a/sky/engine/core/frame/FrameConsole.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_FRAME_FRAMECONSOLE_H_ -#define SKY_ENGINE_CORE_FRAME_FRAMECONSOLE_H_ - -#include "sky/engine/core/frame/ConsoleTypes.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/Forward.h" -#include "sky/engine/wtf/PassOwnPtr.h" - -namespace blink { - -class ConsoleMessage; -class ConsoleMessageStorage; -class Document; -class FrameHost; -class LocalFrame; - -// FrameConsole takes per-frame console messages and routes them up through the FrameHost to the ChromeClient and Inspector. -// It's meant as an abstraction around ChromeClient calls and the way that Blink core/ can add messages to the console. -class FrameConsole final { - DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(FrameConsole); -public: - static PassOwnPtr create(LocalFrame& frame) - { - return adoptPtr(new FrameConsole(frame)); - } - - void addMessage(PassRefPtr); - -private: - explicit FrameConsole(LocalFrame&); - - LocalFrame& m_frame; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_FRAME_FRAMECONSOLE_H_ diff --git a/sky/engine/core/frame/FrameView.cpp b/sky/engine/core/frame/FrameView.cpp index 8ea9560dfa0cd..b692c400d2c4d 100644 --- a/sky/engine/core/frame/FrameView.cpp +++ b/sky/engine/core/frame/FrameView.cpp @@ -35,7 +35,6 @@ #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/loader/FrameLoaderClient.h" #include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/FocusController.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/RenderLayer.h" @@ -186,7 +185,6 @@ RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const void FrameView::performPreLayoutTasks() { TRACE_EVENT0("blink", "FrameView::performPreLayoutTasks"); - lifecycle().advanceTo(DocumentLifecycle::InPreLayout); // Don't schedule more layouts, we're in one. TemporaryChange changeSchedulingEnabled(m_layoutSchedulingEnabled, false); @@ -209,7 +207,6 @@ void FrameView::performPreLayoutTasks() } document->updateRenderTreeIfNeeded(); - lifecycle().advanceTo(DocumentLifecycle::StyleClean); } void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLayout) @@ -219,7 +216,6 @@ void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay ScriptForbiddenScope forbidScript; ASSERT(!isInPerformLayout()); - lifecycle().advanceTo(DocumentLifecycle::InPerformLayout); TemporaryChange changeInPerformLayout(m_inPerformLayout, true); @@ -227,8 +223,6 @@ void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay // FIXME: The 300 other lines in layout() probably belong in other helper functions // so that a single human could understand what layout() is actually doing. rootForThisLayout->layout(); - - lifecycle().advanceTo(DocumentLifecycle::AfterPerformLayout); } void FrameView::scheduleOrPerformPostLayoutTasks() @@ -272,7 +266,6 @@ void FrameView::layout(bool allowSubtree) RefPtr protector(this); m_hasPendingLayout = false; - DocumentLifecycle::Scope lifecycleScope(lifecycle(), DocumentLifecycle::LayoutClean); RELEASE_ASSERT(!isPainting()); @@ -339,11 +332,6 @@ void FrameView::layout(bool allowSubtree) #endif } -DocumentLifecycle& FrameView::lifecycle() const -{ - return m_frame->document()->lifecycle(); -} - void FrameView::setMediaType(const AtomicString& mediaType) { ASSERT(m_frame->document()); @@ -403,7 +391,6 @@ void FrameView::scheduleRelayout() m_hasPendingLayout = true; m_frame->document()->scheduleVisualUpdate(); - lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean); } static bool isObjectAncestorContainerOf(RenderObject* ancestor, RenderObject* descendant) @@ -454,7 +441,6 @@ void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot) m_hasPendingLayout = true; m_frame->document()->scheduleVisualUpdate(); - lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean); } } @@ -466,7 +452,6 @@ bool FrameView::layoutPending() const bool FrameView::isInPerformLayout() const { - ASSERT(m_inPerformLayout == (lifecycle().state() == DocumentLifecycle::InPerformLayout)); return m_inPerformLayout; } @@ -549,11 +534,6 @@ bool FrameView::wasViewportResized() void FrameView::sendResizeEventIfNeeded() { - if (!wasViewportResized()) - return; - - m_lastViewportSize = layoutSize(); - m_frame->document()->enqueueResizeEvent(); } void FrameView::postLayoutTimerFired(Timer*) @@ -623,7 +603,6 @@ void FrameView::paint(GraphicsContext* context, const IntRect& rect) } RELEASE_ASSERT(!needsLayout()); - ASSERT(m_frame->document()->lifecycle().state() >= DocumentLifecycle::StyleAndLayoutClean); bool isTopLevelPainter = !s_inPaintContents; s_inPaintContents = true; @@ -664,9 +643,6 @@ void FrameView::updateLayoutAndStyleForPainting() RefPtr protector(this); updateLayoutAndStyleIfNeededRecursive(); - - // TODO(ojan): Get rid of this and just have the LayoutClean state. - lifecycle().advanceTo(DocumentLifecycle::StyleAndLayoutClean); } void FrameView::updateLayoutAndStyleIfNeededRecursive() diff --git a/sky/engine/core/frame/FrameView.h b/sky/engine/core/frame/FrameView.h index bee2f128f982e..74e346250da80 100644 --- a/sky/engine/core/frame/FrameView.h +++ b/sky/engine/core/frame/FrameView.h @@ -38,7 +38,6 @@ namespace blink { -class DocumentLifecycle; class Element; class FloatSize; class LocalFrame; @@ -182,8 +181,6 @@ class FrameView final : public Widget { void scheduleOrPerformPostLayoutTasks(); void performPostLayoutTasks(); - DocumentLifecycle& lifecycle() const; - // FIXME(sky): Remove now that we're not a ScrollView? void contentsResized(); diff --git a/sky/engine/core/frame/LocalDOMWindow.cpp b/sky/engine/core/frame/LocalDOMWindow.cpp index 3c3745828967f..9762d46e5221e 100644 --- a/sky/engine/core/frame/LocalDOMWindow.cpp +++ b/sky/engine/core/frame/LocalDOMWindow.cpp @@ -28,6 +28,7 @@ #include #include "gen/sky/platform/RuntimeEnabledFeatures.h" +#include "gen/sky/core/EventTypeNames.h" #include "mojo/services/navigation/public/interfaces/navigation.mojom.h" #include "sky/engine/bindings/exception_messages.h" #include "sky/engine/bindings/exception_state.h" @@ -40,15 +41,9 @@ #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/Element.h" #include "sky/engine/core/dom/ExceptionCode.h" -#include "sky/engine/core/dom/ExecutionContext.h" #include "sky/engine/core/dom/RequestAnimationFrameCallback.h" #include "sky/engine/core/editing/Editor.h" -#include "sky/engine/core/events/DOMWindowEventQueue.h" -#include "sky/engine/core/events/EventListener.h" -#include "sky/engine/core/events/HashChangeEvent.h" #include "sky/engine/core/events/PageTransitionEvent.h" -#include "sky/engine/core/frame/DOMWindowLifecycleNotifier.h" -#include "sky/engine/core/frame/FrameConsole.h" #include "sky/engine/core/frame/FrameHost.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalFrame.h" @@ -59,7 +54,6 @@ #include "sky/engine/core/inspector/ConsoleMessage.h" #include "sky/engine/core/loader/FrameLoaderClient.h" #include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/style/RenderStyle.h" #include "sky/engine/core/script/dart_controller.h" @@ -77,63 +71,16 @@ #include "sky/engine/wtf/MathExtras.h" #include "sky/engine/wtf/text/WTFString.h" +// The focus logic in this file is just disconnected cables now. +// TODO(ianh): Remove the concept of focus. + using std::min; using std::max; namespace blink { -static void disableSuddenTermination() -{ - blink::Platform::current()->suddenTerminationChanged(false); -} - -static void enableSuddenTermination() -{ - blink::Platform::current()->suddenTerminationChanged(true); -} - typedef HashCountedSet DOMWindowSet; -static DOMWindowSet& windowsWithUnloadEventListeners() -{ - DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithUnloadEventListeners, ()); - return windowsWithUnloadEventListeners; -} - -static void addUnloadEventListener(LocalDOMWindow* domWindow) -{ - DOMWindowSet& set = windowsWithUnloadEventListeners(); - if (set.isEmpty()) - disableSuddenTermination(); - set.add(domWindow); -} - -static void removeUnloadEventListener(LocalDOMWindow* domWindow) -{ - DOMWindowSet& set = windowsWithUnloadEventListeners(); - DOMWindowSet::iterator it = set.find(domWindow); - if (it == set.end()) - return; - set.remove(it); - if (set.isEmpty()) - enableSuddenTermination(); -} - -static void removeAllUnloadEventListeners(LocalDOMWindow* domWindow) -{ - DOMWindowSet& set = windowsWithUnloadEventListeners(); - DOMWindowSet::iterator it = set.find(domWindow); - if (it == set.end()) - return; - set.removeAll(it); - if (set.isEmpty()) - enableSuddenTermination(); -} - -unsigned LocalDOMWindow::pendingUnloadEventListeners() const -{ - return windowsWithUnloadEventListeners().count(const_cast(this)); -} // This function: // 1) Validates the pending changes are not changing any value to NaN; in that case keep original value. @@ -197,26 +144,10 @@ void LocalDOMWindow::clearDocument() if (!m_document) return; - // FIXME: This should be part of ActiveDOMObject shutdown - clearEventQueue(); - m_document->clearDOMWindow(); m_document = nullptr; } -void LocalDOMWindow::clearEventQueue() -{ - if (!m_eventQueue) - return; - m_eventQueue->close(); - m_eventQueue.clear(); -} - -void LocalDOMWindow::acceptLanguagesChanged() -{ - dispatchEvent(Event::create(EventTypeNames::languagechange)); -} - PassRefPtr LocalDOMWindow::installNewDocument(const DocumentInit& init) { ASSERT(init.frame() == m_frame); @@ -224,96 +155,22 @@ PassRefPtr LocalDOMWindow::installNewDocument(const DocumentInit& init clearDocument(); m_document = Document::create(init); - m_eventQueue = DOMWindowEventQueue::create(m_document.get()); m_document->attach(); return m_document; } -EventQueue* LocalDOMWindow::eventQueue() const -{ - return m_eventQueue.get(); -} - -void LocalDOMWindow::enqueueWindowEvent(PassRefPtr event) -{ - if (!m_eventQueue) - return; - event->setTarget(this); - m_eventQueue->enqueueEvent(event); -} - -void LocalDOMWindow::enqueueDocumentEvent(PassRefPtr event) -{ - if (!m_eventQueue) - return; - event->setTarget(m_document.get()); - m_eventQueue->enqueueEvent(event); -} - -void LocalDOMWindow::dispatchWindowLoadEvent() -{ - ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - dispatchLoadEvent(); -} - -void LocalDOMWindow::documentWasClosed() -{ - dispatchWindowLoadEvent(); - enqueuePageshowEvent(PageshowEventNotPersisted); -} - -void LocalDOMWindow::enqueuePageshowEvent(PageshowEventPersistence persisted) -{ - // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36334 Pageshow event needs to fire asynchronously. - // As per spec pageshow must be triggered asynchronously. - // However to be compatible with other browsers blink fires pageshow synchronously. - dispatchEvent(PageTransitionEvent::create(EventTypeNames::pageshow, persisted), m_document.get()); -} - -void LocalDOMWindow::enqueueHashchangeEvent(const String& oldURL, const String& newURL) -{ - enqueueWindowEvent(HashChangeEvent::create(oldURL, newURL)); -} - LocalDOMWindow::~LocalDOMWindow() { ASSERT(m_hasBeenReset); reset(); -#if ENABLE(OILPAN) - // Oilpan: the frame host and document objects are - // also garbage collected; cannot notify these - // when removing event listeners. - removeAllEventListenersInternal(DoNotBroadcastListenerRemoval); - - // Cleared when detaching document. - ASSERT(!m_eventQueue); -#else - removeAllEventListenersInternal(DoBroadcastListenerRemoval); - ASSERT(m_document->isStopped()); clearDocument(); -#endif -} - -const AtomicString& LocalDOMWindow::interfaceName() const -{ - return EventTargetNames::LocalDOMWindow; -} -ExecutionContext* LocalDOMWindow::executionContext() const -{ - return m_document.get(); -} - -LocalDOMWindow* LocalDOMWindow::toDOMWindow() -{ - return this; } void LocalDOMWindow::AcceptDartGCVisitor(DartGCVisitor& visitor) const { visitor.AddToSetForRoot(document(), dart_wrapper()); - EventTarget::AcceptDartGCVisitor(visitor); } PassRefPtr LocalDOMWindow::matchMedia(const String& media) @@ -404,11 +261,6 @@ Screen& LocalDOMWindow::screen() const return *m_screen; } -FrameConsole* LocalDOMWindow::frameConsole() const -{ - return &m_frame->console(); -} - Location& LocalDOMWindow::location() const { if (!m_location) @@ -441,8 +293,6 @@ void LocalDOMWindow::focus() if (!m_frame) return; - - m_frame->eventHandler().focusDocumentView(); } int LocalDOMWindow::outerHeight() const @@ -626,72 +476,6 @@ DOMWindowCSS& LocalDOMWindow::css() const return *m_css; } -bool LocalDOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr listener, bool useCapture) -{ - if (!EventTarget::addEventListener(eventType, listener, useCapture)) - return false; - - if (Document* document = this->document()) - document->addListenerTypeIfNeeded(eventType); - - lifecycleNotifier().notifyAddEventListener(this, eventType); - - if (eventType == EventTypeNames::unload) - addUnloadEventListener(this); - - return true; -} - -bool LocalDOMWindow::removeEventListener(const AtomicString& eventType, PassRefPtr listener, bool useCapture) -{ - if (!EventTarget::removeEventListener(eventType, listener, useCapture)) - return false; - - lifecycleNotifier().notifyRemoveEventListener(this, eventType); - - if (eventType == EventTypeNames::unload) { - removeUnloadEventListener(this); - } - - return true; -} - -void LocalDOMWindow::dispatchLoadEvent() -{ - RefPtr loadEvent(Event::create(EventTypeNames::load)); - dispatchEvent(loadEvent, document()); -} - -bool LocalDOMWindow::dispatchEvent(PassRefPtr prpEvent, PassRefPtr prpTarget) -{ - ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - - RefPtr protect(this); - RefPtr event = prpEvent; - - event->setTarget(prpTarget ? prpTarget : this); - event->setCurrentTarget(this); - event->setEventPhase(Event::AT_TARGET); - - bool result = fireEventListeners(event.get()); - - return result; -} - -void LocalDOMWindow::removeAllEventListenersInternal(BroadcastListenerRemoval mode) -{ - EventTarget::removeAllEventListeners(); - - lifecycleNotifier().notifyRemoveAllEventListeners(this); - - removeAllUnloadEventListeners(this); -} - -void LocalDOMWindow::removeAllEventListeners() -{ - removeAllEventListenersInternal(DoBroadcastListenerRemoval); -} - void LocalDOMWindow::setLocation(const String& urlString, SetLocationLocking locking) { if (!m_frame) @@ -709,8 +493,6 @@ void LocalDOMWindow::printErrorMessage(const String& message) { if (message.isEmpty()) return; - - frameConsole()->addMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); } @@ -720,14 +502,4 @@ bool LocalDOMWindow::isInsecureScriptAccess(LocalDOMWindow& callingWindow, const return false; } -DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier() -{ - return static_cast(LifecycleContext::lifecycleNotifier()); -} - -PassOwnPtr > LocalDOMWindow::createLifecycleNotifier() -{ - return DOMWindowLifecycleNotifier::create(this); -} - } // namespace blink diff --git a/sky/engine/core/frame/LocalDOMWindow.h b/sky/engine/core/frame/LocalDOMWindow.h index 269458afdbe4d..f6985401ce82e 100644 --- a/sky/engine/core/frame/LocalDOMWindow.h +++ b/sky/engine/core/frame/LocalDOMWindow.h @@ -27,14 +27,14 @@ #ifndef SKY_ENGINE_CORE_FRAME_LOCALDOMWINDOW_H_ #define SKY_ENGINE_CORE_FRAME_LOCALDOMWINDOW_H_ -#include "sky/engine/core/events/EventTarget.h" +#include "sky/engine/core/events/Event.h" #include "sky/engine/core/frame/DOMWindowBase64.h" #include "sky/engine/core/frame/FrameDestructionObserver.h" -#include "sky/engine/platform/LifecycleContext.h" #include "sky/engine/platform/Supplementable.h" #include "sky/engine/platform/heap/Handle.h" #include "sky/engine/wtf/Forward.h" +#include "sky/engine/wtf/HashSet.h" namespace blink { @@ -42,8 +42,6 @@ class CSSStyleDeclaration; class DOMSelection; class DOMURL; class DOMWindowCSS; -class DOMWindowEventQueue; -class DOMWindowLifecycleNotifier; class DOMWindowProperty; class Database; class DatabaseCallback; @@ -51,10 +49,8 @@ class Document; class DocumentInit; class Element; class EventListener; -class EventQueue; class ExceptionState; class FloatRect; -class FrameConsole; class IDBFactory; class LocalFrame; class Location; @@ -75,9 +71,8 @@ enum PageshowEventPersistence { enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList }; -class LocalDOMWindow final : public RefCounted, public EventTargetWithInlineData, public DOMWindowBase64, public FrameDestructionObserver, public Supplementable, public LifecycleContext { +class LocalDOMWindow final : public DartWrappable, public RefCounted, public DOMWindowBase64, public FrameDestructionObserver, public Supplementable { DEFINE_WRAPPERTYPEINFO(); - REFCOUNTED_EVENT_TARGET(LocalDOMWindow); public: static PassRefPtr create(LocalFrame& frame) { @@ -87,10 +82,6 @@ class LocalDOMWindow final : public RefCounted, public EventTarg PassRefPtr installNewDocument(const DocumentInit&); - virtual const AtomicString& interfaceName() const override; - virtual ExecutionContext* executionContext() const override; - - virtual LocalDOMWindow* toDOMWindow() override; void AcceptDartGCVisitor(DartGCVisitor& visitor) const override; void registerProperty(DOMWindowProperty*); @@ -100,8 +91,6 @@ class LocalDOMWindow final : public RefCounted, public EventTarg PassRefPtr matchMedia(const String&); - unsigned pendingUnloadEventListeners() const; - static FloatRect adjustWindowRect(LocalFrame&, const FloatRect& pendingChanges); // DOM Level 0 @@ -145,8 +134,6 @@ class LocalDOMWindow final : public RefCounted, public EventTarg double devicePixelRatio() const; - FrameConsole* frameConsole() const; - void printErrorMessage(const String&); void moveBy(float x, float y) const; @@ -161,17 +148,6 @@ class LocalDOMWindow final : public RefCounted, public EventTarg DOMWindowCSS& css() const; - // Events - // EventTarget API - virtual bool addEventListener(const AtomicString& eventType, PassRefPtr, bool useCapture = false) override; - virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr, bool useCapture = false) override; - virtual void removeAllEventListeners() override; - - using EventTarget::dispatchEvent; - bool dispatchEvent(PassRefPtr prpEvent, PassRefPtr prpTarget); - - void dispatchLoadEvent(); - // This is the interface orientation in degrees. Some examples are: // 0 is straight up; -90 is when the device is rotated 90 clockwise; // 90 is when rotated counter clockwise. @@ -181,24 +157,6 @@ class LocalDOMWindow final : public RefCounted, public EventTarg bool isInsecureScriptAccess(LocalDOMWindow& callingWindow, const String& urlString); - PassOwnPtr > createLifecycleNotifier(); - - EventQueue* eventQueue() const; - void enqueueWindowEvent(PassRefPtr); - void enqueueDocumentEvent(PassRefPtr); - void enqueuePageshowEvent(PageshowEventPersistence); - void enqueueHashchangeEvent(const String& oldURL, const String& newURL); - void dispatchWindowLoadEvent(); - void documentWasClosed(); - - // FIXME: This shouldn't be public once LocalDOMWindow becomes ExecutionContext. - void clearEventQueue(); - - void acceptLanguagesChanged(); - -protected: - DOMWindowLifecycleNotifier& lifecycleNotifier(); - private: explicit LocalDOMWindow(LocalFrame&); @@ -211,18 +169,6 @@ class LocalDOMWindow final : public RefCounted, public EventTarg void resetDOMWindowProperties(); void willDestroyDocumentInFrame(); - // FIXME: Oilpan: the need for this internal method will fall - // away when EventTargets are no longer using refcounts and - // window properties are also on the heap. Inline the minimal - // do-not-broadcast handling then and remove the enum + - // removeAllEventListenersInternal(). - enum BroadcastListenerRemoval { - DoNotBroadcastListenerRemoval, - DoBroadcastListenerRemoval - }; - - void removeAllEventListenersInternal(BroadcastListenerRemoval); - RefPtr m_document; #if ENABLE(ASSERT) @@ -235,8 +181,6 @@ class LocalDOMWindow final : public RefCounted, public EventTarg mutable RefPtr m_location; mutable RefPtr m_tracing; mutable RefPtr m_css; - - RefPtr m_eventQueue; }; } // namespace blink diff --git a/sky/engine/core/frame/LocalFrame.cpp b/sky/engine/core/frame/LocalFrame.cpp index 400f8407da045..e911bfb1fe48d 100644 --- a/sky/engine/core/frame/LocalFrame.cpp +++ b/sky/engine/core/frame/LocalFrame.cpp @@ -36,15 +36,12 @@ #include "sky/engine/core/editing/InputMethodController.h" #include "sky/engine/core/editing/SpellChecker.h" #include "sky/engine/core/events/Event.h" -#include "sky/engine/core/frame/FrameConsole.h" #include "sky/engine/core/frame/FrameDestructionObserver.h" #include "sky/engine/core/frame/FrameHost.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalDOMWindow.h" -#include "sky/engine/core/frame/NewEventHandler.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/loader/FrameLoaderClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/FocusController.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/HitTestResult.h" @@ -65,9 +62,6 @@ inline LocalFrame::LocalFrame(FrameLoaderClient* client, FrameHost* host) , m_editor(Editor::create(*this)) , m_spellChecker(SpellChecker::create(*this)) , m_selection(FrameSelection::create(this)) - , m_eventHandler(adoptPtr(new EventHandler(this))) - , m_newEventHandler(adoptPtr(new NewEventHandler(*this))) - , m_console(FrameConsole::create(*this)) , m_inputMethodController(InputMethodController::create(*this)) , m_document(nullptr) { @@ -136,8 +130,6 @@ void LocalFrame::setView(PassRefPtr view) document()->prepareForDestruction(); } - eventHandler().clear(); - m_view = view; } @@ -199,7 +191,14 @@ String LocalFrame::selectedText() const VisiblePosition LocalFrame::visiblePositionForPoint(const IntPoint& framePoint) { - HitTestResult result = eventHandler().hitTestResultAtPoint(framePoint); + if (!contentRenderer() || !view() || !view()->didFirstLayout()) + return VisiblePosition(); + + LayoutSize padding = LayoutSize(); + HitTestResult result(framePoint, padding.height(), padding.width(), padding.height(), padding.width()); + HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); + contentRenderer()->hitTest(request, result); + Node* node = result.innerNonSharedNode(); if (!node) return VisiblePosition(); @@ -229,19 +228,6 @@ Document* LocalFrame::document() const return m_domWindow ? m_domWindow->document() : 0; } -Document* LocalFrame::documentAtPoint(const IntPoint& point) -{ - if (!view()) - return 0; - - IntPoint pt = view()->windowToContents(point); - HitTestResult result = HitTestResult(pt); - - if (contentRenderer()) - result = eventHandler().hitTestResultAtPoint(pt, HitTestRequest::ReadOnly | HitTestRequest::Active); - return result.innerNode() ? &result.innerNode()->document() : 0; -} - PassRefPtr LocalFrame::rangeForPoint(const IntPoint& framePoint) { VisiblePosition position = visiblePositionForPoint(framePoint); diff --git a/sky/engine/core/frame/LocalFrame.h b/sky/engine/core/frame/LocalFrame.h index 240e24b1fc22c..8a6fc23ddb484 100644 --- a/sky/engine/core/frame/LocalFrame.h +++ b/sky/engine/core/frame/LocalFrame.h @@ -41,17 +41,14 @@ namespace blink { class Document; class Editor; class Element; - class EventHandler; class FloatRect; class FloatSize; - class FrameConsole; class FrameDestructionObserver; class FrameSelection; class FrameView; class InputMethodController; class IntPoint; class IntSize; - class NewEventHandler; class Node; class Range; class RenderView; @@ -85,12 +82,9 @@ namespace blink { RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame. Editor& editor() const; - EventHandler& eventHandler() const; - NewEventHandler& newEventHandler() const; FrameSelection& selection() const; InputMethodController& inputMethodController() const; SpellChecker& spellChecker() const; - FrameConsole& console() const; FrameLoaderClient* loaderClient() const; @@ -104,7 +98,6 @@ namespace blink { String selectedText() const; VisiblePosition visiblePositionForPoint(const IntPoint& framePoint); - Document* documentAtPoint(const IntPoint& windowPoint); PassRefPtr rangeForPoint(const IntPoint& framePoint); void removeSpellingMarkersUnderWords(const Vector& words); @@ -122,9 +115,6 @@ namespace blink { const OwnPtr m_editor; const OwnPtr m_spellChecker; const OwnPtr m_selection; - const OwnPtr m_eventHandler; - const OwnPtr m_newEventHandler; - const OwnPtr m_console; OwnPtr m_inputMethodController; Document* m_document; @@ -150,28 +140,11 @@ namespace blink { return *m_spellChecker; } - inline FrameConsole& LocalFrame::console() const - { - return *m_console; - } - inline InputMethodController& LocalFrame::inputMethodController() const { return *m_inputMethodController; } - inline EventHandler& LocalFrame::eventHandler() const - { - ASSERT(m_eventHandler); - return *m_eventHandler; - } - - inline NewEventHandler& LocalFrame::newEventHandler() const - { - ASSERT(m_newEventHandler); - return *m_newEventHandler; - } - DEFINE_TYPE_CASTS(LocalFrame, Frame, localFrame, true, true); } // namespace blink diff --git a/sky/engine/core/frame/NewEventHandler.cpp b/sky/engine/core/frame/NewEventHandler.cpp deleted file mode 100644 index 1707fe3d02c76..0000000000000 --- a/sky/engine/core/frame/NewEventHandler.cpp +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2015 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 "sky/engine/core/frame/NewEventHandler.h" - -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" -#include "sky/engine/core/editing/Editor.h" -#include "sky/engine/core/editing/FrameSelection.h" -#include "sky/engine/core/editing/htmlediting.h" -#include "sky/engine/core/events/GestureEvent.h" -#include "sky/engine/core/events/KeyboardEvent.h" -#include "sky/engine/core/events/PointerEvent.h" -#include "sky/engine/core/events/WheelEvent.h" -#include "sky/engine/core/frame/LocalFrame.h" -#include "sky/engine/core/frame/FrameView.h" -#include "sky/engine/core/rendering/RenderObject.h" -#include "sky/engine/core/rendering/RenderView.h" -#include "sky/engine/platform/KeyboardCodes.h" -#include "sky/engine/platform/geometry/FloatPoint.h" -#include "sky/engine/public/platform/WebInputEvent.h" - -namespace blink { - -static VisiblePosition visiblePositionForHitTestResult(const HitTestResult& hitTestResult) -{ - Node* innerNode = hitTestResult.innerNode(); - VisiblePosition position(innerNode->renderer()->positionForPoint(hitTestResult.localPoint())); - if (!position.isNull()) - return position; - return VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOWNSTREAM); -} - -template -static LayoutPoint positionForEvent(const EventType& event) -{ - return roundedLayoutPoint(FloatPoint(event.x, event.y)); -} - -NewEventHandler::NewEventHandler(LocalFrame& frame) - : m_frame(frame) - , m_suppressNextCharEvent(false) -{ -} - -NewEventHandler::~NewEventHandler() -{ -} - -Node* NewEventHandler::targetForKeyboardEvent() const -{ - Document* document = m_frame.document(); - if (Node* focusedElement = document->focusedElement()) - return focusedElement; - return document; -} - -Node* NewEventHandler::targetForHitTestResult(const HitTestResult& hitTestResult) -{ - Node* node = hitTestResult.innerNode(); - if (!node) - return m_frame.document(); - if (node->isTextNode()) - return NodeRenderingTraversal::parent(node); - return node; -} - -HitTestResult NewEventHandler::performHitTest(const LayoutPoint& point) -{ - HitTestResult result(point); - if (!m_frame.contentRenderer()) - return result; - m_frame.contentRenderer()->hitTest(HitTestRequest(HitTestRequest::ReadOnly), result); - return result; -} - -bool NewEventHandler::dispatchPointerEvent(PointerState& state, const WebPointerEvent& event) -{ - RefPtr pointerEvent = PointerEvent::create(event); - pointerEvent->setDx(event.x - state.x); - pointerEvent->setDy(event.y - state.y); - state.x = event.x; - state.y = event.y; - // TODO(abarth): Keep track of how many pointers are targeting the same node - // and only mark the first one as primary. - return state.target->dispatchEvent(pointerEvent.release()); -} - -bool NewEventHandler::dispatchGestureEvent(Node& target, const WebGestureEvent& event) -{ - RefPtr gestureEvent = GestureEvent::create(event); - return target.dispatchEvent(gestureEvent.release()); -} - -bool NewEventHandler::dispatchKeyboardEvent(Node& target, const WebKeyboardEvent& event) -{ - RefPtr keyboardEvent = KeyboardEvent::create(event); - return target.dispatchEvent(keyboardEvent.release()); -} - -bool NewEventHandler::dispatchWheelEvent(Node& target, const WebWheelEvent& event) -{ - RefPtr wheelEvent = WheelEvent::create(event); - return target.dispatchEvent(wheelEvent.release()); -} - -bool NewEventHandler::dispatchClickEvent(Node& capturingTarget, const WebPointerEvent& event) -{ - ASSERT(event.type == WebInputEvent::PointerUp); - HitTestResult hitTestResult = performHitTest(positionForEvent(event)); - Node* releaseTarget = targetForHitTestResult(hitTestResult); - Node* clickTarget = NodeRenderingTraversal::commonAncestor(*releaseTarget, capturingTarget); - if (!clickTarget) - return true; - // TODO(abarth): Make a proper gesture event that includes information from the event. - return clickTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNames::click)); -} - -void NewEventHandler::updateSelectionForPointerDown(const HitTestResult& hitTestResult, const WebPointerEvent& event) -{ - Node* innerNode = hitTestResult.innerNode(); - if (!innerNode || !innerNode->renderer()) - return; - if (Position::nodeIsUserSelectNone(innerNode)) - return; - if (!innerNode->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart))) - return; - VisiblePosition position = visiblePositionForHitTestResult(hitTestResult); - // TODO(abarth): Can we change this to setSelectionIfNeeded? - m_frame.selection().setNonDirectionalSelectionIfNeeded(VisibleSelection(position), CharacterGranularity); -} - -bool NewEventHandler::handlePointerEvent(const WebPointerEvent& event) -{ - if (event.type == WebInputEvent::PointerDown) - return handlePointerDownEvent(event); - if (event.type == WebInputEvent::PointerUp) - return handlePointerUpEvent(event); - if (event.type == WebInputEvent::PointerMove) - return handlePointerMoveEvent(event); - ASSERT(event.type == WebInputEvent::PointerCancel); - return handlePointerCancelEvent(event); -} - -bool NewEventHandler::handleGestureEvent(const WebGestureEvent& event) -{ - HitTestResult hitTestResult = performHitTest(positionForEvent(event)); - RefPtr target = targetForHitTestResult(hitTestResult); - return target && !dispatchGestureEvent(*target, event); -} - -bool NewEventHandler::handleKeyboardEvent(const WebKeyboardEvent& event) -{ - bool shouldSuppressCharEvent = m_suppressNextCharEvent; - m_suppressNextCharEvent = false; - - if (event.type == WebInputEvent::Char) { - if (shouldSuppressCharEvent) - return true; - // Do we really need to suppress keypress events for these keys anymore? - if (event.key == VKEY_BACK - || event.key == VKEY_ESCAPE) - return true; - } - - RefPtr target = targetForKeyboardEvent(); - bool handled = target && !dispatchKeyboardEvent(*target, event); - - // If the keydown event was handled, we don't want to "generate" a keypress - // event for that keystroke. However, we'll receive a Char event from the - // embedder regardless, so we set m_suppressNextCharEvent, will will prevent - // us from dispatching the keypress event when we receive that Char event. - if (handled && event.type == WebInputEvent::KeyDown) - m_suppressNextCharEvent = true; - - return handled; -} - -bool NewEventHandler::handleWheelEvent(const WebWheelEvent& event) -{ - HitTestResult hitTestResult = performHitTest(positionForEvent(event)); - RefPtr target = targetForHitTestResult(hitTestResult); - return target && !dispatchWheelEvent(*target, event); -} - -bool NewEventHandler::handlePointerDownEvent(const WebPointerEvent& event) -{ - // In principle, we shouldn't get another pointer down for the same - // pointer ID, but for mice, we don't get a pointer cancel when you - // drag outside the window frame on Linux. For now, send the pointer - // cancel at this point. - bool alreadyDown = m_stateForPointer.find(event.pointer) != m_stateForPointer.end(); - if (event.kind == WebPointerEvent::Mouse && alreadyDown) { - WebPointerEvent fakeCancel = event; - fakeCancel.type = WebInputEvent::PointerCancel; - handlePointerCancelEvent(fakeCancel); - } - - DCHECK(!alreadyDown) << "Pointer id " << event.pointer << "already down!"; - HitTestResult hitTestResult = performHitTest(positionForEvent(event)); - RefPtr target = targetForHitTestResult(hitTestResult); - if (!target) - return false; - PointerState& state = m_stateForPointer[event.pointer]; - state.target = target; - bool eventSwallowed = !dispatchPointerEvent(state, event); - // TODO(abarth): Set the target for the pointer to something determined when - // dispatching the event. - updateSelectionForPointerDown(hitTestResult, event); - return eventSwallowed; -} - -bool NewEventHandler::handlePointerUpEvent(const WebPointerEvent& event) -{ - auto it = m_stateForPointer.find(event.pointer); - if (it == m_stateForPointer.end()) - return false; - PointerState stateCopy = it->second; - m_stateForPointer.erase(it); - ASSERT(stateCopy.target); - bool eventSwallowed = !dispatchPointerEvent(stateCopy, event); - // When the user releases the primary pointer, we need to dispatch a tap - // event to the common ancestor for where the pointer went down and where - // it came up. - if (!eventSwallowed && !dispatchClickEvent(*stateCopy.target, event)) - eventSwallowed = true; - return eventSwallowed; -} - -bool NewEventHandler::handlePointerMoveEvent(const WebPointerEvent& event) -{ - auto it = m_stateForPointer.find(event.pointer); - if (it == m_stateForPointer.end()) - return false; - PointerState& state = it->second; - ASSERT(state.target); - return dispatchPointerEvent(state, event); -} - -bool NewEventHandler::handlePointerCancelEvent(const WebPointerEvent& event) -{ - auto it = m_stateForPointer.find(event.pointer); - if (it == m_stateForPointer.end()) - return false; - PointerState stateCopy = it->second; - m_stateForPointer.erase(it); - ASSERT(stateCopy.target); - return dispatchPointerEvent(stateCopy, event); -} - -} diff --git a/sky/engine/core/frame/NewEventHandler.h b/sky/engine/core/frame/NewEventHandler.h deleted file mode 100644 index 85053d33c842c..0000000000000 --- a/sky/engine/core/frame/NewEventHandler.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2015 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. - -#ifndef SKY_ENGINE_CORE_FRAME_NEWEVENTHANDLER_H_ -#define SKY_ENGINE_CORE_FRAME_NEWEVENTHANDLER_H_ - -#include -#include "sky/engine/core/dom/Node.h" -#include "sky/engine/core/rendering/HitTestRequest.h" -#include "sky/engine/core/rendering/HitTestResult.h" -#include "sky/engine/wtf/HashMap.h" - -namespace blink { - -class LocalFrame; -class WebGestureEvent; -class WebKeyboardEvent; -class WebPointerEvent; -class WebWheelEvent; - -class NewEventHandler { - WTF_MAKE_NONCOPYABLE(NewEventHandler); -public: - explicit NewEventHandler(LocalFrame&); - ~NewEventHandler(); - - bool handlePointerEvent(const WebPointerEvent&); - bool handleGestureEvent(const WebGestureEvent&); - bool handleKeyboardEvent(const WebKeyboardEvent&); - bool handleWheelEvent(const WebWheelEvent&); - -private: - struct PointerState { - RefPtr target; - double x = 0; - double y = 0; - }; - - bool handlePointerDownEvent(const WebPointerEvent&); - bool handlePointerUpEvent(const WebPointerEvent&); - bool handlePointerMoveEvent(const WebPointerEvent&); - bool handlePointerCancelEvent(const WebPointerEvent&); - - bool dispatchGestureEvent(Node& target, const WebGestureEvent& event); - bool dispatchPointerEvent(PointerState& state, const WebPointerEvent&); - bool dispatchClickEvent(Node& capturingTarget, const WebPointerEvent&); - bool dispatchKeyboardEvent(Node& target, const WebKeyboardEvent& event); - bool dispatchWheelEvent(Node& target, const WebWheelEvent& event); - - Node* targetForKeyboardEvent() const; - Node* targetForHitTestResult(const HitTestResult& hitTestResult); - HitTestResult performHitTest(const LayoutPoint&); - void updateSelectionForPointerDown(const HitTestResult&, const WebPointerEvent&); - - typedef std::map PointerStateMap; - - LocalFrame& m_frame; - PointerStateMap m_stateForPointer; - bool m_suppressNextCharEvent; -}; - -} - -#endif // SKY_ENGINE_CORE_FRAME_NEWEVENTHANDLER_H_ diff --git a/sky/engine/core/frame/SuspendableTimer.cpp b/sky/engine/core/frame/SuspendableTimer.cpp deleted file mode 100644 index 553923bc4360e..0000000000000 --- a/sky/engine/core/frame/SuspendableTimer.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "sky/engine/core/frame/SuspendableTimer.h" - -namespace blink { - -SuspendableTimer::SuspendableTimer(ExecutionContext* context) - : ActiveDOMObject(context) - , m_nextFireInterval(0) - , m_repeatInterval(0) - , m_active(false) -#if ENABLE(ASSERT) - , m_suspended(false) -#endif -{ -} - -SuspendableTimer::~SuspendableTimer() -{ -} - -bool SuspendableTimer::hasPendingActivity() const -{ - return isActive(); -} - -void SuspendableTimer::stop() -{ - TimerBase::stop(); -} - -void SuspendableTimer::suspend() -{ -#if ENABLE(ASSERT) - ASSERT(!m_suspended); - m_suspended = true; -#endif - m_active = isActive(); - if (m_active) { - m_nextFireInterval = nextUnalignedFireInterval(); - m_repeatInterval = repeatInterval(); - TimerBase::stop(); - } -} - -void SuspendableTimer::resume() -{ -#if ENABLE(ASSERT) - ASSERT(m_suspended); - m_suspended = false; -#endif - // FIXME: FROM_HERE is wrong here. - if (m_active) - start(m_nextFireInterval, m_repeatInterval, FROM_HERE); -} - -} // namespace blink diff --git a/sky/engine/core/frame/SuspendableTimer.h b/sky/engine/core/frame/SuspendableTimer.h deleted file mode 100644 index f5a2e0858b7a7..0000000000000 --- a/sky/engine/core/frame/SuspendableTimer.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_CORE_FRAME_SUSPENDABLETIMER_H_ -#define SKY_ENGINE_CORE_FRAME_SUSPENDABLETIMER_H_ - -#include "sky/engine/core/dom/ActiveDOMObject.h" -#include "sky/engine/platform/Timer.h" - -namespace blink { - -class SuspendableTimer : public TimerBase, public ActiveDOMObject { -public: - explicit SuspendableTimer(ExecutionContext*); - virtual ~SuspendableTimer(); - - // ActiveDOMObject - virtual bool hasPendingActivity() const override final; - virtual void stop() override; - virtual void suspend() override final; - virtual void resume() override final; - -private: - virtual void fired() = 0; - - double m_nextFireInterval; - double m_repeatInterval; - bool m_active; -#if ENABLE(ASSERT) - bool m_suspended; -#endif -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_FRAME_SUSPENDABLETIMER_H_ diff --git a/sky/engine/core/frame/Window.idl b/sky/engine/core/frame/Window.idl index 1d966dbf73dec..de15331f9c41f 100644 --- a/sky/engine/core/frame/Window.idl +++ b/sky/engine/core/frame/Window.idl @@ -28,7 +28,7 @@ // http://www.w3.org/html/wg/drafts/html/master/browsers.html#window [ ImplementedAs=LocalDOMWindow, -] interface Window : EventTarget { +] interface Window { readonly attribute Screen screen; [Replaceable, PutForwards=href] readonly attribute Location location; @@ -78,4 +78,4 @@ }; Window implements WindowBase64; -Window implements WindowTimers; + diff --git a/sky/engine/core/frame/WindowTimers.idl b/sky/engine/core/frame/WindowTimers.idl deleted file mode 100644 index 700e68d72c34f..0000000000000 --- a/sky/engine/core/frame/WindowTimers.idl +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2011 Google Inc. All rights reserved. - * Copyright (C) 2013 Samsung Electronics. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#windowtimers - -[ - ImplementedAs=DOMWindowTimers, - LegacyTreatAsPartialInterface, - NoInterfaceObject, // Always used on target of 'implements' -] interface WindowTimers { - // FIXME: currently using [Custom] and |any| because overload algorithm - // can't handle Function/DOMString overload properly - // http://crbug.com/293561 - // FIXME: would be clearer as a union type, like: - // typedef (Function or DOMString) Handler - // Needs spec update and better union support: http://crbug.com/240176 - // [Custom] long setTimeout(any handler, [Default=Undefined] optional long timeout); - void clearTimeout([Default=Undefined] optional long handle); - // [Custom] long setInterval(any handler, [Default=Undefined] optional long timeout); - void clearInterval([Default=Undefined] optional long handle); -}; diff --git a/sky/engine/core/inspector/ScriptGCEventListener.h b/sky/engine/core/inspector/ScriptGCEventListener.h deleted file mode 100644 index 5af2c75ca45e7..0000000000000 --- a/sky/engine/core/inspector/ScriptGCEventListener.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_INSPECTOR_SCRIPTGCEVENTLISTENER_H_ -#define SKY_ENGINE_CORE_INSPECTOR_SCRIPTGCEVENTLISTENER_H_ - - -namespace blink { - -class ScriptGCEventListener -{ -public: - virtual void didGC(double startTime, double endTime, size_t collectedBytes) = 0; - virtual ~ScriptGCEventListener(){} -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_INSPECTOR_SCRIPTGCEVENTLISTENER_H_ diff --git a/sky/engine/core/loader/FrameLoader.cpp b/sky/engine/core/loader/FrameLoader.cpp index 1f25cfafecd15..f602aa9d18506 100644 --- a/sky/engine/core/loader/FrameLoader.cpp +++ b/sky/engine/core/loader/FrameLoader.cpp @@ -49,7 +49,6 @@ #include "sky/engine/core/loader/FrameLoaderClient.h" #include "sky/engine/core/loader/UniqueIdentifier.h" #include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/platform/Logging.h" #include "sky/engine/platform/geometry/FloatRect.h" @@ -99,7 +98,6 @@ void FrameLoader::clear() m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); m_frame->selection().prepareForDestruction(); - m_frame->eventHandler().clear(); if (m_frame->view()) m_frame->view()->clear(); } @@ -119,8 +117,6 @@ void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url) ASSERT(!url.isEmpty()); if (!frame) return; - - frame->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, "Not allowed to load local resource: " + url)); } void FrameLoader::stopAllLoaders() diff --git a/sky/engine/core/page/EventHandler.cpp b/sky/engine/core/page/EventHandler.cpp deleted file mode 100644 index 543fa4cf2c449..0000000000000 --- a/sky/engine/core/page/EventHandler.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) - * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/page/EventHandler.h" - -#include "gen/sky/core/HTMLNames.h" -#include "gen/sky/platform/RuntimeEnabledFeatures.h" -#include "sky/engine/bindings/exception_state_placeholder.h" -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/DocumentMarkerController.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" -#include "sky/engine/core/editing/Editor.h" -#include "sky/engine/core/editing/FrameSelection.h" -#include "sky/engine/core/editing/TextIterator.h" -#include "sky/engine/core/editing/htmlediting.h" -#include "sky/engine/core/events/DOMWindowEventQueue.h" -#include "sky/engine/core/events/EventPath.h" -#include "sky/engine/core/events/KeyboardEvent.h" -#include "sky/engine/core/events/TextEvent.h" -#include "sky/engine/core/frame/FrameView.h" -#include "sky/engine/core/frame/LocalFrame.h" -#include "sky/engine/core/frame/Settings.h" -#include "sky/engine/core/loader/FrameLoaderClient.h" -#include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/EditorClient.h" -#include "sky/engine/core/page/FocusController.h" -#include "sky/engine/core/page/Page.h" -#include "sky/engine/core/rendering/HitTestRequest.h" -#include "sky/engine/core/rendering/HitTestResult.h" -#include "sky/engine/core/rendering/RenderLayer.h" -#include "sky/engine/core/rendering/RenderView.h" -#include "sky/engine/core/rendering/style/RenderStyle.h" -#include "sky/engine/platform/TraceEvent.h" -#include "sky/engine/platform/KeyboardCodes.h" -#include "sky/engine/platform/geometry/FloatPoint.h" -#include "sky/engine/platform/graphics/Image.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/Assertions.h" -#include "sky/engine/wtf/CurrentTime.h" -#include "sky/engine/wtf/StdLibExtras.h" -#include "sky/engine/wtf/TemporaryChange.h" - -namespace blink { - -class MaximumDurationTracker { -public: - explicit MaximumDurationTracker(double *maxDuration) - : m_maxDuration(maxDuration) - , m_start(monotonicallyIncreasingTime()) - { - } - - ~MaximumDurationTracker() - { - *m_maxDuration = max(*m_maxDuration, monotonicallyIncreasingTime() - m_start); - } - -private: - double* m_maxDuration; - double m_start; -}; - -EventHandler::EventHandler(LocalFrame* frame) - : m_frame(frame) - , m_capturesDragging(false) - , m_selectionInitiationState(HaveNotStartedSelection) - , m_clickCount(0) - , m_shouldOnlyFireDragOverEvent(false) - , m_didStartDrag(false) - , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) - , m_lastShowPressTimestamp(0) -{ -} - -EventHandler::~EventHandler() -{ -} - -void EventHandler::clear() -{ - m_activeIntervalTimer.stop(); - m_clickCount = 0; - m_clickNode = nullptr; - m_dragTarget = nullptr; - m_shouldOnlyFireDragOverEvent = false; - m_capturesDragging = false; - m_didStartDrag = false; - m_lastShowPressTimestamp = 0; - m_lastDeferredTapElement = nullptr; -} - -void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) -{ - if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) - return; - if (nodeToBeRemoved.isInShadowTree()) { - m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); - } else { - // We don't dispatch click events if the mousedown node is removed - // before a mouseup event. It is compatible with IE and Firefox. - m_clickNode = nullptr; - } -} - -HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding) -{ - TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); - - HitTestResult result(point, padding.height(), padding.width(), padding.height(), padding.width()); - - // RenderView::hitTest causes a layout, and we don't want to hit that until the first - // layout because until then, there is nothing shown on the screen - the user can't - // have intentionally clicked on something belonging to this page. Furthermore, - // mousemove events before the first layout should not lead to a premature layout() - // happening, which could show a flash of white. - // See also the similar code in Document::prepareMouseEvent. - if (!m_frame->contentRenderer() || !m_frame->view() || !m_frame->view()->didFirstLayout()) - return result; - - // hitTestResultAtPoint is specifically used to hitTest into all frames, thus it always allows child frame content. - HitTestRequest request(hitType); - m_frame->contentRenderer()->hitTest(request, result); - - return result; -} - -void EventHandler::invalidateClick() -{ - m_clickCount = 0; - m_clickNode = nullptr; -} - -void EventHandler::activeIntervalTimerFired(Timer*) -{ - m_activeIntervalTimer.stop(); - m_lastDeferredTapElement = nullptr; -} - -void EventHandler::notifyElementActivated() -{ - // Since another element has been set to active, stop current timer and clear reference. - if (m_activeIntervalTimer.isActive()) - m_activeIntervalTimer.stop(); - m_lastDeferredTapElement = nullptr; -} - -void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event) -{ - if (event->type() == EventTypeNames::keydown) { - // Clear caret blinking suspended state to make sure that caret blinks - // when we type again after long pressing on an empty input field. - if (m_frame && m_frame->selection().isCaretBlinkingSuspended()) - m_frame->selection().setCaretBlinkingSuspended(false); - - m_frame->editor().handleKeyboardEvent(event); - if (event->defaultHandled()) - return; - if (event->key() == VKEY_TAB) - defaultTabEventHandler(event); - } - if (event->type() == EventTypeNames::keypress) { - m_frame->editor().handleKeyboardEvent(event); - if (event->defaultHandled()) - return; - } -} - -bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLocation) const -{ - return dragHysteresisExceeded(flooredIntPoint(floatDragViewportLocation)); -} - -bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation) const -{ - return false; -} - -// TODO(abarth): This should just be targetForKeyboardEvent -static Node* eventTargetNodeForDocument(Document* document) -{ - if (Node* node = document->focusedElement()) - return node; - return document; -} - -bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEvent, TextEventInputType inputType) -{ - // Platforms should differentiate real commands like selectAll from text input in disguise (like insertNewline), - // and avoid dispatching text input events from keydown default handlers. - ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || toKeyboardEvent(underlyingEvent)->type() == EventTypeNames::keypress); - - if (!m_frame) - return false; - - EventTarget* target; - if (underlyingEvent) - target = underlyingEvent->target(); - else - target = eventTargetNodeForDocument(m_frame->document()); - if (!target) - return false; - - RefPtr event = TextEvent::create(m_frame->domWindow(), text, inputType); - event->setUnderlyingEvent(underlyingEvent); - - target->dispatchEvent(event, IGNORE_EXCEPTION); - return event->defaultHandled(); -} - -void EventHandler::defaultTextInputEventHandler(TextEvent* event) -{ - if (m_frame->editor().handleTextEvent(event)) - event->setDefaultHandled(); -} - -void EventHandler::defaultTabEventHandler(KeyboardEvent* event) -{ -} - -void EventHandler::capsLockStateMayHaveChanged() -{ -} - -HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType) -{ - HitTestResult result(point); - - if (!frame || !frame->contentRenderer()) - return result; - if (frame->view()) { - IntRect rect = frame->view()->visibleContentRect(); - if (!rect.contains(roundedIntPoint(point))) - return result; - } - frame->contentRenderer()->hitTest(HitTestRequest(hitType), result); - return result; -} - -TouchAction EventHandler::intersectTouchAction(TouchAction action1, TouchAction action2) -{ - if (action1 == TouchActionNone || action2 == TouchActionNone) - return TouchActionNone; - if (action1 == TouchActionAuto) - return action2; - if (action2 == TouchActionAuto) - return action1; - if (!(action1 & action2)) - return TouchActionNone; - return action1 & action2; -} - -TouchAction EventHandler::computeEffectiveTouchAction(const Node& node) -{ - // Start by permitting all actions, then walk the elements supporting - // touch-action from the target node up to the nearest scrollable ancestor - // and exclude any prohibited actions. - TouchAction effectiveTouchAction = TouchActionAuto; - for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal::parent(curNode)) { - if (RenderObject* renderer = curNode->renderer()) { - if (renderer->supportsTouchAction()) { - TouchAction action = renderer->style()->touchAction(); - effectiveTouchAction = intersectTouchAction(action, effectiveTouchAction); - if (effectiveTouchAction == TouchActionNone) - break; - } - } - } - return effectiveTouchAction; -} - -void EventHandler::focusDocumentView() -{ - Page* page = m_frame->page(); - if (!page) - return; - page->focusController().focusDocumentView(m_frame); -} - -} // namespace blink diff --git a/sky/engine/core/page/EventHandler.h b/sky/engine/core/page/EventHandler.h deleted file mode 100644 index 8cc094d85d2c9..0000000000000 --- a/sky/engine/core/page/EventHandler.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_PAGE_EVENTHANDLER_H_ -#define SKY_ENGINE_CORE_PAGE_EVENTHANDLER_H_ - -#include "sky/engine/core/editing/TextGranularity.h" -#include "sky/engine/core/events/TextEventInputType.h" -#include "sky/engine/core/page/FocusType.h" -#include "sky/engine/core/rendering/HitTestRequest.h" -#include "sky/engine/core/rendering/style/RenderStyleConstants.h" -#include "sky/engine/platform/Timer.h" -#include "sky/engine/platform/geometry/LayoutPoint.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/Forward.h" -#include "sky/engine/wtf/HashMap.h" -#include "sky/engine/wtf/HashTraits.h" -#include "sky/engine/wtf/RefPtr.h" - -namespace blink { - -class Document; -class Element; -class Event; -class EventTarget; -class FloatPoint; -class FloatQuad; -class HitTestRequest; -class HitTestResult; -class KeyboardEvent; -class LocalFrame; -class Node; -class RenderLayer; -class RenderObject; -class TextEvent; -class VisibleSelection; -class Widget; - -enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace }; -enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis }; - -class EventHandler { - WTF_MAKE_NONCOPYABLE(EventHandler); -public: - explicit EventHandler(LocalFrame*); - ~EventHandler(); - - void clear(); - void nodeWillBeRemoved(Node&); - - HitTestResult hitTestResultAtPoint(const LayoutPoint&, - HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active, - const LayoutSize& padding = LayoutSize()); - - void defaultKeyboardEventHandler(KeyboardEvent*); - - bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, TextEventInputType = TextEventInputKeyboard); - void defaultTextInputEventHandler(TextEvent*); - - void focusDocumentView(); - - void capsLockStateMayHaveChanged(); // Only called by FrameSelection - - void notifyElementActivated(); - -private: - void hoverTimerFired(Timer*); - void activeIntervalTimerFired(Timer*); - - TouchAction intersectTouchAction(const TouchAction, const TouchAction); - TouchAction computeEffectiveTouchAction(const Node&); - - HitTestResult hitTestResultInFrame(LocalFrame*, const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active); - - void invalidateClick(); - - bool dragHysteresisExceeded(const FloatPoint&) const; - bool dragHysteresisExceeded(const IntPoint&) const; - - void defaultTabEventHandler(KeyboardEvent*); - - bool capturesDragging() const { return m_capturesDragging; } - - LocalFrame* const m_frame; - - bool m_capturesDragging; - - enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection }; - SelectionInitiationState m_selectionInitiationState; - - LayoutPoint m_dragStartPos; - - int m_clickCount; - RefPtr m_clickNode; - - RefPtr m_dragTarget; - bool m_shouldOnlyFireDragOverEvent; - - bool m_didStartDrag; - - Timer m_activeIntervalTimer; - double m_lastShowPressTimestamp; - RefPtr m_lastDeferredTapElement; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_PAGE_EVENTHANDLER_H_ diff --git a/sky/engine/core/page/FocusController.cpp b/sky/engine/core/page/FocusController.cpp index 05884cb0f3214..e059f53d0dee5 100644 --- a/sky/engine/core/page/FocusController.cpp +++ b/sky/engine/core/page/FocusController.cpp @@ -27,6 +27,7 @@ #include "sky/engine/core/page/FocusController.h" #include +#include "gen/sky/core/EventTypeNames.h" #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/Element.h" #include "sky/engine/core/dom/ElementTraversal.h" @@ -43,11 +44,14 @@ #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/page/ChromeClient.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/HitTestResult.h" #include "sky/engine/core/rendering/RenderLayer.h" +// This file is no longer needed now that nothing can be focused and +// events can't be targetted at nodes. +// TODO(ianh): We should remove it. + namespace blink { // FIXME: Some of Node* return values and Node* arguments should be Element*. @@ -96,37 +100,6 @@ FocusNavigationScope FocusNavigationScope::ownedByShadowHost(Node* node) return FocusNavigationScope(toElement(node)->shadow()->shadowRoot()); } -static inline void dispatchEventsOnWindowAndFocusedNode(Document* document, bool focused) -{ - // If we have a focused node we should dispatch blur on it before we blur the window. - // If we have a focused node we should dispatch focus on it after we focus the window. - // https://bugs.webkit.org/show_bug.cgi?id=27105 - - if (!focused && document->focusedElement()) { - RefPtr focusedElement(document->focusedElement()); - focusedElement->setFocus(false); - focusedElement->dispatchBlurEvent(0); - if (focusedElement == document->focusedElement()) { - focusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, 0); - if (focusedElement == document->focusedElement()) - focusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut, 0); - } - } - - if (LocalDOMWindow* window = document->domWindow()) - window->dispatchEvent(Event::create(focused ? EventTypeNames::focus : EventTypeNames::blur)); - if (focused && document->focusedElement()) { - RefPtr focusedElement(document->focusedElement()); - focusedElement->setFocus(true); - focusedElement->dispatchFocusEvent(0, FocusTypePage); - if (focusedElement == document->focusedElement()) { - document->focusedElement()->dispatchFocusInEvent(EventTypeNames::focusin, 0); - if (focusedElement == document->focusedElement()) - document->focusedElement()->dispatchFocusInEvent(EventTypeNames::DOMFocusIn, 0); - } - } -} - #if ENABLE(ASSERT) static inline bool isNonFocusableShadowHost(Node* node) { @@ -200,17 +173,6 @@ void FocusController::setFocusedFrame(PassRefPtr frame) m_focusedFrame = frame.get(); - // Now that the frame is updated, fire events and update the selection focused states of both frames. - if (oldFrame && oldFrame->view()) { - oldFrame->selection().setFocused(false); - oldFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::blur)); - } - - if (newFrame && newFrame->view() && isFocused()) { - newFrame->selection().setFocused(true); - newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus)); - } - m_isChangingFocusedFrame = false; m_page->focusedFrameChanged(newFrame.get()); @@ -222,34 +184,6 @@ void FocusController::focusDocumentView(PassRefPtr frame) if (m_focusedFrame == frame) return; - RefPtr focusedFrame = m_focusedFrame.get(); - if (focusedFrame && focusedFrame->view()) { - RefPtr document = focusedFrame->document(); - Element* focusedElement = document ? document->focusedElement() : 0; - if (focusedElement) { - focusedElement->dispatchBlurEvent(0); - if (focusedElement == document->focusedElement()) { - focusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, 0); - if (focusedElement == document->focusedElement()) - focusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut, 0); - } - } - } - - RefPtr newFocusedFrame = frame.get(); - if (newFocusedFrame && newFocusedFrame->view()) { - RefPtr document = newFocusedFrame->document(); - Element* focusedElement = document ? document->focusedElement() : 0; - if (focusedElement) { - focusedElement->dispatchFocusEvent(0, FocusTypePage); - if (focusedElement == document->focusedElement()) { - document->focusedElement()->dispatchFocusInEvent(EventTypeNames::focusin, 0); - if (focusedElement == document->focusedElement()) - document->focusedElement()->dispatchFocusInEvent(EventTypeNames::DOMFocusIn, 0); - } - } - } - setFocusedFrame(frame); } @@ -268,13 +202,6 @@ void FocusController::setFocused(bool focused) if (!m_focusedFrame) setFocusedFrame(m_page->mainFrame()); - - // setFocusedFrame above might reject to update m_focusedFrame, or - // m_focusedFrame might be changed by blur/focus event handlers. - if (m_focusedFrame->view()) { - m_focusedFrame->selection().setFocused(focused); - dispatchEventsOnWindowAndFocusedNode(m_focusedFrame->document(), focused); - } } Node* FocusController::findFocusableNodeDecendingDownIntoFrameDocument(FocusType type, Node* node) diff --git a/sky/engine/core/page/Page.cpp b/sky/engine/core/page/Page.cpp index e2af1fc41f3bd..14c2dd39ae55f 100644 --- a/sky/engine/core/page/Page.cpp +++ b/sky/engine/core/page/Page.cpp @@ -26,8 +26,6 @@ #include "sky/engine/core/editing/Caret.h" #include "sky/engine/core/editing/UndoStack.h" #include "sky/engine/core/events/Event.h" -#include "sky/engine/core/frame/DOMTimer.h" -#include "sky/engine/core/frame/FrameConsole.h" #include "sky/engine/core/frame/FrameHost.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalDOMWindow.h" @@ -35,7 +33,6 @@ #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/page/ChromeClient.h" #include "sky/engine/core/page/FocusController.h" -#include "sky/engine/core/page/PageLifecycleNotifier.h" #include "sky/engine/core/rendering/RenderView.h" #include "sky/engine/platform/geometry/FloatRect.h" #include "sky/engine/public/platform/WebScreenInfo.h" @@ -70,7 +67,6 @@ Page::Page(PageClients& pageClients, ServiceProvider* services) , m_editorClient(pageClients.editorClient) , m_spellCheckerClient(pageClients.spellCheckerClient) , m_deviceScaleFactor(1) - , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval()) #if ENABLE(ASSERT) , m_isPainting(false) #endif @@ -140,22 +136,6 @@ void Page::setDeviceScaleFactor(float scaleFactor) mainFrame()->deviceOrPageScaleFactorChanged(); } -void Page::setTimerAlignmentInterval(double interval) -{ - if (interval == m_timerAlignmentInterval) - return; - - m_timerAlignmentInterval = interval; - LocalFrame* frame = mainFrame(); - if (frame->document()) - frame->document()->didChangeTimerAlignmentInterval(); -} - -double Page::timerAlignmentInterval() const -{ - return m_timerAlignmentInterval; -} - void Page::addMultisamplingChangedObserver(MultisamplingChangedObserver* observer) { m_multisamplingChangedObservers.add(observer); @@ -201,22 +181,7 @@ void Page::settingsChanged(SettingsDelegate::ChangeType changeType) void Page::didCommitLoad(LocalFrame* frame) { - lifecycleNotifier().notifyDidCommitLoad(frame); -} - -void Page::acceptLanguagesChanged() -{ - mainFrame()->domWindow()->acceptLanguagesChanged(); -} - -PageLifecycleNotifier& Page::lifecycleNotifier() -{ - return static_cast(LifecycleContext::lifecycleNotifier()); -} - -PassOwnPtr > Page::createLifecycleNotifier() -{ - return PageLifecycleNotifier::create(this); + ASSERT_NOT_REACHED(); } void Page::willBeDestroyed() diff --git a/sky/engine/core/page/Page.h b/sky/engine/core/page/Page.h index 8dcca45385249..48f1c12ba2229 100644 --- a/sky/engine/core/page/Page.h +++ b/sky/engine/core/page/Page.h @@ -27,7 +27,6 @@ #include "sky/engine/core/inspector/ConsoleAPITypes.h" #include "sky/engine/core/page/FocusType.h" #include "sky/engine/platform/HostWindow.h" -#include "sky/engine/platform/LifecycleContext.h" #include "sky/engine/platform/Supplementable.h" #include "sky/engine/platform/geometry/LayoutRect.h" #include "sky/engine/platform/geometry/Region.h" @@ -51,7 +50,6 @@ class FrameHost; class IntRect; class LocalFrame; class Node; -class PageLifecycleNotifier; class Range; class RenderBox; class RenderObject; @@ -65,7 +63,7 @@ typedef uint64_t LinkHash; float deviceScaleFactor(LocalFrame*); -class Page final : public Supplementable, public LifecycleContext, public SettingsDelegate, public HostWindow { +class Page final : public Supplementable, public SettingsDelegate, public HostWindow { WTF_MAKE_NONCOPYABLE(Page); friend class Settings; public: @@ -112,8 +110,6 @@ class Page final : public Supplementable, public LifecycleContext, p bool isPainting() const { return m_isPainting; } #endif - double timerAlignmentInterval() const; - class MultisamplingChangedObserver { public: virtual void multisamplingChanged(bool) = 0; @@ -124,10 +120,6 @@ class Page final : public Supplementable, public LifecycleContext, p void didCommitLoad(LocalFrame*); - void acceptLanguagesChanged(); - - PassOwnPtr > createLifecycleNotifier(); - void willBeDestroyed(); // HostWindow methods. @@ -152,12 +144,8 @@ class Page final : public Supplementable, public LifecycleContext, p void* webView() const; private: - PageLifecycleNotifier& lifecycleNotifier(); - void initGroup(); - void setTimerAlignmentInterval(double); - void setNeedsLayoutInAllFrames(); // SettingsDelegate overrides. diff --git a/sky/engine/core/page/PageLifecycleNotifier.cpp b/sky/engine/core/page/PageLifecycleNotifier.cpp deleted file mode 100644 index b85ff7fd971ae..0000000000000 --- a/sky/engine/core/page/PageLifecycleNotifier.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "sky/engine/core/page/PageLifecycleNotifier.h" - -namespace blink { - -PageLifecycleNotifier::PageLifecycleNotifier(Page* context) - : LifecycleNotifier(context) -{ -} - -void PageLifecycleNotifier::addObserver(PageLifecycleNotifier::Observer* observer) -{ - if (observer->observerType() == Observer::PageLifecycleObserverType) { - RELEASE_ASSERT(m_iterating != IteratingOverPageObservers); - m_pageObservers.add(static_cast(observer)); - } - - LifecycleNotifier::addObserver(observer); -} - -void PageLifecycleNotifier::removeObserver(PageLifecycleNotifier::Observer* observer) -{ - if (observer->observerType() == Observer::PageLifecycleObserverType) { - RELEASE_ASSERT(m_iterating != IteratingOverPageObservers); - m_pageObservers.remove(static_cast(observer)); - } - - LifecycleNotifier::removeObserver(observer); -} - -} // namespace blink diff --git a/sky/engine/core/page/PageLifecycleNotifier.h b/sky/engine/core/page/PageLifecycleNotifier.h deleted file mode 100644 index 382dcb9c6e92f..0000000000000 --- a/sky/engine/core/page/PageLifecycleNotifier.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_PAGE_PAGELIFECYCLENOTIFIER_H_ -#define SKY_ENGINE_CORE_PAGE_PAGELIFECYCLENOTIFIER_H_ - -#include "sky/engine/core/page/PageLifecycleObserver.h" -#include "sky/engine/platform/LifecycleNotifier.h" -#include "sky/engine/wtf/PassOwnPtr.h" -#include "sky/engine/wtf/TemporaryChange.h" - -namespace blink { - -class Page; -class LocalFrame; - -class PageLifecycleNotifier final : public LifecycleNotifier { -public: - static PassOwnPtr create(Page*); - - void notifyPageVisibilityChanged(); - void notifyDidCommitLoad(LocalFrame*); - - virtual void addObserver(Observer*) override; - virtual void removeObserver(Observer*) override; - -private: - explicit PageLifecycleNotifier(Page*); - - typedef HashSet PageObserverSet; - PageObserverSet m_pageObservers; -}; - -inline PassOwnPtr PageLifecycleNotifier::create(Page* context) -{ - return adoptPtr(new PageLifecycleNotifier(context)); -} - -inline void PageLifecycleNotifier::notifyPageVisibilityChanged() -{ - TemporaryChange scope(this->m_iterating, IteratingOverPageObservers); - for (PageObserverSet::iterator it = m_pageObservers.begin(); it != m_pageObservers.end(); ++it) - (*it)->pageVisibilityChanged(); -} - -inline void PageLifecycleNotifier::notifyDidCommitLoad(LocalFrame* frame) -{ - TemporaryChange scope(this->m_iterating, IteratingOverPageObservers); - for (PageObserverSet::iterator it = m_pageObservers.begin(); it != m_pageObservers.end(); ++it) - (*it)->didCommitLoad(frame); -} - -} // namespace blink - -#endif // SKY_ENGINE_CORE_PAGE_PAGELIFECYCLENOTIFIER_H_ diff --git a/sky/engine/core/page/PageLifecycleObserver.cpp b/sky/engine/core/page/PageLifecycleObserver.cpp deleted file mode 100644 index 679ee133e8779..0000000000000 --- a/sky/engine/core/page/PageLifecycleObserver.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "sky/engine/core/page/PageLifecycleObserver.h" - -#include "sky/engine/core/page/Page.h" - -namespace blink { - -template<> void observerContext(Page* context, LifecycleObserver* observer) -{ - context->wasObservedBy(observer); -} - -template<> void unobserverContext(Page* context, LifecycleObserver* observer) -{ - context->wasUnobservedBy(observer); -} - -PageLifecycleObserver::PageLifecycleObserver(Page* page) - : LifecycleObserver(page, PageLifecycleObserverType) -{ -} - -PageLifecycleObserver::~PageLifecycleObserver() -{ -} - -Page* PageLifecycleObserver::page() const -{ - return static_cast(lifecycleContext()); -} - -} // namespace blink diff --git a/sky/engine/core/page/PageLifecycleObserver.h b/sky/engine/core/page/PageLifecycleObserver.h deleted file mode 100644 index 996cc53a40831..0000000000000 --- a/sky/engine/core/page/PageLifecycleObserver.h +++ /dev/null @@ -1,53 +0,0 @@ - -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_PAGE_PAGELIFECYCLEOBSERVER_H_ -#define SKY_ENGINE_CORE_PAGE_PAGELIFECYCLEOBSERVER_H_ - -#include "sky/engine/platform/LifecycleObserver.h" - -namespace blink { - -class LocalFrame; -class Page; - -template<> void observerContext(Page*, LifecycleObserver*); -template<> void unobserverContext(Page*, LifecycleObserver*); - -class PageLifecycleObserver : public LifecycleObserver { -public: - explicit PageLifecycleObserver(Page*); - virtual ~PageLifecycleObserver(); - - Page* page() const; - - virtual void pageVisibilityChanged() { } - virtual void didCommitLoad(LocalFrame*) { } -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_PAGE_PAGELIFECYCLEOBSERVER_H_ diff --git a/sky/engine/core/painting/Canvas.h b/sky/engine/core/painting/Canvas.h index ae1150914ed30..eacb81d5182b7 100644 --- a/sky/engine/core/painting/Canvas.h +++ b/sky/engine/core/painting/Canvas.h @@ -35,6 +35,7 @@ class Canvas : public RefCounted, public DartWrappable { return adoptRef(new Canvas(skCanvas)); } + // TODO(ianh): fix crashes here https://github.com/domokit/mojo/issues/326 static PassRefPtr create(PictureRecorder* recorder, Rect& bounds, ExceptionState& es) { diff --git a/sky/engine/core/rendering/RenderBox.cpp b/sky/engine/core/rendering/RenderBox.cpp index e366102d1d940..c6c54828b2fa4 100644 --- a/sky/engine/core/rendering/RenderBox.cpp +++ b/sky/engine/core/rendering/RenderBox.cpp @@ -34,7 +34,6 @@ #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/html/HTMLElement.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/HitTestResult.h" #include "sky/engine/core/rendering/HitTestingTransformState.h" diff --git a/sky/engine/core/rendering/RenderObject.cpp b/sky/engine/core/rendering/RenderObject.cpp index 9112555813130..17d2c48298a44 100644 --- a/sky/engine/core/rendering/RenderObject.cpp +++ b/sky/engine/core/rendering/RenderObject.cpp @@ -39,7 +39,6 @@ #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/html/HTMLElement.h" -#include "sky/engine/core/page/EventHandler.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/HitTestResult.h" #include "sky/engine/core/rendering/RenderFlexibleBox.h" @@ -1851,7 +1850,7 @@ bool RenderObject::nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const bool RenderObject::isAllowedToModifyRenderTreeStructure(Document& document) { - return document.lifecycle().stateAllowsRenderTreeMutations(); + return true; } } // namespace blink diff --git a/sky/engine/core/rendering/RenderObject.h b/sky/engine/core/rendering/RenderObject.h index 14ca33720330f..599cefd451296 100644 --- a/sky/engine/core/rendering/RenderObject.h +++ b/sky/engine/core/rendering/RenderObject.h @@ -27,7 +27,6 @@ #define SKY_ENGINE_CORE_RENDERING_RENDEROBJECT_H_ #include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/DocumentLifecycle.h" #include "sky/engine/core/dom/Element.h" #include "sky/engine/core/editing/TextAffinity.h" #include "sky/engine/core/html/HTMLElement.h" @@ -777,7 +776,7 @@ DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(RenderObject) inline bool RenderObject::documentBeingDestroyed() const { - return document().lifecycle().state() >= DocumentLifecycle::Stopping; + return !document().isActive(); } // setNeedsLayout() won't cause full paint invalidations as diff --git a/sky/engine/core/script/dart_controller.cc b/sky/engine/core/script/dart_controller.cc index cf12e38f7d305..045d09656bab8 100644 --- a/sky/engine/core/script/dart_controller.cc +++ b/sky/engine/core/script/dart_controller.cc @@ -144,9 +144,6 @@ void DartController::CreateIsolateFor(PassOwnPtr state) { builtin_sky_ = adoptPtr(new BuiltinSky(dart_state())); dart_state()->class_library().set_provider(builtin_sky_.get()); - if (dart_state()->document()) - builtin_sky_->InstallWindow(dart_state()); - EnsureHandleWatcherStarted(); } Dart_ExitIsolate(); diff --git a/sky/engine/core/script/dom_dart_state.cc b/sky/engine/core/script/dom_dart_state.cc index c96c30add4175..fa0b2472dc2a1 100644 --- a/sky/engine/core/script/dom_dart_state.cc +++ b/sky/engine/core/script/dom_dart_state.cc @@ -9,8 +9,8 @@ namespace blink { -DOMDartState::DOMDartState(Document* document, const String& url) - : document_(document), url_(url) { +DOMDartState::DOMDartState(const String& url) + : url_(url) { } DOMDartState::~DOMDartState() { @@ -20,6 +20,10 @@ DOMDartState::~DOMDartState() { weak_factory_.InvalidateWeakPtrs(); } +DOMDartState* DOMDartState::Current() { + return static_cast(DartState::Current()); +} + void DOMDartState::DidSetIsolate() { Scope dart_scope(this); x_handle_.Set(this, ToDart("x")); @@ -32,22 +36,4 @@ void DOMDartState::DidSetIsolate() { color_class_.Set(this, Dart_GetType(sky_library, ToDart("Color"), 0, 0)); } -DOMDartState* DOMDartState::Current() { - return static_cast(DartState::Current()); -} - -Document* DOMDartState::CurrentDocument() { - return Current()->document_.get(); -} - -LocalFrame* DOMDartState::CurrentFrame() { - DCHECK(Current()->document_); - return Current()->document_->frame(); -} - -LocalDOMWindow* DOMDartState::CurrentWindow() { - DCHECK(Current()->document_); - return Current()->document_->domWindow(); -} - } // namespace blink diff --git a/sky/engine/core/script/dom_dart_state.h b/sky/engine/core/script/dom_dart_state.h index 3aaf9a797a26a..75574c21ab721 100644 --- a/sky/engine/core/script/dom_dart_state.h +++ b/sky/engine/core/script/dom_dart_state.h @@ -6,8 +6,8 @@ #define SKY_ENGINE_CORE_SCRIPT_DOM_DART_STATE_H_ #include "dart/runtime/include/dart_api.h" -#include "sky/engine/tonic/dart_state.h" #include "sky/engine/core/dom/Document.h" +#include "sky/engine/tonic/dart_state.h" #include "sky/engine/wtf/RefPtr.h" namespace blink { @@ -16,20 +16,14 @@ class LocalDOMWindow; class DOMDartState : public DartState { public: - explicit DOMDartState(Document* document, const String& url); + explicit DOMDartState(const String& url); ~DOMDartState() override; virtual void DidSetIsolate(); - static DOMDartState* Current(); - - static Document* CurrentDocument(); - static LocalFrame* CurrentFrame(); - static LocalDOMWindow* CurrentWindow(); - const String& url() const { return url_; } - Document* document() const { return document_.get(); } + static DOMDartState* Current(); // Cached handles to strings used in Dart/C++ conversions. Dart_Handle x_handle() { return x_handle_.value(); } @@ -40,7 +34,6 @@ class DOMDartState : public DartState { Dart_Handle color_class() { return color_class_.value(); } private: - RefPtr document_; String url_; DartPersistentValue x_handle_; diff --git a/sky/engine/core/testing/NullExecutionContext.cpp b/sky/engine/core/testing/NullExecutionContext.cpp deleted file mode 100644 index 4435300f6c2e1..0000000000000 --- a/sky/engine/core/testing/NullExecutionContext.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 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/testing/NullExecutionContext.h" - -#include "sky/engine/core/events/Event.h" - -namespace blink { - -namespace { - -class NullEventQueue final : public EventQueue { -public: - NullEventQueue() { } - virtual ~NullEventQueue() { } - virtual bool enqueueEvent(PassRefPtr) override { return true; } - virtual bool cancelEvent(Event*) override { return true; } - virtual void close() override { } -}; - -} // namespace - -NullExecutionContext::NullExecutionContext() - : m_queue(adoptPtr(new NullEventQueue())) -{ -} - -} // namespace blink diff --git a/sky/engine/core/testing/NullExecutionContext.h b/sky/engine/core/testing/NullExecutionContext.h deleted file mode 100644 index 30b6e3bd28431..0000000000000 --- a/sky/engine/core/testing/NullExecutionContext.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 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. - -#ifndef SKY_ENGINE_CORE_TESTING_NULLEXECUTIONCONTEXT_H_ -#define SKY_ENGINE_CORE_TESTING_NULLEXECUTIONCONTEXT_H_ - -#include "sky/engine/core/dom/ExecutionContext.h" -#include "sky/engine/core/events/EventQueue.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/platform/weborigin/KURL.h" -#include "sky/engine/wtf/RefCounted.h" - -namespace blink { - -class NullExecutionContext final : public RefCounted, public ExecutionContext { -public: - NullExecutionContext(); - - virtual EventQueue* eventQueue() const override { return m_queue.get(); } - - virtual void reportBlockedScriptExecutionToInspector(const String& directiveText) override { } - -#if !ENABLE(OILPAN) - using RefCounted::ref; - using RefCounted::deref; - - virtual void refExecutionContext() override { ref(); } - virtual void derefExecutionContext() override { deref(); } -#endif - -protected: - virtual const KURL& virtualURL() const override { return m_dummyURL; } - virtual KURL virtualCompleteURL(const String&) const override { return m_dummyURL; } - -private: - OwnPtr m_queue; - - KURL m_dummyURL; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_TESTING_NULLEXECUTIONCONTEXT_H_ diff --git a/sky/engine/platform/BUILD.gn b/sky/engine/platform/BUILD.gn index 8b49d73f2ce77..c1fcffcb6fe3f 100644 --- a/sky/engine/platform/BUILD.gn +++ b/sky/engine/platform/BUILD.gn @@ -120,9 +120,6 @@ source_set("platform") { "LengthFunctions.h", "LengthPoint.h", "LengthSize.h", - "LifecycleContext.h", - "LifecycleNotifier.h", - "LifecycleObserver.h", "Logging.cpp", "Logging.h", "MIMETypeRegistry.cpp", @@ -598,7 +595,6 @@ test("platform_unittests") { "ClockTest.cpp", "DecimalTest.cpp", "LayoutUnitTest.cpp", - "LifecycleContextTest.cpp", "PurgeableVectorTest.cpp", "SharedBufferTest.cpp", "TestingPlatformSupport.cpp", diff --git a/sky/engine/platform/LifecycleContext.h b/sky/engine/platform/LifecycleContext.h deleted file mode 100644 index 92ebedf2ec5d2..0000000000000 --- a/sky/engine/platform/LifecycleContext.h +++ /dev/null @@ -1,95 +0,0 @@ - -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_PLATFORM_LIFECYCLECONTEXT_H_ -#define SKY_ENGINE_PLATFORM_LIFECYCLECONTEXT_H_ - -#include "sky/engine/platform/LifecycleNotifier.h" -#include "sky/engine/platform/LifecycleObserver.h" -#include "sky/engine/wtf/HashSet.h" -#include "sky/engine/wtf/OwnPtr.h" -#include "sky/engine/wtf/PassOwnPtr.h" - -namespace blink { - -template -class LifecycleContext { -public: - typedef LifecycleNotifier Notifier; - typedef LifecycleObserver Observer; - - LifecycleContext() { } - virtual ~LifecycleContext() { } - - virtual bool isContextThread() const { return true; } - - // Called from the constructor of observers. - void wasObservedBy(Observer*); - - // Called from the destructor of observers. - void wasUnobservedBy(Observer*); - -protected: - Notifier& lifecycleNotifier(); - -private: - PassOwnPtr createLifecycleNotifier(); - - OwnPtr m_lifecycleNotifier; -}; - -template -inline void LifecycleContext::wasObservedBy(typename LifecycleContext::Observer* observer) -{ - ASSERT(isContextThread()); - lifecycleNotifier().addObserver(observer); -} - -template -inline void LifecycleContext::wasUnobservedBy(typename LifecycleContext::Observer* observer) -{ - ASSERT(isContextThread()); - lifecycleNotifier().removeObserver(observer); -} - -template -inline typename LifecycleContext::Notifier& LifecycleContext::lifecycleNotifier() -{ - if (!m_lifecycleNotifier) - m_lifecycleNotifier = static_cast(this)->createLifecycleNotifier(); - return *m_lifecycleNotifier; -} - -template -inline PassOwnPtr::Notifier> LifecycleContext::createLifecycleNotifier() -{ - return LifecycleContext::Notifier::create(static_cast(this)); -} - -} // namespace blink - -#endif // SKY_ENGINE_PLATFORM_LIFECYCLECONTEXT_H_ diff --git a/sky/engine/platform/LifecycleContextTest.cpp b/sky/engine/platform/LifecycleContextTest.cpp deleted file mode 100644 index ed1f8784794f9..0000000000000 --- a/sky/engine/platform/LifecycleContextTest.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#include "sky/engine/platform/LifecycleContext.h" - -#include -#include "sky/engine/platform/LifecycleNotifier.h" - -using namespace blink; - -namespace { -class DummyContext : public LifecycleContext { -}; -} - -namespace blink { - -template<> void observerContext(DummyContext* context, LifecycleObserver* observer) -{ - context->wasObservedBy(observer); -} - -template<> void unobserverContext(DummyContext* context, LifecycleObserver* observer) -{ - context->wasUnobservedBy(observer); -} - -} - -namespace { - - -class TestingObserver : public LifecycleObserver { -public: - TestingObserver(DummyContext* context) - : LifecycleObserver(context) - , m_contextDestroyedCalled(false) - { } - - virtual void contextDestroyed() override - { - LifecycleObserver::contextDestroyed(); - m_contextDestroyedCalled = true; - } - - bool m_contextDestroyedCalled; - - void unobserve() { observeContext(0); } -}; - -TEST(LifecycleContextTest, shouldObserveContextDestroyed) -{ - OwnPtr context = adoptPtr(new DummyContext()); - OwnPtr observer = adoptPtr(new TestingObserver(context.get())); - - EXPECT_EQ(observer->lifecycleContext(), context.get()); - EXPECT_FALSE(observer->m_contextDestroyedCalled); - - context.clear(); - EXPECT_EQ(observer->lifecycleContext(), static_cast(0)); - EXPECT_TRUE(observer->m_contextDestroyedCalled); -} - -TEST(LifecycleContextTest, shouldNotObserveContextDestroyedIfUnobserve) -{ - OwnPtr context = adoptPtr(new DummyContext()); - OwnPtr observer = adoptPtr(new TestingObserver(context.get())); - - observer->unobserve(); - context.clear(); - EXPECT_EQ(observer->lifecycleContext(), static_cast(0)); - EXPECT_FALSE(observer->m_contextDestroyedCalled); -} - - -} diff --git a/sky/engine/platform/LifecycleNotifier.h b/sky/engine/platform/LifecycleNotifier.h deleted file mode 100644 index c38bb0f50d4b3..0000000000000 --- a/sky/engine/platform/LifecycleNotifier.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2013 Google Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#ifndef SKY_ENGINE_PLATFORM_LIFECYCLENOTIFIER_H_ -#define SKY_ENGINE_PLATFORM_LIFECYCLENOTIFIER_H_ - -#include "sky/engine/platform/LifecycleObserver.h" -#include "sky/engine/wtf/HashSet.h" -#include "sky/engine/wtf/PassOwnPtr.h" -#include "sky/engine/wtf/TemporaryChange.h" - -namespace blink { - -template -class LifecycleNotifier { -public: - typedef LifecycleObserver Observer; - typedef T Context; - - static PassOwnPtr create(Context* context) - { - return adoptPtr(new LifecycleNotifier(context)); - } - - - virtual ~LifecycleNotifier(); - - - // FIXME: this won't need to be virtual anymore. - virtual void addObserver(Observer*); - virtual void removeObserver(Observer*); - - bool isIteratingOverObservers() const { return m_iterating != IteratingNone; } - -protected: - explicit LifecycleNotifier(Context* context) - : m_iterating(IteratingNone) - , m_context(context) - { - } - - Context* context() const { return m_context; } - - enum IterationType { - IteratingNone, - IteratingOverAll, - IteratingOverActiveDOMObjects, - IteratingOverContextObservers, - IteratingOverDocumentObservers, - IteratingOverPageObservers, - IteratingOverDOMWindowObservers - }; - - IterationType m_iterating; - -private: - typedef HashSet ObserverSet; - - ObserverSet m_observers; - Context* m_context; -}; - -template -inline LifecycleNotifier::~LifecycleNotifier() -{ - TemporaryChange scope(this->m_iterating, IteratingOverAll); - for (typename ObserverSet::iterator it = m_observers.begin(); it != m_observers.end(); it = m_observers.begin()) { - Observer* observer = *it; - m_observers.remove(observer); - ASSERT(observer->lifecycleContext() == m_context); - observer->contextDestroyed(); - } -} - -template -inline void LifecycleNotifier::addObserver(typename LifecycleNotifier::Observer* observer) -{ - RELEASE_ASSERT(m_iterating != IteratingOverAll); - m_observers.add(observer); -} - -template -inline void LifecycleNotifier::removeObserver(typename LifecycleNotifier::Observer* observer) -{ - RELEASE_ASSERT(m_iterating != IteratingOverAll); - m_observers.remove(observer); -} - - - -} // namespace blink - -#endif // SKY_ENGINE_PLATFORM_LIFECYCLENOTIFIER_H_ diff --git a/sky/engine/platform/LifecycleObserver.h b/sky/engine/platform/LifecycleObserver.h deleted file mode 100644 index ffbf7d9ba66f4..0000000000000 --- a/sky/engine/platform/LifecycleObserver.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef SKY_ENGINE_PLATFORM_LIFECYCLEOBSERVER_H_ -#define SKY_ENGINE_PLATFORM_LIFECYCLEOBSERVER_H_ - -#include "sky/engine/wtf/Assertions.h" - -namespace blink { - -template -class LifecycleObserver { -public: - typedef T Context; - - enum Type { - ActiveDOMObjectType, - DocumentLifecycleObserverType, - GenericType, - PageLifecycleObserverType, - DOMWindowLifecycleObserverType - }; - - explicit LifecycleObserver(Context* context, Type type = GenericType) - : m_lifecycleContext(0) - , m_observerType(type) - { - observeContext(context); - } - - virtual ~LifecycleObserver() - { - observeContext(0); - } - - virtual void contextDestroyed() { m_lifecycleContext = 0; } - - - Context* lifecycleContext() const { return m_lifecycleContext; } - Type observerType() const { return m_observerType; } - -protected: - void observeContext(Context*); - - Context* m_lifecycleContext; - Type m_observerType; -}; - -// -// These functions should be specialized for each LifecycleObserver instances. -// -template void observerContext(T*, LifecycleObserver*) { ASSERT_NOT_REACHED(); } -template void unobserverContext(T*, LifecycleObserver*) { ASSERT_NOT_REACHED(); } - - -template -inline void LifecycleObserver::observeContext(typename LifecycleObserver::Context* context) -{ - if (m_lifecycleContext) - unobserverContext(m_lifecycleContext, this); - - m_lifecycleContext = context; - - if (m_lifecycleContext) - observerContext(m_lifecycleContext, this); -} - -} // namespace blink - -#endif // SKY_ENGINE_PLATFORM_LIFECYCLEOBSERVER_H_ diff --git a/sky/engine/public/sky/sky_view.cc b/sky/engine/public/sky/sky_view.cc index ace47b268fcf9..2c75a32a20dca 100644 --- a/sky/engine/public/sky/sky_view.cc +++ b/sky/engine/public/sky/sky_view.cc @@ -88,7 +88,7 @@ void SkyView::CreateView(const String& name) { view_->setDisplayMetrics(display_metrics_); dart_controller_ = adoptPtr(new DartController); - dart_controller_->CreateIsolateFor(adoptPtr(new DOMDartState(nullptr, name))); + dart_controller_->CreateIsolateFor(adoptPtr(new DOMDartState(name))); dart_controller_->InstallView(view_.get()); Dart_Isolate isolate = dart_controller_->dart_state()->isolate(); diff --git a/sky/sdk/lib/widgets/widget.dart b/sky/sdk/lib/widgets/widget.dart index 81b7ff5c7727c..637f39084f0db 100644 --- a/sky/sdk/lib/widgets/widget.dart +++ b/sky/sdk/lib/widgets/widget.dart @@ -334,7 +334,7 @@ class Listener extends TagNode { PointerEventListener onPointerDown, PointerEventListener onPointerMove, PointerEventListener onPointerUp, - Map custom + Map custom }) : listeners = _createListeners( onWheel: onWheel, onGestureFlingCancel: onGestureFlingCancel, @@ -351,9 +351,9 @@ class Listener extends TagNode { ), super(child, key: key); - final Map listeners; + final Map listeners; - static Map _createListeners({ + static Map _createListeners({ EventListener onWheel, GestureEventListener onGestureFlingCancel, GestureEventListener onGestureFlingStart, @@ -365,11 +365,11 @@ class Listener extends TagNode { PointerEventListener onPointerDown, PointerEventListener onPointerMove, PointerEventListener onPointerUp, - Map custom + Map custom }) { var listeners = custom != null ? - new HashMap.from(custom) : - new HashMap(); + new HashMap.from(custom) : + new HashMap(); if (onWheel != null) listeners['wheel'] = onWheel; @@ -398,7 +398,7 @@ class Listener extends TagNode { } void _handleEvent(sky.Event e) { - sky.EventListener listener = listeners[e.type]; + EventListener listener = listeners[e.type]; if (listener != null) { listener(e); }