eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HTML::AbstractElement':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: AbstractElement (in HTML)


Inheritance:

   Object
   |
   +--HTML::AbstractElement
      |
      +--HTML::AbstractHTMLElement
      |
      +--HTML::AbstractProcessingElement
      |
      +--HTML::Embed

Package:
stx:goodies/webServer/htmlTree
Category:
Net-Documents-HTML-ModelTree
Version:
rev: 1.117 date: 2019/07/31 00:14:21
user: cg
file: HTML__AbstractElement.st directory: goodies/webServer/htmlTree
module: stx stc-classLibrary: htmlTree

Description:


common superclass for both HTML and SVG elements


Class protocol:

accessing
o  allConcreteSubclasses
Return all concrete subclasses.

usage example(s):

     self allConcreteSubclasses.

o  allElementImplementingClasses
Return all classes that implement a concrete tag

usage example(s):

     self allElementImplementingClasses

o  auloadAllSubclasses

instance creation
o  newTag: aString
Build a tag for a tag name. If the tag name is fitting to an
existing tag use this tag. If not build a generic tag holding
this new tag name.

usage example(s):

     Element newTag:'a'
     Element newTag:'span'

o  tagToClassMapping
return a mapping for all existing tag names.
The key is the tag name, the value is a
concrete element class.

** This method raises an error - it must be redefined in concrete classes **

o  with: aRawObject
Every HTML element can be created upon a collection of children or
simply on a single element to be the child(ren) of this html-element.

It is allowed to create empty html-objects with '#new' too.

o  with: anObject class: aHTMLClass
Create an element with the information from an object(See '#with:').
Set a html stylesheet class to use for this element and automatically
all included elements.

o  withNew: aOneArgBlock

queries
o  isAbstract
Return if this class is an abstract class.
Return true for this class but false for all subclasses.
To have an abstract subclass implement this method there again.

usage example(s):

     AbstractElement isAbstract.
     Table isAbstract.

required protocol
o  tagName
Return a tag name for the html object.
Each html object needs to define a tag name.


Instance protocol:

accessing
o  add: aChildOrClass
Add a new element to the children.
Use this method as interface to add children.
Do not add children directly into the children collection.

o  addElement: aChildOrClass
Add a new element to the children.
Use this method as interface to add children.
Do not add children directly into the children collection.

o  addElement: aChildOrClass at: anIndex
Add an element of type a class or a child directly.
Fill up the indices upd to an index with empty elements
of the same type.

o  addElement: aChildOrClass before: anIndex
Add an element of type a class or a child directly before anIndex. If
index greater then children size, the element will be added at the end

o  addElements: aCollection
Add new elements to the children.
Use this method as interface to add children.
Do not add children directly into the children collection.

o  addFirst: aChildOrClass
Add a new element to the children.
Use this method as interface to add children.
Do not add children directly into the children collection.

o  attributes
Return a dictionary with html-attributes
or nil if there are no attributes set.

The attributes are included in the opening tag.
An attribute is a key value pair.

o  extractedText
extract the raw text from this (and all sub-elements)

o  parent
Return the parent of this element.
Can be nil for top level elements.
On correct html a page will be the
top level item.

o  removeAllElements

o  removeElement: anElement

o  removeFirst

o  tagName
Return the tag name of this element.
Each element must define its own tag
name in class method.

o  tagName: aStringOrSymbol
Here, assert that the given tag conforms to my
class-given default tagName - i.e. fail, if there is a mismatch.

enumeration
o  allParents
Evaluate a block recursively for all parents

o  allParentsDo: aOneArgumentBlock
Evaluate a block recursively for all parents

o  allSubElementsDo: aOneArgumentBlock
Evaluate a block recursively for all children

o  subElementsDo: aOneArgumentBlock
Evaluate a block for my direct children.
Wrapper for the bad naming...

o  subelementsDo: aOneArgumentBlock
Evaluate a block for all components wrapped by this element.
Default is to evaluate this block for all children.
Subclasses may add special components to be evaluated here.
Bad name; should be named subElementsDo:

interface-attributes
o  classAttribute
Return the class attribute of the element.
Notice: an element can have multiple classes, being space-separated in the class attribute

o  classList
Return the list of classes defined in the class attribute of the element.
Notice: an element can have multiple classes, being space-separated in the class attribute

o  hasClass: className
true if className is includes in my class attribute.
Notice: an element can have multiple classes, being space-separated in the class attribute

o  id
Return the id of the element.

o  id: anID
Set the id of the element.

o  on: what script: aScript
common helper for onXXX: messages;
looks if there is already a script defined for the what-message, and concatenates the scripts,
if required

o  onChange: aScript
Set the on-change-attribute of this element.

o  onClick

o  onClick: aScript

o  onDoubleClick: aScript

o  onKeyDown: aScript

o  onKeyPress: aScript

o  onKeyUp: aScript

o  onMouseDown

o  onMouseDown: aScript

o  onMouseMove: aScript

o  onMouseOut: aScript

o  onMouseOver

o  onMouseOver: aScript

o  onMouseUp

o  onMouseUp: aScript

private-accessing
o  addChild: aChild
Add a new child to the children.

