Initial checkin of relicensing tool and test files.

This commit is contained in:
gerv%gerv.net 2006-03-30 03:27:40 +00:00
Родитель db9da5fe6c
Коммит 94c25b18c3
40 изменённых файлов: 6408 добавлений и 0 удалений

205
tools/relic/README Executable file
Просмотреть файл

@ -0,0 +1,205 @@
ReadMe for relic.py (a Mozilla relicensing tool)
This script is intended to facilitate re-licensing the Mozilla source
tree pursuant to <http://mozilla.org/MPL/>. It cannot do the full job
automatically but handles most of the grunt work.
Table of Contents:
The Problem
Getting Started
Basic Usage
What Files are Processed
Error Handling (--force)
Unfinished Business
Contributors
The Problem:
The basic problem is that Mozilla has a lot of files. The goal is to have
all the files (with a few minor exceptions) contain a leading license
block that is either the MPL/GPL/LGPL tri-license or the NPL/GPL/LGPL
tri-license. Because this was never rigorously enforced a lot of cleanup
is necessary to correct license blocks in Mozilla's files. This script
will traverse the given directory(s)/file(s) and fixup the leading
license block, or give an error message explaining why it cannot. (It
also has modes to just scan for and summarize license info.)
Getting Started:
While 'relic.py' is probably quite portable to Windows it has not been
tested there. There may be some hidden path-delimiter bugs. It is
probably best to just run this script on Linux.
To use:
- crack the relic-<version>.tar.gz tarball in some directory
- call './relic.py --help' to learn the basic usage
- play with './relic.py ...' as desired.
Basic Usage:
'relic.py' has a --help option that explains the basic usage but I'll go
through some examples here. In our examples we will work on re-licensing
the mozilla/js/src directory tree.
'relic.py' has three modes.
(1) List license info on each file processed (the default)
$ ./relic.py mozilla/js/src/jsapi.h
/js/src/jsapi.h
... npl/gpl found
... license block lines: 2-32
... original code is: Mozilla Communicator client code
... initially by: Original Code is Netscape Communications Corporation (1998)
(2) Gather and dump statistics on the processed files:
$ ./relic.py -s mozilla/js/src/jsapi.h
Summary of Licenses in Files
============================
Number Percent License
------- -------- -----------
1 100.00% npl/gpl
----------------------------
1 files processed
Licensed files with complete tri-license block: 0
Licensed files with no 'Initial Developer...' info: 0
Licensed files with no 'Original Code is...' info: 0
Licensed files with improperly indented 'Contributor(s):' line(s): 0
(3) Re-licensing the given files that need it (i.e. files with a complete
and correct license block are changed).
$ ./relic.py -r mozilla/js/src/jsapi.h
mozilla/js/src/jsapi.h
... npl/gpl found, need to relicense
... original code is: Mozilla Communicator client code
... initially by: Original Code is Netscape Communications Corporation (1998)
... replacing lines 2-32 with NPL/GPL/LGPL tri-license
... backing up to 'mozilla/js/src/jsapi.h~0'
... done relicensing 'mozilla/js/src/jsapi.h'
--------------------- Summary of Results ------------------------
Files skipped b/c they are binary: 0
Files skipped b/c they already had proper license: 0
Files skipped b/c they had no license: 0
Files re-licensed: 1
-----------------------------------------------------------------
If you are trying this as you read this, run the following command to see
the changes made to jsapi.h:
$ diff -c mozilla/js/src/jsapi.h~0 mozilla/js/src/jsapi.h
What Files are Processed:
'relic.py' will process any files listed on the command line and will
recursively process all files in any given directories:
$ ./relic.py -s mozilla/js/src
Summary of Licenses in Files
============================
Number Percent License
------- -------- -----------
324 74.14% npl/gpl
71 16.25% <none found>
23 5.26% mpl/gpl/lgpl
4 0.92% npl/gpl/lgpl
4 0.92% mpl
4 0.92% ibm
3 0.69% mpl/gpl
2 0.46% npl
2 0.46% <unknown license>
----------------------------
437 files processed
Licensed files with complete tri-license block: 27
Licensed files with no 'Initial Developer...' info: 1
Licensed files with no 'Original Code is...' info: 27
Licensed files with improperly indented 'Contributor(s):' line(s): 2
The following files are automatically skipped:
- CVS control directories;
- files listed in .cvsignore files;
- all *.s files (there usage of comment delimiters is all over the map);
- binary files; and
- any files included in the following global variables in relic.py:
_g_skip_file_basenames, _g_skip_files, _g_skip_dir_basenames,
_g_skip_dirs, _g_skip_ext.
Error Handling (--force):
There are some situations that relic.py cannot handle. E.g., a file with
no license block to start with, an IBM license block, a license block
sufficiently strange enough to baffle relic.py regular expressions. In
normal operation, when an error is encoutered on any file processing
stops. This can be annoying, so a --force|-f option was added to force
relic.py to continue processing files after an error with a file is
encountered. In all modes of operation errors are summarized at the end.
$ ./relic.py -s mozilla/extensions/transformiix/source/xml
ERROR:relic:This is line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: mozilla/extensions/transformiix/source/xml/XMLDOMUtils.h:20: ' * Keith Visco' (the --force option can be used to skip problematic files and continue processing rather than aborting)
$ ./relic.py -sf mozilla/extensions/transformiix/source/xml
Summary of Licenses in Files
============================
Number Percent License
------- -------- -----------
24 100.00% mpl
----------------------------
24 files processed
Licensed files with complete tri-license block: 0
Licensed files with no 'Initial Developer...' info: 16
Licensed files with no 'Original Code is...' info: 15
Licensed files with improperly indented 'Contributor(s):' line(s): 3
=================== Summary of Errors ===========================
Files with processing errors: 3
=================================================================
mozilla/extensions/transformiix/source/xml/XMLDOMUtils.cpp: This is line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: mozilla/extensions/transformiix/source/xml/XMLDOMUtils.cpp:20: ' * Keith Visco '
mozilla/extensions/transformiix/source/xml/XMLDOMUtils.h: This is line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: mozilla/extensions/transformiix/source/xml/XMLDOMUtils.h:20: ' * Keith Visco '
mozilla/extensions/transformiix/source/xml/parser/txXMLParser.h: This is line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: mozilla/extensions/transformiix/source/xml/parser/txXMLParser.h:20: ' * Tom Kneeland'
=================================================================
Unfinished Business:
The following is a list of issues that should be sorted out before this
should be used to start making patches to the Mozilla tree:
- What to do for files that have no 'Initial Developer...' block?
- What to do for files that have no 'Original Code is...' block?
- Are there specific files or parts of the mozilla tree that should be
skipped always, i.e. generated files, files not meant to have leading
license blocks?
- What to do for files with the IBM license?
- Should *.uf be ignored (there are 87 of them in the mozilla tree)?
- The 'ripl' and lick' scripts' "include licenses" configuration option
is not supported in anyway by relic.py. Is it necessary? I don't see a
useful use case.
- test/x_thread_align_center.xml and test/abs2rel.pl are examples of
files that are not handled correctly. In the former there is some data
loss. In the latter the is some cruft left over.
Contributors:
Trent Mick (TrentM@ActiveState.com) originally wrote this script,
borrowing some from earlier attempts in the name of 'lick', 'lutils.py',
and 'ripl' (see <http://bugzilla.mozilla.org/show_bug.cgi?id=98089>).
If you have problems with the script please let me know and hopefully I
can help you out.

2369
tools/relic/relic Executable file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,145 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: Mozilla-sample-code 1.0
*
* Copyright (c) 2002 Netscape Communications Corporation and
* other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this Mozilla sample software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "BrowserToolTip.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrowserToolTip
CBrowserToolTip::CBrowserToolTip()
{
}
CBrowserToolTip::~CBrowserToolTip()
{
}
BEGIN_MESSAGE_MAP(CBrowserToolTip, CWnd)
//{{AFX_MSG_MAP(CBrowserToolTip)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CBrowserToolTip::Create(CWnd *pParentWnd)
{
return CWnd::CreateEx(WS_EX_TOOLWINDOW,
AfxRegisterWndClass(CS_SAVEBITS, NULL, GetSysColorBrush(COLOR_INFOBK), NULL),
_T("ToolTip"), WS_POPUP | WS_BORDER, 0, 0, 1, 1, pParentWnd->GetSafeHwnd(), NULL);
}
/////////////////////////////////////////////////////////////////////////////
// CBrowserToolTip message handlers
void CBrowserToolTip::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcClient;
GetClientRect(&rcClient);
// Draw tip text
int oldBkMode = dc.SetBkMode(TRANSPARENT);
COLORREF oldTextColor = dc.SetTextColor(GetSysColor(COLOR_INFOTEXT));
HGDIOBJ oldFont = dc.SelectObject(GetStockObject(DEFAULT_GUI_FONT));
dc.DrawText(m_szTipText, -1, rcClient, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
dc.SetBkMode(oldBkMode);
dc.SetTextColor(oldTextColor);
dc.SelectObject(oldFont);
}
BOOL CBrowserToolTip::PreCreateWindow(CREATESTRUCT& cs)
{
return CWnd::PreCreateWindow(cs);
}
void CBrowserToolTip::SetTipText(const CString &szTipText)
{
m_szTipText = szTipText;
}
void CBrowserToolTip::Show(CWnd *pOverWnd, long left, long top)
{
// Calculate the client window size
CRect rcNewClient(0,0,0,0);
CDC *pdc = GetDC();
HGDIOBJ oldFont = pdc->SelectObject(GetStockObject(DEFAULT_GUI_FONT));
rcNewClient.bottom = pdc->DrawText(m_szTipText, -1, rcNewClient,
DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_CALCRECT);
pdc->SelectObject(oldFont);
ReleaseDC(pdc);
rcNewClient.right += 8;
rcNewClient.bottom += 8;
// Adjust the tooltip to new size
AdjustWindowRectEx(rcNewClient, GetWindowLong(m_hWnd, GWL_STYLE), FALSE, GetWindowLong(m_hWnd, GWL_EXSTYLE));
// Adjust the left, top position of the tooltip
CPoint ptTip(left, top);
pOverWnd->ClientToScreen(&ptTip);
// Make sure tip is below cursor
POINT ptCursor;
GetCursorPos(&ptCursor);
long cyCursor = GetSystemMetrics(SM_CYCURSOR);
if (ptTip.y < ptCursor.y + cyCursor)
ptTip.y = ptCursor.y + cyCursor;
// Make sure tip is fully visible
RECT rcScreen;
GetDesktopWindow()->GetClientRect(&rcScreen);
if (ptTip.x < 0)
ptTip.x = 0;
else if (ptTip.x + rcNewClient.Width() > rcScreen.right)
ptTip.x = rcScreen.right - rcNewClient.Width();
if (ptTip.y < 0)
ptTip.y = 0;
else if (ptTip.y + rcNewClient.Height() > rcScreen.bottom)
ptTip.y = rcScreen.bottom - rcNewClient.Height();
// Position and show the tip
SetWindowPos(&CWnd::wndTop, ptTip.x, ptTip.y, rcNewClient.Width(), rcNewClient.Height(),
SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
void CBrowserToolTip::Hide()
{
ShowWindow(SW_HIDE);
}

Просмотреть файл

@ -0,0 +1,107 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
#include <stdio.h>
#include <stdlib.h>
#if defined(VMS)
#include <sys/timeb.h>
#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS)
#include <sys/time.h>
#elif defined(WIN32)
#include <windows.h>
#elif defined(XP_OS2_VACPP)
#include <sys/timeb.h>
#else
#error "Architecture not supported"
#endif
int main(int argc, char **argv)
{
#if defined(OMIT_LIB_BUILD_TIME)
/*
* Some platforms don't have any 64-bit integer type
* such as 'long long'. Because we can't use NSPR's
* PR_snprintf in this program, it is difficult to
* print a static initializer for PRInt64 (a struct).
* So we print nothing. The makefiles that build the
* shared libraries will detect the empty output string
* of this program and omit the library build time
* in PRVersionDescription.
*/
#elif defined(VMS)
long long now;
struct timeb b;
ftime(&b);
now = b.time;
now *= 1000000;
now += (1000 * b.millitm);
fprintf(stdout, "%Ld", now);
#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS)
long long now;
struct timeval tv;
#ifdef HAVE_SVID_GETTOD
gettimeofday(&tv);
#else
gettimeofday(&tv, NULL);
#endif
now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec;
#if defined(OSF1)
fprintf(stdout, "%ld", now);
#elif defined(BEOS) && defined(__POWERPC__)
fprintf(stdout, "%Ld", now); /* Metroworks on BeOS PPC */
#else
fprintf(stdout, "%lld", now);
#endif
#elif defined(WIN32)
__int64 now;
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
CopyMemory(&now, &ft, sizeof(now));
/*
* 116444736000000000 is the number of 100-nanosecond intervals
* between Jan. 1, 1601 and Jan. 1, 1970.
*/
#ifdef __GNUC__
now = (now - 116444736000000000LL) / 10LL;
fprintf(stdout, "%lld", now);
#else
now = (now - 116444736000000000i64) / 10i64;
fprintf(stdout, "%I64d", now);
#endif
#elif defined(XP_OS2_VACPP)
/* no long long or i64 so we use a string */
#include <string.h>
char buf[24];
char tbuf[7];
time_t now;
long mtime;
int i;
struct timeb b;
ftime(&b);
now = b.time;
_ltoa(now, buf, 10);
mtime = b.millitm * 1000;
if (mtime == 0){
++now;
strcat(buf, "000000");
} else {
_ltoa(mtime, tbuf, 10);
for (i = strlen(tbuf); i < 6; ++i)
strcat(buf, "0");
strcat(buf, tbuf);
}
fprintf(stdout, "%s", buf);
#else
#error "Architecture not supported"
#endif
return 0;
} /* main */
/* now.c */

Просмотреть файл

@ -0,0 +1,33 @@
#!env perl
# -*- Mode: Perl; tab-width: 4; -*-
# Blah blah blah
use File::Spec::Unix;
use strict;
print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2);
my $finish = my_canonpath(shift);
my $start = my_canonpath(shift);
my $res = File::Spec::Unix->abs2rel($finish, $start);
#print STDERR "abs2rel($finish,$start) = $res\n";
print "$res\n";
sub my_canonpath($) {
my ($file) = @_;
my (@inlist, @outlist, $dir);
# Do what File::Spec::Unix->no_upwards should do
my @inlist = split(/\//, File::Spec::Unix->canonpath($file));
foreach $dir (@inlist) {
if ($dir eq '..') {
pop @outlist;
} else {
push @outlist, $dir;
}
}
$file = join '/',@outlist;
return $file;
}

Просмотреть файл

@ -0,0 +1,32 @@
#!env perl
# Blah blah blah
use File::Spec::Unix;
use strict;
print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2);
my $finish = my_canonpath(shift);
my $start = my_canonpath(shift);
my $res = File::Spec::Unix->abs2rel($finish, $start);
#print STDERR "abs2rel($finish,$start) = $res\n";
print "$res\n";
sub my_canonpath($) {
my ($file) = @_;
my (@inlist, @outlist, $dir);
# Do what File::Spec::Unix->no_upwards should do
my @inlist = split(/\//, File::Spec::Unix->canonpath($file));
foreach $dir (@inlist) {
if ($dir eq '..') {
pop @outlist;
} else {
push @outlist, $dir;
}
}
$file = join '/',@outlist;
return $file;
}

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<panels xmlns="http://www.silverstone.net.nz/2001/manticore/uidl">
<panel label="Web Browser">
<panel label="Browser Display" id="browser-display"/>
</panel>
</panels>

Просмотреть файл

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the packages being supplied by this jar -->
<RDF:Seq about="urn:mozilla:skin:root">
<RDF:li resource="urn:mozilla:skin:modern/1.0" />
</RDF:Seq>
<!-- skin information -->
<RDF:Description about="urn:mozilla:skin:modern/1.0"
chrome:displayName="Modern"
chrome:author="mozilla.org"
chrome:name="modern/1.0">
<chrome:packages>
<RDF:Seq about="urn:mozilla:skin:modern/1.0:packages">
<RDF:li resource="urn:mozilla:skin:modern/1.0:cview"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
</RDF:RDF>

Просмотреть файл

@ -0,0 +1,143 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdio.h>
#include <stdlib.h>
#if defined(VMS)
#include <sys/timeb.h>
#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS)
#include <sys/time.h>
#elif defined(WIN32)
#include <windows.h>
#elif defined(XP_OS2_VACPP)
#include <sys/timeb.h>
#else
#error "Architecture not supported"
#endif
int main(int argc, char **argv)
{
#if defined(OMIT_LIB_BUILD_TIME)
/*
* Some platforms don't have any 64-bit integer type
* such as 'long long'. Because we can't use NSPR's
* PR_snprintf in this program, it is difficult to
* print a static initializer for PRInt64 (a struct).
* So we print nothing. The makefiles that build the
* shared libraries will detect the empty output string
* of this program and omit the library build time
* in PRVersionDescription.
*/
#elif defined(VMS)
long long now;
struct timeb b;
ftime(&b);
now = b.time;
now *= 1000000;
now += (1000 * b.millitm);
fprintf(stdout, "%Ld", now);
#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS)
long long now;
struct timeval tv;
#ifdef HAVE_SVID_GETTOD
gettimeofday(&tv);
#else
gettimeofday(&tv, NULL);
#endif
now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec;
#if defined(OSF1)
fprintf(stdout, "%ld", now);
#elif defined(BEOS) && defined(__POWERPC__)
fprintf(stdout, "%Ld", now); /* Metroworks on BeOS PPC */
#else
fprintf(stdout, "%lld", now);
#endif
#elif defined(WIN32)
__int64 now;
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
CopyMemory(&now, &ft, sizeof(now));
/*
* 116444736000000000 is the number of 100-nanosecond intervals
* between Jan. 1, 1601 and Jan. 1, 1970.
*/
#ifdef __GNUC__
now = (now - 116444736000000000LL) / 10LL;
fprintf(stdout, "%lld", now);
#else
now = (now - 116444736000000000i64) / 10i64;
fprintf(stdout, "%I64d", now);
#endif
#elif defined(XP_OS2_VACPP)
/* no long long or i64 so we use a string */
#include <string.h>
char buf[24];
char tbuf[7];
time_t now;
long mtime;
int i;
struct timeb b;
ftime(&b);
now = b.time;
_ltoa(now, buf, 10);
mtime = b.millitm * 1000;
if (mtime == 0){
++now;
strcat(buf, "000000");
} else {
_ltoa(mtime, tbuf, 10);
for (i = strlen(tbuf); i < 6; ++i)
strcat(buf, "0");
strcat(buf, tbuf);
}
fprintf(stdout, "%s", buf);
#else
#error "Architecture not supported"
#endif
return 0;
} /* main */
/* now.c */

Просмотреть файл

@ -0,0 +1,69 @@
#!env perl
# -*- Mode: Perl; tab-width: 4; -*-
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org Code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# Blah blah blah
use File::Spec::Unix;
use strict;
print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2);
my $finish = my_canonpath(shift);
my $start = my_canonpath(shift);
my $res = File::Spec::Unix->abs2rel($finish, $start);
#print STDERR "abs2rel($finish,$start) = $res\n";
print "$res\n";
sub my_canonpath($) {
my ($file) = @_;
my (@inlist, @outlist, $dir);
# Do what File::Spec::Unix->no_upwards should do
my @inlist = split(/\//, File::Spec::Unix->canonpath($file));
foreach $dir (@inlist) {
if ($dir eq '..') {
pop @outlist;
} else {
push @outlist, $dir;
}
}
$file = join '/',@outlist;
return $file;
}

Просмотреть файл

@ -0,0 +1,68 @@
#!env perl
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org Code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# Blah blah blah
use File::Spec::Unix;
use strict;
print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2);
my $finish = my_canonpath(shift);
my $start = my_canonpath(shift);
my $res = File::Spec::Unix->abs2rel($finish, $start);
#print STDERR "abs2rel($finish,$start) = $res\n";
print "$res\n";
sub my_canonpath($) {
my ($file) = @_;
my (@inlist, @outlist, $dir);
# Do what File::Spec::Unix->no_upwards should do
my @inlist = split(/\//, File::Spec::Unix->canonpath($file));
foreach $dir (@inlist) {
if ($dir eq '..') {
pop @outlist;
} else {
push @outlist, $dir;
}
}
$file = join '/',@outlist;
return $file;
}

Просмотреть файл

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.org Code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 2001
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
- or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<panels xmlns="http://www.silverstone.net.nz/2001/manticore/uidl">
<panel label="Web Browser">
<panel label="Browser Display" id="browser-display"/>
</panel>
</panels>

Просмотреть файл

@ -0,0 +1,57 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.org Code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 2001
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
- or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the packages being supplied by this jar -->
<RDF:Seq about="urn:mozilla:skin:root">
<RDF:li resource="urn:mozilla:skin:modern/1.0" />
</RDF:Seq>
<!-- skin information -->
<RDF:Description about="urn:mozilla:skin:modern/1.0"
chrome:displayName="Modern"
chrome:author="mozilla.org"
chrome:name="modern/1.0">
<chrome:packages>
<RDF:Seq about="urn:mozilla:skin:modern/1.0:packages">
<RDF:li resource="urn:mozilla:skin:modern/1.0:cview"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
</RDF:RDF>

Просмотреть файл

@ -0,0 +1,75 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is TransforMiiX XSLT processor.
*
* The Initial Developer of the Original Code is The MITRE Corporation.
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
*
* Portions created by Keith Visco as a Non MITRE employee,
* (C) 1999 Keith Visco. All Rights Reserved.
*
* Contributor(s):
* Keith Visco
* -- original author.
*
*/
#include "XMLDOMUtils.h"
#include "dom.h"
#include "nsString.h"
void XMLDOMUtils::getNodeValue(Node* aNode, nsAString& aResult)
{
if (!aNode)
return;
unsigned short nodeType = aNode->getNodeType();
switch (nodeType) {
case Node::ATTRIBUTE_NODE:
case Node::CDATA_SECTION_NODE:
case Node::COMMENT_NODE:
case Node::PROCESSING_INSTRUCTION_NODE:
case Node::TEXT_NODE:
{
nsAutoString nodeValue;
aNode->getNodeValue(nodeValue);
aResult.Append(nodeValue);
break;
}
case Node::DOCUMENT_NODE:
{
getNodeValue(((Document*)aNode)->getDocumentElement(),
aResult);
break;
}
case Node::DOCUMENT_FRAGMENT_NODE:
case Node::ELEMENT_NODE:
{
Node* tmpNode = aNode->getFirstChild();
while (tmpNode) {
nodeType = tmpNode->getNodeType();
if ((nodeType == Node::TEXT_NODE) ||
(nodeType == Node::CDATA_SECTION_NODE)) {
nsAutoString nodeValue;
tmpNode->getNodeValue(nodeValue);
aResult.Append(nodeValue);
}
else if (nodeType == Node::ELEMENT_NODE) {
getNodeValue(tmpNode, aResult);
}
tmpNode = tmpNode->getNextSibling();
}
break;
}
}
}

Просмотреть файл

@ -0,0 +1,59 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*
* This Original Code has been modified by IBM Corporation.
* Modifications made by IBM described herein are
* Copyright (c) International Business Machines
* Corporation, 2000
*
* Modifications to Mozilla code or documentation
* identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 04/20/2000 IBM Corp. OS/2 VisualAge build.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the native code implementation of JS's JavaObject class.
*
* An instance of JavaObject is the JavaScript reflection of a Java object.
*
*/
#include <stdlib.h>
#include <string.h>
/* snip ... */

Просмотреть файл

@ -0,0 +1,64 @@
<?xml version="1.0"?>
<!--
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The Original Code is mozilla.org code.
-
- The Initial Developer of the Original Code is Netscape
- Communications Corp. Portions created by Netscape are
- Copyright (C) 2001 Netscape Communications Corp. All
- Rights Reserved.
-
- Contributor(s):
- Bob Lord <lord@netscape.com>
- Ian McGreer <mcgreer@netscape.com>
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://pippki/locale/certManager.dtd">
<overlay id="CAOverlay"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cert="http://netscape.com/rdf-cert#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox id="CACerts">
<description>&certmgr.cas;</description>
<separator class="thin"/>
<tree id="ca-tree" flex="1" enableColumnDrag="true"
onselect="ca_enableButtons()">
<treecols>
<treecol id="certcol" label="&certmgr.certname;" primary="true"
persist="hidden width ordinal" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="tokencol" label="&certmgr.tokenname;"
persist="hidden width ordinal" flex="1"/>
<!-- <treecol id="certdbkeycol" collapsed="true" flex="1"/> -->
</treecols>
<treechildren ondblclick="viewCerts();"/>
</tree>
<hbox>
<button id="ca_viewButton"
label="&certmgr.view.label;"
disabled="true" oncommand="viewCerts();"/>
<button id="ca_editButton"
label="&certmgr.edit.label;"
disabled="true" oncommand="editCerts();"/>
<button id="ca_addButton"
label="&certmgr.restore.label;"
oncommand="addCACerts();"/>
<button id="ca_deleteButton"
label="&certmgr.delete.label;"
disabled="true" oncommand="deleteCerts();"/>
</hbox>
</vbox>
</overlay>

Просмотреть файл

@ -0,0 +1,413 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Daniel Glazman <glazman@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHTMLCSSUtils_h__
#define nsHTMLCSSUtils_h__
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
#define SPECIFIED_STYLE_TYPE 1
#define COMPUTED_STYLE_TYPE 2
class nsHTMLEditor;
typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
const char * aDefaultValueString,
const char * aPrependString, const char* aAppendString);
class nsHTMLCSSUtils
{
public:
nsHTMLCSSUtils();
~nsHTMLCSSUtils();
enum nsCSSEditableProperty {
eCSSEditableProperty_NONE=0,
eCSSEditableProperty_background_color,
eCSSEditableProperty_background_image,
eCSSEditableProperty_border,
eCSSEditableProperty_caption_side,
eCSSEditableProperty_color,
eCSSEditableProperty_float,
eCSSEditableProperty_font_family,
eCSSEditableProperty_font_size,
eCSSEditableProperty_font_style,
eCSSEditableProperty_font_weight,
eCSSEditableProperty_height,
eCSSEditableProperty_list_style_type,
eCSSEditableProperty_margin_left,
eCSSEditableProperty_margin_right,
eCSSEditableProperty_text_align,
eCSSEditableProperty_text_decoration,
eCSSEditableProperty_vertical_align,
eCSSEditableProperty_whitespace,
eCSSEditableProperty_width
};
struct CSSEquivTable {
nsCSSEditableProperty cssProperty;
nsProcessValueFunc processValueFunctor;
const char * defaultValue;
const char * prependValue;
const char * appendValue;
PRBool gettable;
PRBool caseSensitiveValue;
};
public:
nsresult Init(nsHTMLEditor * aEditor);
/** answers true if the given combination element_name/attribute_name
* has a CSS equivalence in this implementation
*
* @return a boolean saying if the tag/attribute has a css equiv
* @param aNode [IN] a DOM node
* @param aProperty [IN] an atom containing a HTML tag name
* @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above
*/
PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute);
/** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] an atom containing the CSS property to set
* @param aValue [IN] a string containing the value of the CSS property
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
const nsAString & aValue,
PRBool aSuppressTransaction);
nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
const nsAString & aPropertyValue, PRBool aSuppressTransaction);
/** directly adds/remove a CSS declaration to the STYLE atrribute carried by
* a given element without going through the txn manager
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a string containing the CSS property to set/remove
* @param aValue [IN] a string containing the new value of the CSS property
*/
nsresult SetCSSProperty(nsIDOMElement * aElement,
const nsAString & aProperty,
const nsAString & aValue);
nsresult RemoveCSSProperty(nsIDOMElement * aElement,
const nsAString & aProperty);
/** gets the specified/computed style value of a CSS property for a given node (or its element
* ancestor if it is not an element)
*
* @param aNode [IN] a DOM node
* @param aProperty [IN] an atom containing the CSS property to get
* @param aPropertyValue [OUT] the retrieved value of the property
*/
nsresult GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
nsAString & aValue);
nsresult GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
nsAString & aValue);
/** Removes a CSS property from the specified declarations in STYLE attribute
** and removes the node if it is an useless span
*
* @param aNode [IN] the specific node we want to remove a style from
* @param aProperty [IN] the CSS property atom to remove
* @param aPropertyValue [IN] the value of the property we have to rremove if the property
* accepts more than one value
*/
nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
/** Answers true is the property can be removed by setting a "none" CSS value
* on a node
*
* @return a boolean saying if the property can be remove by setting a "none" value
* @param aProperty [IN] an atom containing a CSS property
* @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
*/
PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute);
/** Get the default browser background color if we need it for GetCSSBackgroundColorState
*
* @param aColor [OUT] the default color as it is defined in prefs
*/
nsresult GetDefaultBackgroundColor(nsAString & aColor);
/** Get the default length unit used for CSS Indent/Outdent
*
* @param aLengthUnit [OUT] the default length unit as it is defined in prefs
*/
nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
/** asnwers true if the element aElement carries an ID or a class
*
* @param aElement [IN] a DOM element
* @param aReturn [OUT] the boolean answer
*/
nsresult HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn);
/** returns the list of values for the CSS equivalences to
* the passed HTML style for the passed node
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValueString [OUT] the list of css values
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
nsAString & aValueString,
PRUint8 aStyleType);
/** Does the node aNode (or his parent if it is not an element node) carries
* the CSS equivalent styles to the HTML style for this node ?
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aIsSet [OUT] a boolean being true if the css properties are set
* @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
PRBool & aIsSet,
nsAString & aValueString,
PRUint8 aStyleType);
/** Adds to the node the CSS inline styles equivalent to the HTML style
* and return the number of CSS properties set by the call
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aCount [OUT] the number of CSS properties set by the call
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
const nsAString * aValue,
PRInt32 * aCount,
PRBool aSuppressTransaction);
/** removes from the node the CSS inline styles equivalent to the HTML style
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
nsIAtom *aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
PRBool aSuppressTransaction);
/** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
* we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
* implemented
*
* @param aString [IN] input string to parse
* @param aValue [OUT] numeric part
* @param aUnit [OUT] unit part
*/
void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
/** sets the mIsCSSPrefChecked private member ; used as callback from observer when
* the css pref state is changed
*
* @param aIsCSSPrefChecked [IN] the new boolean state for the pref
*/
nsresult SetCSSEnabled(PRBool aIsCSSPrefChecked);
/** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
* false if it is not
*
* @return the boolean value of the css pref
*/
PRBool IsCSSPrefChecked();
/** ElementsSameStyle compares two elements and checks if they have the same
* specified CSS declarations in the STYLE attribute
* The answer is always false if at least one of them carries an ID or a class
*
* @return true if the two elements are considered to have same styles
* @param aFirstNode [IN] a DOM node
* @param aSecondNode [IN] a DOM node
*/
PRBool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
/** get the specified inline styles (style attribute) for an element
*
* @param aElement [IN] the element node
* @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
* @param aLength [OUT] the number of declarations in aCssDecl
*/
nsresult GetInlineStyles(nsIDOMElement * aElement, nsIDOMCSSStyleDeclaration ** aCssDecl,
PRUint32 * aLength);
/** returns aNode itself if it is an element node, or the first ancestors being an element
* node if aNode is not one itself
*
* @param aNode [IN] a node
* @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
*/
nsresult GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** aElement);
/** Gets the default DOMView for a given node
*
* @param aNode the node we want the default DOMView for
* @param aViewCSS [OUT] the default DOMViewCSS
*/
nsresult GetDefaultViewCSS(nsIDOMNode * aNode, nsIDOMViewCSS ** aViewCSS);
private:
/** retrieves the css property atom from an enum
*
* @param aProperty [IN] the enum value for the property
* @param aAtom [OUT] the corresponding atom
*/
void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
/** retrieves the CSS declarations equivalent to a HTML style value for
* a given equivalence table
*
* @param aPropertyArray [OUT] the array of css properties
* @param aValueArray [OUT] the array of values for the css properties above
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
nsStringArray & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aPropertyArray [OUT] the array of css properties
* @param aValueArray [OUT] the array of values for the css properties above
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
nsStringArray & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
* @param aRemoveProperty [IN] true if we create a "remove" transaction, false for a "set"
*/
nsresult CreateCSSPropertyTxn(nsIDOMElement * aElement,
nsIAtom * aProperty,
const nsAString & aValue,
ChangeCSSInlineStyleTxn ** aTxn,
PRBool aRemoveProperty);
/** back-end for GetSpecifiedProperty and GetComputedProperty
*
* @param aNode [IN] a DOM node
* @param aProperty [IN] a CSS property
* @param aValue [OUT] the retrieved value for this property
* @param aViewCSS [IN] the ViewCSS we need in case we query computed styles
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult GetCSSInlinePropertyBase(nsIDOMNode * aNode, nsIAtom * aProperty,
nsAString & aValue,
nsIDOMViewCSS * aViewCSS,
PRUint8 aStyleType);
private:
nsHTMLEditor *mHTMLEditor;
PRBool mIsCSSPrefChecked;
};
nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
#define NS_EDITOR_INDENT_INCREMENT_EM 3
#define NS_EDITOR_INDENT_INCREMENT_EX 6
#define NS_EDITOR_INDENT_INCREMENT_PX 40
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
#endif /* nsHTMLCSSUtils_h__ */

