Commit Graph

9142 Commits

Author SHA1 Message Date
Ahmed El-Helw 0c9afec7dc Remove ImageRequestHelper for Nodes
Summary:
Use ImageRequestBuilder directly in Nodes, just like we do for
non-Nodes.

Reviewed By: sriramramani

Differential Revision:
D3660610
Ninja: Sandcastle is broken. 25 denizens of the Facebook republic are affected by this unrelated issue today.
2016-12-19 13:40:31 -08:00
Ahmed El-Helw 7cc4e0364a Fix ARTSurfaceView with Nodes
Summary: ARTSurfaceView wasn't working for Nodes. This patch fixes it.

Differential Revision: D3653522
2016-12-19 13:40:30 -08:00
Seth Kirby 28654aef65 Remove logical adjustments from FlatViewGroup.
Summary: These were needed until recent changes in DrawView.

Reviewed By: ahmedre

Differential Revision: D3646707
2016-12-19 13:40:30 -08:00
Seth Kirby dfc815cb19 Rework clipPath for thread safety.
Summary: Caught a couple potential issues when digging around in DrawView.

Reviewed By: ahmedre

Differential Revision: D3646718
2016-12-19 13:40:30 -08:00
Seth Kirby e96f6fa585 Add directional clipping command manager.
Summary: Add directional aware clipping to DrawCommandManager.  Currently not attached to FlatViewGroup logic, with the plan to keep this unattached until we are clipping the way we want to in the final state.

Reviewed By: ahmedre

Differential Revision: D3622253
2016-12-19 13:40:30 -08:00
Ahmed El-Helw f850e61fdb Fix content:// uris not loading in Nodes
Summary:
In Ads Manager, images weren't loading when they were using
content:// as their uri.

Differential Revision: D3645303
2016-12-19 13:40:30 -08:00
Ahmed El-Helw 2f7da48813 Nodes should support loading file:/// uris
Summary: Non-Nodes supports file:///, and Nodes should too.

Differential Revision: D3639675
2016-12-19 13:40:30 -08:00
Seth Kirby 1d034cf91d Delay dropping root views until the drop views step of StateBuilder.
Summary: @public Make UIOperation public so that custom implementations can expose instances of it.

Reviewed By: ahmedre

Differential Revision: D3618197
2016-12-19 13:40:30 -08:00
Ahmed El-Helw 45e626a887 Default Nodes text color to black
Summary:
Nodes' default text color was NaN, which ended up being white on some
devices.

Differential Revision: D3638348
2016-12-19 13:40:30 -08:00
Ahmed El-Helw 2d8cbd70bc Support rounded clipping
Summary:
Support rounded clipping in Nodes. Before, if a view had
a radius and had overflow of hidden, its children could still draw
outside of it (specifically, in the area between the rounded rect
and square rect) - this is due to the fact that clipping is, by
default, rectangular. This patch supports this type of rounded
clipping.

Differential Revision: D3634861
2016-12-19 13:40:30 -08:00
Seth Kirby 498fc63952 Add position information for DrawViews.
Summary: Previously, we had no information about the positioning of the view until after we had attached it.  We have the position information attached to the shadow node, but this attaches it to the DrawView as well.  It also removes the need for AbstractClippingDrawCommand.

Reviewed By: ahmedre

Differential Revision: D3609092
2016-12-19 13:40:30 -08:00
Mengjue Wang ba56043715 Change the textalign setter to support RTL
Summary: @public Change the textalign setter to support RTL. In order to support text alignment according to layout style, move the textalign setter bridge function from ReactTextViewManager.java to ReactTextShadowNode.java and calculate it correctly on RCTTextUpdate.

Reviewed By: dmmiller

Differential Revision: D3597494
2016-12-19 13:40:30 -08:00
Ahmed El-Helw b8313b282b Fix ViewPager behavior with Nodes
Summary: @public Add a batch addition operation for ViewPager.

