Commit Graph

13 Commits

Author SHA1 Message Date
Dustin Shahidehpour
0f822bbef2 Remove overflow and flex from API.
Summary: flex is just shorthand for flexBasis, flexGrow and flexShrink, and I don't want to expose overflow yet, so, removing them from the API.

Reviewed By: ryanolsonk

Differential Revision: D4126773

fbshipit-source-id: e3b9ef714832cb5665bd20d7fa92f97a266c9210
2016-11-04 13:37:40 -07:00
Dustin Shahidehpour
b938017ccf Add Sizing API that doesn't change view's frame.
Summary: This exposes an API so people can find out the resulting size of a layout calculation without changing the frame of the view.

Reviewed By: emilsjolander

Differential Revision: D4124630

fbshipit-source-id: f2b28d8a5474857cb1c92e021a1f161806826cda
2016-11-03 13:07:37 -07:00
Dustin Shahidehpour
d8662805d5 Fix incorrect results from css_usesFlexbox
Summary: With the current implementation, as long as you had set a value on usesFlexbox (YES or NO), it would return YES. This fixes it.

Reviewed By: amonshiz

Differential Revision: D4124485

fbshipit-source-id: 32fe4ec0109b5c8678a112f9d4295bd17a6f6dc2
2016-11-03 09:37:41 -07:00
Dustin Shahidehpour
26e7490fc9 Make CSSNodeRef readonly.
Summary: We don't want people to somehow change the underlying cnode on our CSSNodeBridge. Making it readonly.

Reviewed By: rnystrom

Differential Revision: D4124496

fbshipit-source-id: f88ed82c1df17d401aeca6f6341e429c95e55624
2016-11-03 09:07:37 -07:00
Dustin Shahidehpour
d94363ea7e Cleanup Measure method.
Summary: We have redundant/dead code in UIKit's sizing method, lets clean it up.

Reviewed By: emilsjolander

Differential Revision: D4110939

fbshipit-source-id: 35e856aa6c60fd24316bc67cc564f7eec2d9d714
2016-11-02 17:07:47 -07:00
Lukas Wöhrl
af5e6771d7 Prevent array out of bound access
Summary:
Even so the problem of #236 has been fixed via ced779b there is still a case where you have a out of bound array access of undefined behaviour. This PR prevents the out of bound access of the underlying c array. The out of bound access happens if you already have 4 subViews and add another one. Then you will access CSSNodeGetChild with 4 which points into uninitialized memory.
Closes https://github.com/facebook/css-layout/pull/237

Reviewed By: dshahidehpour

Differential Revision: D4107743

Pulled By: emilsjolander

fbshipit-source-id: 0f21397f3a77308369acfea7327733f74eb72e00
2016-11-01 20:54:00 -07:00
Dustin Shahidehpour
620cb3f507 Remove static method declarations.
Summary: Since these functions are private and only used in the implementation file, we don't need to declare them beforehand.

Reviewed By: emilsjolander

Differential Revision: D4088488

fbshipit-source-id: 738175a4aae27d88d32f8c2cf6b47a4f6ae32aab
2016-10-27 12:52:43 -07:00
Emil Sjolander
46823878a5 BREAKING - Make first parameter of measure and print functions CSSNodeRef instead of just context
Summary: To perform some JNI optimizations for java we need a reference to the node in the measure function. This updates the API to provide the whole node as input instead of just the context.

Reviewed By: javache

Differential Revision: D4081544

fbshipit-source-id: d49679025cea027cf7b8482898de0a01fe0f9d40
2016-10-27 10:52:57 -07:00
Dustin Shahidehpour
26bcc1e072 Remove view.isHidden optimization from sizing/layout.
Summary:
Originally, we thought that skipping the measurement of views that were hidden would be a nice optimiatzion. Upon further review, we saw that according to Apple's `UIView` documentation:

> A hidden view disappears from its window and does not receive input events. It remains in its superview’s list of subviews, however, and participates in autoresizing as usual.

So, to keep parity with common iOS layout APIs, we are going to size and layout views, even if they are hidden.

Reviewed By: emilsjolander

Differential Revision: D4051225

fbshipit-source-id: 0794cbad293a7de83d109dad2b3983d83845d145
2016-10-20 09:37:39 -07:00
Dustin Shahidehpour
eedee80f25 Add Test to make sure associated objects live/die with lifetime of UIView.
Summary: Wrote some tests to make sure the associated objects we use for layout live and die with the objects. This was worthwhile because it made me realize UIView+CSSLayout wasn't enabled to ARC. As a result, my tests were failing because they weren't explicitly deallocing nodes.

Reviewed By: rnystrom

Differential Revision: D4023324

fbshipit-source-id: 5356cf4f0522582d75f83b5eb2193d9bc8d63aee
2016-10-14 14:52:57 -07:00
Dustin Shahidehpour
0254e3e97f Don't call sizeThatFits: if measure modes are exact.
Summary: `sizeThatFits:` can be expensive, this optimizes our measuring function so that we do not call it if we know that we are going to use the exact height and width that were passed-in.

Reviewed By: rnystrom

Differential Revision: D4023715

fbshipit-source-id: dc02703b50bafd168ffab62ed98a7f6342100cc9
2016-10-14 14:52:57 -07:00
Dustin Shahidehpour
05ba3a2565 Do not measure the view if it is hidden.
Summary: If views are hidden on screen, we don't want to bother including them in layout calculations.

Reviewed By: rnystrom

Differential Revision: D4022992

fbshipit-source-id: 2e93eb911f26223f305ef7ce788f86d050b83e4a
2016-10-14 14:37:43 -07:00
Emil Sjolander
8939bcb96d UIView category
Summary: Add flexbox support to UIViews via a category

Reviewed By: dshahidehpour

Differential Revision: D4002873

fbshipit-source-id: f89de3acdf8fd89c7801918dcad34ba9011dd025
2016-10-12 09:37:42 -07:00