Insert rule to style psuedo elements
480493
function (dropdown, target, settings, position) {
      var sheet = Foundation.stylesheet,
          pip_offset_base = 8;

      if (dropdown.hasClass(settings.mega_class)) {
        pip_offset_base = position.left + (target.outerWidth() / 2) - 8;
      } else if (this.small()) {
        pip_offset_base += position.left - 8;
      }

      this.rule_idx = sheet.cssRules.length;

      //default
      var sel_before = '.f-dropdown.open:before',
          sel_after  = '.f-dropdown.open:after',
          css_before = 'left: ' + pip_offset_base + 'px;',
          css_after  = 'left: ' + (pip_offset_base - 1) + 'px;';

      if (position.missRight == true) {
        pip_offset_base = dropdown.outerWidth() - 23;
        sel_before = '.f-dropdown.open:before',
        sel_after  = '.f-dropdown.open:after',
        css_before = 'left: ' + pip_offset_base + 'px;',
        css_after  = 'left: ' + (pip_offset_base - 1) + 'px;';
      }

      //just a case where right is fired, but its not missing right
      if (position.triggeredRight == true) {
        sel_before = '.f-dropdown.open:before',
        sel_after  = '.f-dropdown.open:after',
        css_before = 'left:-12px;',
        css_after  = 'left:-14px;';
      }

      if (sheet.insertRule) {
        sheet.insertRule([sel_before, '{', css_before, '}'].join(' '), this.rule_idx);
        sheet.insertRule([sel_after, '{', css_after, '}'].join(' '), this.rule_idx + 1);
      } else {
        sheet.addRule(sel_before, css_before, this.rule_idx);
        sheet.addRule(sel_after, css_after, this.rule_idx + 1);
      }
    }
231706
function setStyle(element, styles) {
  var style = element.style;


  forEach(styles, function (value, property) {
    if (REGEXP_SUFFIX.test(property) && isNumber(value)) {
      value += 'px';
    }

    style[property] = value;
  });
}
428055
function populateThemes(){
		this.preferences.getTheme(function(themeStyles) {
			var selectElement = document.getElementById('editorTheme');//$NON-NLS-0$
			while (selectElement.hasChildNodes() ){
				selectElement.removeChild(selectElement.lastChild);
			}
			for (var i =0; i < themeStyles.styles.length; i++) {
				var option = document.createElement('option');
				option.setAttribute('value', themeStyles.styles[i].name);
				//checks if a theme is the current theme 
				if (themeStyles.styles[i].name === themeStyles.style.name){
					option.setAttribute('selected', 'true');
				}
				option.appendChild(document.createTextNode(themeStyles.styles[i].name));
				selectElement.appendChild(option);
			}
			this.selectTheme(themeStyles.style.name);
		}.bind(this));
	}
964516
function createStylefromCode(styles, abspath) {
    //may import other file
    const arr = queryImport(styles)
    const baseRes = handleImportStyle(styles, abspath)
    const obj = {}
    const ast = csstree.parse(baseRes);
    csstree.walk(ast, {
        enter: function (node) {
            if (node.type === 'Rule' && node.prelude && node.prelude.type === 'SelectorList') {
                const clzName = []
                node.prelude.children.forEach(e => {
                    //we may handle each class selector here
                    let ans = selectorBlockHandler(e)
                    if (ans) {
                        //to save before value
                        obj[ans] = obj[ans] || {}
                        //save ans to log which to give value
                        clzName.push(ans)
                    }
                })
                const styleArray = []
                node.block.children.forEach(e => {
                    //handle with unit or function case
                    const styleItem = styleBlockHandler(e)
                    styleItem.length > 0 && styleArray.push(styleItem)
                })
                clzName.forEach(e => {
                    try {
                        const styleObject = transform(styleArray)
                        if (styleObject.fontWeight) {
                            //fontWeight must be string
                            styleObject.fontWeight = styleObject.fontWeight + ""
                        }
                        Object.assign(obj[e], styleObject)
                    } catch (e) {
                        console.error("convert ", abspath, " error:", e.message)
                    }

                })
            }
        },
    })
    return {styles: obj, imports: arr}
}
1095033
function appendCSS(cssText, element) {
  console.log(element);
  const styleElement = document.createElement('style');
  styleElement.setAttribute('type', 'text/css');
  styleElement.innerHTML = cssText;
  const refNode = element.hasChildNodes() ? element.children[0] : null;
  element.insertBefore(styleElement, refNode);
}
597411
function setStyles(el, styles) {
         var which;

         for (which in styles) {
             if (styles.hasOwnProperty(which)) {
                 Dom.setStyle(el, which, styles[which]);
             }
         }
     }