Differential Revision: D3597840
2016-12-19 13:40:29 -08:00
Ahmed El-Helw 520f70bd57 Fix measureInWindow for view-backed Nodes
Summary:
This patch fixes measureInWindow for Nodes backed by Views.
Whereas the intention was to call the super implementation when we have a
Node backed by a View, we instead called the super implementation of
measure, which doesn't measure relative to window.

Differential Revision: D3607890
2016-12-19 13:40:29 -08:00
Seth Kirby 690368fc3f Warm text cache.
Summary:
Testing impact of warming text, which shows big wins for other teams, notably Instagram.

https://our.intern.facebook.com/intern/dex/comments-rendering-in-instagram-android/

Reviewed By: ahmedre

Differential Revision: D3603846
2016-12-19 13:40:29 -08:00
Seth Kirby da8ec6fee6 Refactor FlatViewGroup to use DrawCommandManagers.
Summary: Rework FlatViewGroup to more easily transition into more complex draw command managers.

Reviewed By: ahmedre

Differential Revision: D3536262
2016-12-19 13:40:29 -08:00
Seth Kirby a848ce8efd Fix race conditions in DrawView.
Summary:
Currently we have race conditions in DrawView related to isViewGroupClipped, where we create a copy of the DrawView before we update the clipping state, and think the view is unclipped in the next iteration.

Also we are sometimes creating a DrawView with a reactTag of 0.

This fixes both, and is part of the upcoming DrawView bounds change, but is a separate issue that is live in current source.

Reviewed By: ahmedre

Differential Revision: D3598499
2016-12-19 13:40:29 -08:00
Dave Miller 72e665abb4 Set Event timestamp internally
Summary:
@public
This is pure cleanup so that we can make sure that all events are living in the same time space (currently nano seconds).

Reviewed By: foghina

Differential Revision: D3593884
2016-12-19 13:40:29 -08:00
Seth Kirby 8564fc074b Temporary low risk workaround for killing image network requests in rnfeed.
Summary:
View the comment thread for discussion:

https://www.facebook.com/groups/1505872839725322/permalink/1630102823968989

Our current behaviour of add then immediately remove if a view is clipped pretty much guarantees that we kill network requests for images in feed.  We have a better fix for that in the pipeline, but this is a low risk fix in the meantime.

Reviewed By: ahmedre

Differential Revision: D3597785
2016-12-19 13:40:29 -08:00
Mengjue Wang 70fb45393e Provide I18n Module in OSS 3/3
Summary: @public expose context for I18nManagerModule and I18nUtil

Reviewed By: dmmiller

Differential Revision: D3575706
2016-12-19 13:40:29 -08:00
Adam Comella da8759c610 Android: Fix handling of line height with inline images
Summary:
This PR was split from a commit originally in #8619. /cc dmmiller

When an inline image was larger than the specified line height,
the image would be clipped. This changes the behavior so
that the line height is changed to make room for the inline
image. This is consistent with the behavior of RN for iOS.

Here's how the change works.

ReactTextView now receives its line height from the layout thread
rather than directly from JavaScript.

The reason is that the layout thread may pick a different line height.
In the case that the tallest inline image is larger than the line
height supplied by JavaScript, we want to use that image's height as
the line height rather than the supplied line height.

Also fixed a bug where the image, which is supposed to be baseline
aligned, would be positioned at the wrong y location. To fix this,
we use `y` (the baseline) in the `draw` method rather than trying
to calculate the baseline from `bottom`. For more information
see https://code.google.com/p/andro
Closes https://github.com/facebook/react-native/pull/8907

Differential Revision: D3592781

Pulled By: dmmiller
2016-12-19 13:40:29 -08:00
Ahmed El-Helw d89e7475fb Redbox on DrawImageWithDrawee exception
Summary:
DrawImageWithDrawee has caused NPEs when using Nodes in various cases
in RNFeed. This patch explicitly throws a RuntimeException, so that we can
debug as to whether this is coming from bad sources or a bad size for the
image.

