Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=2:
3 */
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 "ia2AccessibleImage.h"
10 #include "AccessibleImage_i.c"
12 #include "ImageAccessibleWrap.h"
13 #include "IUnknownImpl.h"
14 #include "nsIAccessibleTypes.h"
16 #include "nsString.h"
17 #include "nsIURI.h"
19 using namespace mozilla;
20 using namespace mozilla::a11y;
22 // IUnknown
24 STDMETHODIMP
25 ia2AccessibleImage::QueryInterface(REFIID iid, void** ppv)
26 {
27 if (!ppv)
28 return E_INVALIDARG;
30 *ppv = nullptr;
32 if (IID_IAccessibleImage == iid) {
33 *ppv = static_cast<IAccessibleImage*>(this);
34 (static_cast<IUnknown*>(*ppv))->AddRef();
35 return S_OK;
36 }
38 return E_NOINTERFACE;
39 }
41 // IAccessibleImage
43 STDMETHODIMP
44 ia2AccessibleImage::get_description(BSTR* aDescription)
45 {
46 A11Y_TRYBLOCK_BEGIN
48 if (!aDescription)
49 return E_INVALIDARG;
51 *aDescription = nullptr;
53 ImageAccessibleWrap* acc = static_cast<ImageAccessibleWrap*>(this);
54 if (acc->IsDefunct())
55 return CO_E_OBJNOTCONNECTED;
57 nsAutoString description;
58 nsresult rv = acc->GetName(description);
59 if (NS_FAILED(rv))
60 return GetHRESULT(rv);
62 if (description.IsEmpty())
63 return S_FALSE;
65 *aDescription = ::SysAllocStringLen(description.get(), description.Length());
66 return *aDescription ? S_OK : E_OUTOFMEMORY;
68 A11Y_TRYBLOCK_END
69 }
71 STDMETHODIMP
72 ia2AccessibleImage::get_imagePosition(enum IA2CoordinateType aCoordType,
73 long* aX,
74 long* aY)
75 {
76 A11Y_TRYBLOCK_BEGIN
78 if (!aX || !aY)
79 return E_INVALIDARG;
81 *aX = 0;
82 *aY = 0;
84 ImageAccessibleWrap* imageAcc = static_cast<ImageAccessibleWrap*>(this);
85 if (imageAcc->IsDefunct())
86 return CO_E_OBJNOTCONNECTED;
88 uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
89 nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
90 nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
91 int32_t x = 0, y = 0;
93 nsresult rv = imageAcc->GetImagePosition(geckoCoordType, &x, &y);
94 if (NS_FAILED(rv))
95 return GetHRESULT(rv);
97 *aX = x;
98 *aY = y;
99 return S_OK;
101 A11Y_TRYBLOCK_END
102 }
104 STDMETHODIMP
105 ia2AccessibleImage::get_imageSize(long* aHeight, long* aWidth)
106 {
107 A11Y_TRYBLOCK_BEGIN
109 if (!aHeight || !aWidth)
110 return E_INVALIDARG;
112 *aHeight = 0;
113 *aWidth = 0;
115 ImageAccessibleWrap* imageAcc = static_cast<ImageAccessibleWrap*>(this);
116 if (imageAcc->IsDefunct())
117 return CO_E_OBJNOTCONNECTED;
119 int32_t width = 0, height = 0;
120 nsresult rv = imageAcc->GetImageSize(&width, &height);
121 if (NS_FAILED(rv))
122 return GetHRESULT(rv);
124 *aHeight = width;
125 *aWidth = height;
126 return S_OK;
128 A11Y_TRYBLOCK_END
129 }