Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/dom/CompositorProxy.h" | 5 #include "core/dom/CompositorProxy.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionMessages.h" | 7 #include "bindings/core/v8/ExceptionMessages.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/dom/CompositorWorkerProxyClient.h" | 9 #include "core/dom/CompositorWorkerProxyClient.h" |
| 10 #include "core/dom/DOMNodeIds.h" | 10 #include "core/dom/DOMNodeIds.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 CompositorProxy* CompositorProxy::create(ExecutionContext* context, | 108 CompositorProxy* CompositorProxy::create(ExecutionContext* context, |
| 109 Element* element, | 109 Element* element, |
| 110 const Vector<String>& attributeArray, | 110 const Vector<String>& attributeArray, |
| 111 ExceptionState& exceptionState) { | 111 ExceptionState& exceptionState) { |
| 112 if (!context->isDocument()) { | 112 if (!context->isDocument()) { |
| 113 exceptionState.throwTypeError(ExceptionMessages::failedToConstruct( | 113 exceptionState.throwTypeError(ExceptionMessages::failedToConstruct( |
| 114 "CompositorProxy", "Can only be created from the main context.")); | 114 "CompositorProxy", "Can only be created from the main context.")); |
| 115 return nullptr; | 115 return nullptr; |
| 116 } | 116 } |
| 117 | 117 |
| 118 return new CompositorProxy(*element, attributeArray); | 118 Document* document = toDocument(context); |
| 119 Node* scrollingNode = element; | |
| 120 // The scrolling layer for the root scrolling element is attached to the | |
| 121 // document. So use document as scrolling node when creating a proxy to ensure | |
| 122 // we mutate the correct scroll layer. | |
| 123 // TODO(majidvp): Consider checking against | |
| 124 // |RootScrollerController::effectiveRootScroller| instead of | |
| 125 // |Document::scrollingElement|. | |
| 126 if (element->isSameNode(document->scrollingElement())) | |
| 127 scrollingNode = document; | |
|
flackr
2017/03/01 16:31:26
It seems like the proper fix would be for cc to se
| |
| 128 return new CompositorProxy(*element, *scrollingNode, attributeArray); | |
| 119 } | 129 } |
| 120 | 130 |
| 121 CompositorProxy* CompositorProxy::create(ExecutionContext* context, | 131 CompositorProxy* CompositorProxy::create(ExecutionContext* context, |
| 122 uint64_t elementId, | 132 uint64_t elementId, |
| 133 uint64_t scrollingNodeId, | |
| 123 uint32_t compositorMutableProperties) { | 134 uint32_t compositorMutableProperties) { |
| 124 if (context->isCompositorWorkerGlobalScope()) { | 135 if (context->isCompositorWorkerGlobalScope()) { |
| 125 WorkerClients* clients = toWorkerGlobalScope(context)->clients(); | 136 WorkerClients* clients = toWorkerGlobalScope(context)->clients(); |
| 126 DCHECK(clients); | 137 DCHECK(clients); |
| 127 CompositorWorkerProxyClient* client = | 138 CompositorWorkerProxyClient* client = |
| 128 CompositorWorkerProxyClient::from(clients); | 139 CompositorWorkerProxyClient::from(clients); |
| 129 return new CompositorProxy(elementId, compositorMutableProperties, client); | 140 return new CompositorProxy(elementId, scrollingNodeId, |
| 141 compositorMutableProperties, client); | |
| 130 } | 142 } |
| 131 | 143 |
| 132 return new CompositorProxy(elementId, compositorMutableProperties); | 144 return new CompositorProxy(elementId, scrollingNodeId, |
| 145 compositorMutableProperties); | |
| 133 } | 146 } |
| 134 | 147 |
| 135 CompositorProxy::CompositorProxy(uint64_t elementId, | 148 CompositorProxy::CompositorProxy(uint64_t elementId, |
| 149 uint64_t scrollingNodeId, | |
| 136 uint32_t compositorMutableProperties) | 150 uint32_t compositorMutableProperties) |
| 137 : m_elementId(elementId), | 151 : m_elementId(elementId), |
| 152 m_scrollingNodeId(scrollingNodeId), | |
| 138 m_compositorMutableProperties(compositorMutableProperties), | 153 m_compositorMutableProperties(compositorMutableProperties), |
| 139 m_client(nullptr) { | 154 m_client(nullptr) { |
| 140 DCHECK(m_compositorMutableProperties); | 155 DCHECK(m_compositorMutableProperties); |
| 141 #if DCHECK_IS_ON() | 156 #if DCHECK_IS_ON() |
| 142 DCHECK(sanityCheckMutableProperties(m_compositorMutableProperties)); | 157 DCHECK(sanityCheckMutableProperties(m_compositorMutableProperties)); |
| 143 #endif | 158 #endif |
| 144 | 159 |
| 145 if (isMainThread()) { | 160 if (isMainThread()) { |
| 146 incrementCompositorProxiedPropertiesForElement( | 161 incrementCompositorProxiedPropertiesForElement( |
| 147 m_elementId, m_compositorMutableProperties); | 162 m_elementId, m_compositorMutableProperties); |
| 148 } else { | 163 } else { |
| 149 Platform::current()->mainThread()->getWebTaskRunner()->postTask( | 164 Platform::current()->mainThread()->getWebTaskRunner()->postTask( |
| 150 BLINK_FROM_HERE, | 165 BLINK_FROM_HERE, |
| 151 crossThreadBind(&incrementCompositorProxiedPropertiesForElement, | 166 crossThreadBind(&incrementCompositorProxiedPropertiesForElement, |
| 152 m_elementId, m_compositorMutableProperties)); | 167 m_elementId, m_compositorMutableProperties)); |
| 153 } | 168 } |
| 154 } | 169 } |
| 155 | 170 |
| 156 CompositorProxy::CompositorProxy(Element& element, | 171 CompositorProxy::CompositorProxy(Element& element, |
| 172 Node& scrollingNode, | |
| 157 const Vector<String>& attributeArray) | 173 const Vector<String>& attributeArray) |
| 158 : CompositorProxy(DOMNodeIds::idForNode(&element), | 174 : CompositorProxy(DOMNodeIds::idForNode(&element), |
| 175 DOMNodeIds::idForNode(&scrollingNode), | |
| 159 compositorMutablePropertiesFromNames(attributeArray)) { | 176 compositorMutablePropertiesFromNames(attributeArray)) { |
| 160 DCHECK(isMainThread()); | 177 DCHECK(isMainThread()); |
| 161 } | 178 } |
| 162 | 179 |
| 163 CompositorProxy::CompositorProxy(uint64_t elementId, | 180 CompositorProxy::CompositorProxy(uint64_t elementId, |
| 181 uint64_t scrollingNodeId, | |
| 164 uint32_t compositorMutableProperties, | 182 uint32_t compositorMutableProperties, |
| 165 CompositorProxyClient* client) | 183 CompositorProxyClient* client) |
| 166 : CompositorProxy(elementId, compositorMutableProperties) { | 184 : CompositorProxy(elementId, scrollingNodeId, compositorMutableProperties) { |
| 167 m_client = client; | 185 m_client = client; |
| 168 DCHECK(m_client); | 186 DCHECK(m_client); |
| 169 DCHECK(isControlThread()); | 187 DCHECK(isControlThread()); |
| 170 m_client->registerCompositorProxy(this); | 188 m_client->registerCompositorProxy(this); |
| 171 } | 189 } |
| 172 | 190 |
| 173 CompositorProxy::~CompositorProxy() { | 191 CompositorProxy::~CompositorProxy() { |
| 174 // We do not explicitly unregister from client here. The client has a weak | 192 // We do not explicitly unregister from client here. The client has a weak |
| 175 // reference to us which gets collected on its own. This way we avoid using | 193 // reference to us which gets collected on its own. This way we avoid using |
| 176 // a pre-finalizer. | 194 // a pre-finalizer. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 m_elementId, m_compositorMutableProperties); | 317 m_elementId, m_compositorMutableProperties); |
| 300 } else { | 318 } else { |
| 301 Platform::current()->mainThread()->getWebTaskRunner()->postTask( | 319 Platform::current()->mainThread()->getWebTaskRunner()->postTask( |
| 302 BLINK_FROM_HERE, | 320 BLINK_FROM_HERE, |
| 303 crossThreadBind(&decrementCompositorProxiedPropertiesForElement, | 321 crossThreadBind(&decrementCompositorProxiedPropertiesForElement, |
| 304 m_elementId, m_compositorMutableProperties)); | 322 m_elementId, m_compositorMutableProperties)); |
| 305 } | 323 } |
| 306 } | 324 } |
| 307 | 325 |
| 308 } // namespace blink | 326 } // namespace blink |
| OLD | NEW |