1250062
function expandElementRule (element, selectors = [], originalRule) {
  /** early return if we don't have any selectors */
  if (selectors.length === 0) return []

  let usedProps = []
  let expandedRules = []
  let defaultRules = []

  /** create the base rule */
  const baseRule = originalRule.clone()
  baseRule.selectors = selectors
  baseRule.selector = replaceElementTagMentions(element, baseRule.selector)

  /** create postcss rules for each element rule */
  for (const [ ruleSelector, ruleDecls ] of Object.entries(element.rules)) {
    const isRoot = element.pseudos.root === ruleSelector
    const isDefault = element.defaults.includes(ruleSelector)
    const expandedRule = baseRule.clone()

    /** gather all rules that get decls be default */
    if (isDefault) { defaultRules.push(expandedRule) }

    /** map all the selectors to target this rule selector */
    if (!isRoot) { expandedRule.selectors = expandedRule.selectors.map((selector) => `${selector} ${ruleSelector}`) }

    /** strip any non whitelisted props, run tranforms, gather used props */
    expandedRule.walkDecls((decl) => {
      const matchedRuleDecls = ruleDecls.filter(({ prop }) => prop.test(decl.prop))

      if (matchedRuleDecls.length === 0) { return decl.remove() }

      usedProps.push(decl.prop)
      matchedRuleDecls.forEach(({ transform }) => transform(decl, originalRule))
    })

    expandedRules.push(expandedRule)
  }

  baseRule.walkDecls((decl) => {
    if (!usedProps.includes(decl.prop)) {
      defaultRules.forEach((defaultRule) => defaultRule.prepend(decl.clone()))
    }
  })

  return expandedRules
}
581974
function (element, style) {
			var styleString = '';

			for (var key in style) {
				styleString += key + ': ' + style[key] + ';';
			}

			element.setAttribute('style', styleString);

			return element;
		}
1104950
function patchStyle(n, o) {
	var ns =     (n.attrs || emptyObj).style;
	var os = o ? (o.attrs || emptyObj).style : null;

	// replace or remove in full
	if (ns == null || isVal(ns))
		{ n.el.style.cssText = ns; }
	else {
		for (var nn in ns) {
			var nv = ns[nn];

			if (os == null || nv != null && nv !== os[nn])
				{ n.el.style[nn] = autoPx(nn, nv); }
		}

		// clean old
		if (os) {
			for (var on in os) {
				if (ns[on] == null)
					{ n.el.style[on] = ""; }
			}
		}
	}
}
288425
private void applyElementSize(Element element, int width, int height, boolean addCoordSize) {
		if (width >= 0 && height >= 0) {
			if (addCoordSize) {
				Dom.setElementAttribute(element, "coordsize", width + " " + height);
			}
			Dom.setStyleAttribute(element, "width", width + "px");
			Dom.setStyleAttribute(element, "height", height + "px");
		}
	}
664377
function( element )
					{
						if ( CKEDITOR.env.gecko )
						{
							// Grab only the style definition section.
							var styleDefSection = element.onlyChild().value.match( /\/\* Style Definitions \*\/([\s\S]*?)\/\*/ ),
								styleDefText = styleDefSection && styleDefSection[ 1 ],
								rules = {}; // Storing the parsed result.

							if ( styleDefText )
							{
								styleDefText
									// Remove line-breaks.
									.replace(/[\n\r]/g,'')
									// Extract selectors and style properties.
									.replace( /(.+?)\{(.+?)\}/g,
										function( rule, selectors, styleBlock )
										{
											selectors = selectors.split( ',' );
											var length = selectors.length, selector;
											for ( var i = 0; i < length; i++ )
											{
												// Assume MS-Word mostly generate only simple
												// selector( [Type selector][Class selector]).
												CKEDITOR.tools.trim( selectors[ i ] )
															  .replace( /^(\w+)(\.[\w-]+)?$/g,
												function( match, tagName, className )
												{
													tagName = tagName || '*';
													className = className.substring( 1, className.length );

													// Reject MS-Word Normal styles.
													if ( className.match( /MsoNormal/ ) )
														return;

													if ( !rules[ tagName ] )
														rules[ tagName ] = {};
													if ( className )
														rules[ tagName ][ className ] = styleBlock;
													else
														rules[ tagName ] = styleBlock;
												} );
											}
										});

								filters.applyStyleFilter = function( element )
								{
									var name = rules[ '*' ] ? '*' : element.name,
										className = element.attributes && element.attributes[ 'class' ],
										style;
									if ( name in rules )
									{
										style = rules[ name ];
										if ( typeof style == 'object' )
											style = style[ className ];
										// Maintain style rules priorities.
										style && element.addStyle( style, true );
									}
								};
							}
						}
						return false;
					}
