+2007-10-21 Nikolas Zimmermann <zimmermann@kde.org>
+
+ Reviewed by Eric.
+
+ Add new testcase to stress test the glyph-orientation-* parsing rules.
+
+ * svg/css/getComputedStyle-basic-expected.txt:
+ * svg/css/getComputedStyle-basic.xhtml:
+ * svg/css/glyph-orientation-rounding-test-expected.txt: Added.
+ * svg/css/glyph-orientation-rounding-test.xhtml: Added.
+
2007-10-21 Dan Bernstein <mitz@apple.com>
Reviewed by Dave Hyatt.
rect: style.getPropertyCSSValue(text-anchor) : [object CSSPrimitiveValue]
rect: style.getPropertyValue(writing-mode) : lr-tb
rect: style.getPropertyCSSValue(writing-mode) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(glyph-orientation-horizontal) : 0deg
+rect: style.getPropertyCSSValue(glyph-orientation-horizontal) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(glyph-orientation-vertical) : auto
+rect: style.getPropertyCSSValue(glyph-orientation-vertical) : [object CSSPrimitiveValue]
g: style.getPropertyValue(background-attachment) : scroll
g: style.getPropertyCSSValue(background-attachment) : [object CSSPrimitiveValue]
g: style.getPropertyValue(background-color) : rgba(0, 0, 0, 0)
g: style.getPropertyCSSValue(text-anchor) : [object CSSPrimitiveValue]
g: style.getPropertyValue(writing-mode) : lr-tb
g: style.getPropertyCSSValue(writing-mode) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(glyph-orientation-horizontal) : 0deg
+g: style.getPropertyCSSValue(glyph-orientation-horizontal) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(glyph-orientation-vertical) : auto
+g: style.getPropertyCSSValue(glyph-orientation-vertical) : [object CSSPrimitiveValue]
--- /dev/null
+Stress test glyph-orientation SVG CSS propertiesOn success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Strings that fail to parse, and hence parse as "0" for horziontal and "auto" as vertical.
+
+Test angleValue: ' 0,1'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: ' 0,1'
+PASS computedStyle.getPropertyValue('glyph-orientation-vertical') is "auto"
+
+Test angleValue: ' 0,00000.1'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: ' 0,00000.1'
+PASS computedStyle.getPropertyValue('glyph-orientation-vertical') is "auto"
+
+Test angleValue: ' 0 1'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: ' 0 1'
+PASS computedStyle.getPropertyValue('glyph-orientation-vertical') is "auto"
+
+Test angleValue: '0.1 0.2'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '0.1 0.2'
+PASS computedStyle.getPropertyValue('glyph-orientation-vertical') is "auto"
+
+Test angleValue: ' 270,1'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: ' 270,1'
+PASS computedStyle.getPropertyValue('glyph-orientation-vertical') is "auto"
+
+Test angleValue: ' 270,00000.1'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: ' 270,00000.1'
+PASS computedStyle.getPropertyValue('glyph-orientation-vertical') is "auto"
+
+Test angleValue: ' 270 1'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: ' 270 1'
+PASS computedStyle.getPropertyValue('glyph-orientation-vertical') is "auto"
+
+Test angleValue: '270.1 0.2'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '270.1 0.2'
+PASS computedStyle.getPropertyValue('glyph-orientation-vertical') is "auto"
+
+This tests the rounding of glyph orientation values to the only allowed values 0, 90, 180, 270.
+
+Test angleValue: '-0.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '-0.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: '-10.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '-10.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: '-45.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '-45.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: '0.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '0.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: '10.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '10.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: '45.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '45.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: '-90.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '-90.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '-100.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '-100.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '-135.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '-135.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '90.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '90.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '100.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '100.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '135.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '135.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '-180.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '-180.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '-190.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '-190.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '-225.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '-225.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '180.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '180.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '190.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '190.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '225.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '225.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '-270.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '-270.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Test angleValue: '-280.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '-280.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Test angleValue: '-305.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '-305.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Test angleValue: '270.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '270.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Test angleValue: '280.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '280.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Test angleValue: '305.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '305.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Tests angles bigger than 360.
+
+Test angleValue: '449.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '449.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '450.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '450.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '451.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '451.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '539.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '539.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '540.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '540.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '541.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '541.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: '629.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '629.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Test angleValue: '630.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '630.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Test angleValue: '631.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: '631.0'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Tests whitespace before/after angle value.
+
+Test angleValue: ' .0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: ' .0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: ' 0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: ' 0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: ' 90.0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: ' 90.0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: ' 180.0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: ' 180.0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+Test angleValue: ' 270.0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 270
+
+Test angleValue: ' 270.0 '
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 270
+
+Tests rounding of fractional angle values.
+
+Test angleValue: '45.0000'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 0
+
+Test angleValue: '45.0000'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 0
+
+Test angleValue: '45.0001'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '45.0001'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '135.000'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 90
+
+Test angleValue: '135.000'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 90
+
+Test angleValue: '135.001'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-horizontal').getFloatValue() is 180
+
+Test angleValue: '135.001'
+PASS computedStyle.getPropertyCSSValue('glyph-orientation-vertical').getFloatValue() is 180
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"/>
+<script src="../../fast/js/resources/js-test-pre.js"/>
+</head>
+<body>
+<svg display="none" xmlns="http://www.w3.org/2000/svg"><text id="text"/></svg>
+<p id="description"></p>
+<div id="console"/>
+<script>
+var textElement = document.getElementById("text");
+var computedStyle;
+
+function parseGlyphOrientationHelper(property, angleValue, expectedValue)
+{
+ textElement.setAttributeNS(null, property, angleValue);
+ computedStyle = textElement.ownerDocument.defaultView.getComputedStyle(textElement);
+
+ debug("Test angleValue: '" + angleValue + "'");
+
+ if (expectedValue == "auto") {
+ shouldBe("computedStyle.getPropertyValue('" + property + "')", '"auto"');
+ } else {
+ shouldBe("computedStyle.getPropertyCSSValue('" + property + "').getFloatValue()", "" + expectedValue);
+ }
+
+ debug("");
+}
+
+function parseGlyphOrientation(angleValue, expectedValue)
+{
+ if (expectedValue == undefined) {
+ parseGlyphOrientationHelper("glyph-orientation-horizontal", angleValue, 0.0);
+ parseGlyphOrientationHelper("glyph-orientation-vertical", angleValue, "auto");
+ } else {
+ parseGlyphOrientationHelper("glyph-orientation-horizontal", angleValue, expectedValue);
+ parseGlyphOrientationHelper("glyph-orientation-vertical", angleValue, expectedValue);
+ }
+}
+
+description('Stress test glyph-orientation SVG CSS properties');
+debug('');
+
+debug('Strings that fail to parse, and hence parse as "0" for horziontal and "auto" as vertical.');
+debug('');
+
+parseGlyphOrientation(" 0,1");
+parseGlyphOrientation(" 0,00000.1");
+parseGlyphOrientation(" 0 1");
+parseGlyphOrientation("0.1 0.2");
+
+parseGlyphOrientation(" 270,1");
+parseGlyphOrientation(" 270,00000.1");
+parseGlyphOrientation(" 270 1");
+parseGlyphOrientation("270.1 0.2");
+
+
+debug('This tests the rounding of glyph orientation values to the only allowed values 0, 90, 180, 270.');
+debug('');
+
+parseGlyphOrientation("-0.0", 0.0);
+parseGlyphOrientation("-10.0", 0.0);
+parseGlyphOrientation("-45.0", 0.0);
+parseGlyphOrientation("0.0", 0.0);
+parseGlyphOrientation("10.0", 0.0);
+parseGlyphOrientation("45.0", 0.0);
+
+parseGlyphOrientation("-90.0", 90.0);
+parseGlyphOrientation("-100.0", 90.0);
+parseGlyphOrientation("-135.0", 90.0);
+parseGlyphOrientation("90.0", 90.0);
+parseGlyphOrientation("100.0", 90.0);
+parseGlyphOrientation("135.0", 90.0);
+
+parseGlyphOrientation("-180.0", 180.0);
+parseGlyphOrientation("-190.0", 180.0);
+parseGlyphOrientation("-225.0", 180.0);
+parseGlyphOrientation("180.0", 180.0);
+parseGlyphOrientation("190.0", 180.0);
+parseGlyphOrientation("225.0", 180.0);
+
+parseGlyphOrientation("-270.0", 270.0);
+parseGlyphOrientation("-280.0", 270.0);
+parseGlyphOrientation("-305.0", 270.0);
+parseGlyphOrientation("270.0", 270.0);
+parseGlyphOrientation("280.0", 270.0);
+parseGlyphOrientation("305.0", 270.0);
+
+debug('Tests angles bigger than 360.');
+debug('');
+
+parseGlyphOrientation("449.0", 90.0);
+parseGlyphOrientation("450.0", 90.0);
+parseGlyphOrientation("451.0", 90.0);
+
+parseGlyphOrientation("539.0", 180.0);
+parseGlyphOrientation("540.0", 180.0);
+parseGlyphOrientation("541.0", 180.0);
+
+parseGlyphOrientation("629.0", 270.0);
+parseGlyphOrientation("630.0", 270.0);
+parseGlyphOrientation("631.0", 270.0);
+
+debug('Tests whitespace before/after angle value.');
+debug('');
+
+parseGlyphOrientation(" .0 ", 0.0);
+parseGlyphOrientation(" 0 ", 0.0);
+parseGlyphOrientation(" 90.0 ", 90.0);
+parseGlyphOrientation(" 180.0 ", 180.0);
+parseGlyphOrientation(" 270.0 ", 270.0);
+
+debug('Tests rounding of fractional angle values.');
+debug('');
+
+parseGlyphOrientation("45.0000", 0.0);
+parseGlyphOrientation("45.0001", 90.0);
+parseGlyphOrientation("135.000", 90.0);
+parseGlyphOrientation("135.001", 180.0);
+
+successfullyParsed = true;
+
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+
+</body>
+</html>
+2007-10-21 Nikolas Zimmermann <zimmermann@kde.org>
+
+ Reviewed by Eric.
+
+ Handle glyph-orientation-vertical / glyph-orientation-horizontal SVG CSS properties.
+
+ The SVG layouting code itself doesn't handle these properties yet,
+ it's just about recognizing them in the SVG CSS engine.
+
+ * ksvg2/css/SVGCSSComputedStyleDeclaration.cpp:
+ (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
+ * ksvg2/css/SVGCSSParser.cpp:
+ (WebCore::CSSParser::parseSVGValue):
+ * ksvg2/css/SVGCSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::applySVGProperty):
+ * ksvg2/css/SVGRenderStyle.h:
+ (WebCore::SVGRenderStyle::InheritedFlags::operator==):
+ (WebCore::SVGRenderStyle::InheritedFlags::operator!=):
+ (WebCore::SVGRenderStyle::setBitDefaults):
+ * ksvg2/css/SVGRenderStyleDefs.h:
+
2007-10-21 Christian Dywan <christian@twotoasts.de>
Reviewed by Alp.
CSS_PROP_DOMINANT_BASELINE,
CSS_PROP_KERNING,
CSS_PROP_TEXT_ANCHOR,
- CSS_PROP_WRITING_MODE
+ CSS_PROP_WRITING_MODE,
+ CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL,
+ CSS_PROP_GLYPH_ORIENTATION_VERTICAL
#endif
};
*/
#include "config.h"
+
#if ENABLE(SVG)
#include "CSSComputedStyleDeclaration.h"
#include "Document.h"
namespace WebCore {
-
+
+static CSSPrimitiveValue* glyphOrientationToCSSPrimitiveValue(EGlyphOrientation orientation)
+{
+ switch (orientation) {
+ case GO_0DEG:
+ return new CSSPrimitiveValue(0.0f, CSSPrimitiveValue::CSS_DEG);
+ case GO_90DEG:
+ return new CSSPrimitiveValue(90.0f, CSSPrimitiveValue::CSS_DEG);
+ case GO_180DEG:
+ return new CSSPrimitiveValue(180.0f, CSSPrimitiveValue::CSS_DEG);
+ case GO_270DEG:
+ return new CSSPrimitiveValue(270.0f, CSSPrimitiveValue::CSS_DEG);
+ default:
+ return 0;
+ }
+}
+
PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
{
Node* node = m_node.get();
return svgStyle->baselineShiftValue();
}
}
+ case CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL:
+ return glyphOrientationToCSSPrimitiveValue(svgStyle->glyphOrientationHorizontal());
+ case CSS_PROP_GLYPH_ORIENTATION_VERTICAL: {
+ if (CSSPrimitiveValue* value = glyphOrientationToCSSPrimitiveValue(svgStyle->glyphOrientationVertical()))
+ return value;
+
+ if (svgStyle->glyphOrientationVertical() == GO_AUTO)
+ return new CSSPrimitiveValue(CSS_VAL_AUTO);
+
+ return 0;
+ }
case CSS_PROP_MARKER:
case CSS_PROP_ENABLE_BACKGROUND:
case CSS_PROP_COLOR_PROFILE:
- case CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL:
- case CSS_PROP_GLYPH_ORIENTATION_VERTICAL:
// the above properties are not yet implemented in the engine
break;
default:
*/
#include "config.h"
-#if ENABLE(SVG)
+#if ENABLE(SVG)
#include "CSSInheritedValue.h"
#include "CSSInitialValue.h"
#include "CSSParser.h"
valid_primitive = true;
break;
}
- /* fallthrough intentional */
- case CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL: // <angle> | inherit
- if (value->unit == CSSPrimitiveValue::CSS_DEG)
+ /* fallthrough intentional */
+ case CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL: // <angle> (restricted to _deg_ per SVG 1.1 spec) | inherit
+ if (value->unit == CSSPrimitiveValue::CSS_DEG || value->unit == CSSPrimitiveValue::CSS_NUMBER) {
parsedValue = new CSSPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_DEG);
- else if (value->unit == CSSPrimitiveValue::CSS_GRAD)
- parsedValue = new CSSPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_GRAD);
- else if (value->unit == CSSPrimitiveValue::CSS_RAD)
- parsedValue = new CSSPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_RAD);
+
+ if (parsedValue)
+ valueList->next();
+ }
break;
case CSS_PROP_FILL: // <paint> | inherit
*/
#include "config.h"
+
#if ENABLE(SVG)
#include "CSSStyleSelector.h"
#include "SVGRenderStyle.h"
#include "SVGRenderStyleDefs.h"
#include "SVGStyledElement.h"
-#include <math.h>
#include <stdlib.h>
#include <wtf/MathExtras.h>
namespace WebCore {
+static float roundToNearestGlyphOrientationAngle(float angle)
+{
+ angle = fabs(fmodf(angle, 360.0f));
+
+ if (angle <= 45.0f || angle > 315.0f)
+ return 0.0f;
+ else if (angle > 45.0f && angle <= 135.0f)
+ return 90.0f;
+ else if (angle > 135.0f && angle <= 225.0f)
+ return 180.0f;
+
+ return 270.0f;
+}
+
+static int angleToGlyphOrientation(float angle)
+{
+ angle = roundToNearestGlyphOrientationAngle(angle);
+
+ if (angle == 0.0f)
+ return GO_0DEG;
+ else if (angle == 90.0f)
+ return GO_90DEG;
+ else if (angle == 180.0f)
+ return GO_180DEG;
+ else if (angle == 270.0f)
+ return GO_270DEG;
+
+ return -1;
+}
+
void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
{
CSSPrimitiveValue* primitiveValue = 0;
svgstyle->setFloodColor(col);
break;
}
- case CSS_PROP_GLYPH_ORIENTATION_VERTICAL:
case CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL:
- // support for above properties has not been implemented in the engine yet
+ {
+ HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal)
+ if (!primitiveValue)
+ return;
+
+ if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
+ int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
+ ASSERT(orientation != -1);
+
+ svgstyle->setGlyphOrientationHorizontal((EGlyphOrientation) orientation);
+ }
+
break;
+ }
+ case CSS_PROP_GLYPH_ORIENTATION_VERTICAL:
+ {
+ HANDLE_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical)
+ if (!primitiveValue)
+ return;
+
+ if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
+ int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
+ ASSERT(orientation != -1);
+
+ svgstyle->setGlyphOrientationVertical((EGlyphOrientation) orientation);
+ } else if (primitiveValue->getIdent() == CSS_VAL_AUTO)
+ svgstyle->setGlyphOrientationVertical(GO_AUTO);
+
+ break;
+ }
default:
// If you crash here, it's because you added a css property and are not handling it
// in either this switch statement or the one in CSSStyleSelector::applyProperty
no-change
reset-size
-# CSS_PROP_GLYP_ORIENTATION_HORIZONTAL
+# CSS_PROP_GLYPH_ORIENTATION_HORIZONTAL
-# CSS_PROP_GLYP_ORIENTATION_VERTICAL
+# CSS_PROP_GLYPH_ORIENTATION_VERTICAL
# CSS_PROP_KERNING
# CSS_PROP_TEXT_ANCHOR
# start
#define SVGRenderStyle_h
#if ENABLE(SVG)
-
#include "CSSValueList.h"
#include "DataRef.h"
#include "GraphicsTypes.h"
#include "SVGPaint.h"
#include "SVGRenderStyleDefs.h"
-#include <wtf/Platform.h>
-#if PLATFORM(WIN_OS)
-typedef unsigned long long uint64_t;
-#endif
+#include <wtf/Platform.h>
namespace WebCore {
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(ETextAnchor, TextAnchor, textAnchor, TA_START)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(ETextRendering, TextRendering, textRendering, TR_AUTO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EWritingMode, WritingMode, writingMode, WM_LRTB)
-
+ SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EGlyphOrientation, GlyphOrientationHorizontal, glyphOrientationHorizontal, GO_0DEG)
+ SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EGlyphOrientation, GlyphOrientationVertical, glyphOrientationVertical, GO_AUTO)
+
// SVG CSS Properties (using DataRef's)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, fill, opacity, FillOpacity, fillOpacity, 1.0f)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(SVGPaint, fill, paint, FillPaint, fillPaint, SVGPaint::defaultFill())
protected:
// inherit
struct InheritedFlags {
- // 64 bit inherited, don't add to the struct, or the operator will break.
- bool operator==(const InheritedFlags &other) const { return _iflags == other._iflags; }
- bool operator!=(const InheritedFlags &other) const { return _iflags != other._iflags; }
-
- union {
- struct {
- unsigned _colorRendering : 2; // EColorRendering
- unsigned _imageRendering : 2; // EImageRendering
- unsigned _shapeRendering : 2; // EShapeRendering
- unsigned _textRendering : 2; // ETextRendering
- unsigned _clipRule : 1; // WindRule
- unsigned _fillRule : 1; // WindRule
- unsigned _capStyle : 2; // LineCap
- unsigned _joinStyle : 2; // LineJoin
- unsigned _textAnchor : 2; // ETextAnchor
- unsigned _colorInterpolation : 2; // EColorInterpolation
- unsigned _colorInterpolationFilters : 2; // EColorInterpolation
- unsigned _pointerEvents : 4; // EPointerEvents
- unsigned _writingMode : 3; // EWritingMode
- // 5 bits unused
- } f;
- uint32_t _iflags;
- };
+ bool operator==(const InheritedFlags& other) const
+ {
+ return (_colorRendering == other._colorRendering) &&
+ (_imageRendering == other._imageRendering) &&
+ (_shapeRendering == other._shapeRendering) &&
+ (_textRendering == other._textRendering) &&
+ (_clipRule == other._clipRule) &&
+ (_fillRule == other._fillRule) &&
+ (_capStyle == other._capStyle) &&
+ (_joinStyle == other._joinStyle) &&
+ (_textAnchor == other._textAnchor) &&
+ (_colorInterpolation == other._colorInterpolation) &&
+ (_colorInterpolationFilters == other._colorInterpolationFilters) &&
+ (_pointerEvents == other._pointerEvents) &&
+ (_writingMode == other._writingMode) &&
+ (_glyphOrientationHorizontal == other._glyphOrientationHorizontal) &&
+ (_glyphOrientationVertical == other._glyphOrientationVertical);
+ }
+
+ bool operator!=(const InheritedFlags& other) const
+ {
+ return !(*this == other);
+ }
+
+ unsigned _colorRendering : 2; // EColorRendering
+ unsigned _imageRendering : 2; // EImageRendering
+ unsigned _shapeRendering : 2; // EShapeRendering
+ unsigned _textRendering : 2; // ETextRendering
+ unsigned _clipRule : 1; // WindRule
+ unsigned _fillRule : 1; // WindRule
+ unsigned _capStyle : 2; // LineCap
+ unsigned _joinStyle : 2; // LineJoin
+ unsigned _textAnchor : 2; // ETextAnchor
+ unsigned _colorInterpolation : 2; // EColorInterpolation
+ unsigned _colorInterpolationFilters : 2; // EColorInterpolation
+ unsigned _pointerEvents : 4; // EPointerEvents
+ unsigned _writingMode : 3; // EWritingMode
+ unsigned _glyphOrientationHorizontal : 3; // EGlyphOrientation
+ unsigned _glyphOrientationVertical : 3; // EGlyphOrientation
} svg_inherited_flags;
// don't inherit
struct NonInheritedFlags {
- // 64 bit non-inherited, don't add to the struct, or the operator will break.
+ // 32 bit non-inherited, don't add to the struct, or the operator will break.
bool operator==(const NonInheritedFlags &other) const { return _niflags == other._niflags; }
bool operator!=(const NonInheritedFlags &other) const { return _niflags != other._niflags; }
void setBitDefaults()
{
- svg_inherited_flags._iflags = 0;
- svg_inherited_flags.f._clipRule = initialClipRule();
- svg_inherited_flags.f._colorRendering = initialColorRendering();
- svg_inherited_flags.f._fillRule = initialFillRule();
- svg_inherited_flags.f._imageRendering = initialImageRendering();
- svg_inherited_flags.f._shapeRendering = initialShapeRendering();
- svg_inherited_flags.f._textRendering = initialTextRendering();
- svg_inherited_flags.f._textAnchor = initialTextAnchor();
- svg_inherited_flags.f._capStyle = initialCapStyle();
- svg_inherited_flags.f._joinStyle = initialJoinStyle();
- svg_inherited_flags.f._colorInterpolation = initialColorInterpolation();
- svg_inherited_flags.f._colorInterpolationFilters = initialColorInterpolationFilters();
- svg_inherited_flags.f._pointerEvents = initialPointerEvents();
- svg_inherited_flags.f._writingMode = initialWritingMode();
+ svg_inherited_flags._clipRule = initialClipRule();
+ svg_inherited_flags._colorRendering = initialColorRendering();
+ svg_inherited_flags._fillRule = initialFillRule();
+ svg_inherited_flags._imageRendering = initialImageRendering();
+ svg_inherited_flags._shapeRendering = initialShapeRendering();
+ svg_inherited_flags._textRendering = initialTextRendering();
+ svg_inherited_flags._textAnchor = initialTextAnchor();
+ svg_inherited_flags._capStyle = initialCapStyle();
+ svg_inherited_flags._joinStyle = initialJoinStyle();
+ svg_inherited_flags._colorInterpolation = initialColorInterpolation();
+ svg_inherited_flags._colorInterpolationFilters = initialColorInterpolationFilters();
+ svg_inherited_flags._pointerEvents = initialPointerEvents();
+ svg_inherited_flags._writingMode = initialWritingMode();
+ svg_inherited_flags._glyphOrientationHorizontal = initialGlyphOrientationHorizontal();
+ svg_inherited_flags._glyphOrientationVertical = initialGlyphOrientationVertical();
svg_noninherited_flags._niflags = 0;
svg_noninherited_flags.f._alignmentBaseline = initialAlignmentBaseline();
static Data initial##Type() { return Initial; }
#define SVG_RS_DEFINE_ATTRIBUTE_INHERITED(Data, Type, Name, Initial) \
- void set##Type(Data val) { svg_inherited_flags.f._##Name = val; } \
- Data Name() const { return (Data) svg_inherited_flags.f._##Name; } \
+ void set##Type(Data val) { svg_inherited_flags._##Name = val; } \
+ Data Name() const { return (Data) svg_inherited_flags._##Name; } \
static Data initial##Type() { return Initial; }
// "Helper" macros for SVG's RenderStyle properties
enum EWritingMode {
WM_LRTB, WM_LR, WM_RLTB, WM_RL, WM_TBRL, WM_TB
};
-
+
+ enum EGlyphOrientation {
+ GO_0DEG, GO_90DEG, GO_180DEG, GO_270DEG, GO_AUTO
+ };
+
enum EAlignmentBaseline {
AB_AUTO, AB_BASELINE, AB_BEFORE_EDGE, AB_TEXT_BEFORE_EDGE,
AB_MIDDLE, AB_CENTRAL, AB_AFTER_EDGE, AB_TEXT_AFTER_EDGE,