Class RBlock

java.lang.Object
org.lobobrowser.html.renderer.RBlock
All Implemented Interfaces:
ImageObserver, UINode, BoundableRenderable, RCollection, RElement, Renderable, RenderableContainer

public class RBlock extends Object implements RenderableContainer, ImageObserver
Represents a HTML block in a rendered document, typically a DIV. The root renderer node is of this type as well.

Immediately below an RBlock you will find a node of type RBlockViewport.

  • Field Details

    • logger

      protected static final Logger logger
    • frameContext

      protected final FrameContext frameContext
    • listNesting

      protected final int listNesting
    • rendererContext

      protected final HtmlRendererContext rendererContext
    • bodyLayout

      protected final RBlockViewport bodyLayout
    • cachedLayout

      protected final Map cachedLayout
    • startSelection

      protected RenderableSpot startSelection
    • endSelection

      protected RenderableSpot endSelection
    • vScrollBar

      protected JScrollBar vScrollBar
    • hScrollBar

      protected JScrollBar hScrollBar
    • hasHScrollBar

      protected boolean hasHScrollBar
    • hasVScrollBar

      protected boolean hasVScrollBar
    • defaultOverflowX

      protected int defaultOverflowX
    • defaultOverflowY

      protected int defaultOverflowY
    • INVALID_SIZE

      protected static final Integer INVALID_SIZE
    • delayedPairs

      protected Collection delayedPairs
      A list of absolute positioned or float parent-child pairs.
    • backgroundColor

      protected Color backgroundColor
      Background color which may be different to that from RenderState in the case of a Document node.
    • backgroundImage

      protected volatile Image backgroundImage
    • zIndex

      protected int zIndex
    • borderTopColor

      protected Color borderTopColor
    • borderLeftColor

      protected Color borderLeftColor
    • borderBottomColor

      protected Color borderBottomColor
    • borderRightColor

      protected Color borderRightColor
    • borderInsets

      protected Insets borderInsets
    • marginInsets

      protected Insets marginInsets
    • paddingInsets

      protected Insets paddingInsets
    • borderInfo

      protected BorderInfo borderInfo
    • lastBackgroundImageUri

      protected URL lastBackgroundImageUri
    • defaultMarginInsets

      protected Insets defaultMarginInsets
    • defaultPaddingInsets

      protected Insets defaultPaddingInsets
    • overflowX

      protected int overflowX
    • overflowY

      protected int overflowY
    • userAgentContext

      protected final UserAgentContext userAgentContext
    • layoutDeepCanBeInvalidated

      protected boolean layoutDeepCanBeInvalidated
    • SCROLL_BAR_THICKNESS

      protected static final int SCROLL_BAR_THICKNESS
      See Also:
    • SELECTION_COLOR

      protected static final Color SELECTION_COLOR
    • SELECTION_XOR

      protected static final Color SELECTION_XOR
    • container

      protected final RenderableContainer container
    • modelNode

      protected final ModelNode modelNode
    • x

      public int x
    • y

      public int y
    • width

      public int width
    • height

      public int height
    • layoutUpTreeCanBeInvalidated

      protected boolean layoutUpTreeCanBeInvalidated
      Starts as true because ancestors could be invalidated.
    • parent

      protected RCollection parent
      Parent for graphics coordinates.
    • originalParent

      protected RCollection originalParent
      Parent for invalidation.
  • Constructor Details

  • Method Details

    • getVScrollBarWidth

      public int getVScrollBarWidth()
      Gets the width the vertical scrollbar has when shown.
    • finalize

      public void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • getVAlign

      public int getVAlign()
      Description copied from interface: RElement
      Vertical alignment for elements rendered in a line. Returns one of the constants defined in this class.
      Specified by:
      getVAlign in interface RElement
    • ensureVisible

      public void ensureVisible(Point point)
    • isOverflowVisibleX

      public final boolean isOverflowVisibleX()
    • isOverflowVisibleY

      public final boolean isOverflowVisibleY()
    • getFirstLineHeight

      public int getFirstLineHeight()
    • getFirstBaselineOffset

      public int getFirstBaselineOffset()
    • setSelectionEnd

      public void setSelectionEnd(RenderableSpot rpoint)
    • setSelectionStart

      public void setSelectionStart(RenderableSpot rpoint)
    • getViewportListNesting

      public int getViewportListNesting(int blockNesting)
    • paint

      public void paint(Graphics g)
      All overriders should call super implementation.
      Specified by:
      paint in interface Renderable
    • layout

      public final void layout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly)
    • layout

      public final void layout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, boolean sizeOnly)
    • layout

      public final void layout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly)
    • doLayout

      public final void doLayout(int availWidth, int availHeight, boolean sizeOnly)
    • doLayout

      public void doLayout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly)
      Lays out and sets dimensions only if RBlock is invalid (or never before layed out), if the parameters passed differ from the last layout, or if the current font differs from the font for the last layout.
      Parameters:
      availWidth -
      availHeight -
    • paintSelection

      public boolean paintSelection(Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)
      Description copied from interface: BoundableRenderable
      Asks the Renderable to paint the selection between two points. Nothing will be done if the points are outside the Renderable.
      Specified by:
      paintSelection in interface BoundableRenderable
      Returns:
      True iff it's in selection when finished painting.
    • getLowestRenderableSpot

      public RenderableSpot getLowestRenderableSpot(int x, int y)
      Specified by:
      getLowestRenderableSpot in interface BoundableRenderable
    • invalidateLayoutLocal

      public void invalidateLayoutLocal()
      RBlocks should only be invalidated if one of their properties change, or if a descendent changes, or if a style property of an ancestor is such that it could produce layout changes in this RBlock.
    • clearStyle

      protected void clearStyle(boolean isRootBlock)
    • onMouseClick

      public boolean onMouseClick(MouseEvent event, int x, int y)
      Specified by:
      onMouseClick in interface BoundableRenderable
    • onDoubleClick

      public boolean onDoubleClick(MouseEvent event, int x, int y)
      Specified by:
      onDoubleClick in interface BoundableRenderable
    • onMouseDisarmed

      public boolean onMouseDisarmed(MouseEvent event)
      Specified by:
      onMouseDisarmed in interface BoundableRenderable
    • onMousePressed

      public boolean onMousePressed(MouseEvent event, int x, int y)
      Description copied from interface: BoundableRenderable
      Returns false if the event is consumed. True to propagate further.
      Specified by:
      onMousePressed in interface BoundableRenderable
    • onMouseReleased

      public boolean onMouseReleased(MouseEvent event, int x, int y)
      Specified by:
      onMouseReleased in interface BoundableRenderable
    • getPaintedBackgroundColor

      public Color getPaintedBackgroundColor()
      Specified by:
      getPaintedBackgroundColor in interface RenderableContainer
    • getRenderables

      public Iterator getRenderables()
      Description copied from interface: RCollection
      Gets the collection of Renderable children.
      Specified by:
      getRenderables in interface RCollection
    • repaint

      public void repaint(ModelNode modelNode)
      Description copied from interface: UINode
      Called
      Specified by:
      repaint in interface UINode
    • updateWidgetBounds

      public void updateWidgetBounds(int guiX, int guiY)
      Updates bounds of all descendent's GUI components, based on root bounds.
      Specified by:
      updateWidgetBounds in interface RCollection
    • scrollHorizontalTo

      public void scrollHorizontalTo(int newX)
    • scrollVerticalTo

      public void scrollVerticalTo(int newY)
    • scrollByUnits

      public void scrollByUnits(int orientation, int units)
    • scrollBy

      public void scrollBy(int orientation, int offset)
    • scrollTo

      public void scrollTo(Rectangle bounds, boolean xIfNeeded, boolean yIfNeeded)
      Scrolls the viewport's origin to the given location, or as close to it as possible.

      This method should be invoked in the GUI thread.

      Parameters:
      bounds - The bounds of the scrollable area that should become visible.
      xIfNeeded - If this parameter is true the x coordinate is changed only if the horizontal bounds are not currently visible.
      yIfNeeded - If this parameter is true the y coordinate is changed only if the vertical bounds are not currently visible.
    • getRBlockViewport

      public RBlockViewport getRBlockViewport()
    • extractSelectionText

      public boolean extractSelectionText(StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)
      Specified by:
      extractSelectionText in interface BoundableRenderable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getExportableFloatingInfo

      public FloatingInfo getExportableFloatingInfo()
    • getDefaultOverflowX

      public int getDefaultOverflowX()
    • getDefaultOverflowY

      public int getDefaultOverflowY()
    • setDefaultOverflowX

      public void setDefaultOverflowX(int defaultOverflowX)
    • setDefaultOverflowY

      public void setDefaultOverflowY(int defaultOverflowY)
    • setDefaultPaddingInsets

      public void setDefaultPaddingInsets(Insets insets)
    • setDefaultMarginInsets

      public void setDefaultMarginInsets(Insets insets)
    • getAlignmentX

      public float getAlignmentX()
    • getAlignmentY

      public float getAlignmentY()
    • invalidateLayoutDeep

      public final void invalidateLayoutDeep()
      Invalidates this Renderable and all descendents. This is only used in special cases, such as when a new style sheet is added.
      Specified by:
      invalidateLayoutDeep in interface RCollection
    • getDeclaredWidth

      protected Integer getDeclaredWidth(RenderState renderState, int actualAvailWidth)
    • hasDeclaredWidth

      public final boolean hasDeclaredWidth()
    • getDeclaredHeight

      protected Integer getDeclaredHeight(RenderState renderState, int actualAvailHeight)
    • getDeclaredHeightImpl

      protected int getDeclaredHeightImpl(RenderState renderState, int availHeight)
    • layout

      public final void layout(int availWidth, int availHeight, boolean sizeOnly)
      Lays out children, and deals with "valid" state. Override doLayout method instead of this one.
      Specified by:
      layout in interface RElement
      Parameters:
      availWidth - The available width from the parent's canvas.
      availHeight - The available height from the parent's canvas.
      sizeOnly - Whether the layout is for sizing determination only.
    • sendGUIComponentsToParent

      protected final void sendGUIComponentsToParent()
    • clearGUIComponents

      protected final void clearGUIComponents()
    • addComponent

      public Component addComponent(Component component)
      Specified by:
      addComponent in interface RenderableContainer
    • updateAllWidgetBounds

      public void updateAllWidgetBounds()
      Specified by:
      updateAllWidgetBounds in interface RenderableContainer
    • updateWidgetBounds

      public void updateWidgetBounds()
      Updates widget bounds below this node only. Should not be called during general rendering.
    • getBoundsRelativeToBlock

      public Rectangle getBoundsRelativeToBlock()
      Specified by:
      getBoundsRelativeToBlock in interface UINode
    • applyStyle

      protected void applyStyle(int availWidth, int availHeight)
    • loadBackgroundImage

      protected void loadBackgroundImage(URL imageURL)
    • getZIndex

      public int getZIndex()
      Specified by:
      getZIndex in interface BoundableRenderable
    • prePaint

      protected void prePaint(Graphics g)
    • imageUpdate

      public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
      Specified by:
      imageUpdate in interface ImageObserver
    • getInsets

      public Insets getInsets(boolean hscroll, boolean vscroll)
      Gets insets of content area. It includes margin, borders and scrollbars, but not padding.
    • sendDelayedPairsToParent

      protected final void sendDelayedPairsToParent()
    • clearDelayedPairs

      public final void clearDelayedPairs()
      Specified by:
      clearDelayedPairs in interface RenderableContainer
    • getDelayedPairs

      public final Collection getDelayedPairs()
      Specified by:
      getDelayedPairs in interface RenderableContainer
    • addDelayedPair

      public void addDelayedPair(DelayedPair pair)
      Specified by:
      addDelayedPair in interface RenderableContainer
    • getParentContainer

      public RenderableContainer getParentContainer()
      Specified by:
      getParentContainer in interface RenderableContainer
    • isContainedByNode

      public boolean isContainedByNode()
      Description copied from interface: BoundableRenderable
      Returns true if the renderable is fully contained by its modelNode, but said modelNode does not fully contain an ancestor renderable.
      Specified by:
      isContainedByNode in interface BoundableRenderable
    • getCollapsibleMarginBottom

      public int getCollapsibleMarginBottom()
      Specified by:
      getCollapsibleMarginBottom in interface RElement
    • isMarginBoundary

      protected boolean isMarginBoundary()
    • getCollapsibleMarginTop

      public int getCollapsibleMarginTop()
      Specified by:
      getCollapsibleMarginTop in interface RElement
    • getMarginBottom

      public int getMarginBottom()
      Specified by:
      getMarginBottom in interface RElement
    • getMarginLeft

      public int getMarginLeft()
      Specified by:
      getMarginLeft in interface RElement
    • getMarginRight

      public int getMarginRight()
      Specified by:
      getMarginRight in interface RElement
    • getMarginTop

      public int getMarginTop()
      Specified by:
      getMarginTop in interface RElement
    • focus

      public void focus()
      Specified by:
      focus in interface RCollection
    • blur

      public void blur()
      Specified by:
      blur in interface RCollection
    • onMouseMoved

      public void onMouseMoved(MouseEvent event, int x, int y, boolean triggerEvent, ModelNode limit)
      Specified by:
      onMouseMoved in interface BoundableRenderable
    • onMouseOut

      public void onMouseOut(MouseEvent event, int x, int y, ModelNode limit)
      Specified by:
      onMouseOut in interface BoundableRenderable
    • getRenderable

      public BoundableRenderable getRenderable(int x, int y)
    • onRightClick

      public boolean onRightClick(MouseEvent event, int x, int y)
      Specified by:
      onRightClick in interface BoundableRenderable
    • markLayoutValid

      public void markLayoutValid()
    • getGUIPoint

      public Point getGUIPoint(int clientX, int clientY)
      Specified by:
      getGUIPoint in interface BoundableRenderable
    • getRenderablePoint

      public Point getRenderablePoint(int guiX, int guiY)
      Specified by:
      getRenderablePoint in interface BoundableRenderable
    • getHeight

      public int getHeight()
      Specified by:
      getHeight in interface BoundableRenderable
    • getWidth

      public int getWidth()
      Specified by:
      getWidth in interface BoundableRenderable
    • setWidth

      public void setWidth(int width)
      Specified by:
      setWidth in interface BoundableRenderable
    • getX

      public int getX()
      Specified by:
      getX in interface BoundableRenderable
    • getY

      public int getY()
      Specified by:
      getY in interface BoundableRenderable
    • contains

      public boolean contains(int x, int y)
    • getBounds

      public Rectangle getBounds()
      Specified by:
      getBounds in interface BoundableRenderable
    • getSize

      public Dimension getSize()
      Specified by:
      getSize in interface BoundableRenderable
    • getModelNode

      public ModelNode getModelNode()
      Specified by:
      getModelNode in interface BoundableRenderable
      Specified by:
      getModelNode in interface Renderable
    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Specified by:
      setBounds in interface BoundableRenderable
    • setX

      public void setX(int x)
      Specified by:
      setX in interface BoundableRenderable
    • setY

      public void setY(int y)
      Specified by:
      setY in interface BoundableRenderable
    • setHeight

      public void setHeight(int height)
      Specified by:
      setHeight in interface BoundableRenderable
    • setOrigin

      public void setOrigin(int x, int y)
      Specified by:
      setOrigin in interface BoundableRenderable
    • invalidateLayoutUpTree

      public final void invalidateLayoutUpTree()
      Invalidates this Renderable and its parent (i.e. all ancestors).
      Specified by:
      invalidateLayoutUpTree in interface BoundableRenderable
    • isValid

      protected boolean isValid()
    • relayout

      public void relayout()
      Invalidates the current Renderable (which invalidates its ancestors) and then requests the top level GUI container to do the layout and repaint. It's safe to call this method outside the GUI thread.
      Specified by:
      relayout in interface BoundableRenderable
    • relayoutIfValid

      public void relayoutIfValid()
    • setParent

      public void setParent(RCollection parent)
      Specified by:
      setParent in interface BoundableRenderable
    • getParent

      public RCollection getParent()
      Description copied from interface: BoundableRenderable
      Gets the parent where the renderable is rendered.
      Specified by:
      getParent in interface BoundableRenderable
    • setOriginalParent

      public void setOriginalParent(RCollection origParent)
      Specified by:
      setOriginalParent in interface BoundableRenderable
    • getOriginalParent

      public RCollection getOriginalParent()
      This is the parent based on the original element hierarchy.
      Specified by:
      getOriginalParent in interface BoundableRenderable
    • getOriginalOrCurrentParent

      public RCollection getOriginalOrCurrentParent()
      Description copied from interface: BoundableRenderable
      Specified by:
      getOriginalOrCurrentParent in interface BoundableRenderable
    • repaint

      public void repaint(int x, int y, int width, int height)
      Specified by:
      repaint in interface BoundableRenderable
    • repaint

      public void repaint()
      Specified by:
      repaint in interface BoundableRenderable
    • getBlockBackgroundColor

      public Color getBlockBackgroundColor()
    • paintTranslated

      public final void paintTranslated(Graphics g)
      Description copied from interface: BoundableRenderable
      Paints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.
      Specified by:
      paintTranslated in interface BoundableRenderable
      Parameters:
      g - Parent's Graphics context.
    • translateDescendentPoint

      protected final Point translateDescendentPoint(BoundableRenderable descendent, int x, int y)
    • getOrigin

      public Point getOrigin()
      Specified by:
      getOrigin in interface BoundableRenderable
    • getOriginRelativeTo

      public Point getOriginRelativeTo(RCollection ancestor)
      Specified by:
      getOriginRelativeTo in interface BoundableRenderable
    • getOrdinal

      public int getOrdinal()
    • setOrdinal

      public void setOrdinal(int ordinal)