947202
function svgStyle($critere_style, $attribs, $element)
	{
		$path_style = '';
		$fill_gradient = '';
		$w = '';
		$style = '';
		if (substr_count($critere_style['fill'], 'url') > 0 && $element != 'line') {
			//
			// couleur degradé
			$id_gradient = preg_replace("/url\(#([\w_]*)\)/i", "$1", $critere_style['fill']);
			if ($id_gradient != $critere_style['fill']) {
				if (isset($this->svg_gradient[$id_gradient])) {
					$fill_gradient = $this->svgGradient($this->svg_gradient[$id_gradient], $attribs, $element);
					if ($fill_gradient) {
						$path_style = "q ";
						$w = "W";
						$style .= 'N';
					}
				}
			}
		} // Used as indirect setting for currentColor
		else if (strtolower($critere_style['fill']) == 'currentcolor' && $element != 'line') {
			$col = $this->colorConverter->convert($critere_style['color'], $this->mpdf->PDFAXwarnings);
			if ($col) {
				if ($col{0} == 5 && is_numeric($col{4})) {
					$critere_style['fill-opacity'] = ord($col{4} / 100);
				} // RGBa
				if ($col{0} == 6 && is_numeric($col{5})) {
					$critere_style['fill-opacity'] = ord($col{5} / 100);
				} // CMYKa
				$path_style .= $this->mpdf->SetFColor($col, true) . ' ';
				$style .= 'F';
			}
		} else if ($critere_style['fill'] != 'none' && $element != 'line') {
			$col = $this->colorConverter->convert($critere_style['fill'], $this->mpdf->PDFAXwarnings);
			if ($col) {
				if ($col{0} == 5 && is_numeric($col{4})) {
					$critere_style['fill-opacity'] = ord($col{4} / 100);
				} // RGBa
				if ($col{0} == 6 && is_numeric($col{5})) {
					$critere_style['fill-opacity'] = ord($col{5} / 100);
				} // CMYKa
				$path_style .= $this->mpdf->SetFColor($col, true) . ' ';
				$style .= 'F';
			}
		}
		if (substr_count($critere_style['stroke'], 'url') > 0) {
			/*
			  // Cannot put a gradient on a "stroke" in PDF?
			  $id_gradient = preg_replace("/url\(#([\w_]*)\)/i","$1",$critere_style['stroke']);
			  if ($id_gradient != $critere_style['stroke']) {
			  if (isset($this->svg_gradient[$id_gradient])) {
			  $fill_gradient = $this->svgGradient($this->svg_gradient[$id_gradient], $attribs, $element);
			  if ($fill_gradient) {
			  $path_style = "q ";
			  $w = "W";
			  $style .= 'D';
			  }
			  }
			  }
			 */
		} // Used as indirect setting for currentColor
		else if (strtolower($critere_style['stroke']) == 'currentcolor') {
			$col = $this->colorConverter->convert($critere_style['color'], $this->mpdf->PDFAXwarnings);
			if ($col) {
				if ($col{0} == 5 && is_numeric($col{4})) {
					$critere_style['stroke-opacity'] = ord($col{4} / 100);
				} // RGBa
				if ($col{0} == 6 && is_numeric($col{5})) {
					$critere_style['stroke-opacity'] = ord($col{5} / 100);
				} // CMYKa
				$path_style .= $this->mpdf->SetDColor($col, true) . ' ';
				$style .= 'D';
				$lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']);
				$path_style .= sprintf('%.3F w ', $lw * $this->kp);
			}
		} else if ($critere_style['stroke'] != 'none') {
			$col = $this->colorConverter->convert($critere_style['stroke'], $this->mpdf->PDFAXwarnings);
			if ($col) {
				// mPDF 5.0.051
				// mPDF 5.3.74
				if ($col{0} == 5 && is_numeric($col{4})) {
					$critere_style['stroke-opacity'] = ord($col{4} / 100);
				} // RGBa
				if ($col{0} == 6 && is_numeric($col{5})) {
					$critere_style['stroke-opacity'] = ord($col{5} / 100);
				} // CMYKa
				$path_style .= $this->mpdf->SetDColor($col, true) . ' ';
				$style .= 'D';
				$lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']);
				$path_style .= sprintf('%.3F w ', $lw * $this->kp);
			}
		}


		if ($critere_style['stroke'] != 'none') {
			if ($critere_style['stroke-linejoin'] == 'miter') {
				$path_style .= ' 0 j ';
			} else if ($critere_style['stroke-linejoin'] == 'round') {
				$path_style .= ' 1 j ';
			} else if ($critere_style['stroke-linejoin'] == 'bevel') {
				$path_style .= ' 2 j ';
			}

			if ($critere_style['stroke-linecap'] == 'butt') {
				$path_style .= ' 0 J ';
			} else if ($critere_style['stroke-linecap'] == 'round') {
				$path_style .= ' 1 J ';
			} else if ($critere_style['stroke-linecap'] == 'square') {
				$path_style .= ' 2 J ';
			}

			if (isset($critere_style['stroke-miterlimit'])) {
				if ($critere_style['stroke-miterlimit'] == 'none') {
				} else if (preg_match('/^[\d.]+$/', $critere_style['stroke-miterlimit'])) {
					$path_style .= sprintf('%.2F M ', $critere_style['stroke-miterlimit']);
				}
			}
			if (isset($critere_style['stroke-dasharray'])) {
				$off = 0;
				$d = preg_split('/(,\s?|\s)/', $critere_style['stroke-dasharray']);
				if (count($d) == 1 && $d[0] == 0) {
					$path_style .= '[] 0 d ';
				} else {
					if (count($d) % 2 == 1) {
						$d = array_merge($d, $d);
					} // 5, 3, 1 => 5,3,1,5,3,1  OR 3 => 3,3
					$arr = '';
					for ($i = 0; $i < count($d); $i+=2) {
						$arr .= sprintf('%.3F %.3F ', $d[$i] * $this->kp, $d[$i + 1] * $this->kp);
					}
					if (isset($critere_style['stroke-dashoffset'])) {
						$off = $critere_style['stroke-dashoffset'] + 0;
					}
					$path_style .= sprintf('[%s] %.3F d ', $arr, $off * $this->kp);
				}
			}
		}

		if ($critere_style['fill-rule'] == 'evenodd') {
			$fr = '*';
		} else {
			$fr = '';
		}

		if (isset($critere_style['fill-opacity'])) {
			$opacity = 1;
			if ($critere_style['fill-opacity'] == 0) {
				$opacity = 0;
			} else if ($critere_style['fill-opacity'] > 1) {
				$opacity = 1;
			} else if ($critere_style['fill-opacity'] > 0) {
				$opacity = $critere_style['fill-opacity'];
			} else if ($critere_style['fill-opacity'] < 0) {
				$opacity = 0;
			}
			$gs = $this->mpdf->AddExtGState(['ca' => $opacity, 'BM' => '/Normal']);
			$this->mpdf->extgstates[$gs]['fo'] = true;
			$path_style .= sprintf(' /GS%d gs ', $gs);
		}

		if (isset($critere_style['stroke-opacity'])) {
			$opacity = 1;
			if ($critere_style['stroke-opacity'] == 0) {
				$opacity = 0;
			} else if ($critere_style['stroke-opacity'] > 1) {
				$opacity = 1;
			} else if ($critere_style['stroke-opacity'] > 0) {
				$opacity = $critere_style['stroke-opacity'];
			} else if ($critere_style['stroke-opacity'] < 0) {
				$opacity = 0;
			}
			$gs = $this->mpdf->AddExtGState(['CA' => $opacity, 'BM' => '/Normal']);
			$this->mpdf->extgstates[$gs]['fo'] = true;
			$path_style .= sprintf(' /GS%d gs ', $gs);
		}

		switch ($style) {
			case 'F':
				$op = 'f';
				break;
			case 'FD':
				$op = 'B';
				break;
			case 'ND':
				$op = 'S';
				break;
			case 'D':
				$op = 'S';
				break;
			default:
				$op = 'n';
		}

		$prestyle = $path_style . ' ';
		$poststyle = $w . ' ' . $op . $fr . ' ' . $fill_gradient . "\n";
		return [$prestyle, $poststyle];
	}
