| 1 | package POE::XUL::Node; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # $Id: Node.pm 1566 2010-11-03 03:13:32Z fil $ | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright Philip Gwyn 2007-2010. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Based on code Copyright 2003-2004 Ran Eilam. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 21 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 21 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 21 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 21 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 21 | ▶ | use POE::XUL::Constants; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 21 | ▶ | use POE::XUL::TextNode; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 21 | ▶ | use POE::XUL::CDATA; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 21 | ▶ | use POE::XUL::Style; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 21 | ▶ | use POE::XUL::Window; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 21 | ▶ | use Storable qw( dclone ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 21 | ▶ | use HTML::Entities qw( encode_entities_numeric ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 21 | ▶ | use constant DEBUG => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 21 | our $VERSION = '0.0600'; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 21 | our $CM; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 21 | my $ID = 0; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 21 | my @XUL_ELEMENTS = qw( | |||||||||||||||||||||||||||||||||||||||||
| 28 | ArrowScrollBox Box Button Caption CheckBox ColorPicker Column Columns | ||||||||||||||||||||||||||||||||||||||||||
| 29 | Deck Description Grid Grippy GroupBox HBox Image Label ListBox | ||||||||||||||||||||||||||||||||||||||||||
| 30 | ListCell ListCol ListCols ListHead ListHeader ListItem Menu MenuBar | ||||||||||||||||||||||||||||||||||||||||||
| 31 | MenuItem MenuList MenuPopup MenuSeparator ProgressMeter Radio | ||||||||||||||||||||||||||||||||||||||||||
| 32 | RadioGroup Row Rows ScrollBar Seperator Spacer Splitter Stack StatusBar | ||||||||||||||||||||||||||||||||||||||||||
| 33 | StatusBarPanel Tab TabBox TabPanel TabPanels Tabs TextBox ToolBar | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ToolBarButton ToolBarSeperator ToolBox VBox Window | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | Tree TreeChildren TreeItem TreeRow TreeCols TreeCol TreeCell | ||||||||||||||||||||||||||||||||||||||||||
| 37 | TreeSeparator Template Rule | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # my %XUL_ELEMENTS = map { $_ => 1 } @XUL_ELEMENTS; | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 21 | my @HTML_ELEMENTS = qw( | |||||||||||||||||||||||||||||||||||||||||
| 43 | HTML_Pre HTML_H1 HTML_H2 HTML_H3 HTML_H4 HTML_A HTML_Div HTML_Br HTML_Span | ||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | my @DEFAULT_LABEL = | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 21 | my %DEFAULT_ATTRIBUTE = map { $_ => 'label' } qw( | |||||||||||||||||||||||||||||||||||||||||
| 49 | caption button menuitem radio listitem | ||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 21 | my @OTHER_ELEMENTS = qw( | |||||||||||||||||||||||||||||||||||||||||
| 54 | Script Boot RawCmd pxInstructions | ||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 21 | my %LOGICAL_ATTS = ( | |||||||||||||||||||||||||||||||||||||||||
| 58 | selected => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | disabled => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | autoFill => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | autocheck => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | editable => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # checked => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | # creating -------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 69 | sub import | ||||||||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 22 | ▶ | my( $package ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 22 | my $caller = caller(); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 21 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | # export factory methods for each xul element type | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 22 | foreach my $sub ( @XUL_ELEMENTS, @HTML_ELEMENTS ) { | |||||||||||||||||||||||||||||||||||||||||
| 76 | 1584 | my $tag = lc $sub; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 1584 | $tag =~ s/^html_/html:/; | |||||||||||||||||||||||||||||||||||||||||
| 78 | # delete ${"${caller}::$other"}; | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 1584 | *{"${caller}::$sub"} = sub | |||||||||||||||||||||||||||||||||||||||||
| 80 | 1584 | ▶ | { return scalar $package->new(tag => $tag, @_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 22 | foreach my $other (@OTHER_ELEMENTS) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | # delete ${"${caller}::$other"} | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 88 | *{"${caller}::$other"} = sub | |||||||||||||||||||||||||||||||||||||||||
| 85 | 88 | ▶ | { return scalar $package->can("$other")->( $package, @_ ) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # export the xul element constants | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 22 | foreach my $constant_name (@POE::XUL::Node::Constants::EXPORT) { | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | *{"${$caller}::$constant_name"} = *{"$constant_name"} | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 95 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 87 | ▶ | my ($class, @params) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 87 | my $self; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 87 | ▶ | if( ($params[0]||'') eq 'tag' and lc($params[1]||'') eq 'window' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition71%5/7
($params[0] || "") eq "tag" and lc($params[1] || "") eq "window"
$params[0] || ''
$params[1] || ''
MC/DC0%0/2
($params[0] || "") eq "tag" and lc($params[1] || "") eq "window"
$params[0]
$params[1]
Truth table33%1/3
A and B
A= $params[0]B= $params[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 8 | $self = bless {attributes => {}, children => [], events => {}}, | |||||||||||||||||||||||||||||||||||||||||
| 102 | 'POE::XUL::Window'; | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 79 | $self = bless {attributes => {}, children => [], events => {}}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 87 | my $id; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 87 | ( $id, @params ) = $self->__find_id( @params ); | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 87 | $id = $self->__auto_id( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 111 | 87 | ▶ | $CM->before_creation( $self ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 87 | if( DEBUG and not $CM and $INC{'POE/XUL/ChangeManager.pm'} ) { | |||||||||||||||||||||||||||||||||||||||||
| 114 | Carp::cluck "Building a POE::XUL::Node, but no ChangeManager avaiable"; | ||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 87 | ▶ | while (my $param = shift @params) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 216 | ▶ | if( ref $param ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 46 | $self->appendChild( $param ); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | ▶ | elsif( $param =~ /\s/ or 0==@params ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$param =~ /\s/ or 0 == @params
MC/DC100%2/2
$param =~ /\s/ or 0 == @params
$param =~ /\s/
0 == @params
Truth table100%3/3
A or B
A= $param =~ /\s/B= 0 == @params
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 27 | $self->defaultChild( $param ); | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | elsif ($param eq 'textNode' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 6 | $self->appendChild( shift @params ); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | elsif ($param =~ /^[a-z]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 131 | $self->setAttribute( $param => shift @params ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | elsif ($param =~ /^[A-Z]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | $self->attach($param => shift @params ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | croak "unrecognized param: [$param]" | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 87 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 142 | # Scan ->new()'s parameters, trying to pull out an ID | ||||||||||||||||||||||||||||||||||||||||||
| 143 | sub __find_id | ||||||||||||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 87 | ▶ | my( $self, @params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__find_id: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 87 | my( $id, @out ); | |||||||||||||||||||||||||||||||||||||||||
| 147 | 87 | ▶ | while (my $param = shift @params) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 234 | ▶ | if( ref $param or $param =~ /\s/ or 0==@params ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
ref $param or $param =~ /\s/ or 0 == @params
ref $param or $param =~ /\s/
MC/DC100%3/3
ref $param or $param =~ /\s/ or 0 == @params
ref $param
$param =~ /\s/
0 == @params
Truth table100%4/4
A or B or C
A= ref $paramB= $param =~ /\s/C= 0 == @params
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 73 | push @out, $param; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 161 | ▶ | if( $param eq 'id' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 18 | $id = shift @params; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 18 | next; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 143 | push @out, $param, shift @params; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 87 | return ( $id, @out ); | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 163 | sub Script { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Script: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | # warn "class=$class"; | ||||||||||||||||||||||||||||||||||||||||||
| 166 | # warn "script=", join "\n", @_; | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | my $cdata = POE::XUL::CDATA->new( join "\n", @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | return $class->new( tag=>'script', type=>'text/javascript', $cdata ); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # Boot message | ||||||||||||||||||||||||||||||||||||||||||
| 173 | sub Boot | ||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my( $class, $msg ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Boot: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if( $CM ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $CM->Boot( $msg ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $server = $POE::XUL::Application::server; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if( $server ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $server->Boot( $msg ); | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 187 | # Send a raw command to Runner.js | ||||||||||||||||||||||||||||||||||||||||||
| 188 | sub RawCmd | ||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | my( $class, $cmd ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RawCmd: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if( $CM ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $CM->Prepend( $cmd ); | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 198 | # Instructions to Runner.js, via ChangeManager | ||||||||||||||||||||||||||||||||||||||||||
| 199 | sub pxInstructions | ||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | ▶ | my( $self, @inst ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pxInstructions: called CC=4 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | ▶ | unless( $CM ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | unless( $INC{ 'Test/More.pm' } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | # carp "There is no ChangeManager. Instructions ignored."; | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 6 | my $rv; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 6 | foreach my $inst ( @inst ) { | |||||||||||||||||||||||||||||||||||||||||
| 211 | 9 | $rv = $CM->instruction( $inst ); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | return $rv; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 218 | ## Assign an ID as soon as possible, so that the CM and State | ||||||||||||||||||||||||||||||||||||||||||
| 219 | ## will see it | ||||||||||||||||||||||||||||||||||||||||||
| 220 | sub __auto_id | ||||||||||||||||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 87 | ▶ | my( $self, $id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__auto_id: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 87 | ▶ | unless( $id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 69 | $id = "PXN$ID"; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 69 | $ID++; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 69 | $self->{default_id} = $id; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 87 | $self->{attributes}{id} = $id; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 87 | return $id; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 233 | sub build_text_node | ||||||||||||||||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 24 | ▶ | my( $self, $text ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_text_node: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 24 | my $textnode = POE::XUL::TextNode->new; | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 24 | $textnode->nodeValue( $text ); | |||||||||||||||||||||||||||||||||||||||||
| 239 | 24 | return $textnode; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 21 | *createTextNode = \&build_text_node; | |||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 245 | sub textNode | ||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 3 | ▶ | my( $self, $text ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
textNode: called CC=9 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | # Find the last text node | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | my $old; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 3 | foreach my $C ( $self->children ) { | |||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | next unless $C->isa( 'POE::XUL::TextNode' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | $old = $C; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | ▶ | unless( 2==@_ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | return unless $old; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return $old->nodeValue; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | ▶ | if( $old and ref $text ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$old and ref $text
MC/DC50%1/2
$old and ref $text
$old
ref $text
Truth table66%2/3
A and B
A= $oldB= ref $text
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | $self->replaceChild( $text, $old ); | |||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | ▶ | return $text->nodeValue if blessed $text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | elsif( $old ) { | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | return $old->nodeValue( $text ); | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return $self->appendChild( $text )->nodeValue; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 276 | sub getItemAtIndex | ||||||||||||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 4 | ▶ | my( $self, $index ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getItemAtIndex: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 4 | ▶ | return if not defined $index or $index < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $index or $index < 0
MC/DC50%1/2
not defined $index or $index < 0
not defined $index
$index < 0
Truth table66%2/3
not(A) or B
A= not defined $indexB= $index < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | ▶ | if( $self->tag eq 'menulist' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $self = $self->firstChild; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 3 | my $N = 0; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 3 | foreach my $I ( $self->children ) { | |||||||||||||||||||||||||||||||||||||||||
| 287 | 13 | my $t = $I->tag; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 13 | ▶ | next unless $t eq 'listitem' or $t eq 'menuitem'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$t eq "listitem" or $t eq "menuitem"
MC/DC50%1/2
$t eq "listitem" or $t eq "menuitem"
$t eq "listitem"
$t eq "menuitem"
Truth table66%2/3
A or B
A= $t eq "listitem"B= $t eq "menuitem"
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 7 | ▶ | return $I if $N == $index; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | $N++; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 21 | *get_item = \&getItemAtIndex; | |||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | # attribute-like method invocation -------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 297 | sub mk_method | ||||||||||||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 126 | ▶ | my( $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_method: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | return sub { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | return unless $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | $CM->after_method_call( $self, $name, [@_] ); | |||||||||||||||||||||||||||||||||||||||||
| 304 | 126 | }; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 21 | *scrollTo = mk_method( 'scrollTo' ); | |||||||||||||||||||||||||||||||||||||||||
| 307 | 21 | *scrollBy = mk_method( 'scrollBy' ); | |||||||||||||||||||||||||||||||||||||||||
| 308 | 21 | *scrollToLine = mk_method( 'scrollToLine' ); | |||||||||||||||||||||||||||||||||||||||||
| 309 | 21 | *scrollByLine = mk_method( 'scrollByLine' ); | |||||||||||||||||||||||||||||||||||||||||
| 310 | 21 | *scrollByPage = mk_method( 'scrollByPage' ); | |||||||||||||||||||||||||||||||||||||||||
| 311 | 21 | *scrollByIndex = mk_method( 'scrollByIndex' ); | |||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | # attribute handling ---------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 317 | sub attributes | ||||||||||||||||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 22 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 22 | my $ret = dclone $self->{attributes}; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 22 | ▶ | return %$ret if wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 326 | sub get_attribute | ||||||||||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 169 | ▶ | my( $self, $key ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_attribute: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 169 | ▶ | if( $LOGICAL_ATTS{ $key } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 6 | ▶ | return unless $self->{attributes}{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | # 'false' is still true, in Perl | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | ▶ | return if $self->{attributes}{$key} eq 'false'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 166 | ▶ | return $self->style if $key eq 'style'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 166 | return $self->{attributes}{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 21 | *getAttribute = \&get_attribute; | |||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 342 | sub set_attribute | ||||||||||||||||||||||||||||||||||||||||||
| 343 | { | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 157 | ▶ | my( $self, $key, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_attribute: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 157 | ▶ | return $self->style( $value ) if $key eq 'style'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 153 | ▶ | if( $key eq 'tag' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 85 | $value = lc $value; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 85 | $value =~ s/^html_/html:/; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 85 | $value =~ s/^xul://; | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 153 | ▶ | if( $LOGICAL_ATTS{ $key } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 11 | ▶ | if( ! $value or $value eq 'false' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $value or $value eq "false"
MC/DC100%2/2
not $value or $value eq "false"
not $value
$value eq "false"
Truth table100%3/3
not(A) or B
A= not $valueB= $value eq "false"
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 3 | $self->remove_attribute( $key ); | |||||||||||||||||||||||||||||||||||||||||
| 355 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 356 | # remove_attribute() informs the CM, we don't have to | ||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | # 2008-09 : the following is a tad silly... | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 8 | ▶ | $value = $value ? 'true' : 'false'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 150 | if( DEBUG and $key eq 'id' ) { | |||||||||||||||||||||||||||||||||||||||||
| 363 | carp $self->id, ".$key=$value"; | ||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 150 | ▶ | if( $key eq 'value' ) { # and $self->tag eq 'menulist' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | # Carp::cluck( $self->tag . ".value=$value" ); | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 150 | $self->{attributes}{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 150 | ▶ | $CM->after_set_attribute( $self, $key, $value ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 150 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 21 | *setAttribute = \&set_attribute; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 377 | sub remove_attribute | ||||||||||||||||||||||||||||||||||||||||||
| 378 | { | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 7 | ▶ | my( $self, $key ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_attribute: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | # if( $key eq 'value' and $self->tag eq 'menulist' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 381 | # Carp::cluck( $self->tag . ".removeAttribute('value')" ); | ||||||||||||||||||||||||||||||||||||||||||
| 382 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 7 | ▶ | croak "You may not remove the tag attribute" if $key eq 'tag'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 7 | ▶ | $CM->after_remove_attribute( $self, $key ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 7 | delete $self->{attributes}{ $key }; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 21 | *removeAttribute = \&remove_attribute; | |||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 31 | ▶ | sub is_window { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_window: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 21 | *id = __mk_accessor( 'id' ); | |||||||||||||||||||||||||||||||||||||||||
| 394 | 21 | *tagName = __mk_accessor( 'tag' ); | |||||||||||||||||||||||||||||||||||||||||
| 395 | #*textNode = __mk_accessor( 'textNode' ); | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | sub __mk_accessor | ||||||||||||||||||||||||||||||||||||||||||
| 398 | { | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 42 | ▶ | my( $tag ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__mk_accessor: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | return sub { | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 28 | ▶ | my( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 28 | ▶ | if( @_ == 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | return $self->setAttribute( $tag, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 27 | return $self->{attributes}{$tag}; | |||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 42 | } | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 412 | sub style { | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 46 | ▶ | my( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
style: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 46 | ▶ | if( 1==@_ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 35 | return $self->get_style; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 11 | return $self->set_style( $value ); | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | sub get_style | ||||||||||||||||||||||||||||||||||||||||||
| 423 | { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 49 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_style: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 49 | ▶ | return $self->{style_obj} if $self->{style_obj}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 12 | $self->{style_obj} = POE::XUL::Style->new( $self->{attributes}{style} ); | |||||||||||||||||||||||||||||||||||||||||
| 427 | 12 | ▶ | $CM->after_new_style( $self ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 12 | return $self->{style_obj}; | |||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | sub set_style | ||||||||||||||||||||||||||||||||||||||||||
| 432 | { | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 11 | ▶ | my( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_style: called CC=3 SCAR=13.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 11 | $self->{attributes}{style} = "$value"; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 11 | ▶ | if( blessed $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $self->{style_obj} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | $CM->after_new_style( $self ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 11 | delete $self->{style_obj}; | |||||||||||||||||||||||||||||||||||||||||
| 441 | # do the following to provoke a ->after_new_style(); | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 11 | $self->get_style; | |||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 11 | return; | |||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 448 | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 58 | ▶ | my( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 58 | my $key = our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 58 | ▶ | return if $key =~ /DESTROY$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 58 | $key =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 453 | # Carp::confess $key; | ||||||||||||||||||||||||||||||||||||||||||
| 454 | 58 | ▶ | if( $key =~ /^[a-z]/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 58 | ▶ | if( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 52 | return $self->getAttribute( $key ); | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 6 | return $self->setAttribute( $key, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | elsif( $key =~ /^[A-Z]/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $self->add_child( __PACKAGE__->new(tag => $key, @_[ 1..$#_ ] ) ); | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | croak __PACKAGE__. "::AUTOLOAD cannot find method $key"; | |||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 469 | sub hide | ||||||||||||||||||||||||||||||||||||||||||
| 470 | { | ||||||||||||||||||||||||||||||||||||||||||
| 471 | 7 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hide: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 7 | $self->style->display( 'none' ); | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 476 | sub show | ||||||||||||||||||||||||||||||||||||||||||
| 477 | { | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 5 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 5 | $self->style->display( '' ); | |||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | sub hidden | ||||||||||||||||||||||||||||||||||||||||||
| 483 | { | ||||||||||||||||||||||||||||||||||||||||||
| 484 | 4 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hidden: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 4 | return $self->style->display eq 'none'; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | # compositing ----------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 186 | sub children { wantarray? @{shift->{children}}: | |||||||||||||||||||||||||||||||||||||||||
| 491 | 186 | ▶ | [@{shift->{children}}] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children: called CC=2 SCAR=9.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 90 | ▶ | sub child_count { scalar @{shift->{children}} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
child_count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | sub hasChildNodes { return 0!= scalar @{shift->{children}} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hasChildNodes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 6 | ▶ | sub first_child { shift->{children}->[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first_child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | 21 | *firstChild = \&first_child; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 11 | ▶ | sub get_child { shift->{children}->[pop] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 1 | ▶ | sub last_child { shift->{children}->[-1] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | 21 | *lastChild = \&last_child; | |||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 501 | sub add_child { | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | ▶ | my ($self, $child, $index) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_child: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | # This is a huge speed up, but breaks the Aspect stuff | ||||||||||||||||||||||||||||||||||||||||||
| 504 | # unless( defined $index ) { | ||||||||||||||||||||||||||||||||||||||||||
| 505 | # push @{$self->{children}}, $child; | ||||||||||||||||||||||||||||||||||||||||||
| 506 | # return $child; | ||||||||||||||||||||||||||||||||||||||||||
| 507 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | 2 | my $child_count = $self->child_count; | |||||||||||||||||||||||||||||||||||||||||
| 509 | 2 | ▶ | $index = $child_count unless defined $index; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 2 | ▶ | croak "index out of bounds: [$index:$child_count]" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$index < 0 or $index > $child_count
MC/DC0%0/2
$index < 0 or $index > $child_count
$index < 0
$index > $child_count
Truth table33%1/3
A or B
A= $index < 0B= $index > $child_count
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | if ($index < 0 || $index > $child_count); | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | 2 | ▶ | if( $self->{children}[$index] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 1 | $self->remove_child( $index ); | |||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | 2 | $self->_add_child_at_index($child, $index); | |||||||||||||||||||||||||||||||||||||||||
| 518 | 2 | return $child; | |||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | sub appendChild | ||||||||||||||||||||||||||||||||||||||||||
| 521 | { | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 73 | ▶ | my( $self, $child ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
appendChild: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 73 | ▶ | $child = $self->createTextNode( $child ) unless ref $child; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 73 | my $index = $self->child_count; | |||||||||||||||||||||||||||||||||||||||||
| 525 | 73 | $self->_add_child_at_index( $child, $index ); | |||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | sub defaultChild | ||||||||||||||||||||||||||||||||||||||||||
| 529 | { | ||||||||||||||||||||||||||||||||||||||||||
| 530 | 27 | ▶ | my( $self, $text ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defaultChild: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 27 | ▶ | my $d_att = $DEFAULT_ATTRIBUTE{ lc $self->{attributes}{tag} || '' }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
lc $self->{'attributes'}{'tag'} || ''
MC/DC0%0/1
lc $self->{'attributes'}{'tag'} || ''
lc $self->{'attributes'}{'tag'}
Truth table50%1/2
A
A= lc $self->{'attributes'}{'tag'}
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 27 | ▶ | if( $d_att ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 12 | $self->setAttribute( $d_att => $text ); | |||||||||||||||||||||||||||||||||||||||||
| 534 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 15 | my $child = $self->createTextNode( $text ); | |||||||||||||||||||||||||||||||||||||||||
| 538 | 15 | my $index = $self->child_count; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 15 | $self->_add_child_at_index( $child, $index ); | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 543 | sub replaceChild { | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 1 | ▶ | my ($self, $new, $old) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replaceChild: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | 1 | my ($oldNode, $index) = $self->_compute_child_and_index($old); | |||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | ▶ | $CM->before_remove_child( $self, $oldNode, $index ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | splice @{$self->{children}}, $index, 1, $new; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 1 | ▶ | $CM->before__add_child_at_index( $self, $new, $index ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 1 | $old->dispose; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 555 | sub remove_child { | ||||||||||||||||||||||||||||||||||||||||||
| 556 | 11 | ▶ | my ($self, $something) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_child: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | 11 | my ($child, $index) = $self->_compute_child_and_index($something); | |||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 11 | ▶ | unless( $child and $index < @{ $self->{children} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$child and $index < @{$self->{"children"};}
MC/DC50%1/2
$child and $index < @{$self->{"children"};}
$child
$index < @{$self->{"children"};}
Truth table66%2/3
A and B
A= $childB= $index < @{$self->{"children"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | ▶ | Carp::carp "Attempt to remove an unknown child node" unless $ENV{AUTOMATED_TESTING}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | # warn "remove_child id=", $child->{attributes}{id}; | ||||||||||||||||||||||||||||||||||||||||||
| 566 | 9 | ▶ | $CM->before_remove_child( $self, $child, $index ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 9 | splice @{$self->{children}}, $index, 1; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 9 | ▶ | $child->dispose if blessed $child; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 21 | *removeChild = \&remove_child; | |||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 575 | sub get_child_index | ||||||||||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||||||||||
| 577 | 1 | ▶ | my ($self, $child) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_child_index: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | 1 | my $index = 0; | |||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | foreach my $C ( @{ $self->{children} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 580 | 1 | ▶ | return $index if $child eq $C; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $index++; | |||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | confess 'child not in parent'; | |||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 587 | # computes child and index from child or index | ||||||||||||||||||||||||||||||||||||||||||
| 588 | sub _compute_child_and_index | ||||||||||||||||||||||||||||||||||||||||||
| 589 | { | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 12 | ▶ | my ($self, $something) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compute_child_and_index: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 12 | my $is_node = ref $something; | |||||||||||||||||||||||||||||||||||||||||
| 592 | 12 | ▶ | my $child = $is_node? $something: $self->get_child($something); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | 12 | ▶ | my $index = $is_node? $self->get_child_index($something): $something; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | 12 | ▶ | return wantarray? ($child, $index): $child; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | sub _add_child_at_index { | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 90 | ▶ | my ($self, $child, $index) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_child_at_index: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 90 | my $N = $#{ $self->{children} }; | |||||||||||||||||||||||||||||||||||||||||
| 600 | 90 | my $trueindex; | |||||||||||||||||||||||||||||||||||||||||
| 601 | 90 | ▶ | if( $index > $N ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | 90 | $index = -1; | |||||||||||||||||||||||||||||||||||||||||
| 603 | 90 | push @{ $self->{children} }, $child; | |||||||||||||||||||||||||||||||||||||||||
| 604 | 90 | $trueindex = $#{ $self->{children} }; | |||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 606 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | splice @{$self->{children}}, $index, 0, $child; | |||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 90 | ▶ | if( $CM ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 47 | $CM->after__add_child_at_index( $self, $child, $index ); | |||||||||||||||||||||||||||||||||||||||||
| 611 | # after__add_child needs $index to be -1 for appends, so that they | ||||||||||||||||||||||||||||||||||||||||||
| 612 | # work in Runner. However, the state needs to remember the real, true | ||||||||||||||||||||||||||||||||||||||||||
| 613 | # index, so we set it afterwards. | ||||||||||||||||||||||||||||||||||||||||||
| 614 | # 2009-02: the problem with this is that the index might differ from | ||||||||||||||||||||||||||||||||||||||||||
| 615 | # what is happening in the client. Client should send the index back | ||||||||||||||||||||||||||||||||||||||||||
| 616 | # to us. TODO when we implement AJAX | ||||||||||||||||||||||||||||||||||||||||||
| 617 | 47 | ▶ | if( defined $trueindex ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | 47 | $CM->set_trueindex( $self, $child, $trueindex ); | |||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 621 | 90 | return $child; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | ############################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 625 | sub getElementById | ||||||||||||||||||||||||||||||||||||||||||
| 626 | { | ||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | my( $self, $id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getElementById: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | return $id if blessed $id; # act like prototype's $() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | croak "getElementById may only be invoked on a Window" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | unless $self->is_window; | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | return $CM->getElementById( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | # event handling -------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | sub attach { | ||||||||||||||||||||||||||||||||||||||||||
| 637 | 6 | ▶ | my( $self, $name, $listener ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attach: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | 6 | my $state; | |||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | 6 | my $server = $POE::XUL::Application::server; | |||||||||||||||||||||||||||||||||||||||||
| 642 | 6 | ▶ | if( $server ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | # auto-create the handler in the application | ||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $state = $server->attach_handler( $self, $name, $listener ); | |||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 647 | 6 | ▶ | $state = $listener||$name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$listener || $name
MC/DC0%0/2
$listener || $name
$listener
$name
Truth table33%1/3
A || B
A= $listenerB= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||
| 649 | 6 | DEBUG and warn $self->id, ".$name = $state"; | |||||||||||||||||||||||||||||||||||||||||
| 650 | 6 | ▶ | return unless $state; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 6 | $self->{events}->{ $name } = $state; | |||||||||||||||||||||||||||||||||||||||||
| 652 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||
| 654 | 21 | *addEventListener = \&attach; | |||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | sub detach { | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detach: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $listener = delete $self->{events}->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | croak "no listener to detach: $name" unless $listener; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | # TODO: remove the POE state if we auto-created it? | ||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | 21 | *removeEventListener = \&detach; | |||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | sub event { | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my $listener = $self->{events}->{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | return $listener; | |||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | # disposing ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | # protected, used by sessions and by parent nodes to free node memory | ||||||||||||||||||||||||||||||||||||||||||
| 673 | # event handlers could cause reference cycles, so we free them manually | ||||||||||||||||||||||||||||||||||||||||||
| 674 | sub dispose { | ||||||||||||||||||||||||||||||||||||||||||
| 675 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispose: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | 10 | $self->{disposed} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 677 | 10 | delete $self->{style_obj}; | |||||||||||||||||||||||||||||||||||||||||
| 678 | 10 | $_->dispose for grep { blessed $_ } $self->children; | |||||||||||||||||||||||||||||||||||||||||
| 679 | 10 | delete $self->{events}; | |||||||||||||||||||||||||||||||||||||||||
| 680 | 10 | $self->{children} = []; | |||||||||||||||||||||||||||||||||||||||||
| 681 | # TODO: remove any events that auto-created handler states | ||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 683 | 21 | *destroy = \&dispose; | |||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | sub is_destroyed { !shift->{events} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_destroyed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | sub DESTROY | ||||||||||||||||||||||||||||||||||||||||||
| 688 | { | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 66 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 690 | # carp "DESTROY ", ($self->id||$self); | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 66 | ▶ | $CM->after_destroy( $self ) if $CM; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | ####################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 697 | sub as_xml { | ||||||||||||||||||||||||||||||||||||||||||
| 698 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_xml: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 22 | ▶ | my $level = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 700 | 22 | my $tag = lc $self->tag; | |||||||||||||||||||||||||||||||||||||||||
| 701 | 22 | $tag =~ s/_/:/; | |||||||||||||||||||||||||||||||||||||||||
| 702 | 22 | my $attributes = $self->attributes_as_xml; | |||||||||||||||||||||||||||||||||||||||||
| 703 | 22 | my $children = $self->children_as_xml($level + 1); | |||||||||||||||||||||||||||||||||||||||||
| 704 | # my $indent = $self->get_indent($level); | ||||||||||||||||||||||||||||||||||||||||||
| 705 | 22 | ▶ | my $nl = ( $tag =~ /^((h|v|group)box)|(grid|row|(field-(name|value)))$/ ? "\n" : "" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | 22 | ▶ | return qq[<$tag$attributes${\( $children? ">$nl$children</$tag": '/' )}>$nl]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | sub attributes_as_xml { | ||||||||||||||||||||||||||||||||||||||||||
| 710 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attributes_as_xml: called CC=7 SCAR=21.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 22 | my %attributes = $self->attributes; | |||||||||||||||||||||||||||||||||||||||||
| 712 | 22 | my $xml = ''; | |||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | delete $attributes{id} if $self->{default_id} and | ||||||||||||||||||||||||||||||||||||||||||
| 715 | 22 | ▶ | $attributes{id} eq $self->{default_id}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"default_id"} and $attributes{"id"} eq $self->{"default_id"}
MC/DC0%0/2
$self->{"default_id"} and $attributes{"id"} eq $self->{"default_id"}
$self->{"default_id"}
$attributes{"id"} eq $self->{"default_id"}
Truth table33%1/3
A and B
A= $self->{"default_id"}B= $attributes{"id"} eq $self->{"default_id"}
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | 22 | foreach my $k ( keys %attributes ) { | |||||||||||||||||||||||||||||||||||||||||
| 718 | 24 | ▶ | next if defined $attributes{ $k }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | warn $self->id."/$k is undef"; | |||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | $attributes{ $k } = ''; | |||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 2 | $xml .= qq[ $_='${\( encode_entities_numeric( $self->$_, "\x00-\x1f<>&\'\x80-\xff" ) )}'] | |||||||||||||||||||||||||||||||||||||||||
| 723 | 22 | ▶ | for grep { $_ ne 'tag' and $_ ne 'textNode' } keys %attributes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | # die $xml if $xml =~ /\n/; | ||||||||||||||||||||||||||||||||||||||||||
| 725 | 22 | return $xml; | |||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | sub children_as_xml { | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children_as_xml: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | 22 | ▶ | my $level = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | # my $indent = $self->get_indent($level); | ||||||||||||||||||||||||||||||||||||||||||
| 732 | 22 | my $xml = ''; | |||||||||||||||||||||||||||||||||||||||||
| 733 | # $xml .= qq[\n$indent${\( $_->as_xml($level) )}] for $self->children; | ||||||||||||||||||||||||||||||||||||||||||
| 734 | 22 | ▶ | $xml .= qq[${\( blessed $_ ? $_->as_xml($level) : $_ )}] for $self->children; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 735 | 22 | return $xml; | |||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | sub get_indent { ' ' x (3 * pop) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_indent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | 21 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | __END__ | ||||||||||||||||||||||||||||||||||||||||||