Просмотреть файл

@ -0,0 +1,118 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator"
content="HTML Tidy for Mac OS, see www.w3.org" />
<title>thead_align_center.xml</title>
<!-- Modified: Changed doctype to xhtml 1.0 transitional Author: Chris Petersen Date: 2/01/01 -->
<!--
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The Original Code is Mozilla Communicator Test Cases.
-
- The Initial Developer of the Original Code is Netscape Communications
- Corp. Portions created by Netscape Communications Corp. are
- Copyright (C) 1999 Netscape Communications Corp. All
- Rights Reserved.
-
- Contributor(s):Christine Dreckman Date: 1/13/99
Chris Petersen Date: 5/18/99
Christine Dreckman Date: 9/7/2000
-->
</head>
<body>
<p>In this test, the THEAD text should be center aligned</p>
<table border="1">
<thead align="center">
<tr>
<td>THEAD</td>
</tr>
</thead>
<tfoot>
<tr>
<td>This text is in the TFOOT</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>This text is in the TBODY</td>
</tr>
</tbody>
</table>
</body>
</html>

Просмотреть файл

@ -0,0 +1 @@
fallback_initial_copyright_date=2001

Просмотреть файл

@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License
* at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Initial Developers of this code under the MPL are Owen Taylor
* <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developers are Copyright (C) 1999
* Owen Taylor and Christopher Blizzard. All Rights Reserved. */
#ifndef __GTK_MOZAREA_H__
#define __GTK_MOZAREA_H__
#include <gtk/gtkwindow.h>
#include "gdksuperwin.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GtkMozArea GtkMozArea;
typedef struct _GtkMozAreaClass GtkMozAreaClass;
#define GTK_TYPE_MOZAREA (gtk_mozarea_get_type ())
#define GTK_MOZAREA(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MOZAREA, GtkMozArea))
#define GTK_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZAREA, GtkMozAreaClass))
#define GTK_IS_MOZAREA(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZAREA))
#define GTK_IS_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZAREA))
struct _GtkMozArea
{
GtkWidget widget;
GdkSuperWin *superwin;
gboolean toplevel_focus;
/* store away the toplevel window */
GdkWindow *toplevel_window;
};
struct _GtkMozAreaClass
{
GtkWindowClass window_class;
/* signals */
void (* toplevel_focus_in ) (GtkMozArea *area);
void (* toplevel_focus_out) (GtkMozArea *area);
void (* toplevel_configure) (GtkMozArea *area);
};
GtkType gtk_mozarea_get_type (void);
GtkWidget *gtk_mozarea_new ();
gboolean gtk_mozarea_get_toplevel_focus(GtkMozArea *area);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_MOZAREA_H__ */

