Bumping manifests a=b2g-bump
[gecko.git] / dom / base / DOMCursor.cpp
blob1e22b2afe2d63a50fb1adcc5e1a13f35c98b3e11
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)
30 void
31 DOMCursor::Reset()
33 MOZ_ASSERT(!mFinished);
35 // Reset the request state so we can FireSuccess() again.
36 mResult = JSVAL_VOID;
37 mDone = false;
40 void
41 DOMCursor::FireDone()
43 Reset();
44 mFinished = true;
45 FireSuccess(JS::UndefinedHandleValue);
48 NS_IMETHODIMP
49 DOMCursor::GetDone(bool *aDone)
51 *aDone = Done();
52 return NS_OK;
55 NS_IMETHODIMP
56 DOMCursor::Continue()
58 ErrorResult rv;
59 Continue(rv);
60 return rv.ErrorCode();
63 void
64 DOMCursor::Continue(ErrorResult& aRv)
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;
74 Reset();
75 mCallback->HandleContinue();
78 /* virtual */ JSObject*
79 DOMCursor::WrapObject(JSContext* aCx)
81 return DOMCursorBinding::Wrap(aCx, this);
84 } // namespace dom
85 } // namespace mozilla