| Index: Source/core/dom/CompositorProxy.cpp
|
| diff --git a/Source/core/dom/CompositorProxy.cpp b/Source/core/dom/CompositorProxy.cpp
|
| index 088ee933df679f4246e048335c280b1375a8c8f8..21ce9ab4fa707c105668305f6288871fc4321ead 100644
|
| --- a/Source/core/dom/CompositorProxy.cpp
|
| +++ b/Source/core/dom/CompositorProxy.cpp
|
| @@ -31,6 +31,30 @@ static uint64_t compositorProxyIdForElement(Element* element)
|
| return gElementIdMap->get(element);
|
| }
|
|
|
| +static bool isControlThread()
|
| +{
|
| + return !isMainThread();
|
| +}
|
| +
|
| +static bool isCallingCompositorFrameCallback()
|
| +{
|
| + // TODO(sad):
|
| + return true;
|
| +}
|
| +
|
| +static bool raiseExceptionIfMutationNotAllowed(ExceptionState& exceptionState)
|
| +{
|
| + if (!isControlThread()) {
|
| + exceptionState.throwTypeError("Cannot mutate a proxy attribute from the main page.");
|
| + return true;
|
| + }
|
| + if (!isCallingCompositorFrameCallback()) {
|
| + exceptionState.throwTypeError("Cannot mutate a proxy attribute outside of a requestCompositorFrame callback.");
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| static struct {
|
| const char* name;
|
| CompositorProxy::Attributes attribute;
|
| @@ -78,7 +102,7 @@ CompositorProxy* CompositorProxy::create(ExecutionContext* context, Element* ele
|
|
|
| CompositorProxy* CompositorProxy::create(uint64_t elementId, uint32_t attributeFlags)
|
| {
|
| - ASSERT(!isMainThread());
|
| + ASSERT(isControlThread());
|
| #ifndef NDEBUG
|
| uint32_t sanityCheckAttributes = attributeFlags;
|
| for (unsigned i = 0; i < arraysize(allowedAttributes); ++i) {
|
| @@ -91,7 +115,8 @@ CompositorProxy* CompositorProxy::create(uint64_t elementId, uint32_t attributeF
|
|
|
| CompositorProxy::CompositorProxy(Element* element, uint32_t attributeFlags)
|
| : m_elementId(compositorProxyIdForElement(element))
|
| - , m_attributes(attributeFlags)
|
| + , m_mutableAttributes(attributeFlags)
|
| + , m_mutatedAttributes(0)
|
| {
|
| ASSERT(isMainThread());
|
| ASSERT(gElementMap);
|
| @@ -100,7 +125,8 @@ CompositorProxy::CompositorProxy(Element* element, uint32_t attributeFlags)
|
|
|
| CompositorProxy::CompositorProxy(uint64_t elementId, uint32_t attributeFlags)
|
| : m_elementId(elementId)
|
| - , m_attributes(attributeFlags)
|
| + , m_mutableAttributes(attributeFlags)
|
| + , m_mutatedAttributes(0)
|
| {
|
| }
|
|
|
| @@ -117,4 +143,67 @@ void CompositorProxy::notifyElementGone(Element* element)
|
| gElementMap->remove(gElementIdMap->take(element));
|
| }
|
|
|
| +double CompositorProxy::opacity(ExceptionState& exceptionState) const
|
| +{
|
| + if (UNLIKELY(raiseExceptionIfMutationNotAllowed(exceptionState)))
|
| + return 0.0;
|
| + return m_opacity;
|
| +}
|
| +
|
| +double CompositorProxy::scrollTop(ExceptionState& exceptionState) const
|
| +{
|
| + if (UNLIKELY(raiseExceptionIfMutationNotAllowed(exceptionState)))
|
| + return 0.0;
|
| + return m_scrollTop;
|
| +}
|
| +
|
| +Vector<double> CompositorProxy::transform(ExceptionState& exceptionState) const
|
| +{
|
| + if (UNLIKELY(raiseExceptionIfMutationNotAllowed(exceptionState)))
|
| + return Vector<double>();
|
| + return Vector<double>(m_transform);
|
| +}
|
| +
|
| +void CompositorProxy::setOpacity(double opacity, ExceptionState& exceptionState)
|
| +{
|
| + if (UNLIKELY(raiseExceptionIfMutationNotAllowed(exceptionState)))
|
| + return;
|
| + if (UNLIKELY(raiseExceptionIfNotMutable(Attributes::OPACITY, exceptionState)))
|
| + return;
|
| + m_opacity = opacity;
|
| + m_mutatedAttributes |= static_cast<uint32_t>(Attributes::OPACITY);
|
| +}
|
| +
|
| +void CompositorProxy::setScrollTop(double scrollTop, ExceptionState& exceptionState)
|
| +{
|
| + if (UNLIKELY(raiseExceptionIfMutationNotAllowed(exceptionState)))
|
| + return;
|
| + if (UNLIKELY(raiseExceptionIfNotMutable(Attributes::SCROLL_TOP, exceptionState)))
|
| + return;
|
| + m_scrollTop = scrollTop;
|
| + m_mutatedAttributes |= static_cast<uint32_t>(Attributes::SCROLL_TOP);
|
| +}
|
| +
|
| +void CompositorProxy::setTransform(const Vector<double>& transform, ExceptionState& exceptionState)
|
| +{
|
| + if (UNLIKELY(raiseExceptionIfMutationNotAllowed(exceptionState)))
|
| + return;
|
| + if (UNLIKELY(raiseExceptionIfNotMutable(Attributes::TRANSFORM, exceptionState)))
|
| + return;
|
| + if (UNLIKELY(transform.size() != m_transform.size())) {
|
| + exceptionState.throwTypeError("Incorrect size of the transform array.");
|
| + return;
|
| + }
|
| + m_transform = transform;
|
| + m_mutatedAttributes |= static_cast<uint32_t>(Attributes::TRANSFORM);
|
| +}
|
| +
|
| +bool CompositorProxy::raiseExceptionIfNotMutable(Attributes attribute, ExceptionState& exceptionState) const
|
| +{
|
| + if (m_mutableAttributes & static_cast<uint32_t>(attribute))
|
| + return false;
|
| + exceptionState.throwTypeError("Attempted to mutate non-mutable attribute.");
|
| + return true;
|
| +}
|
| +
|
| } // namespace blink
|
|
|