refactor(ivy): revert LNode.data into LViewData[HOST] (#26424)
PR Close #26424
This commit is contained in:

committed by
Miško Hevery

parent
45732e5b91
commit
931e603f80
@ -10,7 +10,8 @@ import {LContainerNode, LElementContainerNode, LElementNode} from './node';
|
||||
import {LQueries} from './query';
|
||||
import {RComment} from './renderer';
|
||||
import {StylingContext} from './styling';
|
||||
import {LViewData, NEXT, PARENT, QUERIES} from './view';
|
||||
import {HOST, LViewData, NEXT, PARENT, QUERIES} from './view';
|
||||
|
||||
|
||||
/**
|
||||
* Below are constants for LContainer indices to help us look up LContainer members
|
||||
@ -18,11 +19,10 @@ import {LViewData, NEXT, PARENT, QUERIES} from './view';
|
||||
* Uglify will inline these when minifying so there shouldn't be a cost.
|
||||
*/
|
||||
export const ACTIVE_INDEX = 0;
|
||||
// PARENT, NEXT, and QUERIES are indices 1, 2, and 3.
|
||||
export const VIEWS = 1;
|
||||
// PARENT, NEXT, QUERIES, and HOST are indices 2, 3, 4, and 5.
|
||||
// As we already have these constants in LViewData, we don't need to re-create them.
|
||||
export const HOST_NATIVE = 4;
|
||||
export const NATIVE = 5;
|
||||
export const VIEWS = 6;
|
||||
export const NATIVE = 6;
|
||||
export const RENDER_PARENT = 7;
|
||||
|
||||
/**
|
||||
@ -43,6 +43,15 @@ export interface LContainer extends Array<any> {
|
||||
*/
|
||||
[ACTIVE_INDEX]: number;
|
||||
|
||||
/**
|
||||
* A list of the container's currently active child views. Views will be inserted
|
||||
* here as they are added and spliced from here when they are removed. We need
|
||||
* to keep a record of current views so we know which views are already in the DOM
|
||||
* (and don't need to be re-added) and so we can remove views from the DOM when they
|
||||
* are no longer required.
|
||||
*/
|
||||
[VIEWS]: LViewData[];
|
||||
|
||||
/**
|
||||
* Access to the parent view is necessary so we can propagate back
|
||||
* up from inside a container to parent[NEXT].
|
||||
@ -63,20 +72,11 @@ export interface LContainer extends Array<any> {
|
||||
|
||||
/** The host node of this LContainer. */
|
||||
// TODO: Should contain just the native element once LNode is removed.
|
||||
[HOST_NATIVE]: LElementNode|LContainerNode|LElementContainerNode|StylingContext;
|
||||
[HOST]: LElementNode|LContainerNode|LElementContainerNode|StylingContext|LViewData;
|
||||
|
||||
/** The comment element that serves as an anchor for this LContainer. */
|
||||
[NATIVE]: RComment;
|
||||
|
||||
/**
|
||||
* A list of the container's currently active child views. Views will be inserted
|
||||
* here as they are added and spliced from here when they are removed. We need
|
||||
* to keep a record of current views so we know which views are already in the DOM
|
||||
* (and don't need to be re-added) and so we can remove views from the DOM when they
|
||||
* are no longer required.
|
||||
*/
|
||||
[VIEWS]: LViewData[];
|
||||
|
||||
/**
|
||||
* Parent Element which will contain the location where all of the Views will be
|
||||
* inserted into to.
|
||||
|
59
packages/core/src/render3/interfaces/context.ts
Normal file
59
packages/core/src/render3/interfaces/context.ts
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
|
||||
import {RElement} from './renderer';
|
||||
import {LViewData} from './view';
|
||||
|
||||
/**
|
||||
* This property will be monkey-patched on elements, components and directives
|
||||
*/
|
||||
export const MONKEY_PATCH_KEY_NAME = '__ngContext__';
|
||||
|
||||
/**
|
||||
* The internal view context which is specific to a given DOM element, directive or
|
||||
* component instance. Each value in here (besides the LViewData and element node details)
|
||||
* can be present, null or undefined. If undefined then it implies the value has not been
|
||||
* looked up yet, otherwise, if null, then a lookup was executed and nothing was found.
|
||||
*
|
||||
* Each value will get filled when the respective value is examined within the getContext
|
||||
* function. The component, element and each directive instance will share the same instance
|
||||
* of the context.
|
||||
*/
|
||||
export interface LContext {
|
||||
/**
|
||||
* The component's parent view data.
|
||||
*/
|
||||
lViewData: LViewData;
|
||||
|
||||
/**
|
||||
* The index instance of the node.
|
||||
*/
|
||||
nodeIndex: number;
|
||||
|
||||
/**
|
||||
* The instance of the DOM node that is attached to the lNode.
|
||||
*/
|
||||
native: RElement;
|
||||
|
||||
/**
|
||||
* The instance of the Component node.
|
||||
*/
|
||||
component: {}|null|undefined;
|
||||
|
||||
/**
|
||||
* The list of active directives that exist on this element.
|
||||
*/
|
||||
directives: any[]|null|undefined;
|
||||
|
||||
/**
|
||||
* The map of local references (local reference name => element or directive instance) that exist
|
||||
* on this element.
|
||||
*/
|
||||
localRefs: {[key: string]: any}|null|undefined;
|
||||
}
|
@ -69,14 +69,6 @@ export interface LNode {
|
||||
* - retrieve the sibling elements of text nodes whose creation / insertion has been delayed
|
||||
*/
|
||||
readonly native: RComment|RElement|RText|null;
|
||||
|
||||
/**
|
||||
* If regular LElementNode, LTextNode, LContainerNode, and LProjectionNode then `data` will be
|
||||
* null.
|
||||
* If LElementNode with component, then `data` contains LViewData.
|
||||
* If LViewNode, then `data` contains the LViewData.
|
||||
*/
|
||||
readonly data: LViewData|null;
|
||||
}
|
||||
|
||||
|
||||
@ -84,30 +76,22 @@ export interface LNode {
|
||||
export interface LElementNode extends LNode {
|
||||
/** The DOM element associated with this node. */
|
||||
readonly native: RElement;
|
||||
|
||||
/** If Component then data has LView (light DOM) */
|
||||
readonly data: LViewData|null;
|
||||
}
|
||||
|
||||
/** LNode representing <ng-container>. */
|
||||
export interface LElementContainerNode extends LNode {
|
||||
/** The DOM comment associated with this node. */
|
||||
readonly native: RComment;
|
||||
readonly data: null;
|
||||
}
|
||||
|
||||
/** LNode representing a #text node. */
|
||||
export interface LTextNode extends LNode {
|
||||
/** The text node associated with this node. */
|
||||
native: RText;
|
||||
readonly data: null;
|
||||
}
|
||||
|
||||
/** Abstract node which contains root nodes of a view. */
|
||||
export interface LViewNode extends LNode {
|
||||
readonly native: null;
|
||||
readonly data: LViewData;
|
||||
}
|
||||
export interface LViewNode extends LNode { readonly native: null; }
|
||||
|
||||
/** Abstract node container which contains other views. */
|
||||
export interface LContainerNode extends LNode {
|
||||
@ -119,14 +103,10 @@ export interface LContainerNode extends LNode {
|
||||
* until the parent view is processed.
|
||||
*/
|
||||
native: RComment;
|
||||
readonly data: null;
|
||||
}
|
||||
|
||||
|
||||
export interface LProjectionNode extends LNode {
|
||||
readonly native: null;
|
||||
readonly data: null;
|
||||
}
|
||||
export interface LProjectionNode extends LNode { readonly native: null; }
|
||||
|
||||
/**
|
||||
* A set of marker values to be used in the attributes arrays. Those markers indicate that some
|
||||
|
@ -121,11 +121,6 @@ import {PlayerContext} from './player';
|
||||
export interface StylingContext extends
|
||||
Array<InitialStyles|{[key: string]: any}|number|string|boolean|LElementNode|StyleSanitizeFn|
|
||||
PlayerContext|null> {
|
||||
/**
|
||||
* Location of element that is used as a target for this context.
|
||||
*/
|
||||
[StylingIndex.ElementPosition]: LElementNode|null;
|
||||
|
||||
/**
|
||||
* Location of animation context (which contains the active players) for this element styling
|
||||
* context.
|
||||
@ -156,6 +151,11 @@ export interface StylingContext extends
|
||||
*/
|
||||
[StylingIndex.ClassOffsetPosition]: number;
|
||||
|
||||
/**
|
||||
* Location of element that is used as a target for this context.
|
||||
*/
|
||||
[StylingIndex.ElementPosition]: LElementNode|null;
|
||||
|
||||
/**
|
||||
* The last class value that was interpreted by elementStylingMap. This is cached
|
||||
* So that the algorithm can exit early incase the value has not changed.
|
||||
@ -201,17 +201,18 @@ export const enum StylingFlags {
|
||||
/** Used as numeric pointer values to determine what cells to update in the `StylingContext` */
|
||||
export const enum StylingIndex {
|
||||
// Position of where the initial styles are stored in the styling context
|
||||
ElementPosition = 0,
|
||||
// Position of where the initial styles are stored in the styling context
|
||||
PlayerContext = 1,
|
||||
PlayerContext = 0,
|
||||
// Position of where the style sanitizer is stored within the styling context
|
||||
StyleSanitizerPosition = 2,
|
||||
StyleSanitizerPosition = 1,
|
||||
// Position of where the initial styles are stored in the styling context
|
||||
InitialStylesPosition = 3,
|
||||
InitialStylesPosition = 2,
|
||||
// Index of location where the start of single properties are stored. (`updateStyleProp`)
|
||||
MasterFlagPosition = 4,
|
||||
MasterFlagPosition = 3,
|
||||
// Index of location where the class index offset value is located
|
||||
ClassOffsetPosition = 5,
|
||||
ClassOffsetPosition = 4,
|
||||
// Position of where the initial styles are stored in the styling context
|
||||
// This index must align with HOST, see interfaces/view.ts
|
||||
ElementPosition = 5,
|
||||
// Position of where the last string-based CSS class value was stored
|
||||
PreviousMultiClassValue = 6,
|
||||
// Position of where the last string-based CSS class value was stored
|
||||
|
@ -13,32 +13,34 @@ import {PlayerHandler} from '../interfaces/player';
|
||||
|
||||
import {LContainer} from './container';
|
||||
import {ComponentDef, ComponentQuery, ComponentTemplate, DirectiveDef, DirectiveDefList, HostBindingsFunction, PipeDef, PipeDefList} from './definition';
|
||||
import {TElementNode, TNode, TViewNode} from './node';
|
||||
import {LContainerNode, LElementContainerNode, LElementNode, TElementNode, TNode, TViewNode} from './node';
|
||||
import {LQueries} from './query';
|
||||
import {Renderer3} from './renderer';
|
||||
import {StylingContext} from './styling';
|
||||
|
||||
/** Size of LViewData's header. Necessary to adjust for it when setting slots. */
|
||||
export const HEADER_OFFSET = 16;
|
||||
export const HEADER_OFFSET = 17;
|
||||
|
||||
// Below are constants for LViewData indices to help us look up LViewData members
|
||||
// without having to remember the specific indices.
|
||||
// Uglify will inline these when minifying so there shouldn't be a cost.
|
||||
export const TVIEW = 0;
|
||||
export const PARENT = 1;
|
||||
export const NEXT = 2;
|
||||
export const QUERIES = 3;
|
||||
export const FLAGS = 4;
|
||||
export const HOST_NODE = 5;
|
||||
export const BINDING_INDEX = 6;
|
||||
export const CLEANUP = 7;
|
||||
export const CONTEXT = 8;
|
||||
export const INJECTOR = 9;
|
||||
export const RENDERER = 10;
|
||||
export const SANITIZER = 11;
|
||||
export const TAIL = 12;
|
||||
export const CONTAINER_INDEX = 13;
|
||||
export const CONTENT_QUERIES = 14;
|
||||
export const DECLARATION_VIEW = 15;
|
||||
export const FLAGS = 1;
|
||||
export const PARENT = 2;
|
||||
export const NEXT = 3;
|
||||
export const QUERIES = 4;
|
||||
export const HOST = 5;
|
||||
export const HOST_NODE = 6;
|
||||
export const BINDING_INDEX = 7;
|
||||
export const CLEANUP = 8;
|
||||
export const CONTEXT = 9;
|
||||
export const INJECTOR = 10;
|
||||
export const RENDERER = 11;
|
||||
export const SANITIZER = 12;
|
||||
export const TAIL = 13;
|
||||
export const CONTAINER_INDEX = 14;
|
||||
export const CONTENT_QUERIES = 15;
|
||||
export const DECLARATION_VIEW = 16;
|
||||
|
||||
// This interface replaces the real LViewData interface if it is an arg or a
|
||||
// return value of a public instruction. This ensures we don't need to expose
|
||||
@ -66,6 +68,9 @@ export interface LViewData extends Array<any> {
|
||||
*/
|
||||
[TVIEW]: TView;
|
||||
|
||||
/** Flags for this view. See LViewFlags for more info. */
|
||||
[FLAGS]: LViewFlags;
|
||||
|
||||
/**
|
||||
* The parent view is needed when we exit the view and must restore the previous
|
||||
* `LViewData`. Without this, the render method would have to keep a stack of
|
||||
@ -90,8 +95,13 @@ export interface LViewData extends Array<any> {
|
||||
/** Queries active for this view - nodes from a view are reported to those queries. */
|
||||
[QUERIES]: LQueries|null;
|
||||
|
||||
/** Flags for this view. See LViewFlags for more info. */
|
||||
[FLAGS]: LViewFlags;
|
||||
/**
|
||||
* The host node for this LViewData instance, if this is a component view.
|
||||
*
|
||||
* If this is an embedded view, HOST will be null.
|
||||
*/
|
||||
// TODO: should store native elements directly when we remove LNode
|
||||
[HOST]: LElementNode|LContainerNode|LElementContainerNode|StylingContext|null;
|
||||
|
||||
/**
|
||||
* Pointer to the `TViewNode` or `TElementNode` which represents the root of the view.
|
||||
|
Reference in New Issue
Block a user