Begin implementing overflow clipping

This commit is contained in:
MoyuScript
2017-08-02 21:35:54 +08:00
parent 8a19c91ceb
commit 32642682af
7 changed files with 158 additions and 27 deletions

View File

@ -8,6 +8,7 @@ import Color from '../Color';
import Length from '../Length';
import Size from '../Size';
import Vector from '../Vector';
import {calculateBorderBoxPath, calculatePaddingBoxPath} from '../Bounds';
export type Background = {
backgroundImage: Array<BackgroundImage>,
@ -123,20 +124,10 @@ export const calculateBackgroungPaintingArea = (
// TODO support CONTENT_BOX
switch (clip) {
case BACKGROUND_CLIP.BORDER_BOX:
return [
curves.topLeftOuter,
curves.topRightOuter,
curves.bottomRightOuter,
curves.bottomLeftOuter
];
return calculateBorderBoxPath(curves);
case BACKGROUND_CLIP.PADDING_BOX:
default:
return [
curves.topLeftInner,
curves.topRightInner,
curves.bottomRightInner,
curves.bottomLeftInner
];
return calculatePaddingBoxPath(curves);
}
};

25
src/parsing/overflow.js Normal file
View File

@ -0,0 +1,25 @@
/* @flow */
'use strict';
export const OVERFLOW = {
VISIBLE: 0,
HIDDEN: 1,
SCROLL: 2,
AUTO: 3
};
export type Overflow = $Values<typeof OVERFLOW>;
export const parseOverflow = (overflow: string): Overflow => {
switch (overflow) {
case 'hidden':
return OVERFLOW.HIDDEN;
case 'scroll':
return OVERFLOW.SCROLL;
case 'auto':
return OVERFLOW.AUTO;
case 'visible':
default:
return OVERFLOW.VISIBLE;
}
};