Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/cssom/ScaleTransformComponent.h" | 5 #ifndef Bind_h |
| 6 #define Bind_h | |
|
haraken
2016/02/15 13:18:39
(Nit: I'm not really happy that Blink's threading
Yuki
2016/02/16 07:31:58
Acknowledged.
| |
| 6 | 7 |
| 7 #include "core/css/CSSPrimitiveValue.h" | 8 #include "base/bind.h" |
| 8 #include "core/css/CSSValuePool.h" | 9 #include "mojo/public/cpp/bindings/callback.h" |
| 10 | |
| 11 // This file provides limited access to base::Bind() function. base::Bind() | |
| 12 // could be dangerous if it's used across threads, so we don't want to allow | |
| 13 // general use of base::Bind(). | |
| 14 // See also "platform/ThreadSafeFunctional.h". | |
| 9 | 15 |
| 10 namespace blink { | 16 namespace blink { |
| 11 | 17 |
| 12 PassRefPtrWillBeRawPtr<CSSFunctionValue> ScaleTransformComponent::toCSSValue() c onst | 18 // Binds an instance of a class to its member function. Does not bind anything |
| 19 // else. | |
| 20 template<typename Class, typename ReturnType, typename... Args> | |
| 21 mojo::Callback<ReturnType(Args...)> | |
| 22 bindInstanceToMethodForMojo(ReturnType (Class::*method)(Args...), Class* instanc e) | |
|
haraken
2016/02/15 13:18:39
sameThreadBindForMojo ? (Assuming that tzik@ is in
Yuki
2016/02/16 07:31:58
Done.
| |
| 13 { | 23 { |
| 14 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(m_is2 D ? CSSValueScale : CSSValueScale3d); | 24 return base::Bind(method, base::Unretained(instance)); |
| 15 | |
| 16 result->append(cssValuePool().createValue(m_x, CSSPrimitiveValue::UnitType:: Number)); | |
| 17 result->append(cssValuePool().createValue(m_y, CSSPrimitiveValue::UnitType:: Number)); | |
| 18 if (!m_is2D) | |
| 19 result->append(cssValuePool().createValue(m_z, CSSPrimitiveValue::UnitTy pe::Number)); | |
| 20 | |
| 21 return result.release(); | |
| 22 } | 25 } |
| 23 | 26 |
| 24 } // namespace blink | 27 } // namespace blink |
| 28 | |
| 29 #endif // Bind_h | |
| OLD | NEW |