blib/lib/HTML/Object/DOM/Element/TableCell.pm untested

filter: Statementstmt 0.0% 0 / 64 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 9 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 29 Podpod 0.0% 0 / 21 totaltotal 0.0% 0 / 129 CC 4 SCAR 11.6
CC
4
Cov
0%
init
12.0
headers
6.0
BEGIN
2.0
CRAP 3.2
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Element/TableCell.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2022/01/07
7 ## Modified 2022/09/18
8 ## All rights reserved
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package HTML::Object::DOM::Element::TableCell;
15 BEGIN
16 {
17 use strict;
18 use warnings;
19 warnings::register_categories( 'HTML::Object' );
20 use parent qw( HTML::Object::DOM::Element );
21 use vars qw( $VERSION );
22 use HTML::Object::DOM::Element::Shared qw( :tablecell );
23 our $VERSION = 'v0.2.0';
24 };
25  
26 use strict;
27 use warnings;
28  
29 sub init
30 {
31 my $self = shift( @_ );
32 # Could be also <th>
33 $self->{tag} = 'td' if( !defined( $self->{tag} ) || !CORE::length( "$self->{tag}" ) );
34 $self->{_init_strict_use_sub} = 1;
35 $self->SUPER::init( @_ ) || return( $self->pass_error );
36 $self->_set_get_internal_attribute_callback( headers => sub
37 {
38 my( $this, $val ) = @_;
39 my $list;
40 return if( !( $list = $this->{_headers_list} ) );
41 # $list->debug( $self->debug );
42 $list->update( $val );
43 });
44 return( $self );
45 }
46  
47 # Note: property abbr
48 sub abbr : lvalue { return( shift->_set_get_property( 'abbr', @_ ) ); }
49  
50 # Note: deprecated property align is inherited
51  
52 # Note: deprecated property axis
53 sub axis : lvalue { return( shift->_set_get_property( 'axis', @_ ) ); }
54  
55 # Note: deprecated property bgColor
56 sub bgColor : lvalue { return( shift->_set_get_property( 'bgcolor', @_ ) ); }
57  
58 sub bgcolor : lvalue { return( shift->bgColor( @_ ) ); }
59  
60 # Note: property cellIndex read-only
61 sub cellIndex
62 {
63 my $self = shift( @_ );
64 my $parent = $self->parent || return;
65 my $siblings = $parent->children;
66 my $pos = $siblings->pos( $self );
67 return( $pos );
68 }
69  
70 # Note: deprecated property ch
71 sub ch : lvalue { return( shift->_set_get_property( 'ch', @_ ) ); }
72  
73 # Note: deprecated property chOff
74 sub chOff : lvalue { return( shift->_set_get_property( 'choff', @_ ) ); }
75  
76 sub choff : lvalue { return( shift->chOff( @_ ) ); }
77  
78 # Note: property colSpan
79 sub colSpan : lvalue { return( shift->_set_get_property( 'colspan', @_ ) ); }
80  
81 sub colspan : lvalue { return( shift->colSpan( @_ ) ); }
82  
83 # Note: property colgroup
84 sub colgroup : lvalue { return( shift->_set_get_property( 'colgroup', @_ ) ); }
85  
86 # Note: property headers read-only
87 sub headers
88 {
89 my $self = shift( @_ );
90 unless( $self->{_headers_list} )
91 {
92 my $headers = $self->attr( 'headers' );
93 require HTML::Object::TokenList;
94 $self->{_headers_list} = HTML::Object::TokenList->new( $headers, element => $self, attribute => 'headers', debug => $self->debug ) ||
95 return( $self->pass_error( HTML::Object::TokenList->error ) );
96 }
97 return( $self->{_headers_list} );
98 }
99  
100 # Note: deprecated property height is inherited
101  
102 # Note: deprecated property noWrap
103 sub noWrap : lvalue { return( shift->_set_get_property( 'nowrap', @_ ) ); }
104  
105 sub nowrap : lvalue { return( shift->noWrap( @_ ) ); }
106  
107 # Note: property rowSpan
108 sub rowSpan : lvalue { return( shift->_set_get_property( 'rowspan', @_ ) ); }
109  
110 sub rowspan : lvalue { return( shift->rowSpan( @_ ) ); }
111  
112 # Note: property scope
113 sub scope : lvalue { return( shift->_set_get_property( 'scope', @_ ) ); }
114  
115 # Note: deprecated property vAlign
116 sub vAlign : lvalue { return( shift->_set_get_property( 'valign', @_ ) ); }
117  
118 sub valign : lvalue { return( shift->vAlign( @_ ) ); }
119  
120 # Note: deprecated property width is inherited
121  
122 1;
123 # NOTE: POD
124 __END__
125  
126 =encoding utf-8
127  
128 =head1 NAME
129  
130 HTML::Object::DOM::Element::TableCell - HTML Object DOM TableCell Class
131  
132 =head1 SYNOPSIS
133  
134 use HTML::Object::DOM::Element::TableCell;
135 my $cell = HTML::Object::DOM::Element::TableCell->new( tag => 'th' ) ||
136 die( HTML::Object::DOM::Element::TableCell->error, "\n" );
137  
138 =head1 VERSION
139  
140 v0.2.0
141  
142 =head1 DESCRIPTION
143  
144 This interface provides special properties and methods (beyond the regular L<HTML::Object::DOM::Element> interface it also has available to it by inheritance) for manipulating the layout and presentation of table cells, either header (C<th>) or data cells (C<td>), in an HTML document.
145  
146 =head1 INHERITANCE
147  
148 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +---------------------------------------+
149 | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::TableCell |
150 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +---------------------------------------+
151  
152 =head1 PROPERTIES
153  
154 Inherits properties from its parent L<HTML::Object::DOM::Element>
155  
156 =head2 abbr
157  
158 A string which can be used on C<th> elements (not on C<td>), specifying an alternative label for the header cell. This alternate label can be used in other contexts, such as when describing the headers that apply to a data cell. This is used to offer a shorter term for use by screen readers in particular, and is a valuable accessibility tool. Usually the value of abbr is an abbreviation or acronym, but can be any text that's appropriate contextually.
159  
160 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/abbr>
161  
162 =head2 cellIndex
163  
164 Read-only.
165  
166 A long integer representing the cell's position in the cells collection of the C<tr> the cell is contained within. If the cell does not belong to a C<tr>, it returns C<undef> (C<-1> normally under JavaScript).
167  
168 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/cellIndex>
169  
170 =head2 colSpan
171  
172 An unsigned long integer indicating the number of columns this cell must span; this lets the cell occupy space across multiple columns of the table. It reflects the colspan HTML attribute.
173  
174 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/colSpan>
175  
176 =head2 colspan
177  
178 Alias for L</colSpan>
179  
180 =head2 headers
181  
182 Read-only.
183  
184 A L<TokenList|HTML::Object::TokenList> describing a list of id of C<th> elements that represents headers associated with the cell. It reflects the headers HTML attribute.
185  
186 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/headers>
187  
188 =head2 rowSpan
189  
190 An unsigned long integer indicating the number of rows this cell must span; this lets a cell occupy space across multiple rows of the table. It reflects the rowspan HTML attribute.
191  
192 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/rowSpan>
193  
194 =head2 rowspan
195  
196 Alias for L</rowSpan>
197  
198 =head2 scope
199  
200 A string indicating the scope of a C<th> cell. Header cells can be configured, using the scope property, the apply to a specified row or column, or to the not-yet-scoped cells within the current row group (that is, the same ancestor L<thead|HTML::Object::DOM::Element::TableSection>, L<tbody|HTML::Object::DOM::Element::TableSection>, or L<tfoot|HTML::Object::DOM::Element::TableSection> element). If no value is specified for scope, the header is not associated directly with cells in this way. Permitted values for scope are:
201  
202 Note that, under perl, those values are not enforced.
203  
204 =over 4
205  
206 =item col
207  
208 The header cell applies to the following cells in the same column (or columns, if colspan is used as well), until either the end of the column or another C<th> in the column establishes a new scope.
209  
210 =item colgroup
211  
212 The header cell applies to all cells in the current column group that do not already have a scope applied to them. This value is only allowed if the cell is in a column group.
213  
214 =item row
215  
216 The header cell applies to the following cells in the same row (or rows, if rowspan is used as well), until either the end of the row or another C<th> in the same row establishes a new scope.
217  
218 =item rowgroup
219  
220 The header cell applies to all cells in the current row group that do not already have a scope applied to them. This value is only allowed if the cell is in a row group.
221  
222 =item The empty string ("")
223  
224 The header cell has no predefined scope; the user agent will establish the scope based on contextual clues.
225  
226 =back
227  
228 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/scope>
229  
230 =head1 METHODS
231  
232 Inherits methods from its parent L<HTML::Object::DOM::Element>
233  
234 =head1 DEPRECATED PROPERTIES
235  
236 =head2 align
237  
238 A string containing an enumerated value reflecting the align attribute. It indicates the alignment of the element's contents with respect to the surrounding context. The possible values are C≤left>, C<right>, and C<center>.
239  
240 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/align>
241  
242 =head2 axis
243  
244 A string containing a name grouping cells in virtual. It reflects the obsolete axis attribute.
245  
246 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/axis>
247  
248 =head2 bgColor
249  
250 A string containing the background color of the cells. It reflects the obsolete bgcolor attribute.
251  
252 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/bgColor>
253  
254 =head2 bgcolor
255  
256 Alias for L</bgColor>
257  
258 =head2 ch
259  
260 A string containing one single chararcter. This character is the one to align all the cell of a column on. It reflects the char and default to the decimal points associated with the language, e.g. '.' for English, or ',' for French. This property was optional and was not very well supported.
261  
262 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/ch>
263  
264 =head2 chOff
265  
266 A string containing a integer indicating how many characters must be left at the right (for left-to-right scripts; or at the left for right-to-left scripts) of the character defined by L</ch>. This property was optional and was not very well supported.
267  
268 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/chOff>
269  
270 =head2 choff
271  
272 Alias for L</chOff>
273  
274 =head2 height
275  
276 A string containing a length of pixel of the hinted height of the cell. It reflects the obsolete height HTML attribute.
277  
278 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/height>
279  
280 =head2 noWrap
281  
282 A boolean value reflecting the nowrap HTML attribute and indicating if cell content can be broken in several lines.
283  
284 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/noWrap>
285  
286 =head2 nowrap
287  
288 Alias for L</noWrap>
289  
290 =head2 vAlign
291  
292 A string representing an enumerated value indicating how the content of the cell must be vertically aligned. It reflects the valign HTML attribute and can have one of the following values: C<top>, C<middle>, C<bottom>, or C<baseline>. Use the CSS vertical-align property instead.
293  
294 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/vAlign>
295  
296 =head2 valign
297  
298 Alias for L</vAlign>
299  
300 =head2 width
301  
302 A string specifying the number of pixels wide the cell should be drawn, if possible. This property reflects the also obsolete width HTML attribute. Use the CSS width property instead.
303  
304 See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement/width>
305  
306 =head1 AUTHOR
307  
308 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
309  
310 =head1 SEE ALSO
311  
312 L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement>, L<Mozilla documentation on tablecell element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tablecell>
313  
314 =head1 COPYRIGHT & LICENSE
315  
316 Copyright(c) 2022 DEGUEST Pte. Ltd.
317  
318 All rights reserved
319  
320 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
321  
322 =cut