Differential Revision: D3574998
2016-12-19 13:40:29 -08:00
Seth Kirby bb5ba3d295 Test perf impact of most straightforward fix for double detach.
Summary: This is the most straightforward fix for the double detach issue.  If a view is not attached, then addViewInLayout never propagates onAttach, and adding through attachViewToParent is a no op.  We could hack something in to attach clipped FlatViewGroups in onClippingRect, but any other view that relies on onAttachedToWindow will have similar issues.

Reviewed By: ahmedre

Differential Revision: D3560565
2016-12-19 13:40:28 -08:00
Seth Kirby 95ae936aa6 Fix for ViewManager commands being run before view updates.
Summary: Since Nodes' manageChildren doesn't enqueue the child updates immediately, commands were being directed to non-updated views.  Previously we applied updates for the shadow node before dispatching the command, but we can instead wait to fire commands until after we update the view hierarchy.

Reviewed By: ahmedre

Differential Revision: D3568541
2016-12-19 13:40:28 -08:00
Seth Kirby 7df627f9be Add support for show layout bounds.
Summary: Supports show layout bounds either by override within FlatViewGroup, or if show layout bounds is set in settings.  Currently requires app restart to disable.

Reviewed By: ahmedre

Differential Revision: D3553669
2016-12-19 13:40:28 -08:00
Seth Kirby 76c2904d31 Add support for WRAP_CONTENT to react views.
Summary: Fixes needing to specify exact height of react views in Mason.  Uses a ViewTreeObserver to delay draw until we have correct bounds.

Reviewed By: sriramramani

Differential Revision: D3527122
2016-12-19 13:40:28 -08:00
Seth Kirby 6cc6cd4d44 Add removed super.dispatchDraw call in FlatViewGroup.
Summary: Accidentally pulled this when fixing comment positioning.  Re-adding now.

Reviewed By: ahmedre

Differential Revision: D3547553
2016-12-19 13:40:28 -08:00
Ahmed El-Helw b300c1979c Support TextDecorationLine in Nodes
Summary:
Nodes wasn't supporting text decorations to the line (strike through
and underline). This patch implements that.

Differential Revision: D3512711
2016-12-19 13:40:28 -08:00
Seth Kirby e674185ea1 Fix a bug with comment box positioning.
Summary: We do want to only apply updates when a view previously wasn't mounted and didn't have a backing view created.  Previously we were applying updates to the view regardless of the mount state, which resulted in positioning bugs.  Rather than revert, I cleaned up the code Ahmed fixed, since didUpdate || ensureBackingViewIsCreated() was both a bug and obscure, as the two should have a swapped order.

Reviewed By: sriramramani

Differential Revision: D3538734
2016-12-19 13:40:28 -08:00
Dave Miller 7562f9d6f5 Fix padding with Text on Android
Summary:
@public
Text was not correctly respecting padding.  We would account for it when measuring, but then not actually apply the padding to the text.  This adds support for proper padding

Reviewed By: andreicoman11

Differential Revision: D3516692
2016-12-19 13:40:28 -08:00
Ahmed El-Helw 87eb779eea Fix commands not always going through with Nodes
Summary:
Previously, to fix the issue of commands happening before the Views
were made and attached to the hierarchy, a check was added to see if a node
had not been mounted to a View, to update its hierarchy. In reality, we need
to do this irrespective, since a node could be mounted to a View, but its
children may not yet be attached, for example. Note that if there is nothing
to be done, this won't do extra work (i.e. applyUpdates recursively goes
through the tree from the node on which we did the operation to apply updates,
but if there are no updates, we stop traversing that praticular subtree).

Reviewed By: sriramramani

Differential Revision: D3511462
2016-12-19 13:40:28 -08:00
Ahmed El-Helw 4622532ca4 Fix TextInput Spannable flags
Summary:
The TextInput spannables are being set wrong by Nodes. Consequently,
when you hit space after a word, anything you type is highlighted, though it
shouldn't be.

