Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:expandtab:shiftwidth=2:tabstop=2: |
michael@0 | 3 | */ |
michael@0 | 4 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #include "ia2AccessibleImage.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "AccessibleImage_i.c" |
michael@0 | 11 | |
michael@0 | 12 | #include "ImageAccessibleWrap.h" |
michael@0 | 13 | #include "IUnknownImpl.h" |
michael@0 | 14 | #include "nsIAccessibleTypes.h" |
michael@0 | 15 | |
michael@0 | 16 | #include "nsString.h" |
michael@0 | 17 | #include "nsIURI.h" |
michael@0 | 18 | |
michael@0 | 19 | using namespace mozilla; |
michael@0 | 20 | using namespace mozilla::a11y; |
michael@0 | 21 | |
michael@0 | 22 | // IUnknown |
michael@0 | 23 | |
michael@0 | 24 | STDMETHODIMP |
michael@0 | 25 | ia2AccessibleImage::QueryInterface(REFIID iid, void** ppv) |
michael@0 | 26 | { |
michael@0 | 27 | if (!ppv) |
michael@0 | 28 | return E_INVALIDARG; |
michael@0 | 29 | |
michael@0 | 30 | *ppv = nullptr; |
michael@0 | 31 | |
michael@0 | 32 | if (IID_IAccessibleImage == iid) { |
michael@0 | 33 | *ppv = static_cast<IAccessibleImage*>(this); |
michael@0 | 34 | (static_cast<IUnknown*>(*ppv))->AddRef(); |
michael@0 | 35 | return S_OK; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | return E_NOINTERFACE; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | // IAccessibleImage |
michael@0 | 42 | |
michael@0 | 43 | STDMETHODIMP |
michael@0 | 44 | ia2AccessibleImage::get_description(BSTR* aDescription) |
michael@0 | 45 | { |
michael@0 | 46 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 47 | |
michael@0 | 48 | if (!aDescription) |
michael@0 | 49 | return E_INVALIDARG; |
michael@0 | 50 | |
michael@0 | 51 | *aDescription = nullptr; |
michael@0 | 52 | |
michael@0 | 53 | ImageAccessibleWrap* acc = static_cast<ImageAccessibleWrap*>(this); |
michael@0 | 54 | if (acc->IsDefunct()) |
michael@0 | 55 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 56 | |
michael@0 | 57 | nsAutoString description; |
michael@0 | 58 | nsresult rv = acc->GetName(description); |
michael@0 | 59 | if (NS_FAILED(rv)) |
michael@0 | 60 | return GetHRESULT(rv); |
michael@0 | 61 | |
michael@0 | 62 | if (description.IsEmpty()) |
michael@0 | 63 | return S_FALSE; |
michael@0 | 64 | |
michael@0 | 65 | *aDescription = ::SysAllocStringLen(description.get(), description.Length()); |
michael@0 | 66 | return *aDescription ? S_OK : E_OUTOFMEMORY; |
michael@0 | 67 | |
michael@0 | 68 | A11Y_TRYBLOCK_END |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | STDMETHODIMP |
michael@0 | 72 | ia2AccessibleImage::get_imagePosition(enum IA2CoordinateType aCoordType, |
michael@0 | 73 | long* aX, |
michael@0 | 74 | long* aY) |
michael@0 | 75 | { |
michael@0 | 76 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 77 | |
michael@0 | 78 | if (!aX || !aY) |
michael@0 | 79 | return E_INVALIDARG; |
michael@0 | 80 | |
michael@0 | 81 | *aX = 0; |
michael@0 | 82 | *aY = 0; |
michael@0 | 83 | |
michael@0 | 84 | ImageAccessibleWrap* imageAcc = static_cast<ImageAccessibleWrap*>(this); |
michael@0 | 85 | if (imageAcc->IsDefunct()) |
michael@0 | 86 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 87 | |
michael@0 | 88 | uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ? |
michael@0 | 89 | nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE : |
michael@0 | 90 | nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE; |
michael@0 | 91 | int32_t x = 0, y = 0; |
michael@0 | 92 | |
michael@0 | 93 | nsresult rv = imageAcc->GetImagePosition(geckoCoordType, &x, &y); |
michael@0 | 94 | if (NS_FAILED(rv)) |
michael@0 | 95 | return GetHRESULT(rv); |
michael@0 | 96 | |
michael@0 | 97 | *aX = x; |
michael@0 | 98 | *aY = y; |
michael@0 | 99 | return S_OK; |
michael@0 | 100 | |
michael@0 | 101 | A11Y_TRYBLOCK_END |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | STDMETHODIMP |
michael@0 | 105 | ia2AccessibleImage::get_imageSize(long* aHeight, long* aWidth) |
michael@0 | 106 | { |
michael@0 | 107 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 108 | |
michael@0 | 109 | if (!aHeight || !aWidth) |
michael@0 | 110 | return E_INVALIDARG; |
michael@0 | 111 | |
michael@0 | 112 | *aHeight = 0; |
michael@0 | 113 | *aWidth = 0; |
michael@0 | 114 | |
michael@0 | 115 | ImageAccessibleWrap* imageAcc = static_cast<ImageAccessibleWrap*>(this); |
michael@0 | 116 | if (imageAcc->IsDefunct()) |
michael@0 | 117 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 118 | |
michael@0 | 119 | int32_t width = 0, height = 0; |
michael@0 | 120 | nsresult rv = imageAcc->GetImageSize(&width, &height); |
michael@0 | 121 | if (NS_FAILED(rv)) |
michael@0 | 122 | return GetHRESULT(rv); |
michael@0 | 123 | |
michael@0 | 124 | *aHeight = width; |
michael@0 | 125 | *aWidth = height; |
michael@0 | 126 | return S_OK; |
michael@0 | 127 | |
michael@0 | 128 | A11Y_TRYBLOCK_END |
michael@0 | 129 | } |
michael@0 | 130 |