Skip to content

Commit

Permalink
Initial Record usage, see #1196
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Apr 22, 2021
1 parent d23db3c commit 1d4bf0e
Show file tree
Hide file tree
Showing 11 changed files with 1,361 additions and 699 deletions.
2 changes: 1 addition & 1 deletion js/accessibility/pdom/PDOMFuzzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class PDOMFuzzer {

// Can't include nodes that are included in other accessible orders
for ( let i = 0; i < order.length; i++ ) {
if ( order[ i ]._pdomParent && order[ i ]._pdomParent !== node ) {
if ( order[ i ].pdomParent && order[ i ].pdomParent !== node ) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/accessibility/pdom/PDOMPeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ class PDOMPeer {
assert && assert( content === null || typeof content === 'string', 'incorrect inner content type' );
assert && assert( this.pdomInstance.children.length === 0, 'descendants exist with accessible content, innerContent cannot be used' );
assert && assert( PDOMUtils.tagNameSupportsContent( this._primarySibling.tagName ),
`tagName: ${this._tagName} does not support inner content` );
`tagName: ${this.tagName} does not support inner content` );

// no-op to support any option order
if ( !this._primarySibling ) {
Expand Down
20 changes: 10 additions & 10 deletions js/accessibility/pdom/PDOMTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const PDOMTree = {

const blockedDisplays = PDOMTree.beforeOp( child );

if ( !child._pdomParent ) {
if ( !child.pdomParent ) {
PDOMTree.addTree( parent, child );
}

Expand All @@ -60,7 +60,7 @@ const PDOMTree = {

const blockedDisplays = PDOMTree.beforeOp( child );

if ( !child._pdomParent ) {
if ( !child.pdomParent ) {
PDOMTree.removeTree( parent, child );
}

Expand Down Expand Up @@ -121,11 +121,11 @@ const PDOMTree = {
// Check some initial conditions
if ( assert ) {
for ( i = 0; i < removedItems; i++ ) {
assert( removedItems[ i ] === null || removedItems[ i ]._pdomParent === node,
assert( removedItems[ i ] === null || removedItems[ i ].pdomParent === node,
'Node should have had an pdomOrder' );
}
for ( i = 0; i < addedItems; i++ ) {
assert( addedItems[ i ] === null || addedItems[ i ]._pdomParent === null,
assert( addedItems[ i ] === null || addedItems[ i ].pdomParent === null,
'Node is already specified in an pdomOrder' );
}
}
Expand All @@ -142,7 +142,7 @@ const PDOMTree = {
const removedItemToRemove = removedItems[ i ];
if ( removedItemToRemove ) {
PDOMTree.removeTree( node, removedItemToRemove, pdomTrails );
removedItemToRemove._pdomParent = null;
removedItemToRemove.pdomParent = null;
}
}

Expand All @@ -154,7 +154,7 @@ const PDOMTree = {
for ( j = 0; j < removedParents.length; j++ ) {
PDOMTree.removeTree( removedParents[ j ], addedItemToRemove );
}
addedItemToRemove._pdomParent = node;
addedItemToRemove.pdomParent = node;
}
}

Expand Down Expand Up @@ -197,7 +197,7 @@ const PDOMTree = {
const blockedDisplays = PDOMTree.beforeOp( node );

let i;
const parents = node._pdomParent ? [ node._pdomParent ] : node._parents;
const parents = node.pdomParent ? [ node.pdomParent ] : node._parents;
const pdomTrailsList = []; // pdomTrailsList[ i ] := PDOMTree.findPDOMTrails( parents[ i ] )

// For now, just regenerate the full tree. Could optimize in the future, if we can swap the content for an
Expand Down Expand Up @@ -475,7 +475,7 @@ const PDOMTree = {
}
}

const parents = root._pdomParent ? [ root._pdomParent ] : root._parents;
const parents = root.pdomParent ? [ root.pdomParent ] : root._parents;
const parentCount = parents.length;
for ( i = 0; i < parentCount; i++ ) {
const parent = parents[ i ];
Expand Down Expand Up @@ -564,8 +564,8 @@ const PDOMTree = {
trail.removeAncestor();
}
// Only visit the pdomParent if we didn't already visit it as a parent.
if ( root._pdomParent && !root._pdomParent.hasChild( root ) ) {
trail.addAncestor( root._pdomParent );
if ( root.pdomParent && !root.pdomParent.hasChild( root ) ) {
trail.addAncestor( root.pdomParent );
recursiveSearch();
trail.removeAncestor();
}
Expand Down
1,491 changes: 1,005 additions & 486 deletions js/accessibility/pdom/ParallelDOM.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions js/display/BackboneDrawable.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,9 @@ class BackboneDrawable extends Drawable {
const node = this.watchedFilterNodes[ i ];
const opacity = node.getEffectiveOpacity();

for ( let j = 0; j < node._filters.length; j++ ) {
filterString += `${filterString ? ' ' : ''}${node._filters[ j ].getCSSFilterString()}`;
const filters = node.getInternalFilters();
for ( let j = 0; j < filters.length; j++ ) {
filterString += `${filterString ? ' ' : ''}${filters[ j ].getCSSFilterString()}`;
}

// Apply opacity after other effects
Expand Down
6 changes: 3 additions & 3 deletions js/display/CanvasBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ class CanvasBlock extends FittedBlock {

// We should not apply opacity or other filters at or below the filter root
if ( i > filterRootIndex ) {
if ( node._filters.length ) {
const filters = node.getInternalFilters();
if ( filters.length ) {
sceneryLog && sceneryLog.CanvasBlock && sceneryLog.CanvasBlock( `Pop filters ${trail.subtrailTo( node ).toDebugString()}` );

const topWrapper = this.wrapperStack[ this.wrapperStackIndex ];
Expand All @@ -322,7 +323,6 @@ class CanvasBlock extends FittedBlock {

bottomWrapper.context.setTransform( 1, 0, 0, 1, 0, 0 );

const filters = node._filters;
// We need to fall back to a different filter behavior with Chrome, since it over-darkens otherwise with the
// built-in feature.
// NOTE: Not blocking chromium anymore, see https://github.com/phetsims/scenery/issues/1139
Expand Down Expand Up @@ -391,7 +391,7 @@ class CanvasBlock extends FittedBlock {
this.pushWrapper();
}

if ( node._filters.length ) {
if ( node.getInternalFilters().length ) {
sceneryLog && sceneryLog.CanvasBlock && sceneryLog.CanvasBlock( `Push filters ${trail.subtrailTo( node ).toDebugString()}` );

// Push filters
Expand Down
25 changes: 15 additions & 10 deletions js/display/Instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,28 +378,29 @@ class Instance {
this.groupRenderer = 0;
this.sharedCacheRenderer = 0;

const hints = this.node._hints;
const renderer = this.node.getInternalRenderer();

this.isUnderCanvasCache = this.isSharedCanvasCacheRoot ||
( this.parent ? ( this.parent.isUnderCanvasCache || this.parent.isInstanceCanvasCache || this.parent.isSharedCanvasCacheSelf ) : false );

// set up our preferred renderer list (generally based on the parent)
this.preferredRenderers = this.parent ? this.parent.preferredRenderers : defaultPreferredRenderers;
// allow the node to modify its preferred renderers (and those of its descendants)
if ( hints.renderer ) {
this.preferredRenderers = Renderer.pushOrderBitmask( this.preferredRenderers, hints.renderer );
if ( renderer ) {
this.preferredRenderers = Renderer.pushOrderBitmask( this.preferredRenderers, renderer );
}

const hasClip = this.node.hasClipArea();
const hasFilters = this.node.effectiveOpacity !== 1 || hints.usesOpacity || this.node._filters.length > 0;
const filters = this.node.getInternalFilters();
const hasFilters = this.node.effectiveOpacity !== 1 || this.node.usesOpacity || filters.length > 0;
// let hasNonDOMFilter = false;
let hasNonSVGFilter = false;
let hasNonCanvasFilter = false;
// let hasNonWebGLFilter = false;
if ( hasFilters ) {
// NOTE: opacity is OK with all of those (currently)
for ( let i = 0; i < this.node._filters.length; i++ ) {
const filter = this.node._filters[ i ];
for ( let i = 0; i < filters.length; i++ ) {
const filter = filters[ i ];

// TODO: how to handle this, if we split AT the node?
// if ( !filter.isDOMCompatible() ) {
Expand All @@ -416,7 +417,8 @@ class Instance {
// }
}
}
const requiresSplit = hints.cssTransform || hints.layerSplit;
const cssTransform = this.node.cssTransform;
const requiresSplit = cssTransform || this.node.layerSplit;
const backboneRequired = this.isDisplayRoot || ( !this.isUnderCanvasCache && requiresSplit );

// Support either "all Canvas" or "all SVG" opacity/clip
Expand All @@ -426,6 +428,9 @@ class Instance {
( !hasNonCanvasFilter && this.node._rendererSummary.isSubtreeRenderedExclusivelyCanvas( this.preferredRenderers ) ) );
const useBackbone = applyTransparencyWithBlock ? false : ( backboneRequired || hasFilters || hasClip );

const canvasCacheHint = false;
const singleCacheHint = false;

// check if we need a backbone or cache
// if we are under a canvas cache, we will NEVER have a backbone
// splits are accomplished just by having a backbone
Expand All @@ -434,17 +439,17 @@ class Instance {
if ( useBackbone ) {
this.isBackbone = true;
this.isVisibilityApplied = true;
this.isTransformed = this.isDisplayRoot || !!hints.cssTransform; // for now, only trigger CSS transform if we have the specific hint
this.isTransformed = this.isDisplayRoot || !!cssTransform; // for now, only trigger CSS transform if we have the specific hint
//OHTWO TODO: check whether the force acceleration hint is being used by our DOMBlock
this.groupRenderer = Renderer.bitmaskDOM; // probably won't be used
}
else if ( !applyTransparencyWithBlock && ( hasFilters || hasClip || hints.canvasCache ) ) {
else if ( !applyTransparencyWithBlock && ( hasFilters || hasClip || canvasCacheHint ) ) {
// everything underneath needs to be renderable with Canvas, otherwise we cannot cache
assert && assert( this.node._rendererSummary.isSingleCanvasSupported(),
`hints.canvasCache provided, but not all node contents can be rendered with Canvas under ${
this.node.constructor.name}` );

if ( hints.singleCache ) {
if ( singleCacheHint ) {
// TODO: scale options - fixed size, match highest resolution (adaptive), or mipmapped
if ( this.isSharedCanvasCacheRoot ) {
this.isSharedCanvasCacheSelf = true;
Expand Down
7 changes: 4 additions & 3 deletions js/display/SVGGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ class SVGGroup {
svgGroup.removeAttribute( 'opacity' );
}

const needsFilter = this.willApplyFilters && this.node._filters.length;
const filters = this.node.getInternalFilters();
const needsFilter = this.willApplyFilters && filters.length;
const filterId = `filter-${this.id}`;

if ( needsFilter ) {
Expand All @@ -319,9 +320,9 @@ class SVGGroup {
// Fill in elements into our filter
let filterRegionPercentageIncrease = 50;
let inName = 'SourceGraphic';
const length = this.node._filters.length;
const length = filters.length;
for ( let i = 0; i < length; i++ ) {
const filter = this.node._filters[ i ];
const filter = filters[ i ];

const resultName = i === length - 1 ? undefined : `e${i}`; // Last result should be undefined
filter.applySVGFilter( this.filterElement, inName, resultName );
Expand Down
8 changes: 5 additions & 3 deletions js/display/WebGLBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,15 @@ class WebGLBlock extends FittedBlock {
this.spriteSheets[ i ].updateTexture();
}

const firstDrawableWebGLScale = this.firstDrawable.node.webglScale;

// temporary hack for supporting webglScale
if ( this.firstDrawable &&
this.firstDrawable === this.lastDrawable &&
this.firstDrawable.node &&
this.firstDrawable.node._hints.webglScale !== null &&
this.backingScale !== this.originalBackingScale * this.firstDrawable.node._hints.webglScale ) {
this.backingScale = this.originalBackingScale * this.firstDrawable.node._hints.webglScale;
firstDrawableWebGLScale !== null &&
this.backingScale !== this.originalBackingScale * firstDrawableWebGLScale ) {
this.backingScale = this.originalBackingScale * firstDrawableWebGLScale;
this.dirtyFit = true;
}

Expand Down
Loading

0 comments on commit 1d4bf0e

Please sign in to comment.