accessible/src/windows/ia2/ia2AccessibleValue.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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.

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 "ia2AccessibleValue.h"
michael@0 9
michael@0 10 #include "AccessibleValue_i.c"
michael@0 11
michael@0 12 #include "AccessibleWrap.h"
michael@0 13 #include "Accessible-inl.h"
michael@0 14 #include "IUnknownImpl.h"
michael@0 15
michael@0 16 #include "mozilla/FloatingPoint.h"
michael@0 17
michael@0 18 using namespace mozilla::a11y;
michael@0 19
michael@0 20 // IUnknown
michael@0 21
michael@0 22 STDMETHODIMP
michael@0 23 ia2AccessibleValue::QueryInterface(REFIID iid, void** ppv)
michael@0 24 {
michael@0 25 if (!ppv)
michael@0 26 return E_INVALIDARG;
michael@0 27
michael@0 28 *ppv = nullptr;
michael@0 29
michael@0 30 if (IID_IAccessibleValue == iid) {
michael@0 31 AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
michael@0 32 if (valueAcc->HasNumericValue()) {
michael@0 33 *ppv = static_cast<IAccessibleValue*>(this);
michael@0 34 valueAcc->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 return E_NOINTERFACE;
michael@0 42 }
michael@0 43
michael@0 44 // IAccessibleValue
michael@0 45
michael@0 46 STDMETHODIMP
michael@0 47 ia2AccessibleValue::get_currentValue(VARIANT* aCurrentValue)
michael@0 48 {
michael@0 49 A11Y_TRYBLOCK_BEGIN
michael@0 50
michael@0 51 if (!aCurrentValue)
michael@0 52 return E_INVALIDARG;
michael@0 53
michael@0 54 VariantInit(aCurrentValue);
michael@0 55
michael@0 56 AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
michael@0 57 if (valueAcc->IsDefunct())
michael@0 58 return CO_E_OBJNOTCONNECTED;
michael@0 59
michael@0 60 double currentValue = valueAcc->CurValue();
michael@0 61 if (IsNaN(currentValue))
michael@0 62 return S_FALSE;
michael@0 63
michael@0 64 aCurrentValue->vt = VT_R8;
michael@0 65 aCurrentValue->dblVal = currentValue;
michael@0 66 return S_OK;
michael@0 67
michael@0 68 A11Y_TRYBLOCK_END
michael@0 69 }
michael@0 70
michael@0 71 STDMETHODIMP
michael@0 72 ia2AccessibleValue::setCurrentValue(VARIANT aValue)
michael@0 73 {
michael@0 74 A11Y_TRYBLOCK_BEGIN
michael@0 75
michael@0 76 AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
michael@0 77 if (valueAcc->IsDefunct())
michael@0 78 return CO_E_OBJNOTCONNECTED;
michael@0 79
michael@0 80 if (aValue.vt != VT_R8)
michael@0 81 return E_INVALIDARG;
michael@0 82
michael@0 83 return valueAcc->SetCurValue(aValue.dblVal) ? S_OK : E_FAIL;
michael@0 84
michael@0 85 A11Y_TRYBLOCK_END
michael@0 86 }
michael@0 87
michael@0 88 STDMETHODIMP
michael@0 89 ia2AccessibleValue::get_maximumValue(VARIANT* aMaximumValue)
michael@0 90 {
michael@0 91 A11Y_TRYBLOCK_BEGIN
michael@0 92
michael@0 93 if (!aMaximumValue)
michael@0 94 return E_INVALIDARG;
michael@0 95
michael@0 96 VariantInit(aMaximumValue);
michael@0 97
michael@0 98 AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
michael@0 99 if (valueAcc->IsDefunct())
michael@0 100 return CO_E_OBJNOTCONNECTED;
michael@0 101
michael@0 102 double maximumValue = valueAcc->MaxValue();
michael@0 103 if (IsNaN(maximumValue))
michael@0 104 return S_FALSE;
michael@0 105
michael@0 106 aMaximumValue->vt = VT_R8;
michael@0 107 aMaximumValue->dblVal = maximumValue;
michael@0 108 return S_OK;
michael@0 109
michael@0 110 A11Y_TRYBLOCK_END
michael@0 111 }
michael@0 112
michael@0 113 STDMETHODIMP
michael@0 114 ia2AccessibleValue::get_minimumValue(VARIANT* aMinimumValue)
michael@0 115 {
michael@0 116 A11Y_TRYBLOCK_BEGIN
michael@0 117
michael@0 118 if (!aMinimumValue)
michael@0 119 return E_INVALIDARG;
michael@0 120
michael@0 121 VariantInit(aMinimumValue);
michael@0 122
michael@0 123 AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
michael@0 124 if (valueAcc->IsDefunct())
michael@0 125 return CO_E_OBJNOTCONNECTED;
michael@0 126
michael@0 127 double minimumValue = valueAcc->MinValue();
michael@0 128 if (IsNaN(minimumValue))
michael@0 129 return S_FALSE;
michael@0 130
michael@0 131 aMinimumValue->vt = VT_R8;
michael@0 132 aMinimumValue->dblVal = minimumValue;
michael@0 133 return S_OK;
michael@0 134
michael@0 135 A11Y_TRYBLOCK_END
michael@0 136 }
michael@0 137

mercurial