Przeglądaj źródła

Rename methods that were using TopRightBottomLeft to BoxEdges methods.

Maciej Gołaszewski 6 lat temu
rodzic
commit
771b87cdd5

+ 8 - 8
packages/ckeditor5-engine/src/view/styles/border.js

@@ -7,7 +7,7 @@
  * @module engine/view/styles/border
  * @module engine/view/styles/border
  */
  */
 
 
-import { getShorthandValues, getTopRightBottomLeftValueReducer, getTopRightBottomLeftValues, isLength, isLineStyle } from './utils';
+import { getShorthandValues, getBoxEdgesValueReducer, getBoxEdgesValues, isLength, isLineStyle } from './utils';
 
 
 /**
 /**
  * Adds a border CSS styles processing rules.
  * Adds a border CSS styles processing rules.
@@ -95,9 +95,9 @@ export function addBorderRules( stylesProcessor ) {
 	stylesProcessor.setExtractor( 'border-bottom-style', 'border.style.bottom' );
 	stylesProcessor.setExtractor( 'border-bottom-style', 'border.style.bottom' );
 	stylesProcessor.setExtractor( 'border-left-style', 'border.style.left' );
 	stylesProcessor.setExtractor( 'border-left-style', 'border.style.left' );
 
 
-	stylesProcessor.setReducer( 'border-color', getTopRightBottomLeftValueReducer( 'border-color' ) );
-	stylesProcessor.setReducer( 'border-style', getTopRightBottomLeftValueReducer( 'border-style' ) );
-	stylesProcessor.setReducer( 'border-width', getTopRightBottomLeftValueReducer( 'border-width' ) );
+	stylesProcessor.setReducer( 'border-color', getBoxEdgesValueReducer( 'border-color' ) );
+	stylesProcessor.setReducer( 'border-style', getBoxEdgesValueReducer( 'border-style' ) );
+	stylesProcessor.setReducer( 'border-width', getBoxEdgesValueReducer( 'border-width' ) );
 	stylesProcessor.setReducer( 'border-top', getBorderPositionReducer( 'top' ) );
 	stylesProcessor.setReducer( 'border-top', getBorderPositionReducer( 'top' ) );
 	stylesProcessor.setReducer( 'border-right', getBorderPositionReducer( 'right' ) );
 	stylesProcessor.setReducer( 'border-right', getBorderPositionReducer( 'right' ) );
 	stylesProcessor.setReducer( 'border-bottom', getBorderPositionReducer( 'bottom' ) );
 	stylesProcessor.setReducer( 'border-bottom', getBorderPositionReducer( 'bottom' ) );
@@ -134,9 +134,9 @@ function borderNormalizer( value ) {
 	return {
 	return {
 		path: 'border',
 		path: 'border',
 		value: {
 		value: {
-			color: getTopRightBottomLeftValues( color ),
-			style: getTopRightBottomLeftValues( style ),
-			width: getTopRightBottomLeftValues( width )
+			color: getBoxEdgesValues( color ),
+			style: getBoxEdgesValues( style ),
+			width: getBoxEdgesValues( width )
 		}
 		}
 	};
 	};
 }
 }
@@ -177,7 +177,7 @@ function getBorderPropertyNormalizer( propertyName ) {
 
 
 function toBorderPropertyShorthand( value, property ) {
 function toBorderPropertyShorthand( value, property ) {
 	return {
 	return {
-		[ property ]: getTopRightBottomLeftValues( value )
+		[ property ]: getBoxEdgesValues( value )
 	};
 	};
 }
 }
 
 

+ 2 - 2
packages/ckeditor5-engine/src/view/styles/margin.js

@@ -7,7 +7,7 @@
  * @module engine/view/styles/margin
  * @module engine/view/styles/margin
  */
  */
 
 
-import { getPositionShorthandNormalizer, getTopRightBottomLeftValueReducer } from './utils';
+import { getPositionShorthandNormalizer, getBoxEdgesValueReducer } from './utils';
 
 
 /**
 /**
  * Adds a margin CSS styles processing rules.
  * Adds a margin CSS styles processing rules.
@@ -35,7 +35,7 @@ export function addMarginRules( stylesProcessor ) {
 	stylesProcessor.setNormalizer( 'margin-bottom', value => ( { path: 'margin.bottom', value } ) );
 	stylesProcessor.setNormalizer( 'margin-bottom', value => ( { path: 'margin.bottom', value } ) );
 	stylesProcessor.setNormalizer( 'margin-left', value => ( { path: 'margin.left', value } ) );
 	stylesProcessor.setNormalizer( 'margin-left', value => ( { path: 'margin.left', value } ) );
 
 
-	stylesProcessor.setReducer( 'margin', getTopRightBottomLeftValueReducer( 'margin' ) );
+	stylesProcessor.setReducer( 'margin', getBoxEdgesValueReducer( 'margin' ) );
 
 
 	stylesProcessor.setStyleRelation( 'margin', [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ] );
 	stylesProcessor.setStyleRelation( 'margin', [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ] );
 }
 }

+ 2 - 2
packages/ckeditor5-engine/src/view/styles/padding.js

@@ -7,7 +7,7 @@
  * @module engine/view/styles/padding
  * @module engine/view/styles/padding
  */
  */
 
 