Use this method as interface to add children.
Do not add children directly into the children collection.

o  addElementOfClass: anElementOrStringOrCollection with: aClass
Add an elment. this can be a ready build elment
or a string or a collection of elements.

o  addFirstChild: aChild
Add a new child to the children.

Use this method as interface to add children.
Do not add children directly into the children collection.

o  childAt: anIndex ifAbsent: anExceptionBlock
Return the child at an index or nil if it does not exist.

o  childAt: anIndex put: aNewChildOrClass
Set a child to be at an index.

o  children
Return the children of this element.

o  getElement: aClass
Return the first element of a class that can
be found, or build a new element if none is
present.
Self children can build a children collection,
this collection will be needed anyhow to hold
the searched element if not present and build.

o  parent: anItem
Set an item to be the parent of this item.
Private - Use only to set child elements.
Do not call from other classes.

o  replaceChild: anUnlovedChild with: adoptedChild

o  setChildren: aCollectionOfElementsOrStrings
Set a collection of elements or strings
to be the children of this element.
Private - Use only for instance creation.

o  style

** This method raises an error - it must be redefined in concrete classes **

o  style: aStyle

** This method raises an error - it must be redefined in concrete classes **

private-accessing-attributes
o  addAttribute: aSymbol
Add an attribute without value

o  addStyle: aStyleElement
Add a css-style-element to the attributes.
Private interface used for accessing style methods.

o  attributeAt: aSymbol
Return the attribute at a symbol
or nil if the attribute is not set.

o  attributeAt: aSymbol add: more
Set or add an attribute value to the attribute.

o  attributeAt: aSymbol put: aValue
Set an attribute value to the attribute.
If a value is nil the attribute is removed.

o  elementAtId: anId
Return the element at an ID
or nil if the attribute is not set.

o  getAttributes
Return a dictionary to put in attributes.
Despite normal access method: '#attributes'
this method garanties to deliver a
dictionary for the attributes.

Call only if you want to set attributes.
Do not call for checking for attributes.
Use method: '#attributes' for this instead.

o  removeAttribute: aSymbol
Remove a symbol from the attribute list
and check if we need the attributes dictionary
any more after removing.

private-building
o  buildElement: aNewChildOrClass
Take the item or instantiate the class.

o  buildElement: aRawData ofType: aClass
Build a new element created from raw data.
Raw data can be either a ready built subelement of the
fitting class, or it can be a simple string that will be
wrapped by a new element of the given class. Or it can be nil
to construct an empty element of the given class.

o  buildElement: rawData ofType: aClass onCollectionDo: aTwoArgumentBLock
Build a new element created from raw data.
Raw data can be either a ready built subelement of the
fitting class, or it can be a simple string that will be
wrapped by a new element of the given class. Or it can be nil
to construct an empty element of the given class. It is
also possible to give a collection of subelements the
added element shall consist of, then a block is executed
for each of these subelements to construct it properly
into the element.

See method: '#addRow' in class Table for usage.

queries
o  canHaveChild: anotherElement
return true, if anotherElement is allowed as my child

** This method raises an error - it must be redefined in concrete classes **

o  canHaveChild: anotherElement in: aParser
return true, if anotherElement is allowed as my child

o  canHaveText
return true, if I allow text as child (i.f. PCDATA)

o  hasChildren
summary:
This may look to you like a terrible idea. You may be also be right.
However, there is a reason for it. There are cases in the HTML tree where
children are not in the children instance variable. For example, In <Head>
there is a child that is not in the collecion children called title.

This makes:

children size ~= 0

not work. So you may rightly argue that we should define hasChildren in each subclass
that has children that are not in the instance variable children. Then we have two methods
that define what an element's children are (a possible reciepe for disaster). So
with this in mind, the following implementation was born.

o  isVoidElement
A void element is an element whose content model
never allows it to have contents under any circumstances.
Void elements can have attributes.

o  mustBeClosed
return true, if I need a closing tag (as opposed to br or img, which do not)

required-visiting
o  acceptHTMLVisitor: aVisitor
Visit this element.
To be implemented by each element(subclass).

** This method raises an error - it must be redefined in concrete classes **

testing
o  isAnchor

o  isArea

o  isBlockElement

o  isBody

o  isBold

o  isButton

o  isCaption

o  isCenter

o  isCode

o  isColgroup

o  isComment

o  isDefinitionDescription

o  isDefinitionList

o  isDefinitionTerm

o  isDiv

o  isDummyContainer

o  isForm

o  isFormWidgetElement

o  isFrame

o  isHTMLDocument

o  isHead

o  isHeading

o  isHeading1

o  isHorizontalRule

o  isImg

o  isInput

o  isLabel

o  isLink

o  isListItem

o  isMeta

o  isNoBr

o  isOption

o  isOrderedList

o  isParagraph

o  isPre

o  isProcessingInstruction

o  isScript

o  isSelect

o  isSpan

o  isStrong

o  isStyle

o  isTable

o  isTableBody

o  isTableCell

o  isTableDataCell

o  isTableFoot

o  isTableHead

o  isTableHeaderCell

o  isTableRow

o  isTextArea

o  isTitle

o  isUnorderedList



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 11 Aug 2022 10:54:30 GMT