Browse Source

Rename style converter to processor.

Maciej Gołaszewski 6 years ago
parent
commit
55ef5f8dac

+ 14 - 14
packages/ckeditor5-engine/src/view/styles.js

@@ -20,16 +20,16 @@ export default class Styles {
 	/**
 	 * Creates Styles instance.
 	 */
-	constructor( processor ) {
+	constructor( styleProcessor ) {
 		/**
 		 * @private
 		 */
 		this._styles = {};
 
-		// This hides the converter from the watchdog.
-		Object.defineProperty( this, 'converter', {
+		// This hides the styleProcessor from the watchdog.
+		Object.defineProperty( this, 'styleProcessor', {
 			get() {
-				return processor || Styles.processor;
+				return styleProcessor || Styles.processor;
 			},
 			enumerable: false
 		} );
@@ -69,7 +69,7 @@ export default class Styles {
 		for ( const key of map.keys() ) {
 			const value = map.get( key );
 
-			this.converter.toNormalizedForm( key, value, this._styles );
+			this.styleProcessor.toNormalizedForm( key, value, this._styles );
 		}
 	}
 
@@ -82,7 +82,7 @@ export default class Styles {
 	 * @returns {Boolean}
 	 */
 	hasProperty( propertyName ) {
-		const normalized = this.converter.getNormalized( propertyName, this._styles );
+		const normalized = this.styleProcessor.getNormalized( propertyName, this._styles );
 
 		if ( !normalized ) {
 			// Try return styles set directly - values that are not parsed.
@@ -90,7 +90,7 @@ export default class Styles {
 		}
 
 		if ( isObject( normalized ) ) {
-			const styles = this.converter.getReducedForm( propertyName, normalized );
+			const styles = this.styleProcessor.getReducedForm( propertyName, normalized );
 
 			const propertyDescriptor = styles.find( ( [ property ] ) => property === propertyName );
 
@@ -128,7 +128,7 @@ export default class Styles {
 				this.insertProperty( key, nameOrObject[ key ] );
 			}
 		} else {
-			this.converter.toNormalizedForm( nameOrObject, value, this._styles );
+			this.styleProcessor.toNormalizedForm( nameOrObject, value, this._styles );
 		}
 	}
 
@@ -161,7 +161,7 @@ export default class Styles {
 	 * @returns {Object|undefined}
 	 */
 	getNormalized( name ) {
-		return this.converter.getNormalized( name, this._styles );
+		return this.styleProcessor.getNormalized( name, this._styles );
 	}
 
 	/**
@@ -187,7 +187,7 @@ export default class Styles {
 	 * @returns {String|undefined}
 	 */
 	getInlineProperty( propertyName ) {
-		const normalized = this.converter.getNormalized( propertyName, this._styles );
+		const normalized = this.styleProcessor.getNormalized( propertyName, this._styles );
 
 		if ( !normalized ) {
 			// Try return styles set directly - values that are not parsed.
@@ -195,7 +195,7 @@ export default class Styles {
 		}
 
 		if ( isObject( normalized ) ) {
-			const styles = this.converter.getReducedForm( propertyName, normalized );
+			const styles = this.styleProcessor.getReducedForm( propertyName, normalized );
 
 			const propertyDescriptor = styles.find( ( [ property ] ) => property === propertyName );
 
@@ -238,9 +238,9 @@ export default class Styles {
 		const keys = Object.keys( this._styles ).sort();
 
 		for ( const key of keys ) {
-			const normalized = this.converter.getNormalized( key, this._styles );
+			const normalized = this.styleProcessor.getNormalized( key, this._styles );
 
-			parsed.push( ...this.converter.getReducedForm( key, normalized ) );
+			parsed.push( ...this.styleProcessor.getReducedForm( key, normalized ) );
 		}
 
 		return parsed;
@@ -472,7 +472,7 @@ function appendStyleValue( stylesObject, nameOrPath, valueOrObject ) {
  *
  * Normalizers produces coherent object representation for both shorthand and longhand forms:
  *
- *		stylesConverter.on( 'normalize:border-color', ( evt, data ) => {
+ *		stylesProcessor.on( 'normalize:border-color', ( evt, data ) => {
  *			data.path = 'border.color';
  *			data.value = {
  *				top: '#f00',

+ 4 - 4
packages/ckeditor5-engine/src/view/styles/backgroundstyles.js

@@ -9,10 +9,10 @@ import { isAttachment, isColor, isPosition, isRepeat, isURL } from './utils';
  * @module engine/view/styles
  */
 
-export function addBackgroundStylesProcessor( stylesConverter ) {
-	stylesConverter.on( 'normalize:background', normalizeBackground );
-	stylesConverter.on( 'normalize:background-color', ( evt, data ) => ( data.path = 'background.color' ) );
-	stylesConverter.on( 'reduce:background', ( evt, data ) => {
+export function addBackgroundStylesProcessor( stylesProcessor ) {
+	stylesProcessor.on( 'normalize:background', normalizeBackground );
+	stylesProcessor.on( 'normalize:background-color', ( evt, data ) => ( data.path = 'background.color' ) );
+	stylesProcessor.on( 'reduce:background', ( evt, data ) => {
 		const ret = [];
 
 		ret.push( [ 'background-color', data.value.color ] );

+ 53 - 53
packages/ckeditor5-engine/src/view/styles/borderstyles.js

@@ -9,65 +9,65 @@ import { getShorthandValues, getTopRightBottomLeftValueReducer, getTopRightBotto
  * @module engine/view/styles/borderstyle
  */
 
-export function addBorderStylesProcessor( stylesConverter ) {
-	stylesConverter.on( 'normalize:border', borderNormalizer );
+export function addBorderStylesProcessor( stylesProcessor ) {
+	stylesProcessor.on( 'normalize:border', borderNormalizer );
 
 	// Border-position shorthands.
-	stylesConverter.on( 'normalize:border-top', getBorderPositionNormalizer( 'top' ) );
-	stylesConverter.on( 'normalize:border-right', getBorderPositionNormalizer( 'right' ) );
-	stylesConverter.on( 'normalize:border-bottom', getBorderPositionNormalizer( 'bottom' ) );
-	stylesConverter.on( 'normalize:border-left', getBorderPositionNormalizer( 'left' ) );
+	stylesProcessor.on( 'normalize:border-top', getBorderPositionNormalizer( 'top' ) );
+	stylesProcessor.on( 'normalize:border-right', getBorderPositionNormalizer( 'right' ) );
+	stylesProcessor.on( 'normalize:border-bottom', getBorderPositionNormalizer( 'bottom' ) );
+	stylesProcessor.on( 'normalize:border-left', getBorderPositionNormalizer( 'left' ) );
 
 	// Border-property shorthands.
-	stylesConverter.on( 'normalize:border-color', getBorderPropertyNormalizer( 'color' ) );
-	stylesConverter.on( 'normalize:border-width', getBorderPropertyNormalizer( 'width' ) );
-	stylesConverter.on( 'normalize:border-style', getBorderPropertyNormalizer( 'style' ) );
+	stylesProcessor.on( 'normalize:border-color', getBorderPropertyNormalizer( 'color' ) );
+	stylesProcessor.on( 'normalize:border-width', getBorderPropertyNormalizer( 'width' ) );
+	stylesProcessor.on( 'normalize:border-style', getBorderPropertyNormalizer( 'style' ) );
 
 	// Border longhands.
-	stylesConverter.on( 'normalize:border-top-color', getBorderPropertyPositionNormalizer( 'color', 'top' ) );
-	stylesConverter.on( 'normalize:border-top-style', getBorderPropertyPositionNormalizer( 'style', 'top' ) );
-	stylesConverter.on( 'normalize:border-top-width', getBorderPropertyPositionNormalizer( 'width', 'top' ) );
-
-	stylesConverter.on( 'normalize:border-right-color', getBorderPropertyPositionNormalizer( 'color', 'right' ) );
-	stylesConverter.on( 'normalize:border-right-style', getBorderPropertyPositionNormalizer( 'style', 'right' ) );
-	stylesConverter.on( 'normalize:border-right-width', getBorderPropertyPositionNormalizer( 'width', 'right' ) );
-
-	stylesConverter.on( 'normalize:border-bottom-color', getBorderPropertyPositionNormalizer( 'color', 'bottom' ) );
-	stylesConverter.on( 'normalize:border-bottom-style', getBorderPropertyPositionNormalizer( 'style', 'bottom' ) );
-	stylesConverter.on( 'normalize:border-bottom-width', getBorderPropertyPositionNormalizer( 'width', 'bottom' ) );
-
-	stylesConverter.on( 'normalize:border-left-color', getBorderPropertyPositionNormalizer( 'color', 'left' ) );
-	stylesConverter.on( 'normalize:border-left-style', getBorderPropertyPositionNormalizer( 'style', 'left' ) );
-	stylesConverter.on( 'normalize:border-left-width', getBorderPropertyPositionNormalizer( 'width', 'left' ) );
-
-	stylesConverter.on( 'extract:border-top', getBorderPositionExtractor( 'top' ) );
-	stylesConverter.on( 'extract:border-right', getBorderPositionExtractor( 'right' ) );
-	stylesConverter.on( 'extract:border-bottom', getBorderPositionExtractor( 'bottom' ) );
-	stylesConverter.on( 'extract:border-left', getBorderPositionExtractor( 'left' ) );
-
-	stylesConverter.on( 'extract:border-top-color', ( evt, data ) => ( data.path = 'border.color.top' ) );
-	stylesConverter.on( 'extract:border-right-color', ( evt, data ) => ( data.path = 'border.color.right' ) );
-	stylesConverter.on( 'extract:border-bottom-color', ( evt, data ) => ( data.path = 'border.color.bottom' ) );
-	stylesConverter.on( 'extract:border-left-color', ( evt, data ) => ( data.path = 'border.color.left' ) );
-
-	stylesConverter.on( 'extract:border-top-width', ( evt, data ) => ( data.path = 'border.width.top' ) );
-	stylesConverter.on( 'extract:border-right-width', ( evt, data ) => ( data.path = 'border.width.right' ) );
-	stylesConverter.on( 'extract:border-bottom-width', ( evt, data ) => ( data.path = 'border.width.bottom' ) );
-	stylesConverter.on( 'extract:border-left-width', ( evt, data ) => ( data.path = 'border.width.left' ) );
-
-	stylesConverter.on( 'extract:border-top-style', ( evt, data ) => ( data.path = 'border.style.top' ) );
-	stylesConverter.on( 'extract:border-right-style', ( evt, data ) => ( data.path = 'border.style.right' ) );
-	stylesConverter.on( 'extract:border-bottom-style', ( evt, data ) => ( data.path = 'border.style.bottom' ) );
-	stylesConverter.on( 'extract:border-left-style', ( evt, data ) => ( data.path = 'border.style.left' ) );
-
-	stylesConverter.on( 'reduce:border-color', getTopRightBottomLeftValueReducer( 'border-color' ) );
-	stylesConverter.on( 'reduce:border-style', getTopRightBottomLeftValueReducer( 'border-style' ) );
-	stylesConverter.on( 'reduce:border-width', getTopRightBottomLeftValueReducer( 'border-width' ) );
-	stylesConverter.on( 'reduce:border-top', getBorderPositionReducer( 'top' ) );
-	stylesConverter.on( 'reduce:border-right', getBorderPositionReducer( 'right' ) );
-	stylesConverter.on( 'reduce:border-bottom', getBorderPositionReducer( 'bottom' ) );
-	stylesConverter.on( 'reduce:border-left', getBorderPositionReducer( 'left' ) );
-	stylesConverter.on( 'reduce:border', borderReducer );
+	stylesProcessor.on( 'normalize:border-top-color', getBorderPropertyPositionNormalizer( 'color', 'top' ) );
+	stylesProcessor.on( 'normalize:border-top-style', getBorderPropertyPositionNormalizer( 'style', 'top' ) );
+	stylesProcessor.on( 'normalize:border-top-width', getBorderPropertyPositionNormalizer( 'width', 'top' ) );
+
+	stylesProcessor.on( 'normalize:border-right-color', getBorderPropertyPositionNormalizer( 'color', 'right' ) );
+	stylesProcessor.on( 'normalize:border-right-style', getBorderPropertyPositionNormalizer( 'style', 'right' ) );
+	stylesProcessor.on( 'normalize:border-right-width', getBorderPropertyPositionNormalizer( 'width', 'right' ) );
+
+	stylesProcessor.on( 'normalize:border-bottom-color', getBorderPropertyPositionNormalizer( 'color', 'bottom' ) );
+	stylesProcessor.on( 'normalize:border-bottom-style', getBorderPropertyPositionNormalizer( 'style', 'bottom' ) );
+	stylesProcessor.on( 'normalize:border-bottom-width', getBorderPropertyPositionNormalizer( 'width', 'bottom' ) );
+
+	stylesProcessor.on( 'normalize:border-left-color', getBorderPropertyPositionNormalizer( 'color', 'left' ) );
+	stylesProcessor.on( 'normalize:border-left-style', getBorderPropertyPositionNormalizer( 'style', 'left' ) );
+	stylesProcessor.on( 'normalize:border-left-width', getBorderPropertyPositionNormalizer( 'width', 'left' ) );
+
+	stylesProcessor.on( 'extract:border-top', getBorderPositionExtractor( 'top' ) );
+	stylesProcessor.on( 'extract:border-right', getBorderPositionExtractor( 'right' ) );
+	stylesProcessor.on( 'extract:border-bottom', getBorderPositionExtractor( 'bottom' ) );
+	stylesProcessor.on( 'extract:border-left', getBorderPositionExtractor( 'left' ) );
+
+	stylesProcessor.on( 'extract:border-top-color', ( evt, data ) => ( data.path = 'border.color.top' ) );
+	stylesProcessor.on( 'extract:border-right-color', ( evt, data ) => ( data.path = 'border.color.right' ) );
+	stylesProcessor.on( 'extract:border-bottom-color', ( evt, data ) => ( data.path = 'border.color.bottom' ) );
+	stylesProcessor.on( 'extract:border-left-color', ( evt, data ) => ( data.path = 'border.color.left' ) );
+
+	stylesProcessor.on( 'extract:border-top-width', ( evt, data ) => ( data.path = 'border.width.top' ) );
+	stylesProcessor.on( 'extract:border-right-width', ( evt, data ) => ( data.path = 'border.width.right' ) );
+	stylesProcessor.on( 'extract:border-bottom-width', ( evt, data ) => ( data.path = 'border.width.bottom' ) );
+	stylesProcessor.on( 'extract:border-left-width', ( evt, data ) => ( data.path = 'border.width.left' ) );
+
+	stylesProcessor.on( 'extract:border-top-style', ( evt, data ) => ( data.path = 'border.style.top' ) );
+	stylesProcessor.on( 'extract:border-right-style', ( evt, data ) => ( data.path = 'border.style.right' ) );
+	stylesProcessor.on( 'extract:border-bottom-style', ( evt, data ) => ( data.path = 'border.style.bottom' ) );
+	stylesProcessor.on( 'extract:border-left-style', ( evt, data ) => ( data.path = 'border.style.left' ) );
+
+	stylesProcessor.on( 'reduce:border-color', getTopRightBottomLeftValueReducer( 'border-color' ) );
+	stylesProcessor.on( 'reduce:border-style', getTopRightBottomLeftValueReducer( 'border-style' ) );
+	stylesProcessor.on( 'reduce:border-width', getTopRightBottomLeftValueReducer( 'border-width' ) );
+	stylesProcessor.on( 'reduce:border-top', getBorderPositionReducer( 'top' ) );
+	stylesProcessor.on( 'reduce:border-right', getBorderPositionReducer( 'right' ) );
+	stylesProcessor.on( 'reduce:border-bottom', getBorderPositionReducer( 'bottom' ) );
+	stylesProcessor.on( 'reduce:border-left', getBorderPositionReducer( 'left' ) );
+	stylesProcessor.on( 'reduce:border', borderReducer );
 }
 
 function borderNormalizer( evt, data ) {

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

@@ -9,14 +9,14 @@ import { getPositionShorthandNormalizer, getTopRightBottomLeftValueReducer } fro
  * @module engine/view/styles
  */
 
-export function addMarginStylesProcessor( stylesConverter ) {
-	stylesConverter.on( 'normalize:margin', getPositionShorthandNormalizer( 'margin' ) );
+export function addMarginStylesProcessor( stylesProcessor ) {
+	stylesProcessor.on( 'normalize:margin', getPositionShorthandNormalizer( 'margin' ) );
 
-	stylesConverter.on( 'normalize:margin-top', ( evt, data ) => ( data.path = 'margin.top' ) );
-	stylesConverter.on( 'normalize:margin-right', ( evt, data ) => ( data.path = 'margin.right' ) );
-	stylesConverter.on( 'normalize:margin-bottom', ( evt, data ) => ( data.path = 'margin.bottom' ) );
-	stylesConverter.on( 'normalize:margin-left', ( evt, data ) => ( data.path = 'margin.left' ) );
+	stylesProcessor.on( 'normalize:margin-top', ( evt, data ) => ( data.path = 'margin.top' ) );
+	stylesProcessor.on( 'normalize:margin-right', ( evt, data ) => ( data.path = 'margin.right' ) );
+	stylesProcessor.on( 'normalize:margin-bottom', ( evt, data ) => ( data.path = 'margin.bottom' ) );
+	stylesProcessor.on( 'normalize:margin-left', ( evt, data ) => ( data.path = 'margin.left' ) );
 
-	stylesConverter.on( 'reduce:margin', getTopRightBottomLeftValueReducer( 'margin' ) );
+	stylesProcessor.on( 'reduce:margin', getTopRightBottomLeftValueReducer( 'margin' ) );
 }
 

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

@@ -9,12 +9,12 @@ import { getPositionShorthandNormalizer, getTopRightBottomLeftValueReducer } fro
  * @module engine/view/styles
  */
 
-export function addPaddingStylesProcessor( stylesConverter ) {
-	stylesConverter.on( 'normalize:padding', getPositionShorthandNormalizer( 'padding' ) );
-	stylesConverter.on( 'normalize:padding-top', ( evt, data ) => ( data.path = 'padding.top' ) );
-	stylesConverter.on( 'normalize:padding-right', ( evt, data ) => ( data.path = 'padding.right' ) );
-	stylesConverter.on( 'normalize:padding-bottom', ( evt, data ) => ( data.path = 'padding.bottom' ) );
-	stylesConverter.on( 'normalize:padding-left', ( evt, data ) => ( data.path = 'padding.left' ) );
+export function addPaddingStylesProcessor( stylesProcessor ) {
+	stylesProcessor.on( 'normalize:padding', getPositionShorthandNormalizer( 'padding' ) );
+	stylesProcessor.on( 'normalize:padding-top', ( evt, data ) => ( data.path = 'padding.top' ) );
+	stylesProcessor.on( 'normalize:padding-right', ( evt, data ) => ( data.path = 'padding.right' ) );
+	stylesProcessor.on( 'normalize:padding-bottom', ( evt, data ) => ( data.path = 'padding.bottom' ) );
+	stylesProcessor.on( 'normalize:padding-left', ( evt, data ) => ( data.path = 'padding.left' ) );
 
-	stylesConverter.on( 'reduce:padding', getTopRightBottomLeftValueReducer( 'padding' ) );
+	stylesProcessor.on( 'reduce:padding', getTopRightBottomLeftValueReducer( 'padding' ) );
 }