1 package org.lobobrowser.html.domimpl; 2 3 import org.lobobrowser.html.*; 4 import org.lobobrowser.html.js.Window; 5 import org.w3c.dom.Document ; 6 import org.w3c.dom.html2.HTMLIFrameElement; 7 8 public class HTMLIFrameElementImpl extends HTMLAbstractUIElement implements 9 HTMLIFrameElement, FrameNode { 10 private volatile BrowserFrame browserFrame; 11 12 public HTMLIFrameElementImpl(String name) { 13 super(name); 14 } 15 16 public void setBrowserFrame(BrowserFrame frame) { 17 this.browserFrame = frame; 18 if(frame != null) { 19 String src = this.getAttribute("src"); 20 if(src != null) { 21 try { 22 frame.loadURL(this.getFullURL(src)); 23 } catch(java.net.MalformedURLException mfu) { 24 this.warn("setBrowserFrame(): Unable to navigate to src.", mfu); 25 } 26 } 27 } 28 } 29 30 public BrowserFrame getBrowserFrame() { 31 return this.browserFrame; 32 } 33 34 public String getAlign() { 35 return this.getAttribute("align"); 36 } 37 38 public Document getContentDocument() { 39 BrowserFrame frame = this.browserFrame; 41 if(frame == null) { 42 return null; 44 } 45 return frame.getContentDocument(); 46 } 47 48 public Window getContentWindow() { 49 BrowserFrame frame = this.browserFrame; 50 if(frame == null) { 51 return null; 53 } 54 return Window.getWindow(frame.getHtmlRendererContext()); 55 } 56 57 public String getFrameBorder() { 58 return this.getAttribute("frameborder"); 59 } 60 61 public String getHeight() { 62 return this.getAttribute("height"); 63 } 64 65 public String getLongDesc() { 66 return this.getAttribute("longdesc"); 67 } 68 69 public String getMarginHeight() { 70 return this.getAttribute("marginheight"); 71 } 72 73 public String getMarginWidth() { 74 return this.getAttribute("marginwidth"); 75 } 76 77 public String getName() { 78 return this.getAttribute("name"); 79 } 80 81 public String getScrolling() { 82 return this.getAttribute("scrolling"); 83 } 84 85 public String getSrc() { 86 return this.getAttribute("src"); 87 } 88 89 public String getWidth() { 90 return this.getAttribute("width"); 91 } 92 93 public void setAlign(String align) { 94 this.setAttribute("align", align); 95 } 96 97 public void setFrameBorder(String frameBorder) { 98 this.setAttribute("frameborder", frameBorder); 99 } 100 101 public void setHeight(String height) { 102 this.setAttribute("height", height); 103 } 104 105 public void setLongDesc(String longDesc) { 106 this.setAttribute("longdesc", longDesc); 107 } 108 109 public void setMarginHeight(String marginHeight) { 110 this.setAttribute("marginHeight", marginHeight); 111 } 112 113 public void setMarginWidth(String marginWidth) { 114 this.setAttribute("marginWidth", marginWidth); 115 } 116 117 public void setName(String name) { 118 this.setAttribute("name", name); 119 } 120 121 public void setScrolling(String scrolling) { 122 this.setAttribute("scrolling", scrolling); 123 } 124 125 public void setSrc(String src) { 126 this.setAttribute("src", src); 127 } 128 129 public void setWidth(String width) { 130 this.setAttribute("width", width); 131 } 132 133 protected void assignAttributeField(String normalName, String value) { 134 if("src".equals(normalName)) { 135 BrowserFrame frame = this.browserFrame; 136 if(frame != null) { 137 try { 138 frame.loadURL(this.getFullURL(value)); 139 } catch(java.net.MalformedURLException mfu) { 140 this.warn("assignAttributeField(): Unable to navigate to src.", mfu); 141 } 142 } 143 } 144 else { 145 super.assignAttributeField(normalName, value); 146 } 147 } 148 } 149 | Popular Tags |