add _vex-inline-marker CSS property to hide inline markers
Change-Id: I83d0f5948169a6d5dde5894a79655d8ca6237e97
Signed-off-by: Carsten Hiesserich <carsten.hie@gmail.com>
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/block-inline.css b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/block-inline.css
index ba32596..1b68fee 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/block-inline.css
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/block-inline.css
@@ -9,6 +9,11 @@
display: inline;
}
+nomarker {
+ display: inline;
+ _vex-inline-marker: none;
+}
+
p {
display: block;
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/block-inline.xml b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/block-inline.xml
index d9aaccd..67aea0a 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/block-inline.xml
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/block-inline.xml
@@ -258,7 +258,28 @@
</result>
</test>
-
+ <test id="Inline w/o marker" layoutWidth="100">
+ <doc><![CDATA[ <root><nomarker>cat sat</nomarker></root> ]]></doc>
+ <result>
+ <box class="RootBox">
+ <box class="BlockElementBox">
+ <box class="BlockElementBox" element="root">
+ <box class="ParagraphBox">
+ <box class="LineBox">
+ <box class="PlaceholderBox" />
+ <box class="InlineElementBox">
+ <box class="DocumentTextBox" text="cat " />
+ <box class="DocumentTextBox" text="sat" />
+ <box class="PlaceholderBox" />
+ </box>
+ <box class="PlaceholderBox" />
+ </box>
+ </box>
+ </box>
+ </box>
+ </box>
+ </result>
+ </test>
<test id="Block Child w/ Inline Before" layoutWidth="75">
<doc><![CDATA[ <root>Paris <p>Garters</p></root> ]]></doc>
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/CSS.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/CSS.java
index beb8584..fdaa4f3 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/CSS.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/CSS.java
@@ -133,6 +133,7 @@
// we can't use a dash '-vex' here, because of a bug in the batik css parser
// see https://issues.apache.org/bugzilla/show_bug.cgi?id=47800
public static final String OUTLINE_CONTENT = "_vex-outline-content";
+ public static final String INLINE_MARKER = "_vex-inline-marker";
// suffixes to BORDER_XXX
public static final String COLOR_SUFFIX = "-color";
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/InlineMarkerProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/InlineMarkerProperty.java
new file mode 100644
index 0000000..29275e7
--- /dev/null
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/InlineMarkerProperty.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Carsten Hiesserich and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Carsten Hiesserich - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.vex.core.internal.css;
+
+import org.eclipse.vex.core.provisional.dom.INode;
+import org.w3c.css.sac.LexicalUnit;
+
+/**
+ * The -vex-inline-marker CSS property. This property decides the type of inline markers<br />
+ * The value <code>none</code> will hide the inline markers around the element.<br />
+ * The defualt is <code>normal</code> to display the default markers.
+ */
+public class InlineMarkerProperty extends AbstractProperty {
+
+ /**
+ * Class constructor.
+ */
+ public InlineMarkerProperty() {
+ super(CSS.INLINE_MARKER);
+ }
+
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final INode node) {
+ if (isInlineMarker(lu)) {
+ return lu.getStringValue();
+ }
+
+ return CSS.NORMAL;
+ }
+
+ /**
+ * Returns true if the given lexical unit represents a valid _vex-inline-marker.
+ *
+ * @param lu
+ * LexicalUnit to check.
+ */
+ public static boolean isInlineMarker(final LexicalUnit lu) {
+ if (lu == null) {
+ return false;
+ } else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
+ final String s = lu.getStringValue();
+ return s.equals(CSS.NORMAL) || s.equals(CSS.NONE);
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java
index 0a6707a..9aa8714 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java
@@ -82,7 +82,7 @@
new BorderWidthProperty(CSS.BORDER_LEFT_WIDTH, CSS.BORDER_LEFT_STYLE, IProperty.Axis.HORIZONTAL),
new BorderWidthProperty(CSS.BORDER_RIGHT_WIDTH, CSS.BORDER_RIGHT_STYLE, IProperty.Axis.HORIZONTAL),
new BorderWidthProperty(CSS.BORDER_TOP_WIDTH, CSS.BORDER_TOP_STYLE, IProperty.Axis.VERTICAL), new BorderSpacingProperty(), new LengthProperty(CSS.HEIGHT, IProperty.Axis.VERTICAL),
- new LengthProperty(CSS.WIDTH, IProperty.Axis.HORIZONTAL), new BackgroundImageProperty(), new OutlineContentProperty() };
+ new LengthProperty(CSS.WIDTH, IProperty.Axis.HORIZONTAL), new BackgroundImageProperty(), new OutlineContentProperty(), new InlineMarkerProperty() };
/**
* The rules that comprise the stylesheet.
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java
index 1cc7da2..5f8e14d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java
@@ -229,6 +229,13 @@
}
/**
+ * Returns the value of the <code>_vex-inline-marker</code> property.
+ */
+ public String getInlineMarker() {
+ return (String) values.get(CSS.INLINE_MARKER);
+ }
+
+ /**
* Returns the value of the <code>lineHeight</code> property.
*/
public int getLineHeight() {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/InlineElementBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/InlineElementBox.java
index d6ecd4a..ac62e8b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/InlineElementBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/InlineElementBox.java
@@ -77,7 +77,9 @@
childList.addAll(LayoutUtils.createGeneratedInlines(context, beforeElement));
}
// left marker
- childList.add(createLeftMarker(node, styles));
+ if (styles.getInlineMarker().equals(CSS.NORMAL)) {
+ childList.add(createLeftMarker(node, styles));
+ }
}
// background image
@@ -106,7 +108,9 @@
childList.add(new PlaceholderBox(context, node, node.getEndOffset() - node.getStartOffset()));
// trailing marker
- childList.add(createRightMarker(node, styles));
+ if (styles.getInlineMarker().equals(CSS.NORMAL)) {
+ childList.add(createRightMarker(node, styles));
+ }
// :after content
final IElement afterElement = context.getStyleSheet().getPseudoElement(node, CSS.PSEUDO_AFTER, true);