-import { getPositionShorthandNormalizer, getTopRightBottomLeftValueReducer } from './utils';
+import { getPositionShorthandNormalizer, getBoxEdgesValueReducer } from './utils';
 
 
 /**
 /**
  * Adds a margin CSS styles processing rules.
  * Adds a margin CSS styles processing rules.
@@ -34,7 +34,7 @@ export function addPaddingRules( stylesProcessor ) {
 	stylesProcessor.setNormalizer( 'padding-bottom', value => ( { path: 'padding.bottom', value } ) );
 	stylesProcessor.setNormalizer( 'padding-bottom', value => ( { path: 'padding.bottom', value } ) );
 	stylesProcessor.setNormalizer( 'padding-left', value => ( { path: 'padding.left', value } ) );
 	stylesProcessor.setNormalizer( 'padding-left', value => ( { path: 'padding.left', value } ) );
 
 
-	stylesProcessor.setReducer( 'padding', getTopRightBottomLeftValueReducer( 'padding' ) );
+	stylesProcessor.setReducer( 'padding', getBoxEdgesValueReducer( 'padding' ) );
 
 
 	stylesProcessor.setStyleRelation( 'padding', [ 'padding-top', 'padding-right', 'padding-bottom', 'padding-left' ] );
 	stylesProcessor.setStyleRelation( 'padding', [ 'padding-top', 'padding-right', 'padding-bottom', 'padding-left' ] );
 }
 }

+ 7 - 7
packages/ckeditor5-engine/src/view/styles/utils.js

@@ -91,7 +91,7 @@ export function isURL( string ) {
 	return urlRegExp.test( string );
 	return urlRegExp.test( string );
 }
 }
 
 
-export function getTopRightBottomLeftValues( value = '' ) {
+export function getBoxEdgesValues( value = '' ) {
 	if ( value === '' ) {
 	if ( value === '' ) {
 		return { top: undefined, right: undefined, bottom: undefined, left: undefined };
 		return { top: undefined, right: undefined, bottom: undefined, left: undefined };
 	}
 	}
@@ -110,12 +110,12 @@ export function getTopRightBottomLeftValues( value = '' ) {
  * Default reducer for CSS properties that concerns edges of a box
  * Default reducer for CSS properties that concerns edges of a box
  * [shorthand](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) notations:
  * [shorthand](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) notations:
  *
  *
- *		stylesProcessor.setReducer( 'padding', getTopRightBottomLeftValueReducer( 'padding' ) );
+ *		stylesProcessor.setReducer( 'padding', getBoxEdgesValueReducer( 'padding' ) );
  *
  *
  * @param {String} styleShorthand
  * @param {String} styleShorthand
  * @returns {Function}
  * @returns {Function}
  */
  */
