Lobo browser - problem when trying to render html - > com.steadystate.css.parser.ParseException

Nayden
2014-05-13
2015-01-25
  • Nayden
    Nayden
    2014-05-13

    Os: Windows 7
    jdk: 1.6
    lib: cobra-0.98.4/lib:
    files: cobra.jar, js.jar
    code:

    import java.awt.Dimension;
    import java.awt.EventQueue;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.logging.Level;
    import java.util.logging.Logger;

    import javax.imageio.ImageIO;

    import org.lobobrowser.html.HtmlRendererContext;
    import org.lobobrowser.html.UserAgentContext;
    import org.lobobrowser.html.gui.HtmlPanel;
    import org.lobobrowser.html.parser.DocumentBuilderImpl;
    import org.lobobrowser.html.parser.InputSourceImpl;
    import org.lobobrowser.html.test.SimpleHtmlRendererContext;
    import org.lobobrowser.html.test.SimpleUserAgentContext;
    import org.w3c.dom.Document;

    public class TestRender {

    public static void main(String[] args) throws Exception {
        Logger.getLogger("org.lobobrowser").setLevel(Level.WARNING);
    
        String uri = "https://yahoo.com";
        URL url = new URL(uri);
        URLConnection connection = url.openConnection();
    
        InputStream inStream = connection.getInputStream();
    
        Reader reader = new InputStreamReader(inStream);
    
        InputSourceImpl inSource = new InputSourceImpl(reader, uri);
    
        final HtmlPanel htmlPanel = new HtmlPanel();
        UserAgentContext usercontext = new SimpleUserAgentContext();
    
        HtmlRendererContext rendererContext = new SimpleHtmlRendererContext(htmlPanel, usercontext);
    
        htmlPanel.setPreferredWidth(600);
    
        DocumentBuilderImpl builder = new DocumentBuilderImpl(rendererContext.getUserAgentContext(), rendererContext);
        Document document = builder.parse(inSource);
        inStream.close();
    
        htmlPanel.setDocument(document, rendererContext);
    
        EventQueue.invokeLater(new Runnable() {
            public void run() {
    
                htmlPanel.doLayout();
    
                Dimension hpPreferedSize = htmlPanel.getPreferredSize();
    
                BufferedImage realImage = new BufferedImage(hpPreferedSize.width, hpPreferedSize.height, BufferedImage.TYPE_INT_RGB);
    
                Graphics2D g2d = (Graphics2D) realImage.getGraphics();
    
                htmlPanel.setBounds(0, 0, realImage.getWidth(), realImage.getHeight());
                htmlPanel.doLayout();
                htmlPanel.update(g2d);
                g2d.dispose();
                realImage = realImage.getSubimage(0, 0, realImage.getWidth() - 16, realImage.getHeight());
                try {
                    ImageIO.write(realImage, "png", new File("c:\\test.png"));
                } catch (Exception e) {
                }
                realImage = null;
            }
        });
    
    }
    

    exception:

    2014-5-13 16:32:12 com.steadystate.css.parser.SACParser styleRuleDeclarations
    INFO: styleRule()
    com.steadystate.css.parser.ParseException: Encountered "*" (kinds=[12]) at line 6, column 1906.
    Was expecting one of:
    <S> ...
    "}" ...
    ";" ...
    <IDENT> ...

    at com.steadystate.css.parser.SACParser.generateParseException(SACParser.java:2829)
    at com.steadystate.css.parser.SACParser.jj_consume_token(SACParser.java:2706)
    at com.steadystate.css.parser.SACParser.styleRuleDeclarations(SACParser.java:1327)
    at com.steadystate.css.parser.SACParser.styleRule(SACParser.java:1270)
    at com.steadystate.css.parser.SACParser.styleSheetRuleList(SACParser.java:273)
    at com.steadystate.css.parser.SACParser.styleSheet(SACParser.java:157)
    at com.steadystate.css.parser.SACParser.parseStyleSheet(SACParser.java:58)
    at com.steadystate.css.parser.CSSOMParser.parseStyleSheet(CSSOMParser.java:71)
    at org.lobobrowser.html.style.CSSUtilities.parse(CSSUtilities.java:130)
    at org.lobobrowser.html.domimpl.HTMLLinkElementImpl.processLink(HTMLLinkElementImpl.java:152)
    at org.lobobrowser.html.domimpl.HTMLLinkElementImpl.setUserData(HTMLLinkElementImpl.java:123)
    at org.lobobrowser.html.parser.HtmlParser.parseToken(HtmlParser.java:755)
    at org.lobobrowser.html.parser.HtmlParser.parseToken(HtmlParser.java:678)
    at org.lobobrowser.html.parser.HtmlParser.parseToken(HtmlParser.java:678)
    at org.lobobrowser.html.parser.HtmlParser.parse(HtmlParser.java:537)
    at org.lobobrowser.html.parser.HtmlParser.parse(HtmlParser.java:507)
    at org.lobobrowser.html.domimpl.HTMLDocumentImpl.load(HTMLDocumentImpl.java:386)
    at org.lobobrowser.html.domimpl.HTMLDocumentImpl.load(HTMLDocumentImpl.java:366)
    at org.lobobrowser.html.parser.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:98)
    at loboTest.TestRender.main(TestRender.java:50)
    

    What can I do?
    The page is not render like the it has to be.
    There is a long page, no scroll, long text, images, not formatted..

     
  • Gwen Kerdal
    Gwen Kerdal
    2014-11-15

    Hello,
    do you know when will be the new version available ?
    Regards,
    Gwen.

     
    • Eric Hocking
      Eric Hocking
      2015-01-25

      Hi there,
      The new version will be available sometime in 2015. We are working on a rewrite of the Cobra engine right now.