2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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"
14 #include "nsObjCExceptions.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();
29 nsView* view = frame->GetView();
31 nsIWidget* widget = view->GetWidget();
33 *aOutView = (void**)widget->GetNativeData(NS_NATIVE_WIDGET);
34 MOZ_DIAGNOSTIC_ASSERT(*aOutView, "Couldn't get the native UIView!");
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);