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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "HTMLWin32ObjectAccessible.h" |
michael@0 | 7 | |
michael@0 | 8 | #include "Role.h" |
michael@0 | 9 | #include "States.h" |
michael@0 | 10 | |
michael@0 | 11 | using namespace mozilla::a11y; |
michael@0 | 12 | |
michael@0 | 13 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 14 | // HTMLWin32ObjectOwnerAccessible |
michael@0 | 15 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 16 | |
michael@0 | 17 | HTMLWin32ObjectOwnerAccessible:: |
michael@0 | 18 | HTMLWin32ObjectOwnerAccessible(nsIContent* aContent, |
michael@0 | 19 | DocAccessible* aDoc, void* aHwnd) : |
michael@0 | 20 | AccessibleWrap(aContent, aDoc), mHwnd(aHwnd) |
michael@0 | 21 | { |
michael@0 | 22 | // Our only child is a HTMLWin32ObjectAccessible object. |
michael@0 | 23 | if (mHwnd) |
michael@0 | 24 | mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 28 | // HTMLWin32ObjectOwnerAccessible: Accessible implementation |
michael@0 | 29 | |
michael@0 | 30 | void |
michael@0 | 31 | HTMLWin32ObjectOwnerAccessible::Shutdown() |
michael@0 | 32 | { |
michael@0 | 33 | AccessibleWrap::Shutdown(); |
michael@0 | 34 | mNativeAccessible = nullptr; |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | role |
michael@0 | 38 | HTMLWin32ObjectOwnerAccessible::NativeRole() |
michael@0 | 39 | { |
michael@0 | 40 | return roles::EMBEDDED_OBJECT; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | bool |
michael@0 | 44 | HTMLWin32ObjectOwnerAccessible::NativelyUnavailable() const |
michael@0 | 45 | { |
michael@0 | 46 | // XXX: No HWND means this is windowless plugin which is not accessible in |
michael@0 | 47 | // the meantime. |
michael@0 | 48 | return !mHwnd; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 52 | // HTMLWin32ObjectOwnerAccessible: Accessible protected implementation |
michael@0 | 53 | |
michael@0 | 54 | void |
michael@0 | 55 | HTMLWin32ObjectOwnerAccessible::CacheChildren() |
michael@0 | 56 | { |
michael@0 | 57 | if (mNativeAccessible) |
michael@0 | 58 | AppendChild(mNativeAccessible); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | |
michael@0 | 62 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 63 | // HTMLWin32ObjectAccessible |
michael@0 | 64 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 65 | |
michael@0 | 66 | HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd) : |
michael@0 | 67 | DummyAccessible() |
michael@0 | 68 | { |
michael@0 | 69 | mHwnd = aHwnd; |
michael@0 | 70 | if (mHwnd) { |
michael@0 | 71 | // The plugin is not windowless. In this situation we use |
michael@0 | 72 | // use its inner child owned by the plugin so that we don't get |
michael@0 | 73 | // in an infinite loop, where the WM_GETOBJECT's get forwarded |
michael@0 | 74 | // back to us and create another HTMLWin32ObjectAccessible |
michael@0 | 75 | HWND childWnd = ::GetWindow((HWND)aHwnd, GW_CHILD); |
michael@0 | 76 | if (childWnd) { |
michael@0 | 77 | mHwnd = childWnd; |
michael@0 | 78 | } |
michael@0 | 79 | } |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | NS_IMETHODIMP |
michael@0 | 83 | HTMLWin32ObjectAccessible::GetNativeInterface(void** aNativeAccessible) |
michael@0 | 84 | { |
michael@0 | 85 | if (mHwnd) { |
michael@0 | 86 | ::AccessibleObjectFromWindow(static_cast<HWND>(mHwnd), |
michael@0 | 87 | OBJID_WINDOW, IID_IAccessible, |
michael@0 | 88 | aNativeAccessible); |
michael@0 | 89 | } |
michael@0 | 90 | return NS_OK; |
michael@0 | 91 | } |
michael@0 | 92 |