1152971
public void applyStyleToElement(Style style, JRDesignElement designElemen) {
        if (style == null) {
//			log.warn("NULL style passed to object");
            JRDesignStyle style_ = new JRDesignStyle();
            style_.setName(createUniqueStyleName());
            designElemen.setStyle(style_);
            try {
                getDesign().addStyle(style_);
            } catch (JRException e) {
                //duplicated style, its ok
            }
//			return null;
            return;
        }
        boolean existsInDesign = style.getName() != null
                && design.getStylesMap().get(style.getName()) != null;
        //		&& !style.isOverridesExistingStyle();

        JRDesignStyle jrstyle;
        //Let's allways add a new JR style
        if (existsInDesign && !style.isOverridesExistingStyle()) {
            jrstyle = (JRDesignStyle) design.getStylesMap().get(style.getName());
        } else {
            addStyleToDesign(style); //Order maters. This line fist
            jrstyle = style.transform();
        }

        designElemen.setStyle(jrstyle);
        if (designElemen instanceof JRDesignTextElement) {
            JRDesignTextElement textField = (JRDesignTextElement) designElemen;
            if (style.getStreching() != null)
                textField.setStretchType(StretchTypeEnum.getByValue(style.getStreching().getValue()));
            textField.setPositionType(PositionTypeEnum.FLOAT);

        }
        if (designElemen instanceof JRDesignTextField) {
            JRDesignTextField textField = (JRDesignTextField) designElemen;
            textField.setStretchWithOverflow(style.isStretchWithOverflow());

            if (!textField.isBlankWhenNull() && style.isBlankWhenNull()) //TODO Re check if this condition is ok
                textField.setBlankWhenNull(true);
        }

        if (designElemen instanceof JRDesignGraphicElement) {
            JRDesignGraphicElement graphicElement = (JRDesignGraphicElement) designElemen;
            graphicElement.setStretchType(StretchTypeEnum.getByValue(style.getStreching().getValue()));
            graphicElement.setPositionType(PositionTypeEnum.FLOAT);
        }
    }
