private void processNotifications() { // This is called in the GUI thread. final ArrayList<DocumentNotification> notifs = this.notifications; DocumentNotification[] notifsArray; synchronized (notifs) { final int size = notifs.size(); if (size == 0) { return; } notifsArray = new DocumentNotification[size]; notifsArray = notifs.toArray(notifsArray); notifs.clear(); } final int length = notifsArray.length; for (int i = 0; i < length; i++) { final DocumentNotification dn = notifsArray[i]; if ((dn.node instanceof HTMLFrameSetElement) && (this.htmlBlockPanel != null)) { if (this.resetIfFrameSet()) { // Revalidation already taken care of. return; } } } final HtmlBlockPanel blockPanel = this.htmlBlockPanel; if (blockPanel != null) { blockPanel.processDocumentNotifications(notifsArray); } final FrameSetPanel frameSetPanel = this.frameSetPanel; if (frameSetPanel != null) { frameSetPanel.processDocumentNotifications(notifsArray); } }
/** * Sets a preferred width that serves as a hint in calculating the preferred size of the <code> * HtmlPanel</code>. Note that the preferred size can only be calculated when a document is * available, and it will vary during incremental rendering. * * <p>This method currently does not have any effect when the document is a FRAMESET. * * <p>Note also that setting the preferred width (to a value other than <code>-1</code>) will * negatively impact performance. * * @param width The preferred width, or <code>-1</code> to unset. */ public void setPreferredWidth(final int width) { this.preferredWidth = width; final HtmlBlockPanel htmlBlock = this.htmlBlockPanel; if (htmlBlock != null) { htmlBlock.setPreferredWidth(width); } }
/** * Sets the default vertical overflow. * * <p>This method has no effect on FRAMESETs. * * @param overflow See {@link org.lobobrowser.html.style.RenderState}. */ public void setDefaultOverflowY(final int overflow) { this.defaultOverflowY = overflow; final HtmlBlockPanel block = this.htmlBlockPanel; if (block != null) { block.setDefaultOverflowY(overflow); } }
/** * Copies the current selection, if any, into the clipboard. This method has no effect in * FRAMESETs at the moment. */ public boolean copy() { final HtmlBlockPanel block = this.htmlBlockPanel; if (block != null) { return block.copy(); } else { return false; } }
/** * Returns true only if the current block has a selection. This method has no effect in FRAMESETs * at the moment. */ public boolean hasSelection() { final HtmlBlockPanel block = this.htmlBlockPanel; if (block == null) { return false; } else { return block.hasSelection(); } }
/** * Gets a DOM node enclosing the selection. The node returned should be the inner-most node that * encloses both selection start and end points. Note that the selection end point may be just * outside of the selection. * * <p>Note: This method should be invoked in the GUI thread. * * @return A node enclosing the current selection, or <code>null</code> if there is no such node. * It also returns <code>null</code> for FRAMESETs. */ public org.w3c.dom.Node getSelectionNode() { final HtmlBlockPanel block = this.htmlBlockPanel; if (block == null) { return null; } else { return block.getSelectionNode(); } }
/** * Gets the selection text. * * <p>Note: This method should be invoked in the GUI thread. */ public String getSelectionText() { final HtmlBlockPanel block = this.htmlBlockPanel; if (block == null) { return null; } else { return block.getSelectionText(); } }
/** * Internal method used to reset the selection so that it is empty at the given point. This is * what is called when the user clicks on a point in the document. * * <p>Note: This method should be invoked in the GUI thread. */ public void resetSelection(final RenderableSpot rpoint) { final HtmlBlockPanel block = this.htmlBlockPanel; if (block != null) { block.setSelectionStart(rpoint); block.setSelectionEnd(rpoint); block.repaint(); } this.selectionDispatch.fireEvent(new SelectionChangeEvent(this, false)); }
/** * Internal method used to expand the selection to the given point. * * <p>Note: This method should be invoked in the GUI thread. */ public void expandSelection(final RenderableSpot rpoint) { final HtmlBlockPanel block = this.htmlBlockPanel; if (block != null) { block.setSelectionEnd(rpoint); block.repaint(); this.selectionDispatch.fireEvent( new SelectionChangeEvent(this, block.isSelectionAvailable())); } }
private void setUpAsBlock(final UserAgentContext ucontext, final HtmlRendererContext rcontext) { final HtmlBlockPanel shp = this.createHtmlBlockPanel(ucontext, rcontext); shp.setPreferredWidth(this.preferredWidth); shp.setDefaultOverflowX(this.defaultOverflowX); shp.setDefaultOverflowY(this.defaultOverflowY); this.htmlBlockPanel = shp; this.frameSetPanel = null; this.removeAll(); this.add(shp); this.nodeRenderer = shp; }
@Override public Future<Boolean> layoutCompletion() { return htmlBlockPanel.layoutCompletion(); }
private void scrollByImpl(final int xOffset, final int yOffset) { final HtmlBlockPanel bp = this.htmlBlockPanel; if (bp != null) { bp.scrollBy(xOffset, yOffset); } }
/** * Gets the root <code>Renderable</code> of the HTML block. It returns <code>null</code> for * FRAMESETs. */ public BoundableRenderable getBlockRenderable() { final HtmlBlockPanel htmlBlock = this.htmlBlockPanel; return htmlBlock == null ? null : htmlBlock.getRootRenderable(); }
/** * Scrolls the body area to the node given, if it is part of the current document. * * <p>This method should be called from the GUI thread. * * @param node A DOM node. */ public void scrollTo(final org.w3c.dom.Node node) { final HtmlBlockPanel htmlBlock = this.htmlBlockPanel; if (htmlBlock != null) { htmlBlock.scrollTo(node); } }
/** * If the current document is not a FRAMESET, this method scrolls the body area to the given * location. * * <p>This method should be called from the GUI thread. * * @param bounds The bounds in the scrollable block area that should become visible. * @param xIfNeeded If this parameter is true, scrolling will only occur if the requested bounds * are not currently visible horizontally. * @param yIfNeeded If this parameter is true, scrolling will only occur if the requested bounds * are not currently visible vertically. */ public void scrollTo(final Rectangle bounds, final boolean xIfNeeded, final boolean yIfNeeded) { final HtmlBlockPanel htmlBlock = this.htmlBlockPanel; if (htmlBlock != null) { htmlBlock.scrollTo(bounds, xIfNeeded, yIfNeeded); } }