Package com.volantis.styling.engine

Examples of com.volantis.styling.engine.StylingEngine


    public void testPrecedingSiblingSelector() {
        String css =
                "a {color: blue}\n" +
                "b ~ * {color: yellow}";

        StylingEngine engine = createStylingEngine(css);
        Attributes attributes = createAttributes();

        {
            // <a>
            engine.startElement(NS, "a", attributes);
            assertStylesEqual(StylesBuilder.getSparseStyles(
                    "color: blue"),
                    engine);

            {
                // <b>
                engine.startElement(NS, "b", attributes);
                assertStylesEqual(StylesBuilder.getSparseStyles(
                        "color: blue"),
                        engine);

                // </b>
                engine.endElement(NS, "b");


                // <c>
                engine.startElement(NS, "c", attributes);
                assertStylesEqual(StylesBuilder.getSparseStyles(
                        "color: yellow"),
                        engine);

                // </c>
                engine.endElement(NS, "c");

                // <c>
                engine.startElement(NS, "c", attributes);
                assertStylesEqual(StylesBuilder.getSparseStyles(
                        "color: yellow"),
                        engine);

                // </c>
                engine.endElement(NS, "c");
            }

            // </a>
            engine.endElement(NS, "a");
        }

    }
View Full Code Here


    public void testImmediatePrecedingSiblingSelector() {
        String css =
                "a {color: blue}\n" +
                "b + * {color: yellow}";

        StylingEngine engine = createStylingEngine(css);
        Attributes attributes = createAttributes();

        {
            // <a>
            engine.startElement(NS, "a", attributes);
            assertStylesEqual(StylesBuilder.getSparseStyles(
                    "color: blue"),
                    engine);

            {
                // <b>
                engine.startElement(NS, "b", attributes);
                assertStylesEqual(StylesBuilder.getSparseStyles(
                        "color: blue"),
                        engine);

                // </b>
                engine.endElement(NS, "b");


                // <c>
                engine.startElement(NS, "c", attributes);
                assertStylesEqual(StylesBuilder.getSparseStyles(
                        "color: yellow"),
                        engine);

                // </c>
                engine.endElement(NS, "c");

                // <c>
                engine.startElement(NS, "c", attributes);
                assertStylesEqual(StylesBuilder.getSparseStyles(
                        "color: blue"),
                        engine);

                // </c>
                engine.endElement(NS, "c");
            }

            // </a>
            engine.endElement(NS, "a");
        }
    }
View Full Code Here

        String css = "body {mcs-container: foo('xyz')}" +
                "div {mcs-container: foo('abc')}";
        StringReader reader = new StringReader(css);

        StylingEngine engine = createStylingEngine(reader,
                                                   functionResolverMock);

        final EvaluationContext context = engine.getEvaluationContext();

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        expectations.add(new OrderedExpectations() {
            public void add() {

                attributesMock.expects.getAttributeValue(
                        null, "class").returns(null);

                stylingFunctionMock.expects
                        .evaluate(context, "foo",
                                  Arrays.asList(new Object[]{
                                      XYZ_STRING
                                  }))
                        .returns(ABC_STRING);

                attributesMock.expects.getAttributeValue(
                        null, "class").returns(null);

                stylingFunctionMock.expects
                        .evaluate(context, "foo",
                                  Arrays.asList(new Object[]{
                                      ABC_STRING
                                  }))
                        .returns(XYZ_STRING);
            }
        });

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        StyleValue value;

        engine.startElement(NS, "body", attributesMock);
        value = getContainerValue(engine, StylePropertyDetails.MCS_CONTAINER);
        assertEquals(ABC_STRING, value);

        {
            engine.startElement(NS, "div", attributesMock);

            value = getContainerValue(engine, StylePropertyDetails.MCS_CONTAINER);
            assertEquals(XYZ_STRING, value);

            engine.endElement(NS, "div");
        }

        engine.endElement(NS, "body");
    }
