| Index: Source/core/workers/TeleportContext.h
|
| diff --git a/Source/core/workers/TeleportContext.h b/Source/core/workers/TeleportContext.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..94881c058b8176472381b13ea287e9b6f0325ec4
|
| --- /dev/null
|
| +++ b/Source/core/workers/TeleportContext.h
|
| @@ -0,0 +1,104 @@
|
| +/*
|
| + * Copyright (C) 2014 Google Inc. All rights reserved.
|
| + *
|
| + * Redistribution and use in source and binary forms, with or without
|
| + * modification, are permitted provided that the following conditions are
|
| + * met:
|
| + *
|
| + * * Redistributions of source code must retain the above copyright
|
| + * notice, this list of conditions and the following disclaimer.
|
| + * * Redistributions in binary form must reproduce the above
|
| + * copyright notice, this list of conditions and the following disclaimer
|
| + * in the documentation and/or other materials provided with the
|
| + * distribution.
|
| + * * Neither the name of Google Inc. nor the names of its
|
| + * contributors may be used to endorse or promote products derived from
|
| + * this software without specific prior written permission.
|
| + *
|
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| + */
|
| +
|
| +#ifndef TeleportContext_h
|
| +#define TeleportContext_h
|
| +
|
| +#include "core/css/CSSMatrix.h"
|
| +#include "public/platform/WebTeleportCallback.h"
|
| +#include "wtf/HashMap.h"
|
| +#include "wtf/PassOwnPtr.h"
|
| +#include "wtf/text/WTFString.h"
|
| +
|
| +namespace blink {
|
| +
|
| +class ExceptionState;
|
| +
|
| +class TeleportContext final : public RefCountedWillBeGarbageCollected<TeleportContext>, public ScriptWrappable {
|
| + DEFINE_WRAPPERTYPEINFO();
|
| +public:
|
| + static PassRefPtrWillBeRawPtr<TeleportContext> create(const Vector<String>& propertyIds)
|
| + {
|
| + return adoptRef(new TeleportContext(propertyIds));
|
| + }
|
| +
|
| + void setTimestamp(double timestamp) { m_timestamp = timestamp; }
|
| + double timestamp() const { return m_timestamp; }
|
| +
|
| + // Current state of device actuators will be available here.
|
| +
|
| + PassRefPtrWillBeRawPtr<CSSMatrix> getMatrix(const String& propertyId, ExceptionState&) const;
|
| + void setMatrix(const String& propertyId, PassRefPtrWillBeRawPtr<CSSMatrix>, ExceptionState&);
|
| +
|
| +
|
| + double getScalar(const String& propertyId, ExceptionState&) const;
|
| + void setScalar(const String& propertyId, double, ExceptionState&);
|
| +
|
| + PassOwnPtr<WebTeleportValues> getWebTeleportValues() const;
|
| + void setWebTeleportValues(const WebTeleportValues&);
|
| +
|
| +private:
|
| + TeleportContext(const Vector<String>& propertyIds);
|
| +
|
| + // Would this make more sense in the scalar values? I thought that default
|
| + // values such as timestamp and input state might be better as explicit
|
| + // members here, but I could be convinced otherwise.
|
| + double m_timestamp;
|
| +
|
| + template <typename T>
|
| + struct TeleportContextValue {
|
| + enum Mode { READ, WRITE, READ_WRITE };
|
| + TeleportContextValue(Mode mode) : initialized(false), modified(false), mode(mode) { }
|
| + // TODO -- (Glenn, what's the todo here? Was it to hook up mode?)
|
| + // yep. Which is likely not going to happen now, I think?
|
| + TeleportContextValue() : initialized(false), modified(false), mode(READ_WRITE) { }
|
| + bool initialized;
|
| + bool modified;
|
| + T value;
|
| + Mode mode;
|
| + int layer_id;
|
| +
|
| + bool isReadable() const { return mode == READ || mode == READ_WRITE; }
|
| + bool isWritable() const { return mode == WRITE || mode == READ_WRITE; }
|
| + };
|
| +
|
| + typedef TeleportContextValue<RefPtr<CSSMatrix> > MatrixValue;
|
| + typedef TeleportContextValue<double> ScalarValue;
|
| + typedef HashMap<String, MatrixValue> MatrixValues;
|
| + typedef HashMap<String, ScalarValue> ScalarValues;
|
| +
|
| + // We could almost certainly do something more performant here.
|
| + ScalarValues m_scalars;
|
| + MatrixValues m_matrices;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif
|
|
|