Package org.xhtmlrenderer.swt
Class SWTReplacedElementFactory
java.lang.Object
org.xhtmlrenderer.swt.SWTReplacedElementFactory
- All Implemented Interfaces:
ReplacedElementFactory
- Direct Known Subclasses:
SWTXhtmlReplacedElementFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<Element, ReplacedElement> Cache of image components (ReplacedElements) for quick lookup, keyed by Element. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clean()
Dispose missing image if created.createReplacedElement
(LayoutContext c, BlockBox box, UserAgentCallback uac, int cssWidth, int cssHeight) NOTE: Only block equivalent elements can be replaced.protected ReplacedElement
Retrieves a ReplacedElement for an image from cache, or null if not found.void
Removes any reference toElement
e
.protected ReplacedElement
replaceImage
(UserAgentCallback uac, LayoutContext context, Element elem, int cssWidth, int cssHeight) Handles replacement of image elements in the document.void
reset()
Instructs theReplacedElementFactory
to discard any cached data (typically because a new page is about to be loaded).void
Identifies the FSL which will be used for callbacks when a form submit action is executed; you can use aDefaultFormSubmissionListener
if you don't want any action to be taken.protected void
Adds a ReplacedElement containing an image to a cache of images for quick lookup.
-
Field Details
-
_imageComponents
Cache of image components (ReplacedElements) for quick lookup, keyed by Element.
-
-
Constructor Details
-
SWTReplacedElementFactory
public SWTReplacedElementFactory()
-
-
Method Details
-
clean
public void clean()Dispose missing image if created. -
createReplacedElement
public ReplacedElement createReplacedElement(LayoutContext c, BlockBox box, UserAgentCallback uac, int cssWidth, int cssHeight) Description copied from interface:ReplacedElementFactory
NOTE: Only block equivalent elements can be replaced.- Specified by:
createReplacedElement
in interfaceReplacedElementFactory
- Parameters:
cssWidth
- The CSS width of the element in dots (or-1
if width isauto
)cssHeight
- The CSS height of the element in dots (or-1
if the height should be treated asauto
)- Returns:
- The
ReplacedElement
ornull
if noReplacedElement
applies
-
replaceImage
protected ReplacedElement replaceImage(UserAgentCallback uac, LayoutContext context, Element elem, int cssWidth, int cssHeight) Handles replacement of image elements in the document. May return the same ReplacedElement for a given image on multiple calls. Image will be automatically scaled to cssWidth and cssHeight assuming these are non-zero positive values. The element is assumed to have a src attribute (e.g. it's a <img> element)- Parameters:
uac
- Used to retrieve images on demand from some source.elem
- The element with the image referencecssWidth
- Target width of the imagecssHeight
- Target height of the image- Returns:
- A ReplacedElement for the image; will not be null.
-
storeImageReplacedElement
Adds a ReplacedElement containing an image to a cache of images for quick lookup.- Parameters:
e
- The element under which the image is keyed.cc
- The replaced element containing the image, or another ReplacedElement to be used in its place (like a placeholder if the image can't be loaded).
-
lookupImageReplacedElement
Retrieves a ReplacedElement for an image from cache, or null if not found.- Parameters:
e
- The element by which the image is keyed- Returns:
- The ReplacedElement for the image, or null if there is none.
-
remove
Description copied from interface:ReplacedElementFactory
Removes any reference toElement
e
.- Specified by:
remove
in interfaceReplacedElementFactory
-
setFormSubmissionListener
Description copied from interface:ReplacedElementFactory
Identifies the FSL which will be used for callbacks when a form submit action is executed; you can use aDefaultFormSubmissionListener
if you don't want any action to be taken.- Specified by:
setFormSubmissionListener
in interfaceReplacedElementFactory
- Parameters:
listener
- the listener instance to receive callbacks on form submission.
-
reset
public void reset()Description copied from interface:ReplacedElementFactory
Instructs theReplacedElementFactory
to discard any cached data (typically because a new page is about to be loaded).- Specified by:
reset
in interfaceReplacedElementFactory
-