410693
function(oColumn) {
    if(oColumn.getKeyIndex() !== null) {
        this._elColgroup.childNodes[oColumn.getKeyIndex()].style.width = '';
    }
}
769256
function getCSSRules(doc) {
    var styles = doc.getElementsByTagName('style'),
        allRules = { },
        rules;

    // very crude parsing of style contents
    for (var i = 0, len = styles.length; i < len; i++) {
      var styleContents = styles[0].textContent;

      // remove comments
      styleContents = styleContents.replace(/\/\*[\s\S]*?\*\//g, '');

      rules = styleContents.match(/[^{]*\{[\s\S]*?\}/g);
      rules = rules.map(function(rule) { return rule.trim() });

      rules.forEach(function(rule) {
        var match = rule.match(/([\s\S]*?)\s*\{([^}]*)\}/),
            rule = match[1],
            declaration = match[2].trim(),
            propertyValuePairs = declaration.replace(/;$/, '').split(/\s*;\s*/);

        if (!allRules[rule]) {
          allRules[rule] = { };
        }

        for (var i = 0, len = propertyValuePairs.length; i < len; i++) {
          var pair = propertyValuePairs[i].split(/\s*:\s*/),
              property = pair[0],
              value = pair[1];

          allRules[rule][property] = value;
        }
      });
    }

    return allRules;
  }
569965
function styleBoxes(selection, self) {
    selection
      .style('width', `${self.boxWidth}px`)
      .style('height', `${self.boxHeight}px`);
    // .style('margin', `${self.boxMargin / 2}px`)
  }
463075
private static void applyShapeStyle(Element element, ShapeStyle style) {
		// First check the presence of the fill and stroke elements:
		NodeList<Element> fills = element.getElementsByTagName("fill");
		if (fills.getLength() == 0) {
			Element stroke = Dom.createElementNS(Dom.NS_VML, "stroke");
			element.appendChild(stroke);
			Element fill = Dom.createElementNS(Dom.NS_VML, "fill");
			element.appendChild(fill);
			fills = element.getElementsByTagName("fill");
		}

		// Then if fill-color then filled=true:
		if (style.getFillColor() != null) {
			element.setAttribute("filled", "true");
			fills.getItem(0).setAttribute("color", style.getFillColor());
			fills.getItem(0).setAttribute("opacity", Float.toString(style.getFillOpacity()));
		} else {
			element.setAttribute("filled", "false");
		}

		// Then if stroke-color then stroke=true:
		if (style.getStrokeColor() != null) {
			element.setAttribute("stroked", "true");
			NodeList<Element> strokes = element.getElementsByTagName("stroke");
			strokes.getItem(0).setAttribute("color", style.getStrokeColor());
			strokes.getItem(0).setAttribute("opacity", Float.toString(style.getStrokeOpacity()));
			element.setAttribute("strokeweight", Float.toString(style.getStrokeWidth()));
		} else {
			element.setAttribute("stroked", "false");
		}
	}