Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 95934261447126e14950eb1f242374ce2a01e5fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************************************************
 * Copyright (c) 2004, 2013 John Krasnay 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:
 *     John Krasnay - initial API and implementation
 *     Florian Thienel - a NULL object
 *******************************************************************************/
package org.eclipse.vex.core.internal.css;

import org.eclipse.vex.core.provisional.dom.INode;

/**
 * Determines whitespace policy for document elements. For example, a CSS stylesheet implements a whitespace policy via
 * its display and white-space properties.
 */
public interface IWhitespacePolicy {

	/**
	 * A NULL object of this type. No blocks and no pre elements.
	 */
	IWhitespacePolicy NULL = new IWhitespacePolicy() {
		public boolean isBlock(final INode node) {
			return false;
		}

		public boolean isPre(final INode node) {
			return false;
		}
	};

	/**
	 * This policy preserves whitespace but knows no blocks.
	 */
	IWhitespacePolicy PRESERVE_WHITESPACE = new IWhitespacePolicy() {
		public boolean isBlock(final INode node) {
			return false;
		}

		public boolean isPre(final INode node) {
			return true;
		}
	};

	/**
	 * Returns true if the given element is normally block-formatted.
	 * 
	 * @param element
	 *            Element to test.
	 */
	boolean isBlock(INode node);

	/**
	 * Returns true if the given element is pre-formatted, that is, all of its contained whitespace should be preserved.
	 * 
	 * @param element
	 *            Element to test.
	 */
	boolean isPre(INode node);
}

Back to the top