Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "platform/graphics/CompositorElementId.h" | 5 #include "platform/graphics/CompositorElementId.h" |
| 6 | 6 |
| 7 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 CompositorElementId CreateCompositorElementId( | 9 CompositorElementId CreateCompositorElementId( |
| 10 int dom_node_id, | 10 int dom_node_id, |
| 11 CompositorSubElementId sub_element_id) { | 11 CompositorSubElementId sub_element_id) { |
| 12 return CompositorElementId(dom_node_id, static_cast<int>(sub_element_id)); | 12 DCHECK(dom_node_id > 0 && dom_node_id < std::numeric_limits<int>::max() / 4); |
|
suzyh_UTC10 (ex-contributor)
2017/05/05 04:27:31
Please make this 4 a named constant or similar rat
chrishtr
2017/05/05 05:34:52
Done.
| |
| 13 int element_id = dom_node_id; | |
|
suzyh_UTC10 (ex-contributor)
2017/05/05 04:27:31
Use one of the unsigned types rather than int?
chrishtr
2017/05/05 05:34:52
Done. Sorry for forgetting to update this file.
| |
| 14 element_id = element_id << 2; // Shift to make room for enum bits. | |
|
suzyh_UTC10 (ex-contributor)
2017/05/05 04:27:31
Nit: specify "sub_element_id enum bits"
chrishtr
2017/05/05 05:34:52
Done.
| |
| 15 element_id += static_cast<int>(sub_element_id); | |
| 16 return CompositorElementId(element_id); | |
| 17 } | |
| 18 | |
| 19 int DomNodeIdFromCompositorElementId(CompositorElementId id) { | |
| 20 return id >> 2; | |
| 13 } | 21 } |
| 14 | 22 |
| 15 } // namespace blink | 23 } // namespace blink |
| OLD | NEW |