| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are |
| 6 * met: |
| 7 * |
| 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. |
| 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ |
| 30 |
| 31 #ifndef TeleportContext_h |
| 32 #define TeleportContext_h |
| 33 |
| 34 #include "core/css/CSSMatrix.h" |
| 35 #include "public/platform/WebTeleportCallback.h" |
| 36 #include "wtf/HashMap.h" |
| 37 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/text/WTFString.h" |
| 39 |
| 40 namespace blink { |
| 41 |
| 42 class ExceptionState; |
| 43 |
| 44 class TeleportContext final : public RefCountedWillBeGarbageCollected<TeleportCo
ntext>, public ScriptWrappable { |
| 45 DEFINE_WRAPPERTYPEINFO(); |
| 46 public: |
| 47 static PassRefPtrWillBeRawPtr<TeleportContext> create(const Vector<String>&
propertyIds) |
| 48 { |
| 49 return adoptRef(new TeleportContext(propertyIds)); |
| 50 } |
| 51 |
| 52 void setTimestamp(double timestamp) { m_timestamp = timestamp; } |
| 53 double timestamp() const { return m_timestamp; } |
| 54 |
| 55 // Current state of device actuators will be available here. |
| 56 |
| 57 PassRefPtrWillBeRawPtr<CSSMatrix> getMatrix(const String& propertyId, Except
ionState&) const; |
| 58 void setMatrix(const String& propertyId, PassRefPtrWillBeRawPtr<CSSMatrix>,
ExceptionState&); |
| 59 |
| 60 |
| 61 double getScalar(const String& propertyId, ExceptionState&) const; |
| 62 void setScalar(const String& propertyId, double, ExceptionState&); |
| 63 |
| 64 PassOwnPtr<WebTeleportValues> getWebTeleportValues() const; |
| 65 void setWebTeleportValues(const WebTeleportValues&); |
| 66 |
| 67 private: |
| 68 TeleportContext(const Vector<String>& propertyIds); |
| 69 |
| 70 // Would this make more sense in the scalar values? I thought that default |
| 71 // values such as timestamp and input state might be better as explicit |
| 72 // members here, but I could be convinced otherwise. |
| 73 double m_timestamp; |
| 74 |
| 75 template <typename T> |
| 76 struct TeleportContextValue { |
| 77 enum Mode { READ, WRITE, READ_WRITE }; |
| 78 TeleportContextValue(Mode mode) : initialized(false), modified(false), m
ode(mode) { } |
| 79 // TODO -- (Glenn, what's the todo here? Was it to hook up mode?) |
| 80 // yep. Which is likely not going to happen now, I think? |
| 81 TeleportContextValue() : initialized(false), modified(false), mode(READ_
WRITE) { } |
| 82 bool initialized; |
| 83 bool modified; |
| 84 T value; |
| 85 Mode mode; |
| 86 int layer_id; |
| 87 |
| 88 bool isReadable() const { return mode == READ || mode == READ_WRITE; } |
| 89 bool isWritable() const { return mode == WRITE || mode == READ_WRITE; } |
| 90 }; |
| 91 |
| 92 typedef TeleportContextValue<RefPtr<CSSMatrix> > MatrixValue; |
| 93 typedef TeleportContextValue<double> ScalarValue; |
| 94 typedef HashMap<String, MatrixValue> MatrixValues; |
| 95 typedef HashMap<String, ScalarValue> ScalarValues; |
| 96 |
| 97 // We could almost certainly do something more performant here. |
| 98 ScalarValues m_scalars; |
| 99 MatrixValues m_matrices; |
| 100 }; |
| 101 |
| 102 } // namespace blink |
| 103 |
| 104 #endif |
| OLD | NEW |