fix: multi token overflow #1850 (#1851)

This commit is contained in:
Niklas von Hertzen 2019-05-26 14:08:56 -07:00 committed by GitHub
parent 5f31b74177
commit 409674fba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 20 deletions

View File

@ -40,7 +40,7 @@ import {listStyleImage} from './property-descriptors/list-style-image';
import {listStylePosition} from './property-descriptors/list-style-position'; import {listStylePosition} from './property-descriptors/list-style-position';
import {listStyleType} from './property-descriptors/list-style-type'; import {listStyleType} from './property-descriptors/list-style-type';
import {marginBottom, marginLeft, marginRight, marginTop} from './property-descriptors/margin'; import {marginBottom, marginLeft, marginRight, marginTop} from './property-descriptors/margin';
import {overflow} from './property-descriptors/overflow'; import {overflow, OVERFLOW} from './property-descriptors/overflow';
import {overflowWrap} from './property-descriptors/overflow-wrap'; import {overflowWrap} from './property-descriptors/overflow-wrap';
import {paddingBottom, paddingLeft, paddingRight, paddingTop} from './property-descriptors/padding'; import {paddingBottom, paddingLeft, paddingRight, paddingTop} from './property-descriptors/padding';
import {textAlign} from './property-descriptors/text-align'; import {textAlign} from './property-descriptors/text-align';
@ -118,7 +118,8 @@ export class CSSParsedDeclaration {
marginBottom: CSSValue; marginBottom: CSSValue;
marginLeft: CSSValue; marginLeft: CSSValue;
opacity: ReturnType<typeof opacity.parse>; opacity: ReturnType<typeof opacity.parse>;
overflow: ReturnType<typeof overflow.parse>; overflowX: OVERFLOW;
overflowY: OVERFLOW;
overflowWrap: ReturnType<typeof overflowWrap.parse>; overflowWrap: ReturnType<typeof overflowWrap.parse>;
paddingTop: LengthPercentage; paddingTop: LengthPercentage;
paddingRight: LengthPercentage; paddingRight: LengthPercentage;
@ -180,7 +181,9 @@ export class CSSParsedDeclaration {
this.marginBottom = parse(marginBottom, declaration.marginBottom); this.marginBottom = parse(marginBottom, declaration.marginBottom);
this.marginLeft = parse(marginLeft, declaration.marginLeft); this.marginLeft = parse(marginLeft, declaration.marginLeft);
this.opacity = parse(opacity, declaration.opacity); this.opacity = parse(opacity, declaration.opacity);
this.overflow = parse(overflow, declaration.overflow); const overflowTuple = parse(overflow, declaration.overflow);
this.overflowX = overflowTuple[0];
this.overflowY = overflowTuple[overflowTuple.length > 1 ? 1 : 0];
this.overflowWrap = parse(overflowWrap, declaration.overflowWrap); this.overflowWrap = parse(overflowWrap, declaration.overflowWrap);
this.paddingTop = parse(paddingTop, declaration.paddingTop); this.paddingTop = parse(paddingTop, declaration.paddingTop);
this.paddingRight = parse(paddingRight, declaration.paddingRight); this.paddingRight = parse(paddingRight, declaration.paddingRight);

View File

@ -1,4 +1,5 @@
import {IPropertyIdentValueDescriptor, PropertyDescriptorParsingType} from '../IPropertyDescriptor'; import {IPropertyListDescriptor, PropertyDescriptorParsingType} from '../IPropertyDescriptor';
import {CSSValue, isIdentToken} from '../syntax/parser';
export enum OVERFLOW { export enum OVERFLOW {
VISIBLE = 0, VISIBLE = 0,
HIDDEN = 1, HIDDEN = 1,
@ -6,13 +7,14 @@ export enum OVERFLOW {
AUTO = 3 AUTO = 3
} }
export const overflow: IPropertyIdentValueDescriptor<OVERFLOW> = { export const overflow: IPropertyListDescriptor<OVERFLOW[]> = {
name: 'overflow', name: 'overflow',
initialValue: 'visible', initialValue: 'visible',
prefix: false, prefix: false,
type: PropertyDescriptorParsingType.IDENT_VALUE, type: PropertyDescriptorParsingType.LIST,
parse: (overflow: string) => { parse: (tokens: CSSValue[]): OVERFLOW[] => {
switch (overflow) { return tokens.filter(isIdentToken).map(overflow => {
switch (overflow.value) {
case 'hidden': case 'hidden':
return OVERFLOW.HIDDEN; return OVERFLOW.HIDDEN;
case 'scroll': case 'scroll':
@ -23,5 +25,6 @@ export const overflow: IPropertyIdentValueDescriptor<OVERFLOW> = {
default: default:
return OVERFLOW.VISIBLE; return OVERFLOW.VISIBLE;
} }
});
} }
}; };

View File

@ -48,7 +48,7 @@ export class ElementPaint {
this.effects.push(new TransformEffect(offsetX, offsetY, matrix)); this.effects.push(new TransformEffect(offsetX, offsetY, matrix));
} }
if (element.styles.overflow !== OVERFLOW.VISIBLE) { if (element.styles.overflowX !== OVERFLOW.VISIBLE) {
const borderBox = calculateBorderBoxPath(this.curves); const borderBox = calculateBorderBoxPath(this.curves);
const paddingBox = calculatePaddingBoxPath(this.curves); const paddingBox = calculatePaddingBoxPath(this.curves);
@ -63,7 +63,7 @@ export class ElementPaint {
getParentEffects(): IElementEffect[] { getParentEffects(): IElementEffect[] {
const effects = this.effects.slice(0); const effects = this.effects.slice(0);
if (this.container.styles.overflow !== OVERFLOW.VISIBLE) { if (this.container.styles.overflowX !== OVERFLOW.VISIBLE) {
const borderBox = calculateBorderBoxPath(this.curves); const borderBox = calculateBorderBoxPath(this.curves);
const paddingBox = calculatePaddingBoxPath(this.curves); const paddingBox = calculatePaddingBoxPath(this.curves);
if (!equalPath(borderBox, paddingBox)) { if (!equalPath(borderBox, paddingBox)) {

View File

@ -74,6 +74,10 @@
auto auto
<p class="auto">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec luctus pretium facilisis. Praesent rutrum eget nisl in tristique. Sed tincidunt nisl et tellus vulputate, nec rhoncus orci pretium.</p> <p class="auto">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec luctus pretium facilisis. Praesent rutrum eget nisl in tristique. Sed tincidunt nisl et tellus vulputate, nec rhoncus orci pretium.</p>
</div> </div>
<div class="cell">
visible hidden
<p style="overflow: visible hidden">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec luctus pretium facilisis. Praesent rutrum eget nisl in tristique. Sed tincidunt nisl et tellus vulputate, nec rhoncus orci pretium.</p>
</div>
<h1>Overflow: visible</h1> <h1>Overflow: visible</h1>
<div> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like <b>Aldus PageMaker</b> including versions of Lorem Ipsum. <div> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like <b>Aldus PageMaker</b> including versions of Lorem Ipsum.
</div> </div>