示例#1
0
 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);
   }
 }
示例#2
0
 /**
  * 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);
   }
 }
示例#3
0
 /**
  * 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);
   }
 }
示例#4
0
 /**
  * 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;
   }
 }
示例#5
0
 /**
  * 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();
   }
 }
示例#6
0
 /**
  * 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();
   }
 }
示例#7
0
 /**
  * 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();
   }
 }
示例#8
0
 /**
  * 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));
 }
示例#9
0
 /**
  * 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()));
   }
 }
示例#10
0
 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;
 }
示例#11
0
 @Override
 public Future<Boolean> layoutCompletion() {
   return htmlBlockPanel.layoutCompletion();
 }
示例#12
0
 private void scrollByImpl(final int xOffset, final int yOffset) {
   final HtmlBlockPanel bp = this.htmlBlockPanel;
   if (bp != null) {
     bp.scrollBy(xOffset, yOffset);
   }
 }
示例#13
0
 /**
  * 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();
 }
示例#14
0
 /**
  * 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);
   }
 }
示例#15
0
 /**
  * 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);
   }
 }