Changeset 811
- Timestamp:
- 02/03/14 12:29:36 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/io/WebParser.java
r808 r811 336 336 int visibleHeight = (Integer) webEngine.executeScript("window.innerHeight"); 337 337 338 WebParser.addTextToFrame( doc,visibleWidth, visibleHeight, window, webEngine, frameToAddTo);338 WebParser.addTextToFrame(visibleWidth, visibleHeight, window, webEngine, frameToAddTo); 339 339 System.out.println("added text"); 340 340 FrameIO.SaveFrame(frameToAddTo); … … 431 431 public void run() { 432 432 try { 433 JSObject window = (JSObject) webEngine.executeScript("window"); 434 433 435 webEngine.executeScript("" 434 436 // Initializing the counter used when scrolling the page … … 443 445 + "cssHide.appendChild(document.createTextNode(style));" 444 446 + "document.getElementsByTagName('head')[0].appendChild(cssHide);"); 445 446 HTMLBodyElement doc = (HTMLBodyElement) webEngine.executeScript("document.body"); 447 448 JSObject window = (JSObject) webEngine.executeScript("window"); 449 450 frame.setBackgroundColor(rgbStringToColor((String) ((JSObject) (window.call("getComputedStyle", new Object[] { doc }))).call("getPropertyValue", 451 new Object[] { "background-color" }))); 452 447 453 448 // Functions to be used later in JavaScript 454 449 webEngine.executeScript("" … … 1144 1139 * @throws IllegalAccessException 1145 1140 */ 1146 private static void addTextToFrame( Node rootElement,int visibleWidth, int visibleHeight, JSObject window, WebEngine webEngine, Frame frame) throws InvocationTargetException,1141 private static void addTextToFrame(int visibleWidth, int visibleHeight, JSObject window, WebEngine webEngine, Frame frame) throws InvocationTargetException, 1147 1142 IllegalAccessException, IllegalArgumentException { 1148 1143 1149 Node currentNode = rootElement; 1150 1151 if (currentNode.getNodeType() == Node.TEXT_NODE) { 1152 1144 webEngine.executeScript("var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);"); 1145 1146 Node currentNode; 1147 1148 while ((currentNode = (Node) webEngine.executeScript("walker.nextNode()")) != null) { 1153 1149 JSObject style; 1154 1150 JSObject bounds; … … 1160 1156 bounds = (JSObject) ((JSObject) currentNode.getParentNode()).call("getBoundingClientRect", new Object[] {}); 1161 1157 1162 1163 // Bounding rectangle position is relative to the current view, so scroll position must be added to x/y 1164 // TODO: This doesn't check if an element or any of its parent elements have position:fixed set - the only 1165 // way to check seems to be to walking through the element's parents until the document root is reached 1158 // TODO: This doesn't check if an element or any of its parent elements have position:fixed set - the only way to check seems to be to walking through the element's parents until the document root is reached (or a recursive function) 1166 1159 float x = Float.valueOf(bounds.getMember("left").toString()); 1167 1160 float y = Float.valueOf(bounds.getMember("top").toString()); … … 1324 1317 } 1325 1318 } 1326 1327 } else if (currentNode.getNodeType() == Node.ELEMENT_NODE) {1328 Node childNode = currentNode.getFirstChild();1329 1330 while (childNode != null) {1331 addTextToFrame(childNode, visibleWidth, visibleHeight, window, webEngine, frame);1332 childNode = childNode.getNextSibling();1333 }1334 1319 } 1335 1320 }
Note:
See TracChangeset
for help on using the changeset viewer.