Просмотреть файл

@ -0,0 +1 @@
fallback_original_code_is=mozilla.org code

Просмотреть файл

@ -0,0 +1,398 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Daniel Glazman <glazman@netscape.com>, foo@bar.org
* ***** END LICENSE BLOCK ***** */
#ifndef nsHTMLCSSUtils_h__
#define nsHTMLCSSUtils_h__
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
#define SPECIFIED_STYLE_TYPE 1
#define COMPUTED_STYLE_TYPE 2
class nsHTMLEditor;
typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
const char * aDefaultValueString,
const char * aPrependString, const char* aAppendString);
class nsHTMLCSSUtils
{
public:
nsHTMLCSSUtils();
~nsHTMLCSSUtils();
enum nsCSSEditableProperty {
eCSSEditableProperty_NONE=0,
eCSSEditableProperty_background_color,
eCSSEditableProperty_background_image,
eCSSEditableProperty_border,
eCSSEditableProperty_caption_side,
eCSSEditableProperty_color,
eCSSEditableProperty_float,
eCSSEditableProperty_font_family,
eCSSEditableProperty_font_size,
eCSSEditableProperty_font_style,
eCSSEditableProperty_font_weight,
eCSSEditableProperty_height,
eCSSEditableProperty_list_style_type,
eCSSEditableProperty_margin_left,
eCSSEditableProperty_margin_right,
eCSSEditableProperty_text_align,
eCSSEditableProperty_text_decoration,
eCSSEditableProperty_vertical_align,
eCSSEditableProperty_whitespace,
eCSSEditableProperty_width
};
struct CSSEquivTable {
nsCSSEditableProperty cssProperty;
nsProcessValueFunc processValueFunctor;
const char * defaultValue;
const char * prependValue;
const char * appendValue;
PRBool gettable;
PRBool caseSensitiveValue;
};
public:
nsresult Init(nsHTMLEditor * aEditor);
/** answers true if the given combination element_name/attribute_name
* has a CSS equivalence in this implementation
*
* @return a boolean saying if the tag/attribute has a css equiv
* @param aNode [IN] a DOM node
* @param aProperty [IN] an atom containing a HTML tag name
* @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above
*/
PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute);
/** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] an atom containing the CSS property to set
* @param aValue [IN] a string containing the value of the CSS property
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
const nsAString & aValue,
PRBool aSuppressTransaction);
nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
const nsAString & aPropertyValue, PRBool aSuppressTransaction);
/** directly adds/remove a CSS declaration to the STYLE atrribute carried by
* a given element without going through the txn manager
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a string containing the CSS property to set/remove
* @param aValue [IN] a string containing the new value of the CSS property
*/
nsresult SetCSSProperty(nsIDOMElement * aElement,
const nsAString & aProperty,
const nsAString & aValue);
nsresult RemoveCSSProperty(nsIDOMElement * aElement,
const nsAString & aProperty);
/** gets the specified/computed style value of a CSS property for a given node (or its element
* ancestor if it is not an element)
*
* @param aNode [IN] a DOM node
* @param aProperty [IN] an atom containing the CSS property to get
* @param aPropertyValue [OUT] the retrieved value of the property
*/
nsresult GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
nsAString & aValue);
nsresult GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
nsAString & aValue);
/** Removes a CSS property from the specified declarations in STYLE attribute
** and removes the node if it is an useless span
*
* @param aNode [IN] the specific node we want to remove a style from
* @param aProperty [IN] the CSS property atom to remove
* @param aPropertyValue [IN] the value of the property we have to rremove if the property
* accepts more than one value
*/
nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
/** Answers true is the property can be removed by setting a "none" CSS value
* on a node
*
* @return a boolean saying if the property can be remove by setting a "none" value
* @param aProperty [IN] an atom containing a CSS property
* @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
*/
PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute);
/** Get the default browser background color if we need it for GetCSSBackgroundColorState
*
* @param aColor [OUT] the default color as it is defined in prefs
*/
nsresult GetDefaultBackgroundColor(nsAString & aColor);
/** Get the default length unit used for CSS Indent/Outdent
*
* @param aLengthUnit [OUT] the default length unit as it is defined in prefs
*/
nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
/** asnwers true if the element aElement carries an ID or a class
*
* @param aElement [IN] a DOM element
* @param aReturn [OUT] the boolean answer
*/
nsresult HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn);
/** returns the list of values for the CSS equivalences to
* the passed HTML style for the passed node
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValueString [OUT] the list of css values
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
nsAString & aValueString,
PRUint8 aStyleType);
/** Does the node aNode (or his parent if it is not an element node) carries
* the CSS equivalent styles to the HTML style for this node ?
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aIsSet [OUT] a boolean being true if the css properties are set
* @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
PRBool & aIsSet,
nsAString & aValueString,
PRUint8 aStyleType);
/** Adds to the node the CSS inline styles equivalent to the HTML style
* and return the number of CSS properties set by the call
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aCount [OUT] the number of CSS properties set by the call
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
const nsAString * aValue,
PRInt32 * aCount,
PRBool aSuppressTransaction);
/** removes from the node the CSS inline styles equivalent to the HTML style
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
nsIAtom *aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
PRBool aSuppressTransaction);
/** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
* we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
* implemented
*
* @param aString [IN] input string to parse
* @param aValue [OUT] numeric part
* @param aUnit [OUT] unit part
*/
void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
/** sets the mIsCSSPrefChecked private member ; used as callback from observer when
* the css pref state is changed
*
* @param aIsCSSPrefChecked [IN] the new boolean state for the pref
*/
nsresult SetCSSEnabled(PRBool aIsCSSPrefChecked);
/** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
* false if it is not
*
* @return the boolean value of the css pref
*/
PRBool IsCSSPrefChecked();
/** ElementsSameStyle compares two elements and checks if they have the same
* specified CSS declarations in the STYLE attribute
* The answer is always false if at least one of them carries an ID or a class
*
* @return true if the two elements are considered to have same styles
* @param aFirstNode [IN] a DOM node
* @param aSecondNode [IN] a DOM node
*/
PRBool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
/** get the specified inline styles (style attribute) for an element
*
* @param aElement [IN] the element node
* @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
* @param aLength [OUT] the number of declarations in aCssDecl
*/
nsresult GetInlineStyles(nsIDOMElement * aElement, nsIDOMCSSStyleDeclaration ** aCssDecl,
PRUint32 * aLength);
/** returns aNode itself if it is an element node, or the first ancestors being an element
* node if aNode is not one itself
*
* @param aNode [IN] a node
* @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
*/
nsresult GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** aElement);
/** Gets the default DOMView for a given node
*
* @param aNode the node we want the default DOMView for
* @param aViewCSS [OUT] the default DOMViewCSS
*/
nsresult GetDefaultViewCSS(nsIDOMNode * aNode, nsIDOMViewCSS ** aViewCSS);
private:
/** retrieves the css property atom from an enum
*
* @param aProperty [IN] the enum value for the property
* @param aAtom [OUT] the corresponding atom
*/
void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
/** retrieves the CSS declarations equivalent to a HTML style value for
* a given equivalence table
*
* @param aPropertyArray [OUT] the array of css properties
* @param aValueArray [OUT] the array of values for the css properties above
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
nsStringArray & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aPropertyArray [OUT] the array of css properties
* @param aValueArray [OUT] the array of values for the css properties above
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
nsStringArray & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
* @param aRemoveProperty [IN] true if we create a "remove" transaction, false for a "set"
*/
nsresult CreateCSSPropertyTxn(nsIDOMElement * aElement,
nsIAtom * aProperty,
const nsAString & aValue,
ChangeCSSInlineStyleTxn ** aTxn,
PRBool aRemoveProperty);
/** back-end for GetSpecifiedProperty and GetComputedProperty
*
* @param aNode [IN] a DOM node
* @param aProperty [IN] a CSS property
* @param aValue [OUT] the retrieved value for this property
* @param aViewCSS [IN] the ViewCSS we need in case we query computed styles
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult GetCSSInlinePropertyBase(nsIDOMNode * aNode, nsIAtom * aProperty,
nsAString & aValue,
nsIDOMViewCSS * aViewCSS,
PRUint8 aStyleType);
private:
nsHTMLEditor *mHTMLEditor;
PRBool mIsCSSPrefChecked;
};
nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
#define NS_EDITOR_INDENT_INCREMENT_EM 3
#define NS_EDITOR_INDENT_INCREMENT_EX 6
#define NS_EDITOR_INDENT_INCREMENT_PX 40
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
#endif /* nsHTMLCSSUtils_h__ */

