Skip to content

Commit

Permalink
For #9 - Implement direction CSS property in preparation of improving…
Browse files Browse the repository at this point in the history
… RTL and BIDI implementation. [ci skip]
  • Loading branch information
danfickle committed Oct 25, 2016
1 parent ed55798 commit 3bee0bc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ public final class CSSName implements Comparable {
PRIMITIVE,
"ltr",
INHERITS,
false,
null
true,
new PrimitivePropertyBuilders.Direction()
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public class IdentValue implements FSDerivedValue {
public final static IdentValue REPEAT_Y = addValue("repeat-y");
public final static IdentValue RIDGE = addValue("ridge");
public final static IdentValue RIGHT = addValue("right");
public final static IdentValue RTL = addValue("rtl");
public final static IdentValue RUN_IN = addValue("run-in");
public final static IdentValue SCROLL = addValue("scroll");
public final static IdentValue SEPARATE = addValue("separate");
Expand Down Expand Up @@ -230,7 +231,7 @@ public class IdentValue implements FSDerivedValue {
/**
* Description of the Field
*/
private static Map ALL_IDENT_VALUES;
private static Map<String, IdentValue> ALL_IDENT_VALUES;

/**
* Constructor for the IdentValue object
Expand Down Expand Up @@ -292,7 +293,7 @@ public static int getIdentCount() {
*/
private final static synchronized IdentValue addValue(String ident) {
if (ALL_IDENT_VALUES == null) {
ALL_IDENT_VALUES = new HashMap();
ALL_IDENT_VALUES = new HashMap<String, IdentValue>();
}
IdentValue val = new IdentValue(ident);
ALL_IDENT_VALUES.put(ident, val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class PrimitivePropertyBuilders {
// thin | medium | thick
public static final BitSet BORDER_WIDTHS = setFor(
new IdentValue[] { IdentValue.THIN, IdentValue.MEDIUM, IdentValue.THICK });

public static final BitSet DIRECTIONS = setFor(
new IdentValue[] { IdentValue.LTR, IdentValue.RTL, IdentValue.AUTO });

// normal | small-caps | inherit
public static final BitSet FONT_VARIANTS = setFor(
Expand Down Expand Up @@ -186,6 +189,13 @@ protected BitSet getAllowed() {
return BORDER_STYLES;
}
}

public static class Direction extends SingleIdent {
@Override
protected BitSet getAllowed() {
return DIRECTIONS;
}
}

private static class GenericBorderWidth extends AbstractPropertyBuilder {
public List buildDeclarations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,18 @@ public boolean isDynamicAutoWidthApplicable() {
public boolean isCanBeShrunkToFit() {
return isInlineBlock() || isFloated() || isAbsolute() || isFixed();
}


public boolean isDirectionLTR() {
return isIdent(CSSName.DIRECTION, IdentValue.LTR);
}

public boolean isDirectionRTL() {
return isIdent(CSSName.DIRECTION, IdentValue.RTL);
}

public boolean isDirectionAuto() {
return isIdent(CSSName.DIRECTION, IdentValue.AUTO);
}
}// end class

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,16 @@ hr[size="1"] {
form{
margin: 0 0 1em 0;
}

bdi {
direction: auto;
}
[dir=ltr], bdi[dir=ltr] {
direction: ltr;
}
[dir=rtl], bdi[dir=rtl] {
direction: rtl;
}
[dir=auto] {
direction: auto;
}

0 comments on commit 3bee0bc

Please sign in to comment.