Bug 1877642 - Disable browser_fullscreen-tab-close-race.js on apple_silicon !debug...
[gecko.git] / accessible / ios / RootAccessibleWrap.mm
blob1d2a4041617566b06ebc032366565142dfe814e8
1 /* clang-format off */
2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* clang-format on */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "RootAccessibleWrap.h"
10 #include "MUIRootAccessible.h"
12 #include "gfxPlatform.h"
13 #include "nsCOMPtr.h"
14 #include "nsObjCExceptions.h"
15 #include "nsIFrame.h"
16 #include "nsView.h"
17 #include "nsIWidget.h"
19 using namespace mozilla;
20 using namespace mozilla::a11y;
22 RootAccessibleWrap::RootAccessibleWrap(dom::Document* aDocument,
23                                        PresShell* aPresShell)
24     : RootAccessible(aDocument, aPresShell) {}
26 void RootAccessibleWrap::GetNativeWidget(void** aOutView) {
27   nsIFrame* frame = GetFrame();
28   if (frame) {
29     nsView* view = frame->GetView();
30     if (view) {
31       nsIWidget* widget = view->GetWidget();
32       if (widget) {
33         *aOutView = (void**)widget->GetNativeData(NS_NATIVE_WIDGET);
34         MOZ_DIAGNOSTIC_ASSERT(*aOutView, "Couldn't get the native UIView!");
35       }
36     }
37   }
40 CGRect RootAccessibleWrap::DevPixelsRectToUIKit(
41     const LayoutDeviceIntRect& aRect) {
42   UIView* nativeWidget = nil;
43   GetNativeWidget((void**)&nativeWidget);
44   CGRect rootFrame = [nativeWidget accessibilityFrame];
45   CGFloat scale = [nativeWidget contentScaleFactor];
46   return CGRectMake(((CGFloat)aRect.x / scale) + rootFrame.origin.x,
47                     ((CGFloat)aRect.y / scale) + rootFrame.origin.y,
48                     (CGFloat)aRect.width / scale,
49                     (CGFloat)aRect.height / scale);