Bug 1268816 - allow Skia to use C++11 features on platforms that have them. r=froydnj
--- a/config/stl-headers
+++ b/config/stl-headers
@@ -29,16 +29,17 @@ iterator
limits
list
map
memory
ostream
set
stack
string
+type_traits
utility
vector
cassert
climits
cmath
cstdarg
cstdio
cstdlib
--- a/config/system-headers
+++ b/config/system-headers
@@ -1109,16 +1109,17 @@ ThreadManagerTests.h
Threads.h
time.h
Timer.h
tlhelp32.h
ToolUtils.h
tr1/functional
trace.h
Traps.h
+type_traits
typeinfo
types.h
Types.h
UAppleEventsMgr.h
UAttachments.h
ucontext.h
uconv.h
UCursor.h
--- a/gfx/skia/skia/include/config/SkUserConfig.h
+++ b/gfx/skia/skia/include/config/SkUserConfig.h
@@ -159,9 +159,20 @@
#ifndef MOZ_IMPLICIT
# ifdef MOZ_CLANG_PLUGIN
# define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
# else
# define MOZ_IMPLICIT
# endif
#endif
+/* Check if building with either MSVC, libc++, or a sufficiently recent version of libstdc++.
++ * On platforms like OS X 10.6 or older Android SDKs, we need to work around a lack of certain
++ * C++11 features.
++ */
+#include "mozilla/Compiler.h"
+#if MOZ_IS_MSVC || MOZ_USING_LIBCXX || MOZ_LIBSTDCXX_VERSION_AT_LEAST(4, 8, 0)
+# define MOZ_SKIA_AVOID_CXX11 0
+#else
+# define MOZ_SKIA_AVOID_CXX11 1
#endif
+
+#endif
--- a/gfx/skia/skia/include/private/SkTLogic.h
+++ b/gfx/skia/skia/include/private/SkTLogic.h
@@ -16,41 +16,28 @@
#include <cstddef>
#include <stdint.h>
#include <utility>
#include <memory>
#include <algorithm>
#include <functional>
-#ifdef MOZ_SKIA
+#ifdef MOZ_SKIA_AVOID_CXX11
#include "mozilla/Function.h"
#include "mozilla/Move.h"
#include "mozilla/TypeTraits.h"
#include "mozilla/UniquePtr.h"
-// In libc++, symbols such as std::forward may be defined in std::__1.
-// The _LIBCPP_BEGIN_NAMESPACE_STD and _LIBCPP_END_NAMESPACE_STD macros
-// will expand to the correct namespace.
-#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
-#define MOZ_BEGIN_STD_NAMESPACE _LIBCPP_BEGIN_NAMESPACE_STD
-#define MOZ_END_STD_NAMESPACE _LIBCPP_END_NAMESPACE_STD
-#else
-#define MOZ_BEGIN_STD_NAMESPACE namespace std {
-#define MOZ_END_STD_NAMESPACE }
-#endif
-
-MOZ_BEGIN_STD_NAMESPACE
+namespace std {
using mozilla::Forward;
using mozilla::Move;
#define forward Forward
#define move Move
-MOZ_END_STD_NAMESPACE
-namespace std {
// If we have 'using mozilla::function', we're going to collide with
// 'std::function' on platforms that have it. Therefore we use a macro
// work around.
template<typename Signature>
using moz_function = mozilla::function<Signature>;
#define function moz_function
typedef decltype(nullptr) moz_nullptr_t;
@@ -94,17 +81,17 @@ template <typename T> using remove_point
template <typename T> struct underlying_type {
using type = __underlying_type(T);
};
template <typename T> using underlying_type_t = typename skstd::underlying_type<T>::type;
}
-#else /* !MOZ_SKIA */
+#else /* !MOZ_SKIA_AVOID_CXX11 */
#include <type_traits>
namespace skstd {
template <bool B> using bool_constant = std::integral_constant<bool, B>;
template <bool B, typename T, typename F> using conditional_t = typename std::conditional<B, T, F>::type;
@@ -221,14 +208,14 @@ template <typename D, typename S> using
template <typename D, typename S> using same_const_t = typename same_const<D, S>::type;
template <typename D, typename S> using same_volatile =copy_volatile<skstd::remove_volatile_t<D>,S>;
template <typename D, typename S> using same_volatile_t = typename same_volatile<D, S>::type;
template <typename D, typename S> using same_cv = copy_cv<skstd::remove_cv_t<D>, S>;
template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type;
} // namespace sknonstd
-#endif /* MOZ_SKIA */
+#endif /* MOZ_SKIA_AVOID_CXX11 */
// Just a pithier wrapper for enable_if_t.
#define SK_WHEN(condition, T) skstd::enable_if_t<!!(condition), T>
#endif