XUL/Window.pm

filter: Statementstmt 61.6% 37 / 60 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 68.7% 11 / 16 Podpod 80.0% 4 / 5 totaltotal 57.1% 52 / 91 CC 6 SCAR 15.4
CC
6
Cov
53%
open
12.0
getElementById
12.0
dispose
6.0
CRAP 4.7
« XUL/Application.pm ↑ Summary XUL/Event.pm »
1 package POE::XUL::Window;
2 # $Id$
3 # Copyright Philip Gwyn 2007-2010. All rights reserved.
4 # Based on code Copyright 2003-2004 Ran Eilam. All rights reserved.
5  
6 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 21 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 21 ▶use POE::XUL::Node;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 21 ▶use POE::XUL::TWindow;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 21 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 21 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 21 ▶use base qw( POE::XUL::Node );
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 21 our $VERSION = '0.0600';
19 21 our $CM;
20  
21 ##############################################################
22 6 ▶sub is_window { 1 }
Subroutine is_window: called CC=1 SCAR=0.0
Pod undocumented
23  
24 sub import
25 {
26 22 ▶ my( $package ) = @_;
Subroutine import: called CC=1 SCAR=0.0
27 22 my $caller = caller();
28 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 22 *{ $caller . "::Window" } =
30 22 ▶ sub { return scalar $package->new( tag=>'Window', @_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
31 }
32  
33 ##############################################################
34 ## DOM-like window.open( $name, $features );
35 sub open
36 {
37 0 ▶ my( $self, $winID, $features ) = @_;
Subroutine open: not called CC=3 SCAR=24.8
Pod documented
38  
39 # TODO: make sure $winID doesn't already exist
40  
41 # popup_window will allocate a winID if one doesn't exist already
42 0 $winID = $POE::XUL::Node::CM->popup_window( $winID, $features );
43  
44 0 ▶ return unless $INC{'POE/XUL/Application.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"POE/XUL/Application.pm"} 0 0 0
45  
46 0 my $server = POE::XUL::Application::server();
47 0 ▶ return unless $server;
Branch: 1 branch
BranchTrueFalseTotal
unless $server 0 0 0
48
49 # Create a temporary window to hold the events until 'connect'
50 0 my $twindow = POE::XUL::TWindow->new( %$features, id => $winID );
51 0 $server->attach_subwindow( $twindow );
52 0 return $twindow;
53 }
54  
55 ##############################################################
56 ## DOM-like window.close()
57 sub close
58 {
59 0 ▶ my( $self ) = @_;
Subroutine close: not called CC=1 SCAR=6.9
Pod documented
60  
61 # carp "$self.close";
62 0 $POE::XUL::Node::CM->close_window( $self->id );
63 # this will cause a close instruction, which closes then window
64 # which will provoke 'disconnect' request, which is where the
65 # window is finnaly GCed
66 0 $self->closed( 1 );
67 }
68  
69 ##############################################################
70 sub getElementById
71 {
72 0 ▶ my( $self, $id ) = @_;
Subroutine getElementById: not called CC=3 SCAR=24.8
Pod documented
73 0 ▶ return $id if blessed $id; # act like prototype's $()
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($id) 0 0 0
74 0 ▶ croak "getElementById may only be invoked on a Window"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_window 0 0 0
75 unless $self->is_window;
76 0 return $POE::XUL::Node::CM->getElementById( $id );
77 }
78 21 *node = \&getElementById;
79  
80 ##############################################################
81 sub dispose
82 {
83 0 ▶ my( $self ) = @_;
Subroutine dispose: not called CC=2 SCAR=17.9
Pod documented
84 0 my $id = $self->id;
85 0 $self->SUPER::dispose;
86 0 ▶ return unless $POE::XUL::Node::CM;
Branch: 1 branch
BranchTrueFalseTotal
unless $POE::XUL::Node::CM 0 0 0
87 0 $POE::XUL::Node::CM->unregister_window( $self );
88 0 $self->{attributes} = {};
89 0 return;
90 }
91 21 *destroy = \&dispose;
92  
93 21 1;
94  
95 __END__
« XUL/Application.pm ↑ Summary XUL/Event.pm »