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