Просмотреть файл

@ -0,0 +1,41 @@
#!env perl
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2002 Netscape Communications Corporation. All
# Rights Reserved.
use File::Spec::Unix;
use strict;
print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2);
my $finish = my_canonpath(shift);
my $start = my_canonpath(shift);
my $res = File::Spec::Unix->abs2rel($finish, $start);
#print STDERR "abs2rel($finish,$start) = $res\n";
print "$res\n";
sub my_canonpath($) {
my ($file) = @_;
my (@inlist, @outlist, $dir);
# Do what File::Spec::Unix->no_upwards should do
my @inlist = split(/\//, File::Spec::Unix->canonpath($file));
foreach $dir (@inlist) {
if ($dir eq '..') {
pop @outlist;
} else {
push @outlist, $dir;
}
}
$file = join '/',@outlist;
return $file;
}

Просмотреть файл

@ -0,0 +1 @@
fallback_original_code_is=mozilla.org code

Просмотреть файл

@ -0,0 +1,46 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is Mozilla Communicator client code, released
# March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#
# This Original Code has been modified by IBM Corporation.
# Modifications made by IBM described herein are
# Copyright (c) International Business Machines
# Corporation, 2000
#
# Modifications to Mozilla code or documentation
# identified per MPL Section 3.3
#
# Date Modified by Description of modification
# 04/20/2000 IBM Corp. OS/2 VisualAge build.
use strict;
# snip ...

Просмотреть файл

@ -0,0 +1,6 @@
// This is my own personal LiceNse.
int main(void) {
return 0;
}

Просмотреть файл

@ -0,0 +1 @@
This line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: relicense_tmp/bad_contributor_section.cpp:20: ' * Keith Visco '

Просмотреть файл

@ -0,0 +1,65 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK *****
*
* This Original Code has been modified by IBM Corporation.
* Modifications made by IBM described herein are
* Copyright (c) International Business Machines
* Corporation, 2000
*
* Modifications to Mozilla code or documentation
* identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 04/20/2000 IBM Corp. OS/2 VisualAge build.
*/
/*
* This file is part of the Java-vendor-neutral implementation of LiveConnect
*
* It contains the native code implementation of JS's JavaObject class.
*
* An instance of JavaObject is the JavaScript reflection of a Java object.
*
*/
#include <stdlib.h>
#include <string.h>
/* snip ... */

Просмотреть файл

@ -0,0 +1,79 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.org code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corp.
- Portions created by the Initial Developer are Copyright (C) 2001
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Bob Lord <lord@netscape.com>
- Ian McGreer <mcgreer@netscape.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
- or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://pippki/locale/certManager.dtd">
<overlay id="CAOverlay"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cert="http://netscape.com/rdf-cert#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox id="CACerts">
<description>&certmgr.cas;</description>
<separator class="thin"/>
<tree id="ca-tree" flex="1" enableColumnDrag="true"
onselect="ca_enableButtons()">
<treecols>
<treecol id="certcol" label="&certmgr.certname;" primary="true"
persist="hidden width ordinal" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="tokencol" label="&certmgr.tokenname;"
persist="hidden width ordinal" flex="1"/>
<!-- <treecol id="certdbkeycol" collapsed="true" flex="1"/> -->
</treecols>
<treechildren ondblclick="viewCerts();"/>
</tree>
<hbox>
<button id="ca_viewButton"
label="&certmgr.view.label;"
disabled="true" oncommand="viewCerts();"/>
<button id="ca_editButton"
label="&certmgr.edit.label;"
disabled="true" oncommand="editCerts();"/>
<button id="ca_addButton"
label="&certmgr.restore.label;"
oncommand="addCACerts();"/>
<button id="ca_deleteButton"
label="&certmgr.delete.label;"
disabled="true" oncommand="deleteCerts();"/>
</hbox>
</vbox>
</overlay>

Просмотреть файл

@ -0,0 +1,412 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Daniel Glazman <glazman@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHTMLCSSUtils_h__
#define nsHTMLCSSUtils_h__
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
#define SPECIFIED_STYLE_TYPE 1
#define COMPUTED_STYLE_TYPE 2
class nsHTMLEditor;
typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
const char * aDefaultValueString,
const char * aPrependString, const char* aAppendString);
class nsHTMLCSSUtils
{
public:
nsHTMLCSSUtils();
~nsHTMLCSSUtils();
enum nsCSSEditableProperty {
eCSSEditableProperty_NONE=0,
eCSSEditableProperty_background_color,
eCSSEditableProperty_background_image,
eCSSEditableProperty_border,
eCSSEditableProperty_caption_side,
eCSSEditableProperty_color,
eCSSEditableProperty_float,
eCSSEditableProperty_font_family,
eCSSEditableProperty_font_size,
eCSSEditableProperty_font_style,
eCSSEditableProperty_font_weight,
eCSSEditableProperty_height,
eCSSEditableProperty_list_style_type,
eCSSEditableProperty_margin_left,
eCSSEditableProperty_margin_right,
eCSSEditableProperty_text_align,
eCSSEditableProperty_text_decoration,
eCSSEditableProperty_vertical_align,
eCSSEditableProperty_whitespace,
eCSSEditableProperty_width
};
struct CSSEquivTable {
nsCSSEditableProperty cssProperty;
nsProcessValueFunc processValueFunctor;
const char * defaultValue;
const char * prependValue;
const char * appendValue;
PRBool gettable;
PRBool caseSensitiveValue;
};
public:
nsresult Init(nsHTMLEditor * aEditor);
/** answers true if the given combination element_name/attribute_name
* has a CSS equivalence in this implementation
*
* @return a boolean saying if the tag/attribute has a css equiv
* @param aNode [IN] a DOM node
* @param aProperty [IN] an atom containing a HTML tag name
* @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above
*/
PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute);
/** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] an atom containing the CSS property to set
* @param aValue [IN] a string containing the value of the CSS property
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
const nsAString & aValue,
PRBool aSuppressTransaction);
nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
const nsAString & aPropertyValue, PRBool aSuppressTransaction);
/** directly adds/remove a CSS declaration to the STYLE atrribute carried by
* a given element without going through the txn manager
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a string containing the CSS property to set/remove
* @param aValue [IN] a string containing the new value of the CSS property
*/
nsresult SetCSSProperty(nsIDOMElement * aElement,
const nsAString & aProperty,
const nsAString & aValue);
nsresult RemoveCSSProperty(nsIDOMElement * aElement,
const nsAString & aProperty);
/** gets the specified/computed style value of a CSS property for a given node (or its element
* ancestor if it is not an element)
*
* @param aNode [IN] a DOM node
* @param aProperty [IN] an atom containing the CSS property to get
* @param aPropertyValue [OUT] the retrieved value of the property
*/
nsresult GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
nsAString & aValue);
nsresult GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
nsAString & aValue);
/** Removes a CSS property from the specified declarations in STYLE attribute
** and removes the node if it is an useless span
*
* @param aNode [IN] the specific node we want to remove a style from
* @param aProperty [IN] the CSS property atom to remove
* @param aPropertyValue [IN] the value of the property we have to rremove if the property
* accepts more than one value
*/
nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
/** Answers true is the property can be removed by setting a "none" CSS value
* on a node
*
* @return a boolean saying if the property can be remove by setting a "none" value
* @param aProperty [IN] an atom containing a CSS property
* @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
*/
PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute);
/** Get the default browser background color if we need it for GetCSSBackgroundColorState
*
* @param aColor [OUT] the default color as it is defined in prefs
*/
nsresult GetDefaultBackgroundColor(nsAString & aColor);
/** Get the default length unit used for CSS Indent/Outdent
*
* @param aLengthUnit [OUT] the default length unit as it is defined in prefs
*/
nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
/** asnwers true if the element aElement carries an ID or a class
*
* @param aElement [IN] a DOM element
* @param aReturn [OUT] the boolean answer
*/
nsresult HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn);
/** returns the list of values for the CSS equivalences to
* the passed HTML style for the passed node
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValueString [OUT] the list of css values
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
nsAString & aValueString,
PRUint8 aStyleType);
/** Does the node aNode (or his parent if it is not an element node) carries
* the CSS equivalent styles to the HTML style for this node ?
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aIsSet [OUT] a boolean being true if the css properties are set
* @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
PRBool & aIsSet,
nsAString & aValueString,
PRUint8 aStyleType);
/** Adds to the node the CSS inline styles equivalent to the HTML style
* and return the number of CSS properties set by the call
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aCount [OUT] the number of CSS properties set by the call
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
const nsAString * aValue,
PRInt32 * aCount,
PRBool aSuppressTransaction);
/** removes from the node the CSS inline styles equivalent to the HTML style
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
nsIAtom *aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
PRBool aSuppressTransaction);
/** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
* we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
* implemented
*
* @param aString [IN] input string to parse
* @param aValue [OUT] numeric part
* @param aUnit [OUT] unit part
*/
void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
/** sets the mIsCSSPrefChecked private member ; used as callback from observer when
* the css pref state is changed
*
* @param aIsCSSPrefChecked [IN] the new boolean state for the pref
*/
nsresult SetCSSEnabled(PRBool aIsCSSPrefChecked);
/** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
* false if it is not
*
* @return the boolean value of the css pref
*/
PRBool IsCSSPrefChecked();
/** ElementsSameStyle compares two elements and checks if they have the same
* specified CSS declarations in the STYLE attribute
* The answer is always false if at least one of them carries an ID or a class
*
* @return true if the two elements are considered to have same styles
* @param aFirstNode [IN] a DOM node
* @param aSecondNode [IN] a DOM node
*/
PRBool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
/** get the specified inline styles (style attribute) for an element
*
* @param aElement [IN] the element node
* @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
* @param aLength [OUT] the number of declarations in aCssDecl
*/
nsresult GetInlineStyles(nsIDOMElement * aElement, nsIDOMCSSStyleDeclaration ** aCssDecl,
PRUint32 * aLength);
/** returns aNode itself if it is an element node, or the first ancestors being an element
* node if aNode is not one itself
*
* @param aNode [IN] a node
* @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
*/
nsresult GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** aElement);
/** Gets the default DOMView for a given node
*
* @param aNode the node we want the default DOMView for
* @param aViewCSS [OUT] the default DOMViewCSS
*/
nsresult GetDefaultViewCSS(nsIDOMNode * aNode, nsIDOMViewCSS ** aViewCSS);
private:
/** retrieves the css property atom from an enum
*
* @param aProperty [IN] the enum value for the property
* @param aAtom [OUT] the corresponding atom
*/
void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
/** retrieves the CSS declarations equivalent to a HTML style value for
* a given equivalence table
*
* @param aPropertyArray [OUT] the array of css properties
* @param aValueArray [OUT] the array of values for the css properties above
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
nsStringArray & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aPropertyArray [OUT] the array of css properties
* @param aValueArray [OUT] the array of values for the css properties above
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
nsStringArray & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
* @param aRemoveProperty [IN] true if we create a "remove" transaction, false for a "set"
*/
nsresult CreateCSSPropertyTxn(nsIDOMElement * aElement,
nsIAtom * aProperty,
const nsAString & aValue,
ChangeCSSInlineStyleTxn ** aTxn,
PRBool aRemoveProperty);
/** back-end for GetSpecifiedProperty and GetComputedProperty
*
* @param aNode [IN] a DOM node
* @param aProperty [IN] a CSS property
* @param aValue [OUT] the retrieved value for this property
* @param aViewCSS [IN] the ViewCSS we need in case we query computed styles
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult GetCSSInlinePropertyBase(nsIDOMNode * aNode, nsIAtom * aProperty,
nsAString & aValue,
nsIDOMViewCSS * aViewCSS,
PRUint8 aStyleType);
private:
nsHTMLEditor *mHTMLEditor;
PRBool mIsCSSPrefChecked;
};
nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
#define NS_EDITOR_INDENT_INCREMENT_EM 3
#define NS_EDITOR_INDENT_INCREMENT_EX 6
#define NS_EDITOR_INDENT_INCREMENT_PX 40
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
#endif /* nsHTMLCSSUtils_h__ */

