refactor(ivy): Switch styling to new reconcile algorithm (#34616)

NOTE: This change must be reverted with previous deletes so that it code remains in build-able state.

This change deletes old styling code and replaces it with a simplified styling algorithm.

The mental model for the new algorithm is:
- Create a linked list of styling bindings in the order of priority. All styling bindings ere executed in compiled order and than a linked list of bindings is created in priority order.
- Flush the style bindings at the end of `advance()` instruction. This implies that there are two flush events. One at the end of template `advance` instruction in the template. Second one at the end of `hostBindings` `advance` instruction when processing host bindings (if any).
- Each binding instructions effectively updates the string to represent the string at that location. Because most of the bindings are additive, this is a cheap strategy in most cases. In rare cases the strategy requires removing tokens from the styling up to this point. (We expect that to be rare case)S Because, the bindings are presorted in the order of priority, it is safe to resume the processing of the concatenated string from the last change binding.

PR Close #34616
This commit is contained in:
Miško Hevery
2019-12-17 15:40:37 -08:00
parent 1ccf3e54f7
commit 49e8028f26
60 changed files with 2439 additions and 1413 deletions

View File

@ -113,9 +113,6 @@
{
"name": "RENDERER_FACTORY"
},
{
"name": "RendererStyleFlags3"
},
{
"name": "SANITIZER"
},
@ -158,18 +155,12 @@
{
"name": "addHostBindingsToExpandoInstructions"
},
{
"name": "addItemToStylingMap"
},
{
"name": "addToViewTree"
},
{
"name": "allocLFrame"
},
{
"name": "allocStylingMapArray"
},
{
"name": "appendChild"
},
@ -195,7 +186,13 @@
"name": "classIndexOf"
},
{
"name": "concatString"
"name": "clearActiveHostElement"
},
{
"name": "computeStaticStyling"
},
{
"name": "concatStringsWithSpace"
},
{
"name": "createDirectivesInstances"
@ -284,9 +281,6 @@
{
"name": "findDirectiveDefMatches"
},
{
"name": "forceStylesAsString"
},
{
"name": "generateExpandoInstructionBlock"
},
@ -335,9 +329,6 @@
{
"name": "getFirstNativeNode"
},
{
"name": "getInitialStylingValue"
},
{
"name": "getInjectorIndex"
},
@ -353,12 +344,6 @@
{
"name": "getLViewParent"
},
{
"name": "getMapProp"
},
{
"name": "getMapValue"
},
{
"name": "getNameOnlyMarkerIndex"
},
@ -407,15 +392,9 @@
{
"name": "getSelectedIndex"
},
{
"name": "getStylingMapArray"
},
{
"name": "growHostVarsSpace"
},
{
"name": "hasActiveElementFlag"
},
{
"name": "hasClassInput"
},
@ -428,18 +407,12 @@
{
"name": "hasTagAndTypeMatch"
},
{
"name": "hyphenate"
},
{
"name": "includeViewProviders"
},
{
"name": "increaseElementDepthCount"
},
{
"name": "incrementActiveDirectiveId"
},
{
"name": "incrementInitPhaseFlags"
},
@ -509,12 +482,6 @@
{
"name": "isProceduralRenderer"
},
{
"name": "isStylingContext"
},
{
"name": "isStylingValueDefined"
},
{
"name": "leaveDI"
},
@ -557,12 +524,6 @@
{
"name": "noSideEffects"
},
{
"name": "objectToClassName"
},
{
"name": "setHostBindingsByExecutingExpandoInstructions"
},
{
"name": "refreshChildComponents"
},
@ -581,9 +542,6 @@
{
"name": "refreshView"
},
{
"name": "registerInitialStylingOnTNode"
},
{
"name": "registerPostOrderHooks"
},
@ -599,15 +557,9 @@
{
"name": "renderComponent"
},
{
"name": "renderInitialStyling"
},
{
"name": "renderStringify"
},
{
"name": "renderStylingMap"
},
{
"name": "renderView"
},
@ -623,9 +575,6 @@
{
"name": "saveResolvedLocalsInData"
},
{
"name": "selectClassBasedInputName"
},
{
"name": "selectIndexInternal"
},
@ -638,17 +587,14 @@
{
"name": "setBindingRoot"
},
{
"name": "setClass"
},
{
"name": "setClassName"
},
{
"name": "setCurrentQueryIndex"
},
{
"name": "setDirectiveStylingInput"
"name": "setDirectiveInputsWhichShadowsStyling"
},
{
"name": "setHostBindingsByExecutingExpandoInstructions"
},
{
"name": "setIncludeViewProviders"
@ -665,30 +611,18 @@
{
"name": "setIsNotParent"
},
{
"name": "setMapValue"
},
{
"name": "setPreviousOrParentTNode"
},
{
"name": "setSelectedIndex"
},
{
"name": "setStyle"
},
{
"name": "setStyleAttr"
},
{
"name": "setUpAttributes"
},
{
"name": "stringifyForError"
},
{
"name": "stylingMapToString"
},
{
"name": "syncViewWithBlueprint"
},
@ -698,14 +632,14 @@
{
"name": "unwrapRNode"
},
{
"name": "updateRawValueOnContext"
},
{
"name": "viewAttachedToChangeDetector"
},
{
"name": "writeStylingValueDirectly"
"name": "writeDirectClass"
},
{
"name": "writeDirectStyle"
},
{
"name": "ɵɵdefineComponent"

View File

@ -104,9 +104,6 @@
{
"name": "RENDERER_FACTORY"
},
{
"name": "RendererStyleFlags3"
},
{
"name": "SANITIZER"
},
@ -143,18 +140,12 @@
{
"name": "addHostBindingsToExpandoInstructions"
},
{
"name": "addItemToStylingMap"
},
{
"name": "addToViewTree"
},
{
"name": "allocLFrame"
},
{
"name": "allocStylingMapArray"
},
{
"name": "appendChild"
},
@ -174,7 +165,13 @@
"name": "callHooks"
},
{
"name": "concatString"
"name": "clearActiveHostElement"
},
{
"name": "computeStaticStyling"
},
{
"name": "concatStringsWithSpace"
},
{
"name": "createLFrame"
@ -242,9 +239,6 @@
{
"name": "extractPipeDef"
},
{
"name": "forceStylesAsString"
},
{
"name": "generateExpandoInstructionBlock"
},
@ -278,9 +272,6 @@
{
"name": "getFirstNativeNode"
},
{
"name": "getInitialStylingValue"
},
{
"name": "getInjectorIndex"
},
@ -296,12 +287,6 @@
{
"name": "getLViewParent"
},
{
"name": "getMapProp"
},
{
"name": "getMapValue"
},
{
"name": "getNativeAnchorNode"
},
@ -344,27 +329,15 @@
{
"name": "getSelectedIndex"
},
{
"name": "getStylingMapArray"
},
{
"name": "growHostVarsSpace"
},
{
"name": "hasActiveElementFlag"
},
{
"name": "hasParentInjector"
},
{
"name": "hyphenate"
},
{
"name": "includeViewProviders"
},
{
"name": "incrementActiveDirectiveId"
},
{
"name": "incrementInitPhaseFlags"
},
@ -404,12 +377,6 @@
{
"name": "isProceduralRenderer"
},
{
"name": "isStylingContext"
},
{
"name": "isStylingValueDefined"
},
{
"name": "leaveDI"
},
@ -443,12 +410,6 @@
{
"name": "noSideEffects"
},
{
"name": "objectToClassName"
},
{
"name": "setHostBindingsByExecutingExpandoInstructions"
},
{
"name": "refreshChildComponents"
},
@ -467,9 +428,6 @@
{
"name": "refreshView"
},
{
"name": "registerInitialStylingOnTNode"
},
{
"name": "registerPreOrderHooks"
},
@ -482,15 +440,9 @@
{
"name": "renderComponent"
},
{
"name": "renderInitialStyling"
},
{
"name": "renderStringify"
},
{
"name": "renderStylingMap"
},
{
"name": "renderView"
},
@ -509,59 +461,44 @@
{
"name": "setBindingRoot"
},
{
"name": "setClass"
},
{
"name": "setClassName"
},
{
"name": "setCurrentQueryIndex"
},
{
"name": "setHostBindingsByExecutingExpandoInstructions"
},
{
"name": "setIncludeViewProviders"
},
{
"name": "setInjectImplementation"
},
{
"name": "setMapValue"
},
{
"name": "setPreviousOrParentTNode"
},
{
"name": "setSelectedIndex"
},
{
"name": "setStyle"
},
{
"name": "setStyleAttr"
},
{
"name": "setUpAttributes"
},
{
"name": "stringifyForError"
},
{
"name": "stylingMapToString"
},
{
"name": "syncViewWithBlueprint"
},
{
"name": "unwrapRNode"
},
{
"name": "updateRawValueOnContext"
},
{
"name": "viewAttachedToChangeDetector"
},
{
"name": "writeStylingValueDirectly"
"name": "writeDirectClass"
},
{
"name": "writeDirectStyle"
},
{
"name": "ɵɵdefineComponent"

View File

@ -2,9 +2,6 @@
{
"name": "ACTIVE_INDEX"
},
{
"name": "BIT_MASK_START_VALUE"
},
{
"name": "BLOOM_MASK"
},
@ -38,18 +35,6 @@
{
"name": "DECLARATION_VIEW"
},
{
"name": "DEFAULT_BINDING_INDEX"
},
{
"name": "DEFAULT_BINDING_VALUE"
},
{
"name": "DEFAULT_GUARD_MASK_VALUE"
},
{
"name": "DEFAULT_TOTAL_SOURCES"
},
{
"name": "DOCUMENT"
},
@ -90,7 +75,7 @@
"name": "HOST"
},
{
"name": "INDEX_START_VALUE"
"name": "IGNORE_DUE_TO_INPUT_SHADOW"
},
{
"name": "INJECTOR"
@ -107,12 +92,6 @@
{
"name": "IterableDiffers"
},
{
"name": "MAP_BASED_ENTRY_PROP_NAME"
},
{
"name": "MAP_DIRTY_VALUE"
},
{
"name": "MONKEY_PATCH_KEY_NAME"
},
@ -206,15 +185,9 @@
{
"name": "RecordViewTuple"
},
{
"name": "RendererStyleFlags3"
},
{
"name": "SANITIZER"
},
{
"name": "STYLING_INDEX_FOR_MAP_BINDING"
},
{
"name": "SWITCH_ELEMENT_REF_FACTORY"
},
@ -230,9 +203,6 @@
{
"name": "SkipSelf"
},
{
"name": "TEMPLATE_DIRECTIVE_INDEX"
},
{
"name": "TNODE"
},
@ -317,9 +287,6 @@
{
"name": "__window"
},
{
"name": "_activeStylingMapApplyFn"
},
{
"name": "_currentInjector"
},
@ -332,27 +299,15 @@
{
"name": "_renderCompCount"
},
{
"name": "_state"
},
{
"name": "_symbolIterator"
},
{
"name": "addBindingIntoContext"
},
{
"name": "addComponentLogic"
},
{
"name": "addHostBindingsToExpandoInstructions"
},
{
"name": "addItemToStylingMap"
},
{
"name": "addNewSourceColumn"
},
{
"name": "addRemoveViewFromContainer"
},
@ -365,21 +320,12 @@
{
"name": "allocLFrame"
},
{
"name": "allocStylingMapArray"
},
{
"name": "allocTStylingContext"
},
{
"name": "allocateNewContextEntry"
},
{
"name": "allowDirectStyling"
},
{
"name": "appendChild"
},
{
"name": "appendStyling"
},
{
"name": "applyContainer"
},
@ -389,15 +335,6 @@
{
"name": "applyProjectionRecursive"
},
{
"name": "applyStylingValue"
},
{
"name": "applyStylingValueDirectly"
},
{
"name": "applyStylingViaContext"
},
{
"name": "applyToElementOrContainer"
},
@ -437,17 +374,50 @@
{
"name": "checkNoChangesInternal"
},
{
"name": "checkStylingProperty"
},
{
"name": "classIndexOf"
},
{
"name": "cleanUpView"
},
{
"name": "clearActiveHostElement"
},
{
"name": "collectNativeNodes"
},
{
"name": "concatString"
"name": "computeClassChanges"
},
{
"name": "computeStaticStyling"
},
{
"name": "computeStyleChanges"
},
{
"name": "concatStringsWithSpace"
},
{
"name": "consumeClassToken"
},
{
"name": "consumeQuotedText"
},
{
"name": "consumeSeparator"
},
{
"name": "consumeStyleKey"
},
{
"name": "consumeStyleValue"
},
{
"name": "consumeWhitespace"
},
{
"name": "createContainerRef"
@ -575,9 +545,6 @@
{
"name": "extractPipeDef"
},
{
"name": "findAndApplyMapValue"
},
{
"name": "findAttrIndexInNode"
},
@ -591,10 +558,10 @@
"name": "findViaComponent"
},
{
"name": "flushStyling"
"name": "flushStyleBinding"
},
{
"name": "forceStylesAsString"
"name": "flushStylingOnElementExit"
},
{
"name": "forwardRef"
@ -608,15 +575,9 @@
{
"name": "generatePropertyAliases"
},
{
"name": "getActiveDirectiveId"
},
{
"name": "getBeforeNodeForView"
},
{
"name": "getBindingValue"
},
{
"name": "getBindingsEnabled"
},
@ -624,7 +585,7 @@
"name": "getCheckNoChangesMode"
},
{
"name": "getClassesContext"
"name": "getClassBindingChanged"
},
{
"name": "getCleanup"
@ -647,9 +608,6 @@
{
"name": "getContainerRenderParent"
},
{
"name": "getContext"
},
{
"name": "getContextLView"
},
@ -659,9 +617,6 @@
{
"name": "getDebugContext"
},
{
"name": "getDefaultValue"
},
{
"name": "getDirectiveDef"
},
@ -680,12 +635,6 @@
{
"name": "getFirstNativeNode"
},
{
"name": "getGuardMask"
},
{
"name": "getInitialStylingValue"
},
{
"name": "getInjectableDef"
},
@ -705,10 +654,10 @@
"name": "getLViewParent"
},
{
"name": "getMapProp"
"name": "getLastParsedKey"
},
{
"name": "getMapValue"
"name": "getLastParsedValue"
},
{
"name": "getNameOnlyMarkerIndex"
@ -773,35 +722,14 @@
{
"name": "getPreviousOrParentTNode"
},
{
"name": "getProp"
},
{
"name": "getPropConfig"
},
{
"name": "getPropValuesStartPosition"
},
{
"name": "getRenderParent"
},
{
"name": "getRenderer"
},
{
"name": "getSelectedIndex"
},
{
"name": "getStylesContext"
},
{
"name": "getStylingMapArray"
},
{
"name": "getStylingMapsSyncFn"
},
{
"name": "getStylingState"
"name": "getStyleBindingChanged"
},
{
"name": "getSymbolIterator"
@ -810,10 +738,19 @@
"name": "getTNode"
},
{
"name": "getTViewCleanup"
"name": "getTStylingRangeNext"
},
{
"name": "getTotalSources"
"name": "getTStylingRangePrev"
},
{
"name": "getTStylingRangePrevDuplicate"
},
{
"name": "getTStylingRangeTail"
},
{
"name": "getTViewCleanup"
},
{
"name": "getTypeName"
@ -821,42 +758,27 @@
{
"name": "getTypeNameForDebugging"
},
{
"name": "getValue"
},
{
"name": "getValuesCount"
},
{
"name": "growHostVarsSpace"
},
{
"name": "handleError"
},
{
"name": "hasActiveElementFlag"
},
{
"name": "hasClassInput"
},
{
"name": "hasConfig"
},
{
"name": "hasParentInjector"
},
{
"name": "hasStyleInput"
},
{
"name": "hasStylingInputShadow"
},
{
"name": "hasTagAndTypeMatch"
},
{
"name": "hasValueChanged"
},
{
"name": "hyphenate"
},
{
"name": "includeViewProviders"
},
@ -864,7 +786,7 @@
"name": "increaseElementDepthCount"
},
{
"name": "incrementActiveDirectiveId"
"name": "incrementBindingIndex"
},
{
"name": "incrementInitPhaseFlags"
@ -893,6 +815,9 @@
{
"name": "insertBloom"
},
{
"name": "insertTStylingBinding"
},
{
"name": "insertView"
},
@ -917,6 +842,9 @@
{
"name": "invokeHostBindingsInCreationMode"
},
{
"name": "isActiveHostElement"
},
{
"name": "isAnimationProp"
},
@ -948,10 +876,7 @@
"name": "isForwardRef"
},
{
"name": "isHostStyling"
},
{
"name": "isHostStylingActive"
"name": "isInHostBindings"
},
{
"name": "isJsObject"
@ -983,15 +908,6 @@
{
"name": "isRootView"
},
{
"name": "isSanitizationRequired"
},
{
"name": "isStylingContext"
},
{
"name": "isStylingValueDefined"
},
{
"name": "iterateListLike"
},
@ -1037,6 +953,12 @@
{
"name": "markDirtyIfOnPush"
},
{
"name": "markDuplicates"
},
{
"name": "markStylingBindingDirty"
},
{
"name": "markViewDirty"
},
@ -1083,19 +1005,28 @@
"name": "noSideEffects"
},
{
"name": "normalizeBitMaskValue"
"name": "parseClassName"
},
{
"name": "objectToClassName"
"name": "parseClassNameNext"
},
{
"name": "patchConfig"
"name": "parseKeyValue"
},
{
"name": "patchHostStylingFlag"
"name": "parseStyle"
},
{
"name": "setHostBindingsByExecutingExpandoInstructions"
"name": "parseStyleNext"
},
{
"name": "parserState"
},
{
"name": "processClassToken"
},
{
"name": "processStyleKeyValue"
},
{
"name": "readPatchedData"
@ -1103,6 +1034,12 @@
{
"name": "readPatchedLView"
},
{
"name": "reconcileClassNames"
},
{
"name": "reconcileStyleNames"
},
{
"name": "refreshChildComponents"
},
@ -1121,12 +1058,6 @@
{
"name": "refreshView"
},
{
"name": "registerBinding"
},
{
"name": "registerInitialStylingOnTNode"
},
{
"name": "registerPostOrderHooks"
},
@ -1139,6 +1070,9 @@
{
"name": "removeListeners"
},
{
"name": "removeStyle"
},
{
"name": "removeView"
},
@ -1157,30 +1091,18 @@
{
"name": "renderDetachView"
},
{
"name": "renderHostBindingsAsStale"
},
{
"name": "renderInitialStyling"
},
{
"name": "renderStringify"
},
{
"name": "renderStylingMap"
},
{
"name": "renderView"
},
{
"name": "resetCurrentStyleSanitizer"
"name": "resetParserState"
},
{
"name": "resetPreOrderHookFlags"
},
{
"name": "resetStylingState"
},
{
"name": "resolveDirectives"
},
@ -1199,15 +1121,9 @@
{
"name": "searchTokensOnInjector"
},
{
"name": "selectClassBasedInputName"
},
{
"name": "selectIndexInternal"
},
{
"name": "setActiveElementFlag"
},
{
"name": "setActiveHostElement"
},
@ -1220,29 +1136,17 @@
{
"name": "setCheckNoChangesMode"
},
{
"name": "setClass"
},
{
"name": "setClassName"
},
{
"name": "setCurrentQueryIndex"
},
{
"name": "setCurrentStyleSanitizer"
},
{
"name": "setDefaultValue"
},
{
"name": "setDirectiveStylingInput"
"name": "setDirectiveInputsWhichShadowsStyling"
},
{
"name": "setElementExitFn"
},
{
"name": "setGuardMask"
"name": "setHostBindingsByExecutingExpandoInstructions"
},
{
"name": "setIncludeViewProviders"
@ -1262,12 +1166,6 @@
{
"name": "setLContainerActiveIndex"
},
{
"name": "setMapAsDirty"
},
{
"name": "setMapValue"
},
{
"name": "setPreviousOrParentTNode"
},
@ -1275,19 +1173,25 @@
"name": "setSelectedIndex"
},
{
"name": "setStyle"
"name": "setTStylingRangeNext"
},
{
"name": "setStyleAttr"
"name": "setTStylingRangeNextDuplicate"
},
{
"name": "setTStylingRangePrev"
},
{
"name": "setTStylingRangePrevDuplicate"
},
{
"name": "setUpAttributes"
},
{
"name": "setValue"
"name": "shouldSearchParent"
},
{
"name": "shouldSearchParent"
"name": "splitClassList"
},
{
"name": "storeCleanupFn"
@ -1299,16 +1203,10 @@
"name": "stringifyForError"
},
{
"name": "stylingApply"
"name": "styleKeyValue"
},
{
"name": "stylingMapToString"
},
{
"name": "stylingProp"
},
{
"name": "syncContextInitialStyling"
"name": "stylingPropertyFirstUpdatePass"
},
{
"name": "syncViewWithBlueprint"
@ -1325,6 +1223,12 @@
{
"name": "tickRootContext"
},
{
"name": "toTStylingRange"
},
{
"name": "toggleClass"
},
{
"name": "trackByIdentity"
},
@ -1337,21 +1241,6 @@
{
"name": "unwrapSafeValue"
},
{
"name": "updateBindingData"
},
{
"name": "updateClassViaContext"
},
{
"name": "updateInitialStylingOnContext"
},
{
"name": "updateRawValueOnContext"
},
{
"name": "updateStyleViaContext"
},
{
"name": "viewAttachedToChangeDetector"
},
@ -1365,7 +1254,16 @@
"name": "wrapListener"
},
{
"name": "writeStylingValueDirectly"
"name": "writeAndReconcileClass"
},
{
"name": "writeAndReconcileStyle"
},
{
"name": "writeDirectClass"
},
{
"name": "writeDirectStyle"
},
{
"name": "ɵɵadvance"