| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Scripter::WindowGroup; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.031'; # update POD, too |
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
2264
|
use Carp; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
120
|
|
|
6
|
2
|
|
|
2
|
|
817
|
use WWW'Scripter; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
649
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
3
|
|
|
3
|
1
|
64
|
my(undef,%args) = @_; |
|
10
|
3
|
100
|
|
|
|
9
|
if($args{empty}) { |
|
11
|
1
|
|
|
|
|
3
|
bless [],shift |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
else { |
|
14
|
2
|
|
|
|
|
10
|
my $self = bless [my $w = new WWW'Scripter], shift; |
|
15
|
2
|
|
|
|
|
7
|
$w->window_group($self); |
|
16
|
2
|
|
|
|
|
5
|
$self; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub active_window { |
|
21
|
4
|
|
|
4
|
1
|
19
|
return $_[0][0] |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub windows { |
|
25
|
23
|
|
|
23
|
1
|
2266
|
@{$_[0]} |
|
|
23
|
|
|
|
|
116
|
|
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new_window { |
|
29
|
|
|
|
|
|
|
unshift |
|
30
|
2
|
|
|
|
|
7
|
@{$_[0]}, |
|
31
|
2
|
50
|
|
2
|
1
|
4
|
my $w = $_[0][0] ? clear_history{clone{$_[0][0]}}1 : new WWW'Scripter; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
7
|
|
|
32
|
2
|
|
|
|
|
6
|
$w->window_group($_[0]); |
|
33
|
2
|
|
|
|
|
4
|
$w |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub detach { |
|
37
|
12
|
|
|
12
|
1
|
19
|
my $self = shift; |
|
38
|
12
|
|
|
|
|
13
|
my $inddx = 0; |
|
39
|
12
|
|
|
|
|
22
|
for(@$self) { |
|
40
|
18
|
100
|
|
|
|
60
|
$_ == $_[0] |
|
41
|
|
|
|
|
|
|
and splice(@$self, $inddx, 1), $_->window_group(undef),return; |
|
42
|
6
|
|
|
|
|
7
|
++$inddx |
|
43
|
|
|
|
|
|
|
} |
|
44
|
0
|
|
|
|
|
0
|
croak "detach cannot find $_[0] in $self"; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub bring_to_front { |
|
48
|
5
|
|
|
5
|
1
|
6
|
my $self = shift; |
|
49
|
5
|
|
|
|
|
5
|
my $inddx = 0; |
|
50
|
5
|
|
|
|
|
9
|
for(@$self) { |
|
51
|
10
|
100
|
|
|
|
24
|
$_ == $_[0] and splice(@$self, $inddx, 1), unshift(@$self,$_), return; |
|
52
|
5
|
|
|
|
|
7
|
++$inddx |
|
53
|
|
|
|
|
|
|
} |
|
54
|
0
|
|
|
|
|
0
|
croak "bring_to_front cannot find $_[0] in $self"; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub attach { |
|
58
|
17
|
|
|
17
|
1
|
475
|
unshift @{$_[0]}, $_[1]; |
|
|
17
|
|
|
|
|
30
|
|
|
59
|
17
|
|
|
|
|
43
|
$_[1]->window_group($_[0]); |
|
60
|
|
|
|
|
|
|
_: |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
WWW::Scripter::WindowGroup - Multiple-window browsing environment |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 VERSION |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Version 0.031 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
use WWW'Scripter'WindowGroup; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$browser = new WWW'Scripter'WindowGroup; |
|
76
|
|
|
|
|
|
|
# This has one window already |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# OR: |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$browser = new WWW'Scripter'WindowGroup empty => 1; |
|
81
|
|
|
|
|
|
|
$browser->attach($w = new WWW'Scripter); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$w = $browser->active_window; |
|
84
|
|
|
|
|
|
|
$w->get('http://ghare.dr/'); |
|
85
|
|
|
|
|
|
|
$w->close; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$w = $browser->new_window; |
|
88
|
|
|
|
|
|
|
@w = $browser->windows; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This module provides a virtual multiple-window browsing environment for |
|
93
|
|
|
|
|
|
|
L. It does not actually create any windows on the screen, |
|
94
|
|
|
|
|
|
|
but |
|
95
|
|
|
|
|
|
|
it can be used to script websites that make use of multiple windows. The |
|
96
|
|
|
|
|
|
|
individual windows themselves are WWW::Scripter objects. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Before you start using this, consider whether the site you are scripting |
|
99
|
|
|
|
|
|
|
actually I multiple windows. If a single-window environment will do, |
|
100
|
|
|
|
|
|
|
use L directly. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Note: Window groups hold strong references to their windows, but the |
|
103
|
|
|
|
|
|
|
windows themselves hold weak references to the window group. So if you let |
|
104
|
|
|
|
|
|
|
a window group go out of scope while retaining a reference to a window, |
|
105
|
|
|
|
|
|
|
that window will revert to single-window mode. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 METHODS |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=over |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item new |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The constructor. Call this method on the class, not on an object thereof. |
|
114
|
|
|
|
|
|
|
It takes no arguments. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item active_window |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns the window that is currently 'active'. This can be changed by |
|
119
|
|
|
|
|
|
|
scripts calling the C method on a window, or opening a new one, so |
|
120
|
|
|
|
|
|
|
keep your own |
|
121
|
|
|
|
|
|
|
reference to it if you need to refer to a specific window repeatedly. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item windows |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns a list of all windows in list context, or the number of windows in |
|
126
|
|
|
|
|
|
|
scalar context. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item new_window |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Adds a new WWW::Scripter to the window group and returns it. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item attach ($window) |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This methods adds a window to the group, making it the frontmost window and |
|
135
|
|
|
|
|
|
|
setting its C |
|
136
|
|
|
|
|
|
|
attribute appropriately. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
If you attach a window that is already attached to another group, strange |
|
139
|
|
|
|
|
|
|
things may happen. Detach it first. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item detach ($window) |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This removes the window from the group and sets its C |
|
144
|
|
|
|
|
|
|
attribute to C. This is used internally by |
|
145
|
|
|
|
|
|
|
WWW::Scripter's C method. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item bring_to_front ($window) |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This makes C<$window> the active window. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR & COPYRIGHT |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
See L |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=over 4 |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item - |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=back |