 Chromium Code Reviews
 Chromium Code Reviews Issue 2457013004:
  Use NGLogicalRect instead of NGExclusion for exclusions.  (Closed)
    
  
    Issue 2457013004:
  Use NGLogicalRect instead of NGExclusion for exclusions.  (Closed) 
  | Index: third_party/WebKit/Source/core/layout/ng/ptr_util.h | 
| diff --git a/third_party/WebKit/Source/core/layout/ng/ptr_util.h b/third_party/WebKit/Source/core/layout/ng/ptr_util.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..5bf1545c9b5381edf1369d41a18ba62cf6def9b0 | 
| --- /dev/null | 
| +++ b/third_party/WebKit/Source/core/layout/ng/ptr_util.h | 
| @@ -0,0 +1,57 @@ | 
| +// Copyright 2016 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef ptr_util_h | 
| 
ikilpatrick
2016/10/31 21:36:08
would prefer to wait until we have this in wtf ins
 
Gleb Lanbin
2016/10/31 23:08:18
deleted
 | 
| +#define ptr_util_h | 
| + | 
| +#include <memory> | 
| +#include <utility> | 
| + | 
| +// This is a partial copy of base/memory/ptr_util.h that sadly cannot be used in | 
| +// Blink because of "-base" from third_party's include_rules. | 
| +// TODO(glebl): move to WebKit/base? similar to | 
| +// third_party/pdfium/third_party/base/ptr_util.h | 
| + | 
| +namespace blink { | 
| + | 
| +namespace { | 
| + | 
| +template <typename T> | 
| +struct MakeUniqueResult { | 
| + using Scalar = std::unique_ptr<T>; | 
| +}; | 
| + | 
| +template <typename T> | 
| +struct MakeUniqueResult<T[]> { | 
| + using Array = std::unique_ptr<T[]>; | 
| +}; | 
| + | 
| +template <typename T, size_t N> | 
| +struct MakeUniqueResult<T[N]> { | 
| + using Invalid = void; | 
| +}; | 
| + | 
| +} // namespace | 
| + | 
| +// Helper to construct an object wrapped in a std::unique_ptr. This is an | 
| +// implementation of C++14's std::MakeUnique that can be used in Chrome. | 
| +// | 
| +// MakeUnique<T>(args) should be preferred over WrapUnique(new T(args)): bare | 
| +// calls to `new` should be treated with scrutiny. | 
| +// | 
| +// Usage: | 
| +// // ptr is a std::unique_ptr<std::string> | 
| +// auto ptr = MakeUnique<std::string>("hello world!"); | 
| +// | 
| +// // arr is a std::unique_ptr<int[]> | 
| +// auto arr = MakeUnique<int[]>(5); | 
| + | 
| +// Overload for non-array types. Arguments are forwarded to T's constructor. | 
| +template <typename T, typename... Args> | 
| +typename MakeUniqueResult<T>::Scalar MakeUnique(Args&&... args) { | 
| + return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); | 
| +} | 
| + | 
| +} // namespace blink | 
| +#endif // ptr_util_h |