Differential Revision: D3507516
2016-12-19 13:40:28 -08:00
Felix Oghina 1b77f1a372 extract MultiSourceHelper
Reviewed By: andreicoman11

Differential Revision: D3505224
2016-12-19 13:40:28 -08:00
Ahmed El-Helw 9a28701bd8 Fix measureInWindow when using Nodes
Summary:
The results from measureInWindow were always wrong the first time it
was called. This was due to the fact that the view in question was not
actually a view yet, so the results were incorrect. This patch uses the
existing measure functionality (which can measure virtual nodes) to measure
the view, while modifying it to properly get the results relative to the
window instead of relative to the root view.

Reviewed By: sriramramani

Differential Revision: D3501544
2016-12-19 13:40:28 -08:00
Andy Street ace1b4d78e Start creating views before end of batch for nodes
Summary:
Depends on D3120798
Depends on D3120631

Enables D3120631 for nodes. This implementation seems to work but let me know if I'm doing something really stupid.

Reviewed By: ahmedre

Differential Revision: D3120814
2016-12-19 13:40:27 -08:00
Ahmed El-Helw f8d623ca3a Fix modals when using Nodes
Summary:
Modals were broken in Nodes, because the custom measurement logic for
all the children of the ReactModalShadowNode was not being applied (because we
wrapped it in a NativeViewWrapper). This change adds a custom flat node type
for modals.

Differential Revision: D3499557
2016-12-19 13:40:27 -08:00
Ahmed El-Helw aadf4dfdc2 Fix DrawImageWithPipeline for Nodes
Summary:
Fix DrawImageWithPipeline's code for checking whether or not an image
request exists or not to be the same as DrawImageWithDrawee's.

Differential Revision: D3489532
2016-12-19 13:40:27 -08:00
Seth Kirby 298a3f947b Remove unnecessary view mounting when views are clipped.
Summary: Reduced view attaching by 93% in mountViews.

Reviewed By: ahmedre

Differential Revision: D3477555
2016-12-19 13:40:27 -08:00
Ahmed El-Helw e5c81e1c1b Fix a Nodes crash when removing children
Summary:
In manageChildren, we were assuming that the indices that
were passed in to be removed were sorted, however, they weren't.
This patch sorts the children to be removed. Note that it doesn't
explicitly sort move, since these are sorted by the MoveProxy class.

Reviewed By: astreet

Differential Revision: D3474639
2016-12-19 13:40:27 -08:00
Ahmed El-Helw f602640e5c Allow for customization of the RootViewManager
Summary:
Groups encountered a pretty major crash where, in many cases,
we would find that DrawCommands and Views were out of sync. This
turns out to be due to the fact that when we drop views from the
root view, we remove each child using removeChildAt (which ultimately
causes an invalidate and redraw). If this happens for a
FlatViewGroup, this causes issues where the Views are all removed,
but there are some DrawCommands (potentially DrawViews) that aren't
removed, hence them going out of sync.

Reviewed By: astreet

Differential Revision: D3473916
2016-12-19 13:40:27 -08:00
Ahmed El-Helw f223335dae Fix measure callback for TextInput on Nodes
Summary: @public Add a MeasureUtil class

Reviewed By: emilsjolander

Differential Revision: D3467598
2016-12-19 13:40:27 -08:00
Seth Kirby 88dfd75aa7 Clip all views when removing clipping subviews, rather than just FlatViewGroup views.
Summary: Currently only FlatViewGroup children were clipped, rather than all offscreen Android views.

Reviewed By: ahmedre

