Changeset 253231 in webkit


Ignore:
Timestamp:
Dec 6, 2019 4:19:22 PM (4 years ago)
Author:
pvollan@apple.com
Message:

[iOS] Calls to device orientation API should be done in the UI process
https://bugs.webkit.org/show_bug.cgi?id=204720

Reviewed by Alex Christensen.

Source/WebCore:

The device orientation API on iOS is communicating with locationd. Since mach lookup to this daemon
will be closed, the calls to this API should be moved from the WebContent process to the UI process.
This patch implements forwarding of the device orientation requests to the UI process through a new
class, DeviceOrientationUpdateProvider, which is subclassed by WebDeviceOrientationUpdateProvider in
modern WebKit. This class implements forwarding of the requests to the UI process, and receives
device orientation updates from the UI process. An instance of this class will be shared by all
device orientation clients on a page, and passed as part of the page configuration parameters. On
the UI process side, a new class WebDeviceOrientationUpdateProviderProxy attached to the Web page
proxy is taking care of calling the device orientation API through the existing WebCoreMotionManager
Objective-C class, and send device orientation updates back to the Web process. Also, use a weak
hash set of orientation clients in WebCoreMotionManager.

  • WebCore.xcodeproj/project.pbxproj:
  • dom/DeviceOrientationClient.h:
  • dom/Document.cpp:
  • page/Page.cpp:

(WebCore::m_deviceOrientationUpdateProvider):
(WebCore::m_applicationManifest): Deleted.

  • page/Page.h:

(WebCore::Page::deviceOrientationUpdateProvider const):

  • page/PageConfiguration.h:
  • platform/ios/DeviceOrientationClientIOS.h:
  • platform/ios/DeviceOrientationClientIOS.mm:

(WebCore::DeviceOrientationClientIOS::DeviceOrientationClientIOS):
(WebCore::DeviceOrientationClientIOS::startUpdating):
(WebCore::DeviceOrientationClientIOS::stopUpdating):
(WebCore::DeviceOrientationClientIOS::deviceOrientationControllerDestroyed):

  • platform/ios/WebCoreMotionManager.h:
  • platform/ios/WebCoreMotionManager.mm:

(-[WebCoreMotionManager addOrientationClient:]):
(-[WebCoreMotionManager removeOrientationClient:]):
(-[WebCoreMotionManager checkClientStatus]):
(-[WebCoreMotionManager sendMotionData:withHeading:]):

Source/WebKit:

Add a new class, WebDeviceOrientationUpdateProviderProxy, to handle messages to start and stop updating device orientation
in the UI process. Also, add a message to update the device orientation in the WebContent process. In the UI process, the
device orientation API is called through the already existing WebCoreMotionManager class.

  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • UIProcess/WebPageProxy.cpp:

(WebKit::m_webDeviceOrientationUpdateProviderProxy):
(WebKit::m_resetRecentCrashCountTimer): Deleted.

  • UIProcess/WebPageProxy.h:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::m_overriddenMediaType):