Просмотреть файл

@ -0,0 +1,107 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator"
content="HTML Tidy for Mac OS, see www.w3.org" />
<title>thead_align_center.xml</title>
<!-- Modified: Changed doctype to xhtml 1.0 transitional Author: Chris Petersen Date: 2/01/01 -->
<!--
- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is Mozilla Communicator Test Cases.
-
- The Initial Developer of the Original Code is
- Netscape Communications.
- Portions created by the Initial Developer are Copyright (C) 2001
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Christine Dreckman Date: 1/13/99
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
- or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
</head>
<body>
<p>In this test, the THEAD text should be center aligned</p>
<table border="1">
<thead align="center">
<tr>
<td>THEAD</td>
</tr>
</thead>
<tfoot>
<tr>
<td>This text is in the TFOOT</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>This text is in the TBODY</td>
</tr>
</tbody>
</table>
</body>
</html>

Просмотреть файл

@ -0,0 +1,86 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Owen Taylor <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __GTK_MOZAREA_H__
#define __GTK_MOZAREA_H__
#include <gtk/gtkwindow.h>
#include "gdksuperwin.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GtkMozArea GtkMozArea;
typedef struct _GtkMozAreaClass GtkMozAreaClass;
#define GTK_TYPE_MOZAREA (gtk_mozarea_get_type ())
#define GTK_MOZAREA(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MOZAREA, GtkMozArea))
#define GTK_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZAREA, GtkMozAreaClass))
#define GTK_IS_MOZAREA(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZAREA))
#define GTK_IS_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZAREA))
struct _GtkMozArea
{
GtkWidget widget;
GdkSuperWin *superwin;
gboolean toplevel_focus;
/* store away the toplevel window */
GdkWindow *toplevel_window;
};
struct _GtkMozAreaClass
{
GtkWindowClass window_class;
/* signals */
void (* toplevel_focus_in ) (GtkMozArea *area);
void (* toplevel_focus_out) (GtkMozArea *area);
void (* toplevel_configure) (GtkMozArea *area);
};
GtkType gtk_mozarea_get_type (void);
GtkWidget *gtk_mozarea_new ();
gboolean gtk_mozarea_get_toplevel_focus(GtkMozArea *area);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_MOZAREA_H__ */

