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 "ia2AccessibleHypertext.h"
10 #include "AccessibleHypertext_i.c"
12 #include "HyperTextAccessibleWrap.h"
13 #include "IUnknownImpl.h"
15 using namespace mozilla::a11y;
17 // IAccessibleHypertext
19 STDMETHODIMP
20 ia2AccessibleHypertext::get_nHyperlinks(long* aHyperlinkCount)
21 {
22 A11Y_TRYBLOCK_BEGIN
24 if (!aHyperlinkCount)
25 return E_INVALIDARG;
27 *aHyperlinkCount = 0;
29 HyperTextAccessibleWrap* hyperText = static_cast<HyperTextAccessibleWrap*>(this);
30 if (hyperText->IsDefunct())
31 return CO_E_OBJNOTCONNECTED;
33 *aHyperlinkCount = hyperText->LinkCount();
34 return S_OK;
36 A11Y_TRYBLOCK_END
37 }
39 STDMETHODIMP
40 ia2AccessibleHypertext::get_hyperlink(long aLinkIndex,
41 IAccessibleHyperlink** aHyperlink)
42 {
43 A11Y_TRYBLOCK_BEGIN
45 if (!aHyperlink)
46 return E_INVALIDARG;
48 *aHyperlink = nullptr;
50 HyperTextAccessibleWrap* hyperText = static_cast<HyperTextAccessibleWrap*>(this);
51 if (hyperText->IsDefunct())
52 return CO_E_OBJNOTCONNECTED;
54 Accessible* hyperLink = hyperText->LinkAt(aLinkIndex);
55 if (!hyperLink)
56 return E_FAIL;
58 *aHyperlink =
59 static_cast<IAccessibleHyperlink*>(static_cast<AccessibleWrap*>(hyperLink));
60 (*aHyperlink)->AddRef();
61 return S_OK;
63 A11Y_TRYBLOCK_END
64 }
66 STDMETHODIMP
67 ia2AccessibleHypertext::get_hyperlinkIndex(long aCharIndex, long* aHyperlinkIndex)
68 {
69 A11Y_TRYBLOCK_BEGIN
71 if (!aHyperlinkIndex)
72 return E_INVALIDARG;
74 *aHyperlinkIndex = 0;
76 HyperTextAccessibleWrap* hyperAcc = static_cast<HyperTextAccessibleWrap*>(this);
77 if (hyperAcc->IsDefunct())
78 return CO_E_OBJNOTCONNECTED;
80 *aHyperlinkIndex = hyperAcc->LinkIndexAtOffset(aCharIndex);
81 return S_OK;
83 A11Y_TRYBLOCK_END
84 }