Package org.lobobrowser.html.renderer
Class RBlockViewport
java.lang.Object
org.lobobrowser.html.renderer.RBlockViewport
- All Implemented Interfaces:
BoundableRenderable
,RCollection
,Renderable
A substantial portion of the HTML rendering logic of the package can
be found in this class.
This class is in charge of laying out the DOM subtree of a node,
usually on behalf of an RBlock.
It creates a renderer subtree consisting of RLine's or RBlock's. RLine's in
turn contain RWord's and so on.
This class also happens to be used as an RBlock scrollable viewport.
- Author:
- J. H. S.
-
Field Summary
FieldsModifier and TypeFieldDescriptionint
protected boolean
Starts as true because ancestors could be invalidated.protected final ModelNode
protected RCollection
Parent for invalidation.protected RCollection
Parent for graphics coordinates.protected static final Color
protected static final Color
int
int
int
static final Insets
Fields inherited from interface org.lobobrowser.html.renderer.Renderable
EMPTY_ARRAY
-
Constructor Summary
ConstructorsConstructorDescriptionRBlockViewport
(ModelNode modelNode, RenderableContainer container, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RCollection parent) Constructs an HtmlBlockLayout. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Applies any horizonal aLignment.void
Applies vertical alignment.void
blur()
boolean
contains
(int x, int y) boolean
extractSelectionText
(StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) void
focus()
int
int
int
getGUIPoint
(int clientX, int clientY) int
getLowestRenderableSpot
(int x, int y) int
ReturnsBoundableRenderable.getOriginalParent()
if not null.This is the parent based on the original element hierarchy.getOriginRelativeTo
(RCollection ancestor) Gets the parent where the renderable is rendered.getRenderable
(int x, int y) getRenderable
(Point point) getRenderablePoint
(int guiX, int guiY) Gets the collection ofRenderable
children.getRenderables
(int pointx, int pointy) getRenderables
(Point point) getRenderables
(Rectangle clipBounds) getSize()
int
getWidth()
int
getX()
int
getY()
int
void
Invalidates layout in all descendents.void
final void
Invalidates this Renderable and its parent (i.e.boolean
Returns true if the renderable is fully contained by its modelNode, but said modelNode does not fully contain an ancestor renderable.protected boolean
isValid()
void
layout
(int desiredWidth, int desiredHeight, Insets paddingInsets, int yLimit, org.lobobrowser.html.renderer.FloatingBounds floatBounds, boolean sizeOnly) Builds the layout/renderer tree from scratch.void
boolean
onDoubleClick
(MouseEvent event, int x, int y) boolean
onMouseClick
(MouseEvent event, int x, int y) boolean
onMouseDisarmed
(MouseEvent event) void
onMouseMoved
(MouseEvent event, int x, int y, boolean triggerEvent, ModelNode limit) void
onMouseOut
(MouseEvent event, int x, int y, ModelNode limit) boolean
onMousePressed
(MouseEvent event, int x, int y) Returns false if the event is consumed.boolean
onMouseReleased
(MouseEvent event, int x, int y) boolean
onRightClick
(MouseEvent event, int x, int y) void
boolean
paintSelection
(Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) Asks the Renderable to paint the selection between two points.final void
Paints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.void
relayout()
Invalidates the current Renderable (which invalidates its ancestors) and then requests the top level GUI container to do the layout and repaint.void
void
repaint()
void
repaint
(int x, int y, int width, int height) void
setBounds
(int x, int y, int width, int height) void
setHeight
(int height) void
setOrdinal
(int ordinal) void
setOrigin
(int x, int y) void
setOriginalParent
(RCollection origParent) void
setParent
(RCollection parent) void
setWidth
(int width) void
setX
(int x) void
setY
(int y) toString()
protected final Point
translateDescendentPoint
(BoundableRenderable descendent, int x, int y) void
updateWidgetBounds
(int guiX, int guiY) Updates bounds of all descendent's GUI components, based on root bounds.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.lobobrowser.html.renderer.BoundableRenderable
getBounds, getGUIPoint, getHeight, getModelNode, getOrdinal, getOrigin, getOriginalOrCurrentParent, getOriginalParent, getOriginRelativeTo, getParent, getRenderablePoint, getSize, getWidth, getX, getY, getZIndex, invalidateLayoutUpTree, paintTranslated, relayout, repaint, repaint, setBounds, setHeight, setOrdinal, setOrigin, setOriginalParent, setParent, setWidth, setX, setY
-
Field Details
-
ZERO_INSETS
-
SELECTION_COLOR
-
SELECTION_XOR
-
modelNode
-
x
public int x -
y
public int y -
width
public int width -
height
public int height -
layoutUpTreeCanBeInvalidated
protected boolean layoutUpTreeCanBeInvalidatedStarts as true because ancestors could be invalidated. -
parent
Parent for graphics coordinates. -
originalParent
Parent for invalidation.
-
-
Constructor Details
-
RBlockViewport
public RBlockViewport(ModelNode modelNode, RenderableContainer container, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RCollection parent) Constructs an HtmlBlockLayout.- Parameters:
container
- This is usually going to be an RBlock.listNesting
- The nesting level for lists. This is zero except inside a list.pcontext
- The HTMLParserContext instance.frameContext
- This is usually going to be HtmlBlock, an object where text selections are contained.parent
- This is usually going to be the parent ofcontainer
.
-
-
Method Details
-
invalidateLayoutLocal
public void invalidateLayoutLocal() -
getAvailContentWidth
public int getAvailContentWidth() -
layout
public void layout(int desiredWidth, int desiredHeight, Insets paddingInsets, int yLimit, org.lobobrowser.html.renderer.FloatingBounds floatBounds, boolean sizeOnly) Builds the layout/renderer tree from scratch. Note: Returned dimension needs to be actual size needed for rendered content, not the available container size. This is relied upon by table layout.- Parameters:
yLimit
- If other than -1,layout
will throwSizeExceededException
in the event that the layout goes beyond this y-coordinate point.
-
alignX
Applies any horizonal aLignment. It may adjust height if necessary.- Parameters:
canvasWidth
- The new width of the viewport. It could be different to the previously calculated width.paddingInsets
-
-
alignY
Applies vertical alignment.- Parameters:
canvasHeight
-paddingInsets
-
-
getRenderablesArray
-
getRenderables
Description copied from interface:RCollection
Gets the collection ofRenderable
children. -
getRenderables
-
getRenderable
-
getRenderable
-
getRenderables
-
getRenderables
-
getFirstLineHeight
public int getFirstLineHeight() -
getFirstBaselineOffset
public int getFirstBaselineOffset() -
getLowestRenderableSpot
-
onMouseClick
-
onDoubleClick
-
onMouseDisarmed
-
onMousePressed
Description copied from interface:BoundableRenderable
Returns false if the event is consumed. True to propagate further. -
onMouseReleased
-
paint
-
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. -
toString
-
getExportableFloatingInfo
-
focus
public void focus()- Specified by:
focus
in interfaceRCollection
-
blur
public void blur()- Specified by:
blur
in interfaceRCollection
-
updateWidgetBounds
public void updateWidgetBounds(int guiX, int guiY) Updates bounds of all descendent's GUI components, based on root bounds.- Specified by:
updateWidgetBounds
in interfaceRCollection
-
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 interfaceBoundableRenderable
- Returns:
- True iff it's in selection when finished painting.
-
extractSelectionText
public boolean extractSelectionText(StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) - Specified by:
extractSelectionText
in interfaceBoundableRenderable
-
invalidateLayoutDeep
public void invalidateLayoutDeep()Description copied from interface:RCollection
Invalidates layout in all descendents.- Specified by:
invalidateLayoutDeep
in interfaceRCollection
-
onMouseMoved
- Specified by:
onMouseMoved
in interfaceBoundableRenderable
-
onMouseOut
- Specified by:
onMouseOut
in interfaceBoundableRenderable
-
onRightClick
- Specified by:
onRightClick
in interfaceBoundableRenderable
-
markLayoutValid
public void markLayoutValid() -
getGUIPoint
- Specified by:
getGUIPoint
in interfaceBoundableRenderable
-
getRenderablePoint
- Specified by:
getRenderablePoint
in interfaceBoundableRenderable
-
getHeight
public int getHeight()- Specified by:
getHeight
in interfaceBoundableRenderable
-
getWidth
public int getWidth()- Specified by:
getWidth
in interfaceBoundableRenderable
-
setWidth
public void setWidth(int width) - Specified by:
setWidth
in interfaceBoundableRenderable
-
getX
public int getX()- Specified by:
getX
in interfaceBoundableRenderable
-
getY
public int getY()- Specified by:
getY
in interfaceBoundableRenderable
-
contains
public boolean contains(int x, int y) -
getBounds
- Specified by:
getBounds
in interfaceBoundableRenderable
-
getSize
- Specified by:
getSize
in interfaceBoundableRenderable
-
getModelNode
- Specified by:
getModelNode
in interfaceBoundableRenderable
- Specified by:
getModelNode
in interfaceRenderable
-
setBounds
public void setBounds(int x, int y, int width, int height) - Specified by:
setBounds
in interfaceBoundableRenderable
-
setX
public void setX(int x) - Specified by:
setX
in interfaceBoundableRenderable
-
setY
public void setY(int y) - Specified by:
setY
in interfaceBoundableRenderable
-
setHeight
public void setHeight(int height) - Specified by:
setHeight
in interfaceBoundableRenderable
-
setOrigin
public void setOrigin(int x, int y) - Specified by:
setOrigin
in interfaceBoundableRenderable
-
invalidateLayoutUpTree
public final void invalidateLayoutUpTree()Invalidates this Renderable and its parent (i.e. all ancestors).- Specified by:
invalidateLayoutUpTree
in interfaceBoundableRenderable
-
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 interfaceBoundableRenderable
-
relayoutIfValid
public void relayoutIfValid() -
setParent
- Specified by:
setParent
in interfaceBoundableRenderable
-
getParent
Description copied from interface:BoundableRenderable
Gets the parent where the renderable is rendered.- Specified by:
getParent
in interfaceBoundableRenderable
-
setOriginalParent
- Specified by:
setOriginalParent
in interfaceBoundableRenderable
-
getOriginalParent
This is the parent based on the original element hierarchy.- Specified by:
getOriginalParent
in interfaceBoundableRenderable
-
getOriginalOrCurrentParent
Description copied from interface:BoundableRenderable
ReturnsBoundableRenderable.getOriginalParent()
if not null. Otherwise it returnsBoundableRenderable.getParent()
.- Specified by:
getOriginalOrCurrentParent
in interfaceBoundableRenderable
-
repaint
public void repaint(int x, int y, int width, int height) - Specified by:
repaint
in interfaceBoundableRenderable
-
repaint
public void repaint()- Specified by:
repaint
in interfaceBoundableRenderable
-
getBlockBackgroundColor
-
paintTranslated
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 interfaceBoundableRenderable
- Parameters:
g
- Parent's Graphics context.
-
translateDescendentPoint
-
getOrigin
- Specified by:
getOrigin
in interfaceBoundableRenderable
-
getOriginRelativeTo
- Specified by:
getOriginRelativeTo
in interfaceBoundableRenderable
-
getOrdinal
public int getOrdinal() -
getZIndex
public int getZIndex() -
setOrdinal
public void setOrdinal(int ordinal)
-