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/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 Loading... | |
| 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 if (!m_state.get()) | 
| 
 
jbroman
2016/06/13 19:45:17
Should these be returning zero? What does it mean
 
majidvp
2016/06/13 21:52:51
Not having a state is equivalent to the underlying
 
Ian Vollick
2016/06/14 11:24:28
There's no harm in throwing in the getter and I th
 
majidvp
2016/06/14 17:25:58
Done.
 
 | |
| 182 return 0.0; | |
| 183 return m_state->opacity(); | |
| 182 } | 184 } | 
| 183 | 185 | 
| 184 double CompositorProxy::scrollLeft(ExceptionState& exceptionState) const | 186 double CompositorProxy::scrollLeft(ExceptionState& exceptionState) const | 
| 185 { | 187 { | 
| 186 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 188 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 
| 187 return 0.0; | 189 return 0.0; | 
| 188 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, excep tionState)) | 190 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, excep tionState)) | 
| 189 return 0.0; | 191 return 0.0; | 
| 190 return m_scrollLeft; | 192 if (!m_state.get()) | 
| 193 return 0.0; | |
| 194 return m_state->scrollLeft(); | |
| 191 } | 195 } | 
| 192 | 196 | 
| 193 double CompositorProxy::scrollTop(ExceptionState& exceptionState) const | 197 double CompositorProxy::scrollTop(ExceptionState& exceptionState) const | 
| 194 { | 198 { | 
| 195 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 199 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 
| 196 return 0.0; | 200 return 0.0; | 
| 197 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, except ionState)) | 201 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, except ionState)) | 
| 198 return 0.0; | 202 return 0.0; | 
| 199 return m_scrollTop; | 203 if (!m_state.get()) | 
| 204 return 0.0; | |
| 205 return m_state->scrollTop(); | |
| 200 } | 206 } | 
| 201 | 207 | 
| 202 DOMMatrix* CompositorProxy::transform(ExceptionState& exceptionState) const | 208 DOMMatrix* CompositorProxy::transform(ExceptionState& exceptionState) const | 
| 203 { | 209 { | 
| 204 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 210 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 
| 205 return nullptr; | 211 return nullptr; | 
| 206 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, except ionState)) | 212 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, except ionState)) | 
| 207 return nullptr; | 213 return nullptr; | 
| 208 return m_transform; | 214 if (!m_state.get()) | 
| 215 return DOMMatrix::create(); | |
| 216 return DOMMatrix::create(m_state->transform()); | |
| 209 } | 217 } | 
| 210 | 218 | 
| 211 void CompositorProxy::setOpacity(double opacity, ExceptionState& exceptionState) | 219 void CompositorProxy::setOpacity(double opacity, ExceptionState& exceptionState) | 
| 212 { | 220 { | 
| 213 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 221 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 
| 214 return; | 222 return; | 
| 215 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptio nState)) | 223 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptio nState)) | 
| 216 return; | 224 return; | 
| 217 m_opacity = std::min(1., std::max(0., opacity)); | 225 if (!m_state.get()) | 
| 218 m_mutatedProperties |= CompositorMutableProperty::kTransform; | 226 return; | 
| 227 | |
| 228 m_state->setOpacity(std::min(1., std::max(0., opacity))); | |
| 219 } | 229 } | 
| 220 | 230 | 
| 221 void CompositorProxy::setScrollLeft(double scrollLeft, ExceptionState& exception State) | 231 void CompositorProxy::setScrollLeft(double scrollLeft, ExceptionState& exception State) | 
| 222 { | 232 { | 
| 223 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 233 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 
| 224 return; | 234 return; | 
| 225 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, excep tionState)) | 235 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, excep tionState)) | 
| 226 return; | 236 return; | 
| 227 m_scrollLeft = scrollLeft; | 237 if (!m_state.get()) | 
| 228 m_mutatedProperties |= CompositorMutableProperty::kScrollLeft; | 238 return; | 
| 239 m_state->setScrollLeft(scrollLeft); | |
| 229 } | 240 } | 
| 230 | 241 | 
| 231 void CompositorProxy::setScrollTop(double scrollTop, ExceptionState& exceptionSt ate) | 242 void CompositorProxy::setScrollTop(double scrollTop, ExceptionState& exceptionSt ate) | 
| 232 { | 243 { | 
| 233 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 244 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 
| 234 return; | 245 return; | 
| 235 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, except ionState)) | 246 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, except ionState)) | 
| 236 return; | 247 return; | 
| 237 m_scrollTop = scrollTop; | 248 if (!m_state.get()) | 
| 238 m_mutatedProperties |= CompositorMutableProperty::kScrollTop; | 249 return; | 
| 250 m_state->setScrollTop(scrollTop); | |
| 239 } | 251 } | 
| 240 | 252 | 
| 241 void CompositorProxy::setTransform(DOMMatrix* transform, ExceptionState& excepti onState) | 253 void CompositorProxy::setTransform(DOMMatrix* transform, ExceptionState& excepti onState) | 
| 242 { | 254 { | 
| 243 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 255 if (raiseExceptionIfMutationNotAllowed(exceptionState)) | 
| 244 return; | 256 return; | 
| 245 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, except ionState)) | 257 if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, except ionState)) | 
| 246 return; | 258 return; | 
| 247 m_transform = transform; | 259 if (!m_state.get()) | 
| 248 m_mutatedProperties |= CompositorMutableProperty::kTransform; | 260 return; | 
| 261 m_state->setTransform(TransformationMatrix::toSkMatrix44(transform->matrix() )); | |
| 262 } | |
| 263 | |
| 264 void CompositorProxy::takeCompositorMutableState(std::unique_ptr<CompositorMutab leState> state) | |
| 265 { | |
| 266 m_state = std::move(state); | |
| 249 } | 267 } | 
| 250 | 268 | 
| 251 bool CompositorProxy::raiseExceptionIfNotMutable(uint32_t property, ExceptionSta te& exceptionState) const | 269 bool CompositorProxy::raiseExceptionIfNotMutable(uint32_t property, ExceptionSta te& exceptionState) const | 
| 252 { | 270 { | 
| 253 if (m_connected && (m_compositorMutableProperties & property)) | 271 if (m_connected && (m_compositorMutableProperties & property)) | 
| 254 return false; | 272 return false; | 
| 255 exceptionState.throwDOMException(NoModificationAllowedError, | 273 exceptionState.throwDOMException(NoModificationAllowedError, | 
| 256 m_connected ? "Attempted to mutate non-mutable attribute." : "Attempted to mutate attribute on a disconnected proxy."); | 274 m_connected ? "Attempted to mutate non-mutable attribute." : "Attempted to mutate attribute on a disconnected proxy."); | 
| 257 return true; | 275 return true; | 
| 258 } | 276 } | 
| (...skipping 11 matching lines...) Expand all Loading... | |
| 270 return; | 288 return; | 
| 271 m_connected = false; | 289 m_connected = false; | 
| 272 if (isMainThread()) { | 290 if (isMainThread()) { | 
| 273 decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositor MutableProperties); | 291 decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositor MutableProperties); | 
| 274 } else { | 292 } else { | 
| 275 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_eleme ntId, m_compositorMutableProperties)); | 293 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_eleme ntId, m_compositorMutableProperties)); | 
| 276 } | 294 } | 
| 277 } | 295 } | 
| 278 | 296 | 
| 279 } // namespace blink | 297 } // namespace blink | 
| OLD | NEW |