Changeset 133016 in webkit
- Timestamp:
- Oct 31, 2012 5:55:54 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r132960 r133016 1711 1711 page/ContextMenuController.cpp 1712 1712 page/Crypto.cpp 1713 page/DeviceController.cpp 1713 1714 page/DiagnosticLoggingKeys.cpp 1714 1715 page/DOMSecurityPolicy.cpp -
trunk/Source/WebCore/ChangeLog
r133015 r133016 1 2012-10-31 Kihong Kwon <kihong.kwon@samsung.com> 2 3 Add DeviceController base-class to remove duplication of DeviceXXXControler 4 https://bugs.webkit.org/show_bug.cgi?id=96894 5 6 Reviewed by Hajime Morita. 7 8 Add DeviceController which is extracted from DeviceOrientationController to remove duplication. 9 And soon-to-be-added DeviceMotionController and ProximityController. 10 11 Covered by existing tests. 12 13 * CMakeLists.txt: 14 * GNUmakefile.list.am: 15 * Target.pri: 16 * WebCore.gypi: 17 * WebCore.vcproj/WebCore.vcproj: 18 * WebCore.xcodeproj/project.pbxproj: 19 * dom/DeviceOrientationClient.h: 20 * dom/DeviceOrientationController.cpp: 21 Remove member functions to move to DeviceController. 22 - addListener(), removeListener(), removeAllListeners(), isActive() 23 (WebCore::DeviceOrientationController::DeviceOrientationController): 24 (WebCore::DeviceOrientationController::didChangeDeviceOrientation): 25 (WebCore::DeviceOrientationController::client): 26 (WebCore::DeviceOrientationController::hasLastData): 27 (WebCore::DeviceOrientationController::getLastEvent): 28 (WebCore::DeviceOrientationController::from): 29 (WebCore): 30 * dom/DeviceOrientationController.h: 31 (WebCore): 32 (WebCore::DeviceOrientationController::~DeviceOrientationController): 33 (DeviceOrientationController): 34 * dom/Document.cpp: 35 Remove suspendEventsForAllListeners() and resumeEventsForAllListeners() function calls. 36 These calls can be made by checking activeDOMObjectsAreSuspended() and activeDOMObjectsAreStopped() before dispatchEvent. 37 (WebCore::Document::suspendActiveDOMObjects): 38 (WebCore::Document::resumeActiveDOMObjects): 39 * loader/EmptyClients.h: 40 (EmptyDeviceClient): 41 (WebCore::EmptyDeviceClient::startUpdating): 42 (WebCore::EmptyDeviceClient::stopUpdating): 43 (WebCore): 44 * page/DOMWindow.cpp: 45 (WebCore::DOMWindow::addEventListener): 46 (WebCore::DOMWindow::removeEventListener): 47 (WebCore::DOMWindow::removeAllEventListeners): 48 * page/DeviceClient.h: Added. 49 (WebCore): 50 (DeviceClient): 51 (WebCore::DeviceClient::~DeviceClient): 52 * page/DeviceController.cpp: Added. 53 DeviceController has extracted functions from DeviceOrientationController and DeviceMotionController. 54 - addDeviceEventListener(), removeDeviceEventlistener(), removeAllDeviceEventListeners(), dispatchDeviceEvent() 55 All kind of device event controller which has DeviceClient can be inherited from DeviceController. 56 (WebCore): 57 (WebCore::DeviceController::DeviceController): 58 (WebCore::DeviceController::addDeviceEventListener): 59 (WebCore::DeviceController::removeDeviceEventListener): 60 (WebCore::DeviceController::removeAllDeviceEventListeners): 61 (WebCore::DeviceController::dispatchDeviceEvent): 62 (WebCore::DeviceController::fireDeviceEvent): 63 * page/DeviceController.h: Added. 64 (WebCore): 65 (DeviceController): 66 (WebCore::DeviceController::~DeviceController): 67 (WebCore::DeviceController::isActive): 68 (WebCore::DeviceController::client): 69 (WebCore::DeviceController::hasLastData): 70 (WebCore::DeviceController::getLastEvent): 71 1 72 2012-10-31 Pavel Feldman <pfeldman@chromium.org> 2 73 -
trunk/Source/WebCore/GNUmakefile.list.am
r132960 r133016 4008 4008 Source/WebCore/page/Crypto.cpp \ 4009 4009 Source/WebCore/page/Crypto.h \ 4010 Source/WebCore/page/DeviceClient.h \ 4011 Source/WebCore/page/DeviceController.cpp \ 4012 Source/WebCore/page/DeviceController.h \ 4010 4013 Source/WebCore/page/DiagnosticLoggingKeys.cpp \ 4011 4014 Source/WebCore/page/DiagnosticLoggingKeys.h \ -
trunk/Source/WebCore/Target.pri
r132960 r133016 872 872 page/ContextMenuController.cpp \ 873 873 page/Crypto.cpp \ 874 page/DeviceController.cpp \ 874 875 page/DiagnosticLoggingKeys.cpp \ 875 876 page/DOMSelection.cpp \ … … 1998 1999 page/ContextMenuProvider.h \ 1999 2000 page/Coordinates.h \ 2001 page/DeviceClient.h \ 2002 page/DeviceController.h \ 2000 2003 page/DiagnosticLoggingKeys.h \ 2001 2004 page/DOMSelection.h \ -
trunk/Source/WebCore/WebCore.gypi
r132960 r133016 3114 3114 'page/Crypto.cpp', 3115 3115 'page/Crypto.h', 3116 'page/DeviceClient.h', 3117 'page/DeviceController.cpp', 3118 'page/DeviceController.h', 3116 3119 'page/DiagnosticLoggingKeys.cpp', 3117 3120 'page/DiagnosticLoggingKeys.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r132960 r133016 26964 26964 </File> 26965 26965 <File 26966 RelativePath="..\page\DeviceClient.h" 26967 > 26968 </File> 26969 <File 26970 RelativePath="..\page\DeviceController.cpp" 26971 > 26972 </File> 26973 <File 26974 RelativePath="..\page\DeviceController.h" 26975 > 26976 </File> 26977 <File 26966 26978 RelativePath="..\page\DiagnosticLoggingKeys.cpp" 26967 26979 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r132992 r133016 5892 5892 CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; }; 5893 5893 CAE9F910146441F000C245B1 /* CSSVariableValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B1 /* CSSVariableValue.h */; }; 5894 CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51015F613060048CDD6 /* DeviceClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5895 CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CCC2B51115F613060048CDD6 /* DeviceController.cpp */; }; 5896 CCC2B51615F613060048CDD6 /* DeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51215F613060048CDD6 /* DeviceController.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5894 5897 CD127DED14F3097D00E84779 /* WebCoreFullScreenWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */; }; 5895 5898 CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 13267 13270 CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = "<group>"; }; 13268 13271 CAE9F90E146441F000C245B1 /* CSSVariableValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSVariableValue.h; sourceTree = "<group>"; }; 13272 CCC2B51015F613060048CDD6 /* DeviceClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceClient.h; sourceTree = "<group>"; }; 13273 CCC2B51115F613060048CDD6 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = "<group>"; }; 13274 CCC2B51215F613060048CDD6 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = "<group>"; }; 13269 13275 CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWindow.h; sourceTree = "<group>"; }; 13270 13276 CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWindow.mm; sourceTree = "<group>"; }; … … 15855 15861 975CA288130365F800E99AD9 /* Crypto.h */, 15856 15862 975CA289130365F800E99AD9 /* Crypto.idl */, 15863 CCC2B51015F613060048CDD6 /* DeviceClient.h */, 15864 CCC2B51115F613060048CDD6 /* DeviceController.cpp */, 15865 CCC2B51215F613060048CDD6 /* DeviceController.h */, 15857 15866 CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */, 15858 15867 CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */, … … 22778 22787 FD1660A513787C6D001FFA7B /* DenormalDisabler.h in Headers */, 22779 22788 A7C9ABF91357A3BF00F5503F /* DetailsMarkerControl.h in Headers */, 22789 CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */, 22790 CCC2B51615F613060048CDD6 /* DeviceController.h in Headers */, 22780 22791 31FB1A57120A5D0600DC02A0 /* DeviceMotionClient.h in Headers */, 22781 22792 31FB1A59120A5D0600DC02A0 /* DeviceMotionController.h in Headers */, … … 26336 26347 93309DE0099E64920056E581 /* DeleteSelectionCommand.cpp in Sources */, 26337 26348 A7C9ABF81357A3BF00F5503F /* DetailsMarkerControl.cpp in Sources */, 26349 CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */, 26338 26350 31FB1A58120A5D0600DC02A0 /* DeviceMotionController.cpp in Sources */, 26339 26351 31FB1A5A120A5D0600DC02A0 /* DeviceMotionData.cpp in Sources */, -
trunk/Source/WebCore/dom/DeviceOrientationClient.h
r121016 r133016 1 1 /* 2 2 * Copyright 2010, The Android Open Source Project 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 #define DeviceOrientationClient_h 28 29 30 #include "DeviceClient.h" 31 29 32 namespace WebCore { 30 33 … … 33 36 class Page; 34 37 35 class DeviceOrientationClient {38 class DeviceOrientationClient : public DeviceClient { 36 39 public: 37 40 virtual ~DeviceOrientationClient() {} 38 41 virtual void setController(DeviceOrientationController*) = 0; 39 virtual void startUpdating() = 0;40 virtual void stopUpdating() = 0;41 42 virtual DeviceOrientationData* lastOrientation() const = 0; 42 43 virtual void deviceOrientationControllerDestroyed() = 0; -
trunk/Source/WebCore/dom/DeviceOrientationController.cpp
r124484 r133016 1 1 /* 2 2 * Copyright 2010, The Android Open Source Project 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 35 36 36 37 DeviceOrientationController::DeviceOrientationController(Page* page, DeviceOrientationClient* client) 37 : m_client(client)38 : DeviceController(client) 38 39 , m_page(page) 39 , m_timer(this, &DeviceOrientationController::timerFired)40 40 { 41 41 ASSERT(m_client); 42 m_client->setController(this); 43 } 44 45 DeviceOrientationController::~DeviceOrientationController() 46 { 47 m_client->deviceOrientationControllerDestroyed(); 42 deviceOrientationClient()->setController(this); 48 43 } 49 44 … … 53 48 } 54 49 55 void DeviceOrientationController:: timerFired(Timer<DeviceOrientationController>* timer)50 void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientationData* orientation) 56 51 { 57 ASSERT_UNUSED(timer, timer == &m_timer); 58 ASSERT(m_client->lastOrientation()); 59 60 RefPtr<DeviceOrientationData> orientation = m_client->lastOrientation(); 61 RefPtr<DeviceOrientationEvent> event = DeviceOrientationEvent::create(eventNames().deviceorientationEvent, orientation.get()); 62 63 Vector<RefPtr<DOMWindow> > listenersVector; 64 copyToVector(m_newListeners, listenersVector); 65 m_newListeners.clear(); 66 for (size_t i = 0; i < listenersVector.size(); ++i) 67 listenersVector[i]->dispatchEvent(event); 52 dispatchDeviceEvent(DeviceOrientationEvent::create(eventNames().deviceorientationEvent, orientation)); 68 53 } 69 54 70 void DeviceOrientationController::addListener(DOMWindow* window)55 DeviceOrientationClient* DeviceOrientationController::deviceOrientationClient() 71 56 { 72 // If the client already has an orientation, we should fire an event with that 73 // orientation. The event is fired asynchronously, but without 74 // waiting for the client to get a new orientation. 75 if (m_client->lastOrientation()) { 76 m_newListeners.add(window); 77 if (!m_timer.isActive()) 78 m_timer.startOneShot(0); 79 } 80 81 // The client must not call back synchronously. 82 bool wasEmpty = m_listeners.isEmpty(); 83 m_listeners.add(window); 84 if (wasEmpty) 85 m_client->startUpdating(); 57 return static_cast<DeviceOrientationClient*>(m_client); 86 58 } 87 59 88 void DeviceOrientationController::removeListener(DOMWindow* window)60 bool DeviceOrientationController::hasLastData() 89 61 { 90 m_listeners.remove(window); 91 m_suspendedListeners.remove(window); 92 m_newListeners.remove(window); 93 if (m_listeners.isEmpty()) 94 m_client->stopUpdating(); 62 return deviceOrientationClient()->lastOrientation(); 95 63 } 96 64 97 void DeviceOrientationController::removeAllListeners(DOMWindow* window)65 PassRefPtr<Event> DeviceOrientationController::getLastEvent() 98 66 { 99 // May be called with a DOMWindow that's not a listener. 100 if (!m_listeners.contains(window)) 101 return; 102 103 m_listeners.removeAll(window); 104 m_suspendedListeners.removeAll(window); 105 m_newListeners.remove(window); 106 if (m_listeners.isEmpty()) 107 m_client->stopUpdating(); 108 } 109 110 void DeviceOrientationController::suspendEventsForAllListeners(DOMWindow* window) 111 { 112 if (!m_listeners.contains(window)) 113 return; 114 115 int count = m_listeners.count(window); 116 removeAllListeners(window); 117 while (count--) 118 m_suspendedListeners.add(window); 119 } 120 121 void DeviceOrientationController::resumeEventsForAllListeners(DOMWindow* window) 122 { 123 if (!m_suspendedListeners.contains(window)) 124 return; 125 126 int count = m_suspendedListeners.count(window); 127 m_suspendedListeners.removeAll(window); 128 while (count--) 129 addListener(window); 130 } 131 132 void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientationData* orientation) 133 { 134 orientation = InspectorInstrumentation::overrideDeviceOrientation(m_page, orientation); 135 RefPtr<DeviceOrientationEvent> event = DeviceOrientationEvent::create(eventNames().deviceorientationEvent, orientation); 136 Vector<RefPtr<DOMWindow> > listenersVector; 137 copyToVector(m_listeners, listenersVector); 138 for (size_t i = 0; i < listenersVector.size(); ++i) 139 listenersVector[i]->dispatchEvent(event); 67 return DeviceOrientationEvent::create(eventNames().deviceorientationEvent, deviceOrientationClient()->lastOrientation()); 140 68 } 141 69 … … 144 72 DEFINE_STATIC_LOCAL(AtomicString, name, ("DeviceOrientationController")); 145 73 return name; 74 } 75 76 DeviceOrientationController* DeviceOrientationController::from(Page* page) 77 { 78 return static_cast<DeviceOrientationController*>(Supplement<Page>::from(page, supplementName())); 146 79 } 147 80 -
trunk/Source/WebCore/dom/DeviceOrientationController.h
r124484 r133016 1 1 /* 2 2 * Copyright 2010, The Android Open Source Project 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 #define DeviceOrientationController_h 28 29 29 #include "DOMWindow.h" 30 #include "Page.h" 31 #include "Timer.h" 32 30 #include "DeviceController.h" 33 31 #include <wtf/HashCountedSet.h> 34 32 35 33 namespace WebCore { 36 34 35 class DeviceOrientationClient; 37 36 class DeviceOrientationData; 38 class DeviceOrientationClient;39 37 40 class DeviceOrientationController : public Supplement<Page>{38 class DeviceOrientationController : public DeviceController { 41 39 public: 42 ~DeviceOrientationController() ;40 ~DeviceOrientationController() { }; 43 41 44 42 static PassOwnPtr<DeviceOrientationController> create(Page*, DeviceOrientationClient*); 45 43 46 void addListener(DOMWindow*); 47 void removeListener(DOMWindow*); 48 void removeAllListeners(DOMWindow*); 44 void didChangeDeviceOrientation(DeviceOrientationData*); 45 DeviceOrientationClient* deviceOrientationClient(); 49 46 50 void suspendEventsForAllListeners(DOMWindow*); 51 void resumeEventsForAllListeners(DOMWindow*); 52 53 void didChangeDeviceOrientation(DeviceOrientationData*); 54 55 bool isActive() { return !m_listeners.isEmpty(); } 56 57 DeviceOrientationClient* client() const { return m_client; } 47 virtual bool hasLastData() OVERRIDE; 48 virtual PassRefPtr<Event> getLastEvent() OVERRIDE; 58 49 59 50 static const AtomicString& supplementName(); 60 static DeviceOrientationController* from(Page* page) { return static_cast<DeviceOrientationController*>(Supplement<Page>::from(page, supplementName())); }51 static DeviceOrientationController* from(Page*); 61 52 static bool isActiveAt(Page*); 62 53 63 54 private: 64 explicitDeviceOrientationController(Page*, DeviceOrientationClient*);55 DeviceOrientationController(Page*, DeviceOrientationClient*); 65 56 66 void timerFired(Timer<DeviceOrientationController>*);67 68 DeviceOrientationClient* m_client;69 57 Page* m_page; 70 typedef HashCountedSet<RefPtr<DOMWindow> > ListenersCountedSet;71 ListenersCountedSet m_listeners;72 ListenersCountedSet m_suspendedListeners;73 typedef HashSet<RefPtr<DOMWindow> > ListenersSet;74 ListenersSet m_newListeners;75 Timer<DeviceOrientationController> m_timer;76 58 }; 77 59 -
trunk/Source/WebCore/dom/Document.cpp
r132918 r133016 2182 2182 if (DeviceMotionController* controller = DeviceMotionController::from(page())) 2183 2183 controller->suspendEventsForAllListeners(domWindow()); 2184 if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))2185 controller->suspendEventsForAllListeners(domWindow());2186 2187 2184 #endif 2188 2185 } … … 2197 2194 2198 2195 if (DeviceMotionController* controller = DeviceMotionController::from(page())) 2199 controller->resumeEventsForAllListeners(domWindow());2200 if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))2201 2196 controller->resumeEventsForAllListeners(domWindow()); 2202 2197 #endif -
trunk/Source/WebCore/loader/EmptyClients.h
r132915 r133016 574 574 }; 575 575 576 class EmptyDeviceClient : public DeviceClient { 577 public: 578 virtual void startUpdating() OVERRIDE { } 579 virtual void stopUpdating() OVERRIDE { } 580 }; 581 576 582 class EmptyDeviceMotionClient : public DeviceMotionClient { 577 583 public: … … 586 592 public: 587 593 virtual void setController(DeviceOrientationController*) { } 588 virtual void startUpdating() { }589 virtual void stopUpdating() { }590 594 virtual DeviceOrientationData* lastOrientation() const { return 0; } 591 595 virtual void deviceOrientationControllerDestroyed() { } -
trunk/Source/WebCore/page/DOMWindow.cpp
r132183 r133016 1602 1602 } else if (eventType == eventNames().deviceorientationEvent && RuntimeEnabledFeatures::deviceOrientationEnabled()) { 1603 1603 if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) 1604 controller->add Listener(this);1604 controller->addDeviceEventListener(this); 1605 1605 } 1606 1606 #endif … … 1631 1631 } else if (eventType == eventNames().deviceorientationEvent) { 1632 1632 if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) 1633 controller->remove Listener(this);1633 controller->removeDeviceEventListener(this); 1634 1634 } 1635 1635 #endif … … 1688 1688 controller->removeAllListeners(this); 1689 1689 if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) 1690 controller->removeAll Listeners(this);1690 controller->removeAllDeviceEventListeners(this); 1691 1691 #endif 1692 1692 -
trunk/Source/WebKit/qt/ChangeLog
r132900 r133016 1 2012-10-31 Kihong Kwon <kihong.kwon@samsung.com> 2 3 Add DeviceController base-class to remove duplication of DeviceXXXControler 4 https://bugs.webkit.org/show_bug.cgi?id=96894 5 6 Reviewed by Hajime Morita. 7 8 Change client() to deviceOrientationClient() to get DeviceOrientationClient*. 9 10 * WebCoreSupport/DumpRenderTreeSupportQt.cpp: 11 (DumpRenderTreeSupportQt::setMockDeviceOrientation): 12 1 13 2012-10-30 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> 2 14 -
trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
r132900 r133016 714 714 #if ENABLE(DEVICE_ORIENTATION) 715 715 Page* corePage = QWebPagePrivate::core(page); 716 DeviceOrientationClientMock* mockClient = toDeviceOrientationClientMock(DeviceOrientationController::from(corePage)-> client());716 DeviceOrientationClientMock* mockClient = toDeviceOrientationClientMock(DeviceOrientationController::from(corePage)->deviceOrientationClient()); 717 717 mockClient->setOrientation(DeviceOrientationData::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma)); 718 718 #endif
Note: See TracChangeset
for help on using the changeset viewer.