public CloneableStyleDeclaration(StyleDeclaration sd) {
   this.count = sd.size();
   this.values = new Value[count];
   for (int idx = 0; idx < count; idx++) {
     this.values[idx] = sd.getValue(idx);
   }
   this.indexes = new int[count];
   for (int idx = 0; idx < count; idx++) {
     this.indexes[idx] = sd.getIndex(idx);
   }
   this.priorities = new boolean[count];
   for (int idx = 0; idx < count; idx++) {
     this.priorities[idx] = sd.getPriority(idx);
   }
 }
  public void updateCSSColor(Color colorToChange, Color newColor) {
    if (colorToChange == null || newColor == null || colorToChange.equals(newColor)) {
      return;
    }

    FloatValue newRedValue = new FloatValue((short) 1, (float) newColor.getRed());
    FloatValue newGreenValue = new FloatValue((short) 1, (float) newColor.getGreen());
    FloatValue newBlueValue = new FloatValue((short) 1, (float) newColor.getBlue());
    RGBColorValue newRGBColorValue = new RGBColorValue(newRedValue, newGreenValue, newBlueValue);

    StyleDeclaration sd = originalStyle.clone();
    int sdlen = sd.size();
    for (int sdindex = 0; sdindex < sdlen; sdindex++) {
      Value val = sd.getValue(sdindex);
      if (val instanceof RGBColorValue) {
        RGBColorValue colorVal = (RGBColorValue) val;
        if (isSameColor(colorVal, colorToChange)) {
          sd.put(sdindex, newRGBColorValue, sd.getIndex(sdindex), sd.getPriority(sdindex));
        }
      }
    }
    element.getStyle().setCssText(sd.toString(cssEngine));
  }