Просмотреть файл

@ -0,0 +1,412 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Daniel Glazman <glazman@netscape.com>, foo@bar.org
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHTMLCSSUtils_h__
#define nsHTMLCSSUtils_h__
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIHTMLEditor.h"
#include "ChangeCSSInlineStyleTxn.h"
#include "nsEditProperty.h"
#include "nsIDOMCSSStyleDeclaration.h"
#define SPECIFIED_STYLE_TYPE 1
#define COMPUTED_STYLE_TYPE 2
class nsHTMLEditor;
typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
const char * aDefaultValueString,
const char * aPrependString, const char* aAppendString);
class nsHTMLCSSUtils
{
public:
nsHTMLCSSUtils();
~nsHTMLCSSUtils();
enum nsCSSEditableProperty {
eCSSEditableProperty_NONE=0,
eCSSEditableProperty_background_color,
eCSSEditableProperty_background_image,
eCSSEditableProperty_border,
eCSSEditableProperty_caption_side,
eCSSEditableProperty_color,
eCSSEditableProperty_float,
eCSSEditableProperty_font_family,
eCSSEditableProperty_font_size,
eCSSEditableProperty_font_style,
eCSSEditableProperty_font_weight,
eCSSEditableProperty_height,
eCSSEditableProperty_list_style_type,
eCSSEditableProperty_margin_left,
eCSSEditableProperty_margin_right,
eCSSEditableProperty_text_align,
eCSSEditableProperty_text_decoration,
eCSSEditableProperty_vertical_align,
eCSSEditableProperty_whitespace,
eCSSEditableProperty_width
};
struct CSSEquivTable {
nsCSSEditableProperty cssProperty;
nsProcessValueFunc processValueFunctor;
const char * defaultValue;
const char * prependValue;
const char * appendValue;
PRBool gettable;
PRBool caseSensitiveValue;
};
public:
nsresult Init(nsHTMLEditor * aEditor);
/** answers true if the given combination element_name/attribute_name
* has a CSS equivalence in this implementation
*
* @return a boolean saying if the tag/attribute has a css equiv
* @param aNode [IN] a DOM node
* @param aProperty [IN] an atom containing a HTML tag name
* @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above
*/
PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute);
/** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] an atom containing the CSS property to set
* @param aValue [IN] a string containing the value of the CSS property
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
const nsAString & aValue,
PRBool aSuppressTransaction);
nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
const nsAString & aPropertyValue, PRBool aSuppressTransaction);
/** directly adds/remove a CSS declaration to the STYLE atrribute carried by
* a given element without going through the txn manager
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a string containing the CSS property to set/remove
* @param aValue [IN] a string containing the new value of the CSS property
*/
nsresult SetCSSProperty(nsIDOMElement * aElement,
const nsAString & aProperty,
const nsAString & aValue);
nsresult RemoveCSSProperty(nsIDOMElement * aElement,
const nsAString & aProperty);
/** gets the specified/computed style value of a CSS property for a given node (or its element
* ancestor if it is not an element)
*
* @param aNode [IN] a DOM node
* @param aProperty [IN] an atom containing the CSS property to get
* @param aPropertyValue [OUT] the retrieved value of the property
*/
nsresult GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
nsAString & aValue);
nsresult GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
nsAString & aValue);
/** Removes a CSS property from the specified declarations in STYLE attribute
** and removes the node if it is an useless span
*
* @param aNode [IN] the specific node we want to remove a style from
* @param aProperty [IN] the CSS property atom to remove
* @param aPropertyValue [IN] the value of the property we have to rremove if the property
* accepts more than one value
*/
nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
/** Answers true is the property can be removed by setting a "none" CSS value
* on a node
*
* @return a boolean saying if the property can be remove by setting a "none" value
* @param aProperty [IN] an atom containing a CSS property
* @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
*/
PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute);
/** Get the default browser background color if we need it for GetCSSBackgroundColorState
*
* @param aColor [OUT] the default color as it is defined in prefs
*/
nsresult GetDefaultBackgroundColor(nsAString & aColor);
/** Get the default length unit used for CSS Indent/Outdent
*
* @param aLengthUnit [OUT] the default length unit as it is defined in prefs
*/
nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
/** asnwers true if the element aElement carries an ID or a class
*
* @param aElement [IN] a DOM element
* @param aReturn [OUT] the boolean answer
*/
nsresult HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn);
/** returns the list of values for the CSS equivalences to
* the passed HTML style for the passed node
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValueString [OUT] the list of css values
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
nsAString & aValueString,
PRUint8 aStyleType);
/** Does the node aNode (or his parent if it is not an element node) carries
* the CSS equivalent styles to the HTML style for this node ?
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aIsSet [OUT] a boolean being true if the css properties are set
* @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
PRBool & aIsSet,
nsAString & aValueString,
PRUint8 aStyleType);
/** Adds to the node the CSS inline styles equivalent to the HTML style
* and return the number of CSS properties set by the call
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aCount [OUT] the number of CSS properties set by the call
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString * aAttribute,
const nsAString * aValue,
PRInt32 * aCount,
PRBool aSuppressTransaction);
/** removes from the node the CSS inline styles equivalent to the HTML style
*
* @param aNode [IN] a DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aSuppressTransaction [IN] a boolean indicating, when true,
* that no transaction should be recorded
*/
nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
nsIAtom *aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
PRBool aSuppressTransaction);
/** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
* we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
* implemented
*
* @param aString [IN] input string to parse
* @param aValue [OUT] numeric part
* @param aUnit [OUT] unit part
*/
void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
/** sets the mIsCSSPrefChecked private member ; used as callback from observer when
* the css pref state is changed
*
* @param aIsCSSPrefChecked [IN] the new boolean state for the pref
*/
nsresult SetCSSEnabled(PRBool aIsCSSPrefChecked);
/** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
* false if it is not
*
* @return the boolean value of the css pref
*/
PRBool IsCSSPrefChecked();
/** ElementsSameStyle compares two elements and checks if they have the same
* specified CSS declarations in the STYLE attribute
* The answer is always false if at least one of them carries an ID or a class
*
* @return true if the two elements are considered to have same styles
* @param aFirstNode [IN] a DOM node
* @param aSecondNode [IN] a DOM node
*/
PRBool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
/** get the specified inline styles (style attribute) for an element
*
* @param aElement [IN] the element node
* @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
* @param aLength [OUT] the number of declarations in aCssDecl
*/
nsresult GetInlineStyles(nsIDOMElement * aElement, nsIDOMCSSStyleDeclaration ** aCssDecl,
PRUint32 * aLength);
/** returns aNode itself if it is an element node, or the first ancestors being an element
* node if aNode is not one itself
*
* @param aNode [IN] a node
* @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
*/
nsresult GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** aElement);
/** Gets the default DOMView for a given node
*
* @param aNode the node we want the default DOMView for
* @param aViewCSS [OUT] the default DOMViewCSS
*/
nsresult GetDefaultViewCSS(nsIDOMNode * aNode, nsIDOMViewCSS ** aViewCSS);
private:
/** retrieves the css property atom from an enum
*
* @param aProperty [IN] the enum value for the property
* @param aAtom [OUT] the corresponding atom
*/
void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
/** retrieves the CSS declarations equivalent to a HTML style value for
* a given equivalence table
*
* @param aPropertyArray [OUT] the array of css properties
* @param aValueArray [OUT] the array of values for the css properties above
* @param aEquivTable [IN] the equivalence table
* @param aValue [IN] the HTML style value
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
nsStringArray & cssValueArray,
const CSSEquivTable * aEquivTable,
const nsAString * aValue,
PRBool aGetOrRemoveRequest);
/** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
* for a given node
*
* @param aNode [IN] the DOM node
* @param aHTMLProperty [IN] an atom containing an HTML property
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
* @param aValue [IN] the attribute value
* @param aPropertyArray [OUT] the array of css properties
* @param aValueArray [OUT] the array of values for the css properties above
* @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
* is made for GetCSSEquivalentToHTMLInlineStyleSet or
* RemoveCSSEquivalentToHTMLInlineStyleSet
*/
void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
nsIAtom * aHTMLProperty,
const nsAString *aAttribute,
const nsAString *aValue,
nsVoidArray & aPropertyArray,
nsStringArray & aValueArray,
PRBool aGetOrRemoveRequest);
/** creates a Transaction for setting or removing a css property
*
* @param aElement [IN] a DOM element
* @param aProperty [IN] a CSS property
* @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
* @param aTxn [OUT] the created transaction
* @param aRemoveProperty [IN] true if we create a "remove" transaction, false for a "set"
*/
nsresult CreateCSSPropertyTxn(nsIDOMElement * aElement,
nsIAtom * aProperty,
const nsAString & aValue,
ChangeCSSInlineStyleTxn ** aTxn,
PRBool aRemoveProperty);
/** back-end for GetSpecifiedProperty and GetComputedProperty
*
* @param aNode [IN] a DOM node
* @param aProperty [IN] a CSS property
* @param aValue [OUT] the retrieved value for this property
* @param aViewCSS [IN] the ViewCSS we need in case we query computed styles
* @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
COMPUTED_STYLE_TYPE to query the computed style values
*/
nsresult GetCSSInlinePropertyBase(nsIDOMNode * aNode, nsIAtom * aProperty,
nsAString & aValue,
nsIDOMViewCSS * aViewCSS,
PRUint8 aStyleType);
private:
nsHTMLEditor *mHTMLEditor;
PRBool mIsCSSPrefChecked;
};
nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
#define NS_EDITOR_INDENT_INCREMENT_EM 3
#define NS_EDITOR_INDENT_INCREMENT_EX 6
#define NS_EDITOR_INDENT_INCREMENT_PX 40
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
#endif /* nsHTMLCSSUtils_h__ */