Differential Revision: D3462002
2016-12-19 13:40:27 -08:00
Ahmed El-Helw 241fd0869d Fix autoFocus for TextInput
Summary:
During the patch for fixing the order of UI operations, we apply
updates to any node receiving a ViewManager command in order to ensure that
nodes that were not yet mounted to a View and not yet attached to their parent
would be properly able to receive the event. However, if a node is already a
view, calling the update could cause unwanted things to happen (for example,
the View's bounds changing improperly), because we're only traversing that
node of the tree and down (instead of the entire tree). This fixes the issue
by only applying updates to the node if the view mount state has changed.

Reviewed By: sriramramani

Differential Revision: D3448356
2016-12-19 13:40:27 -08:00
Ahmed El-Helw f0734c141f Fix Nodes crash when text is not spanned
Summary:
A Layout's text can either be an Ellipsizer or a SpannedEllipsizer.
SpannedEllipsizer implements Spannable, but Ellipsizer doesn't. We were
casting the Layout's text directly to a Spanned without first checking as to
whether or not it was actually a Spanned.

Reviewed By: sriramramani

Differential Revision: D3435075
2016-12-19 13:40:27 -08:00
Andrei Coman fc622504de Show low res image if available in cache
Summary: Nodes version of D3392751.

Reviewed By: ahmedre

Differential Revision: D3425740
2016-12-19 13:40:27 -08:00
Andrei Coman c61aafe95d Support multiple sources
Summary:
The nodes version of D3364550. The only difference is that here we
don't get `onSizeChanged` but `onBoundsChanged`, and we need to compute the
height/width of the target image from those bounds. ahmedre please let me know
if any of these assumptions are in any way incorrect.

Reviewed By: ahmedre

Differential Revision: D3424843
2016-12-19 13:40:27 -08:00
Andrei Coman f2a6570b07 Refactor nodes to lazy-load image from source
Summary:
This is needed for the upcoming loading from multiple sources (D3364550 for the non-nodes version) and cache interrogation (D3392751 for non-nodes version).
This postpones creating the DraweeRequestHelper until the image size is known, which in the nodes universe is when `onBoundsChanged` is called.

Reviewed By: foghina, ahmedre

Differential Revision: D3413467
2016-12-19 13:40:26 -08:00
Ahmed El-Helw 4ecfa0c800 Fix touch inspector when using Nodes
Summary:
Fix touch inspector when using Nodes by implementing custom logic.
This logic now takes into account that non-View nodes need to be clickable.

Reviewed By: astreet

Differential Revision: D3433927
2016-12-19 13:40:26 -08:00
Emil Sjolander 5f3f9caceb Refactor RCTText to take advantage of learnings from components
Summary:
Made some improvements to RCTText based on some of our learnings from components for android. This now resembles diffusion/FBS/browse/master/fbandroid/java/com/facebook/components/widget/TextSpec.java

Things that have improved:
- Calculation of text width is now faster (we noticed in components that .getWith() on the layout is all that is needed and it is much faster)
- Use text layout builder to abstract away a lot of the low level details of static / boring layouts and text measurements
- Handle MeasureMode correctly, previously AT_MOST was not supported.
- Better handling of RTL text by using TextLayoutBuilder where I made changes to support RTL text in components. Specifically RTL text measured with UNSPECIFIED or AT_MOST.
- There was an incorrect assumption being made that when measure() was not called the text had to be boring. This is incorrect, Arabic text is never boring for example. Also multiline text is not boring either and may have exact sizing.

Reviewed By: ahmedre

Differential Revision: D3374752
2016-12-19 13:40:26 -08:00
Ahmed El-Helw 754d2848a4 Fix dispatchViewManagerCommand ordering for Nodes
Summary:
The dispatchViewManager command should, according to the spec, only
be executed after children are added. On Nodes, however, due to the fact that
the Views in question may not have been created until the call to the command
occurred, the dispatchViewManagerCommand may occur too early. Consequently,
ensure that we apply any state updates to the Node represented by that
reactTag before we enqueue the view manager command (this will ensure that
views are properly added to the parent, etc before sending the command).

Reviewed By: astreet

Differential Revision: D3428855
2016-12-19 13:40:26 -08:00