Skip to content

Commit

Permalink
Merge fd63033 into 13b5bf7
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed Dec 2, 2022
2 parents 13b5bf7 + fd63033 commit 28113dc
Show file tree
Hide file tree
Showing 100 changed files with 3,377 additions and 191 deletions.
2 changes: 1 addition & 1 deletion packages/g-camera-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-camera-api",
"version": "1.0.19",
"version": "1.0.20",
"description": "A simple implementation of Camera API.",
"keywords": [
"antv",
Expand Down
14 changes: 7 additions & 7 deletions packages/g-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvas",
"version": "1.9.18",
"version": "1.9.19",
"description": "A renderer implemented by Canvas 2D API",
"keywords": [
"antv",
Expand Down Expand Up @@ -32,12 +32,12 @@
"sync": "tnpm sync"
},
"dependencies": {
"@antv/g-plugin-canvas-path-generator": "^1.1.30",
"@antv/g-plugin-canvas-picker": "^1.8.27",
"@antv/g-plugin-canvas-renderer": "^1.7.33",
"@antv/g-plugin-dom-interaction": "^1.7.30",
"@antv/g-plugin-html-renderer": "^1.7.30",
"@antv/g-plugin-image-loader": "^1.1.31",
"@antv/g-plugin-canvas-path-generator": "^1.1.31",
"@antv/g-plugin-canvas-picker": "^1.8.28",
"@antv/g-plugin-canvas-renderer": "^1.7.34",
"@antv/g-plugin-dom-interaction": "^1.7.31",
"@antv/g-plugin-html-renderer": "^1.7.31",
"@antv/g-plugin-image-loader": "^1.1.32",
"@antv/util": "^3.3.1",
"@types/offscreencanvas": "^2019.6.4",
"tslib": "^2.3.1"
Expand Down
14 changes: 7 additions & 7 deletions packages/g-canvaskit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvaskit",
"version": "0.8.18",
"version": "0.8.19",
"description": "A renderer implemented by CanvasKit",
"keywords": [
"antv",
Expand Down Expand Up @@ -32,12 +32,12 @@
"sync": "tnpm sync"
},
"dependencies": {
"@antv/g-plugin-canvas-path-generator": "^1.1.30",
"@antv/g-plugin-canvas-picker": "^1.8.27",
"@antv/g-plugin-canvaskit-renderer": "^1.1.31",
"@antv/g-plugin-dom-interaction": "^1.7.30",
"@antv/g-plugin-html-renderer": "^1.7.30",
"@antv/g-plugin-image-loader": "^1.1.31",
"@antv/g-plugin-canvas-path-generator": "^1.1.31",
"@antv/g-plugin-canvas-picker": "^1.8.28",
"@antv/g-plugin-canvaskit-renderer": "^1.1.32",
"@antv/g-plugin-dom-interaction": "^1.7.31",
"@antv/g-plugin-html-renderer": "^1.7.31",
"@antv/g-plugin-image-loader": "^1.1.32",
"@antv/util": "^3.3.1",
"canvaskit-wasm": "^0.34.0",
"tslib": "^2.3.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/g-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-components",
"version": "1.7.30",
"version": "1.7.31",
"description": "Components for g",
"keywords": [
"antv",
Expand Down
2 changes: 1 addition & 1 deletion packages/g-css-layout-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-css-layout-api",
"version": "1.0.19",
"version": "1.0.20",
"description": "A simple implementation of CSS Layout API.",
"keywords": [
"antv",
Expand Down
2 changes: 1 addition & 1 deletion packages/g-css-typed-om-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-css-typed-om-api",
"version": "1.0.19",
"version": "1.0.20",
"description": "A simple implementation of CSS Typed OM API.",
"keywords": [
"antv",
Expand Down
2 changes: 1 addition & 1 deletion packages/g-devtool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-devtool",
"version": "0.10.30",
"version": "0.10.31",
"private": true,
"description": "devtool for g in browser",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/g-dom-mutation-observer-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-dom-mutation-observer-api",
"version": "1.0.19",
"version": "1.0.20",
"description": "A simple implementation of DOM MutationObserver API.",
"keywords": [
"antv",
Expand Down
6 changes: 3 additions & 3 deletions packages/g-gesture/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-gesture",
"version": "0.0.53",
"version": "0.0.54",
"description": "G Gesture",
"keywords": [
"antv",
Expand Down Expand Up @@ -34,8 +34,8 @@
"eventemitter3": "^4.0.0"
},
"devDependencies": {
"@antv/g-mobile-canvas": "^0.8.27",
"@antv/g-mobile-canvas-element": "^0.6.30"
"@antv/g-mobile-canvas": "^0.8.28",
"@antv/g-mobile-canvas-element": "^0.6.31"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/g-image-exporter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-image-exporter",
"version": "0.5.30",
"version": "0.5.31",
"description": "A image exporter for G using DOM API",
"keywords": [
"antv",
Expand Down
2 changes: 1 addition & 1 deletion packages/g-layout-blocklike/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-layout-blocklike",
"version": "1.7.30",
"version": "1.7.31",
"description": "A blocklike layout",
"keywords": [
"antv",
Expand Down
4 changes: 2 additions & 2 deletions packages/g-lite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-lite",
"version": "1.0.19",
"version": "1.0.20",
"description": "A core module for rendering engine implements DOM API.",
"keywords": [
"antv",
Expand Down Expand Up @@ -32,7 +32,7 @@
"sync": "tnpm sync"
},
"dependencies": {
"@antv/g-math": "^1.7.30",
"@antv/g-math": "^1.7.31",
"@antv/util": "^3.3.1",
"@types/offscreencanvas": "^2019.6.4",
"d3-color": "^1.4.0",
Expand Down
95 changes: 74 additions & 21 deletions packages/g-lite/src/css/StyleValueRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { formatAttributeName, isFunction } from '../utils';
import type { CSSRGB, CSSStyleValue } from './cssom';
import { CSSKeywordValue } from './cssom';
import { getOrCreateKeyword } from './CSSStyleValuePool';
import type { PropertyMetadata, PropertyParseOptions, StyleValueRegistry } from './interfaces';
import type {
PropertyMetadata,
PropertyParseOptions,
StyleValueRegistry,
} from './interfaces';
import { PropertySyntax } from './interfaces';
import type { ParsedFilterStyleProperty } from './parser';
import { convertPercentUnit } from './parser/dimension';
Expand Down Expand Up @@ -210,10 +214,10 @@ export const BUILT_IN_PROPERTIES: PropertyMetadata[] = [
ind: true,
inh: true,
/**
* TODO: support interpolation
* support interpolation
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility#interpolation
*/
// int: true,
int: true,
d: 'visible',
},
{
Expand Down Expand Up @@ -514,7 +518,11 @@ export const BUILT_IN_PROPERTIES: PropertyMetadata[] = [
l: true,
syntax: PropertySyntax.NUMBER,
d: (nodeName: string) => {
if (nodeName === Shape.PATH || nodeName === Shape.POLYGON || nodeName === Shape.POLYLINE) {
if (
nodeName === Shape.PATH ||
nodeName === Shape.POLYGON ||
nodeName === Shape.POLYLINE
) {
return '4';
}
return '10';
Expand Down Expand Up @@ -653,7 +661,12 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
usedAttributes: [],
},
) {
const { skipUpdateAttribute, skipParse, forceUpdateGeometry, usedAttributes } = options;
const {
skipUpdateAttribute,
skipParse,
forceUpdateGeometry,
usedAttributes,
} = options;

let needUpdateGeometry = forceUpdateGeometry;
let attributeNames = Object.keys(attributes);
Expand Down Expand Up @@ -735,7 +748,11 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
/**
* string -> parsed value
*/
parseProperty(name: string, value: any, object: DisplayObject): CSSStyleValue {
parseProperty(
name: string,
value: any,
object: DisplayObject,
): CSSStyleValue {
const metadata = propertyMetadataCache[name];

let computed: CSSStyleValue = value;
Expand Down Expand Up @@ -768,7 +785,11 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
/**
* computed value -> used value
*/
computeProperty(name: string, computed: CSSStyleValue, object: DisplayObject) {
computeProperty(
name: string,
computed: CSSStyleValue,
object: DisplayObject,
) {
const metadata = propertyMetadataCache[name];
const isDocumentElement = object.id === 'g-root';

Expand Down Expand Up @@ -796,14 +817,18 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
if (!isNil(defaultValue)) {
computed = this.parseProperty(
name,
isFunction(defaultValue) ? defaultValue(object.nodeName) : defaultValue,
isFunction(defaultValue)
? defaultValue(object.nodeName)
: defaultValue,
object,
);
}
} else if (value === 'inherit') {
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
// behave like `inherit`
const resolved = this.tryToResolveProperty(object, name, { inherited: true });
const resolved = this.tryToResolveProperty(object, name, {
inherited: true,
});
if (!isNil(resolved)) {
// object.parsedStyle[name] = resolved;
// return false;
Expand Down Expand Up @@ -836,7 +861,8 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
const metadata = propertyMetadataCache[name];

if (metadata && metadata.syntax) {
const handler = metadata.syntax && this.getPropertySyntax(metadata.syntax);
const handler =
metadata.syntax && this.getPropertySyntax(metadata.syntax);
const propertyHandler = handler;

if (propertyHandler && propertyHandler.postProcessor) {
Expand All @@ -860,11 +886,18 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
}
}

tryToResolveProperty(object: DisplayObject, name: string, options: { inherited?: boolean } = {}) {
tryToResolveProperty(
object: DisplayObject,
name: string,
options: { inherited?: boolean } = {},
) {
const { inherited } = options;

if (inherited) {
if (object.parentElement && isPropertyResolved(object.parentElement as DisplayObject, name)) {
if (
object.parentElement &&
isPropertyResolved(object.parentElement as DisplayObject, name)
) {
// const computedValue = object.parentElement.computedStyle[name];
const usedValue = object.parentElement.parsedStyle[name];
if (
Expand Down Expand Up @@ -935,7 +968,12 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
const flipX = height < 0;

// init with content box
const halfExtents = vec3.set(tmpVec3a, Math.abs(width) / 2, Math.abs(height) / 2, depth / 2);
const halfExtents = vec3.set(
tmpVec3a,
Math.abs(width) / 2,
Math.abs(height) / 2,
depth / 2,
);

// anchor is center by default, don't account for lineWidth here
const {
Expand Down Expand Up @@ -986,26 +1024,33 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
const hasStroke = stroke && !(stroke as CSSRGB).isNone;
if (hasStroke) {
const halfLineWidth =
((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) * expansion;
((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) *
expansion;
// halfExtents[0] += halfLineWidth[0];
// halfExtents[1] += halfLineWidth[1];

vec3.add(halfExtents, halfExtents, vec3.set(tmpVec3c, halfLineWidth, halfLineWidth, 0));
vec3.add(
halfExtents,
halfExtents,
vec3.set(tmpVec3c, halfLineWidth, halfLineWidth, 0),
);
}
geometry.renderBounds.update(center, halfExtents);

// account for shadow, only support constant value now
if (shadowColor && shadowType && shadowType !== 'inner') {
const { min, max } = geometry.renderBounds;

const { shadowBlur, shadowOffsetX, shadowOffsetY } = parsedStyle as ParsedBaseStyleProps;
const { shadowBlur, shadowOffsetX, shadowOffsetY } =
parsedStyle as ParsedBaseStyleProps;
const shadowBlurInPixels = shadowBlur || 0;
const shadowOffsetXInPixels = shadowOffsetX || 0;
const shadowOffsetYInPixels = shadowOffsetY || 0;
const shadowLeft = min[0] - shadowBlurInPixels + shadowOffsetXInPixels;
const shadowRight = max[0] + shadowBlurInPixels + shadowOffsetXInPixels;
const shadowTop = min[1] - shadowBlurInPixels + shadowOffsetYInPixels;
const shadowBottom = max[1] + shadowBlurInPixels + shadowOffsetYInPixels;
const shadowBottom =
max[1] + shadowBlurInPixels + shadowOffsetYInPixels;
min[0] = Math.min(min[0], shadowLeft);
max[0] = Math.max(max[0], shadowRight);
min[1] = Math.min(min[1], shadowTop);
Expand Down Expand Up @@ -1048,14 +1093,22 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
anchor = parsedStyle.anchor;

// set transform origin
let usedOriginXValue = (flipY ? -1 : 1) * convertPercentUnit(transformOrigin[0], 0, object);
let usedOriginYValue = (flipX ? -1 : 1) * convertPercentUnit(transformOrigin[1], 1, object);
let usedOriginXValue =
(flipY ? -1 : 1) * convertPercentUnit(transformOrigin[0], 0, object);
let usedOriginYValue =
(flipX ? -1 : 1) * convertPercentUnit(transformOrigin[1], 1, object);
usedOriginXValue =
usedOriginXValue -
(flipY ? -1 : 1) * ((anchor && anchor[0]) || 0) * geometry.contentBounds.halfExtents[0] * 2;
(flipY ? -1 : 1) *
((anchor && anchor[0]) || 0) *
geometry.contentBounds.halfExtents[0] *
2;
usedOriginYValue =
usedOriginYValue -
(flipX ? -1 : 1) * ((anchor && anchor[1]) || 0) * geometry.contentBounds.halfExtents[1] * 2;
(flipX ? -1 : 1) *
((anchor && anchor[1]) || 0) *
geometry.contentBounds.halfExtents[1] *
2;
object.setOrigin(usedOriginXValue, usedOriginYValue);

runtime.sceneGraphService.dirtifyToRoot(object);
Expand Down

0 comments on commit 28113dc

Please sign in to comment.