Skip to content

Commit

Permalink
#649 Link to web doc for background props from source
Browse files Browse the repository at this point in the history
This might work if we maintain it.
  • Loading branch information
danfickle committed Feb 16, 2021
1 parent 8984de6 commit 661f0e0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
import com.openhtmltopdf.css.parser.FSRGBColor;
import com.openhtmltopdf.css.parser.PropertyValue;
import com.openhtmltopdf.css.sheet.PropertyDeclaration;
import com.openhtmltopdf.util.WebDoc;
import com.openhtmltopdf.util.WebDocLocations;

@WebDoc(WebDocLocations.CSS_BACKGROUND_PROPERTIES)
public class BackgroundPropertyBuilder extends AbstractPropertyBuilder {
// [<'background-color'> || <'background-image'> || <'background-repeat'> ||
// <'background-attachment'> || <'background-position'>] | inherit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import com.openhtmltopdf.css.parser.Token;
import com.openhtmltopdf.css.parser.property.PrimitivePropertyBuilders.GenericColor;
import com.openhtmltopdf.css.sheet.PropertyDeclaration;
import com.openhtmltopdf.util.WebDoc;
import com.openhtmltopdf.util.WebDocLocations;

@WebDoc(WebDocLocations.CSS_BACKGROUND_PROPERTIES)
public class PrimitiveBackgroundPropertyBuilders {
private static BitSet setOf(IdentValue... val) {
return PrimitivePropertyBuilders.setFor(val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.openhtmltopdf.css.style;

import java.awt.Cursor;
import java.lang.annotation.Documented;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -55,6 +56,8 @@
import com.openhtmltopdf.render.FSFontMetrics;
import com.openhtmltopdf.render.RenderingContext;
import com.openhtmltopdf.util.LogMessageId;
import com.openhtmltopdf.util.WebDoc;
import com.openhtmltopdf.util.WebDocLocations;
import com.openhtmltopdf.util.XRLog;
import com.openhtmltopdf.util.XRRuntimeException;

Expand Down Expand Up @@ -1388,6 +1391,11 @@ public FSLinearGradient getLinearGradient(
return new FSLinearGradient(this, value.getFunction(), boxWidth, boxHeight, cssContext);
}

/**
* Gets the values of the background properties and combines in a list
* of BackgroundContainer values.
*/
@WebDoc(WebDocLocations.CSS_BACKGROUND_PROPERTIES)
public List<BackgroundContainer> getBackgroundImages() {
List<PropertyValue> images = ((ListValue) valueByName(CSSName.BACKGROUND_IMAGE)).getValues();
List<PropertyValue> positions = ((ListValue) valueByName(CSSName.BACKGROUND_POSITION)).getValues();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.openhtmltopdf.util;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.SOURCE;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;


/**
* Lets us specify a url where the type, method, etc
* is documented. Specified as an annotation so we can use
* IDE features to find instances and maybe tooling can use it too.
*/
@Retention(SOURCE)
@Target({ TYPE, FIELD, METHOD, CONSTRUCTOR })
public @interface WebDoc {
/**
* A url where docs can be found.
*/
public String value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.openhtmltopdf.util;

public class WebDocLocations {
public static final String CSS_BACKGROUND_PROPERTIES = "https://github.com/danfickle/openhtmltopdf/wiki/Big-CSS-reference#background-properties";
}

0 comments on commit 661f0e0

Please sign in to comment.