Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/WebKit/Source/core/dom/CompositorProxy.cpp

Issue 2041193005: [compositorworker] compositor proxy mutation updates underlying layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor-worker-upstream-registration
Patch Set: raise if not initialized Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/DOMNodeIds.h" 9 #include "core/dom/DOMNodeIds.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 { 171 {
172 return m_compositorMutableProperties & compositorMutablePropertyForName(attr ibuteName); 172 return m_compositorMutableProperties & compositorMutablePropertyForName(attr ibuteName);
173 } 173 }
174 174
175 double CompositorProxy::opacity(ExceptionState& exceptionState) const 175 double CompositorProxy::opacity(ExceptionState& exceptionState) const
176 { 176 {
177 if (raiseExceptionIfMutationNotAllowed(exceptionState)) 177 if (raiseExceptionIfMutationNotAllowed(exceptionState))
178 return 0.0; 178 return 0.0;
179 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptio nState)) 179 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptio nState))
180 return 0.0; 180 return 0.0;
181 return m_opacity; 181 return m_state->opacity();
182 } 182 }
183 183
184 double CompositorProxy::scrollLeft(ExceptionState& exceptionState) const 184 double CompositorProxy::scrollLeft(ExceptionState& exceptionState) const
185 { 185 {
186 if (raiseExceptionIfMutationNotAllowed(exceptionState)) 186 if (raiseExceptionIfMutationNotAllowed(exceptionState))
187 return 0.0; 187 return 0.0;
188 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, excep tionState)) 188 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, excep tionState))
189 return 0.0; 189 return 0.0;
190 return m_scrollLeft; 190 return m_state->scrollLeft();
191 } 191 }
192 192
193 double CompositorProxy::scrollTop(ExceptionState& exceptionState) const 193 double CompositorProxy::scrollTop(ExceptionState& exceptionState) const
194 { 194 {
195 if (raiseExceptionIfMutationNotAllowed(exceptionState)) 195 if (raiseExceptionIfMutationNotAllowed(exceptionState))
196 return 0.0; 196 return 0.0;
197 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, except ionState)) 197 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, except ionState))
198 return 0.0; 198 return 0.0;
199 return m_scrollTop; 199 return m_state->scrollTop();
200 } 200 }
201 201
202 DOMMatrix* CompositorProxy::transform(ExceptionState& exceptionState) const 202 DOMMatrix* CompositorProxy::transform(ExceptionState& exceptionState) const
203 { 203 {
204 if (raiseExceptionIfMutationNotAllowed(exceptionState)) 204 if (raiseExceptionIfMutationNotAllowed(exceptionState))
205 return nullptr; 205 return nullptr;
206 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, except ionState)) 206 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, except ionState))
207 return nullptr; 207 return nullptr;
208 return m_transform; 208 return DOMMatrix::create(m_state->transform());
209 } 209 }
210 210
211 void CompositorProxy::setOpacity(double opacity, ExceptionState& exceptionState) 211 void CompositorProxy::setOpacity(double opacity, ExceptionState& exceptionState)
212 { 212 {
213 if (raiseExceptionIfMutationNotAllowed(exceptionState)) 213 if (raiseExceptionIfMutationNotAllowed(exceptionState))
214 return; 214 return;
215 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptio nState)) 215 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptio nState))
216 return; 216 return;
217 m_opacity = std::min(1., std::max(0., opacity)); 217 m_state->setOpacity(std::min(1., std::max(0., opacity)));
218 m_mutatedProperties |= CompositorMutableProperty::kTransform;
219 } 218 }
220 219
221 void CompositorProxy::setScrollLeft(double scrollLeft, ExceptionState& exception State) 220 void CompositorProxy::setScrollLeft(double scrollLeft, ExceptionState& exception State)
222 { 221 {
223 if (raiseExceptionIfMutationNotAllowed(exceptionState)) 222 if (raiseExceptionIfMutationNotAllowed(exceptionState))
224 return; 223 return;
225 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, excep tionState)) 224 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, excep tionState))
226 return; 225 return;
227 m_scrollLeft = scrollLeft; 226 m_state->setScrollLeft(scrollLeft);
228 m_mutatedProperties |= CompositorMutableProperty::kScrollLeft;
229 } 227 }
230 228
231 void CompositorProxy::setScrollTop(double scrollTop, ExceptionState& exceptionSt ate) 229 void CompositorProxy::setScrollTop(double scrollTop, ExceptionState& exceptionSt ate)
232 { 230 {
233 if (raiseExceptionIfMutationNotAllowed(exceptionState)) 231 if (raiseExceptionIfMutationNotAllowed(exceptionState))
234 return; 232 return;
235 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, except ionState)) 233 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, except ionState))
236 return; 234 return;
237 m_scrollTop = scrollTop; 235 m_state->setScrollTop(scrollTop);
238 m_mutatedProperties |= CompositorMutableProperty::kScrollTop;
239 } 236 }
240 237
241 void CompositorProxy::setTransform(DOMMatrix* transform, ExceptionState& excepti onState) 238 void CompositorProxy::setTransform(DOMMatrix* transform, ExceptionState& excepti onState)
242 { 239 {
243 if (raiseExceptionIfMutationNotAllowed(exceptionState)) 240 if (raiseExceptionIfMutationNotAllowed(exceptionState))
244 return; 241 return;
245 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, except ionState)) 242 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, except ionState))
246 return; 243 return;
247 m_transform = transform; 244 m_state->setTransform(TransformationMatrix::toSkMatrix44(transform->matrix() ));
248 m_mutatedProperties |= CompositorMutableProperty::kTransform; 245 }
246
247 void CompositorProxy::takeCompositorMutableState(std::unique_ptr<CompositorMutab leState> state)
248 {
249 m_state = std::move(state);
249 } 250 }
250 251
251 bool CompositorProxy::raiseExceptionIfNotMutable(uint32_t property, ExceptionSta te& exceptionState) const 252 bool CompositorProxy::raiseExceptionIfNotMutable(uint32_t property, ExceptionSta te& exceptionState) const
252 { 253 {
253 if (m_connected && (m_compositorMutableProperties & property)) 254 if (!m_connected)
254 return false; 255 exceptionState.throwDOMException(NoModificationAllowedError, "Attempted to mutate attribute on a disconnected proxy.");
255 exceptionState.throwDOMException(NoModificationAllowedError, 256 else if (!(m_compositorMutableProperties & property))
256 m_connected ? "Attempted to mutate non-mutable attribute." : "Attempted to mutate attribute on a disconnected proxy."); 257 exceptionState.throwDOMException(NoModificationAllowedError, "Attempted to mutate non-mutable attribute.");
257 return true; 258 else if (!m_state)
259 exceptionState.throwDOMException(NoModificationAllowedError, "Attempted to mutate attribute on an uninitialized proxy.");
260
261 return exceptionState.hadException();
258 } 262 }
259 263
260 void CompositorProxy::disconnect() 264 void CompositorProxy::disconnect()
261 { 265 {
262 disconnectInternal(); 266 disconnectInternal();
263 if (m_client) 267 if (m_client)
264 m_client->unregisterCompositorProxy(this); 268 m_client->unregisterCompositorProxy(this);
265 } 269 }
266 270
267 void CompositorProxy::disconnectInternal() 271 void CompositorProxy::disconnectInternal()
268 { 272 {
269 if (!m_connected) 273 if (!m_connected)
270 return; 274 return;
271 m_connected = false; 275 m_connected = false;
272 if (isMainThread()) { 276 if (isMainThread()) {
273 decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositor MutableProperties); 277 decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositor MutableProperties);
274 } else { 278 } else {
275 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_eleme ntId, m_compositorMutableProperties)); 279 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_eleme ntId, m_compositorMutableProperties));
276 } 280 }
277 } 281 }
278 282
279 } // namespace blink 283 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698