Location:
trunk/Source
Files:
7 added
19 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r253228 r253231  
     12019-12-06  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [iOS] Calls to device orientation API should be done in the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=204720
     5
     6        Reviewed by Alex Christensen.
     7
     8        The device orientation API on iOS is communicating with locationd. Since mach lookup to this daemon
     9        will be closed, the calls to this API should be moved from the WebContent process to the UI process.
     10        This patch implements forwarding of the device orientation requests to the UI process through a new
     11        class, DeviceOrientationUpdateProvider, which is subclassed by WebDeviceOrientationUpdateProvider in
     12        modern WebKit. This class implements forwarding of the requests to the UI process, and receives
     13        device orientation updates from the UI process. An instance of this class will be shared by all
     14        device orientation clients on a page, and passed as part of the page configuration parameters. On
     15        the UI process side, a new class WebDeviceOrientationUpdateProviderProxy attached to the Web page
     16        proxy is taking care of calling the device orientation API through the existing WebCoreMotionManager
     17        Objective-C class, and send device orientation updates back to the Web process. Also, use a weak
     18        hash set of orientation clients in WebCoreMotionManager.
     19
     20        * WebCore.xcodeproj/project.pbxproj:
     21        * dom/DeviceOrientationClient.h:
     22        * dom/Document.cpp:
     23        * page/Page.cpp:
     24        (WebCore::m_deviceOrientationUpdateProvider):
     25        (WebCore::m_applicationManifest): Deleted.
     26        * page/Page.h:
     27        (WebCore::Page::deviceOrientationUpdateProvider const):
     28        * page/PageConfiguration.h:
     29        * platform/ios/DeviceOrientationClientIOS.h:
     30        * platform/ios/DeviceOrientationClientIOS.mm:
     31        (WebCore::DeviceOrientationClientIOS::DeviceOrientationClientIOS):
     32        (WebCore::DeviceOrientationClientIOS::startUpdating):
     33        (WebCore::DeviceOrientationClientIOS::stopUpdating):
     34        (WebCore::DeviceOrientationClientIOS::deviceOrientationControllerDestroyed):
     35        * platform/ios/WebCoreMotionManager.h:
     36        * platform/ios/WebCoreMotionManager.mm:
     37        (-[WebCoreMotionManager addOrientationClient:]):
     38        (-[WebCoreMotionManager removeOrientationClient:]):
     39        (-[WebCoreMotionManager checkClientStatus]):
     40        (-[WebCoreMotionManager sendMotionData:withHeading:]):
     41
    1422019-12-06  Sihui Liu  <sihui_liu@apple.com>
    243
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r253178 r253231  
    910910                3135910B1E7DDC7300F30630 /* RTCSignalingState.h in Headers */ = {isa = PBXBuildFile; fileRef = 313591051E7DDC6000F30630 /* RTCSignalingState.h */; };
    911911                313BCE1C235E3BE500FC39E5 /* ElementContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE1B235E3BDB00FC39E5 /* ElementContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    912                 3140379B124BEA7F00AF40E4 /* WebCoreMotionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */; };
     912                3140379B124BEA7F00AF40E4 /* WebCoreMotionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
    913913                3140379D124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 31403799124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h */; };
    914914                3140C5201FDF151A00D2A873 /* OffscreenCanvasRenderingContext2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 3140C51E1FDF151A00D2A873 /* OffscreenCanvasRenderingContext2D.h */; };
     
    47814781                E377FE4D1DADE16500CDD025 /* NodeConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D049931DADC04500718F3C /* NodeConstants.h */; settings = {ATTRIBUTES = (Private, ); }; };
    47824782                E37C86501EB63E3F0087C6CA /* JSDOMPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
     4783                E39628BF2395728F00658ECD /* DeviceOrientationUpdateProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E39628BD2395728E00658ECD /* DeviceOrientationUpdateProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
     4784                E39628C12395743100658ECD /* MotionManagerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E39628C02395743000658ECD /* MotionManagerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    47834785                E3A776671DC85D2800B690D8 /* DOMJITIDLConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = E3A776651DC85D2200B690D8 /* DOMJITIDLConvert.h */; settings = {ATTRIBUTES = (Private, ); }; };
    47844786                E3A776681DC85D2800B690D8 /* DOMJITIDLType.h in Headers */ = {isa = PBXBuildFile; fileRef = E3A776661DC85D2200B690D8 /* DOMJITIDLType.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1508515087                E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptModuleLoader.h; sourceTree = "<group>"; };
    1508615088                E38D06091F8E811900649CF2 /* ModuleFetchParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleFetchParameters.h; sourceTree = "<group>"; };
     15089                E39628BD2395728E00658ECD /* DeviceOrientationUpdateProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationUpdateProvider.h; sourceTree = "<group>"; };
     15090                E39628C02395743000658ECD /* MotionManagerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MotionManagerClient.h; sourceTree = "<group>"; };
    1508715091                E3975B761EC9AF3900847717 /* JSDocumentFragmentDOMJIT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentFragmentDOMJIT.cpp; sourceTree = "<group>"; };
    1508815092                E3975B771EC9AF3900847717 /* JSElementDOMJIT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSElementDOMJIT.cpp; sourceTree = "<group>"; };
     
    2281522819                                31403799124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h */,
    2281622820                                3140379A124BEA7F00AF40E4 /* DeviceOrientationClientIOS.mm */,
     22821                                E39628BD2395728E00658ECD /* DeviceOrientationUpdateProvider.h */,
    2281722822                                0FDA7C22188330A900C954B5 /* DragImageIOS.mm */,
    2281822823                                265541371489811C000DFC5D /* KeyEventCodesIOS.h */,
     
    2283122836                                1C43DE6A22AB4B8A001527D9 /* LocalCurrentTraitCollection.mm */,
    2283222837                                46EFAF0D1E5FB9C200E7F34B /* LowPowerModeNotifierIOS.mm */,
     22838                                E39628C02395743000658ECD /* MotionManagerClient.h */,
    2283322839                                E45390190EAFCACA003695C8 /* PasteboardIOS.mm */,
    2283422840                                26601EBD14B3B9AD0012C0FE /* PlatformEventFactoryIOS.h */,
     
    2955629562                                460E3075222F4EFD009A0606 /* DeviceOrientationOrMotionEvent.h in Headers */,
    2955729563                                460E3077222F4F03009A0606 /* DeviceOrientationOrMotionPermissionState.h in Headers */,
     29564                                E39628BF2395728F00658ECD /* DeviceOrientationUpdateProvider.h in Headers */,
    2955829565                                572B401F21757A64000AD43E /* DeviceRequestConverter.h in Headers */,
    2955929566                                572B403A21772581000AD43E /* DeviceResponseConverter.h in Headers */,
     
    3144331450                                E3201C1A1F8E82130076A032 /* ModuleFetchParameters.h in Headers */,
    3144431451                                F55B3DC61251F12D003EF269 /* MonthInputType.h in Headers */,
     31452                                E39628C12395743100658ECD /* MotionManagerClient.h in Headers */,
    3144531453                                85031B460A44EFC700F992E0 /* MouseEvent.h in Headers */,
    3144631454                                83765F951DAC522F00C06537 /* MouseEventInit.h in Headers */,
  • trunk/Source/WebCore/dom/DeviceOrientationClient.h

    r240237 r253231  
    2929#include "DeviceClient.h"
    3030#include <wtf/Noncopyable.h>
     31#include <wtf/RefPtr.h>
    3132
    3233namespace WebCore {
  • trunk/Source/WebCore/dom/Document.cpp

    r253096 r253231  
    566566    , m_deviceMotionClient(makeUnique<DeviceMotionClientIOS>())
    567567    , m_deviceMotionController(makeUnique<DeviceMotionController>(*m_deviceMotionClient))
    568     , m_deviceOrientationClient(makeUnique<DeviceOrientationClientIOS>())
     568    , m_deviceOrientationClient(makeUnique<DeviceOrientationClientIOS>(page() ? page()->deviceOrientationUpdateProvider() : nullptr))
    569569    , m_deviceOrientationController(makeUnique<DeviceOrientationController>(*m_deviceOrientationClient))
    570570#endif
  • trunk/Source/WebCore/page/Page.cpp

    r253213 r253231  
    289289    , m_applicationManifest(pageConfiguration.applicationManifest)
    290290#endif
     291#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
     292    , m_deviceOrientationUpdateProvider(WTFMove(pageConfiguration.deviceOrientationUpdateProvider))
     293#endif
    291294{
    292295    updateTimerThrottlingState();
  • trunk/Source/WebCore/page/Page.h

    r253213 r253231  
    6868#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    6969#include "MediaPlaybackTargetContext.h"
     70#endif
     71
     72#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
     73#include "DeviceOrientationUpdateProvider.h"
    7074#endif
    7175
     
    724728    WEBCORE_EXPORT Vector<Ref<Element>> editableElementsInRect(const FloatRect&) const;
    725729
     730#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
     731    DeviceOrientationUpdateProvider* deviceOrientationUpdateProvider() const { return m_deviceOrientationUpdateProvider.get(); }
     732#endif
     733
    726734private:
    727735    struct Navigation {
     
    9961004    Optional<ViewportArguments> m_overrideViewportArguments;
    9971005
     1006#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
     1007    RefPtr<DeviceOrientationUpdateProvider> m_deviceOrientationUpdateProvider;
     1008#endif
     1009
    9981010    bool m_shouldEnableICECandidateFilteringByDefault { true };
    9991011    bool m_mediaPlaybackIsSuspended { false };
  • trunk/Source/WebCore/page/PageConfiguration.h

    r253182 r253231  
    119119    RefPtr<UserContentProvider> userContentProvider;
    120120    RefPtr<VisitedLinkStore> visitedLinkStore;
     121   
     122#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
     123    RefPtr<DeviceOrientationUpdateProvider> deviceOrientationUpdateProvider;
     124#endif
    121125};
    122126
  • trunk/Source/WebCore/platform/ios/DeviceOrientationClientIOS.h

    r237266 r253231  
    3131#include "DeviceOrientationController.h"
    3232#include "DeviceOrientationData.h"
     33#include "DeviceOrientationUpdateProvider.h"
     34#include "MotionManagerClient.h"
    3335#include <wtf/RefPtr.h>
    3436
     
    3739namespace WebCore {
    3840
    39 class DeviceOrientationClientIOS : public DeviceOrientationClient {
     41class DeviceOrientationClientIOS : public DeviceOrientationClient, public MotionManagerClient {
    4042public:
    41     DeviceOrientationClientIOS();
     43    DeviceOrientationClientIOS(RefPtr<DeviceOrientationUpdateProvider>&&);
    4244    ~DeviceOrientationClientIOS() override;
    4345    void setController(DeviceOrientationController*) override;
     
    4749    void deviceOrientationControllerDestroyed() override;
    4850
    49     void orientationChanged(double, double, double, double, double);
     51    void orientationChanged(double, double, double, double, double) override;
    5052
    5153private:
    52     WebCoreMotionManager* m_motionManager;
    53     DeviceOrientationController* m_controller;
     54    WebCoreMotionManager* m_motionManager  { nullptr };
     55    DeviceOrientationController* m_controller  { nullptr };
    5456    RefPtr<DeviceOrientationData> m_currentDeviceOrientation;
    55     bool m_updating;
     57    RefPtr<DeviceOrientationUpdateProvider> m_deviceOrientationUpdateProvider;
     58    bool m_updating { false };
    5659};
    5760
  • trunk/Source/WebCore/platform/ios/DeviceOrientationClientIOS.mm

    r237266 r253231  
    3434namespace WebCore {
    3535
    36 DeviceOrientationClientIOS::DeviceOrientationClientIOS()
     36DeviceOrientationClientIOS::DeviceOrientationClientIOS(RefPtr<DeviceOrientationUpdateProvider>&& deviceOrientationUpdateProvider)
    3737    : DeviceOrientationClient()
    38     , m_motionManager(nullptr)
    39     , m_updating(0)
     38    , m_deviceOrientationUpdateProvider(WTFMove(deviceOrientationUpdateProvider))
    4039{
    4140}
     
    5453    m_updating = true;
    5554
     55    if (m_deviceOrientationUpdateProvider) {
     56        m_deviceOrientationUpdateProvider->startUpdating(*this);
     57        return;
     58    }
     59
    5660    if (!m_motionManager)
    5761        m_motionManager = [WebCoreMotionManager sharedManager];
     
    6367{
    6468    m_updating = false;
     69
     70    if (m_deviceOrientationUpdateProvider) {
     71        m_deviceOrientationUpdateProvider->stopUpdating(*this);
     72        return;
     73    }
    6574
    6675    // Remove ourselves as the orientation client so we won't get updates.
     
    7584void DeviceOrientationClientIOS::deviceOrientationControllerDestroyed()
    7685{
     86    if (m_deviceOrientationUpdateProvider) {
     87        m_deviceOrientationUpdateProvider->stopUpdating(*this);
     88        return;
     89    }
     90
    7791    [m_motionManager removeOrientationClient:this];
    7892}
  • trunk/Source/WebCore/platform/ios/DeviceOrientationUpdateProvider.h

    r253230 r253231  
    11/*
    2  * Copyright (C) 2010, The Android Open Source Project
    3  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2726#pragma once
    2827
    29 #include "DeviceClient.h"
    30 #include <wtf/Noncopyable.h>
     28#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
     29
     30#include <wtf/RefCounted.h>
    3131
    3232namespace WebCore {
    3333
    34 class DeviceOrientationController;
    35 class DeviceOrientationData;
    36 class Page;
     34class MotionManagerClient;
    3735
    38 class DeviceOrientationClient : public DeviceClient {
    39     WTF_MAKE_NONCOPYABLE(DeviceOrientationClient);
     36class DeviceOrientationUpdateProvider : public RefCounted<DeviceOrientationUpdateProvider> {
    4037public:
    41     DeviceOrientationClient() = default;
    42     virtual ~DeviceOrientationClient() = default;
    43     virtual void setController(DeviceOrientationController*) = 0;
    44     virtual DeviceOrientationData* lastOrientation() const = 0;
    45     virtual void deviceOrientationControllerDestroyed() = 0;
     38    virtual ~DeviceOrientationUpdateProvider() { }
     39
     40    virtual void startUpdating(MotionManagerClient&) = 0;
     41    virtual void stopUpdating(MotionManagerClient&) = 0;
     42
     43    virtual void deviceOrientationChanged(double, double, double, double, double) = 0;
     44   
     45protected:
     46    DeviceOrientationUpdateProvider() = default;
    4647};
    4748
    48 WEBCORE_EXPORT void provideDeviceOrientationTo(Page&, DeviceOrientationClient&);
     49} // namespace WebCore
    4950
    50 } // namespace WebCore
     51#endif // PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
  • trunk/Source/WebCore/platform/ios/WebCoreMotionManager.h

    r237266 r253231  
    2626#pragma once
    2727
    28 #import "DeviceMotionClientIOS.h"
    29 #import "DeviceOrientationClientIOS.h"
    3028#import <CoreLocation/CoreLocation.h>
    3129#import <wtf/HashCountedSet.h>
     30#import <wtf/WeakHashSet.h>
    3231
    3332#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
     
    3736const float kMotionUpdateInterval = 1.0f / 60.0f;
    3837
    39 @interface WebCoreMotionManager : NSObject {
     38namespace WebCore {
     39class DeviceMotionClientIOS;
     40class MotionManagerClient;
     41};
     42
     43WEBCORE_EXPORT @interface WebCoreMotionManager : NSObject {
    4044    CMMotionManager* m_motionManager;
    4145    CLLocationManager* m_locationManager;
    4246    HashSet<WebCore::DeviceMotionClientIOS*> m_deviceMotionClients;
    43     HashSet<WebCore::DeviceOrientationClientIOS*> m_deviceOrientationClients;
     47    WeakHashSet<WebCore::MotionManagerClient> m_deviceOrientationClients;
    4448    NSTimer* m_updateTimer;
    4549    BOOL m_gyroAvailable;
     
    5155- (void)addMotionClient:(WebCore::DeviceMotionClientIOS *)client;
    5256- (void)removeMotionClient:(WebCore::DeviceMotionClientIOS *)client;
    53 - (void)addOrientationClient:(WebCore::DeviceOrientationClientIOS *)client;
    54 - (void)removeOrientationClient:(WebCore::DeviceOrientationClientIOS *)client;
     57- (void)addOrientationClient:(WebCore::MotionManagerClient *)client;
     58- (void)removeOrientationClient:(WebCore::MotionManagerClient *)client;
    5559- (BOOL)gyroAvailable;
    5660- (BOOL)headingAvailable;
  • trunk/Source/WebCore/platform/ios/WebCoreMotionManager.mm

    r240355 r253231  
    2929#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
    3030
     31#import "DeviceMotionClientIOS.h"
     32#import "MotionManagerClient.h"
    3133#import "WebCoreObjCExtras.h"
    3234#import "WebCoreThreadRun.h"
     
    113115}
    114116
    115 - (void)addOrientationClient:(WebCore::DeviceOrientationClientIOS *)client
    116 {
    117     m_deviceOrientationClients.add(client);
     117- (void)addOrientationClient:(WebCore::MotionManagerClient *)client
     118{
     119    m_deviceOrientationClients.add(*client);
    118120    if (m_initialized)
    119121        [self checkClientStatus];
    120122}
    121123
    122 - (void)removeOrientationClient:(WebCore::DeviceOrientationClientIOS *)client
    123 {
    124     m_deviceOrientationClients.remove(client);
     124- (void)removeOrientationClient:(WebCore::MotionManagerClient *)client
     125{
     126    m_deviceOrientationClients.remove(*client);
    125127    if (m_initialized)
    126128        [self checkClientStatus];
     
    170172    ASSERT(m_motionManager);
    171173
    172     if (m_deviceMotionClients.size() || m_deviceOrientationClients.size()) {
     174    if (m_deviceMotionClients.size() || m_deviceOrientationClients.computeSize()) {
    173175        if (m_gyroAvailable)
    174176            [m_motionManager startDeviceMotionUpdates];
     
    247249        CMAttitude* attitude = newMotion.attitude;
    248250
    249         auto orientationClients = copyToVector(m_deviceOrientationClients);
    250 
     251        Vector<WeakPtr<MotionManagerClient>> orientationClients;
     252        orientationClients.reserveInitialCapacity(m_deviceOrientationClients.computeSize());
     253        for (auto& client : m_deviceOrientationClients)
     254            orientationClients.uncheckedAppend(makeWeakPtr(&client));
     255       
    251256        // Compose the raw motion data to an intermediate ZXY-based 3x3 rotation
    252257        // matrix (R) where [z=attitude.yaw, x=attitude.pitch, y=attitude.roll]
     
    320325        double headingAccuracy = (m_headingAvailable && newHeading) ? newHeading.headingAccuracy : -1;
    321326
    322         for (size_t i = 0; i < orientationClients.size(); ++i)
    323             orientationClients[i]->orientationChanged(alpha, beta, gamma, heading, headingAccuracy);
     327        for (size_t i = 0; i < orientationClients.size(); ++i) {
     328            if (orientationClients[i])
     329                orientationClients[i]->orientationChanged(alpha, beta, gamma, heading, headingAccuracy);
     330        }
    324331    });
    325332}
  • trunk/Source/WebKit/ChangeLog

    r253224 r253231  
     12019-12-06  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [iOS] Calls to device orientation API should be done in the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=204720
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add a new class, WebDeviceOrientationUpdateProviderProxy, to handle messages to start and stop updating device orientation
     9        in the UI process. Also, add a message to update the device orientation in the WebContent process. In the UI process, the
     10        device orientation API is called through the already existing WebCoreMotionManager class.
     11
     12        * DerivedSources-input.xcfilelist:
     13        * DerivedSources-output.xcfilelist:
     14        * DerivedSources.make:
     15        * UIProcess/WebPageProxy.cpp:
     16        (WebKit::m_webDeviceOrientationUpdateProviderProxy):
     17        (WebKit::m_resetRecentCrashCountTimer): Deleted.
     18        * UIProcess/WebPageProxy.h:
     19        * WebKit.xcodeproj/project.pbxproj:
     20        * WebProcess/WebPage/WebPage.cpp:
     21        (WebKit::m_overriddenMediaType):
     22
    1232019-12-06  Chris Dumez  <cdumez@apple.com>
    224
  • trunk/Source/WebKit/DerivedSources-input.xcfilelist

    r253098 r253231  
    8989$(PROJECT_DIR)/UIProcess/ios/EditableImageController.messages.in
    9090$(PROJECT_DIR)/UIProcess/ios/SmartMagnificationController.messages.in
     91$(PROJECT_DIR)/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.messages.in
    9192$(PROJECT_DIR)/UIProcess/mac/SecItemShimProxy.messages.in
    9293$(PROJECT_DIR)/WebProcess/ApplePay/WebPaymentCoordinator.messages.in
     
    114115$(PROJECT_DIR)/WebProcess/UserContent/WebUserContentController.messages.in
    115116$(PROJECT_DIR)/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in
     117$(PROJECT_DIR)/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in
    116118$(PROJECT_DIR)/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in
    117119$(PROJECT_DIR)/WebProcess/WebPage/DrawingArea.messages.in
  • trunk/Source/WebKit/DerivedSources-output.xcfilelist

    r253098 r253231  
    194194$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebCookieManagerProxyMessages.h
    195195$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebCookieManagerProxyMessagesReplies.h
     196$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderMessageReceiver.cpp
     197$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderMessages.h
     198$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderMessagesReplies.h
     199$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderProxyMessageReceiver.cpp
     200$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderProxyMessages.h
     201$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderProxyMessagesReplies.h
    196202$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebFullScreenManagerMessageReceiver.cpp
    197203$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebFullScreenManagerMessages.h
  • trunk/Source/WebKit/DerivedSources.make

    r253098 r253231  
    190190    WebSWServerConnection \
    191191    WebSWServerToContextConnection \
     192    WebDeviceOrientationUpdateProvider \
     193    WebDeviceOrientationUpdateProviderProxy \
    192194    WebSocketChannel \
    193195    WebSocketStream \
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r253224 r253231  
    452452    , m_resetRecentCrashCountTimer(RunLoop::main(), this, &WebPageProxy::resetRecentCrashCount)
    453453    , m_tryCloseTimeoutTimer(RunLoop::main(), this, &WebPageProxy::tryCloseTimedOut)
     454#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
     455    , m_webDeviceOrientationUpdateProviderProxy(*this)
     456#endif
    454457{
    455458    RELEASE_LOG_IF_ALLOWED(Loading, "constructor:");
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r253224 r253231  
    150150#endif
    151151
     152#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
     153#include "WebDeviceOrientationUpdateProviderProxy.h"
     154#endif
     155
    152156#if ENABLE(MEDIA_SESSION)
    153157namespace WebCore {
     
    26332637   
    26342638    String m_overriddenMediaType;
     2639       
     2640#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
     2641    WebDeviceOrientationUpdateProviderProxy m_webDeviceOrientationUpdateProviderProxy;
     2642#endif
    26352643};
    26362644
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r253131 r253231  
    16971697                E1E552C516AE065F004ED653 /* SandboxInitializationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = E1E552C316AE065E004ED653 /* SandboxInitializationParameters.h */; };
    16981698                E1EE53E311F8CFC000CCBEE4 /* InjectedBundlePageEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE53DC11F8CF9F00CCBEE4 /* InjectedBundlePageEditorClient.h */; };
     1699                E3866AE52397400400F88FE9 /* WebDeviceOrientationUpdateProviderProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3866AE42397400400F88FE9 /* WebDeviceOrientationUpdateProviderProxy.mm */; };
     1700                E3866AE72397405300F88FE9 /* WebDeviceOrientationUpdateProviderProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = E3866AE62397405300F88FE9 /* WebDeviceOrientationUpdateProviderProxy.h */; };
     1701                E3866B082399A2D100F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = E3866B052399979C00F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessages.h */; };
     1702                E3866B092399A2D500F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3866B042399979C00F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessageReceiver.cpp */; };
     1703                E3866B0A2399A2D900F88FE9 /* WebDeviceOrientationUpdateProviderMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = E3866B072399979D00F88FE9 /* WebDeviceOrientationUpdateProviderMessages.h */; };
     1704                E3866B0B2399A2DD00F88FE9 /* WebDeviceOrientationUpdateProviderMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3866B062399979C00F88FE9 /* WebDeviceOrientationUpdateProviderMessageReceiver.cpp */; };
     1705                E39628DD23960CC600658ECD /* WebDeviceOrientationUpdateProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E39628DB23960CC500658ECD /* WebDeviceOrientationUpdateProvider.h */; };
     1706                E39628DE23960CC600658ECD /* WebDeviceOrientationUpdateProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E39628DC23960CC600658ECD /* WebDeviceOrientationUpdateProvider.cpp */; };
    16991707                E413F59D1AC1ADC400345360 /* NetworkCacheEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = E413F59B1AC1ADB600345360 /* NetworkCacheEntry.h */; };
    17001708                E42E06101AA7523B00B11699 /* NetworkCacheIOChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = E42E060B1AA7440D00B11699 /* NetworkCacheIOChannel.h */; };
     
    19761984                        dstSubfolderSpec = 0;
    19771985                        files = (
     1986                                2DB96053239886C100102791 /* com.apple.WebKit.GPU.sb in CopyFiles */,
    19781987                                A78CCDDB193AC9F8005ECC25 /* com.apple.WebKit.Networking.sb in CopyFiles */,
    19791988                                A78CCDDC193AC9FB005ECC25 /* com.apple.WebKit.WebContent.sb in CopyFiles */,
    1980                                 2DB96053239886C100102791 /* com.apple.WebKit.GPU.sb in CopyFiles */,
    19811989                        );
    19821990                        runOnlyForDeploymentPostprocessing = 0;
     
    48074815                E1EE53E611F8CFFB00CCBEE4 /* InjectedBundlePageEditorClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageEditorClient.cpp; sourceTree = "<group>"; };
    48084816                E3439B632345463A0011DE0B /* NetworkProcessConnectionInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NetworkProcessConnectionInfo.h; path = Network/NetworkProcessConnectionInfo.h; sourceTree = "<group>"; };
     4817                E3866AE42397400400F88FE9 /* WebDeviceOrientationUpdateProviderProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebDeviceOrientationUpdateProviderProxy.mm; path = ios/WebDeviceOrientationUpdateProviderProxy.mm; sourceTree = "<group>"; };
     4818                E3866AE62397405300F88FE9 /* WebDeviceOrientationUpdateProviderProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebDeviceOrientationUpdateProviderProxy.h; path = ios/WebDeviceOrientationUpdateProviderProxy.h; sourceTree = "<group>"; };
     4819                E3866AED2398471A00F88FE9 /* WebDeviceOrientationUpdateProviderProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebDeviceOrientationUpdateProviderProxy.messages.in; path = ios/WebDeviceOrientationUpdateProviderProxy.messages.in; sourceTree = "<group>"; };
     4820                E3866B042399979C00F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebDeviceOrientationUpdateProviderProxyMessageReceiver.cpp; path = DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderProxyMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
     4821                E3866B052399979C00F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebDeviceOrientationUpdateProviderProxyMessages.h; path = DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderProxyMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
     4822                E3866B062399979C00F88FE9 /* WebDeviceOrientationUpdateProviderMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebDeviceOrientationUpdateProviderMessageReceiver.cpp; path = DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
     4823                E3866B072399979D00F88FE9 /* WebDeviceOrientationUpdateProviderMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebDeviceOrientationUpdateProviderMessages.h; path = DerivedSources/WebKit2/WebDeviceOrientationUpdateProviderMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
     4824                E39628DB23960CC500658ECD /* WebDeviceOrientationUpdateProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDeviceOrientationUpdateProvider.h; sourceTree = "<group>"; };
     4825                E39628DC23960CC600658ECD /* WebDeviceOrientationUpdateProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebDeviceOrientationUpdateProvider.cpp; sourceTree = "<group>"; };
     4826                E39628E423971F3400658ECD /* WebDeviceOrientationUpdateProvider.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebDeviceOrientationUpdateProvider.messages.in; sourceTree = "<group>"; };
    48094827                E404907021DE65F70037F0DB /* ScrollerPairMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollerPairMac.h; sourceTree = "<group>"; };
    48104828                E404907121DE65F70037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeFrameScrollingNodeRemoteMac.cpp; sourceTree = "<group>"; };
     
    59245942                        children = (
    59255943                                2D28F3E01885CCC1004B9EAE /* WebChromeClientIOS.mm */,
     5944                                E39628DC23960CC600658ECD /* WebDeviceOrientationUpdateProvider.cpp */,
     5945                                E39628DB23960CC500658ECD /* WebDeviceOrientationUpdateProvider.h */,
     5946                                E39628E423971F3400658ECD /* WebDeviceOrientationUpdateProvider.messages.in */,
    59265947                                2D28F3E21885CCC1004B9EAE /* WebEditorClientIOS.mm */,
    59275948                                2D28F3E31885CCC1004B9EAE /* WebFrameLoaderClientIOS.mm */,
     
    63116332                                E5BEF6802130C47F00F31111 /* WebDataListSuggestionsDropdownIOS.h */,
    63126333                                E5BEF6812130C47F00F31111 /* WebDataListSuggestionsDropdownIOS.mm */,
     6334                                E3866AE62397405300F88FE9 /* WebDeviceOrientationUpdateProviderProxy.h */,
     6335                                E3866AED2398471A00F88FE9 /* WebDeviceOrientationUpdateProviderProxy.messages.in */,
     6336                                E3866AE42397400400F88FE9 /* WebDeviceOrientationUpdateProviderProxy.mm */,
    63136337                                2DA944AB1884E9BA00ED86DB /* WebPageProxyIOS.mm */,
    63146338                                2DA944AC1884E9BA00ED86DB /* WebProcessProxyIOS.mm */,
     
    91499173                                330934451315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp */,
    91509174                                330934461315B9220097A7BC /* WebCookieManagerProxyMessages.h */,
     9175                                E3866B062399979C00F88FE9 /* WebDeviceOrientationUpdateProviderMessageReceiver.cpp */,
     9176                                E3866B072399979D00F88FE9 /* WebDeviceOrientationUpdateProviderMessages.h */,
     9177                                E3866B042399979C00F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessageReceiver.cpp */,
     9178                                E3866B052399979C00F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessages.h */,
    91519179                                CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */,
    91529180                                CD73BA49131ACD8E00EEDED2 /* WebFullScreenManagerMessages.h */,
     
    1013610164                                E568B92220A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h in Headers */,
    1013710165                                46B0524722668D8500265B97 /* WebDeviceOrientationAndMotionAccessController.h in Headers */,
     10166                                E39628DD23960CC600658ECD /* WebDeviceOrientationUpdateProvider.h in Headers */,
     10167                                E3866B0A2399A2D900F88FE9 /* WebDeviceOrientationUpdateProviderMessages.h in Headers */,
     10168                                E3866AE72397405300F88FE9 /* WebDeviceOrientationUpdateProviderProxy.h in Headers */,
     10169                                E3866B082399A2D100F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessages.h in Headers */,
    1013810170                                CD19A26E1A13E834008D650E /* WebDiagnosticLoggingClient.h in Headers */,
    1013910171                                1A5B1C5518987EDF004FCF9B /* WebDocumentLoader.h in Headers */,
     
    1182911861                                330934491315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp in Sources */,
    1183011862                                2D92A788212B6AB100F493FD /* WebCoreArgumentCoders.cpp in Sources */,
     11863                                E39628DE23960CC600658ECD /* WebDeviceOrientationUpdateProvider.cpp in Sources */,
     11864                                E3866B0B2399A2DD00F88FE9 /* WebDeviceOrientationUpdateProviderMessageReceiver.cpp in Sources */,
     11865                                E3866AE52397400400F88FE9 /* WebDeviceOrientationUpdateProviderProxy.mm in Sources */,
     11866                                E3866B092399A2D500F88FE9 /* WebDeviceOrientationUpdateProviderProxyMessageReceiver.cpp in Sources */,
    1183111867                                2D92A789212B6AB100F493FD /* WebEvent.cpp in Sources */,
    1183211868                                CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */,
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r253187 r253231  
    308308#endif
    309309
     310#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
     311#include "WebDeviceOrientationUpdateProvider.h"
     312#endif
     313
    310314namespace WebKit {
    311315using namespace JSC;
     
    501505#if ENABLE(APPLICATION_MANIFEST)
    502506    pageConfiguration.applicationManifest = parameters.applicationManifest;
     507#endif
     508   
     509#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
     510    pageConfiguration.deviceOrientationUpdateProvider = WebDeviceOrientationUpdateProvider::create(*this);
    503511#endif
    504512
Note: See TracChangeset for help on using the changeset viewer.