Просмотреть файл

@ -0,0 +1,67 @@
#!env perl
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
use File::Spec::Unix;
use strict;
print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2);
my $finish = my_canonpath(shift);
my $start = my_canonpath(shift);
my $res = File::Spec::Unix->abs2rel($finish, $start);
#print STDERR "abs2rel($finish,$start) = $res\n";
print "$res\n";
sub my_canonpath($) {
my ($file) = @_;
my (@inlist, @outlist, $dir);
# Do what File::Spec::Unix->no_upwards should do
my @inlist = split(/\//, File::Spec::Unix->canonpath($file));
foreach $dir (@inlist) {
if ($dir eq '..') {
pop @outlist;
} else {
push @outlist, $dir;
}
}
$file = join '/',@outlist;
return $file;
}

Просмотреть файл

@ -0,0 +1,52 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: NPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Netscape Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Communicator client code, released
# March 31, 1998.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the NPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the NPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
# This Original Code has been modified by IBM Corporation.
# Modifications made by IBM described herein are
# Copyright (c) International Business Machines
# Corporation, 2000
#
# Modifications to Mozilla code or documentation
# identified per MPL Section 3.3
#
# Date Modified by Description of modification
# 04/20/2000 IBM Corp. OS/2 VisualAge build.
use strict;
# snip ...

Просмотреть файл

@ -0,0 +1 @@
relicense_tmp/unknown_license.c: unknown license (possibly) found

169
tools/relic/test/test.py Executable file
Просмотреть файл

@ -0,0 +1,169 @@
#!python
# Copyright (c) 2004 Trent Mick
"""
relic.py Regression Test Suite Harness
Usage:
python test.py [<options>...] [<tests>...]
Options:
-x <testname>, --exclude=<testname>
Exclude the named test from the set of tests to be
run. This can be used multiple times to specify
multiple exclusions.
-v, --verbose run tests in verbose mode with output to stdout
-q, --quiet don't print anything except if a test fails
-h, --help print this text and exit
This will find all modules whose name is "test_*" in the test
directory, and run them. Various command line options provide
additional facilities.
If non-option arguments are present, they are names for tests to run.
If no test names are given, all tests are run.
Test Setup Options:
-c, --clean Don't setup, just clean up the test workspace.
-n, --no-clean Don't clean up after setting up and running the
test suite.
"""
import os
import sys
import getopt
import glob
import time
import types
import tempfile
import unittest
#---- exceptions
class TestError(Exception):
pass
#---- globals
gVerbosity = 2
#---- utility routines
def _rmtreeOnError(rmFunction, filePath, excInfo):
if excInfo[0] == OSError:
# presuming because file is read-only
os.chmod(filePath, 0777)
rmFunction(filePath)
def _rmtree(dirname):
import shutil
shutil.rmtree(dirname, 0, _rmtreeOnError)
def _getAllTests(testDir):
"""Return a list of all tests to run."""
testPyFiles = glob.glob(os.path.join(testDir, "test_*.py"))
modules = [f[:-3] for f in testPyFiles if f and f.endswith(".py")]
packages = []
for f in glob.glob(os.path.join(testDir, "test_*")):
if os.path.isdir(f) and "." not in f:
if os.path.isfile(os.path.join(testDir, f, "__init__.py")):
packages.append(f)
return modules + packages
def _setUp():
# Ensure the *development* check is tested.
topDir = os.path.abspath(os.pardir)
sys.path.insert(0, topDir)
print "Setup to test:"
import relic
ver = "%s.%s.%s" % relic._version_
print "relic %s at '%s'" % (ver, relic.__file__)
print "-"*70 + '\n'
def _tearDown():
pass
def test(testModules, testDir=os.curdir, exclude=[]):
"""Run the given regression tests and report the results."""
# Determine the test modules to run.
if not testModules:
testModules = _getAllTests(testDir)
testModules = [t for t in testModules if t not in exclude]
# Aggregate the TestSuite's from each module into one big one.
allSuites = []
for moduleFile in testModules:
module = __import__(moduleFile, globals(), locals(), [])
suite = getattr(module, "suite", None)
if suite is not None:
allSuites.append(suite())
else:
if gVerbosity >= 2:
print "WARNING: module '%s' did not have a suite() method."\
% moduleFile
suite = unittest.TestSuite(allSuites)
# Run the suite.
runner = unittest.TextTestRunner(sys.stdout, verbosity=gVerbosity)
result = runner.run(suite)
#---- mainline
def main(argv):
testDir = os.path.dirname(sys.argv[0])
# parse options
global gVerbosity
try:
opts, testModules = getopt.getopt(sys.argv[1:], 'hvqx:cn',
['help', 'verbose', 'quiet', 'exclude=', 'clean',
'no-clean'])
except getopt.error, ex:
print "%s: ERROR: %s" % (argv[0], ex)
print __doc__
sys.exit(2)
exclude = []
setupOpts = {}
justClean = 0
clean = 1
for opt, optarg in opts:
if opt in ("-h", "--help"):
print __doc__
sys.exit(0)
elif opt in ("-v", "--verbose"):
gVerbosity += 1
elif opt in ("-q", "--quiet"):
gVerbosity -= 1
elif opt in ("-x", "--exclude"):
exclude.append(optarg)
elif opt in ("-c", "--clean"):
justClean = 1
elif opt in ("-n", "--no-clean"):
clean = 0
retval = None
if not justClean:
_setUp(**setupOpts)
try:
if not justClean:
retval = test(testModules, testDir=testDir, exclude=exclude)
finally:
if clean:
_tearDown(**setupOpts)
return retval
if __name__ == '__main__':
sys.exit( main(sys.argv) )

Просмотреть файл

@ -0,0 +1,147 @@
#!/usr/bin/env python
#
# Copyright (c) 2004 Trent Mick
"""Test adding licenses to addlicense_inputs/... with relic.py."""
import sys
import os
import unittest
import difflib
import pprint
import shutil
import StringIO
import testsupport
#---- globals
gInputsDir = "addlicense_inputs"
gOutputsDir = "addlicense_outputs"
gTmpDir = "addlicense_tmp"
#----- test cases
class RelicInputsTestCase(unittest.TestCase):
def setUp(self):
if not os.path.exists(gTmpDir):
os.mkdir(gTmpDir)
def tearDown(self):
testsupport.rmtree(gTmpDir)
def _testOneInputFile(self, fname):
import relic
_debug = 0 # Set to true to dump status info for each test run.
infile = os.path.join(gInputsDir, fname) # input
outfile = os.path.join(gOutputsDir, fname) # expected output
tmpfile = os.path.join(gTmpDir, fname) # actual output
errfile = os.path.join(gOutputsDir, fname+'.error') # expected error
# An options file is a set of kwargs for the relic.addlicense()
# method call. One key-value pair per-line like this:
# key=value
# Whitespace is stripped off the value.
optsfile = os.path.join(gInputsDir, fname+'.options') # input options
if _debug:
print
print "*"*50, "relic '%s'" % fname
# Determine input options to use, if any.
opts = {}
if os.path.exists(optsfile):
for line in open(optsfile, 'r').read().splitlines(0):
name, value = line.split('=', 1)
value = value.strip()
try: # allow value to be a type other than string
value = eval(value)
except Exception:
pass
opts[name] = value
if _debug:
print "*"*50, "options"
pprint.pprint(opts)
else:
# If no options were specified, we presume the equivalent of the
# command-line --defaults option.
opts = {
"original_code_is": "mozilla.org Code",
"initial_copyright_date": "2001",
"initial_developer": "Netscape Communications Corporation",
}
# Copy the input file to the tmp location where relicensing is done.
shutil.copy(infile, tmpfile)
# Relicense the file, capturing stdout and stderr and any possible
# error.
oldStdout = sys.stdout
oldStderr = sys.stderr
sys.stdout = StringIO.StringIO()
sys.stderr = StringIO.StringIO()
try:
try:
relic.addlicense([tmpfile], **opts)
except relic.RelicError, ex:
error = ex
else:
error = None
finally:
stdout = sys.stdout.getvalue()
stderr = sys.stderr.getvalue()
sys.stdout = oldStdout
sys.stderr = oldStderr
if _debug:
print "*"*50, "stdout"
print stdout
print "*"*50, "stderr"
print stderr
print "*"*50, "error"
print str(error)
print "*" * 50
# Verify that the results are as expected.
if os.path.exists(outfile) and error:
self.fail("adding license '%s' raised an error but success was "
"expected: error='%s'" % (fname, str(error)))
elif os.path.exists(outfile):
expected = open(outfile, 'r').readlines()
actual = open(tmpfile, 'r').readlines()
if expected != actual:
diff = list(difflib.ndiff(expected, actual))
self.fail("%r != %r:\n%s"\
% (outfile, tmpfile, pprint.pformat(diff)))
elif os.path.exists(errfile):
# There is no reference output file. This means that processing
# this file is expected to fail.
expectedError = open(errfile, 'r').read()
actualError = str(error)
self.failUnlessEqual(actualError.strip(), expectedError.strip())
else:
self.fail("No reference ouput file or error file for '%s'." % infile)
# Ensure next test file gets a clean relic.
del sys.modules['relic']
#for fname in ["separated_license_comment_blocks.pl"]:
for fname in os.listdir(gInputsDir):
if fname.endswith(".options"): continue # skip input option files
testFunction = lambda self, fname=fname: _testOneInputFile(self, fname)
name = 'test_addlicense_'+fname
setattr(RelicInputsTestCase, name, testFunction)
#---- mainline
def suite():
"""Return a unittest.TestSuite to be used by test.py."""
return unittest.makeSuite(RelicInputsTestCase)
if __name__ == "__main__":
runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
result = runner.run(suite())

Просмотреть файл

@ -0,0 +1,139 @@
#!/usr/bin/env python
#
# Copyright (c) 2004 Trent Mick
"""Test relicensing of inputs/... with relic.py."""
import sys
import os
import unittest
import difflib
import pprint
import shutil
import StringIO
import testsupport
#---- globals
gInputsDir = "relicense_inputs"
gOutputsDir = "relicense_outputs"
gTmpDir = "relicense_tmp"
#----- test cases
class RelicInputsTestCase(unittest.TestCase):
def setUp(self):
if not os.path.exists(gTmpDir):
os.mkdir(gTmpDir)
def tearDown(self):
testsupport.rmtree(gTmpDir)
def _testOneInputFile(self, fname):
import relic
_debug = 0 # Set to true to dump status info for each test run.
infile = os.path.join(gInputsDir, fname) # input
outfile = os.path.join(gOutputsDir, fname) # expected output
tmpfile = os.path.join(gTmpDir, fname) # actual output
errfile = os.path.join(gOutputsDir, fname+'.error') # expected error
# An options file is a set of kwargs for the relic.relicense()
# method call. One key-value pair per-line like this:
# key=value
# Whitespace is stripped off the value.
optsfile = os.path.join(gInputsDir, fname+'.options') # input options
if _debug:
print
print "*"*50, "relic '%s'" % fname
# Determine input options to use, if any.
opts = {}
if os.path.exists(optsfile):
for line in open(optsfile, 'r').read().splitlines(0):
name, value = line.split('=', 1)
value = value.strip()
try: # allow value to be a type other than string
value = eval(value)
except Exception:
pass
opts[name] = value
if _debug:
print "*"*50, "options"
pprint.pprint(opts)
# Copy the input file to the tmp location where relicensing is done.
shutil.copy(infile, tmpfile)
# Relicense the file, capturing stdout and stderr and any possible
# error.
oldStdout = sys.stdout
oldStderr = sys.stderr
sys.stdout = StringIO.StringIO()
sys.stderr = StringIO.StringIO()
try:
try:
relic.relicense([tmpfile], **opts)
except relic.RelicError, ex:
error = ex
else:
error = None
finally:
stdout = sys.stdout.getvalue()
stderr = sys.stderr.getvalue()
sys.stdout = oldStdout
sys.stderr = oldStderr
if _debug:
print "*"*50, "stdout"
print stdout
print "*"*50, "stderr"
print stderr
print "*"*50, "error"
print str(error)
print "*" * 50
# Verify that the results are as expected.
if os.path.exists(outfile) and error:
self.fail("relicensing '%s' raised an error but success was "
"expected: error='%s'" % (fname, str(error)))
elif os.path.exists(outfile):
expected = open(outfile, 'r').readlines()
actual = open(tmpfile, 'r').readlines()
if expected != actual:
diff = list(difflib.ndiff(expected, actual))
self.fail("%r != %r:\n%s"\
% (outfile, tmpfile, pprint.pformat(diff)))
elif os.path.exists(errfile):
# There is no reference output file. This means that processing
# this file is expected to fail.
expectedError = open(errfile, 'r').read()
actualError = str(error)
self.failUnlessEqual(actualError.strip(), expectedError.strip())
else:
self.fail("No reference ouput file or error file for '%s'." % infile)
# Ensure next test file gets a clean relic.
del sys.modules['relic']
#for fname in ["separated_license_comment_blocks.pl"]:
for fname in os.listdir(gInputsDir):
if fname.endswith(".options"): continue # skip input option files
testFunction = lambda self, fname=fname: _testOneInputFile(self, fname)
name = 'test_relicense_'+fname
setattr(RelicInputsTestCase, name, testFunction)
#---- mainline
def suite():
"""Return a unittest.TestSuite to be used by test.py."""
return unittest.makeSuite(RelicInputsTestCase)
if __name__ == "__main__":
runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
result = runner.run(suite())

82
tools/relic/test/testsupport.py Executable file
Просмотреть файл

@ -0,0 +1,82 @@
#!/usr/bin/env python
import os
import sys
import types
import shutil
#---- Support routines
def _escapeArg(arg):
"""Escape the given command line argument for the shell."""
#XXX There is a *lot* more that we should escape here.
return arg.replace('"', r'\"')
def _joinArgv(argv):
r"""Join an arglist to a string appropriate for running.
>>> import os
>>> _joinArgv(['foo', 'bar "baz'])
'foo "bar \\"baz"'
"""
cmdstr = ""
for arg in argv:
if ' ' in arg:
cmdstr += '"%s"' % _escapeArg(arg)
else:
cmdstr += _escapeArg(arg)
cmdstr += ' '
if cmdstr.endswith(' '): cmdstr = cmdstr[:-1] # strip trailing space
return cmdstr
def run(argv):
"""Prepare and run the given arg vector, 'argv', and return the
results. Returns (<stdout lines>, <stderr lines>, <return value>).
Note: 'argv' may also just be the command string.
"""
if type(argv) in (types.ListType, types.TupleType):
cmd = _joinArgv(argv)
else:
cmd = argv
if sys.platform.startswith('win'):
i, o, e = os.popen3(cmd)
output = o.read()
error = e.read()
i.close()
e.close()
try:
retval = o.close()
except IOError:
# IOError is raised iff the spawned app returns -1. Go
# figure.
retval = -1
if retval is None:
retval = 0
else:
import popen2
p = popen2.Popen3(cmd, 1)
i, o, e = p.tochild, p.fromchild, p.childerr
output = o.read()
error = e.read()
i.close()
o.close()
e.close()
retval = (p.wait() & 0xFF00) >> 8
if retval > 2**7: # 8-bit signed 1's-complement conversion
retval -= 2**8
return output, error, retval
def _rmtreeOnError(rmFunction, filePath, excInfo):
if excInfo[0] == OSError:
# presuming because file is read-only
os.chmod(filePath, 0777)
rmFunction(filePath)
def rmtree(dirname):
import shutil
shutil.rmtree(dirname, 0, _rmtreeOnError)