-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[change] Use classic CSS in View, Text, etc., implementations
The CSS base styles for certain primitives are implemented using classic CSS to reduce browser layout times and better support 'null' values in StyleSheet-defined styles. Combined with the previous patch this reduces the benchmark layout times by about 30%. Ref #1136 Fix #1044 Fix #1223 Fix #13
- Loading branch information
Showing
16 changed files
with
253 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ative-web/src/exports/StyleSheet/__tests__/__snapshots__/createReactDOMStyle-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright (c) 2016-present, Nicolas Gallagher. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @noflow | ||
*/ | ||
|
||
import { classic } from './compile'; | ||
import styleResolver from './styleResolver'; | ||
import { STYLE_GROUPS } from './constants'; | ||
|
||
/** | ||
* A simple (and dangerous) CSS system. | ||
* The order of CSS rule insertion is not guaranteed. | ||
* Avoiding combining 2 or more classes that modify the same property. | ||
*/ | ||
const css = { | ||
/** | ||
* const classes = css.create({ base: {}, extra: {} }) | ||
*/ | ||
create(rules) { | ||
const result = {}; | ||
Object.keys(rules).forEach(name => { | ||
const style = rules[name]; | ||
const compiled = classic(style, name); | ||
|
||
Object.values(compiled).forEach(({ identifier, rules }) => { | ||
rules.forEach(rule => { | ||
styleResolver.sheet.insert(rule, STYLE_GROUPS.classic); | ||
}); | ||
result[name] = identifier; | ||
}); | ||
}); | ||
return result; | ||
}, | ||
/** | ||
* css.combine(classes.base, classes.extra) | ||
*/ | ||
combine(...args) { | ||
return args.reduce((className, value) => { | ||
if (value) { | ||
className += className.length > 0 ? ' ' + value : value; | ||
} | ||
return className; | ||
}, ''); | ||
} | ||
}; | ||
|
||
export default css; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.