Changeset 134918 in webkit
- Timestamp:
- Nov 16, 2012 2:19:41 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r134828 r134918 1707 1707 page/ContextMenuController.cpp 1708 1708 page/Crypto.cpp 1709 page/DeviceController.cpp 1709 1710 page/DiagnosticLoggingKeys.cpp 1710 1711 page/DOMSecurityPolicy.cpp -
trunk/Source/WebCore/ChangeLog
r134917 r134918 1 2012-11-16 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-11-16 Alexander Pavlov <apavlov@chromium.org> 2 73 -
trunk/Source/WebCore/GNUmakefile.list.am
r134886 r134918 3987 3987 Source/WebCore/page/Crypto.cpp \ 3988 3988 Source/WebCore/page/Crypto.h \ 3989 Source/WebCore/page/DeviceClient.h \ 3990 Source/WebCore/page/DeviceController.cpp \ 3991 Source/WebCore/page/DeviceController.h \ 3989 3992 Source/WebCore/page/DiagnosticLoggingKeys.cpp \ 3990 3993 Source/WebCore/page/DiagnosticLoggingKeys.h \ -
trunk/Source/WebCore/Target.pri
r134886 r134918 876 876 page/ContextMenuController.cpp \ 877 877 page/Crypto.cpp \ 878 page/DeviceController.cpp \ 878 879 page/DiagnosticLoggingKeys.cpp \ 879 880 page/DOMSelection.cpp \ … … 2004 2005 page/ContextMenuProvider.h \ 2005 2006 page/Coordinates.h \ 2007 page/DeviceClient.h \ 2008 page/DeviceController.h \ 2006 2009 page/DiagnosticLoggingKeys.h \ 2007 2010 page/DOMSelection.h \ -
trunk/Source/WebCore/WebCore.gypi
r134911 r134918 3084 3084 'page/Crypto.cpp', 3085 3085 'page/Crypto.h', 3086 'page/DeviceClient.h', 3087 'page/DeviceController.cpp', 3088 'page/DeviceController.h', 3086 3089 'page/DiagnosticLoggingKeys.cpp', 3087 3090 'page/DiagnosticLoggingKeys.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r134911 r134918 26851 26851 </File> 26852 26852 <File 26853 RelativePath="..\page\DeviceClient.h" 26854 > 26855 </File> 26856 <File 26857 RelativePath="..\page\DeviceController.cpp" 26858 > 26859 </File> 26860 <File 26861 RelativePath="..\page\DeviceController.h" 26862 > 26863 </File> 26864 <File 26853 26865 RelativePath="..\page\DiagnosticLoggingKeys.cpp" 26854 26866 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r134886 r134918 5888 5888 CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; }; 5889 5889 CAE9F910146441F000C245B1 /* CSSVariableValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B1 /* CSSVariableValue.h */; }; 5890 CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51015F613060048CDD6 /* DeviceClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5891 CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CCC2B51115F613060048CDD6 /* DeviceController.cpp */; }; 5892 CCC2B51615F613060048CDD6 /* DeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51215F613060048CDD6 /* DeviceController.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5890 5893 CD127DED14F3097D00E84779 /* WebCoreFullScreenWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */; }; 5891 5894 CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 13271 13274 CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = "<group>"; }; 13272 13275 CAE9F90E146441F000C245B1 /* CSSVariableValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSVariableValue.h; sourceTree = "<group>"; }; 13276 CCC2B51015F613060048CDD6 /* DeviceClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceClient.h; sourceTree = "<group>"; }; 13277 CCC2B51115F613060048CDD6 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = "<group>"; }; 13278 CCC2B51215F613060048CDD6 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = "<group>"; }; 13273 13279 CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWindow.h; sourceTree = "<group>"; }; 13274 13280 CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWindow.mm; sourceTree = "<group>"; }; … … 15859 15865 975CA288130365F800E99AD9 /* Crypto.h */, 15860 15866 975CA289130365F800E99AD9 /* Crypto.idl */, 15867 CCC2B51015F613060048CDD6 /* DeviceClient.h */, 15868 CCC2B51115F613060048CDD6 /* DeviceController.cpp */, 15869 CCC2B51215F613060048CDD6 /* DeviceController.h */, 15861 15870 CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */, 15862 15871 CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */, … … 22804 22813 FD1660A513787C6D001FFA7B /* DenormalDisabler.h in Headers */, 22805 22814 A7C9ABF91357A3BF00F5503F /* DetailsMarkerControl.h in Headers */, 22815 CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */, 22816 CCC2B51615F613060048CDD6 /* DeviceController.h in Headers */, 22806 22817 31FB1A57120A5D0600DC02A0 /* DeviceMotionClient.h in Headers */, 22807 22818 31FB1A59120A5D0600DC02A0 /* DeviceMotionController.h in Headers */, … … 26361 26372 93309DE0099E64920056E581 /* DeleteSelectionCommand.cpp in Sources */, 26362 26373 A7C9ABF81357A3BF00F5503F /* DetailsMarkerControl.cpp in Sources */, 26374 CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */, 26363 26375 31FB1A58120A5D0600DC02A0 /* DeviceMotionController.cpp in Sources */, 26364 26376 31FB1A5A120A5D0600DC02A0 /* DeviceMotionData.cpp in Sources */, -
trunk/Source/WebCore/dom/DeviceOrientationClient.h
r133167 r134918 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
r133976 r134918 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)56 {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);68 }69 70 void DeviceOrientationController::addListener(DOMWindow* window)71 {72 // If the client already has an orientation, we should fire an event with that73 // orientation. The event is fired asynchronously, but without74 // 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();86 }87 88 void DeviceOrientationController::removeListener(DOMWindow* window)89 {90 m_listeners.remove(window);91 m_suspendedListeners.remove(window);92 m_newListeners.remove(window);93 if (m_listeners.isEmpty())94 m_client->stopUpdating();95 }96 97 void DeviceOrientationController::removeAllListeners(DOMWindow* window)98 {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 50 void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientationData* orientation) 133 51 { 134 52 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); 53 dispatchDeviceEvent(DeviceOrientationEvent::create(eventNames().deviceorientationEvent, orientation)); 54 } 55 56 DeviceOrientationClient* DeviceOrientationController::deviceOrientationClient() 57 { 58 return static_cast<DeviceOrientationClient*>(m_client); 59 } 60 61 bool DeviceOrientationController::hasLastData() 62 { 63 return deviceOrientationClient()->lastOrientation(); 64 } 65 66 PassRefPtr<Event> DeviceOrientationController::getLastEvent() 67 { 68 return DeviceOrientationEvent::create(eventNames().deviceorientationEvent, deviceOrientationClient()->lastOrientation()); 140 69 } 141 70 … … 144 73 DEFINE_STATIC_LOCAL(AtomicString, name, ("DeviceOrientationController", AtomicString::ConstructFromLiteral)); 145 74 return name; 75 } 76 77 DeviceOrientationController* DeviceOrientationController::from(Page* page) 78 { 79 return static_cast<DeviceOrientationController*>(Supplement<Page>::from(page, supplementName())); 146 80 } 147 81 -
trunk/Source/WebCore/dom/DeviceOrientationController.h
r133167 r134918 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
r134714 r134918 2177 2177 if (DeviceMotionController* controller = DeviceMotionController::from(page())) 2178 2178 controller->suspendEventsForAllListeners(domWindow()); 2179 if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))2180 controller->suspendEventsForAllListeners(domWindow());2181 2182 2179 #endif 2183 2180 } … … 2192 2189 2193 2190 if (DeviceMotionController* controller = DeviceMotionController::from(page())) 2194 controller->resumeEventsForAllListeners(domWindow());2195 if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))2196 2191 controller->resumeEventsForAllListeners(domWindow()); 2197 2192 #endif -
trunk/Source/WebCore/loader/EmptyClients.h
r133396 r134918 578 578 }; 579 579 580 class EmptyDeviceClient : public DeviceClient { 581 public: 582 virtual void startUpdating() OVERRIDE { } 583 virtual void stopUpdating() OVERRIDE { } 584 }; 585 580 586 class EmptyDeviceMotionClient : public DeviceMotionClient { 581 587 public: … … 590 596 public: 591 597 virtual void setController(DeviceOrientationController*) { } 592 virtual void startUpdating() { }593 virtual void stopUpdating() { }594 598 virtual DeviceOrientationData* lastOrientation() const { return 0; } 595 599 virtual void deviceOrientationControllerDestroyed() { } -
trunk/Source/WebCore/page/DOMWindow.cpp
r134586 r134918 1600 1600 } else if (eventType == eventNames().deviceorientationEvent && RuntimeEnabledFeatures::deviceOrientationEnabled()) { 1601 1601 if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) 1602 controller->add Listener(this);1602 controller->addDeviceEventListener(this); 1603 1603 } 1604 1604 #endif … … 1629 1629 } else if (eventType == eventNames().deviceorientationEvent) { 1630 1630 if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) 1631 controller->remove Listener(this);1631 controller->removeDeviceEventListener(this); 1632 1632 } 1633 1633 #endif … … 1686 1686 controller->removeAllListeners(this); 1687 1687 if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) 1688 controller->removeAll Listeners(this);1688 controller->removeAllDeviceEventListeners(this); 1689 1689 #endif 1690 1690 -
trunk/Source/WebKit/qt/ChangeLog
r134596 r134918 1 2012-11-16 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-11-14 Csaba Osztrogonác <ossy@webkit.org> 2 14 -
trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
r133167 r134918 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.