dom/base/DOMCursor.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "DOMCursor.h"
     8 #include "mozilla/dom/DOMCursorBinding.h"
    10 namespace mozilla {
    11 namespace dom {
    13 NS_IMPL_CYCLE_COLLECTION_INHERITED(DOMCursor, DOMRequest,
    14                                    mCallback)
    16 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMCursor)
    17   NS_INTERFACE_MAP_ENTRY(nsIDOMDOMCursor)
    18 NS_INTERFACE_MAP_END_INHERITING(DOMRequest)
    20 NS_IMPL_ADDREF_INHERITED(DOMCursor, DOMRequest)
    21 NS_IMPL_RELEASE_INHERITED(DOMCursor, DOMRequest)
    23 DOMCursor::DOMCursor(nsPIDOMWindow* aWindow, nsICursorContinueCallback* aCallback)
    24   : DOMRequest(aWindow)
    25   , mCallback(aCallback)
    26   , mFinished(false)
    27 {
    28 }
    30 void
    31 DOMCursor::Reset()
    32 {
    33   MOZ_ASSERT(!mFinished);
    35   // Reset the request state so we can FireSuccess() again.
    36   mResult = JSVAL_VOID;
    37   mDone = false;
    38 }
    40 void
    41 DOMCursor::FireDone()
    42 {
    43   Reset();
    44   mFinished = true;
    45   FireSuccess(JS::UndefinedHandleValue);
    46 }
    48 NS_IMETHODIMP
    49 DOMCursor::GetDone(bool *aDone)
    50 {
    51   *aDone = Done();
    52   return NS_OK;
    53 }
    55 NS_IMETHODIMP
    56 DOMCursor::Continue()
    57 {
    58   ErrorResult rv;
    59   Continue(rv);
    60   return rv.ErrorCode();
    61 }
    63 void
    64 DOMCursor::Continue(ErrorResult& aRv)
    65 {
    66   MOZ_ASSERT(mCallback, "If you're creating your own cursor class with no callback, you should override Continue()");
    68   // We need to have a result here because we must be in a 'success' state.
    69   if (mResult == JSVAL_VOID) {
    70     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    71     return;
    72   }
    74   Reset();
    75   mCallback->HandleContinue();
    76 }
    78 /* virtual */ JSObject*
    79 DOMCursor::WrapObject(JSContext* aCx)
    80 {
    81   return DOMCursorBinding::Wrap(aCx, this);
    82 }
    84 } // namespace dom
    85 } // namespace mozilla

mercurial