diff --git a/.gitignore b/.gitignore
index 8229a87a8c..2a22d83c9e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@
/.buckd
/lib/gtest/googletest-*/
/gentest/test.html
+
+# Visual studio code
+.vscode
diff --git a/.hgignore b/.hgignore
index 8229a87a8c..875f1d7d1e 100644
--- a/.hgignore
+++ b/.hgignore
@@ -6,3 +6,6 @@
/.buckd
/lib/gtest/googletest-*/
/gentest/test.html
+
+# Visual studio code
+.vscode
\ No newline at end of file
diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h
index 3ebce6855e..f3353fdf05 100644
--- a/CSSLayout/CSSLayout.h
+++ b/CSSLayout/CSSLayout.h
@@ -122,16 +122,16 @@ typedef CSSSize (*CSSMeasureFunc)(void *context,
typedef void (*CSSPrintFunc)(void *context);
// CSSNode
-CSSNodeRef CSSNodeNew();
-void CSSNodeInit(const CSSNodeRef node);
-void CSSNodeFree(const CSSNodeRef node);
+WIN_EXPORT CSSNodeRef CSSNodeNew();
+WIN_EXPORT void CSSNodeInit(const CSSNodeRef node);
+WIN_EXPORT void CSSNodeFree(const CSSNodeRef node);
-void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index);
-void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);
-CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index);
-uint32_t CSSNodeChildCount(const CSSNodeRef node);
+WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index);
+WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);
+WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index);
+WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node);
-void CSSNodeCalculateLayout(const CSSNodeRef node,
+WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node,
const float availableWidth,
const float availableHeight,
const CSSDirection parentDirection);
@@ -142,26 +142,26 @@ void CSSNodeCalculateLayout(const CSSNodeRef node,
// measure functions
// depends on information not known to CSSLayout they must perform this dirty
// marking manually.
-void CSSNodeMarkDirty(const CSSNodeRef node);
-bool CSSNodeIsDirty(const CSSNodeRef node);
+WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node);
+WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node);
-void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options);
+WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options);
-bool CSSValueIsUndefined(const float value);
+WIN_EXPORT bool CSSValueIsUndefined(const float value);
#define CSS_NODE_PROPERTY(type, name, paramName) \
- void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
- type CSSNodeGet##name(const CSSNodeRef node);
+ WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
+ WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node);
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
- void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \
- type CSSNodeStyleGet##name(const CSSNodeRef node);
+ WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \
+ WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node);
#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
- void CSSNodeStyleSet##name(const CSSNodeRef node, const CSSEdge edge, const type paramName); \
- type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge);
+ WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const CSSEdge edge, const type paramName); \
+ WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge);
-#define CSS_NODE_LAYOUT_PROPERTY(type, name) type CSSNodeLayoutGet##name(const CSSNodeRef node);
+#define CSS_NODE_LAYOUT_PROPERTY(type, name) WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node);
CSS_NODE_PROPERTY(void *, Context, context);
CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc);
diff --git a/CSSLayout/CSSMacros.h b/CSSLayout/CSSMacros.h
index eb05985699..f4e29a1e3f 100644
--- a/CSSLayout/CSSMacros.h
+++ b/CSSLayout/CSSMacros.h
@@ -17,6 +17,12 @@
#define CSS_EXTERN_C_END
#endif
+#ifdef _WINDLL
+#define WIN_EXPORT __declspec(dllexport)
+#else
+#define WIN_EXPORT
+#endif
+
#ifndef FB_ASSERTIONS_ENABLED
#define FB_ASSERTIONS_ENABLED 1
#endif
diff --git a/csharp/.gitignore b/csharp/.gitignore
new file mode 100644
index 0000000000..4e1cd4a568
--- /dev/null
+++ b/csharp/.gitignore
@@ -0,0 +1,265 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
\ No newline at end of file
diff --git a/csharp/.hgignore b/csharp/.hgignore
new file mode 100644
index 0000000000..4e1cd4a568
--- /dev/null
+++ b/csharp/.hgignore
@@ -0,0 +1,265 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
\ No newline at end of file
diff --git a/csharp/BUCK b/csharp/BUCK
new file mode 100644
index 0000000000..0e88d1241e
--- /dev/null
+++ b/csharp/BUCK
@@ -0,0 +1,20 @@
+# Copyright (c) 2014-present, Facebook, Inc.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree. An additional grant
+# of patent rights can be found in the PATENTS file in the same directory.
+
+csharp_library(
+ name = 'csslibnet46',
+ dll_name = 'Facebook.CSSLayout.dll',
+ framework_ver = 'net46',
+ srcs = glob(['**/*.cs']),
+)
+
+csharp_library(
+ name = 'csslibnet45',
+ dll_name = 'Facebook.CSSLayout.dll',
+ framework_ver = 'net45',
+ srcs = glob(['**/*.cs']),
+)
diff --git a/csharp/CSSLayout/CSSLayout.vcxproj b/csharp/CSSLayout/CSSLayout.vcxproj
new file mode 100644
index 0000000000..5f2e34f072
--- /dev/null
+++ b/csharp/CSSLayout/CSSLayout.vcxproj
@@ -0,0 +1,177 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}
+ Win32Proj
+ CSSLayout
+ 10.0.10586.0
+
+
+
+ DynamicLibrary
+ true
+ v140
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140
+ true
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v140
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ _DEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ NDEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/csharp/CSSLayout/CSSLayout.vcxproj.filters b/csharp/CSSLayout/CSSLayout.vcxproj.filters
new file mode 100644
index 0000000000..bac85caa07
--- /dev/null
+++ b/csharp/CSSLayout/CSSLayout.vcxproj.filters
@@ -0,0 +1,48 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/csharp/CSSLayout/dllmain.cpp b/csharp/CSSLayout/dllmain.cpp
new file mode 100644
index 0000000000..d911b341d3
--- /dev/null
+++ b/csharp/CSSLayout/dllmain.cpp
@@ -0,0 +1,27 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+// dllmain.cpp : Defines the entry point for the DLL application.
+#include "stdafx.h"
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
diff --git a/csharp/CSSLayout/stdafx.cpp b/csharp/CSSLayout/stdafx.cpp
new file mode 100644
index 0000000000..53e7c3465a
--- /dev/null
+++ b/csharp/CSSLayout/stdafx.cpp
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+// stdafx.cpp : source file that includes just the standard includes
+// CSSLayout.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/csharp/CSSLayout/stdafx.h b/csharp/CSSLayout/stdafx.h
new file mode 100644
index 0000000000..1984e9a085
--- /dev/null
+++ b/csharp/CSSLayout/stdafx.h
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/csharp/CSSLayout/targetver.h b/csharp/CSSLayout/targetver.h
new file mode 100644
index 0000000000..d87345ba02
--- /dev/null
+++ b/csharp/CSSLayout/targetver.h
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include
diff --git a/csharp/Facebook.CSSLayout.sln b/csharp/Facebook.CSSLayout.sln
new file mode 100644
index 0000000000..5c67bda9c6
--- /dev/null
+++ b/csharp/Facebook.CSSLayout.sln
@@ -0,0 +1,46 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSSLayout", "CSSLayout\CSSLayout.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}"
+EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Facebook.CSSLayout", "Facebook.CSSLayout\Facebook.CSSLayout.xproj", "{75BB7605-E54B-4EDE-8F5A-FF1F24464236}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x64.ActiveCfg = Debug|x64
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x64.Build.0 = Debug|x64
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x86.ActiveCfg = Debug|Win32
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x86.Build.0 = Debug|Win32
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|Any CPU.ActiveCfg = Release|Win32
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x64.ActiveCfg = Release|x64
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x64.Build.0 = Release|x64
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x86.ActiveCfg = Release|Win32
+ {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x86.Build.0 = Release|Win32
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|x64.Build.0 = Debug|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|x86.Build.0 = Debug|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|Any CPU.Build.0 = Release|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|x64.ActiveCfg = Release|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|x64.Build.0 = Release|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|x86.ActiveCfg = Release|Any CPU
+ {75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/csharp/Facebook.CSSLayout/CSSAlign.cs b/csharp/Facebook.CSSLayout/CSSAlign.cs
new file mode 100644
index 0000000000..685fea752d
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSAlign.cs
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSAlign
+ {
+ Auto,
+ FlexStart,
+ Center,
+ FlexEnd,
+ Stretch
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSConstants.cs b/csharp/Facebook.CSSLayout/CSSConstants.cs
new file mode 100644
index 0000000000..a57d62f277
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSConstants.cs
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public static class CSSConstants
+ {
+ public const float Undefined = float.NaN;
+
+ public static bool IsUndefined(float value)
+ {
+ return float.IsNaN(value);
+ }
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSDIrection.cs b/csharp/Facebook.CSSLayout/CSSDIrection.cs
new file mode 100644
index 0000000000..1a45570988
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSDIrection.cs
@@ -0,0 +1,18 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSDirection
+ {
+ Inherit,
+ LeftToRight,
+ RightToLeft
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSDimension.cs b/csharp/Facebook.CSSLayout/CSSDimension.cs
new file mode 100644
index 0000000000..a8fd2b2621
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSDimension.cs
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSDimension
+ {
+ Width,
+ Height
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSEdge.cs b/csharp/Facebook.CSSLayout/CSSEdge.cs
new file mode 100644
index 0000000000..f4877f8733
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSEdge.cs
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSEdge
+ {
+ Left,
+ Top,
+ Right,
+ Bottom,
+ Start,
+ End,
+ Horizontal,
+ Vertical,
+ All,
+ Count,
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSFlexDirection.cs b/csharp/Facebook.CSSLayout/CSSFlexDirection.cs
new file mode 100644
index 0000000000..a06f7533e0
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSFlexDirection.cs
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSFlexDirection
+ {
+ Column,
+ ColumnReverse,
+ Row,
+ RowReverse,
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSJustify.cs b/csharp/Facebook.CSSLayout/CSSJustify.cs
new file mode 100644
index 0000000000..93e1566f28
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSJustify.cs
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSJustify
+ {
+ FlexStart,
+ Center,
+ FlexEnd,
+ SpaceBetween,
+ SpaceAround,
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSLayoutContext.cs b/csharp/Facebook.CSSLayout/CSSLayoutContext.cs
new file mode 100644
index 0000000000..51520e509b
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSLayoutContext.cs
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public class CSSLayoutContext
+ {
+ public MeasureOutput measureOutput { get; } = new MeasureOutput();
+ public int CurrentGenerationCount { get; set; }
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs b/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs
new file mode 100644
index 0000000000..57f70d726b
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+using System;
+
+namespace Facebook.CSSLayout
+{
+ public delegate CSSSize CSSMeasureFunc(
+ IntPtr context,
+ float width,
+ CSSMeasureMode widthMode,
+ float height,
+ CSSMeasureMode heightMode);
+}
diff --git a/csharp/Facebook.CSSLayout/CSSMeasureMode.cs b/csharp/Facebook.CSSLayout/CSSMeasureMode.cs
new file mode 100644
index 0000000000..ff82545c46
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSMeasureMode.cs
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSMeasureMode
+ {
+ Undefined,
+ Exactly,
+ AtMost,
+ Count,
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs
new file mode 100644
index 0000000000..55158030d3
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSNode.cs
@@ -0,0 +1,685 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Facebook.CSSLayout
+{
+ public class CSSNode : IDisposable, IEnumerable
+ {
+ private bool _isDisposed;
+ private IntPtr _cssNode;
+ private IntPtr _context;
+
+ private CSSNode _parent;
+ private List _children;
+ private MeasureFunction _measureFunction;
+ private CSSMeasureFunc _measureFunc;
+ private CSSPrintFunc _printFunc;
+ private object _data;
+
+ public CSSNode()
+ {
+ _measureFunc = MeasureInternal;
+ _printFunc = PrintInternal;
+ }
+
+ private void CheckDisposed()
+ {
+ if (_isDisposed)
+ {
+ throw new ObjectDisposedException("CSSNode");
+ }
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_isDisposed && disposing)
+ {
+ _isDisposed = true;
+ Native.CSSNodeFree(_cssNode);
+ GCHandle.FromIntPtr(_context).Free();
+ }
+ }
+
+ public void Initialize()
+ {
+ _cssNode = Native.CSSNodeNew();
+ _context = (IntPtr)GCHandle.Alloc(this);
+ Native.CSSNodeSetContext(_cssNode, _context);
+ _children = new List(4);
+ Native.CSSNodeSetPrintFunc(_cssNode, _printFunc);
+ }
+
+ public void Reset()
+ {
+ Native.CSSNodeFree(_cssNode);
+ GCHandle.FromIntPtr(_context).Free();
+ _children = null;
+ _parent = null;
+ _measureFunction = null;
+ }
+
+ public bool IsDirty
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeIsDirty(_cssNode);
+ }
+ }
+
+ public virtual void MarkDirty()
+ {
+ CheckDisposed();
+ Native.CSSNodeMarkDirty(_cssNode);
+ }
+
+ public bool IsTextNode
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeGetIsTextnode(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeSetIsTextnode(_cssNode, value);
+ }
+ }
+
+ public bool HasNewLayout
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeGetHasNewLayout(_cssNode);
+ }
+ }
+
+ public void MarkHasNewLayout()
+ {
+ CheckDisposed();
+ Native.CSSNodeSetHasNewLayout(_cssNode, true);
+ }
+
+ public CSSNode Parent
+ {
+ get
+ {
+ CheckDisposed();
+ return _parent;
+ }
+ }
+
+ public bool IsMeasureDefined
+ {
+ get
+ {
+ return _measureFunction != null;
+ }
+ }
+
+ public CSSDirection StyleDirection
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetDirection(_cssNode);
+ }
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetDirection(_cssNode, value);
+ }
+ }
+
+ public CSSFlexDirection FlexDirection
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetFlexDirection(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetFlexDirection(_cssNode, value);
+ }
+ }
+
+ public CSSJustify JustifyContent
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetJustifyContent(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetJustifyContent(_cssNode, value);
+ }
+ }
+
+ public CSSAlign AlignItems
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetAlignItems(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetAlignItems(_cssNode, value);
+ }
+ }
+
+ public CSSAlign AlignSelf
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetAlignSelf(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetAlignSelf(_cssNode, value);
+ }
+ }
+
+ public CSSAlign AlignContent
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetAlignContent(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetAlignContent(_cssNode, value);
+ }
+ }
+
+ public CSSPositionType PositionType
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetPositionType(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetPositionType(_cssNode, value);
+ }
+ }
+
+ public CSSWrap Wrap
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetFlexWrap(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetFlexWrap(_cssNode, value);
+ }
+ }
+
+ public float Flex
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetFlex(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetFlex(_cssNode, value);
+ }
+ }
+
+ public float FlexGrow
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetFlexGrow(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetFlexGrow(_cssNode, value);
+ }
+ }
+
+ public float FlexShrink
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetFlexShrink(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetFlexShrink(_cssNode, value);
+ }
+ }
+
+ public float FlexBasis
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetFlexBasis(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetFlexBasis(_cssNode, value);
+ }
+ }
+
+ public Spacing GetMargin()
+ {
+ CheckDisposed();
+
+ var margin = new Spacing();
+ margin.Set(Spacing.Left, Native.CSSNodeStyleGetMargin(_cssNode, CSSEdge.Left));
+ margin.Set(Spacing.Top, Native.CSSNodeStyleGetMargin(_cssNode, CSSEdge.Top));
+ margin.Set(Spacing.Right, Native.CSSNodeStyleGetMargin(_cssNode, CSSEdge.Right));
+ margin.Set(Spacing.Bottom, Native.CSSNodeStyleGetMargin(_cssNode, CSSEdge.Bottom));
+ margin.Set(Spacing.Start, Native.CSSNodeStyleGetMargin(_cssNode, CSSEdge.Start));
+ margin.Set(Spacing.End, Native.CSSNodeStyleGetMargin(_cssNode, CSSEdge.End));
+
+ return margin;
+ }
+
+ public void SetMargin(CSSEdge edge, float value)
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetMargin(_cssNode, edge, value);
+ }
+
+ public Spacing GetPadding()
+ {
+ CheckDisposed();
+
+ var padding = new Spacing();
+ padding.Set(Spacing.Left, Native.CSSNodeStyleGetPadding(_cssNode, CSSEdge.Left));
+ padding.Set(Spacing.Top, Native.CSSNodeStyleGetPadding(_cssNode, CSSEdge.Top));
+ padding.Set(Spacing.Right, Native.CSSNodeStyleGetPadding(_cssNode, CSSEdge.Right));
+ padding.Set(Spacing.Bottom, Native.CSSNodeStyleGetPadding(_cssNode, CSSEdge.Bottom));
+ padding.Set(Spacing.Start, Native.CSSNodeStyleGetPadding(_cssNode, CSSEdge.Start));
+ padding.Set(Spacing.End, Native.CSSNodeStyleGetPadding(_cssNode, CSSEdge.End));
+
+ return padding;
+ }
+
+ public void SetPadding(CSSEdge edge, float padding)
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetPadding(_cssNode, edge, padding);
+ }
+
+ public Spacing GetBorder()
+ {
+ CheckDisposed();
+
+ var border = new Spacing();
+ border.Set(Spacing.Left, Native.CSSNodeStyleGetBorder(_cssNode, CSSEdge.Left));
+ border.Set(Spacing.Top, Native.CSSNodeStyleGetBorder(_cssNode, CSSEdge.Top));
+ border.Set(Spacing.Right, Native.CSSNodeStyleGetBorder(_cssNode, CSSEdge.Right));
+ border.Set(Spacing.Bottom, Native.CSSNodeStyleGetBorder(_cssNode, CSSEdge.Bottom));
+ border.Set(Spacing.Start, Native.CSSNodeStyleGetBorder(_cssNode, CSSEdge.Start));
+ border.Set(Spacing.End, Native.CSSNodeStyleGetBorder(_cssNode, CSSEdge.End));
+
+ return border;
+ }
+
+ public void SetBorder(CSSEdge edge, float border)
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetBorder(_cssNode, edge, border);
+ }
+
+ public Spacing GetPosition()
+ {
+ CheckDisposed();
+
+ var position = new Spacing();
+ position.Set(Spacing.Left, Native.CSSNodeStyleGetPosition(_cssNode, CSSEdge.Left));
+ position.Set(Spacing.Top, Native.CSSNodeStyleGetPosition(_cssNode, CSSEdge.Top));
+ position.Set(Spacing.Right, Native.CSSNodeStyleGetPosition(_cssNode, CSSEdge.Right));
+ position.Set(Spacing.Bottom, Native.CSSNodeStyleGetPosition(_cssNode, CSSEdge.Bottom));
+ position.Set(Spacing.Start, Native.CSSNodeStyleGetPosition(_cssNode, CSSEdge.Start));
+ position.Set(Spacing.End, Native.CSSNodeStyleGetPosition(_cssNode, CSSEdge.End));
+
+ return position;
+ }
+
+ public void SetPosition(CSSEdge edge, float position)
+ {
+ CheckDisposed();
+ }
+
+ public float StyleWidth
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetWidth(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetWidth(_cssNode, value);
+ }
+ }
+
+ public float StyleHeight
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetHeight(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetHeight(_cssNode, value);
+ }
+ }
+
+ public float StyleMaxWidth
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetMaxWidth(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetMaxWidth(_cssNode, value);
+ }
+ }
+
+ public float StyleMaxHeight
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetMaxHeight(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetMaxHeight(_cssNode, value);
+ }
+ }
+
+ public float StyleMinWidth
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetMinWidth(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetMinWidth(_cssNode, value);
+ }
+ }
+
+ public float StyleMinHeight
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetMinHeight(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetMinHeight(_cssNode, value);
+ }
+ }
+
+ public float LayoutX
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeLayoutGetLeft(_cssNode);
+ }
+ }
+
+ public float LayoutY
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeLayoutGetTop(_cssNode);
+ }
+ }
+
+ public float LayoutWidth
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeLayoutGetWidth(_cssNode);
+ }
+ }
+
+ public float LayoutHeight
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeLayoutGetHeight(_cssNode);
+ }
+ }
+
+ public CSSDirection LayoutDirection
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeLayoutGetDirection(_cssNode);
+ }
+ }
+
+ public CSSOverflow Overflow
+ {
+ get
+ {
+ CheckDisposed();
+ return Native.CSSNodeStyleGetOverflow(_cssNode);
+ }
+
+ set
+ {
+ CheckDisposed();
+ Native.CSSNodeStyleSetOverflow(_cssNode, value);
+ }
+ }
+
+ public object Data
+ {
+ get
+ {
+ CheckDisposed();
+ return _data;
+ }
+
+ set
+ {
+ CheckDisposed();
+ _data = value;
+ }
+ }
+
+ public CSSNode this[int index]
+ {
+ get
+ {
+ CheckDisposed();
+ return _children[index];
+ }
+ }
+
+ public int Count
+ {
+ get
+ {
+ CheckDisposed();
+ return _children.Count;
+ }
+ }
+
+ public void MarkLayoutSeen()
+ {
+ CheckDisposed();
+ Native.CSSNodeSetHasNewLayout(_cssNode, false);
+ }
+
+ public bool ValuesEqual(float f1, float f2)
+ {
+ if (float.IsNaN(f1) || float.IsNaN(f2))
+ {
+ return float.IsNaN(f1) && float.IsNaN(f2);
+ }
+
+ return Math.Abs(f2 - f1) < float.Epsilon;
+ }
+
+ public void Insert(int index, CSSNode node)
+ {
+ CheckDisposed();
+ _children.Insert(index, node);
+ node._parent = this;
+ Native.CSSNodeInsertChild(_cssNode, node._cssNode, (uint)index);
+ }
+
+ public void RemoveAt(int index)
+ {
+ CheckDisposed();
+ var child = _children[index];
+ child._parent = null;
+ _children.RemoveAt(index);
+ Native.CSSNodeRemoveChild(_cssNode, child._cssNode);
+ }
+
+ public int IndexOf(CSSNode node)
+ {
+ CheckDisposed();
+ return _children.IndexOf(node);
+ }
+
+ public void SetMeasureFunction(MeasureFunction measureFunction)
+ {
+ CheckDisposed();
+ _measureFunction = measureFunction;
+ Native.CSSNodeSetMeasureFunc(_cssNode, measureFunction != null ? _measureFunc : null);
+ }
+
+ public void CalculateLayout(CSSLayoutContext layoutContext)
+ {
+ CheckDisposed();
+ Native.CSSNodeCalculateLayout(_cssNode, CSSConstants.Undefined, CSSConstants.Undefined, Native.CSSNodeStyleGetDirection(_cssNode));
+ }
+
+ public long Measure(CSSNode node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode)
+ {
+ if (_measureFunction == null)
+ {
+ throw new InvalidOperationException(@"Measure function is not defined.");
+ }
+
+ var output = new MeasureOutput();
+
+ _measureFunction(this,
+ width,
+ widthMode,
+ height,
+ heightMode,
+ output);
+
+ return ((long)output.Width) << 32 | ((long)output.Height);
+ }
+
+ private CSSSize MeasureInternal(
+ IntPtr context,
+ float width,
+ CSSMeasureMode widthMode,
+ float height,
+ CSSMeasureMode heightMode)
+ {
+ var measureResult = Measure(this, width, widthMode, height, heightMode);
+ var measuredWidth = 0xFFFFFFFF & (measureResult >> 32);
+ var measuredHeight = 0xFFFFFFFF & measureResult;
+
+ return new CSSSize { width = measuredWidth, height = measuredHeight };
+ }
+
+ private void PrintInternal(IntPtr context)
+ {
+ System.Diagnostics.Debug.WriteLine(ToString());
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return ((IEnumerable)_children).GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)_children).GetEnumerator();
+ }
+ }
+}
\ No newline at end of file
diff --git a/csharp/Facebook.CSSLayout/CSSOverflow.cs b/csharp/Facebook.CSSLayout/CSSOverflow.cs
new file mode 100644
index 0000000000..df1492ec2e
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSOverflow.cs
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSOverflow
+ {
+ Visible,
+ Hidden,
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSPositionType.cs b/csharp/Facebook.CSSLayout/CSSPositionType.cs
new file mode 100644
index 0000000000..ac12484dae
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSPositionType.cs
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSPositionType
+ {
+ Relative,
+ Absolute
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSPrintFunc.cs b/csharp/Facebook.CSSLayout/CSSPrintFunc.cs
new file mode 100644
index 0000000000..1a308c03be
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSPrintFunc.cs
@@ -0,0 +1,15 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+using System;
+
+namespace Facebook.CSSLayout
+{
+ public delegate void CSSPrintFunc(IntPtr context);
+}
diff --git a/csharp/Facebook.CSSLayout/CSSPrintOptions.cs b/csharp/Facebook.CSSLayout/CSSPrintOptions.cs
new file mode 100644
index 0000000000..8d608f4ed8
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSPrintOptions.cs
@@ -0,0 +1,18 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSPrintOptions
+ {
+ Layout = 1,
+ Style = 2,
+ Children = 4,
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSSize.cs b/csharp/Facebook.CSSLayout/CSSSize.cs
new file mode 100644
index 0000000000..5fd3a2916e
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSSize.cs
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Facebook.CSSLayout
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct CSSSize
+ {
+ public float width;
+ public float height;
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/CSSWrap.cs b/csharp/Facebook.CSSLayout/CSSWrap.cs
new file mode 100644
index 0000000000..15425b2811
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/CSSWrap.cs
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public enum CSSWrap
+ {
+ NoWrap,
+ Wrap,
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/Facebook.CSSLayout.xproj b/csharp/Facebook.CSSLayout/Facebook.CSSLayout.xproj
new file mode 100644
index 0000000000..2f3cd6f29f
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/Facebook.CSSLayout.xproj
@@ -0,0 +1,21 @@
+
+
+
+ 14.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+
+
+
+ 75bb7605-e54b-4ede-8f5a-ff1f24464236
+ Facebook.CSSLayout
+ .\obj
+ .\bin\
+ v4.5.2
+
+
+
+ 2.0
+
+
+
diff --git a/csharp/Facebook.CSSLayout/MeasureFunction.cs b/csharp/Facebook.CSSLayout/MeasureFunction.cs
new file mode 100644
index 0000000000..db4396dd42
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/MeasureFunction.cs
@@ -0,0 +1,13 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public delegate void MeasureFunction(CSSNode node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode, MeasureOutput measureOutput);
+}
diff --git a/csharp/Facebook.CSSLayout/MeasureOutput.cs b/csharp/Facebook.CSSLayout/MeasureOutput.cs
new file mode 100644
index 0000000000..1543393762
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/MeasureOutput.cs
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+namespace Facebook.CSSLayout
+{
+ public class MeasureOutput
+ {
+ public float Width { get; set; }
+ public float Height { get; set; }
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/Native.cs b/csharp/Facebook.CSSLayout/Native.cs
new file mode 100644
index 0000000000..76cdca614f
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/Native.cs
@@ -0,0 +1,263 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Facebook.CSSLayout
+{
+ internal static class Native
+ {
+ private const string DllName = "CSSLayout.dll";
+
+ [DllImport(DllName)]
+ public static extern IntPtr CSSNodeNew();
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeInit(IntPtr cssNode);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeFree(IntPtr cssNode);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeRemoveChild(IntPtr node, IntPtr child);
+
+ [DllImport(DllName)]
+ public static extern IntPtr CSSNodeGetChild(IntPtr node, uint index);
+
+ [DllImport(DllName)]
+ public static extern uint CSSNodeChildCount(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeCalculateLayout(IntPtr node,
+ float availableWidth,
+ float availableHeight,
+ CSSDirection parentDirection);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeMarkDirty(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern bool CSSNodeIsDirty(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodePrint(IntPtr node, CSSPrintOptions options);
+
+ [DllImport(DllName)]
+ public static extern bool CSSValueIsUndefined(float value);
+
+ #region CSS_NODE_PROPERTY
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeSetContext(IntPtr node, IntPtr context);
+
+ [DllImport(DllName)]
+ public static extern IntPtr CSSNodeGetContext(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeSetMeasureFunc(IntPtr node, CSSMeasureFunc measureFunc);
+
+ [DllImport(DllName)]
+ public static extern CSSMeasureFunc CSSNodeGetMeasureFunc(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeSetPrintFunc(IntPtr node, CSSPrintFunc printFunc);
+
+ [DllImport(DllName)]
+ public static extern CSSPrintFunc CSSNodeGePrintFunc(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeSetIsTextnode(IntPtr node, bool isTextNode);
+
+ [DllImport(DllName)]
+ public static extern bool CSSNodeGetIsTextnode(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeSetHasNewLayout(IntPtr node, bool hasNewLayout);
+
+ [DllImport(DllName)]
+ public static extern bool CSSNodeGetHasNewLayout(IntPtr node);
+
+ #endregion
+
+ #region CSS_NODE_STYLE_PROPERTY
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetDirection(IntPtr node, CSSDirection direction);
+
+ [DllImport(DllName)]
+ public static extern CSSDirection CSSNodeStyleGetDirection(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetFlexDirection(IntPtr node, CSSFlexDirection flexDirection);
+
+ [DllImport(DllName)]
+ public static extern CSSFlexDirection CSSNodeStyleGetFlexDirection(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetJustifyContent(IntPtr node, CSSJustify justifyContent);
+
+ [DllImport(DllName)]
+ public static extern CSSJustify CSSNodeStyleGetJustifyContent(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetAlignContent(IntPtr node, CSSAlign alignContent);
+
+ [DllImport(DllName)]
+ public static extern CSSAlign CSSNodeStyleGetAlignContent(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetAlignItems(IntPtr node, CSSAlign alignItems);
+
+ [DllImport(DllName)]
+ public static extern CSSAlign CSSNodeStyleGetAlignItems(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetAlignSelf(IntPtr node, CSSAlign alignSelf);
+
+ [DllImport(DllName)]
+ public static extern CSSAlign CSSNodeStyleGetAlignSelf(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetPositionType(IntPtr node, CSSPositionType positionType);
+
+ [DllImport(DllName)]
+ public static extern CSSPositionType CSSNodeStyleGetPositionType(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetFlexWrap(IntPtr node, CSSWrap flexWrap);
+
+ [DllImport(DllName)]
+ public static extern CSSWrap CSSNodeStyleGetFlexWrap(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetOverflow(IntPtr node, CSSOverflow flexWrap);
+
+ [DllImport(DllName)]
+ public static extern CSSOverflow CSSNodeStyleGetOverflow(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetFlex(IntPtr node, float flex);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetFlex(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetFlexGrow(IntPtr node, float flexGrow);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetFlexGrow(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetFlexShrink(IntPtr node, float flexShrink);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetFlexShrink(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetFlexBasis(IntPtr node, float flexBasis);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetFlexBasis(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetWidth(IntPtr node, float width);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetWidth(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetHeight(IntPtr node, float height);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetHeight(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetMinWidth(IntPtr node, float minWidth);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetMinWidth(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetMinHeight(IntPtr node, float minHeight);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetMinHeight(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetMaxWidth(IntPtr node, float maxWidth);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetMaxWidth(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetMaxHeight(IntPtr node, float maxHeight);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetMaxHeight(IntPtr node);
+
+ #endregion
+
+ #region CSS_NODE_STYLE_EDGE_PROPERTY
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetPosition(IntPtr node, CSSEdge edge, float position);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetPosition(IntPtr node, CSSEdge edge);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetMargin(IntPtr node, CSSEdge edge, float margin);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetMargin(IntPtr node, CSSEdge edge);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetPadding(IntPtr node, CSSEdge edge, float padding);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetPadding(IntPtr node, CSSEdge edge);
+
+ [DllImport(DllName)]
+ public static extern void CSSNodeStyleSetBorder(IntPtr node, CSSEdge edge, float border);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeStyleGetBorder(IntPtr node, CSSEdge edge);
+
+ #endregion
+
+ #region CSS_NODE_LAYOUT_PROPERTY
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeLayoutGetLeft(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeLayoutGetTop(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeLayoutGetRight(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeLayoutGetBottom(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeLayoutGetWidth(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern float CSSNodeLayoutGetHeight(IntPtr node);
+
+ [DllImport(DllName)]
+ public static extern CSSDirection CSSNodeLayoutGetDirection(IntPtr node);
+
+ #endregion
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/Properties/AssemblyInfo.cs b/csharp/Facebook.CSSLayout/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..95d38201db
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/Properties/AssemblyInfo.cs
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+using System.Reflection;
+using System.Resources;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Facebook, Inc.")]
+[assembly: AssemblyProduct("Facebook.CSSLayout")]
+[assembly: AssemblyTrademark("Copyright (c) 2014-present, Facebook, Inc.")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("75bb7605-e54b-4ede-8f5a-ff1f24464236")]
+
+[assembly: NeutralResourcesLanguage("en")]
+
+[assembly: AssemblyVersion("3.0.0.0")]
diff --git a/csharp/Facebook.CSSLayout/Spacing.cs b/csharp/Facebook.CSSLayout/Spacing.cs
new file mode 100644
index 0000000000..34775464ab
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/Spacing.cs
@@ -0,0 +1,188 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+using System;
+
+namespace Facebook.CSSLayout
+{
+ ///
+ /// Class representing CSS spacing (padding, margin, and borders). This is mostly necessary to
+ /// properly implement interactions and updates for properties like margin, marginLeft, and
+ /// marginHorizontal.
+ ///
+ public class Spacing
+ {
+ ///
+ /// Spacing type that represents the left direction. E.g. marginLeft
.
+ ///
+ public const int Left = 0;
+
+ ///
+ /// Spacing type that represents the top direction. E.g. marginTop
.
+ ///
+ public const int Top = 1;
+
+ ///
+ /// Spacing type that represents the right direction. E.g. marginRight
.
+ ///
+ public const int Right = 2;
+
+ ///
+ /// Spacing type that represents the bottom direction. E.g. marginBottom
.
+ ///
+ public const int Bottom = 3;
+
+ ///
+ /// Spacing type that represents start direction e.g. left in left-to-right, right in right-to-left.
+ ///
+ public const int Start = 4;
+
+ ///
+ /// Spacing type that represents end direction e.g. right in left-to-right, left in right-to-left.
+ ///
+ public const int End = 5;
+
+ ///
+ /// Spacing type that represents horizontal direction (left and right). E.g. marginHorizontal
.
+ ///
+ public const int Horizontal = 6;
+
+ ///
+ /// Spacing type that represents vertical direction (top and bottom). E.g. marginVertical
.
+ ///
+ public const int Vertical = 7;
+
+ ///
+ /// Spacing type that represents all directions (left, top, right, bottom). E.g. margin
.
+ ///
+ public const int All = 8;
+
+ private static readonly int[] _flagsMap = new[]
+ {
+ 1, /*LEFT*/
+ 2, /*TOP*/
+ 4, /*RIGHT*/
+ 8, /*BOTTOM*/
+ 16, /*START*/
+ 32, /*END*/
+ 64, /*HORIZONTAL*/
+ 128, /*VERTICAL*/
+ 256, /*ALL*/
+ };
+
+ private int _valueFlags = 0;
+ private readonly float _defaultValue;
+ private readonly float[] _spacing = NewFullSpacingArray();
+ private bool _hasAliasesSet;
+
+ public Spacing() : this(0)
+ {
+
+ }
+
+ public Spacing(float defaultValue)
+ {
+ _defaultValue = defaultValue;
+ }
+
+ public float Get(int spacingType)
+ {
+ var defaultValue = spacingType == Start || spacingType == End ? CSSConstants.Undefined : _defaultValue;
+
+ if (_valueFlags == 0)
+ {
+ return defaultValue;
+ }
+
+ if ((_valueFlags & _flagsMap[spacingType]) != 0)
+ {
+ return _spacing[spacingType];
+ }
+
+ if (_hasAliasesSet)
+ {
+ var secondType = spacingType == Top || spacingType == Bottom ? Vertical : Horizontal;
+ if ((_valueFlags & _flagsMap[secondType]) != 0)
+ {
+ return _spacing[secondType];
+ }
+ else if ((_valueFlags & _flagsMap[All]) != 0)
+ {
+ return _spacing[All];
+ }
+ }
+
+ return defaultValue;
+ }
+
+ public float GetRaw(int spacingType)
+ {
+ return _spacing[spacingType];
+ }
+
+ public bool Set(int spacingType, float value)
+ {
+ if (FloatEqual(_spacing[spacingType], value))
+ {
+ _spacing[spacingType] = value;
+
+ if (CSSConstants.IsUndefined(value))
+ {
+ _valueFlags &= ~_flagsMap[spacingType];
+ }
+ else
+ {
+ _valueFlags |= ~_flagsMap[spacingType];
+ }
+
+ _hasAliasesSet =
+ (_valueFlags & _flagsMap[All]) != 0 ||
+ (_valueFlags & _flagsMap[Vertical]) != 0 ||
+ (_valueFlags & _flagsMap[Horizontal]) != 0;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public void Reset()
+ {
+ for (var i = 0; i < 9; i++) { _spacing[i] = CSSConstants.Undefined; }
+ _hasAliasesSet = false;
+ _valueFlags = 0;
+ }
+
+ private static bool FloatEqual(float f1, float f2)
+ {
+ if (float.IsNaN(f1) || float.IsNaN(f2))
+ {
+ return float.IsNaN(f1) && float.IsNaN(f2);
+ }
+
+ return Math.Abs(f2 - f1) < float.Epsilon;
+ }
+
+ private static float[] NewFullSpacingArray()
+ {
+ return new float[]
+ {
+ CSSConstants.Undefined,
+ CSSConstants.Undefined,
+ CSSConstants.Undefined,
+ CSSConstants.Undefined,
+ CSSConstants.Undefined,
+ CSSConstants.Undefined,
+ CSSConstants.Undefined,
+ CSSConstants.Undefined,
+ CSSConstants.Undefined
+ };
+ }
+ }
+}
diff --git a/csharp/Facebook.CSSLayout/project.json b/csharp/Facebook.CSSLayout/project.json
new file mode 100644
index 0000000000..a0454a86c4
--- /dev/null
+++ b/csharp/Facebook.CSSLayout/project.json
@@ -0,0 +1,14 @@
+{
+ "language": "en",
+ "version": "3.0.0-*",
+
+ "dependencies": {
+ "NETStandard.Library": "1.6.0"
+ },
+
+ "frameworks": {
+ "netstandard1.6": {
+ "imports": "dnxcore50"
+ }
+ }
+}