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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/TransformValue.cpp

Issue 2099513002: [Typed OM] Rename TransformValue -> CSSTransformValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rename-transformcomponent
Patch Set: sync to head Created 4 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/css/cssom/TransformValue.h"
6
7 #include "core/css/CSSValueList.h"
8 #include "core/css/cssom/CSSTransformComponent.h"
9
10 namespace blink {
11
12 namespace {
13
14 class TransformValueIterationSource final : public ValueIterable<CSSTransformCom ponent*>::IterationSource {
15 public:
16 explicit TransformValueIterationSource(TransformValue* transformValue)
17 : m_transformValue(transformValue)
18 {
19 }
20
21 bool next(ScriptState*, CSSTransformComponent*& value, ExceptionState&) over ride
22 {
23 if (m_index >= m_transformValue->size()) {
24 return false;
25 }
26 value = m_transformValue->componentAtIndex(m_index);
27 return true;
28 }
29
30 DEFINE_INLINE_VIRTUAL_TRACE()
31 {
32 visitor->trace(m_transformValue);
33 ValueIterable<CSSTransformComponent*>::IterationSource::trace(visitor);
34 }
35
36 private:
37 const Member<TransformValue> m_transformValue;
38 };
39
40 } // namespace
41
42 TransformValue* TransformValue::fromCSSValue(const CSSValue& cssValue)
43 {
44 if (!cssValue.isValueList()) {
45 // TODO(meade): Also need to check the separator here if we care.
46 return nullptr;
47 }
48 HeapVector<Member<CSSTransformComponent>> components;
49 for (const CSSValue* value : toCSSValueList(cssValue)) {
50 CSSTransformComponent* component = CSSTransformComponent::fromCSSValue(* value);
51 if (!component)
52 return nullptr;
53 components.append(component);
54 }
55 return TransformValue::create(components);
56 }
57
58 ValueIterable<CSSTransformComponent*>::IterationSource* TransformValue::startIte ration(ScriptState*, ExceptionState&)
59 {
60 return new TransformValueIterationSource(this);
61 }
62
63 bool TransformValue::is2D() const
64 {
65 for (size_t i = 0; i < m_transformComponents.size(); i++) {
66 if (!m_transformComponents[i]->is2DComponent()) {
67 return false;
68 }
69 }
70 return true;
71 }
72
73 CSSValue* TransformValue::toCSSValue() const
74 {
75 CSSValueList* transformCSSValue = CSSValueList::createSpaceSeparated();
76 for (size_t i = 0; i < m_transformComponents.size(); i++) {
77 transformCSSValue->append(*m_transformComponents[i]->toCSSValue());
78 }
79 return transformCSSValue;
80 }
81
82 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/TransformValue.h ('k') | third_party/WebKit/Source/core/css/cssom/TransformValue.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698