View Full Code Here

        // =====================================================================

        String css = "body {content: foo('abc') 'abc' foo('abc')}";
        StringReader reader = new StringReader(css);

        StylingEngine engine = createStylingEngine(reader,
                                                   functionResolverMock);

        final EvaluationContext context = engine.getEvaluationContext();

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        expectations.add(new OrderedExpectations() {
            public void add() {

                attributesMock.expects.getAttributeValue(
                        null, "class").returns(null);

                stylingFunctionMock.expects
                        .evaluate(context, "foo",
                                  Arrays.asList(new Object[]{
                                      ABC_STRING
                                  }))
                        .returns(XYZ_STRING);

                stylingFunctionMock.expects
                        .evaluate(context, "foo",
                                  Arrays.asList(new Object[]{
                                      ABC_STRING
                                  }))
                        .returns(XYZ_STRING);
            }
        });

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        StyleValue value;

        StyleList expected = STYLE_VALUE_FACTORY.getList(Arrays.asList(
                new Object[]{
                    XYZ_STRING,
                    ABC_STRING,
                    XYZ_STRING
                }));

        engine.startElement(NS, "body", attributesMock);
        value = getContainerValue(engine, StylePropertyDetails.CONTENT);
        assertEquals(expected, value);

        engine.endElement(NS, "body");
    }
View Full Code Here

                stylingFactory.createStyleSheetCompiler(configuration);

        CompiledStyleSheet compiledStyleSheet =
                compiler.compileStyleSheet(styleSheet);

        StylingEngine engine = stylingFactory.createStylingEngine();

        engine.pushStyleSheet(compiledStyleSheet);
        return engine;
    }
View Full Code Here

        protocol.setMarinerPageContext(pageContextMock);

        requestContextMock.expects.
            getMarinerPageContext().returns(pageContextMock).any();

        final StylingEngine stylingEngine = getStylingEngine();

        final PaneInstanceMock paneInstance = getPaneInstance();

        pageContextMock.expects.enteringXDIMECPElement().any();
        pageContextMock.expects.insideXDIMECPElement().returns(false).any();
View Full Code Here

        } catch (IOException e) {
            throw new ExtendedRuntimeException(e);
        }

        StylingFactory stylingFactory = StylingFactory.getDefaultInstance();
        StylingEngine stylingEngine =
                stylingFactory.createStylingEngine(
                        new InlineStyleSheetCompilerFactory(
                                StylingFunctions.getResolver()));
        stylingEngine.pushStyleSheet(defaultCompiledStyleSheet);

        DocumentStyler styler = new DocumentStyler(stylingEngine,
                XDIMESchemata.CDM_NAMESPACE);
        styler.style(document);
View Full Code Here

            StylingFactory stylingFactory) {

        this.pageContext = pageContext;
        this.fragmentLinkWriter = fragmentLinkWriter;

        StylingEngine engine = stylingFactory.createStylingEngine();
        formatStylingEngine = new FormatStylingEngineImpl(engine);
    }
View Full Code Here

        StyleSheetCompiler compiler = stylingFactory.createStyleSheetCompiler(
                configuration);
        CompiledStyleSheet compiledStyleSheet = compiler.compileStyleSheet(
                styleSheet);

        StylingEngine stylingEngine = stylingFactory.createStylingEngine();

        stylingEngine.pushStyleSheet(compiledStyleSheet);

        FormatStylingEngine formatStylingEngine =
                new FormatStylingEngineImpl(stylingEngine);
        return formatStylingEngine;
    }
View Full Code Here

                  public String getHeader(String name) {
                      return null//To change body of implemented methods use File | Settings | File Templates.
                  }
            });

        StylingEngine stylingEngine = context.getStylingEngine();

        assertSame("Styling engine", stylingEngineMock, stylingEngine);
    }
View Full Code Here

TOP

Related Classes of com.volantis.styling.engine.StylingEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.