-export function getTopRightBottomLeftValueReducer( styleShorthand ) {
+export function getBoxEdgesValueReducer( styleShorthand ) {
 	return value => {
 	return value => {
 		const { top, right, bottom, left } = value;
 		const { top, right, bottom, left } = value;
 
 
@@ -138,7 +138,7 @@ export function getTopRightBottomLeftValueReducer( styleShorthand ) {
 				reduced.push( [ styleShorthand + '-left', left ] );
 				reduced.push( [ styleShorthand + '-left', left ] );
 			}
 			}
 		} else {
 		} else {
-			reduced.push( [ styleShorthand, getTopRightBottomLeftShorthandValue( value ) ] );
+			reduced.push( [ styleShorthand, getBoxEdgesShorthandValue( value ) ] );
 		}
 		}
 
 
 		return reduced;
 		return reduced;
@@ -148,13 +148,13 @@ export function getTopRightBottomLeftValueReducer( styleShorthand ) {
 /**
 /**
  * Returns a proper 1-to-4 value of a CSS [shorthand](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) notation.
  * Returns a proper 1-to-4 value of a CSS [shorthand](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) notation.
  *
  *
- *		getTopRightBottomLeftShorthandValue( { top: '1px', right: '1px', bottom: '2px', left: '1px' } );
+ *		getBoxEdgesShorthandValue( { top: '1px', right: '1px', bottom: '2px', left: '1px' } );
  *		// will return '1px 1px 2px'
  *		// will return '1px 1px 2px'
  *
  *
  * @param {module:engine/view/stylesmap~BoxEdges} styleShorthand
  * @param {module:engine/view/stylesmap~BoxEdges} styleShorthand
  * @returns {Function}
  * @returns {Function}
  */
  */
-export function getTopRightBottomLeftShorthandValue( { top, right, bottom, left } ) {
+export function getBoxEdgesShorthandValue( { top, right, bottom, left } ) {
 	const out = [];
 	const out = [];
 
 
 	if ( left !== right ) {
 	if ( left !== right ) {
@@ -182,7 +182,7 @@ export function getPositionShorthandNormalizer( shorthand ) {
 	return value => {
 	return value => {
 		return {
 		return {
 			path: shorthand,
 			path: shorthand,
-			value: getTopRightBottomLeftValues( value )
+			value: getBoxEdgesValues( value )
 		};
 		};
 	};
 	};
 }
 }

+ 14 - 14
packages/ckeditor5-engine/tests/view/styles/utils.js

@@ -5,8 +5,8 @@
 
 
 import {
 import {
 	getShorthandValues,
 	getShorthandValues,
-	getTopRightBottomLeftShorthandValue,
-	getTopRightBottomLeftValues,
+	getBoxEdgesShorthandValue,
+	getBoxEdgesValues,
 	isColor,
 	isColor,
 	isLength,
 	isLength,
 	isLineStyle
 	isLineStyle
@@ -69,29 +69,29 @@ describe( 'Styles utils', () => {
 		} );
 		} );
 	} );
 	} );
 
 
-	describe( 'getTopRightBottomLeftShorthandValue()', () => {
+	describe( 'getBoxEdgesShorthandValue()', () => {
 		it( 'should output one value for same values', () => {
 		it( 'should output one value for same values', () => {
-			expect( getTopRightBottomLeftShorthandValue( { top: 'foo', right: 'foo', bottom: 'foo', left: 'foo' } ) ).to.equal( 'foo' );
+			expect( getBoxEdgesShorthandValue( { top: 'foo', right: 'foo', bottom: 'foo', left: 'foo' } ) ).to.equal( 'foo' );
 		} );
 		} );
 
 
 		it( 'should output two value for top == bottom and right == left', () => {
 		it( 'should output two value for top == bottom and right == left', () => {
-			expect( getTopRightBottomLeftShorthandValue( { top: 'foo', right: 'bar', bottom: 'foo', left: 'bar' } ) ).to.equal( 'foo bar' );
+			expect( getBoxEdgesShorthandValue( { top: 'foo', right: 'bar', bottom: 'foo', left: 'bar' } ) ).to.equal( 'foo bar' );
 		} );
 		} );
 
 
 		it( 'should output three values if bottom is different then top', () => {
 		it( 'should output three values if bottom is different then top', () => {
-			expect( getTopRightBottomLeftShorthandValue( { top: 'foo', right: 'foo', bottom: 'bar', left: 'foo' } ) )
+			expect( getBoxEdgesShorthandValue( { top: 'foo', right: 'foo', bottom: 'bar', left: 'foo' } ) )
 				.to.equal( 'foo foo bar' );
 				.to.equal( 'foo foo bar' );
 		} );
 		} );
 
 
 		it( 'should output four values if left is different then right', () => {
 		it( 'should output four values if left is different then right', () => {
-			expect( getTopRightBottomLeftShorthandValue( { top: 'foo', right: 'foo', bottom: 'foo', left: 'bar' } ) )
+			expect( getBoxEdgesShorthandValue( { top: 'foo', right: 'foo', bottom: 'foo', left: 'bar' } ) )
 				.to.equal( 'foo foo foo bar' );
 				.to.equal( 'foo foo foo bar' );
 		} );
 		} );
 	} );
 	} );
 
 
-	describe( 'getTopRightBottomLeftValues()', () => {
+	describe( 'getBoxEdgesValues()', () => {
 		it( 'should parse empty string', () => {
 		it( 'should parse empty string', () => {
-			expect( getTopRightBottomLeftValues( '' ) ).to.deep.equal( {
+			expect( getBoxEdgesValues( '' ) ).to.deep.equal( {
 				top: undefined,
 				top: undefined,
 				right: undefined,
 				right: undefined,
 				bottom: undefined,
 				bottom: undefined,
@@ -100,7 +100,7 @@ describe( 'Styles utils', () => {
 		} );
 		} );
 
 
 		it( 'should parse one value', () => {
 		it( 'should parse one value', () => {
-			expect( getTopRightBottomLeftValues( 'foo' ) ).to.deep.equal( {
+			expect( getBoxEdgesValues( 'foo' ) ).to.deep.equal( {
 				top: 'foo',
 				top: 'foo',
 				right: 'foo',
 				right: 'foo',
 				bottom: 'foo',
 				bottom: 'foo',
@@ -109,7 +109,7 @@ describe( 'Styles utils', () => {
 		} );
 		} );
 
 
 		it( 'should parse one value', () => {
 		it( 'should parse one value', () => {
-			expect( getTopRightBottomLeftValues( 'foo' ) ).to.deep.equal( {
+			expect( getBoxEdgesValues( 'foo' ) ).to.deep.equal( {
 				top: 'foo',
 				top: 'foo',
 				right: 'foo',
 				right: 'foo',
 				bottom: 'foo',
 				bottom: 'foo',
@@ -118,7 +118,7 @@ describe( 'Styles utils', () => {
 		} );
 		} );
 
 
 		it( 'should parse two value', () => {
 		it( 'should parse two value', () => {
-			expect( getTopRightBottomLeftValues( 'foo bar' ) ).to.deep.equal( {
+			expect( getBoxEdgesValues( 'foo bar' ) ).to.deep.equal( {
 				top: 'foo',
 				top: 'foo',
 				right: 'bar',
 				right: 'bar',
 				bottom: 'foo',
 				bottom: 'foo',
@@ -127,7 +127,7 @@ describe( 'Styles utils', () => {
 		} );
 		} );
 
 
 		it( 'should parse three values', () => {
 		it( 'should parse three values', () => {
-			expect( getTopRightBottomLeftValues( 'foo foo bar' ) ).to.deep.equal( {
+			expect( getBoxEdgesValues( 'foo foo bar' ) ).to.deep.equal( {
 				top: 'foo',
 				top: 'foo',
 				right: 'foo',
 				right: 'foo',
 				bottom: 'bar',
 				bottom: 'bar',
@@ -136,7 +136,7 @@ describe( 'Styles utils', () => {
 		} );
 		} );
 
 
 		it( 'should output four values if left is different then right', () => {
 		it( 'should output four values if left is different then right', () => {
-			expect( getTopRightBottomLeftValues( 'foo foo foo bar' ) ).to.deep.equal( {
+			expect( getBoxEdgesValues( 'foo foo foo bar' ) ).to.deep.equal( {
 				top: 'foo',
 				top: 'foo',
 				right: 'foo',
 				right: 'foo',
 				bottom: 'foo',
 				bottom: 'foo',

+ 2 - 2
packages/ckeditor5-engine/tests/view/stylesmap.js

@@ -6,7 +6,7 @@
 import StylesMap, { StylesProcessor } from '../../src/view/stylesmap';
 import StylesMap, { StylesProcessor } from '../../src/view/stylesmap';
 import encodedImage from './_utils/encodedimage.txt';
 import encodedImage from './_utils/encodedimage.txt';
 import { addPaddingRules } from '../../src/view/styles/padding';
 import { addPaddingRules } from '../../src/view/styles/padding';
-import { getTopRightBottomLeftValueReducer } from '../../src/view/styles/utils';
+import { getBoxEdgesValueReducer } from '../../src/view/styles/utils';
 
 
 describe( 'StylesMap', () => {
 describe( 'StylesMap', () => {
 	let stylesMap, stylesProcessor;
 	let stylesMap, stylesProcessor;
@@ -23,7 +23,7 @@ describe( 'StylesMap', () => {
 			path: 'foo.top',
 			path: 'foo.top',
 			value
 			value
 		} ) );
 		} ) );
-		stylesProcessor.setReducer( 'foo', getTopRightBottomLeftValueReducer( 'foo' ) );
+		stylesProcessor.setReducer( 'foo', getBoxEdgesValueReducer( 'foo' ) );
 
 
 		addPaddingRules( stylesProcessor );
 		addPaddingRules( stylesProcessor );
 		StylesMap._setProcessor( stylesProcessor );
 		StylesMap._setProcessor( stylesProcessor );