Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | var gTreeUtils = { |
michael@0 | 8 | deleteAll: function (aTree, aView, aItems, aDeletedItems) |
michael@0 | 9 | { |
michael@0 | 10 | for (var i = 0; i < aItems.length; ++i) |
michael@0 | 11 | aDeletedItems.push(aItems[i]); |
michael@0 | 12 | aItems.splice(0, aItems.length); |
michael@0 | 13 | var oldCount = aView.rowCount; |
michael@0 | 14 | aView._rowCount = 0; |
michael@0 | 15 | aTree.treeBoxObject.rowCountChanged(0, -oldCount); |
michael@0 | 16 | }, |
michael@0 | 17 | |
michael@0 | 18 | deleteSelectedItems: function (aTree, aView, aItems, aDeletedItems) |
michael@0 | 19 | { |
michael@0 | 20 | var selection = aTree.view.selection; |
michael@0 | 21 | selection.selectEventsSuppressed = true; |
michael@0 | 22 | |
michael@0 | 23 | var rc = selection.getRangeCount(); |
michael@0 | 24 | for (var i = 0; i < rc; ++i) { |
michael@0 | 25 | var min = { }; var max = { }; |
michael@0 | 26 | selection.getRangeAt(i, min, max); |
michael@0 | 27 | for (var j = min.value; j <= max.value; ++j) { |
michael@0 | 28 | aDeletedItems.push(aItems[j]); |
michael@0 | 29 | aItems[j] = null; |
michael@0 | 30 | } |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | var nextSelection = 0; |
michael@0 | 34 | for (i = 0; i < aItems.length; ++i) { |
michael@0 | 35 | if (!aItems[i]) { |
michael@0 | 36 | var j = i; |
michael@0 | 37 | while (j < aItems.length && !aItems[j]) |
michael@0 | 38 | ++j; |
michael@0 | 39 | aItems.splice(i, j - i); |
michael@0 | 40 | nextSelection = j < aView.rowCount ? j - 1 : j - 2; |
michael@0 | 41 | aView._rowCount -= j - i; |
michael@0 | 42 | aTree.treeBoxObject.rowCountChanged(i, i - j); |
michael@0 | 43 | } |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | if (aItems.length) { |
michael@0 | 47 | selection.select(nextSelection); |
michael@0 | 48 | aTree.treeBoxObject.ensureRowIsVisible(nextSelection); |
michael@0 | 49 | aTree.focus(); |
michael@0 | 50 | } |
michael@0 | 51 | selection.selectEventsSuppressed = false; |
michael@0 | 52 | }, |
michael@0 | 53 | |
michael@0 | 54 | sort: function (aTree, aView, aDataSet, aColumn, aComparator, |
michael@0 | 55 | aLastSortColumn, aLastSortAscending) |
michael@0 | 56 | { |
michael@0 | 57 | var ascending = (aColumn == aLastSortColumn) ? !aLastSortAscending : true; |
michael@0 | 58 | if (aDataSet.length == 0) |
michael@0 | 59 | return ascending; |
michael@0 | 60 | |
michael@0 | 61 | var numericSort = !isNaN(aDataSet[0][aColumn]); |
michael@0 | 62 | var sortFunction = null; |
michael@0 | 63 | if (aComparator) { |
michael@0 | 64 | sortFunction = function (a, b) { return aComparator(a[aColumn], b[aColumn]); }; |
michael@0 | 65 | } |
michael@0 | 66 | aDataSet.sort(sortFunction); |
michael@0 | 67 | if (!ascending) |
michael@0 | 68 | aDataSet.reverse(); |
michael@0 | 69 | |
michael@0 | 70 | aTree.view.selection.clearSelection(); |
michael@0 | 71 | aTree.view.selection.select(0); |
michael@0 | 72 | aTree.treeBoxObject.invalidate(); |
michael@0 | 73 | aTree.treeBoxObject.ensureRowIsVisible(0); |
michael@0 | 74 | |
michael@0 | 75 | return ascending; |
michael@0 | 76 | } |
michael@0 | 77 | }; |
michael@0 | 78 |