Ejemplo n.º 1
0
 private HTMLElementImpl[] getSubFrames(HTMLElementImpl parent) {
   NodeImpl[] children = parent.getChildrenArray();
   ArrayList subFrames = new ArrayList();
   for (int i = 0; i < children.length; i++) {
     NodeImpl child = children[i];
     if (child instanceof HTMLElementImpl) {
       String nodeName = child.getNodeName();
       if ("FRAME".equalsIgnoreCase(nodeName) || "FRAMESET".equals(nodeName)) {
         subFrames.add(child);
       }
     }
   }
   return (HTMLElementImpl[]) subFrames.toArray(new HTMLElementImpl[0]);
 }
Ejemplo n.º 2
0
 public void setRootNode(NodeImpl node) {
   if (!(node instanceof HTMLElementImpl)) {
     throw new IllegalArgumentException("node=" + node);
   }
   HTMLElementImpl element = (HTMLElementImpl) node;
   HtmlRendererContext context = element.getHtmlRendererContext();
   this.htmlContext = context;
   if (context != null) {
     String rows = element.getAttribute("rows");
     String cols = element.getAttribute("cols");
     HtmlLength[] rowLengths = this.getLengths(rows);
     HtmlLength[] colLengths = this.getLengths(cols);
     this.rowHtmlLengths = rowLengths;
     this.colHtmlLengths = colLengths;
     HTMLElementImpl[] subframes = this.getSubFrames(element);
     Component[] frameComponents = new Component[subframes.length];
     this.frameComponents = frameComponents;
     for (int i = 0; i < subframes.length; i++) {
       HTMLElementImpl frameElement = subframes[i];
       if (frameElement != null && "FRAMESET".equalsIgnoreCase(frameElement.getTagName())) {
         FrameSetPanel fsp = new FrameSetPanel();
         fsp.setRootNode(frameElement);
         frameComponents[i] = fsp;
       } else {
         BrowserFrame frame = context.createBrowserFrame();
         if (frameElement != null) {
           String src = frameElement.getAttribute("src");
           if (src != null) {
             java.net.URL url;
             try {
               url = frameElement.getFullURL(src);
               if (url != null) {
                 frame.loadURL(url);
               }
             } catch (MalformedURLException mfu) {
               // ignore
             }
           }
         }
         frameComponents[i] = frame.getComponent();
       }
     }
   }
 }