Compare commits

..

3 Commits

Author SHA1 Message Date
dkl%redhat.com
b52a1dc48a Various fixes. Added CanSeeProduct functionality back in but also left in old style product groups. Removed references to usebuggroupsentry and usebuggroups since we want it on all the time.
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_Groups_Branch@122814 18797224-902f-48f8-a5cc-f745e15eee43
2002-06-06 18:07:41 +00:00
dkl%redhat.com
48b5f960fd Initial creation of Bugzilla_PgSQL_Groups_Branch 2002/05/23
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_Groups_Branch@122087 18797224-902f-48f8-a5cc-f745e15eee43
2002-05-23 19:34:21 +00:00
(no author)
73bf11394f This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_Groups_Branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_Groups_Branch@122018 18797224-902f-48f8-a5cc-f745e15eee43
2002-05-22 09:21:37 +00:00
3394 changed files with 103488 additions and 511965 deletions

View File

@@ -1,791 +0,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) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Stephen Lamm
# Benjamin Smedberg <bsmedberg@covad.net>
#
# 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 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 *****
# Build a mozilla application.
#
# To checkout and build a tree,
# 1. cvs co mozilla/client.mk
# 2. cd mozilla
# 3. create your .mozconfig file with
# mk_add_options MOZ_CO_PROJECT=suite,browser,mail,xulrunner
# 4. gmake -f client.mk
#
# This script will pick up the CVSROOT from the CVS/Root file. If you wish
# to use a different CVSROOT, you must set CVSROOT in your environment:
#
# export CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
# export CVSROOT=:pserver:username%somedomain.org@cvs.mozilla.org:/cvsroot
#
# You must specify which products/modules you wish to checkout, with
# MOZ_CO_PROJECT, MOZ_CO_MODULE, and BUILD_MODULES variables.
#
# MOZ_CO_PROJECT possibilities include the following:
# suite (Seamonkey suite)
# browser (aka Firefox)
# mail (aka Thunderbird)
# composer (standalone composer, aka NVU)
# calendar (aka Sunbird, use this to build the calendar extensions also)
# xulrunner
# macbrowser (aka Camino)
#
# Other common MOZ_CO_MODULE options include the following:
# mozilla/other-licenses/libart_lgpl
# mozilla/tools/codesighs
#
# Other targets (gmake -f client.mk [targets...]),
# checkout
# build
# clean (realclean is now the same as clean)
# distclean
#
# See http://www.mozilla.org/build/ for more information.
#
# Options:
# MOZ_OBJDIR - Destination object directory
# MOZ_CO_DATE - Date tag to use for checkout (default: none)
# MOZ_CO_MODULE - Module to checkout
# MOZ_CVS_FLAGS - Flags to pass cvs (default: -q -z3)
# MOZ_CO_FLAGS - Flags to pass after 'cvs co' (default: -P)
# MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
# MOZ_CO_LOCALES - localizations to pull (MOZ_CO_LOCALES="de-DE,pt-BR")
# MOZ_LOCALE_DIRS - directories which contain localizations
# LOCALES_CVSROOT - CVSROOT to use to pull localizations
#
AVAILABLE_PROJECTS = \
suite \
toolkit \
browser \
mail \
composer \
calendar \
xulrunner \
macbrowser \
$(NULL)
MODULES_suite := \
SeaMonkeyAll \
mozilla/ipc/ipcd \
mozilla/modules/libpr0n \
mozilla/accessible \
mozilla/security/manager \
mozilla/toolkit \
mozilla/storage \
mozilla/db/sqlite3 \
$(NULL)
MODULES_toolkit := \
$(MODULES_suite) \
mozilla/chrome \
$(NULL)
LOCALES_toolkit := \
mozilla/toolkit/locales \
$(NULL)
MODULES_browser := \
$(MODULES_toolkit) \
mozilla/browser \
mozilla/other-licenses/branding/firefox \
mozilla/other-licenses/7zstub/firefox \
$(NULL)
LOCALES_browser := \
$(LOCALES_toolkit) \
mozilla/browser/locales \
$(NULL)
BOOTSTRAP_browser := mozilla/browser/config/mozconfig
MODULES_mail := \
$(MODULES_toolkit) \
mozilla/mail \
mozilla/other-licenses/branding/thunderbird \
mozilla/other-licenses/7zstub/thunderbird \
$(NULL)
LOCALES_mail := \
$(LOCALES_toolkit) \
mozilla/mail/locales \
$(NULL)
BOOTSTRAP_mail := mozilla/mail/config/mozconfig
MODULES_composer := \
$(MODULES_toolkit) \
mozilla/composer \
$(NULL)
MODULES_calendar := \
$(MODULES_toolkit) \
mozilla/calendar \
mozilla/other-licenses/libical \
$(NULL)
BOOTSTRAP_calendar := mozilla/calendar/sunbird/config/mozconfig
MODULES_xulrunner := \
$(MODULES_toolkit) \
mozilla/xulrunner \
$(NULL)
BOOTSTRAP_xulrunner := mozilla/xulrunner/config/mozconfig
MODULES_macbrowser := \
$(MODULES_suite) \
mozilla/camino \
$(NULL)
BOOTSTRAP_macbrowser := mozilla/camino/config/mozconfig
#######################################################################
# Checkout Tags
#
# For branches, uncomment the MOZ_CO_TAG line with the proper tag,
# and commit this file on that tag.
#MOZ_CO_TAG = <tag>
NSPR_CO_TAG = NSPRPUB_PRE_4_2_CLIENT_BRANCH
NSS_CO_TAG = NSS_CLIENT_TAG
LDAPCSDK_CO_TAG = ldapcsdk_50_client_branch
LAYOUT_CO_TAG = REFLOW_20041213_BRANCH
LOCALES_CO_TAG =
BUILD_MODULES = all
#######################################################################
# Defines
#
CVS = cvs
comma := ,
CWD := $(shell pwd)
ifeq "$(CWD)" "/"
CWD := /.
endif
ifneq (, $(wildcard client.mk))
# Ran from mozilla directory
ROOTDIR := $(shell dirname $(CWD))
TOPSRCDIR := $(CWD)
else
# Ran from mozilla/.. directory (?)
ROOTDIR := $(CWD)
TOPSRCDIR := $(CWD)/mozilla
endif
# on os2, TOPSRCDIR may have two forward slashes in a row, which doesn't
# work; replace first instance with one forward slash
TOPSRCDIR := $(shell echo "$(TOPSRCDIR)" | sed -e 's%//%/%')
ifndef TOPSRCDIR_MOZ
TOPSRCDIR_MOZ=$(TOPSRCDIR)
endif
# if ROOTDIR equals only drive letter (i.e. "C:"), set to "/"
DIRNAME := $(shell echo "$(ROOTDIR)" | sed -e 's/^.://')
ifeq ($(DIRNAME),)
ROOTDIR := /.
endif
AUTOCONF := autoconf
MKDIR := mkdir
SH := /bin/sh
ifndef MAKE
MAKE := gmake
endif
CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
ifdef CONFIG_GUESS_SCRIPT
CONFIG_GUESS = $(shell $(CONFIG_GUESS_SCRIPT))
else
_IS_FIRST_CHECKOUT := 1
endif
####################################
# CVS
# Add the CVS root to CVS_FLAGS if needed
CVS_ROOT_IN_TREE := $(shell cat $(TOPSRCDIR)/CVS/Root 2>/dev/null)
ifneq ($(CVS_ROOT_IN_TREE),)
ifneq ($(CVS_ROOT_IN_TREE),$(CVSROOT))
CVS_FLAGS := -d $(CVS_ROOT_IN_TREE)
endif
endif
CVS_CO_DATE_FLAGS = $(if $(MOZ_CO_DATE),-D "$(MOZ_CO_DATE)")
CVSCO = $(CVS) $(CVS_FLAGS) co $(MOZ_CO_FLAGS) $(if $(MOZ_CO_TAG),-r $(MOZ_CO_TAG)) $(CVS_CO_DATE_FLAGS)
CVSCO_LOGFILE := $(ROOTDIR)/cvsco.log
CVSCO_LOGFILE := $(shell echo $(CVSCO_LOGFILE) | sed s%//%/%)
# if LOCALES_CVSROOT is not specified, set it here
# (and let mozconfig override it)
LOCALES_CVSROOT ?= :pserver:anonymous@cvs-mirror.mozilla.org:/l10n
####################################
# Load mozconfig Options
# See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
MOZCONFIG_LOADER := mozilla/build/autoconf/mozconfig2client-mk
MOZCONFIG_FINDER := mozilla/build/autoconf/mozconfig-find
MOZCONFIG_MODULES := mozilla/build/unix/modules.mk mozilla/build/unix/uniq.pl
run_for_side_effects := \
$(shell cd $(ROOTDIR); \
if test "$(_IS_FIRST_CHECKOUT)"; then \
$(CVSCO) $(MOZCONFIG_FINDER) $(MOZCONFIG_LOADER) $(MOZCONFIG_MODULES); \
else true; \
fi; \
$(MOZCONFIG_LOADER) $(TOPSRCDIR) mozilla/.mozconfig.mk > mozilla/.mozconfig.out)
include $(TOPSRCDIR)/.mozconfig.mk
include $(TOPSRCDIR)/build/unix/modules.mk
####################################
# Options that may come from mozconfig
MOZ_PROJECT_LIST := $(subst $(comma), ,$(MOZ_CO_PROJECT))
ifneq (,$(filter-out $(AVAILABLE_PROJECTS),$(MOZ_PROJECT_LIST)))
$(error MOZ_CO_PROJECT contains an unrecognized project.)
endif
MOZ_MODULE_LIST := $(subst $(comma), ,$(MOZ_CO_MODULE)) $(foreach project,$(MOZ_PROJECT_LIST),$(MODULES_$(project)))
LOCALE_DIRS := $(MOZ_LOCALE_DIRS) $(foreach project,$(MOZ_PROJECT_LIST),$(LOCALES_$(project)))
MOZCONFIG_MODULES += $(foreach project,$(MOZ_PROJECT_LIST),$(BOOTSTRAP_$(project)))
# Change CVS flags if anonymous root is requested
ifdef MOZ_CO_USE_MIRROR
CVS_FLAGS := -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
endif
# MOZ_CVS_FLAGS - Basic CVS flags
ifeq "$(origin MOZ_CVS_FLAGS)" "undefined"
CVS_FLAGS := $(CVS_FLAGS) -q -z 3
else
CVS_FLAGS := $(MOZ_CVS_FLAGS)
endif
ifdef MOZ_OBJDIR
OBJDIR := $(MOZ_OBJDIR)
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
else
OBJDIR := $(TOPSRCDIR)
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS)
endif
####################################
# CVS defines for NSS
#
NSS_CO_MODULE = \
mozilla/security/nss \
mozilla/security/coreconf \
$(NULL)
NSS_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
NSS_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
NSS_CO_FLAGS := $(NSS_CO_FLAGS) $(if $(NSS_CO_TAG),-r $(NSS_CO_TAG),-A)
# Cannot pull static tags by date
ifeq ($(NSS_CO_TAG),NSS_CLIENT_TAG)
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(NSS_CO_MODULE)
else
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSS_CO_MODULE)
endif
####################################
# CVS defines for NSPR
#
NSPR_CO_MODULE = mozilla/nsprpub
NSPR_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
NSPR_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
NSPR_CO_FLAGS := $(NSPR_CO_FLAGS) $(if $(NSPR_CO_TAG),-r $(NSPR_CO_TAG),-A)
# Cannot pull static tags by date
ifeq ($(NSPR_CO_TAG),NSPRPUB_CLIENT_TAG)
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(NSPR_CO_MODULE)
else
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSPR_CO_MODULE)
endif
####################################
# CVS defines for the C LDAP SDK
#
LDAPCSDK_CO_MODULE = mozilla/directory/c-sdk
LDAPCSDK_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
LDAPCSDK_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
LDAPCSDK_CO_FLAGS := $(LDAPCSDK_CO_FLAGS) $(if $(LDAPCSDK_CO_TAG),-r $(LDAPCSDK_CO_TAG),-A)
CVSCO_LDAPCSDK = $(CVS) $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(LDAPCSDK_CO_MODULE)
########################
# CVS defines for layout
#
LAYOUT_CO_MODULE = mozilla/layout
LAYOUT_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
LAYOUT_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
LAYOUT_CO_FLAGS := $(LAYOUT_CO_FLAGS) $(if $(LAYOUT_CO_TAG),-r $(LAYOUT_CO_TAG),-A)
CVSCO_LAYOUT = $(CVS) $(CVS_FLAGS) co $(LAYOUT_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(LAYOUT_CO_MODULE)
####################################
# CVS defines for standalone modules
#
ifeq ($(BUILD_MODULES),all)
CHECKOUT_STANDALONE := true
CHECKOUT_STANDALONE_NOSUBDIRS := true
else
STANDALONE_CO_MODULE := $(filter-out $(NSPRPUB_DIR) security directory/c-sdk, $(BUILD_MODULE_CVS))
STANDALONE_CO_MODULE += allmakefiles.sh client.mk aclocal.m4 configure configure.in
STANDALONE_CO_MODULE += Makefile.in
MOZ_MODULE_LIST += $(addprefix mozilla/,$(STANDALONE_CO_MODULE))
NOSUBDIRS_MODULE := $(addprefix mozilla/,$(BUILD_MODULE_CVS_NS))
ifeq (,$(filter $(NSPRPUB_DIR), $(BUILD_MODULE_CVS))$(MOZ_CO_PROJECT))
CVSCO_NSPR :=
endif
ifeq (,$(filter security security/manager, $(BUILD_MODULE_CVS))$(MOZ_CO_PROJECT))
CVSCO_NSS :=
endif
ifeq (,$(filter directory/c-sdk, $(BUILD_MODULE_CVS))$(MOZ_CO_PROJECT))
CVSCO_LDAPCSDK :=
endif
endif
####################################
# Error on obsolete variables.
#
ifdef MOZ_MAPINFO
$(warning MOZ_MAPINFO is obsolete, use MOZ_CO_MODULE=mozilla/tools/codesighs instead.)
MOZ_MODULE_LIST += mozilla/tools/codesighs
endif
ifdef MOZ_INTERNAL_LIBART_LGPL
$(error MOZ_INTERNAL_LIBART_LGPL is obsolete, use MOZ_CO_MODULE=mozilla/other-licenses/libart_lgpl instead.)
endif
ifdef MOZ_PHOENIX
$(warning MOZ_PHOENIX is obsolete.)
MOZ_MODULE_LIST += $(MODULES_browser)
# $(error MOZ_PHOENIX is obsolete, use MOZ_CO_PROJECT=browser and --enable-application=browser)
endif
ifdef MOZ_THUNDERBIRD
$(warning MOZ_THUNDERBIRD is obsolete.)
MOZ_MODULE_LIST += $(MODULES_mail)
# $(error MOZ_THUNDERBIRD is obsolete, use MOZ_CO_PROJECT=mail and --enable-application=mail)
endif
###################################
# Checkout main modules
#
# sort is used to remove duplicates. SeaMonkeyAll is special-cased to
# checkout last, because if you check it out first, there is a sticky
# tag left over from checking out the LDAP SDK, which causes files in
# the root directory to be missed.
MOZ_MODULE_LIST := $(sort $(filter-out SeaMonkeyAll,$(MOZ_MODULE_LIST))) $(firstword $(filter SeaMonkeyAll,$(MOZ_MODULE_LIST)))
MODULES_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
MODULES_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
MODULES_CO_FLAGS := $(MODULES_CO_FLAGS) $(if $(MOZ_CO_TAG),-r $(MOZ_CO_TAG),-A)
CVSCO_MODULES_NS = $(CVS) $(CVS_FLAGS) co $(MODULES_CO_FLAGS) $(CVS_CO_DATE_FLAGS) -l $(NOSUBDIRS_MODULE)
ifeq (,$(strip $(MOZ_MODULE_LIST)))
FASTUPDATE_MODULES = $(error No modules or projects were specified. Use MOZ_CO_PROJECT to specify a project for checkout.)
CHECKOUT_MODULES = $(error No modules or projects were specified. Use MOZ_CO_PROJECT to specify a project for checkout.)
else
FASTUPDATE_MODULES := fast_update $(CVS) $(CVS_FLAGS) co $(MODULES_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(MOZ_MODULE_LIST)
CHECKOUT_MODULES := $(foreach module,$(MOZ_MODULE_LIST),cvs_co $(CVS) $(CVS_FLAGS) co $(MODULES_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(module);)
CHECKOUT_MODULES := $(subst SeaMonkeyAll, SeaMonkeyAll \!mozilla/layout, $(CHECKOUT_MODULES))
endif
ifeq (,$(NOSUBDIRS_MODULE))
FASTUPDATE_MODULES_NS := true
CHECKOUT_MODULES_NS := true
else
FASTUPDATE_MODULES_NS := fast_update $(CVSCO_MODULES_NS)
CHECKOUT_MODULES_NS := cvs_co $(CVSCO_MODULES_NS)
endif
###################################
# CVS defines for locales
#
LOCALES_CO_FLAGS := -P
ifdef MOZ_CO_FLAGS
LOCALES_CO_FLAGS := $(MOZ_CO_FLAGS)
endif
LOCALES_CO_FLAGS := $(LOCALES_CO_FLAGS) $(if $(LOCALES_CO_TAG),-r $(LOCALES_CO_TAG),-A)
ifndef MOZ_CO_LOCALES
FASTUPDATE_LOCALES := true
CHECKOUT_LOCALES := true
else
override MOZ_CO_LOCALES := $(subst $(comma), ,$(MOZ_CO_LOCALES))
ifeq (all,$(MOZ_CO_LOCALES))
MOZCONFIG_MODULES += $(addsuffix /all-locales,$(LOCALE_DIRS))
FASTUPDATE_LOCALES := \
for dir in $(LOCALE_DIRS); do \
for locale in `cat $$dir/all-locales`; do \
fast_update $(CVS) $(CVS_FLAGS) -d $(LOCALES_CVSROOT) co $$dir/$$locale; \
done; \
done
CHECKOUT_LOCALES := \
for dir in $(LOCALE_DIRS); do \
for locale in `cat $$dir/all-locales`; do \
cvs_co $(CVS) $(CVS_FLAGS) -d $(LOCALES_CVSROOT) co $(LOCALES_CO_FLAGS) $$dir/$$locale; \
done; \
done
else # MOZ_CO_LOCALES != all
LOCALE_CO_DIRS = $(foreach locale,$(MOZ_CO_LOCALES),$(addsuffix /$(locale),$(LOCALE_DIRS)))
CVSCO_LOCALES := $(CVS) $(CVS_FLAGS) -d $(LOCALES_CVSROOT) co $(LOCALES_CO_FLAGS) $(LOCALE_CO_DIRS)
FASTUPDATE_LOCALES := fast_update $(CVSCO_LOCALES)
CHECKOUT_LOCALES := cvs_co $(CVSCO_LOCALES)
endif
endif #MOZ_CO_LOCALES
#######################################################################
# Rules
#
# Print out any options loaded from mozconfig.
all build checkout clean depend distclean export libs install realclean::
@if test -f .mozconfig.out; then \
cat .mozconfig.out; \
rm -f .mozconfig.out; \
else true; \
fi
ifdef _IS_FIRST_CHECKOUT
all:: checkout build
else
all:: checkout alldep
endif
# Windows equivalents
pull_all: checkout
build_all: build
build_all_dep: alldep
build_all_depend: alldep
clobber clobber_all: clean
pull_and_build_all: checkout alldep
# Do everything from scratch
everything: checkout clean build
####################################
# CVS checkout
#
checkout::
# @: Backup the last checkout log.
@if test -f $(CVSCO_LOGFILE) ; then \
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
else true; \
fi
ifdef RUN_AUTOCONF_LOCALLY
@echo "Removing local configures" ; \
cd $(ROOTDIR) && \
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
mozilla/directory/c-sdk/configure
endif
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
@echo '$(CVSCO) $(CVS_CO_DATE_FLAGS) -r $(LAYOUT_CO_TAG) mozilla/client.mk' && \
cd $(ROOTDIR) && \
$(CVSCO) $(CVS_CO_DATE_FLAGS) -r $(LAYOUT_CO_TAG) mozilla/client.mk && \
echo '$(CVSCO) $(CVS_CO_DATE_FLAGS) $(MOZCONFIG_MODULES)' && \
$(CVSCO) $(CVS_CO_DATE_FLAGS) $(MOZCONFIG_MODULES)
@cd $(ROOTDIR) && $(MAKE) -f mozilla/client.mk real_checkout
# Start the checkout. Split the output to the tty and a log file.
real_checkout:
@set -e; \
cvs_co() { set -e; echo "$$@" ; \
"$$@" 2>&1 | tee -a $(CVSCO_LOGFILE); }; \
cvs_co $(CVSCO_NSPR); \
cvs_co $(CVSCO_NSS); \
cvs_co $(CVSCO_LDAPCSDK); \
cvs_co $(CVSCO_LAYOUT); \
$(CHECKOUT_MODULES) \
$(CHECKOUT_MODULES_NS); \
$(CHECKOUT_LOCALES); \
echo '$(CVSCO) $(CVS_CO_DATE_FLAGS) -r $(LAYOUT_CO_TAG) mozilla/client.mk' && \
$(CVSCO) $(CVS_CO_DATE_FLAGS) -r $(LAYOUT_CO_TAG) mozilla/client.mk;
@echo "checkout finish: "`date` | tee -a $(CVSCO_LOGFILE)
# update the NSS checkout timestamp
@if test `egrep -c '^(U|C) mozilla/security/(nss|coreconf)' $(CVSCO_LOGFILE) 2>/dev/null` != 0; then \
touch $(TOPSRCDIR)/security/manager/.nss.checkout; \
fi
# @: Check the log for conflicts. ;
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
if test "$$conflicts" ; then \
echo "$(MAKE): *** Conflicts during checkout." ;\
echo "$$conflicts" ;\
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
false; \
else true; \
fi
ifdef RUN_AUTOCONF_LOCALLY
@echo Generating configures using $(AUTOCONF) ; \
cd $(TOPSRCDIR) && $(AUTOCONF) && \
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
endif
fast-update:
# @: Backup the last checkout log.
@if test -f $(CVSCO_LOGFILE) ; then \
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
else true; \
fi
ifdef RUN_AUTOCONF_LOCALLY
@echo "Removing local configures" ; \
cd $(ROOTDIR) && \
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
mozilla/directory/c-sdk/configure
endif
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
@echo '$(CVSCO) mozilla/client.mk $(MOZCONFIG_MODULES)'; \
cd $(ROOTDIR) && \
$(CVSCO) mozilla/client.mk $(MOZCONFIG_MODULES)
@cd $(TOPSRCDIR) && \
$(MAKE) -f client.mk real_fast-update
# Start the update. Split the output to the tty and a log file.
real_fast-update:
@set -e; \
fast_update() { set -e; config/cvsco-fast-update.pl $$@ 2>&1 | tee -a $(CVSCO_LOGFILE); }; \
cvs_co() { set -e; echo "$$@" ; \
"$$@" 2>&1 | tee -a $(CVSCO_LOGFILE); }; \
fast_update $(CVSCO_NSPR); \
cd $(ROOTDIR); \
cvs_co $(CVSCO_NSS); \
cd mozilla; \
fast_update $(CVSCO_LDAPCSDK); \
$(FASTUPDATE_MODULES); \
$(FASTUPDATE_MODULES_NS); \
$(FASTUPDATE_LOCALES);
@echo "fast_update finish: "`date` | tee -a $(CVSCO_LOGFILE)
# update the NSS checkout timestamp
@if test `egrep -c '^(U|C) mozilla/security/(nss|coreconf)' $(CVSCO_LOGFILE) 2>/dev/null` != 0; then \
touch $(TOPSRCDIR)/security/manager/.nss.checkout; \
fi
# @: Check the log for conflicts. ;
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
if test "$$conflicts" ; then \
echo "$(MAKE): *** Conflicts during fast-update." ;\
echo "$$conflicts" ;\
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
false; \
else true; \
fi
ifdef RUN_AUTOCONF_LOCALLY
@echo Generating configures using $(AUTOCONF) ; \
cd $(TOPSRCDIR) && $(AUTOCONF) && \
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
endif
####################################
# Web configure
WEBCONFIG_FILE := $(HOME)/.mozconfig
MOZCONFIG2CONFIGURATOR := build/autoconf/mozconfig2configurator
webconfig:
@cd $(TOPSRCDIR); \
url=`$(MOZCONFIG2CONFIGURATOR) $(TOPSRCDIR)`; \
echo Running mozilla with the following url: ;\
echo ;\
echo $$url ;\
mozilla -remote "openURL($$url)" || \
netscape -remote "openURL($$url)" || \
mozilla $$url || \
netscape $$url ;\
echo ;\
echo 1. Fill out the form on the browser. ;\
echo 2. Save the results to $(WEBCONFIG_FILE)
#####################################################
# First Checkout
ifdef _IS_FIRST_CHECKOUT
# First time, do build target in a new process to pick up new files.
build::
$(MAKE) -f $(TOPSRCDIR)/client.mk build
else
#####################################################
# After First Checkout
####################################
# Configure
CONFIG_STATUS := $(wildcard $(OBJDIR)/config.status)
CONFIG_CACHE := $(wildcard $(OBJDIR)/config.cache)
ifdef RUN_AUTOCONF_LOCALLY
EXTRA_CONFIG_DEPS := \
$(TOPSRCDIR)/aclocal.m4 \
$(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
$(NULL)
$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
@echo Generating $@ using autoconf
cd $(TOPSRCDIR); $(AUTOCONF)
endif
CONFIG_STATUS_DEPS_L10N := $(wildcard $(TOPSRCDIR)/l10n/makefiles.all)
CONFIG_STATUS_DEPS := \
$(TOPSRCDIR)/configure \
$(TOPSRCDIR)/allmakefiles.sh \
$(TOPSRCDIR)/.mozconfig.mk \
$(wildcard $(TOPSRCDIR)/nsprpub/configure) \
$(wildcard $(TOPSRCDIR)/directory/c-sdk/configure) \
$(wildcard $(TOPSRCDIR)/mailnews/makefiles) \
$(CONFIG_STATUS_DEPS_L10N) \
$(wildcard $(TOPSRCDIR)/themes/makefiles) \
$(wildcard $(TOPSRCDIR)/config/milestone.txt) \
$(wildcard $(TOPSRCDIR)/config/chrome-versions.sh) \
$(NULL)
# configure uses the program name to determine @srcdir@. Calling it without
# $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
# path of $(TOPSRCDIR).
ifeq ($(TOPSRCDIR),$(OBJDIR))
CONFIGURE := ./configure
else
CONFIGURE := $(TOPSRCDIR)/configure
endif
ifdef MOZ_TOOLS
CONFIGURE := $(TOPSRCDIR)/configure
endif
$(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
@echo cd $(OBJDIR);
@echo $(CONFIGURE) $(CONFIGURE_ARGS)
@cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
|| ( echo "*** Fix above errors and then restart with\
\"$(MAKE) -f client.mk build\"" && exit 1 )
@touch $(OBJDIR)/Makefile
ifdef CONFIG_STATUS
$(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
cd $(OBJDIR); \
CONFIG_FILES=config/autoconf.mk ./config.status
endif
####################################
# Depend
depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE) export && $(MOZ_MAKE) depend
####################################
# Build it
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE)
####################################
# Profile-feedback build (gcc only)
# To use this, you should set the following variables in your mozconfig
# mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
#
# The profile script should exercise the functionality to be included
# in the profile feedback.
profiledbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE) MOZ_PROFILE_GENERATE=1
OBJDIR=${OBJDIR} $(PROFILE_GEN_SCRIPT)
$(MOZ_MAKE) clobber_all
$(MOZ_MAKE) MOZ_PROFILE_USE=1
find $(OBJDIR) -name "*.da" -exec rm {} \;
####################################
# Other targets
# Pass these target onto the real build system
install export libs clean realclean distclean alldep:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
$(MOZ_MAKE) $@
cleansrcdir:
@cd $(TOPSRCDIR); \
if [ -f webshell/embed/gtk/Makefile ]; then \
$(MAKE) -C webshell/embed/gtk distclean; \
fi; \
if [ -f Makefile ]; then \
$(MAKE) distclean ; \
else \
echo "Removing object files from srcdir..."; \
rm -fr `find . -type d \( -name .deps -print -o -name CVS \
-o -exec test ! -d {}/CVS \; \) -prune \
-o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
build/autoconf/clean-config.sh; \
fi;
# (! IS_FIRST_CHECKOUT)
endif
echo_objdir:
@echo $(OBJDIR)
.PHONY: checkout real_checkout depend build export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything

View File

@@ -1,76 +0,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) 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 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 *****
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = layout
DIRS = \
style \
base \
generic \
forms \
printing \
tables \
xul \
$(NULL)
ifdef MOZ_MATHML
DIRS += mathml
endif
ifdef MOZ_XTF
DIRS += xtf
endif
ifdef MOZ_SVG
DIRS += svg
endif
DIRS += build
ifdef ENABLE_TESTS
DIRS += html/tests
endif
include $(topsrcdir)/config/rules.mk

View File

@@ -1,170 +0,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) 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 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 *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = layout
XPIDL_MODULE = layout_base
GRE_MODULE = 1
LIBRARY_NAME = gkbase_s
REQUIRES = xpcom \
string \
dom \
content \
xul \
xuldoc \
gfx \
widget \
view \
necko \
docshell \
webshell \
webbrwsr \
uriloader \
js \
xpconnect \
plugin \
locale \
pref \
imglib2 \
unicharutil \
htmlparser \
util \
windowwatcher \
intl \
accessibility \
$(NULL)
XPIDLSRCS = \
nsIChromeEventHandler.idl \
nsISelectionImageService.idl \
$(NULL)
EXPORTS = \
nsBidi.h \
nsBidiPresUtils.h \
nsBidiUtils.h \
nsCSSFrameConstructor.h \
nsChangeHint.h \
nsCompatibility.h \
nsFrameManager.h \
nsFrameManagerBase.h \
nsFrameTraversal.h \
nsIAutoCopy.h \
nsICaret.h \
nsIDocumentViewer.h \
nsIFrameSelection.h \
nsIFrameTraversal.h \
nsIImageMap.h \
nsILayoutDebugger.h \
nsILayoutHistoryState.h \
nsIPercentHeightObserver.h \
nsIPresShell.h \
nsIPresState.h \
nsIReflowCallback.h \
nsLayoutAtomList.h \
nsLayoutAtoms.h \
nsLayoutErrors.h \
nsLayoutUtils.h \
nsPresContext.h \
nsStyleChangeList.h \
nsStyleConsts.h \
$(NULL)
CPPSRCS = \
nsAutoCopy.cpp \
nsBidiUtils.cpp \
nsCSSColorUtils.cpp \
nsCSSFrameConstructor.cpp \
nsCSSRendering.cpp \
nsCaret.cpp \
nsChildIterator.cpp \
nsDocumentViewer.cpp \
nsFrameContentIterator.cpp \
nsFrameManager.cpp \
nsFrameTraversal.cpp \
nsImageLoader.cpp \
nsLayoutAtoms.cpp \
nsLayoutDebugger.cpp \
nsLayoutHistoryState.cpp \
nsLayoutUtils.cpp \
nsPresContext.cpp \
nsPresShell.cpp \
nsPresState.cpp \
nsQuoteList.cpp \
nsStyleChangeList.cpp \
$(NULL)
ifdef IBMBIDI
CPPSRCS += \
nsBidiPresUtils.cpp \
nsBidi.cpp \
$(NULL)
endif
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \
-I$(srcdir) \
-I$(srcdir)/../generic \
-I$(srcdir)/../forms \
-I$(srcdir)/../tables \
-I$(srcdir)/../printing \
-I$(srcdir)/../xul/base/src \
-I$(srcdir)/../../content/events/src \
-I$(srcdir)/../../view/src \
$(NULL)
ifdef MOZ_MATHML
LOCAL_INCLUDES += \
-I$(srcdir)/../mathml/content/src \
-I$(srcdir)/../mathml/base/src
endif
ifdef MOZ_SVG
LOCAL_INCLUDES += \
-I$(srcdir)/../svg/base/src
endif
DEFINES += -D_IMPL_NS_LAYOUT

File diff suppressed because it is too large Load Diff

View File

@@ -1,156 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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 Communicator client 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):
* shaver@mozilla.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 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 "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIAutoCopy.h"
#include "nsISelection.h"
#include "nsISelectionPrivate.h"
#include "nsISelectionListener.h"
#include "nsIDOMDocument.h"
#include "nsCopySupport.h"
#include "nsIClipboard.h"
#include "nsIDocument.h"
#include "nsSupportsPrimitives.h"
class nsAutoCopyService : public nsIAutoCopyService , public nsISelectionListener
{
public:
NS_DECL_ISUPPORTS
nsAutoCopyService();
virtual ~nsAutoCopyService(){}//someday maybe we have it able to shutdown during run
//nsIAutoCopyService interfaces
NS_IMETHOD Listen(nsISelection *aDomSelection);
//end nsIAutoCopyService
//nsISelectionListener interfaces
NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason);
//end nsISelectionListener
};
// Implement our nsISupports methods
NS_IMPL_ISUPPORTS2(nsAutoCopyService, nsIAutoCopyService,nsISelectionListener)
nsresult
NS_NewAutoCopyService(nsIAutoCopyService** aResult)
{
*aResult = new nsAutoCopyService;
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}
nsAutoCopyService::nsAutoCopyService()
{
}
NS_IMETHODIMP
nsAutoCopyService::Listen(nsISelection *aDomSelection)
{
if (!aDomSelection)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISelection> selection(aDomSelection);
nsCOMPtr<nsISelectionPrivate> selectionPrivate(do_QueryInterface(selection));
return selectionPrivate->AddSelectionListener(this);
}
/*
* What we do now:
* On every selection change, we copy to the clipboard anew, creating a
* HTML buffer, a transferable, an nsISupportsString and
* a huge mess every time. This is basically what nsPresShell::DoCopy does
* to move the selection into the clipboard for Edit->Copy.
*
* What we should do, to make our end of the deal faster:
* Create a singleton transferable with our own magic converter. When selection
* changes (use a quick cache to detect ``real'' changes), we put the new
* nsISelection in the transferable. Our magic converter will take care of
* transferable->whatever-other-format when the time comes to actually
* hand over the clipboard contents.
*
* Other issues:
* - which X clipboard should we populate?
* - should we use a different one than Edit->Copy, so that inadvertant
* selections (or simple clicks, which currently cause a selection
* notification, regardless of if they're in the document which currently has
* selection!) don't lose the contents of the ``application''? Or should we
* just put some intelligence in the ``is this a real selection?'' code to
* protect our selection against clicks in other documents that don't create
* selections?
* - maybe we should just never clear the X clipboard? That would make this
* problem just go away, which is very tempting.
*/
#define DRAGGING 1
NS_IMETHODIMP
nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason)
{
nsresult rv;
if (!(aReason & nsISelectionListener::MOUSEUP_REASON ||
aReason & nsISelectionListener::SELECTALL_REASON ||
aReason & nsISelectionListener::KEYPRESS_REASON))
return NS_OK; //dont care if we are still dragging
PRBool collapsed;
if (!aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed)) || collapsed) {
#ifdef DEBUG_CLIPBOARD
fprintf(stderr, "CLIPBOARD: no selection/collapsed selection\n");
#endif
/* clear X clipboard? */
return NS_OK;
}
nsCOMPtr<nsIDocument> doc;
doc = do_QueryInterface(NS_REINTERPRET_CAST(nsISupports *,aDoc),&rv);
if (NS_FAILED(rv))
return rv;
if (!doc)
return NS_ERROR_NULL_POINTER;
// call the copy code
rv = nsCopySupport::HTMLCopy(aSel, doc, nsIClipboard::kSelectionClipboard);
return rv;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,276 +0,0 @@
/* -*- 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
* IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* IBM Corporation
*
* 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 ***** */
#ifdef IBMBIDI
#ifndef nsBidiPresUtils_h___
#define nsBidiPresUtils_h___
#include "nsVoidArray.h"
#include "nsIFrame.h"
#include "nsBidi.h"
#include "nsBidiUtils.h"
#include "nsCOMPtr.h"
#include "nsDataHashtable.h"
/**
* A structure representing a logical position which should be resolved
* into its visual position during BiDi processing.
*/
struct nsBidiPositionResolve
{
// [in] Logical index within string.
PRInt32 logicalIndex;
// [out] Visual index within string.
// If the logical position was not found, set to kNotFound.
PRInt32 visualIndex;
// [out] Visual position of the character, from the left (on the X axis), in twips.
// Eessentially, this is the X position (relative to the rendering context) where the text was drawn + the font metric of the visual string to the left of the given logical position.
// If the logical position was not found, set to kNotFound.
PRInt32 visualLeftTwips;
};
class nsBidiPresUtils {
public:
nsBidiPresUtils();
~nsBidiPresUtils();
PRBool IsSuccessful(void) const;
/**
* Make Bidi engine calculate the embedding levels of the frames that are
* descendants of a given block frame.
*
* @param aPresContext The presContext
* @param aBlockFrame The block frame
* @param aFirstChild The first child frame of aBlockFrame
* @param aForceReflow [OUT] Set if we delete frames and will need to
* reflow the block frame
* @param aIsVisualFormControl [IN] Set if we are in a form control on a
* visual page.
* @see nsHTMLReflowState::IsBidiFormControl
*
* @lina 06/18/2000
*/
nsresult Resolve(nsPresContext* aPresContext,
nsIFrame* aBlockFrame,
nsIFrame* aFirstChild,
PRBool& aForceReflow,
PRBool aIsVisualFormControl);
/**
* Reorder this line using Bidi engine.
* Update frame array, following the new visual sequence.
*
* @lina 05/02/2000
*/
void ReorderFrames(nsPresContext* aPresContext,
nsIRenderingContext* aRendContext,
nsIFrame* aFirstChild,
nsIFrame* aNextInFlow,
PRInt32 aChildCount);
/**
* Format Unicode text, taking into account bidi capabilities
* of the platform. The formatting includes: reordering, Arabic shaping,
* symmetric and numeric swapping, removing control characters.
*
* @lina 06/18/2000
*/
nsresult FormatUnicodeText(nsPresContext* aPresContext,
PRUnichar* aText,
PRInt32& aTextLength,
nsCharType aCharType,
PRBool aIsOddLevel,
PRBool aIsBidiSystem);
/**
* Reorder Unicode text, taking into account bidi capabilities of the
* platform. The reordering includes symmetric swapping and removing
* control characters.
*/
nsresult ReorderUnicodeText(PRUnichar* aText,
PRInt32& aTextLength,
nsCharType aCharType,
PRBool aIsOddLevel,
PRBool aIsBidiSystem);
/**
* Return our nsBidi object (bidi reordering engine)
*/
nsresult GetBidiEngine(nsBidi** aBidiEngine);
/**
* Reorder plain text using the Unicode Bidi algorithm and send it to
* a rendering context for rendering.
*
* @param[in] aText the string to be rendered (in logical order)
* @param aLength the number of characters in the string
* @param aBaseDirection the base direction of the string
* NSBIDI_LTR - left-to-right string
* NSBIDI_RTL - right-to-left string
* @param aPresContext the presentation context
* @param aRenderingContext the rendering context
* @param aX the x-coordinate to render the string
* @param aY the y-coordinate to render the string
* @param[in,out] aPosResolve array of logical positions to resolve into visual positions; can be nsnull if this functionality is not required
* @param aPosResolveCount number of items in the aPosResolve array
*/
nsresult RenderText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nscoord aX,
nscoord aY,
nsBidiPositionResolve* aPosResolve = nsnull,
PRInt32 aPosResolveCount = 0);
private:
/**
* Create a string containing entire text content of this block.
*
* @lina 05/02/2000
*/
void CreateBlockBuffer(nsPresContext* aPresContext);
/**
* Set up an array of the frames after splitting frames so that each frame has
* consistent directionality. At this point the frames are still in logical
* order
*/
nsresult InitLogicalArray(nsPresContext* aPresContext,
nsIFrame* aCurrentFrame,
nsIFrame* aNextInFlow,
PRBool aAddMarkers = PR_FALSE);
/**
* Reorder the frame array from logical to visual order
*
* @param aPresContext the presentation context
* @param aBidiEnabled TRUE on return if the visual order is different from
* the logical order
*/
nsresult Reorder(nsPresContext* aPresContext,
PRBool& aBidiEnabled);
/**
* Adjust frame positions following their visual order
*
* @param <code>nsPresContext*</code>, the first kid
*
* @lina 04/11/2000
*/
void RepositionInlineFrames(nsPresContext* aPresContext,
nsIRenderingContext* aRendContext,
nsIFrame* aFirstChild,
PRInt32 aChildCount) const;
void RepositionContainerFrame(nsPresContext* aPresContext,
nsIFrame* aContainer,
PRInt32& aMinX,
PRInt32& aMaxX) const;
/**
* Helper method for Resolve()
* Truncate a text frame and possibly create a continuation frame with the
* remainder of its content.
*
* @param aPresContext the pres context
* @param aContent the content of the frame
* @param aFrame the original frame
* @param aNewFrame [OUT] the new frame that was created
* @param aFrameIndex [IN/OUT] index of aFrame in mLogicalFrames
*
* If there is already a bidi continuation for this frame in mLogicalFrames,
* no new frame will be created. On exit aNewFrame will point to the existing
* bidi continuation and aFrameIndex will contain its index.
* @see Resolve()
* @see RemoveBidiContinuation()
*/
PRBool EnsureBidiContinuation(nsPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aFrame,
nsIFrame** aNewFrame,
PRInt32& aFrameIndex);
/**
* Helper method for Resolve()
* Delete one or more bidi continuation frames created in a previous reflow by
* EnsureBidiContinuation().
* @param aPresContext the pres context
* @param aFrame the frame whose continuations are to be removed
* @param aFirstIndex index of aFrame in mLogicalFrames
* @param aLastIndex index of the last frame to be removed
* @param aOffset [OUT] count of directional frames removed. Since
* directional frames have control characters
* corresponding to them in mBuffer, the pointers to
* mBuffer in Resolve() will need to be updated after
* deleting the frames.
*
* @see Resolve()
* @see EnsureBidiContinuation()
*/
void RemoveBidiContinuation(nsPresContext* aPresContext,
nsIFrame* aFrame,
PRInt32 aFirstIndex,
PRInt32 aLastIndex,
PRInt32& aOffset) const;
void CalculateCharType(PRInt32& aOffset,
PRInt32 aCharTypeLimit,
PRInt32& aRunLimit,
PRInt32& aRunLength,
PRInt32& aRunCount,
PRUint8& aCharType,
PRUint8& aPrevCharType) const;
void StripBidiControlCharacters(PRUnichar* aText,
PRInt32& aTextLength) const;
nsAutoString mBuffer;
nsVoidArray mLogicalFrames;
nsVoidArray mVisualFrames;
nsDataHashtable<nsISupportsHashKey, PRInt32> mContentToFrameIndex;
PRInt32 mArraySize;
PRInt32* mIndexMap;
PRUint8* mLevels;
nsresult mSuccess;
nsBidi* mBidiEngine;
};
#endif /* nsBidiPresUtils_h___ */
#endif // IBMBIDI

View File

@@ -1,555 +0,0 @@
/* -*- 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
* IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Maha Abou El Rous <mahar@eg.ibm.com>
* Lina Kemmel <lkemmel@il.ibm.com>
* Simon Montagu <smontagu@netscape.com>
* Roozbeh Pournader <roozbeh@sharif.edu>
*
* 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 "nsBidiUtils.h"
#define FE_TO_06_OFFSET 0xfe70
static const PRUnichar FE_TO_06 [][2] = {
{0x064b,0x0000},{0x064b,0x0640},{0x064c,0x0000},
{0x0000,0x0000},{0x064d,0x0000},{0x0000,0x0000},
{0x064e,0x0000},{0x064e,0x0640},{0x064f,0x0000},
{0x064f,0x0640},{0x0650,0x0000},{0x0650,0x0640},
{0x0651,0x0000},{0x0651,0x0640},{0x0652,0x0000},
{0x0652,0x0640},{0x0621,0x0000},{0x0622,0x0000},
{0x0622,0x0000},{0x0623,0x0000},{0x0623,0x0000},
{0x0624,0x0000},{0x0624,0x0000},{0x0625,0x0000},
{0x0625,0x0000},{0x0626,0x0000},{0x0626,0x0000},
{0x0626,0x0000},{0x0626,0x0000},{0x0627,0x0000},
{0x0627,0x0000},{0x0628,0x0000},{0x0628,0x0000},
{0x0628,0x0000},{0x0628,0x0000},{0x0629,0x0000},
{0x0629,0x0000},{0x062a,0x0000},{0x062a,0x0000},
{0x062a,0x0000},{0x062a,0x0000},{0x062b,0x0000},
{0x062b,0x0000},{0x062b,0x0000},{0x062b,0x0000},
{0x062c,0x0000},{0x062c,0x0000},{0x062c,0x0000},
{0x062c,0x0000},{0x062d,0x0000},{0x062d,0x0000},
{0x062d,0x0000},{0x062d,0x0000},{0x062e,0x0000},
{0x062e,0x0000},{0x062e,0x0000},{0x062e,0x0000},
{0x062f,0x0000},{0x062f,0x0000},{0x0630,0x0000},
{0x0630,0x0000},{0x0631,0x0000},{0x0631,0x0000},
{0x0632,0x0000},{0x0632,0x0000},{0x0633,0x0000},
{0x0633,0x0000},{0x0633,0x0000},{0x0633,0x0000},
{0x0634,0x0000},{0x0634,0x0000},{0x0634,0x0000},
{0x0634,0x0000},{0x0635,0x0000},{0x0635,0x0000},
{0x0635,0x0000},{0x0635,0x0000},{0x0636,0x0000},
{0x0636,0x0000},{0x0636,0x0000},{0x0636,0x0000},
{0x0637,0x0000},{0x0637,0x0000},{0x0637,0x0000},
{0x0637,0x0000},{0x0638,0x0000},{0x0638,0x0000},
{0x0638,0x0000},{0x0638,0x0000},{0x0639,0x0000},
{0x0639,0x0000},{0x0639,0x0000},{0x0639,0x0000},
{0x063a,0x0000},{0x063a,0x0000},{0x063a,0x0000},
{0x063a,0x0000},{0x0641,0x0000},{0x0641,0x0000},
{0x0641,0x0000},{0x0641,0x0000},{0x0642,0x0000},
{0x0642,0x0000},{0x0642,0x0000},{0x0642,0x0000},
{0x0643,0x0000},{0x0643,0x0000},{0x0643,0x0000},
{0x0643,0x0000},{0x0644,0x0000},{0x0644,0x0000},
{0x0644,0x0000},{0x0644,0x0000},{0x0645,0x0000},
{0x0645,0x0000},{0x0645,0x0000},{0x0645,0x0000},
{0x0646,0x0000},{0x0646,0x0000},{0x0646,0x0000},
{0x0646,0x0000},{0x0647,0x0000},{0x0647,0x0000},
{0x0647,0x0000},{0x0647,0x0000},{0x0648,0x0000},
{0x0648,0x0000},{0x0649,0x0000},{0x0649,0x0000},
{0x064a,0x0000},{0x064a,0x0000},{0x064a,0x0000},
{0x064a,0x0000},{0x0644,0x0622},{0x0644,0x0622},
{0x0644,0x0623},{0x0644,0x0623},{0x0644,0x0625},
{0x0644,0x0625},{0x0644,0x0627},{0x0644,0x0627}
};
static const PRUnichar FB_TO_06 [] = {
0x0671,0x0671,0x067B,0x067B,0x067B,0x067B,0x067E,0x067E, //FB50-FB57
0x067E,0x067E,0x0680,0x0680,0x0680,0x0680,0x067A,0x067A, //FB58-FB5F
0x067A,0x067A,0x067F,0x067F,0x067F,0x067F,0x0679,0x0679, //FB60-FB67
0x0679,0x0679,0x06A4,0x06A4,0x06A4,0x06A4,0x06A6,0x06A6, //FB68-FB6F
0x06A6,0x06A6,0x0684,0x0684,0x0684,0x0684,0x0683,0x0683, //FB70-FB77
0x0683,0x0683,0x0686,0x0686,0x0686,0x0686,0x0687,0x0687, //FB78-FB7F
0x0687,0x0687,0x068D,0x068D,0x068C,0x068C,0x068E,0x068E, //FB80-FB87
0x0688,0x0688,0x0698,0x0698,0x0691,0x0691,0x06A9,0x06A9, //FB88-FB8F
0x06A9,0x06A9,0x06AF,0x06AF,0x06AF,0x06AF,0x06B3,0x06B3, //FB90-FB97
0x06B3,0x06B3,0x06B1,0x06B1,0x06B1,0x06B1,0x06BA,0x06BA, //FB98-FB9F
0x06BB,0x06BB,0x06BB,0x06BB,0x06C0,0x06C0,0x06C1,0x06C1, //FBA0-FBA7
0x06C1,0x06C1,0x06BE,0x06BE,0x06BE,0x06BE,0x06D2,0x06D2, //FBA8-FBAF
0x06D3,0x06D3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBB0-FBB7
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBB8-FBBF
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBC0-FBC7
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBC8-FBCF
0x0000,0x0000,0x0000,0x06AD,0x06AD,0x06AD,0x06AD,0x06C7, //FBD0-FBD7
0x06C7,0x06C6,0x06C6,0x06C8,0x06C8,0x0677,0x06CB,0x06CB, //FBD8-FBDF
0x06C5,0x06C5,0x06C9,0x06C9,0x06D0,0x06D0,0x06D0,0x06D0, //FBE0-FBE7
0x0649,0x0649,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBE8-FBEF
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBF0-FBF7
0x0000,0x0000,0x0000,0x0000,0x06CC,0x06CC,0x06CC,0x06CC //FBF8-FBFF
};
#define PresentationToOriginal(c, order) \
(((0xFE70 <= (c) && (c) <= 0xFEFC)) ? \
FE_TO_06[(c)- FE_TO_06_OFFSET][order] : \
(((0xFB50 <= (c) && (c) <= 0xFBFF) && (order) == 0) ? \
FB_TO_06[(c)-0xFB50] : (PRUnichar) 0x0000))
//============ Begin Arabic Basic to Presentation Form B Code ============
// Note: the following code are moved from gfx/src/windows/nsRenderingContextWin.cpp
static const PRUint8 gArabicMap1[] = {
0x81, 0x83, 0x85, 0x87, 0x89, 0x8D, // 0622-0627
0x8F, 0x93, 0x95, 0x99, 0x9D, 0xA1, 0xA5, 0xA9, // 0628-062F
0xAB, 0xAD, 0xAF, 0xB1, 0xB5, 0xB9, 0xBD, 0xC1, // 0630-0637
0xC5, 0xC9, 0xCD // 0638-063A
};
static const PRUint8 gArabicMap2[] = {
0xD1, 0xD5, 0xD9, 0xDD, 0xE1, 0xE5, 0xE9, // 0641-0647
0xED, 0xEF, 0xF1 // 0648-064A
};
static const PRUint8 gArabicMapEx[] = {
0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0671-0677
0x00, 0x66, 0x5E, 0x52, 0x00, 0x00, 0x56, 0x62, // 0678-067F
0x5A, 0x00, 0x00, 0x76, 0x72, 0x00, 0x7A, 0x7E, // 0680-0687
0x88, 0x00, 0x00, 0x00, 0x84, 0x82, 0x86, 0x00, // 0688-068F
0x00, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0690-0697
0x8A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0698-069F
0x00, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x6E, 0x00, // 06A0-06A7
0x00, 0x8E, 0x00, 0x00, 0x00, 0xD3, 0x00, 0x92, // 06A8-06AF
0x00, 0x9A, 0x00, 0x96, 0x00, 0x00, 0x00, 0x00, // 06B0-06B7
0x00, 0x00, 0x9E, 0xA0, 0x00, 0x00, 0xAA, 0x00, // 06B8-06BF
0xA4, 0xA6, 0x00, 0x00, 0x00, 0xE0, 0xD9, 0xD7, // 06C0-06C7
0xDB, 0xE2, 0x00, 0xDE, 0xFC, 0x00, 0x00, 0x00, // 06C8-06CF
0xE4, 0x00, 0xAE, 0xB0 // 06D0-06D3
};
#define PresentationFormB(c, form) \
(((0x0622<=(c)) && ((c)<=0x063A)) ? \
(0xFE00|(gArabicMap1[(c)-0x0622] + (form))) : \
(((0x0641<=(c)) && ((c)<=0x064A)) ? \
(0xFE00|(gArabicMap2[(c)-0x0641] + (form))) : \
(((0x0671<=(c)) && ((c))<=0x06D3) && gArabicMapEx[(c)-0x0671]) ? \
(0xFB00|(gArabicMapEx[(c)-0x0671] + (form))) : (c)))
typedef enum {
eIsolated, // or Char N
eFinal, // or Char R
eInitial, // or Char L
eMedial // or Char M
} eArabicForm;
typedef enum {
eTr = 0, // Transparent
eRJ = 1, // Right-Joining
eLJ = 2, // Left-Joining
eDJ = 3, // Dual-Joining
eNJ = 4, // Non-Joining
eJC = 7, // Joining Causing
eRightJCMask = 2, // bit of Right-Join Causing
eLeftJCMask = 1 // bit of Left-Join Causing
} eArabicJoiningClass;
#define RightJCClass(j) (eRightJCMask&(j))
#define LeftJCClass(j) (eLeftJCMask&(j))
#define DecideForm(jl,j,jr) \
(((eRJ == (j)) && RightJCClass(jr)) ? eFinal \
: \
((eDJ == (j)) ? \
((RightJCClass(jr)) ? \
(((LeftJCClass(jl)) ? eMedial \
: eFinal)) \
: \
(((LeftJCClass(jl)) ? eInitial \
: eIsolated)) \
) : eIsolated)) \
// All letters without an equivalen in the FB50 block are 'eNJ' here. This
// should be fixed after finding some better mechanism for handling Arabic.
static const PRInt8 gJoiningClass[] = {
eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0600-0607
eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0608-060F
eTr, eTr, eTr, eTr, eTr, eTr, eNJ, eNJ, // 0610-0617
eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0618-061F
eNJ, eNJ, eRJ, eRJ, eRJ, eRJ, eDJ, eRJ, // 0620-0627
eDJ, eRJ, eDJ, eDJ, eDJ, eDJ, eDJ, eRJ, // 0628-062F
eRJ, eRJ, eRJ, eDJ, eDJ, eDJ, eDJ, eDJ, // 0630-0637
eDJ, eDJ, eDJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0638-063F
eJC, eDJ, eDJ, eDJ, eDJ, eDJ, eDJ, eDJ, // 0640-0647
eRJ, eDJ, eDJ, eTr, eTr, eTr, eTr, eTr, // 0648-064F
eTr, eTr, eTr, eTr, eTr, eTr, eTr, eTr, // 0650-0657
eTr, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0658-065F
eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0660-0667
eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0668-066F
eTr, eRJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0670-0677
eNJ, eDJ, eDJ, eDJ, eNJ, eNJ, eDJ, eDJ, // 0678-067F
eDJ, eNJ, eNJ, eDJ, eDJ, eNJ, eDJ, eDJ, // 0680-0687
eRJ, eNJ, eNJ, eNJ, eRJ, eRJ, eRJ, eNJ, // 0688-068F
eNJ, eRJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0690-0697
eRJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0698-069F
eNJ, eNJ, eNJ, eNJ, eDJ, eNJ, eDJ, eNJ, // 06A0-06A7
eNJ, eDJ, eNJ, eNJ, eNJ, eDJ, eNJ, eDJ, // 06A8-06AF
eNJ, eDJ, eNJ, eDJ, eNJ, eNJ, eNJ, eNJ, // 06B0-06B7
eNJ, eNJ, eDJ, eDJ, eNJ, eNJ, eDJ, eNJ, // 06B8-06BF
eRJ, eDJ, eNJ, eNJ, eNJ, eRJ, eRJ, eRJ, // 06C0-06C7
eRJ, eRJ, eNJ, eRJ, eDJ, eNJ, eNJ, eNJ, // 06C8-06CF
eDJ, eNJ, eRJ, eRJ, eNJ, eNJ, eTr, eTr, // 06D0-06D7
eTr, eTr, eTr, eTr, eTr, eNJ, eNJ, eTr, // 06D8-06DF
eTr, eTr, eTr, eTr, eTr, eNJ, eNJ, eTr, // 06E0-06E7
eTr, eNJ, eTr, eTr, eTr, eTr, eNJ, eNJ, // 06E8-06EF
eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 06F0-06F7
eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ // 06F8-06FF
};
#define GetJoiningClass(c) \
((IS_ARABIC_CHAR(c)) ? \
(gJoiningClass[(c) - 0x0600]) : \
((0x200D == (c)) ? eJC : eTr))
static const PRUint16 gArabicLigatureMap[] =
{
0x82DF, // 0xFE82 0xFEDF -> 0xFEF5
0x82E0, // 0xFE82 0xFEE0 -> 0xFEF6
0x84DF, // 0xFE84 0xFEDF -> 0xFEF7
0x84E0, // 0xFE84 0xFEE0 -> 0xFEF8
0x88DF, // 0xFE88 0xFEDF -> 0xFEF9
0x88E0, // 0xFE88 0xFEE0 -> 0xFEFA
0x8EDF, // 0xFE8E 0xFEDF -> 0xFEFB
0x8EE0 // 0xFE8E 0xFEE0 -> 0xFEFC
};
#define ARABIC_TO_HINDI_DIGIT_INCREMENT (START_HINDI_DIGITS - START_ARABIC_DIGITS)
#define NUM_TO_ARABIC(c) \
((((c)>=START_HINDI_DIGITS) && ((c)<=END_HINDI_DIGITS)) ? \
((c) - (PRUint16)ARABIC_TO_HINDI_DIGIT_INCREMENT) : \
(c))
#define NUM_TO_HINDI(c) \
((((c)>=START_ARABIC_DIGITS) && ((c)<=END_ARABIC_DIGITS)) ? \
((c) + (PRUint16)ARABIC_TO_HINDI_DIGIT_INCREMENT): \
(c))
// helper function to reverse a PRUnichar buffer
static void ReverseString(PRUnichar* aBuffer, PRUint32 aLen)
{
PRUnichar *start, *end;
PRUnichar swapChar;
for (start = aBuffer, end = aBuffer + aLen - 1; start < end; ++start, --end) {
swapChar = *start;
*start = *end;
*end = swapChar;
}
}
nsresult ArabicShaping(const PRUnichar* aString, PRUint32 aLen,
PRUnichar* aBuf, PRUint32 *aBufLen,
PRBool aInputLogical, PRBool aOutputLogical)
{
nsAutoString tempString(aString, aLen);
PRUnichar *tempBuf = tempString.BeginWriting();
if (aInputLogical) {
ReverseString(tempBuf, aLen);
}
const PRUnichar* src = tempBuf;
const PRUnichar* p;
PRUnichar* dest = aBuf;
PRUnichar formB;
PRInt8 leftJ, thisJ, rightJ;
PRInt8 leftNoTrJ, rightNoTrJ;
thisJ = leftNoTrJ = eNJ;
rightJ = GetJoiningClass(*(src));
while(src<tempBuf+aLen-1) {
leftJ = thisJ;
if ((eTr != leftJ) || ((leftJ == eTr) &&
( ( (src-1) >= tempBuf) && !IS_ARABIC_CHAR(*(src-1)))))
leftNoTrJ = thisJ;
if(src-2 >= (tempBuf)){
for(p=src-2; (p >= (tempBuf))&& (eTr == leftNoTrJ) && (IS_ARABIC_CHAR(*(p+1))) ; p--)
leftNoTrJ = GetJoiningClass(*(p)) ;
}
thisJ = rightJ;
rightJ = rightNoTrJ = GetJoiningClass(*(src+1)) ;
if(src+2 <= (tempBuf+aLen-1)){
for(p=src+2; (p <= (tempBuf+aLen-1))&&(eTr == rightNoTrJ) && (IS_ARABIC_CHAR(*(src+1))); p++)
rightNoTrJ = GetJoiningClass(*(p)) ;
}
formB = PresentationFormB(*src, DecideForm(leftNoTrJ, thisJ, rightNoTrJ));
*dest++ = formB;
src++;
}
if((eTr != thisJ) ||
((thisJ == eTr) && (((src-1)>=tempBuf) && (!IS_ARABIC_CHAR(*(src-1))))))
leftNoTrJ = thisJ;
if(src-2 >= (tempBuf)){
for(p=src-2; (src-2 >= (tempBuf)) && (eTr == leftNoTrJ) && (IS_ARABIC_CHAR(*(p+1))); p--)
leftNoTrJ = GetJoiningClass(*(p)) ;
}
formB = PresentationFormB(*src, DecideForm(leftNoTrJ, rightJ, eNJ));
*dest++ = formB;
src++;
PRUnichar *lSrc = aBuf;
PRUnichar *lDest = aBuf;
while(lSrc < (dest-1)) {
PRUnichar next = *(lSrc+1);
if(((0xFEDF == next) || (0xFEE0 == next)) &&
(0xFE80 == (0xFFF1 & *lSrc))) {
PRBool done = PR_FALSE;
PRUint16 key = ((*lSrc) << 8) | ( 0x00FF & next);
PRUint16 i;
for(i=0;i<8;i++) {
if(key == gArabicLigatureMap[i]) {
done = PR_TRUE;
// lam and alef in the source are mapped to a lam-alef ligature in the
// destination, so lSrc is incremented by 2 here
*lDest++ = 0xFEF5 + i;
lSrc+=2;
break;
}
}
if(! done)
*lDest++ = *lSrc++;
}
else
*lDest++ = *lSrc++;
}
if(lSrc < dest)
*lDest++ = *lSrc++;
*aBufLen = lDest - aBuf;
if (aOutputLogical) {
ReverseString(aBuf, *aBufLen);
}
return NS_OK;
}
nsresult Conv_FE_06(const nsString& aSrc, nsString& aDst)
{
PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
PRUint32 i, size = aSrc.Length();
aDst.Truncate();
for (i=0;i<size;i++) { // i : Source
if (aSrcUnichars[i] == 0x0000)
break; // no need to convert char after the NULL
if (IS_FE_CHAR(aSrcUnichars[i])) {
//ahmed for lamalf
PRUnichar ch = (PresentationToOriginal(aSrcUnichars[i], 1));
if(ch)
aDst += ch;
ch=(PresentationToOriginal(aSrcUnichars[i], 0));
if(ch)
aDst += ch;
else //if it is 00, just output what we have in FExx
aDst += aSrcUnichars[i];
} else {
aDst += aSrcUnichars[i]; // copy it even if it is not in FE range
}
}// for : loop the buffer
return NS_OK;
}
nsresult Conv_FE_06_WithReverse(const nsString& aSrc, nsString& aDst)
{
PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
PRBool foundArabic = PR_FALSE;
PRUint32 i, endArabic, beginArabic, size;
beginArabic = 0;
size = aSrc.Length();
aDst.Truncate();
for (endArabic=0;endArabic<size;endArabic++) {
if (aSrcUnichars[endArabic] == 0x0000)
break; // no need to convert char after the NULL
while( (IS_FE_CHAR(aSrcUnichars[endArabic]))||
(IS_ARABIC_CHAR(aSrcUnichars[endArabic]))||
(IS_ARABIC_DIGIT(aSrcUnichars[endArabic]))||
(aSrcUnichars[endArabic]==0x0020))
{
if(! foundArabic ) {
beginArabic=endArabic;
foundArabic= PR_TRUE;
}
endArabic++;
}
if(foundArabic) {
endArabic--;
for (i=endArabic; i>=beginArabic; i--) {
if(IS_FE_CHAR(aSrcUnichars[i])) {
//ahmed for the bug of lamalf
aDst += PresentationToOriginal(aSrcUnichars[i], 0);
if (PresentationToOriginal(aSrcUnichars[i], 1)) {
// Two characters, we have to resize the buffer :(
aDst += PresentationToOriginal(aSrcUnichars[i], 1);
} // if expands to 2 char
} else {
// do we need to check the following if ?
if((IS_ARABIC_CHAR(aSrcUnichars[i]))||
(IS_ARABIC_DIGIT(aSrcUnichars[i]))||
(aSrcUnichars[i]==0x0020))
aDst += aSrcUnichars[i];
}
}
} else {
aDst += aSrcUnichars[endArabic];
}
foundArabic=PR_FALSE;
}// for : loop the buffer
return NS_OK;
}
nsresult Conv_06_FE_WithReverse(const nsString& aSrc,
nsString& aDst,
PRUint32 aDir)
{
PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
PRUint32 i, beginArabic, endArabic, size;
beginArabic = 0;
size = aSrc.Length();
aDst.Truncate();
PRBool foundArabic = PR_FALSE;
for (endArabic=0;endArabic<size;endArabic++) {
if (aSrcUnichars[endArabic] == 0x0000)
break; // no need to convert char after the NULL
while( (IS_06_CHAR(aSrcUnichars[endArabic])) ||
(IS_ARABIC_CHAR(aSrcUnichars[endArabic])) ||
(aSrcUnichars[endArabic]==0x0020) ||
(IS_ARABIC_DIGIT(aSrcUnichars[endArabic])) )
{
if(! foundArabic) {
beginArabic=endArabic;
foundArabic=PR_TRUE;
}
endArabic++;
}
if(foundArabic) {
endArabic--;
PRUnichar buf[8192];
PRUint32 len=8192;
ArabicShaping(&aSrcUnichars[beginArabic], endArabic-beginArabic+1,
buf, &len,
PR_TRUE, PR_FALSE);
// to reverse the numerals
PRUint32 endNumeral, beginNumeral = 0;
for (endNumeral=0;endNumeral<=len-1;endNumeral++){
PRBool foundNumeral = PR_FALSE;
while((endNumeral < len) && (IS_ARABIC_DIGIT(buf[endNumeral])) ) {
if(!foundNumeral)
{
foundNumeral=PR_TRUE;
beginNumeral=endNumeral;
}
endNumeral++;
}
if(foundNumeral){
endNumeral--;
PRUnichar numbuf[20];
for(i=beginNumeral; i<=endNumeral; i++){
numbuf[i-beginNumeral]=buf[endNumeral-i+beginNumeral];
}
for(i=0;i<=endNumeral-beginNumeral;i++){
buf[i+beginNumeral]=numbuf[i];
}
}
}
if(aDir==1){//ltr
for (i=0;i<=len-1;i++){
aDst+= buf[i];
}
}
else if(aDir==2){//rtl
for (i=0;i<=len-1;i++){
aDst+= buf[len-1-i];
}
}
} else {
aDst += aSrcUnichars[endArabic];
}
foundArabic=PR_FALSE;
}// for : loop the buffer
return NS_OK;
}
nsresult HandleNumbers(PRUnichar* aBuffer, PRUint32 aSize, PRUint32 aNumFlag)
{
PRUint32 i;
// IBMBIDI_NUMERAL_NOMINAL *
// IBMBIDI_NUMERAL_REGULAR
// IBMBIDI_NUMERAL_HINDICONTEXT
// IBMBIDI_NUMERAL_ARABIC
// IBMBIDI_NUMERAL_HINDI
switch (aNumFlag) {
case IBMBIDI_NUMERAL_HINDI:
for (i=0;i<aSize;i++)
aBuffer[i] = NUM_TO_HINDI(aBuffer[i]);
break;
case IBMBIDI_NUMERAL_ARABIC:
for (i=0;i<aSize;i++)
aBuffer[i] = NUM_TO_ARABIC(aBuffer[i]);
break;
case IBMBIDI_NUMERAL_REGULAR:
case IBMBIDI_NUMERAL_HINDICONTEXT:
// for clipboard handling
//XXX do we really want to convert numerals when copying text?
for (i=1;i<aSize;i++) {
if (IS_ARABIC_CHAR(aBuffer[i-1]))
aBuffer[i] = NUM_TO_HINDI(aBuffer[i]);
else
aBuffer[i] = NUM_TO_ARABIC(aBuffer[i]);
}
case IBMBIDI_NUMERAL_NOMINAL:
default:
break;
}
return NS_OK;
}
nsresult HandleNumbers(const nsString& aSrc, nsString& aDst)
{
aDst = aSrc;
return HandleNumbers((PRUnichar *)aDst.get(),aDst.Length(), IBMBIDI_NUMERAL_REGULAR);
}

View File

@@ -1,243 +0,0 @@
/* -*- 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
* IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Maha Abou El Rous <mahar@eg.ibm.com>
* Lina Kemmel <lkemmel@il.ibm.com>
* Simon Montagu <smontagu@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 ***** */
#ifndef nsBidiUtils_h__
#define nsBidiUtils_h__
#include "nsCOMPtr.h"
#include "nsString.h"
/**
* Perform Arabic shaping on a Unichar string
* @param aString is the input string
* @param aLen is the length of aStrong
* @param aBuf receives the shaped output
* @param aBuflen receives the length of aBuf
* @param aInputLogical indicates that the input is in logical order
* @param aOutputLogical indicates that the output should be in logical order
*/
nsresult ArabicShaping(const PRUnichar* aString, PRUint32 aLen,
PRUnichar* aBuf, PRUint32* aBufLen,
PRBool aInputLogical, PRBool aOutputLogical);
/**
* Scan an nsString, converting characters in the FExx range (Arabic presentation forms) to the equivalent characters in the 06xx
* range
* @param aSrc is the input string
* @param aDst is the output string
*/
nsresult Conv_FE_06(const nsString& aSrc, nsString& aDst);
/**
* Scan an nsString, converting characters in the FExx range (Arabic presentation forms) to the equivalent characters in the 06xx
* range, and also reverse the string
* @param aSrc is the input string
* @param aDst is the output string
*/
nsresult Conv_FE_06_WithReverse(const nsString& aSrc, nsString& aDst);
/**
* Scan an nsString, converting characters in the 06xx range to the equivalent characters in the 0Fxx range (Arabic presentation
* forms), with the option to reverse the string
* @param aSrc is the input string
* @param aDst is the output string
* @param aDir indicates whether the string should be reversed
* IBMBIDI_TEXTDIRECTION_LTR: do not reverse the string
* IBMBIDI_TEXTDIRECTION_RTL: reverse the string
*/
nsresult Conv_06_FE_WithReverse(const nsString& aSrc, nsString& aDst, PRUint32 aDir);
/**
* Scan a Unichar string, converting numbers to Arabic or Hindi forms in place
* @param aBuffer is the string
* @param aSize is the size of aBuffer
* @param aNumFlag specifies the conversion to perform:
* IBMBIDI_NUMERAL_NOMINAL: don't do any conversion
* IBMBIDI_NUMERAL_HINDI: convert to Hindi forms (Unicode 0660-0669)
* IBMBIDI_NUMERAL_ARABIC: convert to Arabic forms (Unicode 0030-0039)
* IBMBIDI_NUMERAL_HINDICONTEXT: convert numbers in Arabic text to Hindi, otherwise to Arabic
*/
nsresult HandleNumbers(PRUnichar* aBuffer, PRUint32 aSize, PRUint32 aNumFlag);
/**
* Scan an nsString, converting numerals to Arabic or Hindi forms
* @param aSrc is the input string
* @param aDst is the output string
*/
nsresult HandleNumbers(const nsString& aSrc, nsString& aDst);
// --------------------------------------------------
// IBMBIDI
// --------------------------------------------------
//
// These values are shared with Preferences dialog
// ------------------
// If Pref values are to be changed
// in the XUL file of Prefs. the values
// Must be changed here too..
// ------------------
//
#define IBMBIDI_TEXTDIRECTION_STR "bidi.direction"
#define IBMBIDI_TEXTTYPE_STR "bidi.texttype"
#define IBMBIDI_CONTROLSTEXTMODE_STR "bidi.controlstextmode"
#define IBMBIDI_NUMERAL_STR "bidi.numeral"
#define IBMBIDI_SUPPORTMODE_STR "bidi.support"
#define IBMBIDI_CHARSET_STR "bidi.characterset"
#define IBMBIDI_TEXTDIRECTION 1
#define IBMBIDI_TEXTTYPE 2
#define IBMBIDI_CONTROLSTEXTMODE 3
#define IBMBIDI_NUMERAL 4
#define IBMBIDI_SUPPORTMODE 5
#define IBMBIDI_CHARSET 6
// ------------------
// Text Direction
// ------------------
// bidi.direction
#define IBMBIDI_TEXTDIRECTION_LTR 1 // 1 = directionLTRBidi *
#define IBMBIDI_TEXTDIRECTION_RTL 2 // 2 = directionRTLBidi
// ------------------
// Text Type
// ------------------
// bidi.texttype
#define IBMBIDI_TEXTTYPE_CHARSET 1 // 1 = charsettexttypeBidi *
#define IBMBIDI_TEXTTYPE_LOGICAL 2 // 2 = logicaltexttypeBidi
#define IBMBIDI_TEXTTYPE_VISUAL 3 // 3 = visualtexttypeBidi
// ------------------
// Controls Text Mode
// ------------------
// bidi.controlstextmode
#define IBMBIDI_CONTROLSTEXTMODE_LOGICAL 1 // 1 = logicalcontrolstextmodeBidiCmd *
#define IBMBIDI_CONTROLSTEXTMODE_VISUAL 2 // 2 = visualcontrolstextmodeBidi
#define IBMBIDI_CONTROLSTEXTMODE_CONTAINER 3 // 3 = containercontrolstextmodeBidi
// ------------------
// Numeral Style
// ------------------
// bidi.numeral
#define IBMBIDI_NUMERAL_NOMINAL 0 // 0 = nominalnumeralBidi *
#define IBMBIDI_NUMERAL_REGULAR 1 // 1 = regularcontextnumeralBidi
#define IBMBIDI_NUMERAL_HINDICONTEXT 2 // 2 = hindicontextnumeralBidi
#define IBMBIDI_NUMERAL_ARABIC 3 // 3 = arabicnumeralBidi
#define IBMBIDI_NUMERAL_HINDI 4 // 4 = hindinumeralBidi
// ------------------
// Support Mode
// ------------------
// bidi.support
#define IBMBIDI_SUPPORTMODE_MOZILLA 1 // 1 = mozillaBidisupport *
#define IBMBIDI_SUPPORTMODE_OSBIDI 2 // 2 = OsBidisupport
#define IBMBIDI_SUPPORTMODE_DISABLE 3 // 3 = disableBidisupport
// ------------------
// Charset Mode
// ------------------
// bidi.characterset
#define IBMBIDI_CHARSET_BIDI 1 // 1 = doccharactersetBidi *
#define IBMBIDI_CHARSET_DEFAULT 2 // 2 = defaultcharactersetBidi
#define IBMBIDI_DEFAULT_BIDI_OPTIONS \
((IBMBIDI_TEXTDIRECTION_LTR<<0) | \
(IBMBIDI_TEXTTYPE_CHARSET<<4) | \
(IBMBIDI_CONTROLSTEXTMODE_LOGICAL<<8) | \
(IBMBIDI_NUMERAL_NOMINAL<<12) | \
(IBMBIDI_SUPPORTMODE_MOZILLA<<16) | \
(IBMBIDI_CHARSET_BIDI<<20))
#define GET_BIDI_OPTION_DIRECTION(bo) (((bo)>>0) & 0x0000000F) /* 4 bits for DIRECTION */
#define GET_BIDI_OPTION_TEXTTYPE(bo) (((bo)>>4) & 0x0000000F) /* 4 bits for TEXTTYPE */
#define GET_BIDI_OPTION_CONTROLSTEXTMODE(bo) (((bo)>>8) & 0x0000000F) /* 4 bits for CONTROLTEXTMODE */
#define GET_BIDI_OPTION_NUMERAL(bo) (((bo)>>12) & 0x0000000F) /* 4 bits for NUMERAL */
#define GET_BIDI_OPTION_SUPPORT(bo) (((bo)>>16) & 0x0000000F) /* 4 bits for SUPPORT */
#define GET_BIDI_OPTION_CHARACTERSET(bo) (((bo)>>20) & 0x0000000F) /* 4 bits for CHARACTERSET */
#define SET_BIDI_OPTION_DIRECTION(bo, dir) {(bo)=((bo) & 0xFFFFFFF0)|(((dir)& 0x0000000F)<<0);}
#define SET_BIDI_OPTION_TEXTTYPE(bo, tt) {(bo)=((bo) & 0xFFFFFF0F)|(((tt)& 0x0000000F)<<4);}
#define SET_BIDI_OPTION_CONTROLSTEXTMODE(bo, cotm) {(bo)=((bo) & 0xFFFFF0FF)|(((cotm)& 0x0000000F)<<8);}
#define SET_BIDI_OPTION_NUMERAL(bo, num) {(bo)=((bo) & 0xFFFF0FFF)|(((num)& 0x0000000F)<<12);}
#define SET_BIDI_OPTION_SUPPORT(bo, sup) {(bo)=((bo) & 0xFFF0FFFF)|(((sup)& 0x0000000F)<<16);}
#define SET_BIDI_OPTION_CHARACTERSET(bo, cs) {(bo)=((bo) & 0xFF0FFFFF)|(((cs)& 0x0000000F)<<20);}
/* Constants related to the position of numerics in the codepage */
#define START_HINDI_DIGITS 0x0660
#define END_HINDI_DIGITS 0x0669
#define START_ARABIC_DIGITS 0x0030
#define END_ARABIC_DIGITS 0x0039
#define START_FARSI_DIGITS 0x06f0
#define END_FARSI_DIGITS 0x06f9
#define IS_HINDI_DIGIT(u) ( ( (u) >= START_HINDI_DIGITS ) && ( (u) <= END_HINDI_DIGITS ) )
#define IS_ARABIC_DIGIT(u) ( ( (u) >= START_ARABIC_DIGITS ) && ( (u) <= END_ARABIC_DIGITS ) )
#define IS_FARSI_DIGIT(u) ( ( (u) >= START_FARSI_DIGITS ) && ( (u) <= END_FARSI_DIGITS ) )
#define IS_ARABIC_SEPARATOR(u) ( ( (u) == 0x066A ) || ( (u) == 0x066B ) || ( (u) == 0x066C ) )
#define IS_BIDI_DIACRITIC(u) ( \
( (u) >= 0x0591 && (u) <= 0x05A1) || ( (u) >= 0x05A3 && (u) <= 0x05B9) \
|| ( (u) >= 0x05BB && (u) <= 0x05BD) || ( (u) == 0x05BF) || ( (u) == 0x05C1) \
|| ( (u) == 0x05C2) || ( (u) == 0x05C4) \
|| ( (u) >= 0x064B && (u) <= 0x0652) || ( (u) == 0x0670) \
|| ( (u) >= 0x06D7 && (u) <= 0x06E4) || ( (u) == 0x06E7) || ( (u) == 0x06E8) \
|| ( (u) >= 0x06EA && (u) <= 0x06ED) )
#define IS_HEBREW_CHAR(c) (((0x0590 <= (c)) && ((c)<= 0x05FF)) || (((c) >= 0xfb1d) && ((c) <= 0xfb4f)))
#define IS_06_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
#define IS_FE_CHAR(c) (((0xfb50 <= (c)) && ((c)<= 0xfbFF)) \
|| ((0xfe70 <= (c)) && ((c)<= 0xfeFC)))
#define IS_ARABIC_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
#define IS_ARABIC_ALPHABETIC(c) (IS_ARABIC_CHAR(c) && \
!(IS_HINDI_DIGIT(c) || IS_FARSI_DIGIT(c) || IS_ARABIC_SEPARATOR(c)))
/**
* The codepoint ranges in the following macros are based on the blocks
* allocated, or planned to be allocated, to right-to-left characters in the
* BMP (Basic Multilingual Plane) and SMP (Supplementary Multilingual Plane)
* according to
* http://unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt and
* http://www.unicode.org/roadmaps/
*/
#define IS_IN_BMP_RTL_BLOCK(c) ((0x590 <= (c)) && ((c) <= 0x8ff))
#define IS_RTL_PRESENTATION_FORM(c) (((0xfb1d <= (c)) && ((c) <= 0xfdff)) || \
((0xfe70 <= (c)) && ((c) <= 0xfefc)))
#define IS_IN_SMP_RTL_BLOCK(c) ((0x10800 <= (c)) && ((c) <= 0x10fff))
#define UCS2_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
(IS_RTL_PRESENTATION_FORM(c)))
#define UTF32_CHAR_IS_BIDI(c) ((IS_IN_BMP_RTL_BLOCK(c)) || \
(IS_RTL_PRESENTATION_FORM(c)) || \
(IS_IN_SMP_RTL_BLOCK(c)))
#endif /* nsBidiUtils_h__ */

View File

@@ -1,299 +0,0 @@
/* -*- 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
* 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 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 "nsCSSColorUtils.h"
#include <math.h>
// Weird color computing code stolen from winfe which was stolen
// from the xfe which was written originally by Eric Bina. So there.
#define RED_LUMINOSITY 30
#define GREEN_LUMINOSITY 59
#define BLUE_LUMINOSITY 11
#define INTENSITY_FACTOR 25
#define LIGHT_FACTOR 0
#define LUMINOSITY_FACTOR 75
#define MAX_COLOR 255
#define COLOR_DARK_THRESHOLD 51
#define COLOR_LIGHT_THRESHOLD 204
#define COLOR_LITE_BS_FACTOR 45
#define COLOR_LITE_TS_FACTOR 70
#define COLOR_DARK_BS_FACTOR 30
#define COLOR_DARK_TS_FACTOR 50
#define LIGHT_GRAY NS_RGB(192, 192, 192)
#define DARK_GRAY NS_RGB(96, 96, 96)
#define WHITE NS_RGB(255, 255, 255)
#define BLACK NS_RGB(0, 0, 0)
#define MAX_BRIGHTNESS 254
#define MAX_DARKNESS 0
void NS_Get3DColors(nscolor aResult[2], nscolor aBackgroundColor)
{
int rb = NS_GET_R(aBackgroundColor);
int gb = NS_GET_G(aBackgroundColor);
int bb = NS_GET_B(aBackgroundColor);
int brightness = NS_GetBrightness(rb,gb,bb);
int f0, f1;
if (brightness < COLOR_DARK_THRESHOLD) {
f0 = COLOR_DARK_BS_FACTOR;
f1 = COLOR_DARK_TS_FACTOR;
} else if (brightness > COLOR_LIGHT_THRESHOLD) {
f0 = COLOR_LITE_BS_FACTOR;
f1 = COLOR_LITE_TS_FACTOR;
} else {
f0 = COLOR_DARK_BS_FACTOR +
(brightness *
(COLOR_LITE_BS_FACTOR - COLOR_DARK_BS_FACTOR) / MAX_COLOR);
f1 = COLOR_DARK_TS_FACTOR +
(brightness *
(COLOR_LITE_TS_FACTOR - COLOR_DARK_TS_FACTOR) / MAX_COLOR);
}
int r = rb - (f0 * rb / 100);
int g = gb - (f0 * gb / 100);
int b = bb - (f0 * bb / 100);
aResult[0] = NS_RGB(r, g, b);
if ((r == rb) && (g == gb) && (b == bb)) {
aResult[0] = (aBackgroundColor == BLACK) ? DARK_GRAY : BLACK;
}
r = rb + (f1 * (MAX_COLOR - rb) / 100);
if (r > 255) r = 255;
g = gb + (f1 * (MAX_COLOR - gb) / 100);
if (g > 255) g = 255;
b = bb + (f1 * (MAX_COLOR - bb) / 100);
if (b > 255) b = 255;
aResult[1] = NS_RGB(r, g, b);
if ((r == rb) && (g == gb) && (b == bb)) {
aResult[1] = (aBackgroundColor == WHITE) ? LIGHT_GRAY : WHITE;
}
}
void NS_GetSpecial3DColors(nscolor aResult[2],
nscolor aBackgroundColor,
nscolor aBorderColor)
{
PRUint8 f0, f1;
PRUint8 r, g, b;
PRUint8 rb = NS_GET_R(aBorderColor);
PRUint8 gb = NS_GET_G(aBorderColor);
PRUint8 bb = NS_GET_B(aBorderColor);
// This needs to be optimized.
// Calculating background brightness again and again is
// a waste of time!!!. Just calculate it only once.
// .....somehow!!!
PRUint8 red = NS_GET_R(aBackgroundColor);
PRUint8 green = NS_GET_G(aBackgroundColor);
PRUint8 blue = NS_GET_B(aBackgroundColor);
PRUint8 elementBrightness = NS_GetBrightness(rb,gb,bb);
PRUint8 backgroundBrightness = NS_GetBrightness(red, green, blue);
if (backgroundBrightness < COLOR_DARK_THRESHOLD) {
f0 = COLOR_DARK_BS_FACTOR;
f1 = COLOR_DARK_TS_FACTOR;
if(elementBrightness == MAX_DARKNESS)
{
rb = NS_GET_R(DARK_GRAY);
gb = NS_GET_G(DARK_GRAY);
bb = NS_GET_B(DARK_GRAY);
}
}else if (backgroundBrightness > COLOR_LIGHT_THRESHOLD) {
f0 = COLOR_LITE_BS_FACTOR;
f1 = COLOR_LITE_TS_FACTOR;
if(elementBrightness == MAX_BRIGHTNESS)
{
rb = NS_GET_R(LIGHT_GRAY);
gb = NS_GET_G(LIGHT_GRAY);
bb = NS_GET_B(LIGHT_GRAY);
}
}else {
f0 = COLOR_DARK_BS_FACTOR +
(backgroundBrightness *
(COLOR_LITE_BS_FACTOR - COLOR_DARK_BS_FACTOR) / MAX_COLOR);
f1 = COLOR_DARK_TS_FACTOR +
(backgroundBrightness *
(COLOR_LITE_TS_FACTOR - COLOR_DARK_TS_FACTOR) / MAX_COLOR);
}
r = rb - (f0 * rb / 100);
g = gb - (f0 * gb / 100);
b = bb - (f0 * bb / 100);
aResult[0] = NS_RGB(r, g, b);
r = rb + (f1 * (MAX_COLOR - rb) / 100);
g = gb + (f1 * (MAX_COLOR - gb) / 100);
b = bb + (f1 * (MAX_COLOR - bb) / 100);
aResult[1] = NS_RGB(r, g, b);
}
int NS_GetBrightness(PRUint8 aRed, PRUint8 aGreen, PRUint8 aBlue)
{
PRUint8 intensity = (aRed + aGreen + aBlue) / 3;
PRUint8 luminosity =
((RED_LUMINOSITY * aRed) / 100) +
((GREEN_LUMINOSITY * aGreen) / 100) +
((BLUE_LUMINOSITY * aBlue) / 100);
return ((intensity * INTENSITY_FACTOR) +
(luminosity * LUMINOSITY_FACTOR)) / 100;
}
// Function to convert RGB color space into the HSV colorspace
// Hue is the primary color defined from 0 to 359 degrees
// Saturation is defined from 0 to 255. The higher the number.. the deeper the color
// Value is the brightness of the color. 0 is black, 255 is white.
void
NS_RGB2HSV(nscolor aColor,PRUint16 &aHue,PRUint16 &aSat,PRUint16 &aValue)
{
PRUint8 r,g,b;
PRInt16 delta,min,max,r1,b1,g1;
float hue;
r = NS_GET_R(aColor);
g = NS_GET_G(aColor);
b = NS_GET_B(aColor);
if (r>g) {
max = r;
min = g;
} else {
max = g;
min = r;
}
if (b>max) {
max = b;
}
if (b<min) {
min = b;
}
// value or brightness will always be the max of all the colors(RGB)
aValue = max;
delta = max-min;
aSat = (max!=0)?((delta*255)/max):0;
r1 = r;
b1 = b;
g1 = g;
if (aSat==0) {
hue = 1000;
} else {
if(r==max){
hue=(float)(g1-b1)/(float)delta;
} else if (g1==max) {
hue= 2.0f+(float)(b1-r1)/(float)delta;
} else {
hue = 4.0f+(float)(r1-g1)/(float)delta;
}
}
if(hue<999) {
hue*=60;
if(hue<0){
hue+=360;
}
} else {
hue=0;
}
aHue = (PRUint16)hue;
}
// Function to convert HSV color space into the RGB colorspace
// Hue is the primary color defined from 0 to 359 degrees
// Saturation is defined from 0 to 255. The higher the number.. the deeper the color
// Value is the brightness of the color. 0 is black, 255 is white.
void
NS_HSV2RGB(nscolor &aColor,PRUint16 aHue,PRUint16 aSat,PRUint16 aValue)
{
PRUint16 r=0,g=0,b=0;
PRUint16 i,p,q,t;
double h,f,percent;
if ( aSat == 0 ){
// achromatic color, no hue is defined
r = aValue;
g = aValue;
b = aValue;
} else {
// hue in in degrees around the color wheel defined from
// 0 to 360 degrees.
if (aHue >= 360) {
aHue = 0;
}
// we break the color wheel into 6 areas.. these
// areas define how the saturation and value define the color.
// reds behave differently than the blues
h = (double)aHue / 60.0;
i = (PRUint16) floor(h);
f = h-(double)i;
percent = ((double)aValue/255.0); // this needs to be a value from 0 to 1, so a percentage
// can be calculated of the saturation.
p = (PRUint16)(percent*(255-aSat));
q = (PRUint16)(percent*(255-(aSat*f)));
t = (PRUint16)(percent*(255-(aSat*(1.0-f))));
// i is guarenteed to never be larger than 5.
switch(i){
case 0: r = aValue; g = t; b = p;break;
case 1: r = q; g = aValue; b = p;break;
case 2: r = p; g = aValue; b = t;break;
case 3: r = p; g = q; b = aValue;break;
case 4: r = t; g = p; b = aValue;break;
case 5: r = aValue; g = p; b = q;break;
}
}
aColor = NS_RGB(r,g,b);
}

View File

@@ -1,62 +0,0 @@
/* -*- 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
* 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 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 __nsCSSColorUtils_h
#define __nsCSSColorUtils_h
#include "nsColor.h"
// Weird color computing code stolen from winfe which was stolen
// from the xfe which was written originally by Eric Bina. So there.
// To determin colors based on the background brightness
void NS_Get3DColors(nscolor aResult[2], nscolor aBackgroundColor);
// To determine colors based on the background brightness and border color
void NS_GetSpecial3DColors(nscolor aResult[2],
nscolor aBackgroundColor,
nscolor aBorderColor);
// Determins brightness for a specific color
int NS_GetBrightness(PRUint8 aRed, PRUint8 aGreen, PRUint8 aBlue);
// function to convert from RGB color space to HSV color space
void NS_RGB2HSV(nscolor aColor,PRUint16 &aHue,PRUint16 &aSat,PRUint16 &aValue);
// function to convert from HSV color space to RGB color space
void NS_HSV2RGB(nscolor &aColor,PRUint16 aHue,PRUint16 aSat,PRUint16 aValue);
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,402 +0,0 @@
/* -*- 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
* 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 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 nsCSSRendering_h___
#define nsCSSRendering_h___
#include "nsIRenderingContext.h"
struct nsPoint;
class nsStyleContext;
class nsPresContext;
class nsCSSRendering {
public:
/**
* Render the border for an element using css rendering rules
* for borders. aSkipSides is a bitmask of the sides to skip
* when rendering. If 0 then no sides are skipped.
*
* Both aDirtyRect and aBorderArea are in the local coordinate space
* of aForFrame
*/
static void PaintBorder(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0,
nscoord aHardBorderSize = 0,
PRBool aShouldIgnoreRounded = PR_FALSE);
/**
* Render the outline for an element using css rendering rules
* for borders. aSkipSides is a bitmask of the sides to skip
* when rendering. If 0 then no sides are skipped.
*
* Both aDirtyRect and aBorderArea are in the local coordinate space
* of aForFrame
*/
static void PaintOutline(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
const nsStyleOutline& aOutlineStyle,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0);
/**
* Just like PaintBorder, but takes as input a list of border segments
* rather than a single border style. Useful for any object that needs to
* draw a border where an edge is not necessarily homogenous.
* Render the border for an element using css rendering rules
* for borders. aSkipSides is a bitmask of the sides to skip
* when rendering. If 0 then no sides are skipped.
*
* Both aDirtyRect and aBorderArea are in the local coordinate space
* of aForFrame
*/
static void PaintBorderEdges(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
nsBorderEdges * aBorderEdges,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0);
/**
* Fill in an nsStyleBackground to be used to paint the background for
* an element. The nsStyleBackground should first be initialized
* using the pres context. This applies the rules for propagating
* backgrounds between BODY, the root element, and the canvas.
*/
static PRBool FindBackground(nsPresContext* aPresContext,
nsIFrame* aForFrame,
const nsStyleBackground** aBackground,
PRBool* aIsCanvas);
/**
* Find a non-transparent background, for various table-related and
* HR-related backwards-compatibility hacks. Be very hesitant if
* you're considering calling this function -- it's usually not what
* you want.
*/
static const nsStyleBackground*
FindNonTransparentBackground(nsStyleContext* aContext,
PRBool aStartAtParent = PR_FALSE);
/**
* Render the background for an element using css rendering rules
* for backgrounds.
*
* Both aDirtyRect and aBorderArea are in the local coordinate space
* of aForFrame
*/
static void PaintBackground(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
PRBool aUsePrintSettings,
nsRect* aBGClipRect = nsnull);
/**
* Same as |PaintBackground|, except using the provided style context
* (which short-circuits the code that ensures that the root element's
* background is drawn on the canvas.
*/
static void PaintBackgroundWithSC(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
PRBool aUsePrintSettings = PR_FALSE,
nsRect* aBGClipRect = nsnull);
/**
* Called by the presShell when painting is finished, so we can clear our
* inline background data cache.
*/
static void DidPaint();
static void DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const PRUint8 borderStyles[],
const nscolor borderColors[],
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
nsRect* aGap);
static void DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const nsStyleColor* aColorStyle,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
PRBool aDoOutline,
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
nsRect* aGap);
/** draw the dashed segements of a segmented border */
//XXX: boy is it annoying that we have 3 methods to draw dashed sides!
// they clearly can be factored.
static void DrawDashedSegments(nsIRenderingContext& aContext,
const nsRect& aBounds,
nsBorderEdges * aBorderEdges,
PRIntn aSkipSides,
nsRect* aGap);
// Draw a border segment in the table collapsing border model without beveling corners
static void DrawTableBorderSegment(nsIRenderingContext& aContext,
PRUint8 aBorderStyle,
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
const nsRect& aBorderRect,
float aPixelsToTwips,
PRUint8 aStartBevelSide = 0,
nscoord aStartBevelOffset = 0,
PRUint8 aEndBevelSide = 0,
nscoord aEndBevelOffset = 0);
/**
* transform a color to a color that will show up on a printer if needed
* aMapColor - color to evaluate
* aIsPrinter - Is this a printing device
* return - the transformed color
*/
static nscolor TransformColor(nscolor aMapColor,PRBool aNoBackGround);
protected:
/**
* Render the border for an element using css rendering rules
* for borders. aSkipSides is a bitmask of the sides to skip
* when rendering. If 0 then no sides are skipped.
* Both aDirtyRect and aBorderArea are in the local coordinate space
* of aForFrame
*/
static void PaintRoundedBorder(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
PRInt16 aBorderRadius[4],nsRect* aGap = 0,
PRBool aIsOutline=PR_FALSE);
static void RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext,
const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsStyleContext* aStyleContext,
PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel,
PRBool aIsOutline=PR_FALSE);
static void PaintBackgroundColor(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aBgClipArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
const nsStylePadding& aPadding,
PRBool aCanPaintNonWhite);
static void PaintRoundedBackground(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aBorderArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
PRInt16 aTheRadius[4],
PRBool aCanPaintNonWhite);
static nscolor MakeBevelColor(PRIntn whichSide, PRUint8 style,
nscolor aBackgroundColor,
nscolor aBorderColor,
PRBool aSpecialCase);
static PRIntn MakeSide(nsPoint aPoints[],
nsIRenderingContext& aContext,
PRIntn whichSide,
const nsRect& outside, const nsRect& inside,
PRIntn aSkipSides,
PRIntn borderPart, float borderFrac,
nscoord twipsPerPixel);
static void DrawSide(nsIRenderingContext& aContext,
PRIntn whichSide,
const PRUint8 borderStyle,
const nscolor borderColor,
const nscolor aBackgroundColor,
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
nscoord twipsPerPixel,
nsRect* aGap = 0);
static void DrawCompositeSide(nsIRenderingContext& aContext,
PRIntn aWhichSide,
nsBorderColors* aCompositeColors,
const nsRect& aOuterRect,
const nsRect& aInnerRect,
PRInt16* aBorderRadii,
nscoord aTwipsPerPixel,
nsRect* aGap);
static void DrawLine (nsIRenderingContext& aContext,
nscoord aX1, nscoord aY1, nscoord aX2, nscoord aY2,
nsRect* aGap);
static void FillPolygon (nsIRenderingContext& aContext,
const nsPoint aPoints[],
PRInt32 aNumPoints,
nsRect* aGap);
};
/** ---------------------------------------------------
* Class QBCurve, a quadratic bezier curve, used to implement the rounded rectangles
* @update 3/26/99 dwc
*/
class QBCurve
{
public:
nsFloatPoint mAnc1;
nsFloatPoint mCon;
nsFloatPoint mAnc2;
QBCurve() {mAnc1.x=0;mAnc1.y=0;mCon=mAnc2=mAnc1;}
void SetControls(nsFloatPoint &aAnc1,nsFloatPoint &aCon,nsFloatPoint &aAnc2) { mAnc1 = aAnc1; mCon = aCon; mAnc2 = aAnc2;}
void SetPoints(float a1x,float a1y,float acx,float acy,float a2x,float a2y) {mAnc1.MoveTo(a1x,a1y),mCon.MoveTo(acx,acy),mAnc2.MoveTo(a2x,a2y);}
/** ---------------------------------------------------
* Divide a Quadratic curve into line segments if it is not smaller than a certain size
* else it is so small that it can be approximated by 2 lineto calls
* @param aRenderingContext -- The RenderingContext to use to draw with
* @param aPointArray[] -- A list of points we can put line calls into instead of drawing. If null, lines are drawn
* @param aCurInex -- a pointer to an Integer that tells were to put the points into the array, incremented when finished
* @update 3/26/99 dwc
*/
void SubDivide(nsIRenderingContext *aRenderingContext,nsPoint aPointArray[],PRInt32 *aCurIndex);
/** ---------------------------------------------------
* Divide a Quadratic Bezier curve at the mid-point
* @update 3/26/99 dwc
* @param aCurve1 -- Curve 1 as a result of the division
* @param aCurve2 -- Curve 2 as a result of the division
*/
void MidPointDivide(QBCurve *A,QBCurve *B);
};
/** ---------------------------------------------------
* Class RoundedRect, A class to encapsulate all the rounded rect functionality,
* which are based on the QBCurve
* @update 4/13/99 dwc
*/
class RoundedRect
{
public:
PRInt32 mRoundness[4];
PRBool mDoRound;
PRInt32 mLeft;
PRInt32 mRight;
PRInt32 mTop;
PRInt32 mBottom;
/**
* Construct a rounded rectangle object
* @update 4/19/99
*/
void RoundRect() {mRoundness[0]=0;}
/**
* Set the curves boundaries and then break it up into the curve pieces for rendering
* @update 4/13/99 dwc
* @param aLeft -- Left side of bounding box
* @param aTop -- Top side of bounding box
* @param aWidth -- Width of bounding box
* @param aHeight -- Height of bounding box
* @param aRadius -- radius for the rounding
*/
void Set(nscoord aLeft,nscoord aTop,PRInt32 aWidth,PRInt32 aHeight,PRInt16 aRadius[4],PRInt16 aNumTwipPerPix);
/**
* Calculate the inset of a curve based on a border
* @update 4/13/99 dwc
* @param aLeft -- Left side of bounding box
* @param aTop -- Top side of bounding box
*/
void CalcInsetCurves(QBCurve &aULCurve,QBCurve &aURCurve,QBCurve &aLLCurve,QBCurve &aLRCurve,nsMargin &aBorder);
/** ---------------------------------------------------
* set the passed in curves to the rounded borders of the rectangle
* @update 4/13/99 dwc
* @param aULCurve -- upperleft curve
* @param aURCurve -- upperright curve
* @param aLRCurve -- lowerright curve
* @param aLLCurve -- lowerleft curve
*/
void GetRoundedBorders(QBCurve &aULCurve,QBCurve &aURCurve,QBCurve &aLLCurve,QBCurve &aLRCurve);
};
#endif /* nsCSSRendering_h___ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,131 +0,0 @@
/* -*- 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
* 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 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 "nsCoord.h"
#include "nsISelectionListener.h"
#include "nsIRenderingContext.h"
#include "nsITimer.h"
#include "nsICaret.h"
#include "nsWeakPtr.h"
#ifdef IBMBIDI
#include "nsIBidiKeyboard.h"
#endif
class nsIView;
//-----------------------------------------------------------------------------
class nsCaret : public nsICaret,
public nsISelectionListener
{
public:
nsCaret();
virtual ~nsCaret();
NS_DECL_ISUPPORTS
public:
// nsICaret interface
NS_IMETHOD Init(nsIPresShell *inPresShell);
NS_IMETHOD Terminate();
NS_IMETHOD GetCaretDOMSelection(nsISelection **outDOMSel);
NS_IMETHOD SetCaretDOMSelection(nsISelection *inDOMSel);
NS_IMETHOD GetCaretVisible(PRBool *outMakeVisible);
NS_IMETHOD SetCaretVisible(PRBool intMakeVisible);
NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly);
NS_IMETHOD GetCaretCoordinates(EViewCoordinates aRelativeToType, nsISelection *inDOMSel, nsRect* outCoordinates, PRBool* outIsCollapsed, nsIView **outView);
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame);
NS_IMETHOD EraseCaret();
NS_IMETHOD SetVisibilityDuringSelection(PRBool aVisibility);
NS_IMETHOD DrawAtPosition(nsIDOMNode* aNode, PRInt32 aOffset);
//nsISelectionListener interface
NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason);
static void CaretBlinkCallback(nsITimer *aTimer, void *aClosure);
protected:
void KillTimer();
nsresult PrimeTimer();
nsresult StartBlinking();
nsresult StopBlinking();
void GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordType, nsPoint &viewOffset, nsRect& outClipRect, nsIView **outRenderingView, nsIView **outRelativeView);
PRBool SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, nsIFrameSelection::HINT aFrameHint);
PRBool MustDrawCaret();
void DrawCaret();
void GetCaretRectAndInvert();
void ToggleDrawnStatus() { mDrawn = !mDrawn; }
protected:
nsWeakPtr mPresShell;
nsWeakPtr mDomSelectionWeak;
nsCOMPtr<nsITimer> mBlinkTimer;
nsCOMPtr<nsIRenderingContext> mRendContext;
PRUint32 mBlinkRate; // time for one cyle (off then on), in milliseconds
nscoord mCaretTwipsWidth; // caret width in twips. this gets calculated laziiy
nscoord mBidiIndicatorTwipsSize; // width and height of bidi indicator
PRPackedBool mVisible; // is the caret blinking
PRPackedBool mDrawn; // this should be mutable
PRPackedBool mReadOnly; // it the caret in readonly state (draws differently)
PRPackedBool mShowDuringSelection; // show when text is selected
nsRect mCaretRect; // the last caret rect
nsIFrame* mLastCaretFrame; // store the frame the caret was last drawn in.
nsIView* mLastCaretView; // last view that we used for drawing. Cached so we can tell when we need to make a new RC
PRInt32 mLastContentOffset;
#ifdef IBMBIDI
nsRect mHookRect; // directional hook on the caret
nsCOMPtr<nsIBidiKeyboard> mBidiKeyboard; // Bidi keyboard object to set and query keyboard language
PRPackedBool mKeyboardRTL; // is the keyboard language right-to-left
#endif
};

View File

@@ -1,114 +0,0 @@
/* -*- 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
* Netscape 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 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 nsChangeHint_h___
#define nsChangeHint_h___
#include "prtypes.h"
// Defines for various style related constants
enum nsChangeHint {
nsChangeHint_RepaintFrame = 0x01, // change was visual only (e.g., COLOR=)
nsChangeHint_ReflowFrame = 0x02, // change requires reflow (e.g., WIDTH=)
nsChangeHint_SyncFrameView = 0x04, // change requires view to be updated, if there is one (e.g., clip:)
nsChangeHint_ReconstructFrame = 0x08 // change requires frame change (e.g., display:)
// This subsumes all the above
// TBD: add nsChangeHint_ForceFrameView to force frame reconstruction if the frame doesn't yet
// have a view
};
#ifdef DEBUG_roc
// Redefine these operators to return nothing. This will catch any use
// of these operators on hints. We should not be using these operators
// on nsChangeHints
inline void operator<(nsChangeHint s1, nsChangeHint s2) {}
inline void operator>(nsChangeHint s1, nsChangeHint s2) {}
inline void operator!=(nsChangeHint s1, nsChangeHint s2) {}
inline void operator==(nsChangeHint s1, nsChangeHint s2) {}
inline void operator<=(nsChangeHint s1, nsChangeHint s2) {}
inline void operator>=(nsChangeHint s1, nsChangeHint s2) {}
#endif
// Operators on nsChangeHints
// Merge two hints, taking the union
inline nsChangeHint NS_CombineHint(nsChangeHint aH1, nsChangeHint aH2) {
return (nsChangeHint)(aH1 | aH2);
}
// Merge two hints, taking the union
inline nsChangeHint NS_SubtractHint(nsChangeHint aH1, nsChangeHint aH2) {
return (nsChangeHint)(aH1 & ~aH2);
}
// Merge the "src" hint into the "dst" hint
// Returns true iff the destination changed
inline PRBool NS_UpdateHint(nsChangeHint& aDest, nsChangeHint aSrc) {
nsChangeHint r = (nsChangeHint)(aDest | aSrc);
PRBool changed = (int)r != (int)aDest;
aDest = r;
return changed;
}
// Returns true iff the second hint contains all the hints of the first hint
inline PRBool NS_IsHintSubset(nsChangeHint aSubset, nsChangeHint aSuperSet) {
return (aSubset & aSuperSet) == aSubset;
}
// Redefine the old NS_STYLE_HINT constants in terms of the new hint structure
#define NS_STYLE_HINT_NONE \
nsChangeHint(0)
#define NS_STYLE_HINT_VISUAL \
nsChangeHint(nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView)
#define NS_STYLE_HINT_REFLOW \
nsChangeHint(NS_STYLE_HINT_VISUAL | nsChangeHint_ReflowFrame)
#define NS_STYLE_HINT_FRAMECHANGE \
nsChangeHint(NS_STYLE_HINT_REFLOW | nsChangeHint_ReconstructFrame)
/**
* |nsReStyleHint| is a bitfield for the result of |HasStateDependentStyle|
* and |HasAttributeDependentStyle|. All values have an implied "and
* descendants." When no restyling is necesary, use |nsReStyleHint(0)|.
*/
enum nsReStyleHint {
eReStyle_Self = 0x1,
eReStyle_LaterSiblings = 0x2
};
#endif /* nsChangeHint_h___ */

View File

@@ -1,84 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:cindent:ts=2:et:sw=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) 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 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 "nsChildIterator.h"
#include "nsIDocument.h"
#include "nsIBindingManager.h"
nsresult
ChildIterator::Init(nsIContent* aContent,
ChildIterator* aFirst,
ChildIterator* aLast)
{
// Initialize out parameters to be equal, in case of failure.
aFirst->mContent = aLast->mContent = nsnull;
aFirst->mIndex = aLast->mIndex = 0;
NS_PRECONDITION(aContent != nsnull, "no content");
if (! aContent)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDocument> doc = aContent->GetDocument();
NS_ASSERTION(doc, "element not in the document");
if (! doc)
return NS_ERROR_FAILURE;
nsIBindingManager *mgr = doc->GetBindingManager();
if (! mgr)
return NS_ERROR_FAILURE;
// If this node has XBL children, then use them. Otherwise, just use
// the vanilla content APIs.
nsCOMPtr<nsIDOMNodeList> nodes;
mgr->GetXBLChildNodesFor(aContent, getter_AddRefs(nodes));
PRUint32 length;
if (nodes)
nodes->GetLength(&length);
else
length = aContent->GetChildCount();
aFirst->mContent = aContent;
aLast->mContent = aContent;
aFirst->mIndex = 0;
aLast->mIndex = length;
aFirst->mNodes = nodes;
aLast->mNodes = nodes;
return NS_OK;
}

View File

@@ -1,150 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:cindent:ts=2:et:sw=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) 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 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 "nsCOMPtr.h"
#include "nsIContent.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMNode.h"
/**
* Helper class for iterating children during frame construction.
* This class should always be used in lieu of the straight content
* node APIs, since it handles XBL-generated anonymous content as
* well.
*/
class ChildIterator
{
protected:
nsCOMPtr<nsIContent> mContent;
PRUint32 mIndex;
nsCOMPtr<nsIDOMNodeList> mNodes;
public:
ChildIterator()
: mIndex(0) {}
ChildIterator(const ChildIterator& aOther)
: mContent(aOther.mContent),
mIndex(aOther.mIndex),
mNodes(aOther.mNodes) {}
ChildIterator& operator=(const ChildIterator& aOther) {
mContent = aOther.mContent;
mIndex = aOther.mIndex;
mNodes = aOther.mNodes;
return *this;
}
ChildIterator& operator++() {
++mIndex;
return *this;
}
ChildIterator operator++(int) {
ChildIterator result(*this);
++mIndex;
return result;
}
ChildIterator& operator--() {
--mIndex;
return *this;
}
ChildIterator operator--(int) {
ChildIterator result(*this);
--mIndex;
return result;
}
already_AddRefed<nsIContent> get() const {
nsIContent* result = nsnull;
if (mNodes) {
nsCOMPtr<nsIDOMNode> node;
mNodes->Item(mIndex, getter_AddRefs(node));
CallQueryInterface(node, &result);
} else {
result = mContent->GetChildAt(PRInt32(mIndex));
NS_IF_ADDREF(result);
}
return result;
}
already_AddRefed<nsIContent> operator*() const { return get(); }
PRBool operator==(const ChildIterator& aOther) const {
return mContent == aOther.mContent && mIndex == aOther.mIndex;
}
PRBool operator!=(const ChildIterator& aOther) const {
return !aOther.operator==(*this);
}
PRUint32 index() {
return mIndex;
}
void seek(PRUint32 aIndex) {
// Make sure that aIndex is reasonable. This should be |#ifdef
// DEBUG|, but we need these numbers for the temporary workaround
// for bug 133219.
PRUint32 length;
if (mNodes)
mNodes->GetLength(&length);
else
length = mContent->GetChildCount();
NS_ASSERTION(PRInt32(aIndex) >= 0 && aIndex <= length, "out of bounds");
// Temporary workaround for bug 133219.
if (aIndex > length)
aIndex = length;
mIndex = aIndex;
}
/**
* Create a pair of ChildIterators for a content node. aFirst will
* point to the first child of aContent; aLast will point one past
* the last child of aContent.
*/
static nsresult Init(nsIContent* aContent,
ChildIterator* aFirst,
ChildIterator* aLast);
};

View File

@@ -1,47 +0,0 @@
/* -*- 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* IBM Corporation
*
* 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 nsCompatibility_h___
#define nsCompatibility_h___
enum nsCompatibility {
eCompatibility_FullStandards = 1,
eCompatibility_AlmostStandards = 2,
eCompatibility_NavQuirks = 3
};
#endif /* nsCompatibility_h___ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,287 +0,0 @@
/* -*- Mode: C++; tab-width: 8; 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) 2000
* 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 "nsCOMPtr.h"
#include "nsIContentIterator.h"
#include "nsPresContext.h"
#include "nsIFrame.h"
#include "nsIContent.h"
#include "nsIEnumerator.h"
#include "nsFrameList.h"
class nsFrameContentIterator : public nsIContentIterator
{
public:
nsFrameContentIterator(nsPresContext* aPresContext, nsIFrame* aFrame);
virtual ~nsFrameContentIterator();
// nsISupports
NS_DECL_ISUPPORTS
// nsIContentIterator
virtual nsresult Init(nsIContent* aRoot);
virtual nsresult Init(nsIDOMRange* aRange);
virtual void First();
virtual void Last();
virtual void Next();
virtual void Prev();
virtual nsIContent *GetCurrentNode();
virtual PRBool IsDone();
virtual nsresult PositionAt(nsIContent* aCurNode);
private:
nsCOMPtr<nsPresContext> mPresContext;
nsIFrame* mParentFrame;
nsIFrame* mCurrentChild;
PRBool mIsDone;
};
nsFrameContentIterator::nsFrameContentIterator(nsPresContext* aPresContext,
nsIFrame* aFrame)
: mPresContext(aPresContext), mParentFrame(aFrame), mIsDone(PR_FALSE)
{
First();
}
NS_IMPL_ISUPPORTS1(nsFrameContentIterator, nsIContentIterator)
nsFrameContentIterator::~nsFrameContentIterator()
{
}
nsresult
nsFrameContentIterator::Init(nsIContent* aRoot)
{
return NS_ERROR_ALREADY_INITIALIZED;
}
nsresult
nsFrameContentIterator::Init(nsIDOMRange* aRange)
{
return NS_ERROR_ALREADY_INITIALIZED;
}
void
nsFrameContentIterator::First()
{
// Get the first child frame and make it the current node
mCurrentChild = mParentFrame->GetFirstChild(nsnull);
mIsDone = !mCurrentChild;
}
static nsIFrame*
GetNextChildFrame(nsPresContext* aPresContext, nsIFrame* aFrame)
{
NS_PRECONDITION(aFrame, "null pointer");
// Get the last-in-flow
aFrame = aFrame->GetLastInFlow();
// Get its next sibling
nsIFrame* nextSibling = aFrame->GetNextSibling();
// If there's no next sibling, then check if the parent frame
// has a next-in-flow and look there
if (!nextSibling) {
nsIFrame* parent = aFrame->GetParent()->GetNextInFlow();
if (parent) {
nextSibling = parent->GetFirstChild(nsnull);
}
}
return nextSibling;
}
void
nsFrameContentIterator::Last()
{
// Starting with the first child walk and find the last child
mCurrentChild = nsnull;
nsIFrame* nextChild = mParentFrame->GetFirstChild(nsnull);
while (nextChild) {
mCurrentChild = nextChild;
nextChild = ::GetNextChildFrame(mPresContext, nextChild);
}
mIsDone = !mCurrentChild;
}
void
nsFrameContentIterator::Next()
{
nsIFrame* nextChild = ::GetNextChildFrame(mPresContext, mCurrentChild);
if (nextChild) {
// Advance to the next child
mCurrentChild = nextChild;
// If we're at the end then the collection is at the end
mIsDone = (nsnull == ::GetNextChildFrame(mPresContext, mCurrentChild));
return;
}
// No next frame, we're done.
mIsDone = PR_TRUE;
}
static nsIFrame*
GetPrevChildFrame(nsPresContext* aPresContext, nsIFrame* aFrame)
{
NS_PRECONDITION(aFrame, "null pointer");
// Get its previous sibling. Because we have a singly linked list we
// need to search from the first child
nsIFrame* parent = aFrame->GetParent();
nsIFrame* prevSibling;
nsIFrame* firstChild = parent->GetFirstChild(nsnull);
NS_ASSERTION(firstChild, "parent has no first child");
nsFrameList frameList(firstChild);
prevSibling = frameList.GetPrevSiblingFor(aFrame);
// If there's no previous sibling, then check if the parent frame
// has a prev-in-flow and look there
if (!prevSibling) {
parent = parent->GetPrevInFlow();
if (parent) {
firstChild = parent->GetFirstChild(nsnull);
frameList.SetFrames(firstChild);
prevSibling = frameList.LastChild();
}
}
// Get the first-in-flow
while (PR_TRUE) {
nsIFrame* prevInFlow = prevSibling->GetPrevInFlow();
if (prevInFlow) {
prevSibling = prevInFlow;
} else {
break;
}
}
return prevSibling;
}
void
nsFrameContentIterator::Prev()
{
nsIFrame* prevChild = ::GetPrevChildFrame(mPresContext, mCurrentChild);
if (prevChild) {
// Make the previous child the current child
mCurrentChild = prevChild;
// If we're at the beginning then the collection is at the end
mIsDone = (nsnull == ::GetPrevChildFrame(mPresContext, mCurrentChild));
return;
}
// No previous frame, we're done.
mIsDone = PR_TRUE;
}
nsIContent *
nsFrameContentIterator::GetCurrentNode()
{
if (mCurrentChild && !mIsDone) {
return mCurrentChild->GetContent();
}
return nsnull;
}
PRBool
nsFrameContentIterator::IsDone()
{
return mIsDone;
}
nsresult
nsFrameContentIterator::PositionAt(nsIContent* aCurNode)
{
// Starting with the first child frame search for the child frame
// with the matching content object
nsIFrame* child = mParentFrame->GetFirstChild(nsnull);
while (child) {
if (child->GetContent() == aCurNode) {
break;
}
child = ::GetNextChildFrame(mPresContext, child);
}
if (child) {
// Make it the current child
mCurrentChild = child;
mIsDone = PR_FALSE;
}
return NS_OK;
}
nsresult
NS_NewFrameContentIterator(nsPresContext* aPresContext,
nsIFrame* aFrame,
nsIContentIterator** aIterator)
{
NS_ENSURE_ARG_POINTER(aIterator);
if (!aIterator) {
return NS_ERROR_NULL_POINTER;
}
NS_ENSURE_ARG_POINTER(aFrame);
if (!aFrame) {
return NS_ERROR_NULL_POINTER;
}
// Make sure the frame corresponds to generated content
NS_ASSERTION(aFrame->GetStateBits() & NS_FRAME_GENERATED_CONTENT, "unexpected frame");
nsFrameContentIterator* it = new nsFrameContentIterator(aPresContext, aFrame);
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(NS_GET_IID(nsIContentIterator), (void **)aIterator);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,258 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:cindent:ts=2:et:sw=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) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.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 *****
*
* 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.
*/
#ifndef _nsFrameManager_h_
#define _nsFrameManager_h_
#include "nsIFrame.h"
#include "nsIStatefulFrame.h"
#include "nsChangeHint.h"
#include "nsFrameManagerBase.h"
/**
* Frame manager interface. The frame manager serves two purposes:
* <li>provides a service for mapping from content to frame and from
* out-of-flow frame to placeholder frame.
* <li>handles structural modifications to the frame model. If the frame model
* lock can be acquired, then the changes are processed immediately; otherwise,
* they're queued and processed later.
*
* Do not add virtual methods to this class, or bryner will punish you.
*/
class nsFrameManager : public nsFrameManagerBase
{
public:
nsFrameManager() NS_HIDDEN;
~nsFrameManager() NS_HIDDEN;
void* operator new(size_t aSize, nsIPresShell* aHost) {
NS_ASSERTION(aSize == sizeof(nsFrameManager), "Unexpected subclass");
NS_ASSERTION(aSize == sizeof(nsFrameManagerBase),
"Superclass/subclass mismatch");
return aHost->FrameManager();
}
// Initialization
NS_HIDDEN_(nsresult) Init(nsIPresShell* aPresShell, nsStyleSet* aStyleSet);
/*
* After Destroy is called, it is an error to call any FrameManager methods.
* Destroy should be called when the frame tree managed by the frame
* manager is no longer being displayed.
*/
NS_HIDDEN_(void) Destroy();
/*
* Gets and sets the root frame (typically the viewport). The lifetime of the
* root frame is controlled by the frame manager. When the frame manager is
* destroyed, it destroys the entire frame hierarchy.
*/
NS_HIDDEN_(nsIFrame*) GetRootFrame() { return mRootFrame; }
NS_HIDDEN_(void) SetRootFrame(nsIFrame* aRootFrame)
{
NS_ASSERTION(!mRootFrame, "already have a root frame");
mRootFrame = aRootFrame;
}
/*
* Get the canvas frame, searching from the root frame down.
* The canvas frame may or may not exist, so this may return null.
*/
NS_HIDDEN_(nsIFrame*) GetCanvasFrame();
// Primary frame functions
NS_HIDDEN_(nsIFrame*) GetPrimaryFrameFor(nsIContent* aContent);
NS_HIDDEN_(nsresult) SetPrimaryFrameFor(nsIContent* aContent,
nsIFrame* aPrimaryFrame);
NS_HIDDEN_(void) ClearPrimaryFrameMap();
// Placeholder frame functions
NS_HIDDEN_(nsPlaceholderFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame);
NS_HIDDEN_(nsresult)
RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
NS_HIDDEN_(void)
UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
NS_HIDDEN_(void) ClearPlaceholderFrameMap();
// Mapping undisplayed content
NS_HIDDEN_(nsStyleContext*) GetUndisplayedContent(nsIContent* aContent);
NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent,
nsStyleContext* aStyleContext);
NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent,
nsStyleContext* aStyleContext);
NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent,
nsIContent* aParentContent);
NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent);
NS_HIDDEN_(void) ClearUndisplayedContentMap();
// Functions for manipulating the frame model
NS_HIDDEN_(nsresult) AppendFrames(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
return aParentFrame->AppendFrames(GetPresContext(), *GetPresShell(),
aListName, aFrameList);
}
NS_HIDDEN_(nsresult) InsertFrames(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_HIDDEN_(nsresult) RemoveFrame(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_HIDDEN_(nsresult) ReplaceFrame(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aOldFrame,
nsIFrame* aNewFrame)
{
return aParentFrame->ReplaceFrame(GetPresContext(), *GetPresShell(),
aListName, aOldFrame, aNewFrame);
}
// Notification that we were unable to render a replaced element
NS_HIDDEN_(nsresult) CantRenderReplacedElement(nsIFrame* aFrame);
/*
* Notification that a frame is about to be destroyed. This allows any
* outstanding references to the frame to be cleaned up.
*/
NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame);
/*
* Reparent the style contexts of this frame subtree to live under the new
* given parent style context. The StyleContextParent of aFrame should be
* changed _before_ this method is called, so that style tree verification
* can take place correctly.
*/
NS_HIDDEN_(nsresult) ReParentStyleContext(nsIFrame* aFrame,
nsStyleContext* aNewParentContext);
/*
* Re-resolve the style contexts for a frame tree. Returns the top-level
* change hint resulting from the style re-resolution.
*/
NS_HIDDEN_(nsChangeHint)
ComputeStyleChangeFor(nsIFrame* aFrame,
nsStyleChangeList* aChangeList,
nsChangeHint aMinChange);
// Determine whether an attribute affects style
NS_HIDDEN_(nsReStyleHint) HasAttributeDependentStyle(nsIContent *aContent,
nsIAtom *aAttribute,
PRInt32 aModType);
/*
* Capture/restore frame state for the frame subtree rooted at aFrame.
* aState is the document state storage object onto which each frame
* stores its state.
*/
NS_HIDDEN_(void) CaptureFrameState(nsIFrame* aFrame,
nsILayoutHistoryState* aState);
NS_HIDDEN_(void) RestoreFrameState(nsIFrame* aFrame,
nsILayoutHistoryState* aState);
/*
* Add/restore state for one frame
* (special, global type, like scroll position)
*/
NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame* aFrame,
nsILayoutHistoryState* aState,
nsIStatefulFrame::SpecialStateID aID =
nsIStatefulFrame::eNoID);
NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame* aFrame,
nsILayoutHistoryState* aState,
nsIStatefulFrame::SpecialStateID aID =
nsIStatefulFrame::eNoID);
#ifdef NS_DEBUG
/**
* DEBUG ONLY method to verify integrity of style tree versus frame tree
*/
NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame);
#endif
private:
friend struct CantRenderReplacedElementEvent;
NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
NS_HIDDEN_(nsPresContext*) GetPresContext() const {
return mPresShell->GetPresContext();
}
NS_HIDDEN_(nsChangeHint)
ReResolveStyleContext(nsPresContext *aPresContext,
nsIFrame *aFrame,
nsIContent *aParentContent,
nsStyleChangeList *aChangeList,
nsChangeHint aMinChange);
NS_HIDDEN_(nsresult) RevokePostedEvents();
NS_HIDDEN_(CantRenderReplacedElementEvent**)
FindPostedEventFor(nsIFrame* aFrame);
NS_HIDDEN_(void) DequeuePostedEventFor(nsIFrame* aFrame);
static NS_HIDDEN_(void)
HandlePLEvent(CantRenderReplacedElementEvent* aEvent);
static NS_HIDDEN_(void)
DestroyPLEvent(CantRenderReplacedElementEvent* aEvent);
};
#endif

View File

@@ -1,85 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:cindent:ts=2:et:sw=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) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Brian Ryner <bryner@brianryner.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 *****
*
* 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.
*/
#ifndef _nsFrameManagerBase_h_
#define _nsFrameManagerBase_h_
#include "pldhash.h"
class nsIPresShell;
class nsStyleSet;
class nsIContent;
class nsPlaceholderFrame;
class nsIFrame;
class nsStyleContext;
class nsIAtom;
class nsStyleChangeList;
class nsILayoutHistoryState;
struct CantRenderReplacedElementEvent;
class nsFrameManagerBase
{
protected:
class UndisplayedMap;
// weak link, because the pres shell owns us
nsIPresShell* mPresShell;
// the pres shell owns the style set
nsStyleSet* mStyleSet;
nsIFrame* mRootFrame;
PLDHashTable mPrimaryFrameMap;
PLDHashTable mPlaceholderMap;
UndisplayedMap* mUndisplayedMap;
CantRenderReplacedElementEvent* mPostedEvents;
PRBool mIsDestroyingFrames;
};
#endif

View File

@@ -1,789 +0,0 @@
/* -*- 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
* 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 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 "nsCOMPtr.h"
#include "nsLayoutAtoms.h"
#include "nsFrameTraversal.h"
#include "nsFrameList.h"
#include "nsPlaceholderFrame.h"
class nsFrameIterator: public nsIBidirectionalEnumerator
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD First();
NS_IMETHOD Last();
NS_IMETHOD Next()=0;
NS_IMETHOD Prev()=0;
NS_IMETHOD CurrentItem(nsISupports **aItem);
NS_IMETHOD IsDone();//what does this mean??off edge? yes
nsFrameIterator();
protected:
void setCurrent(nsIFrame *aFrame){mCurrent = aFrame;}
nsIFrame *getCurrent(){return mCurrent;}
void setStart(nsIFrame *aFrame){mStart = aFrame;}
nsIFrame *getStart(){return mStart;}
nsIFrame *getLast(){return mLast;}
void setLast(nsIFrame *aFrame){mLast = aFrame;}
PRInt8 getOffEdge(){return mOffEdge;}
void setOffEdge(PRInt8 aOffEdge){mOffEdge = aOffEdge;}
private:
nsIFrame *mStart;
nsIFrame *mCurrent;
nsIFrame *mLast; //the last one that was in current;
PRInt8 mOffEdge; //0= no -1 to far prev, 1 to far next;
};
/*
class nsFastFrameIterator: public nsFrameIterator
{
nsFastFrameIterator(nsIFrame *start);
private :
virtual nsresult Next();
virtual nsresult Prev();
}
*/
class nsLeafIterator: public nsFrameIterator
{
public:
nsLeafIterator(nsPresContext* aPresContext, nsIFrame *start);
void SetExtensive(PRBool aExtensive) {mExtensive = aExtensive;}
PRBool GetExtensive(){return mExtensive;}
void SetLockInScrollView(PRBool aLockScroll){mLockScroll = aLockScroll;}
private :
NS_IMETHOD Next();
NS_IMETHOD Prev();
nsPresContext* mPresContext;
PRPackedBool mExtensive;
PRBool mLockScroll;
};
class nsFocusIterator : public nsFrameIterator
{
public:
nsFocusIterator(nsPresContext* aPresContext, nsIFrame* aStart);
private:
NS_IMETHOD Next();
NS_IMETHOD Prev();
NS_IMETHOD Last();
/*
Our own versions of the standard frame tree navigation
methods, which apply the following rules for placeholder
frames:
- If a frame HAS a placeholder frame, getting its parent
gets the placeholder's parent.
- If a frame's first child or next/prev sibling IS a
placeholder frame, then we instead return the real frame.
- If a frame HAS a placeholder frame, getting its next/prev
sibling gets the placeholder frame's next/prev sibling.
These are all applied recursively to support multiple levels of
placeholders.
*/
nsIFrame* GetParentFrame(nsIFrame* aFrame);
nsIFrame* GetFirstChild(nsIFrame* aFrame);
nsIFrame* GetNextSibling(nsIFrame* aFrame);
nsIFrame* GetPrevSibling(nsIFrame* aFrame);
nsIFrame* GetRealFrame(nsIFrame* aFrame);
nsIFrame* GetPlaceholderFrame(nsIFrame* aFrame);
PRBool IsPopupFrame(nsIFrame* aFrame);
nsPresContext* mPresContext;
};
#ifdef IBMBIDI // Simon
class nsVisualIterator: public nsFrameIterator
{
public:
nsVisualIterator(nsPresContext* aPresContext, nsIFrame *start);
private :
NS_IMETHOD Next();
NS_IMETHOD Prev();
nsPresContext* mPresContext;
};
#endif
/************IMPLEMENTATIONS**************/
nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nsnull;
nsCOMPtr<nsIFrameTraversal> t(new nsFrameTraversal());
if (!t)
return NS_ERROR_OUT_OF_MEMORY;
*aResult = t;
NS_ADDREF(*aResult);
return NS_OK;
}
nsresult
NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
nsTraversalType aType,
nsPresContext* aPresContext,
nsIFrame *aStart,
PRBool aLockInScrollView)
{
if (!aEnumerator || !aStart)
return NS_ERROR_NULL_POINTER;
switch(aType)
{
case LEAF: {
nsLeafIterator *trav = new nsLeafIterator(aPresContext, aStart);
if (!trav)
return NS_ERROR_OUT_OF_MEMORY;
trav->SetLockInScrollView(aLockInScrollView);
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
NS_ADDREF(trav);
trav->SetExtensive(PR_FALSE);
}
break;
case EXTENSIVE:{
nsLeafIterator *trav = new nsLeafIterator(aPresContext, aStart);
if (!trav)
return NS_ERROR_OUT_OF_MEMORY;
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
NS_ADDREF(trav);
trav->SetExtensive(PR_TRUE);
}
break;
case FOCUS: {
nsFocusIterator *trav = new nsFocusIterator(aPresContext, aStart);
if (!trav)
return NS_ERROR_OUT_OF_MEMORY;
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
NS_ADDREF(trav);
}
break;
#ifdef IBMBIDI
case VISUAL:{
nsVisualIterator *trav = new nsVisualIterator(aPresContext, aStart);
if (!trav)
return NS_ERROR_OUT_OF_MEMORY;
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
NS_ADDREF(trav);
}
break;
#endif
#if 0
case FASTEST:{
nsFastestTraversal *trav = new nsFastestTraversal(aStart);
if (!trav)
return NS_ERROR_NOMEMORY;
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
NS_ADDREF(trav);
}
#endif
default:
return NS_ERROR_NOT_IMPLEMENTED;
break;
}
return NS_OK;
}
nsFrameTraversal::nsFrameTraversal()
{
}
nsFrameTraversal::~nsFrameTraversal()
{
}
NS_IMPL_ISUPPORTS1(nsFrameTraversal,nsIFrameTraversal)
NS_IMETHODIMP
nsFrameTraversal::NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
PRUint32 aType,
nsPresContext* aPresContext,
nsIFrame *aStart)
{
return NS_NewFrameTraversal(aEnumerator, NS_STATIC_CAST(nsTraversalType,
aType),
aPresContext, aStart,PR_FALSE);
}
/*********nsFrameIterator************/
NS_IMPL_ISUPPORTS2(nsFrameIterator, nsIEnumerator, nsIBidirectionalEnumerator)
nsFrameIterator::nsFrameIterator()
{
mOffEdge = 0;
mLast = nsnull;
mCurrent = nsnull;
mStart = nsnull;
}
NS_IMETHODIMP
nsFrameIterator::CurrentItem(nsISupports **aItem)
{
if (!aItem)
return NS_ERROR_NULL_POINTER;
*aItem = mCurrent;
if (mOffEdge)
return NS_ENUMERATOR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsFrameIterator::IsDone()//what does this mean??off edge? yes
{
if (mOffEdge != 0)
return NS_OK;
return NS_ENUMERATOR_FALSE;
}
NS_IMETHODIMP
nsFrameIterator::First()
{
mCurrent = mStart;
return NS_OK;
}
NS_IMETHODIMP
nsFrameIterator::Last()
{
return NS_ERROR_FAILURE;
}
/*********LEAFITERATOR**********/
nsLeafIterator::nsLeafIterator(nsPresContext* aPresContext, nsIFrame *aStart)
: mPresContext(aPresContext)
{
setStart(aStart);
setCurrent(aStart);
setLast(aStart);
SetLockInScrollView(PR_FALSE);
}
static PRBool
IsRootFrame(nsIFrame* aFrame)
{
nsIAtom* atom = aFrame->GetType();
return (atom == nsLayoutAtoms::canvasFrame) ||
(atom == nsLayoutAtoms::rootFrame);
}
NS_IMETHODIMP
nsLeafIterator::Next()
{
//recursive-oid method to get next frame
nsIFrame *result = nsnull;
nsIFrame *parent = getCurrent();
if (!parent)
parent = getLast();
if (!mExtensive)
{
while (nsnull != (result = parent->GetFirstChild(nsnull)))
{
parent = result;
}
}
if (parent != getCurrent())
{
result = parent;
}
else {
while(parent && !IsRootFrame(parent)) {
result = parent->GetNextSibling();
if (result) {
parent = result;
while (nsnull != (result = parent->GetFirstChild(nsnull)))
{
parent = result;
}
result = parent;
break;
}
else
{
result = parent->GetParent();
if (!result || IsRootFrame(result)) {
result = nsnull;
break;
}
else
{
parent = result;
// check if FrameType of result is TextInputFrame
if (mLockScroll) //lock the traversal when we hit a scroll frame
{
if ( result->GetType() == nsLayoutAtoms::scrollFrame )
return NS_ERROR_FAILURE;
}
if (mExtensive)
break;
}
}
}
}
setCurrent(result);
if (!result)
setOffEdge(1);
return NS_OK;
}
NS_IMETHODIMP
nsLeafIterator::Prev()
{
//recursive-oid method to get prev frame
nsIFrame *result = nsnull;
nsIFrame *parent = getCurrent();
if (!parent)
parent = getLast();
while (parent){
nsIFrame *grandParent = parent->GetParent();
if (grandParent)
{
// check if FrameType of grandParent is TextInputFrame
if (mLockScroll) //lock the traversal when we hit a scroll frame
{
nsIAtom* atom = grandParent->GetType();
#ifdef DEBUG_skamio
if ( atom )
{
nsAutoString aString;
res = atom->ToString(aString);
if ( NS_SUCCEEDED(res) ) {
printf("%s:%d\n", __FILE__, __LINE__);
printf("FrameType: %s\n", NS_ConvertUCS2toUTF8(aString).get());
}
}
#endif
if ( atom == nsLayoutAtoms::scrollFrame )
return NS_ERROR_FAILURE;
}
result = grandParent->GetFirstChild(nsnull);
nsFrameList list(result);
result = list.GetPrevSiblingFor(parent);
if (result)
{
parent = result;
while (nsnull != (result = parent->GetFirstChild(nsnull)))
{
parent = result;
while ((result = parent->GetNextSibling()) != nsnull)
{
parent = result;
}
}
result = parent;
break;
}
else if (!(result = parent->GetParent()))
{
result = nsnull;
break;
}
else
{
parent = result;
if (mExtensive)
break;
}
}
else
{
setLast(parent);
result = nsnull;
break;
}
}
setCurrent(result);
if (!result)
setOffEdge(-1);
return NS_OK;
}
nsFocusIterator::nsFocusIterator(nsPresContext* aPresContext, nsIFrame* aStart)
: mPresContext(aPresContext)
{
nsIFrame* start = aStart;
if (aStart)
start = GetRealFrame(aStart);
setStart(start);
setCurrent(start);
setLast(start);
}
nsIFrame*
nsFocusIterator::GetPlaceholderFrame(nsIFrame* aFrame)
{
nsIFrame* result = aFrame;
nsIPresShell *presShell = mPresContext->GetPresShell();
if (presShell) {
nsIFrame* placeholder = 0;
presShell->GetPlaceholderFrameFor(aFrame, &placeholder);
if (placeholder)
result = placeholder;
}
if (result != aFrame)
result = GetPlaceholderFrame(result);
return result;
}
nsIFrame*
nsFocusIterator::GetRealFrame(nsIFrame* aFrame)
{
nsIFrame* result = aFrame;
// See if it's a placeholder frame for a float.
if (aFrame) {
PRBool isPlaceholder = nsLayoutAtoms::placeholderFrame == aFrame->GetType();
if (isPlaceholder) {
// Get the out-of-flow frame that the placeholder points to.
// This is the real float that we should examine.
result = NS_STATIC_CAST(nsPlaceholderFrame*,aFrame)->GetOutOfFlowFrame();
NS_ASSERTION(result, "No out of flow frame found for placeholder!\n");
}
if (result != aFrame)
result = GetRealFrame(result);
}
return result;
}
PRBool
nsFocusIterator::IsPopupFrame(nsIFrame* aFrame)
{
return (aFrame->GetStyleDisplay()->mDisplay == NS_STYLE_DISPLAY_POPUP);
}
nsIFrame*
nsFocusIterator::GetParentFrame(nsIFrame* aFrame)
{
nsIFrame* placeholder = GetPlaceholderFrame(aFrame);
if (placeholder)
return placeholder->GetParent();
return nsnull;
}
nsIFrame*
nsFocusIterator::GetFirstChild(nsIFrame* aFrame)
{
nsIFrame* result = aFrame->GetFirstChild(nsnull);
if (result)
result = GetRealFrame(result);
if (result && IsPopupFrame(result))
result = GetNextSibling(result);
return result;
}
nsIFrame*
nsFocusIterator::GetNextSibling(nsIFrame* aFrame)
{
nsIFrame* result = nsnull;
nsIFrame* placeholder = GetPlaceholderFrame(aFrame);
if (placeholder) {
result = placeholder->GetNextSibling();
if (result)
result = GetRealFrame(result);
}
if (result && IsPopupFrame(result))
result = GetNextSibling(result);
return result;
}
nsIFrame*
nsFocusIterator::GetPrevSibling(nsIFrame* aFrame)
{
nsIFrame* result = 0;
nsIFrame* placeholder = GetPlaceholderFrame(aFrame);
if (placeholder) {
nsIFrame* parent = GetParentFrame(placeholder);
if (parent) {
nsFrameList list(parent->GetFirstChild(nsnull));
result = list.GetPrevSiblingFor(placeholder);
result = GetRealFrame(result);
}
}
if (result && IsPopupFrame(result))
result = GetPrevSibling(result);
return result;
}
NS_IMETHODIMP
nsFocusIterator::Next()
{
nsIFrame* result = 0;
nsIFrame* parent = getCurrent();
if (!parent)
parent = getLast();
if ((result = GetFirstChild(parent)))
parent = result;
result = parent;
if (result == getCurrent()) {
while (result && !IsRootFrame(result)) {
if ((parent = GetNextSibling(result))) {
result = parent;
break;
} else {
parent = result;
result = GetParentFrame(parent);
}
}
if (!result || IsRootFrame(result)) {
result = 0;
setLast(parent);
}
}
setCurrent(result);
if (!result)
setOffEdge(1);
return NS_OK;
}
NS_IMETHODIMP
nsFocusIterator::Prev()
{
nsIFrame *result = nsnull;
nsIFrame *parent = getCurrent();
if (!parent)
parent = getLast();
if (parent) {
if ((result = GetPrevSibling(parent))) {
parent = result;
while ((result = GetFirstChild(parent))) {
parent = result;
while ((result = GetNextSibling(parent)))
parent = result;
}
result = parent;
} else if (!(result = GetParentFrame(parent))) {
result = 0;
setLast(parent);
}
}
setCurrent(result);
if (!result)
setOffEdge(-1);
return NS_OK;
}
NS_IMETHODIMP
nsFocusIterator::Last()
{
nsIFrame* result;
nsIFrame* parent = getCurrent();
while (!IsRootFrame(parent) && (result = GetParentFrame(parent)))
parent = result;
while ((result = GetFirstChild(parent))) {
parent = result;
while ((result = GetNextSibling(parent)))
parent = result;
}
setCurrent(parent);
if (!parent)
setOffEdge(1);
return NS_OK;
}
#ifdef IBMBIDI
/*********VISUALITERATOR**********/
nsVisualIterator::nsVisualIterator(nsPresContext* aPresContext, nsIFrame *aStart)
: mPresContext(aPresContext)
{
setStart(aStart);
setCurrent(aStart);
setLast(aStart);
}
NS_IMETHODIMP
nsVisualIterator::Next()
{
//recursive-oid method to get next frame
nsIFrame *result = nsnull;
nsIFrame *parent = getCurrent();
if (!parent)
parent = getLast();
while (nsnull != (result = parent->GetFirstChild(nsnull)))
{
parent = result;
}
if (parent != getCurrent())
{
result = parent;
}
else {
while(parent && !IsRootFrame(parent)) {
nsIFrame *grandParent = parent->GetParent();
if (grandParent) {
nsFrameList list(grandParent->GetFirstChild(nsnull));
result = list.GetNextVisualFor(parent);
if (result){
parent = result;
while (nsnull != (result = parent->GetFirstChild(nsnull))) {
parent = result;
}
result = parent;
break;
}
else if (!(result = parent->GetParent()) || IsRootFrame(result)) {
result = nsnull;
break;
}
else
{
parent = result;
}
}
else{
setLast(parent);
result = nsnull;
break;
}
}
}
setCurrent(result);
if (!result)
setOffEdge(-1);
return NS_OK;
}
NS_IMETHODIMP
nsVisualIterator::Prev()
{
//recursive-oid method to get prev frame
nsIFrame *result = nsnull;
nsIFrame *parent = getCurrent();
if (!parent)
parent = getLast();
while(parent){
nsIFrame *grandParent = parent->GetParent();
if (grandParent) {
nsFrameList list(grandParent->GetFirstChild(nsnull));
result = list.GetPrevVisualFor(parent);
if (result){
parent = result;
while (nsnull != (result = parent->GetFirstChild(nsnull))) {
parent = result;
while ((result = parent->GetNextSibling()) != nsnull) {
parent = result;
}
}
result = parent;
break;
}
else if (!(result = parent->GetParent())) {
break;
}
else
{
parent = result;
}
}
else{
setLast(parent);
result = nsnull;
break;
}
}
setCurrent(result);
if (!result)
setOffEdge(-1);
return NS_OK;
}
#endif

View File

@@ -1,66 +0,0 @@
/* -*- 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
* 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 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 NSFRAMETRAVERSAL_H
#define NSFRAMETRAVERSAL_H
#include "nsIEnumerator.h"
#include "nsIFrame.h"
#include "nsIFrameTraversal.h"
nsresult NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
nsTraversalType aType,
nsPresContext* aPresContext,
nsIFrame *aStart,
PRBool aLockInScrollView);
nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
class nsFrameTraversal : public nsIFrameTraversal
{
public:
nsFrameTraversal();
virtual ~nsFrameTraversal();
NS_DECL_ISUPPORTS
NS_IMETHOD NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
PRUint32 aType,
nsPresContext* aPresContext,
nsIFrame *aStart);
};
#endif //NSFRAMETRAVERSAL_H

View File

@@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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 Communicator client 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):
*
* 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 "nsISupports.h"
#ifndef nsIAutoCopyService_h__
#define nsIAutoCopyService_h__
// {558B93CD-95C1-417d-A66E-F9CA66DC98A8}
#define NS_IAUTOCOPYSERVICE_IID \
{ 0x558b93cd, 0x95c1, 0x417d, { 0xa6, 0x6e, 0xf9, 0xca, 0x66, 0xdc, 0x98, 0xa8 } }
class nsISelection;
class nsIAutoCopyService : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IAUTOCOPYSERVICE_IID)
//This will add this service as a selection listener.
NS_IMETHOD Listen(nsISelection *aDomSelection)=0;
};
#endif //nsIAutoCopyService_h__

View File

@@ -1,160 +0,0 @@
/* -*- 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
* 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 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 nsICaret_h__
#define nsICaret_h__
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsCoord.h"
struct nsRect;
struct nsPoint;
class nsIRenderingContext;
class nsIFrame;
class nsIView;
class nsIPresShell;
class nsISelection;
class nsIDOMNode;
// IID for the nsICaret interface
#define NS_ICARET_IID \
{ 0x43d789e0, 0x21b7, 0x4fb4, { 0xb6, 0xfc, 0x4a, 0x41, 0x49, 0x3e, 0x40, 0xf0 } }
class nsICaret: public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICARET_IID)
enum EViewCoordinates {
eTopLevelWindowCoordinates,
eRenderingViewCoordinates,
eClosestViewCoordinates,
eIMECoordinates
};
NS_IMETHOD Init(nsIPresShell *inPresShell) = 0;
NS_IMETHOD Terminate() = 0;
NS_IMETHOD GetCaretDOMSelection(nsISelection **aDOMSel) = 0;
NS_IMETHOD SetCaretDOMSelection(nsISelection *aDOMSel) = 0;
/** SetCaretVisible will set the visibility of the caret
* @param inMakeVisible PR_TRUE to show the caret, PR_FALSE to hide it
*/
NS_IMETHOD SetCaretVisible(PRBool inMakeVisible) = 0;
/** GetCaretVisible will get the visibility of the caret
* @param inMakeVisible PR_TRUE it is shown, PR_FALSE it is hidden
*/
NS_IMETHOD GetCaretVisible(PRBool *outMakeVisible) = 0;
/** SetCaretReadOnly set the appearance of the caret
* @param inMakeReadonly PR_TRUE to show the caret in a 'read only' state,
* PR_FALSE to show the caret in normal, editing state
*/
NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly) = 0;
/** GetCaretCoordinates
* Get the position of the caret in coordinates relative to the typed specified (aRelativeToType).
* If the selection is collapsed, this returns the caret location
* and true in outIsCollapsed.
* If the selection is not collapsed, this returns the location of the focus pos,
* and false in outIsCollapsed.
*/
NS_IMETHOD GetCaretCoordinates(EViewCoordinates aRelativeToType, nsISelection *aDOMSel, nsRect *outCoordinates, PRBool *outIsCollapsed, nsIView **outView) = 0;
/** ClearFrameRefs
* The caret stores a reference to the frame that the caret was last drawn in.
* This is called to tell the caret that that frame is going away.
*/
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
/** Erase Caret
* this will erase the caret if its drawn and reset drawn status
*/
NS_IMETHOD EraseCaret() = 0;
NS_IMETHOD SetVisibilityDuringSelection(PRBool aVisibilityDuringSelection) = 0;
/** DrawAtPosition
*
* Draw the caret explicitly, at the specified node and offset.
* To avoid drawing glitches, you should call EraseCaret()
* after each call to DrawAtPosition().
*
**/
NS_IMETHOD DrawAtPosition(nsIDOMNode* aNode, PRInt32 aOffset) = 0;
};
nsresult
NS_NewCaret(nsICaret** aInstancePtrResult);
// handy stack-based class for temporarily disabling the caret
class StCaretHider
{
public:
StCaretHider(nsICaret* aSelCon)
: mWasVisible(PR_FALSE), mCaret(aSelCon)
{
if (mCaret)
{
mCaret->GetCaretVisible(&mWasVisible);
if (mWasVisible)
mCaret->SetCaretVisible(PR_FALSE);
}
}
~StCaretHider()
{
if (mCaret && mWasVisible)
mCaret->SetCaretVisible(PR_TRUE);
// nsCOMPtr releases mPresShell
}
protected:
PRBool mWasVisible;
nsCOMPtr<nsICaret> mCaret;
};
#endif // nsICaret_h__

View File

@@ -1,67 +0,0 @@
/* -*- Mode: IDL; 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 the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Travis Bogard <travis@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 ***** */
#include "nsISupports.idl"
%{ C++
#include "nsEvent.h" // for nsEventStatus enum
class nsPresContext;
%}
[ptr] native nsPresContext(nsPresContext);
native nsEvent(nsEvent);
[ptr] native nsEventPtr(nsEvent);
native nsEventStatus(nsEventStatus);
interface nsIDOMEvent;
/**
* The nsIChromeEventHandler
*/
[scriptable, uuid(7BC08970-9E6C-11d3-AFB2-00A024FFC08C)]
interface nsIChromeEventHandler : nsISupports
{
/**
* Handle a chrome DOM event.
*/
[noscript] void handleChromeEvent(in nsPresContext aPresContext,
in nsEventPtr aEvent, out nsIDOMEvent aDOMEvent, in unsigned long aFlags,
inout nsEventStatus aStatus);
};

View File

@@ -1,71 +0,0 @@
/* -*- 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 Communicator client 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):
*
* 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 nsIDocumentViewer_h___
#define nsIDocumentViewer_h___
#include "nsIContentViewer.h"
class nsIDocument;
class nsPresContext;
class nsIPresShell;
class nsIStyleSheet;
#define NS_IDOCUMENT_VIEWER_IID \
{ 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
/**
* A document viewer is a kind of content viewer that uses NGLayout
* to manage the presentation of the content.
*/
class nsIDocumentViewer : public nsIContentViewer
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_VIEWER_IID)
NS_IMETHOD SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet) = 0;
NS_IMETHOD GetDocument(nsIDocument** aResult) = 0;
NS_IMETHOD GetPresShell(nsIPresShell** aResult) = 0;
NS_IMETHOD GetPresContext(nsPresContext** aResult) = 0;
NS_IMETHOD CreateDocumentViewerUsing(nsPresContext* aPresContext,
nsIDocumentViewer** aResult) = 0;
};
#endif /* nsIDocumentViewer_h___ */

View File

@@ -1,106 +0,0 @@
/* -*- 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 Communicator client 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):
*
* 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 nsIDocumentViewerPrint_h___
#define nsIDocumentViewerPrint_h___
#include "nsISupports.h"
class nsPresContext;
class nsIPrintSettings;
class nsPrintObject;
class nsISelection;
class nsIPresShell;
class nsIDocument;
class nsStyleSet;
class nsIContent;
class nsIWebShell;
// {D0B7F354-D575-43fd-903D-5AA35A193EDA}
#define NS_IDOCUMENT_VIEWER_PRINT_IID \
{ 0xd0b7f354, 0xd575, 0x43fd, { 0x90, 0x3d, 0x5a, 0xa3, 0x5a, 0x19, 0x3e, 0xda } }
/**
* A DocumentViewerPrint is an INTERNAL Interface mainly used for interaction
* between the DocumentViewer and the PrintEngine, although other objects may
* use to find out if printing or print preview is currently underway
*/
class nsIDocumentViewerPrint : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_VIEWER_PRINT_IID)
virtual void SetIsPrinting(PRBool aIsPrinting) = 0;
virtual PRBool GetIsPrinting() = 0;
virtual void SetIsPrintPreview(PRBool aIsPrintPreview) = 0;
virtual PRBool GetIsPrintPreview() = 0;
virtual PRBool GetIsCreatingPrintPreview() = 0;
// The style set returned by CreateStyleSet is in the middle of an
// update batch so that the caller can add sheets to it if needed.
// Callers should call EndUpdate() on it when ready to use.
virtual nsresult CreateStyleSet(nsIDocument* aDocument, nsStyleSet** aStyleSet) = 0;
virtual nsresult GetDocumentSelection(nsISelection **aSelection,
nsIPresShell * aPresShell = nsnull) = 0;
virtual void IncrementDestroyRefCount() = 0;
virtual void ReturnToGalleyPresentation() = 0;
virtual void InstallNewPresentation() = 0;
virtual void OnDonePrinting() = 0;
};
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIDOCUMENTVIEWERPRINT \
virtual void SetIsPrinting(PRBool aIsPrinting); \
virtual PRBool GetIsPrinting(); \
virtual void SetIsPrintPreview(PRBool aIsPrintPreview); \
virtual PRBool GetIsPrintPreview(); \
virtual PRBool GetIsCreatingPrintPreview(); \
virtual nsresult CreateStyleSet(nsIDocument* aDocument, nsStyleSet** aStyleSet); \
virtual nsresult GetDocumentSelection(nsISelection **aSelection, nsIPresShell * aPresShell = nsnull); \
virtual void IncrementDestroyRefCount(); \
virtual void ReturnToGalleyPresentation(); \
virtual void InstallNewPresentation(); \
virtual void OnDonePrinting();
#endif /* nsIDocumentViewerPrint_h___ */

View File

@@ -1,469 +0,0 @@
/* -*- 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
* 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 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 ***** */
/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* NOTE!! This is not a general class, but specific to layout and frames.
* Consumers looking for the general selection interface should look at
* nsISelection.
*/
#ifndef nsIFrameSelection_h___
#define nsIFrameSelection_h___
#include "nsISupports.h"
#include "nsIFrame.h"
#include "nsISelection.h"
#include "nsIContent.h"
#include "nsCOMPtr.h"
#include "nsISelectionController.h"
class nsIPresShell;
// IID for the nsIFrameSelection interface
#define NS_IFRAMESELECTION_IID \
{ 0x18477ed4, 0x01ff, 0x4319, \
{ 0x95, 0xc0, 0x63, 0x9e, 0xe4, 0x33, 0xbe, 0x92 } }
//----------------------------------------------------------------------
// Selection interface
struct SelectionDetails
{
PRInt32 mStart;
PRInt32 mEnd;
SelectionType mType;
SelectionDetails *mNext;
};
/*PeekOffsetStruct
* @param mShell is used to get the PresContext usefull for measuring text ect.
* @param mDesiredX is the "desired" location of the new caret
* @param mAmount eWord, eCharacter, eLine
* @param mDirection enum defined in this file to be eForward or eBackward
* @param mStartOffset start offset to start the peek. 0 == beginning -1 = end
* @param mResultContent content that actually is the next/previous
* @param mResultOffset offset for result content
* @param mResultFrame resulting frame for peeking
* @param mEatingWS boolean to tell us the state of our search for Next/Prev
* @param mPreferLeft true = prev line end, false = next line begin
* @param mJumpLines if this is true then its ok to cross lines while peeking
* @param mScrollViewStop if this is true then stop peeking across scroll view boundary
*/
struct nsPeekOffsetStruct
{
void SetData(nsIPresShell *aShell,
nscoord aDesiredX,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
PRBool aEatingWS,
PRBool aPreferLeft,
PRBool aJumpLines,
PRBool aScrollViewStop,
PRBool aIsKeyboardSelect)
{
mShell=aShell;
mDesiredX=aDesiredX;
mAmount=aAmount;
mDirection=aDirection;
mStartOffset=aStartOffset;
mEatingWS=aEatingWS;
mPreferLeft=aPreferLeft;
mJumpLines = aJumpLines;
mScrollViewStop = aScrollViewStop;
mIsKeyboardSelect = aIsKeyboardSelect;
}
nsIPresShell *mShell;
nscoord mDesiredX;
nsSelectionAmount mAmount;
nsDirection mDirection;
PRInt32 mStartOffset;
nsCOMPtr<nsIContent> mResultContent;
PRInt32 mContentOffset;
PRInt32 mContentOffsetEnd;
nsIFrame *mResultFrame;
PRBool mEatingWS;
PRBool mPreferLeft;
PRBool mJumpLines;
PRBool mScrollViewStop;
PRBool mIsKeyboardSelect;
};
class nsIScrollableView;
class nsIFrameSelection : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMESELECTION_IID)
enum HINT { HINTLEFT = 0, HINTRIGHT = 1}; //end of this line or beginning of next
/** Init will initialize the frame selector with the necessary pres shell to
* be used by most of the methods
* @param aShell is the parameter to be used for most of the other calls for callbacks ect
* @param aLimiter limits the selection to nodes with aLimiter parents
*/
NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter) = 0; //default since this isnt used for embedding
/* SetScrollableView sets the scroll view
* @param aScrollView is the scroll view for this selection.
*/
NS_IMETHOD SetScrollableView(nsIScrollableView *aScrollView) =0;
/* GetScrollableView gets the current scroll view
* @param aScrollView is the scroll view for this selection.
*/
NS_IMETHOD GetScrollableView(nsIScrollableView **aScrollView) =0;
/** ShutDown will be called when the owner of the frame selection is shutting down
* this should be the time to release all member variable interfaces. all methods
* called after ShutDown should return NS_ERROR_FAILURE
*/
NS_IMETHOD ShutDown() = 0;
/** HandleKeyEvent will accept an event.
* <P>DOES NOT ADDREF<P>
* @param aGuiEvent is the event that should be dealt with by aFocusFrame
* @param aFrame is the frame that MAY handle the event
*/
NS_IMETHOD HandleTextEvent(nsGUIEvent *aGuiEvent) = 0;
/** HandleKeyEvent will accept an event and a PresContext.
* <P>DOES NOT ADDREF<P>
* @param aGuiEvent is the event that should be dealt with by aFocusFrame
* @param aFrame is the frame that MAY handle the event
*/
NS_IMETHOD HandleKeyEvent(nsPresContext* aPresContext, nsGUIEvent *aGuiEvent) = 0;
/** HandleClick will take the focus to the new frame at the new offset and
* will either extend the selection from the old anchor, or replace the old anchor.
* the old anchor and focus position may also be used to deselect things
* @param aNewfocus is the content that wants the focus
* @param aContentOffset is the content offset of the parent aNewFocus
* @param aContentOffsetEnd is the content offset of the parent aNewFocus and is specified different
* when you need to select to and include both start and end points
* @param aContinueSelection is the flag that tells the selection to keep the old anchor point or not.
* @param aMultipleSelection will tell the frame selector to replace /or not the old selection.
* cannot coexist with aContinueSelection
* @param aHint will tell the selection which direction geometrically to actually show the caret on.
* 1 = end of this line 0 = beggining of this line
*/
NS_IMETHOD HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset ,
PRBool aContinueSelection, PRBool aMultipleSelection, PRBool aHint) = 0;
/** HandleDrag extends the selection to contain the frame closest to aPoint.
* @param aPresContext is the context to use when figuring out what frame contains the point.
* @param aFrame is the parent of all frames to use when searching for the closest frame to the point.
* @param aPoint is relative to aFrame's parent view.
*/
NS_IMETHOD HandleDrag(nsPresContext *aPresContext, nsIFrame *aFrame, nsPoint& aPoint) = 0;
/** HandleTableSelection will set selection to a table, cell, etc
* depending on information contained in aFlags
* @param aParentContent is the paretent of either a table or cell that user clicked or dragged the mouse in
* @param aContentOffset is the offset of the table or cell
* @param aTarget indicates what to select (defined in nsISelectionPrivate.idl/nsISelectionPrivate.h):
* TABLESELECTION_CELL We should select a cell (content points to the cell)
* TABLESELECTION_ROW We should select a row (content points to any cell in row)
* TABLESELECTION_COLUMN We should select a row (content points to any cell in column)
* TABLESELECTION_TABLE We should select a table (content points to the table)
* TABLESELECTION_ALLCELLS We should select all cells (content points to any cell in table)
* @param aMouseEvent passed in so we we can get where event occured and what keys are pressed
*/
NS_IMETHOD HandleTableSelection(nsIContent *aParentContent, PRInt32 aContentOffset, PRInt32 aTarget, nsMouseEvent *aMouseEvent) = 0;
/** StartAutoScrollTimer is responsible for scrolling views so that aPoint is always
* visible, and for selecting any frame that contains aPoint. The timer will also reset
* itself to fire again if we have not scrolled to the end of the document.
* @param aPresContext is the context to use when figuring out what frame contains the point.
* @param aView is view to use when searching for the closest frame to the point,
* which is the view that is capturing the mouse
* @param aPoint is relative to the view.
* @param aDelay is the timer's interval.
*/
NS_IMETHOD StartAutoScrollTimer(nsPresContext *aPresContext, nsIView* aFrame, nsPoint& aPoint, PRUint32 aDelay) = 0;
/** StopAutoScrollTimer stops any active auto scroll timer.
*/
NS_IMETHOD StopAutoScrollTimer() = 0;
/** EnableFrameNotification
* mutch like start batching, except all dirty calls are ignored. no notifications will go
* out until enableNotifications with a PR_TRUE is called
*/
NS_IMETHOD EnableFrameNotification(PRBool aEnable) = 0;
/** Lookup Selection
* returns in frame coordinates the selection beginning and ending with the type of selection given
* @param aContent is the content asking
* @param aContentOffset is the starting content boundary
* @param aContentLength is the length of the content piece asking
* @param aReturnDetails linkedlist of return values for the selection.
* @param aSlowCheck will check using slow method with no shortcuts
*/
NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,
SelectionDetails **aReturnDetails, PRBool aSlowCheck) = 0;
/** SetMouseDownState(PRBool);
* sets the mouse state to aState for resons of drag state.
* @param aState is the new state of mousedown
*/
NS_IMETHOD SetMouseDownState(PRBool aState)=0;
/** GetMouseDownState(PRBool *);
* gets the mouse state to aState for resons of drag state.
* @param aState will hold the state of mousedown
*/
NS_IMETHOD GetMouseDownState(PRBool *aState)=0;
/**
if we are in table cell selection mode. aka ctrl click in table cell
*/
NS_IMETHOD GetTableCellSelection(PRBool *aState)=0;
/** GetSelection
* no query interface for selection. must use this method now.
* @param aSelectionType enum value defined in nsISelection for the seleciton you want.
*/
NS_IMETHOD GetSelection(SelectionType aSelectionType, nsISelection **aSelection)=0;
/**
* ScrollSelectionIntoView scrolls a region of the selection,
* so that it is visible in the scrolled view.
*
* @param aType the selection to scroll into view.
* @param aRegion the region inside the selection to scroll into view.
* @param aIsSynchronous when PR_TRUE, scrolls the selection into view
* at some point after the method returns.request which is processed
*/
NS_IMETHOD ScrollSelectionIntoView(SelectionType aSelectionType, SelectionRegion aRegion, PRBool aIsSynchronous)=0;
/** RepaintSelection repaints the selected frames that are inside the selection
* specified by aSelectionType.
* @param aSelectionType enum value defined in nsISelection for the seleciton you want.
*/
NS_IMETHOD RepaintSelection(nsPresContext* aPresContext, SelectionType aSelectionType)=0;
/** GetFrameForNodeOffset given a node and its child offset, return the nsIFrame and
* the offset into that frame.
* @param aNode input parameter for the node to look at
* @param aOffset offset into above node.
* @param aReturnFrame will contain the return frame. MUST NOT BE NULL or will return error
* @param aReturnOffset will contain offset into frame.
*/
NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset)=0;
/** AdjustOffsetsFromStyle. Called after detecting that a click or drag will
* select the frame, this function looks for user-select style on that frame or a parent
* frame, and adjust the content and offsets accordingly.
* @param aFrame the frame that was clicked
* @param outContent content node to be selected
* @param outStartOffset selection start offset
* @param outEndOffset selection end offset
*/
NS_IMETHOD AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset)=0;
NS_IMETHOD GetHint(HINT *aHint)=0;
NS_IMETHOD SetHint(HINT aHint)=0;
/** CharacterMove will generally be called from the nsiselectioncontroller implementations.
* the effect being the selection will move one character left or right.
* @param aForward move forward in document.
* @param aExtend continue selection
*/
NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend)=0;
/** WordMove will generally be called from the nsiselectioncontroller implementations.
* the effect being the selection will move one word left or right.
* @param aForward move forward in document.
* @param aExtend continue selection
*/
NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend)=0;
/** LineMove will generally be called from the nsiselectioncontroller implementations.
* the effect being the selection will move one line up or down.
* @param aForward move forward in document.
* @param aExtend continue selection
*/
NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend)=0;
/** IntraLineMove will generally be called from the nsiselectioncontroller implementations.
* the effect being the selection will move to beginning or end of line
* @param aForward move forward in document.
* @param aExtend continue selection
*/
NS_IMETHOD IntraLineMove(PRBool aForward, PRBool aExtend)=0;
/**
* Scrolling then moving caret placement code in common to text areas and
* content areas should be located in the implementer
* This method will accept the following parameters and perform the scroll
* and caret movement. It remains for the caller to call the final
* ScrollCaretIntoView if that called wants to be sure the caret is always
* visible.
*
* @param aForward if PR_TRUE, scroll forward if not scroll backward
*
* @param aExtend if PR_TRUE, extend selection to the new point
*
* @param aScrollableView the view that needs the scrolling
*
* @param aFrameSel the nsIFrameSelection of the caller.
*
* @return always NS_OK
*/
NS_IMETHOD CommonPageMove(PRBool aForward,
PRBool aExtend,
nsIScrollableView *aScrollableView,
nsIFrameSelection *aFrameSel)=0;
/** Select All will generally be called from the nsiselectioncontroller implementations.
* it will select the whole doc
*/
NS_IMETHOD SelectAll()=0;
/** Sets/Gets The display selection enum.
*/
NS_IMETHOD SetDisplaySelection(PRInt16 aState)=0;
NS_IMETHOD GetDisplaySelection(PRInt16 *aState)=0;
/** Allow applications to specify how we should place the caret
* when the user clicks over an existing selection. A aDelay
* value of PR_TRUE means delay clearing the selection and
* placing the caret until MouseUp, when the user clicks over
* an existing selection. This is especially usefull when applications
* want to support Drag & Drop of the current selection. A value
* of PR_FALSE means place the caret immediately. If the application
* never calls this method, the nsIFrameSelection implementation
* assumes the default value is PR_TRUE.
* @param aDelay PR_TRUE if we should delay caret placement.
*/
NS_IMETHOD SetDelayCaretOverExistingSelection(PRBool aDelay)=0;
/** Get the current delay caret setting. If aDelay contains
* a return value of PR_TRUE, the caret is placed on MouseUp
* when clicking over an existing selection. If PR_FALSE,
* the selection is cleared and caret is placed immediately
* in all cases.
* @param aDelay will contain the return value.
*/
NS_IMETHOD GetDelayCaretOverExistingSelection(PRBool *aDelay)=0;
/** If we are delaying caret placement til MouseUp (see
* Set/GetDelayCaretOverExistingSelection()), this method
* can be used to store the data received during the MouseDown
* so that we can place the caret during the MouseUp event.
* @aMouseEvent the event received by the selection MouseDown
* handling method. A NULL value can be use to tell this method
* that any data is storing is no longer valid.
*/
NS_IMETHOD SetDelayedCaretData(nsMouseEvent *aMouseEvent)=0;
/** Get the delayed MouseDown event data necessary to place the
* caret during MouseUp processing.
* @aMouseEvent will contain a pointer to the event received
* by the selection during MouseDown processing. It can be NULL
* if the data is no longer valid.
*/
NS_IMETHOD GetDelayedCaretData(nsMouseEvent **aMouseEvent)=0;
/** Get the content node that limits the selection
* When searching up a nodes for parents, as in a text edit field
* in an browser page, we must stop at this node else we reach into the
* parent page, which is very bad!
*/
NS_IMETHOD GetLimiter(nsIContent **aLimiterContent)=0;
/** This will tell the frame selection that a double click has been pressed
* so it can track abort future drags if inside the same selection
* @aDoubleDown has the double click down happened
*/
NS_IMETHOD SetMouseDoubleDown(PRBool aDoubleDown)=0;
/** This will return whether the double down flag was set.
* @aDoubleDown is the return boolean value
*/
NS_IMETHOD GetMouseDoubleDown(PRBool *aDoubleDown)=0;
/**
* MaintainSelection will track the current selection as being "sticky".
* Dragging or extending selection will never allow for a subset
* (or the whole) of the maintained selection to become unselected.
* Primary use: double click selecting then dragging on second click
*/
NS_IMETHOD MaintainSelection()=0;
#ifdef IBMBIDI
/** GetPrevNextBidiLevels will return the frames and associated Bidi levels of the characters
* logically before and after a (collapsed) selection.
* @param aPresContext is the context to use
* @param aNode is the node containing the selection
* @param aContentOffset is the offset of the selection in the node
* @param aPrevFrame will hold the frame of the character before the selection
* @param aNextFrame will hold the frame of the character after the selection
* @param aPrevLevel will hold the Bidi level of the character before the selection
* @param aNextLevel will hold the Bidi level of the character after the selection
*
* At the beginning and end of each line there is assumed to be a frame with Bidi level equal to the
* paragraph embedding level. In these cases aPrevFrame and aNextFrame respectively will return nsnull.
*/
NS_IMETHOD GetPrevNextBidiLevels(nsPresContext *aPresContext, nsIContent *aNode, PRUint32 aContentOffset,
nsIFrame **aPrevFrame, nsIFrame **aNextFrame, PRUint8 *aPrevLevel, PRUint8 *aNextLevel)=0;
/** GetFrameFromLevel will scan in a given direction
* until it finds a frame with a Bidi level less than or equal to a given level.
* It will return the last frame before this.
* @param aPresContext is the context to use
* @param aFrameIn is the frame to start from
* @param aDirection is the direction to scan
* @param aBidiLevel is the level to search for
* @param aFrameOut will hold the frame returned
*/
NS_IMETHOD GetFrameFromLevel(nsPresContext *aPresContext, nsIFrame *aFrameIn, nsDirection aDirection, PRUint8 aBidiLevel,
nsIFrame **aFrameOut)=0;
#endif // IBMBIDI
};
#endif /* nsIFrameSelection_h___ */

View File

@@ -1,95 +0,0 @@
/* -*- 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
* 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 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 NSIFRAMETRAVERSAL_H
#define NSIFRAMETRAVERSAL_H
#include "nsISupports.h"
#include "nsIEnumerator.h"
#include "nsIFrame.h"
/* Brief explanation of frame traversal types:
*
* LEAF:
* Iterate over only the leaf frames in the tree, in depth-first order.
*
* EXTENSIVE:
* Iterate over all frames in the tree, including non-leaf frames.
* Child frames are traversed before their parents going both forward
* and backward.
*
* FOCUS:
* Traverse frames in "focus" order, which is like extensive but
* does a strict preorder traversal in both directions. This type of
* traversal also handles placeholder frames transparently, meaning that
* it will never stop on one - going down will get the real frame, going
* back up will go on past the placeholder, so the placeholders are logically
* part of the frame tree.
*
* FASTEST:
* XXX not implemented
*
* VISUAL:
* Traverse frames in "visual" order (left-to-right, top-to-bottom).
*/
enum nsTraversalType{
LEAF,
EXTENSIVE,
FOCUS,
FASTEST
#ifdef IBMBIDI // Simon
, VISUAL
#endif
};
// {1691E1F3-EE41-11d4-9885-00C04FA0CF4B}
#define NS_IFRAMETRAVERSAL_IID \
{ 0x1691e1f3, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
class nsIFrameTraversal : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMETRAVERSAL_IID)
NS_IMETHOD NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
PRUint32 aType,
nsPresContext* aPresContext,
nsIFrame *aStart) = 0;
};
#endif //NSIFRAMETRAVERSAL_H

View File

@@ -1,57 +0,0 @@
/* -*- 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
* 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 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 nsIImageMap_h___
#define nsIImageMap_h___
#include "nsISupports.h"
class nsIContent;
struct nsRect;
#define NS_IIMAGEMAP_IID \
{ 0x36a48085, 0xc213, 0x4464, { 0xab, 0x60, 0x41, 0x2e, 0xc8, 0xe8, 0xb1, 0xfe } }
class nsIImageMap : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEMAP_IID)
NS_IMETHOD GetBoundsForAreaContent(nsIContent *aContent,
nsPresContext* aPresContext,
nsRect& aBounds) = 0;
};
#endif /* nsIImageMap_h___ */

View File

@@ -1,74 +0,0 @@
/* -*- 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 Communicator client 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):
*
* 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 nsILayoutDebugger_h___
#define nsILayoutDebugger_h___
#include "nsISupports.h"
class nsIDocument;
class nsIPresShell;
/* a6cf90f8-15b3-11d2-932e-00805f8add32 */
#define NS_ILAYOUT_DEBUGGER_IID \
{ 0xa6cf90f8, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
/**
* API for access and control of layout debugging
*/
class nsILayoutDebugger : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILAYOUT_DEBUGGER_IID)
NS_IMETHOD SetShowFrameBorders(PRBool aEnable) = 0;
NS_IMETHOD GetShowFrameBorders(PRBool* aResult) = 0;
NS_IMETHOD SetShowEventTargetFrameBorder(PRBool aEnable) = 0;
NS_IMETHOD GetShowEventTargetFrameBorder(PRBool* aResult) = 0;
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
PRInt32* aSizeInBytesResult) = 0;
NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
PRInt32* aSizeInBytesResult) = 0;
NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
PRInt32* aSizeInBytesResult) = 0;
};
#endif /* nsILayoutDebugger_h___ */

View File

@@ -1,26 +0,0 @@
#ifndef _nsILayoutHistoryState_h
#define _nsILayoutHistoryState_h
#include "nsISupports.h"
#include "nsIPresState.h"
#define NS_ILAYOUTHISTORYSTATE_IID_STR "306c8ca0-5f0c-11d3-a9fb-000064657374"
#define NS_ILAYOUTHISTORYSTATE_IID \
{0x306c8ca0, 0x5f0c, 0x11d3, \
{0xa9, 0xfb, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
class nsILayoutHistoryState : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILAYOUTHISTORYSTATE_IID)
NS_IMETHOD AddState(const nsCString& aKey, nsIPresState* aState) = 0;
NS_IMETHOD GetState(const nsCString& aKey, nsIPresState** aState) = 0;
NS_IMETHOD RemoveState(const nsCString& aKey) = 0;
};
nsresult
NS_NewLayoutHistoryState(nsILayoutHistoryState** aState);
#endif /* _nsILayoutHistoryState_h */

View File

@@ -1,65 +0,0 @@
/* -*- 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
* 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 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 nsIPercentHeightObserver_h___
#define nsIPercentHeightObserver_h___
struct nsHTMLReflowState;
class nsPresContext;
// IID for the nsIPercentHeightObserver interface
#define NS_IPERCENTHEIGHTOBSERVER_IID \
{ 0x9cdc174b, 0x4f39, 0x41ad, {0xbc, 0x16, 0x5a, 0xc5, 0xa8, 0x64, 0x14, 0xa1}}
/**
* This interface is supported by frames that need to provide computed height
* values to children during reflow which would otherwise not happen. Currently only
* table cells support this.
*/
class nsIPercentHeightObserver : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPERCENTHEIGHTOBSERVER_IID)
// Notify the observer that aReflowState has no computed height, but it has a percent height
virtual void NotifyPercentHeight(const nsHTMLReflowState& aReflowState) = 0;
// Ask the observer if it should observe aReflowState.frame
virtual PRBool NeedsToObserve(const nsHTMLReflowState& aReflowState) = 0;
};
#endif // nsIPercentHeightObserver_h___

View File

@@ -1,703 +0,0 @@
/* -*- 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Steve Clark <buster@netscape.com>
* Dan Rosen <dr@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 *****
*
* 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
* 05/03/2000 IBM Corp. Observer related defines for reflow
*/
#ifndef nsIPresShell_h___
#define nsIPresShell_h___
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsEvent.h"
#include "nsReflowType.h"
#include "nsCompatibility.h"
#include "nsCOMArray.h"
#include "nsFrameManagerBase.h"
#include "mozFlushType.h"
#include <stdio.h> // for FILE definition
class nsIAtom;
class nsIContent;
class nsIContentIterator;
class nsIDocument;
class nsIDocumentObserver;
class nsIFrame;
class nsPresContext;
class nsStyleSet;
class nsIViewManager;
class nsIDeviceContext;
class nsIRenderingContext;
class nsIPageSequenceFrame;
class nsString;
class nsAString;
class nsStringArray;
class nsICaret;
class nsStyleContext;
class nsIFrameSelection;
class nsFrameManager;
class nsILayoutHistoryState;
class nsIReflowCallback;
class nsISupportsArray;
class nsIDOMNode;
class nsHTMLReflowCommand;
class nsIStyleFrameConstruction;
class nsIStyleSheet;
class nsCSSFrameConstructor;
#define NS_IPRESSHELL_IID \
{ 0x3b864134, 0x4e25, 0x4cd0, \
{0xa6, 0x9e, 0x34, 0x14, 0x13, 0x18, 0x39, 0x58} }
// Constants uses for ScrollFrameIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
#define NS_PRESSHELL_SCROLL_BOTTOM 100
#define NS_PRESSHELL_SCROLL_LEFT 0
#define NS_PRESSHELL_SCROLL_RIGHT 100
#define NS_PRESSHELL_SCROLL_CENTER 50
#define NS_PRESSHELL_SCROLL_ANYWHERE -1
#define NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE -2
// debug VerifyReflow flags
#define VERIFY_REFLOW_ON 0x01
#define VERIFY_REFLOW_NOISY 0x02
#define VERIFY_REFLOW_ALL 0x04
#define VERIFY_REFLOW_DUMP_COMMANDS 0x08
#define VERIFY_REFLOW_NOISY_RC 0x10
#define VERIFY_REFLOW_REALLY_NOISY_RC 0x20
#define VERIFY_REFLOW_INCLUDE_SPACE_MANAGER 0x40
#define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x80
#ifdef IBMBIDI // Constant for Set/Get CaretBidiLevel
#define BIDI_LEVEL_UNDEFINED 0x80
#endif
// for PostAttributeChanged
enum nsAttributeChangeType {
eChangeType_Set = 0, // Set attribute
eChangeType_Remove = 1 // Remove attribute
};
/**
* Presentation shell interface. Presentation shells are the
* controlling point for managing the presentation of a document. The
* presentation shell holds a live reference to the document, the
* presentation context, the style manager, the style set and the root
* frame. <p>
*
* When this object is Release'd, it will release the document, the
* presentation context, the style manager, the style set and the root
* frame.
*/
// hack to make egcs / gcc 2.95.2 happy
class nsIPresShell_base : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID)
};
class nsIPresShell : public nsIPresShell_base
{
public:
NS_IMETHOD Init(nsIDocument* aDocument,
nsPresContext* aPresContext,
nsIViewManager* aViewManager,
nsStyleSet* aStyleSet,
nsCompatibility aCompatMode) = 0;
/**
* All callers are responsible for calling |Destroy| after calling
* |EndObservingDocument|. It needs to be separate only because form
* controls incorrectly store their data in the frames rather than the
* content model and printing calls |EndObservingDocument| multiple
* times to make form controls behave nicely when printed.
*/
NS_IMETHOD Destroy() = 0;
// All frames owned by the shell are allocated from an arena. They are also recycled
// using free lists (separate free lists being maintained for each size_t).
// Methods for recycling frames.
virtual void* AllocateFrame(size_t aSize) = 0;
virtual void FreeFrame(size_t aSize, void* aFreeChunk) = 0;
// Dynamic stack memory allocation
NS_IMETHOD PushStackMemory() = 0;
NS_IMETHOD PopStackMemory() = 0;
NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult) = 0;
nsIDocument* GetDocument() { return mDocument; }
nsPresContext* GetPresContext() { return mPresContext; }
nsIViewManager* GetViewManager() { return mViewManager; }
#ifdef _IMPL_NS_LAYOUT
nsStyleSet* StyleSet() { return mStyleSet; }
nsCSSFrameConstructor* FrameConstructor()
{
return mFrameConstructor;
}
nsFrameManager* FrameManager() const {
return NS_REINTERPRET_CAST(nsFrameManager*,
&NS_CONST_CAST(nsIPresShell*, this)->mFrameManager);
}
#endif
// These two methods are used only by viewer
NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle) = 0;
NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle) = 0;
/* Enable/disable author style level. Disabling author style disables the entire
* author level of the cascade, including the HTML preshint level.
*/
// XXX these could easily be inlined, but there is a circular #include
// problem with nsStyleSet.
NS_HIDDEN_(void) SetAuthorStyleDisabled(PRBool aDisabled);
NS_HIDDEN_(PRBool) GetAuthorStyleDisabled();
/*
* Called when stylesheets are added/removed/enabled/disabled to rebuild
* all style data for a given pres shell without necessarily reconstructing
* all of the frames.
*/
virtual NS_HIDDEN_(void) ReconstructStyleDataExternal();
NS_HIDDEN_(void) ReconstructStyleDataInternal();
#ifdef _IMPL_NS_LAYOUT
void ReconstructStyleData() { ReconstructStyleDataInternal(); }
#else
void ReconstructStyleData() { ReconstructStyleDataExternal(); }
#endif
/** Setup all style rules required to implement preferences
* - used for background/text/link colors and link underlining
* may be extended for any prefs that are implemented via style rules
* - aForceReflow argument is used to force a full reframe to make the rules show
* (only used when the current page needs to reflect changed pref rules)
*
* - initially created for bugs 31816, 20760, 22963
*/
NS_IMETHOD SetPreferenceStyleRules(PRBool aForceReflow) = 0;
/**
* Gather titles of all selectable (alternate and preferred) style sheets
* fills void array with nsString* caller must free strings
*/
NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList) = 0;
/**
* FrameSelection will return the Frame based selection API.
* You cannot go back and forth anymore with QI between nsIDOM sel and
* nsIFrame sel.
*/
nsIFrameSelection* FrameSelection() { return mSelection; }
// Make shell be a document observer
NS_IMETHOD BeginObservingDocument() = 0;
// Make shell stop being a document observer
NS_IMETHOD EndObservingDocument() = 0;
/**
* Determine if InitialReflow() was previously called.
* @param aDidInitialReflow PR_TRUE if InitalReflow() was previously called,
* PR_FALSE otherwise.
*/
NS_IMETHOD GetDidInitialReflow(PRBool *aDidInitialReflow) = 0;
/**
* Perform the initial reflow. Constructs the frame for the root content
* object and then reflows the frame model into the specified width and
* height.
*
* The coordinates for aWidth and aHeight must be in standard nscoord's.
*/
NS_IMETHOD InitialReflow(nscoord aWidth, nscoord aHeight) = 0;
/**
* Reflow the frame model into a new width and height. The
* coordinates for aWidth and aHeight must be in standard nscoord's.
*/
NS_IMETHOD ResizeReflow(nscoord aWidth, nscoord aHeight) = 0;
/**
* Reflow the frame model with a reflow reason of eReflowReason_StyleChange
*/
NS_IMETHOD StyleChangeReflow() = 0;
/**
* This calls through to the frame manager to get the root frame.
* Callers inside of gklayout should use FrameManager()->GetRootFrame()
* instead, as it's more efficient.
*/
virtual NS_HIDDEN_(nsIFrame*) GetRootFrame() const;
/**
* Returns the page sequence frame associated with the frame hierarchy.
* Returns NULL if not a paginated view.
*/
NS_IMETHOD GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const = 0;
/**
* Gets the primary frame associated with the content object. This is a
* helper function that just forwards the request to the frame manager.
*
* The primary frame is the frame that is most closely associated with the
* content. A frame is more closely associated with the content that another
* frame if the one frame contains directly or indirectly the other frame (e.g.,
* when a frame is scrolled there is a scroll frame that contains the frame
* being scrolled). The primary frame is always the first-in-flow.
*
* In the case of absolutely positioned elements and floated elements,
* the primary frame is the frame that is out of the flow and not the
* placeholder frame.
*/
NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent,
nsIFrame** aPrimaryFrame) const = 0;
/**
* Returns a layout object associated with the primary frame for the content object.
*
* @param aContent the content object for which we seek a layout object
* @param aResult the resulting layout object as an nsISupports, if found. Refcounted.
*/
NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent,
nsISupports** aResult) const = 0;
/**
* Gets the placeholder frame associated with the specified frame. This is
* a helper frame that forwards the request to the frame manager.
*/
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aPlaceholderFrame) const = 0;
/**
* Reflow commands
*/
NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand) = 0;
NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, nsReflowType* aCmdType) = 0;
NS_IMETHOD CancelAllReflowCommands() = 0;
/**
* Recreates the frames for a node
*/
NS_IMETHOD RecreateFramesFor(nsIContent* aContent) = 0;
/**
* Determine if it is safe to flush all pending notifications
* @param aIsSafeToFlush PR_TRUE if it is safe, PR_FALSE otherwise.
*
*/
NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush) = 0;
/**
* Flush pending notifications of the type specified. This method
* will not affect the content model; it'll just affect style and
* frames. Callers that actually want up-to-date presentation (other
* than the document itself) should probably be calling
* nsIDocument::FlushPendingNotifications.
*
* @param aType the type of notifications to flush
*/
NS_IMETHOD FlushPendingNotifications(mozFlushType aType) = 0;
/**
* Post a request to handle a DOM event after Reflow has finished.
*/
NS_IMETHOD PostDOMEvent(nsIContent* aContent, nsEvent* aEvent)=0;
/**
* Post a request to set and attribute after reflow has finished.
*/
NS_IMETHOD PostAttributeChange(nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aName,
const nsString& aValue,
PRBool aNotify,
nsAttributeChangeType aType) = 0;
NS_IMETHOD PostReflowCallback(nsIReflowCallback* aCallback) = 0;
NS_IMETHOD CancelReflowCallback(nsIReflowCallback* aCallback) = 0;
/**
* Reflow batching
*/
NS_IMETHOD BeginReflowBatching() = 0;
NS_IMETHOD EndReflowBatching(PRBool aFlushPendingReflows) = 0;
NS_IMETHOD GetReflowBatchingStatus(PRBool* aIsBatching) = 0;
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
/**
* Given a frame, create a rendering context suitable for use with
* the frame.
*/
NS_IMETHOD CreateRenderingContext(nsIFrame *aFrame,
nsIRenderingContext** aContext) = 0;
/**
* Notification that we were unable to render a replaced element.
* Called when the replaced element can not be rendered, and we should
* instead render the element's contents.
* The content object associated with aFrame should either be a IMG
* element, an OBJECT element, or an APPLET element
*/
NS_IMETHOD CantRenderReplacedElement(nsIFrame* aFrame) = 0;
/**
* Informs the pres shell that the document is now at the anchor with
* the given name. If |aScroll| is true, scrolls the view of the
* document so that the anchor with the specified name is displayed at
* the top of the window. If |aAnchorName| is empty, then this informs
* the pres shell that there is no current target, and |aScroll| must
* be false.
*/
NS_IMETHOD GoToAnchor(const nsAString& aAnchorName, PRBool aScroll) = 0;
/**
* Scrolls the view of the document so that the frame is displayed at the
* top of the window.
*
* @param aFrame The frame to scroll into view
* @param aVPercent How to align the frame vertically. A value of 0
* (NS_PRESSHELL_SCROLL_TOP) means the frame's upper edge is
* aligned with the top edge of the visible area. A value of
* 100 (NS_PRESSHELL_SCROLL_BOTTOM) means the frame's bottom
* edge is aligned with the bottom edge of the visible area.
* For values in between, the point "aVPercent" down the frame
* is placed at the point "aVPercent" down the visible area. A
* value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
* vertically. A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
* the frame the minimum amount necessary in order for the entire
* frame to be visible vertically (if possible)
* @param aHPercent How to align the frame horizontally. A value of 0
* (NS_PRESSHELL_SCROLL_LEFT) means the frame's left edge is
* aligned with the left edge of the visible area. A value of
* 100 (NS_PRESSHELL_SCROLL_RIGHT) means the frame's right
* edge is aligned with the right edge of the visible area.
* For values in between, the point "aVPercent" across the frame
* is placed at the point "aVPercent" across the visible area.
* A value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
* horizontally . A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
* the frame the minimum amount necessary in order for the entire
* frame to be visible horizontally (if possible)
*/
NS_IMETHOD ScrollFrameIntoView(nsIFrame *aFrame,
PRIntn aVPercent,
PRIntn aHPercent) const = 0;
/**
* Suppress notification of the frame manager that frames are
* being destroyed.
*/
NS_IMETHOD SetIgnoreFrameDestruction(PRBool aIgnore) = 0;
/**
* Notification sent by a frame informing the pres shell that it is about to
* be destroyed.
* This allows any outstanding references to the frame to be cleaned up
*/
NS_IMETHOD NotifyDestroyingFrame(nsIFrame* aFrame) = 0;
/**
* Notify the Clipboard that we have something to copy.
*/
NS_IMETHOD DoCopy() = 0;
/**
* Get link location.
*/
NS_IMETHOD GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation) = 0;
/**
* Get the doc or the selection as text or html.
*/
NS_IMETHOD DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString& outValue) = 0;
/**
* Get the caret, if it exists. AddRefs it.
*/
NS_IMETHOD GetCaret(nsICaret **aOutCaret) = 0;
/**
* Should the images have borders etc. Actual visual effects are determined
* by the frames. Visual effects may not effect layout, only display.
* Takes effect on next repaint, does not force a repaint itself.
*
* @param aEnabled if PR_TRUE, visual selection effects are enabled
* if PR_FALSE visual selection effects are disabled
* @return always NS_OK
*/
NS_IMETHOD SetSelectionFlags(PRInt16 aInEnable) = 0;
/**
* Gets the current state of non text selection effects
* @param aEnabled [OUT] set to the current state of non text selection,
* as set by SetDisplayNonTextSelection
* @return if aOutEnabled==null, returns NS_ERROR_INVALID_ARG
* else NS_OK
*/
NS_IMETHOD GetSelectionFlags(PRInt16 *aOutEnabled) = 0;
/**
* Interface to dispatch events via the presshell
*/
NS_IMETHOD HandleEventWithTarget(nsEvent* aEvent,
nsIFrame* aFrame,
nsIContent* aContent,
PRUint32 aFlags,
nsEventStatus* aStatus) = 0;
/**
* Dispatch event to content only (NOT full processing)
*/
NS_IMETHOD HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsEvent* aEvent,
nsEventStatus* aStatus) = 0;
/**
* Gets the current target event frame from the PresShell
*/
NS_IMETHOD GetEventTargetFrame(nsIFrame** aFrame) = 0;
/**
* Gets the current target event frame from the PresShell
*/
NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent) = 0;
/**
* Get and set the history state for the current document
*/
NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage = PR_FALSE) = 0;
/**
* Determine if reflow is currently locked
* @param aIsReflowLocked returns PR_TRUE if reflow is locked, PR_FALSE otherwise
*/
NS_IMETHOD IsReflowLocked(PRBool* aIsLocked) = 0;
/**
* Returns a content iterator to iterate the generated content nodes.
* You must specify whether you want to iterate the "before" generated
* content or the "after" generated content. If there is no generated
* content of the specified type for the promary frame associated with
* with the content object then NULL is returned
*/
enum GeneratedContentType {Before, After};
NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent,
GeneratedContentType aType,
nsIContentIterator** aIterator) const = 0;
/**
* Store the nsIAnonymousContentCreator-generated anonymous
* content that's associated with an element. The new anonymous content
* is added to whatever anonymous content might already be associated with
* the element.
* @param aContent the element with which the anonymous
* content is to be associated with
* @param aAnonymousElements an array of nsIContent
* objects, or null to indicate that any anonymous
* content should be dissociated from the aContent
*/
NS_IMETHOD SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnonymousElements) = 0;
/**
* Retrieve the nsIAnonymousContentCreator-generated anonymous
* content that's associated with an element.
* @param aContent the element for which to retrieve the
* associated anonymous content
* @param aAnonymousElements an array of nsIContent objects,
* or null to indicate that there are no anonymous elements
* associated with aContent
*/
NS_IMETHOD GetAnonymousContentFor(nsIContent* aContent, nsISupportsArray** aAnonymousElements) = 0;
/**
* Release all nsIAnonymousContentCreator-generated
* anonymous content associated with the shell.
*/
NS_IMETHOD ReleaseAnonymousContent() = 0;
/**
* Called to find out if painting is suppressed for this presshell. If it is suppressd,
* we don't allow the painting of any layer but the background, and we don't
* recur into our children.
*/
NS_IMETHOD IsPaintingSuppressed(PRBool* aResult)=0;
/**
* Unsuppress painting.
*/
NS_IMETHOD UnsuppressPainting() = 0;
/**
* Called to disable nsITheme support in a specific presshell.
*/
NS_IMETHOD DisableThemeSupport() = 0;
/**
* Indicates whether theme support is enabled.
*/
virtual PRBool IsThemeSupportEnabled() = 0;
/**
* Get the set of agent style sheets for this presentation
*/
virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets) = 0;
/**
* Replace the set of agent style sheets
*/
virtual nsresult SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets) = 0;
/**
* Add an override style sheet for this presentation
*/
virtual nsresult AddOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
/**
* Remove an override style sheet
*/
virtual nsresult RemoveOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
/**
* Reconstruct frames for all elements in the document
*/
virtual nsresult ReconstructFrames() = 0;
/**
* See if reflow verification is enabled. To enable reflow verification add
* "verifyreflow:1" to your NSPR_LOG_MODULES environment variable
* (any non-zero debug level will work). Or, call SetVerifyReflowEnable
* with PR_TRUE.
*/
static PRBool GetVerifyReflowEnable();
/**
* Set the verify-reflow enable flag.
*/
static void SetVerifyReflowEnable(PRBool aEnabled);
/**
* Get the flags associated with the VerifyReflow debug tool
*/
static PRInt32 GetVerifyReflowFlags();
#ifdef MOZ_REFLOW_PERF
NS_IMETHOD DumpReflows() = 0;
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
NS_IMETHOD PaintCount(const char * aName,
nsIRenderingContext* aRenderingContext,
nsPresContext * aPresContext,
nsIFrame * aFrame,
PRUint32 aColor) = 0;
NS_IMETHOD SetPaintFrameCount(PRBool aOn) = 0;
#endif
#ifdef IBMBIDI
/**
* SetCaretBidiLevel will set the Bidi embedding level for the cursor. 0-63
*/
NS_IMETHOD SetCaretBidiLevel(PRUint8 aLevel) = 0;
/**
* GetCaretBidiLevel will get the Bidi embedding level for the cursor. 0-63
*/
NS_IMETHOD GetCaretBidiLevel(PRUint8 *aOutLevel) = 0;
/**
* UndefineCaretBidiLevel will set the Bidi embedding level for the cursor to an out-of-range value
*/
NS_IMETHOD UndefineCaretBidiLevel(void) = 0;
/**
* Reconstruct and reflow frame model
*/
NS_IMETHOD BidiStyleChangeReflow(void) = 0;
#endif
#ifdef DEBUG
// Debugging hooks
virtual void ListStyleContexts(nsIFrame *aRootFrame, FILE *out,
PRInt32 aIndent = 0) = 0;
virtual void ListStyleSheets(FILE *out, PRInt32 aIndent = 0) = 0;
#endif
protected:
// IMPORTANT: The ownership implicit in the following member variables
// has been explicitly checked. If you add any members to this class,
// please make the ownership explicit (pinkerton, scc).
// these are the same Document and PresContext owned by the DocViewer.
// we must share ownership.
nsIDocument* mDocument; // [STRONG]
nsPresContext* mPresContext; // [STRONG]
nsStyleSet* mStyleSet; // [OWNS]
nsCSSFrameConstructor* mFrameConstructor; // [OWNS]
nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
nsIFrameSelection* mSelection;
nsFrameManagerBase mFrameManager; // [OWNS]
PRPackedBool mStylesHaveChanged;
};
/**
* Create a new empty presentation shell. Upon success, call Init
* before attempting to use the shell.
*/
nsresult
NS_NewPresShell(nsIPresShell** aInstancePtrResult);
#endif /* nsIPresShell_h___ */

View File

@@ -1,39 +0,0 @@
#ifndef _nsIPresState_h
#define _nsIPresState_h
#include "nsISupports.h"
#include "nsString.h"
// {98DABCE1-C9D7-11d3-BF87-00105A1B0627}
#define NS_IPRESSTATE_IID \
{ 0x98dabce1, 0xc9d7, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
class nsIPresState : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESSTATE_IID)
NS_IMETHOD GetStatePropertyAsSupports(const nsAString& aName,
nsISupports** aResult) = 0;
NS_IMETHOD SetStatePropertyAsSupports(const nsAString& aName,
nsISupports* aValue) = 0;
/**
* Get the current value of a property.
*
* @param aName the name of the property.
* @param aResult the value (may legitimately be the empty string) [OUT]
* @throws NS_STATE_PROPERTY_NOT_THERE if the property is not set
* @throws NS_STATE_PROPERTY_EXISTS if the attribute exists (==NS_OK)
*/
NS_IMETHOD GetStateProperty(const nsAString& aName,
nsAString& aResult) = 0;
NS_IMETHOD SetStateProperty(const nsAString& aProperty,
const nsAString& aValue) = 0;
NS_IMETHOD RemoveStateProperty(const nsAString& aName) = 0;
};
nsresult
NS_NewPresState(nsIPresState** aResult);
#endif /* _nsIPresState_h */

View File

@@ -1,57 +0,0 @@
/* -*- 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 Communicator client 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: David Hyatt (hyatt@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 ***** */
#ifndef nsIReflowCallback_h___
#define nsIReflowCallback_h___
// {03E6FD70-889C-44b1-8639-A7EF5A80ED5C}
#define NS_IREFLOWCALLBACK_IID \
{ 0x3e6fd70, 0x889c, 0x44b1, { 0x86, 0x39, 0xa7, 0xef, 0x5a, 0x80, 0xed, 0x5c } }
class nsIPresShell;
/**
* Reflow callback interface
*/
class nsIReflowCallback : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IREFLOWCALLBACK_IID)
NS_IMETHOD ReflowFinished(nsIPresShell* aShell, PRBool* aFlushFlag) = 0;
};
#endif /* nsIFrameUtil_h___ */

View File

@@ -1,61 +0,0 @@
/* -*- Mode: IDL; 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 the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* 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 ***** */
#include "nsISupports.idl"
%{ C++
class imgIContainer;
%}
[ptr] native imgIContainer(imgIContainer);
[uuid(f6f68e3c-f078-4235-bf71-53d180c37d26)]
interface nsISelectionImageService : nsISupports
{
/**
* the current image is marked as invalid
*/
void reset();
/**
* retrieve the image for alpha blending
*/
void getImage(in short selectionValue, out imgIContainer container);
};

View File

@@ -1,276 +0,0 @@
/* -*- 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@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 ***** */
#include "nsImageLoader.h"
#include "imgILoader.h"
#include "nsIURI.h"
#include "nsILoadGroup.h"
#include "nsNetUtil.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "imgIContainer.h"
#include "nsIViewManager.h"
#include "nsStyleContext.h"
// Paint forcing
#include "prenv.h"
NS_IMPL_ISUPPORTS2(nsImageLoader, imgIDecoderObserver, imgIContainerObserver)
nsImageLoader::nsImageLoader() :
mFrame(nsnull), mPresContext(nsnull)
{
}
nsImageLoader::~nsImageLoader()
{
mFrame = nsnull;
mPresContext = nsnull;
if (mRequest) {
mRequest->Cancel(NS_ERROR_FAILURE);
}
}
void
nsImageLoader::Init(nsIFrame *aFrame, nsPresContext *aPresContext)
{
mFrame = aFrame;
mPresContext = aPresContext;
}
void
nsImageLoader::Destroy()
{
mFrame = nsnull;
mPresContext = nsnull;
if (mRequest) {
mRequest->Cancel(NS_ERROR_FAILURE);
}
mRequest = nsnull;
}
nsresult
nsImageLoader::Load(imgIRequest *aImage)
{
if (!mFrame)
return NS_ERROR_NOT_INITIALIZED;
if (!aImage)
return NS_ERROR_FAILURE;
if (mRequest) {
nsCOMPtr<nsIURI> oldURI;
mRequest->GetURI(getter_AddRefs(oldURI));
nsCOMPtr<nsIURI> newURI;
aImage->GetURI(getter_AddRefs(newURI));
PRBool eq = PR_FALSE;
nsresult rv = newURI->Equals(oldURI, &eq);
if (NS_SUCCEEDED(rv) && eq) {
return NS_OK;
}
// Now cancel the old request so it won't hold a stale ref to us.
mRequest->Cancel(NS_ERROR_FAILURE);
mRequest = nsnull;
}
return aImage->Clone(this, getter_AddRefs(mRequest));
}
NS_IMETHODIMP nsImageLoader::OnStartDecode(imgIRequest *aRequest)
{
return NS_OK;
}
NS_IMETHODIMP nsImageLoader::OnStartContainer(imgIRequest *aRequest,
imgIContainer *aImage)
{
if (aImage)
{
/* Get requested animation policy from the pres context:
* normal = 0
* one frame = 1
* one loop = 2
*/
aImage->SetAnimationMode(mPresContext->ImageAnimationMode());
// Ensure the animation (if any) is started.
aImage->StartAnimation();
}
return NS_OK;
}
NS_IMETHODIMP nsImageLoader::OnStartFrame(imgIRequest *aRequest,
gfxIImageFrame *aFrame)
{
return NS_OK;
}
NS_IMETHODIMP nsImageLoader::OnDataAvailable(imgIRequest *aRequest,
gfxIImageFrame *aFrame,
const nsRect *aRect)
{
// Background images are not displayed incrementally, they are displayed after the entire
// image has been loaded.
// Note: Images referenced by the <img> element are displayed incrementally in nsImageFrame.cpp
return NS_OK;
}
NS_IMETHODIMP nsImageLoader::OnStopFrame(imgIRequest *aRequest,
gfxIImageFrame *aFrame)
{
if (!mFrame)
return NS_ERROR_FAILURE;
#ifdef NS_DEBUG
// Make sure the image request status's STATUS_FRAME_COMPLETE flag has been set to ensure
// the image will be painted when invalidated
if (aRequest) {
PRUint32 status = imgIRequest::STATUS_ERROR;
nsresult rv = aRequest->GetImageStatus(&status);
if (NS_SUCCEEDED(rv)) {
NS_ASSERTION((status & imgIRequest::STATUS_FRAME_COMPLETE), "imgIRequest::STATUS_FRAME_COMPLETE not set");
}
}
#endif
if (!mRequest) {
// We're in the middle of a paint anyway
return NS_OK;
}
// Draw the background image
RedrawDirtyFrame(nsnull);
return NS_OK;
}
NS_IMETHODIMP nsImageLoader::OnStopContainer(imgIRequest *aRequest,
imgIContainer *aImage)
{
return NS_OK;
}
NS_IMETHODIMP nsImageLoader::OnStopDecode(imgIRequest *aRequest,
nsresult status,
const PRUnichar *statusArg)
{
return NS_OK;
}
NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer,
gfxIImageFrame *newframe,
nsRect * dirtyRect)
{
if (!mFrame)
return NS_ERROR_FAILURE;
if (!mRequest) {
// We're in the middle of a paint anyway
return NS_OK;
}
nsRect r(*dirtyRect);
float p2t;
p2t = mPresContext->PixelsToTwips();
r.x = NSIntPixelsToTwips(r.x, p2t);
r.y = NSIntPixelsToTwips(r.y, p2t);
r.width = NSIntPixelsToTwips(r.width, p2t);
r.height = NSIntPixelsToTwips(r.height, p2t);
RedrawDirtyFrame(&r);
return NS_OK;
}
void
nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
{
// NOTE: It is not sufficient to invalidate only the size of the image:
// the image may be tiled!
// The best option is to call into the frame, however lacking this
// we have to at least invalidate the frame's bounds, hence
// as long as we have a frame we'll use its size.
//
// Invalidate the entire frame
// XXX We really only need to invalidate the client area of the frame...
nsRect bounds(nsPoint(0, 0), mFrame->GetSize());
// XXX this should be ok, but there is some crappy ass bug causing it not to work
// XXX seems related to the "body fixup rule" dealing with the canvas and body frames...
#if 0
// Invalidate the entire frame only if the frame has a tiled background
// image, otherwise just invalidate the intersection of the frame's bounds
// with the damaged rect.
nsStyleContext* styleContext;
mFrame->GetStyleContext(&styleContext);
const nsStyleBackground* bg = styleContext->GetStyleBackground();
if ((bg->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) ||
(bg->mBackgroundRepeat == NS_STYLE_BG_REPEAT_OFF)) {
// The frame does not have a background image so we are free
// to invalidate only the intersection of the damage rect and
// the frame's bounds.
if (aDamageRect) {
bounds.IntersectRect(*aDamageRect, bounds);
}
}
#endif
mFrame->Invalidate(bounds, PR_FALSE);
}

View File

@@ -1,74 +0,0 @@
/* -*- 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@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 ***** */
#include "imgIDecoderObserver.h"
class nsPresContext;
class nsIFrame;
class nsIURI;
#include "imgIRequest.h"
#include "nsCOMPtr.h"
class nsImageLoader : public imgIDecoderObserver
{
public:
nsImageLoader();
virtual ~nsImageLoader();
NS_DECL_ISUPPORTS
NS_DECL_IMGIDECODEROBSERVER
NS_DECL_IMGICONTAINEROBSERVER
void Init(nsIFrame *aFrame, nsPresContext *aPresContext);
nsresult Load(imgIRequest *aImage);
void Destroy();
nsIFrame *GetFrame() { return mFrame; }
imgIRequest *GetRequest() { return mRequest; }
private:
void RedrawDirtyFrame(const nsRect* aDamageRect);
private:
nsIFrame *mFrame;
nsPresContext *mPresContext;
nsCOMPtr<imgIRequest> mRequest;
};

View File

@@ -1,253 +0,0 @@
/* -*- 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
* Netscape Communications Corporation.
* 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 ***** */
/******
This file contains the list of all layout nsIAtoms and their values
It is designed to be used as inline input to nsLayoutAtoms.cpp *only*
through the magic of C preprocessing.
All entires must be enclosed in the macro LAYOUT_ATOM which will have cruel
and unusual things done to it
It is recommended (but not strictly necessary) to keep all entries
in alphabetical order
The first argument to LAYOUT_ATOM is the C++ identifier of the atom
The second argument is the string value of the atom
******/
// OUTPUT_CLASS=nsLayoutAtoms
// MACRO_NAME=LAYOUT_ATOM
// Alphabetical list of media type atoms
LAYOUT_ATOM(all, "all") // Media atoms must be lower case
LAYOUT_ATOM(aural, "aural")
LAYOUT_ATOM(braille, "braille")
LAYOUT_ATOM(embossed, "embossed")
LAYOUT_ATOM(handheld, "handheld")
LAYOUT_ATOM(print, "print")
LAYOUT_ATOM(projection, "projection")
LAYOUT_ATOM(screen, "screen")
LAYOUT_ATOM(tty, "tty")
LAYOUT_ATOM(tv, "tv")
// Alphabetical list of standard name space prefixes
LAYOUT_ATOM(htmlNameSpace, "html")
LAYOUT_ATOM(xmlNameSpace, "xml")
LAYOUT_ATOM(xmlnsNameSpace, "xmlns")
// Alphabetical list of frame additional child list names
LAYOUT_ATOM(absoluteList, "Absolute-list")
LAYOUT_ATOM(bulletList, "Bullet-list")
LAYOUT_ATOM(captionList, "Caption-list")
LAYOUT_ATOM(colGroupList, "ColGroup-list")
LAYOUT_ATOM(editorDisplayList, "EditorDisplay-List")
LAYOUT_ATOM(fixedList, "Fixed-list")
LAYOUT_ATOM(floatList, "Float-list")
LAYOUT_ATOM(overflowList, "Overflow-list")
LAYOUT_ATOM(overflowOutOfFlowList, "OverflowOutOfFlow-list")
LAYOUT_ATOM(popupList, "Popup-list")
LAYOUT_ATOM(commentTagName, "__moz_comment")
LAYOUT_ATOM(textTagName, "__moz_text")
LAYOUT_ATOM(processingInstructionTagName, "__moz_pi")
LAYOUT_ATOM(documentFragmentNodeName, "#document-fragment")
// Alphabetical list of frame types
LAYOUT_ATOM(areaFrame, "AreaFrame")
LAYOUT_ATOM(bcTableCellFrame, "BCTableCellFrame") // table cell in border collapsing model
LAYOUT_ATOM(blockFrame, "BlockFrame")
LAYOUT_ATOM(boxFrame, "BoxFrame")
LAYOUT_ATOM(brFrame, "BRFrame")
LAYOUT_ATOM(bulletFrame, "BulletFrame")
LAYOUT_ATOM(columnSetFrame, "ColumnSetFrame")
LAYOUT_ATOM(fieldSetFrame, "FieldSetFrame")
LAYOUT_ATOM(gfxButtonControlFrame, "gfxButtonControlFrame")
LAYOUT_ATOM(subDocumentFrame, "subDocumentFrame")
LAYOUT_ATOM(imageBoxFrame, "ImageBoxFrame")
LAYOUT_ATOM(imageFrame, "ImageFrame")
LAYOUT_ATOM(imageControlFrame, "ImageControlFrame")
LAYOUT_ATOM(inlineFrame, "InlineFrame")
LAYOUT_ATOM(legendFrame, "LegendFrame")
LAYOUT_ATOM(letterFrame, "LetterFrame")
LAYOUT_ATOM(lineFrame, "LineFrame")
LAYOUT_ATOM(listControlFrame,"ListControlFrame")
LAYOUT_ATOM(objectFrame, "ObjectFrame")
LAYOUT_ATOM(pageFrame, "PageFrame")
LAYOUT_ATOM(pageBreakFrame, "PageBreakFrame")
LAYOUT_ATOM(pageContentFrame, "PageContentFrame")
LAYOUT_ATOM(placeholderFrame, "PlaceholderFrame")
LAYOUT_ATOM(positionedInlineFrame, "PositionedInlineFrame")
LAYOUT_ATOM(canvasFrame, "CanvasFrame")
LAYOUT_ATOM(rootFrame, "RootFrame")
LAYOUT_ATOM(scrollFrame, "ScrollFrame")
LAYOUT_ATOM(sequenceFrame, "SequenceFrame")
LAYOUT_ATOM(tableCaptionFrame, "TableCaptionFrame")
LAYOUT_ATOM(tableCellFrame, "TableCellFrame")
LAYOUT_ATOM(tableColFrame, "TableColFrame")
LAYOUT_ATOM(tableColGroupFrame, "TableColGroupFrame")
LAYOUT_ATOM(tableFrame, "TableFrame")
LAYOUT_ATOM(tableOuterFrame, "TableOuterFrame")
LAYOUT_ATOM(tableRowGroupFrame, "TableRowGroupFrame")
LAYOUT_ATOM(tableRowFrame, "TableRowFrame")
LAYOUT_ATOM(textInputFrame,"TextInputFrame")
LAYOUT_ATOM(textFrame, "TextFrame")
LAYOUT_ATOM(viewportFrame, "ViewportFrame")
// Alphabetical list of frame property names
LAYOUT_ATOM(boxMetricsProperty, "BoxMetricsProperty") // nsBoxLayoutMetrics*
LAYOUT_ATOM(changeListProperty, "ChangeListProperty") // void*
LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty") // nsPoint*
LAYOUT_ATOM(computedOffsetProperty, "ComputedOffsetProperty") // nsPoint*
LAYOUT_ATOM(IBSplitSpecialPrevSibling, "IBSplitSpecialPrevSibling")// nsIFrame*
LAYOUT_ATOM(IBSplitSpecialSibling, "IBSplitSpecialSibling") // nsIFrame*
LAYOUT_ATOM(lineCursorProperty, "LineCursorProperty") // nsLineBox*
LAYOUT_ATOM(maxElementWidthProperty, "MaxElementWidthProperty") // nscoord*
LAYOUT_ATOM(overflowAreaProperty, "OverflowArea") // nsRect*
LAYOUT_ATOM(overflowProperty, "OverflowProperty") // list of nsIFrame*
LAYOUT_ATOM(overflowLinesProperty, "OverflowLinesProperty") // list of nsLineBox*
LAYOUT_ATOM(overflowOutOfFlowsProperty, "OverflowOutOfFlowsProperty") // nsFrameList*
LAYOUT_ATOM(overflowPlaceholdersProperty, "OverflowPlaceholdersProperty") // nsPlaceholder*
LAYOUT_ATOM(rowUnpaginatedHeightProperty, "RowUnpaginatedHeightProperty") // nscoord*
LAYOUT_ATOM(spaceManagerProperty, "SpaceManagerProperty") // the space manager for a block
LAYOUT_ATOM(tableBCProperty, "TableBCProperty") // table border collapsing info (e.g. damage area, table border widths)
LAYOUT_ATOM(viewProperty, "ViewProperty")
// Alphabetical list of event handler names
LAYOUT_ATOM(onabort, "onabort")
LAYOUT_ATOM(onbeforeunload, "onbeforeunload")
LAYOUT_ATOM(onblur, "onblur")
LAYOUT_ATOM(onbroadcast, "onbroadcast")
LAYOUT_ATOM(onchange, "onchange")
LAYOUT_ATOM(onclick, "onclick")
LAYOUT_ATOM(onclose, "onclose")
LAYOUT_ATOM(oncommand, "oncommand")
LAYOUT_ATOM(oncommandupdate, "oncommandupdate")
LAYOUT_ATOM(oncontextmenu, "oncontextmenu")
LAYOUT_ATOM(onDOMActivate, "onDOMActivate")
LAYOUT_ATOM(onDOMFocusIn, "onDOMFocusIn")
LAYOUT_ATOM(onDOMFocusOut, "onDOMFocusOut")
LAYOUT_ATOM(ondblclick, "ondblclick")
LAYOUT_ATOM(ondragdrop, "ondragdrop")
LAYOUT_ATOM(ondragenter, "ondragenter")
LAYOUT_ATOM(ondragexit, "ondragexit")
LAYOUT_ATOM(ondraggesture, "ondraggesture")
LAYOUT_ATOM(ondragover, "ondragover")
LAYOUT_ATOM(onerror, "onerror")
LAYOUT_ATOM(onfocus, "onfocus")
LAYOUT_ATOM(oninput, "oninput")
LAYOUT_ATOM(onkeydown, "onkeydown")
LAYOUT_ATOM(onkeypress, "onkeypress")
LAYOUT_ATOM(onkeyup, "onkeyup")
LAYOUT_ATOM(onload, "onload")
LAYOUT_ATOM(onmousedown, "onmousedown")
LAYOUT_ATOM(onmousemove, "onmousemove")
LAYOUT_ATOM(onmouseout, "onmouseout")
LAYOUT_ATOM(onmouseover, "onmouseover")
LAYOUT_ATOM(onmouseup, "onmouseup")
LAYOUT_ATOM(onpaint, "onpaint")
LAYOUT_ATOM(onpopuphidden, "onpopuphidden")
LAYOUT_ATOM(onpopuphiding, "onpopuphiding")
LAYOUT_ATOM(onpopupshowing, "onpopupshowing")
LAYOUT_ATOM(onpopupshown, "onpopupshown")
LAYOUT_ATOM(onreset, "onreset")
LAYOUT_ATOM(onresize, "onresize")
LAYOUT_ATOM(onscroll, "onscroll")
LAYOUT_ATOM(onselect, "onselect")
LAYOUT_ATOM(onsubmit, "onsubmit")
LAYOUT_ATOM(onunload, "onunload")
// scrolling
LAYOUT_ATOM(onoverflow, "onoverflow")
LAYOUT_ATOM(onunderflow, "onunderflow")
LAYOUT_ATOM(onoverflowchanged, "onoverflowchanged")
// mutation events
LAYOUT_ATOM(onDOMSubtreeModified, "onDOMSubtreeModified")
LAYOUT_ATOM(onDOMNodeInserted, "onDOMNodeInserted")
LAYOUT_ATOM(onDOMNodeRemoved, "onDOMNodeRemoved")
LAYOUT_ATOM(onDOMNodeRemovedFromDocument, "onDOMNodeRemovedFromDocument")
LAYOUT_ATOM(onDOMNodeInsertedIntoDocument, "onDOMNodeInsertedIntoDocument")
LAYOUT_ATOM(onDOMAttrModified, "onDOMAttrModified")
LAYOUT_ATOM(onDOMCharacterDataModified, "onDOMCharacterDataModified")
// Alphabetical list of languages for lang-specific transforms
LAYOUT_ATOM(Japanese, "ja")
LAYOUT_ATOM(Chinese, "zh-CN")
LAYOUT_ATOM(Taiwanese, "zh-TW")
LAYOUT_ATOM(HongKongChinese, "zh-HK")
LAYOUT_ATOM(Unicode, "x-unicode")
// other
LAYOUT_ATOM(wildcard, "*")
LAYOUT_ATOM(mozdirty, "_moz_dirty")
LAYOUT_ATOM(stylesheet, "stylesheet")
LAYOUT_ATOM(transform, "transform")
LAYOUT_ATOM(show, "show")
LAYOUT_ATOM(actuate, "actuate")
LAYOUT_ATOM(autoAtom, "auto")
LAYOUT_ATOM(none, "none")
LAYOUT_ATOM(normal, "normal")
LAYOUT_ATOM(transparent, "transparent")
LAYOUT_ATOM(directionalFrame, "DirectionalFrame")
LAYOUT_ATOM(baseLevel, "BaseLevel") // PRUint8
LAYOUT_ATOM(embeddingLevel, "EmbeddingLevel") // PRUint8
LAYOUT_ATOM(endsInDiacritic, "EndsInDiacritic") // PRUint32
LAYOUT_ATOM(nextBidi, "NextBidi") // nsIFrame*
LAYOUT_ATOM(charType, "charType") // PRUint8
#ifdef DEBUG
// Alphabetical list of atoms used by debugging code
LAYOUT_ATOM(cellMap, "TableCellMap")
LAYOUT_ATOM(imageMap, "ImageMap")
LAYOUT_ATOM(lineBoxBig, "LineBox:inline,big")
LAYOUT_ATOM(lineBoxBlockBig, "LineBox:block,big")
LAYOUT_ATOM(lineBoxBlockSmall, "LineBox:block,small")
LAYOUT_ATOM(lineBoxFloats, "LineBoxFloats")
LAYOUT_ATOM(lineBoxSmall, "LineBox:inline,small")
LAYOUT_ATOM(spaceManager, "SpaceManager")
LAYOUT_ATOM(tableColCache, "TableColumnCache")
LAYOUT_ATOM(tableStrategy, "TableLayoutStrategy")
LAYOUT_ATOM(textRun, "TextRun")
LAYOUT_ATOM(xml_document_entities, "XMLDocumentEntities")
LAYOUT_ATOM(xml_document_notations, "XMLDocumentNotations")
#endif

View File

@@ -1,58 +0,0 @@
/* -*- 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
* 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 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 "nsLayoutAtoms.h"
#include "nsStaticAtom.h"
#include "nsMemory.h"
// define storage for all atoms
#define LAYOUT_ATOM(_name, _value) nsIAtom* nsLayoutAtoms::_name;
#include "nsLayoutAtomList.h"
#undef LAYOUT_ATOM
static const nsStaticAtom LayoutAtoms_info[] = {
#define LAYOUT_ATOM(name_, value_) { value_, &nsLayoutAtoms::name_ },
#include "nsLayoutAtomList.h"
#undef LAYOUT_ATOM
};
void nsLayoutAtoms::AddRefAtoms()
{
NS_RegisterStaticAtoms(LayoutAtoms_info,
NS_ARRAY_LENGTH(LayoutAtoms_info));
}

View File

@@ -1,71 +0,0 @@
/* -*- 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
* 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 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 nsLayoutAtoms_h___
#define nsLayoutAtoms_h___
#include "nsIAtom.h"
/**
* This class wraps up the creation (and destruction) of the standard
* set of atoms used during layout processing. These objects
* are created when the first presentation context is created and they
* are destroyed when the last presentation context object is destroyed.
*/
class nsLayoutAtoms {
public:
static void AddRefAtoms();
/* Declare all atoms
The atom names and values are stored in nsLayoutAtomList.h and
are brought to you by the magic of C preprocessing
Add new atoms to nsLayoutAtomList and all support logic will be auto-generated
*/
#define LAYOUT_ATOM(_name, _value) static nsIAtom* _name;
#include "nsLayoutAtomList.h"
#undef LAYOUT_ATOM
};
static inline PRBool IS_TABLE_CELL(nsIAtom* frameType) {
return nsLayoutAtoms::tableCellFrame == frameType ||
nsLayoutAtoms::bcTableCellFrame == frameType;
}
#endif /* nsLayoutAtoms_h___ */

View File

@@ -1,144 +0,0 @@
/* -*- 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 Communicator client 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):
*
* 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 "nsILayoutDebugger.h"
#include "nsIFrame.h"
#include "nsIFrameDebug.h"
#ifdef NS_DEBUG
class nsLayoutDebugger : public nsILayoutDebugger {
public:
nsLayoutDebugger();
virtual ~nsLayoutDebugger();
NS_DECL_ISUPPORTS
NS_IMETHOD SetShowFrameBorders(PRBool aEnable);
NS_IMETHOD GetShowFrameBorders(PRBool* aResult);
NS_IMETHOD SetShowEventTargetFrameBorder(PRBool aEnable);
NS_IMETHOD GetShowEventTargetFrameBorder(PRBool* aResult);
NS_IMETHOD GetContentSize(nsIDocument* aDocument,
PRInt32* aSizeInBytesResult);
NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
PRInt32* aSizeInBytesResult);
NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
PRInt32* aSizeInBytesResult);
};
nsresult
NS_NewLayoutDebugger(nsILayoutDebugger** aResult)
{
NS_PRECONDITION(aResult, "null OUT ptr");
if (!aResult) {
return NS_ERROR_NULL_POINTER;
}
nsLayoutDebugger* it = new nsLayoutDebugger();
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(NS_GET_IID(nsILayoutDebugger), (void**)aResult);
}
nsLayoutDebugger::nsLayoutDebugger()
{
}
nsLayoutDebugger::~nsLayoutDebugger()
{
}
NS_IMPL_ISUPPORTS1(nsLayoutDebugger, nsILayoutDebugger)
NS_IMETHODIMP
nsLayoutDebugger::SetShowFrameBorders(PRBool aEnable)
{
nsIFrameDebug::ShowFrameBorders(aEnable);
return NS_OK;
}
NS_IMETHODIMP
nsLayoutDebugger::GetShowFrameBorders(PRBool* aResult)
{
*aResult = nsIFrameDebug::GetShowFrameBorders();
return NS_OK;
}
NS_IMETHODIMP
nsLayoutDebugger::SetShowEventTargetFrameBorder(PRBool aEnable)
{
nsIFrameDebug::ShowEventTargetFrameBorder(aEnable);
return NS_OK;
}
NS_IMETHODIMP
nsLayoutDebugger::GetShowEventTargetFrameBorder(PRBool* aResult)
{
*aResult = nsIFrameDebug::GetShowEventTargetFrameBorder();
return NS_OK;
}
NS_IMETHODIMP
nsLayoutDebugger::GetContentSize(nsIDocument* aDocument,
PRInt32* aSizeInBytesResult)
{
*aSizeInBytesResult = 0;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsLayoutDebugger::GetFrameSize(nsIPresShell* aPresentation,
PRInt32* aSizeInBytesResult)
{
*aSizeInBytesResult = 0;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsLayoutDebugger::GetStyleSize(nsIPresShell* aPresentation,
PRInt32* aSizeInBytesResult)
{
*aSizeInBytesResult = 0;
return NS_ERROR_FAILURE;
}
#endif

View File

@@ -1,65 +0,0 @@
/* -*- 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonas Sicking <jonas@sicking.cc> (original author)
*
* 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 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 nsLayoutErrors_h___
#define nsLayoutErrors_h___
/** Error codes for nsITableLayout */
#define NS_TABLELAYOUT_CELL_NOT_FOUND \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 0)
/** Error codes for nsFrame::GetNextPrevLineFromeBlockFrame */
#define NS_POSITION_BEFORE_TABLE \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 3)
/** Error code to return from nsIFrame::Init() if the frame got
replaced by alt text or something like that **/
#define NS_ERROR_FRAME_REPLACED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LAYOUT, 4)
/** Error codes for nsIPresState::GetProperty() */
/** Returned if the property exists */
#define NS_STATE_PROPERTY_EXISTS NS_OK
/** Returned if the property does not exist */
#define NS_STATE_PROPERTY_NOT_THERE \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 5)
#endif // nsLayoutErrors_h___

View File

@@ -1,144 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.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 ***** */
#include "nsILayoutHistoryState.h"
#include "nsWeakReference.h"
#include "nsHashtable.h"
class nsLayoutHistoryState : public nsILayoutHistoryState,
public nsSupportsWeakReference
{
public:
nsLayoutHistoryState();
virtual ~nsLayoutHistoryState();
NS_DECL_ISUPPORTS
// nsILayoutHistoryState
NS_IMETHOD AddState(const nsCString& aKey, nsIPresState* aState);
NS_IMETHOD GetState(const nsCString& aKey, nsIPresState** aState);
NS_IMETHOD RemoveState(const nsCString& aKey);
private:
nsSupportsHashtable mStates;
};
nsresult
NS_NewLayoutHistoryState(nsILayoutHistoryState** aState)
{
NS_ENSURE_ARG_POINTER(aState);
if (! aState)
return NS_ERROR_NULL_POINTER;
nsLayoutHistoryState *state = new nsLayoutHistoryState();
if (!state)
return NS_ERROR_OUT_OF_MEMORY;
*aState = NS_STATIC_CAST(nsILayoutHistoryState *, state);
NS_ADDREF(*aState);
return NS_OK;
}
nsLayoutHistoryState::nsLayoutHistoryState()
{
}
nsLayoutHistoryState::~nsLayoutHistoryState()
{
}
NS_IMPL_ISUPPORTS2(nsLayoutHistoryState,
nsILayoutHistoryState,
nsISupportsWeakReference)
NS_IMETHODIMP
nsLayoutHistoryState::AddState(const nsCString& aStateKey,
nsIPresState* aState)
{
nsCStringKey key(aStateKey);
/*
* nsSupportsHashtable::Put() returns false when no object was
* replaced when inserting the new one, true if one was.
*/
#ifdef DEBUG_pollmann
PRBool replaced =
#endif
mStates.Put (&key, aState);
#ifdef DEBUG_pollmann
NS_ASSERTION(!replaced,
"nsLayoutHistoryState::AddState OOPS!. There was already a state in the hash table for the key\n");
#endif
return NS_OK;
}
NS_IMETHODIMP
nsLayoutHistoryState::GetState(const nsCString& aKey,
nsIPresState** aState)
{
nsresult rv = NS_OK;
nsCStringKey key(aKey);
nsISupports *state = nsnull;
state = mStates.Get(&key);
if (state) {
*aState = (nsIPresState *)state;
}
else {
#if 0
printf("nsLayoutHistoryState::GetState, ERROR getting History state for the key\n");
#endif
*aState = nsnull;
rv = NS_OK;
}
return rv;
}
NS_IMETHODIMP
nsLayoutHistoryState::RemoveState(const nsCString& aKey)
{
nsresult rv = NS_OK;
nsCStringKey key(aKey);
mStates.Remove(&key);
return rv;
}

View File

@@ -1,498 +0,0 @@
/* -*- 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
* 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 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 "nsLayoutUtils.h"
#include "nsIFrame.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "nsFrameList.h"
#include "nsLayoutAtoms.h"
#include "nsIAtom.h"
#include "nsCSSPseudoElements.h"
#include "nsIView.h"
#include "nsIScrollableView.h"
#include "nsPlaceholderFrame.h"
#include "nsIScrollableFrame.h"
/**
* A namespace class for static layout utilities.
*/
/**
* GetFirstChildFrame returns the first "real" child frame of a
* given frame. It will descend down into pseudo-frames (unless the
* pseudo-frame is the :before generated frame).
* @param aPresContext the prescontext
* @param aFrame the frame
* @param aFrame the frame's content node
*/
static nsIFrame*
GetFirstChildFrame(nsPresContext* aPresContext,
nsIFrame* aFrame,
nsIContent* aContent)
{
NS_PRECONDITION(aFrame, "NULL frame pointer");
// Get the first child frame
nsIFrame* childFrame = aFrame->GetFirstChild(nsnull);
// If the child frame is a pseudo-frame, then return its first child.
// Note that the frame we create for the generated content is also a
// pseudo-frame and so don't drill down in that case
if (childFrame &&
childFrame->IsPseudoFrame(aContent) &&
!childFrame->IsGeneratedContentFrame()) {
return GetFirstChildFrame(aPresContext, childFrame, aContent);
}
return childFrame;
}
/**
* GetLastChildFrame returns the last "real" child frame of a
* given frame. It will descend down into pseudo-frames (unless the
* pseudo-frame is the :after generated frame).
* @param aPresContext the prescontext
* @param aFrame the frame
* @param aFrame the frame's content node
*/
static nsIFrame*
GetLastChildFrame(nsPresContext* aPresContext,
nsIFrame* aFrame,
nsIContent* aContent)
{
NS_PRECONDITION(aFrame, "NULL frame pointer");
// Get the last in flow frame
nsIFrame* lastInFlow = aFrame->GetLastInFlow();
// Get the last child frame
nsIFrame* firstChildFrame = lastInFlow->GetFirstChild(nsnull);
if (firstChildFrame) {
nsFrameList frameList(firstChildFrame);
nsIFrame* lastChildFrame = frameList.LastChild();
NS_ASSERTION(lastChildFrame, "unexpected error");
// Get the frame's first-in-flow. This matters in case the frame has
// been continuted across multiple lines
lastChildFrame = lastChildFrame->GetFirstInFlow();
// If the last child frame is a pseudo-frame, then return its last child.
// Note that the frame we create for the generated content is also a
// pseudo-frame and so don't drill down in that case
if (lastChildFrame &&
lastChildFrame->IsPseudoFrame(aContent) &&
!lastChildFrame->IsGeneratedContentFrame()) {
return GetLastChildFrame(aPresContext, lastChildFrame, aContent);
}
return lastChildFrame;
}
return nsnull;
}
// static
nsIFrame*
nsLayoutUtils::GetBeforeFrame(nsIFrame* aFrame, nsPresContext* aPresContext)
{
NS_PRECONDITION(aFrame, "NULL frame pointer");
NS_ASSERTION(!aFrame->GetPrevInFlow(), "aFrame must be first-in-flow");
nsIFrame* firstFrame = GetFirstChildFrame(aPresContext, aFrame, aFrame->GetContent());
if (firstFrame && IsGeneratedContentFor(nsnull, firstFrame,
nsCSSPseudoElements::before)) {
return firstFrame;
}
return nsnull;
}
// static
nsIFrame*
nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame, nsPresContext* aPresContext)
{
NS_PRECONDITION(aFrame, "NULL frame pointer");
nsIFrame* lastFrame = GetLastChildFrame(aPresContext, aFrame, aFrame->GetContent());
if (lastFrame && IsGeneratedContentFor(nsnull, lastFrame,
nsCSSPseudoElements::after)) {
return lastFrame;
}
return nsnull;
}
// static
nsIFrame*
nsLayoutUtils::GetPageFrame(nsIFrame* aFrame)
{
for (nsIFrame* frame = aFrame; frame; frame = frame->GetParent()) {
if (frame->GetType() == nsLayoutAtoms::pageFrame) {
return frame;
}
}
return nsnull;
}
nsIFrame*
nsLayoutUtils::GetFloatFromPlaceholder(nsIFrame* aFrame) {
if (nsLayoutAtoms::placeholderFrame != aFrame->GetType()) {
return nsnull;
}
nsIFrame *outOfFlowFrame =
NS_STATIC_CAST(nsPlaceholderFrame*, aFrame)->GetOutOfFlowFrame();
// This is a hack.
if (outOfFlowFrame &&
!outOfFlowFrame->GetStyleDisplay()->IsAbsolutelyPositioned()) {
return outOfFlowFrame;
}
return nsnull;
}
// static
PRBool
nsLayoutUtils::IsGeneratedContentFor(nsIContent* aContent,
nsIFrame* aFrame,
nsIAtom* aPseudoElement)
{
NS_PRECONDITION(aFrame, "Must have a frame");
NS_PRECONDITION(aPseudoElement, "Must have a pseudo name");
if (!aFrame->IsGeneratedContentFrame()) {
return PR_FALSE;
}
if (aContent && aFrame->GetContent() != aContent) {
return PR_FALSE;
}
return aFrame->GetStyleContext()->GetPseudoType() == aPseudoElement;
}
// static
PRBool
nsLayoutUtils::IsProperAncestorFrame(nsIFrame* aAncestorFrame, nsIFrame* aFrame,
nsIFrame* aCommonAncestor)
{
if (aFrame == aCommonAncestor) {
return PR_FALSE;
}
nsIFrame* parentFrame = aFrame->GetParent();
while (parentFrame != aCommonAncestor) {
if (parentFrame == aAncestorFrame) {
return PR_TRUE;
}
parentFrame = parentFrame->GetParent();
}
return PR_FALSE;
}
// static
PRInt32
nsLayoutUtils::DoCompareTreePosition(nsIContent* aContent1,
nsIContent* aContent2,
PRInt32 aIf1Ancestor,
PRInt32 aIf2Ancestor,
nsIContent* aCommonAncestor)
{
NS_PRECONDITION(aContent1, "aContent1 must not be null");
NS_PRECONDITION(aContent2, "aContent2 must not be null");
nsAutoVoidArray content1Ancestors;
nsIContent* c1;
for (c1 = aContent1; c1 && c1 != aCommonAncestor; c1 = c1->GetParent()) {
content1Ancestors.AppendElement(c1);
}
if (!c1 && aCommonAncestor) {
// So, it turns out aCommonAncestor was not an ancestor of c1. Oops.
// Never mind. We can continue as if aCommonAncestor was null.
aCommonAncestor = nsnull;
}
nsAutoVoidArray content2Ancestors;
nsIContent* c2;
for (c2 = aContent2; c2 && c2 != aCommonAncestor; c2 = c2->GetParent()) {
content2Ancestors.AppendElement(c2);
}
if (!c2 && aCommonAncestor) {
// So, it turns out aCommonAncestor was not an ancestor of c2.
// We need to retry with no common ancestor hint.
return DoCompareTreePosition(aContent1, aContent2,
aIf1Ancestor, aIf2Ancestor, nsnull);
}
int last1 = content1Ancestors.Count() - 1;
int last2 = content2Ancestors.Count() - 1;
nsIContent* content1Ancestor = nsnull;
nsIContent* content2Ancestor = nsnull;
while (last1 >= 0 && last2 >= 0
&& ((content1Ancestor = NS_STATIC_CAST(nsIContent*, content1Ancestors.ElementAt(last1)))
== (content2Ancestor = NS_STATIC_CAST(nsIContent*, content2Ancestors.ElementAt(last2))))) {
last1--;
last2--;
}
if (last1 < 0) {
if (last2 < 0) {
NS_ASSERTION(aContent1 == aContent2, "internal error?");
return 0;
} else {
// aContent1 is an ancestor of aContent2
return aIf1Ancestor;
}
} else {
if (last2 < 0) {
// aContent2 is an ancestor of aContent1
return aIf2Ancestor;
} else {
// content1Ancestor != content2Ancestor, so they must be siblings with the same parent
nsIContent* parent = content1Ancestor->GetParent();
NS_ASSERTION(parent, "no common ancestor at all???");
if (!parent) { // different documents??
return 0;
}
PRInt32 index1 = parent->IndexOf(content1Ancestor);
PRInt32 index2 = parent->IndexOf(content2Ancestor);
if (index1 < 0 || index2 < 0) {
// one of them must be anonymous; we can't determine the order
return 0;
}
return index1 - index2;
}
}
}
// static
nsIFrame* nsLayoutUtils::GetLastSibling(nsIFrame* aFrame) {
if (!aFrame) {
return nsnull;
}
nsIFrame* next;
while ((next = aFrame->GetNextSibling()) != nsnull) {
aFrame = next;
}
return aFrame;
}
// static
nsIView*
nsLayoutUtils::FindSiblingViewFor(nsIView* aParentView, nsIFrame* aFrame) {
nsIFrame* parentViewFrame = NS_STATIC_CAST(nsIFrame*, aParentView->GetClientData());
nsIContent* parentViewContent = parentViewFrame ? parentViewFrame->GetContent() : nsnull;
for (nsIView* insertBefore = aParentView->GetFirstChild(); insertBefore;
insertBefore = insertBefore->GetNextSibling()) {
nsIFrame* f = NS_STATIC_CAST(nsIFrame*, insertBefore->GetClientData());
if (!f) {
// this view could be some anonymous view attached to a meaningful parent
for (nsIView* searchView = insertBefore->GetParent(); searchView;
searchView = searchView->GetParent()) {
f = NS_STATIC_CAST(nsIFrame*, searchView->GetClientData());
if (f) {
break;
}
}
NS_ASSERTION(f, "Can't find a frame anywhere!");
}
if (f && CompareTreePosition(aFrame->GetContent(),
f->GetContent(), parentViewContent) > 0) {
// aFrame's content is after f's content, so put our view before f's view
return insertBefore;
}
}
return nsnull;
}
//static
nsIScrollableFrame*
nsLayoutUtils::GetScrollableFrameFor(nsIFrame *aScrolledFrame)
{
nsIFrame *frame = aScrolledFrame->GetParent();
if (!frame) {
return nsnull;
}
frame = frame->GetParent();
if (!frame) {
return nsnull;
}
nsIScrollableFrame *sf;
CallQueryInterface(frame, &sf);
return sf;
}
//static
nsIScrollableFrame*
nsLayoutUtils::GetScrollableFrameFor(nsIScrollableView *aScrollableView)
{
nsIFrame *frame = GetFrameFor(aScrollableView->View());
if (frame && ((frame = frame->GetParent()))) {
nsIScrollableFrame *sf;
CallQueryInterface(frame, &sf);
return sf;
}
return nsnull;
}
//static
nsPresContext::ScrollbarStyles
nsLayoutUtils::ScrollbarStylesOfView(nsIScrollableView *aScrollableView)
{
nsIScrollableFrame *sf = GetScrollableFrameFor(aScrollableView);
return sf ? sf->GetScrollbarStyles() :
nsPresContext::ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN,
NS_STYLE_OVERFLOW_HIDDEN);
}
// static
nsIScrollableView*
nsLayoutUtils::GetNearestScrollingView(nsIView* aView, Direction aDirection)
{
// If aDirection is eEither, find first view with a scrolllable frame.
// Otherwise, find the first view that has a scrollable frame whose
// ScrollbarStyles is not NS_STYLE_OVERFLOW_HIDDEN in aDirection
// and where there is something currently not visible
// that can be scrolled to in aDirection.
NS_ASSERTION(aView, "GetNearestScrollingView expects a non-null view");
nsIScrollableView* scrollableView = nsnull;
for (; aView; aView = aView->GetParent()) {
scrollableView = aView->ToScrollableView();
if (scrollableView) {
nsPresContext::ScrollbarStyles ss =
nsLayoutUtils::ScrollbarStylesOfView(scrollableView);
nsIScrollableFrame *scrollableFrame = GetScrollableFrameFor(scrollableView);
// NS_ASSERTION(scrollableFrame, "Must have scrollable frame for view!");
if (!scrollableFrame) {
// XXX Once bug 260652 is fixed we should get scrollable frames for HTML
// frames and can uncomment the above scrollableFrame assertion instead
// of using this if condition.
break; // If scrollableView but not scrollable Frame, on an HTML <frame>
}
nsMargin margin = scrollableFrame->GetActualScrollbarSizes();
// Get size of total scrollable area
nscoord totalWidth, totalHeight;
scrollableView->GetContainerSize(&totalWidth, &totalHeight);
// Get size of currently visible area
nsSize visibleSize = GetFrameFor(aView)->GetSize();
// aDirection can be eHorizontal, eVertical, or eEither
// If scrolling in a specific direction, require visible scrollbars or
// something to scroll to in that direction.
if (aDirection != eHorizontal &&
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN &&
(aDirection == eEither || totalHeight > visibleSize.height || margin.right))
break;
if (aDirection != eVertical &&
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN &&
(aDirection == eEither || totalWidth > visibleSize.width || margin.bottom))
break;
}
}
return scrollableView;
}
// Combine aNewBreakType with aOrigBreakType, but limit the break types
// to NS_STYLE_CLEAR_LEFT, RIGHT, LEFT_AND_RIGHT.
PRUint8
nsLayoutUtils::CombineBreakType(PRUint8 aOrigBreakType,
PRUint8 aNewBreakType)
{
PRUint8 breakType = aOrigBreakType;
switch(breakType) {
case NS_STYLE_CLEAR_LEFT:
if ((NS_STYLE_CLEAR_RIGHT == aNewBreakType) ||
(NS_STYLE_CLEAR_LEFT_AND_RIGHT == aNewBreakType)) {
breakType = NS_STYLE_CLEAR_LEFT_AND_RIGHT;
}
break;
case NS_STYLE_CLEAR_RIGHT:
if ((NS_STYLE_CLEAR_LEFT == aNewBreakType) ||
(NS_STYLE_CLEAR_LEFT_AND_RIGHT == aNewBreakType)) {
breakType = NS_STYLE_CLEAR_LEFT_AND_RIGHT;
}
break;
case NS_STYLE_CLEAR_NONE:
if ((NS_STYLE_CLEAR_LEFT == aNewBreakType) ||
(NS_STYLE_CLEAR_RIGHT == aNewBreakType) ||
(NS_STYLE_CLEAR_LEFT_AND_RIGHT == aNewBreakType)) {
breakType = aNewBreakType;
}
}
return breakType;
}
// Mark the intrinsic widths as dirty on the frame, all of its ancestors,
// and all of its descendants.
/* static */ void
nsLayoutUtils::MarkIntrinsicWidthsDirty(nsIFrame* aFrame)
{
// Mark argument and all ancestors dirty
for (nsIFrame *a = aFrame; a; a = a->GetParent())
a->MarkIntrinsicWidthsDirty();
// Mark all descendants dirty (using an nsVoidArray stack rather than
// recursion).
nsVoidArray stack;
stack.AppendElement(aFrame);
while (stack.Count() != 0) {
nsIFrame *f =
NS_STATIC_CAST(nsIFrame*, stack.FastElementAt[stack.Count() - 1]);
stack.RemoveElementAt(stack.Count() - 1);
PRInt32 childListIndex = 0;
nsIAtom *childListName;
do {
childListName = f->GetAdditionalChildListName(childListIndex++);
for (nsIFrame *kid = f->GetFirstChild(childListName); kid;
kid = kid->GetNextSibling()) {
kid->MarkIntrinsicWidthsDirty();
stack.AppendElement(kid);
}
} while (childListName);
}
}

View File

@@ -1,251 +0,0 @@
/* -*- 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
* Boris Zbarsky <bzbarsky@mit.edu>.
* 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 ***** */
#ifndef nsLayoutUtils_h__
#define nsLayoutUtils_h__
class nsIFrame;
class nsPresContext;
class nsIContent;
class nsIAtom;
class nsIScrollableView;
class nsIScrollableFrame;
#include "prtypes.h"
#include "nsStyleContext.h"
#include "nsAutoPtr.h"
#include "nsStyleSet.h"
#include "nsIView.h"
/**
* nsLayoutUtils is a namespace class used for various helper
* functions that are useful in multiple places in layout. The goal
* is not to define multiple copies of the same static helper.
*/
class nsLayoutUtils
{
public:
/**
* GetBeforeFrame returns the :before frame of the given frame, if
* one exists. This is typically O(1). The frame passed in must be
* the first-in-flow.
*
* @param aFrame the frame whose :before is wanted
* @param aPresContext the prescontext
* @return the :before frame or nsnull if there isn't one
*/
static nsIFrame* GetBeforeFrame(nsIFrame* aFrame, nsPresContext* aPresContext);
/**
* GetAfterFrame returns the :after frame of the given frame, if one
* exists. This will walk the in-flow chain to the last-in-flow if
* needed. This function is typically O(N) in the number of child
* frames, following in-flows, etc.
*
* @param aFrame the frame whose :after is wanted
* @param aPresContext the prescontext
* @return the :after frame or nsnull if there isn't one
*/
static nsIFrame* GetAfterFrame(nsIFrame* aFrame, nsPresContext* aPresContext);
/**
* Given a frame, search up the frame tree until we find an
* ancestor "Page" frame, if any.
*
* @param the frame to start at
* @return a frame of type nsLayoutAtoms::pageFrame or nsnull if no
* such ancestor exists
*/
static nsIFrame* GetPageFrame(nsIFrame* aFrame);
/**
* IsGeneratedContentFor returns PR_TRUE if aFrame is generated
* content of type aPseudoElement for aContent
*
* @param aContent the content node we're looking at. If this is
* null, then we just assume that aFrame has the right content
* pointer.
* @param aFrame the frame we're looking at
* @param aPseudoElement the pseudo type we're interested in
* @return whether aFrame is the generated aPseudoElement frame for aContent
*/
static PRBool IsGeneratedContentFor(nsIContent* aContent, nsIFrame* aFrame,
nsIAtom* aPseudoElement);
/**
* CompareTreePosition determines whether aContent1 comes before or
* after aContent2 in a preorder traversal of the content tree.
*
* @param aCommonAncestor either null, or a common ancestor of
* aContent1 and aContent2. Actually this is
* only a hint; if it's not an ancestor of
* aContent1 or aContent2, this function will
* still work, but it will be slower than
* normal.
* @return < 0 if aContent1 is before aContent2
* > 0 if aContent1 is after aContent2,
* 0 otherwise (meaning they're the same, or they're in
* different documents)
*/
static PRInt32 CompareTreePosition(nsIContent* aContent1,
nsIContent* aContent2,
nsIContent* aCommonAncestor = nsnull)
{
return DoCompareTreePosition(aContent1, aContent2, -1, 1, aCommonAncestor);
}
/*
* More generic version of |CompareTreePosition|. |aIf1Ancestor|
* gives the value to return when 1 is an ancestor of 2, and likewise
* for |aIf2Ancestor|. Passing (-1, 1) gives preorder traversal
* order, and (1, -1) gives postorder traversal order.
*/
static PRInt32 DoCompareTreePosition(nsIContent* aContent1,
nsIContent* aContent2,
PRInt32 aIf1Ancestor,
PRInt32 aIf2Ancestor,
nsIContent* aCommonAncestor = nsnull);
/**
* GetLastSibling simply finds the last sibling of aFrame, or returns nsnull if
* aFrame is null.
*/
static nsIFrame* GetLastSibling(nsIFrame* aFrame);
/**
* FindSiblingViewFor locates the child of aParentView that aFrame's
* view should be inserted 'above' (i.e., before in sibling view
* order). This is the first child view of aParentView whose
* corresponding content is before aFrame's content (view siblings
* are in reverse content order).
*/
static nsIView* FindSiblingViewFor(nsIView* aParentView, nsIFrame* aFrame);
/**
* IsProperAncestorFrame checks whether aAncestorFrame is an ancestor
* of aFrame and not equal to aFrame.
* @param aCommonAncestor nsnull, or a common ancestor of aFrame and
* aAncestorFrame. If non-null, this can bound the search and speed up
* the function
*/
static PRBool IsProperAncestorFrame(nsIFrame* aAncestorFrame, nsIFrame* aFrame,
nsIFrame* aCommonAncestor = nsnull);
/**
* GetFrameFor returns the root frame for a view
* @param aView is the view to return the root frame for
* @return the root frame for the view
*/
static nsIFrame* GetFrameFor(nsIView *aView)
{ return NS_STATIC_CAST(nsIFrame*, aView->GetClientData()); }
/**
* GetScrollableFrameFor returns the scrollable frame for a scrollable view
* @param aScrollableView is the scrollable view to return the
* scrollable frame for.
* @return the scrollable frame for the scrollable view
*/
static nsIScrollableFrame* GetScrollableFrameFor(nsIScrollableView *aScrollableView);
/**
* GetScrollableFrameFor returns the scrollable frame for a scrolled frame
*/
static nsIScrollableFrame* GetScrollableFrameFor(nsIFrame *aScrolledFrame);
static nsPresContext::ScrollbarStyles
ScrollbarStylesOfView(nsIScrollableView *aScrollableView);
/**
* GetNearestScrollingView locates the first ancestor of aView (or
* aView itself) that is scrollable. It does *not* count an
* 'overflow' style of 'hidden' as scrollable, even though a scrolling
* view is present. Thus, the direction of the scroll is needed as
* an argument.
*
* @param aView the view we're looking at
* @param aDirection Whether it's for horizontal or vertical scrolling.
* @return the nearest scrollable view or nsnull if not found
*/
enum Direction { eHorizontal, eVertical, eEither };
static nsIScrollableView* GetNearestScrollingView(nsIView* aView,
Direction aDirection);
/**
* HasPseudoStyle returns PR_TRUE if aContent (whose primary style
* context is aStyleContext) has the aPseudoElement pseudo-style
* attached to it; returns PR_FALSE otherwise.
*
* @param aContent the content node we're looking at
* @param aStyleContext aContent's style context
* @param aPseudoElement the name of the pseudo style we care about
* @param aPresContext the presentation context
* @return whether aContent has aPseudoElement style attached to it
*/
static PRBool HasPseudoStyle(nsIContent* aContent,
nsStyleContext* aStyleContext,
nsIAtom* aPseudoElement,
nsPresContext* aPresContext)
{
NS_PRECONDITION(aPresContext, "Must have a prescontext");
NS_PRECONDITION(aPseudoElement, "Must have a pseudo name");
nsRefPtr<nsStyleContext> pseudoContext;
if (aContent) {
pseudoContext = aPresContext->StyleSet()->
ProbePseudoStyleFor(aContent, aPseudoElement, aStyleContext);
}
return pseudoContext != nsnull;
}
/**
* If this frame is a placeholder for a float, then return the float,
* otherwise return nsnull.
*/
static nsIFrame* GetFloatFromPlaceholder(nsIFrame* aPossiblePlaceholder);
// Combine aNewBreakType with aOrigBreakType, but limit the break types
// to NS_STYLE_CLEAR_LEFT, RIGHT, LEFT_AND_RIGHT.
static PRUint8 CombineBreakType(PRUint8 aOrigBreakType, PRUint8 aNewBreakType);
/**
* Mark the intrinsic widths as dirty on the frame, all of its ancestors,
* and all of its descendants.
*/
static void MarkIntrinsicWidthsDirty(nsIFrame* aFrame);
};
#endif // nsLayoutUtils_h__

File diff suppressed because it is too large Load Diff

View File

@@ -1,751 +0,0 @@
/* -*- 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
* 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 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 nsPresContext_h___
#define nsPresContext_h___
#include "nsISupports.h"
#include "nsColor.h"
#include "nsCoord.h"
#include "nsAString.h"
#include "nsCompatibility.h"
#include "nsCOMPtr.h"
#include "nsIPresShell.h"
#include "nsRect.h"
#include "nsIDeviceContext.h"
#include "nsHashtable.h"
#include "nsFont.h"
#include "nsIWeakReference.h"
#include "nsITheme.h"
#include "nsILanguageAtomService.h"
#include "nsIObserver.h"
#include "nsCRT.h"
#include "nsIPrintSettings.h"
#include "nsPropertyTable.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
struct nsRect;
class imgIRequest;
class nsIContent;
class nsIDocument;
class nsIFontMetrics;
class nsIFrame;
class nsFrameManager;
class nsIImage;
class nsILinkHandler;
class nsStyleContext;
class nsIAtom;
class nsIEventStateManager;
class nsIURI;
class nsILookAndFeel;
class nsICSSPseudoComparator;
class nsIAtom;
struct nsStyleStruct;
struct nsStyleBackground;
#ifdef MOZ_REFLOW_PERF
class nsIRenderingContext;
#endif
#define NS_IPRESCONTEXT_IID \
{ 0x96e4bc06, 0x8e72, 0x4941, \
{0xa6, 0x6c, 0x70, 0xee, 0x7d, 0x1b, 0x58, 0x21} }
enum nsWidgetType {
eWidgetType_Button = 1,
eWidgetType_Checkbox = 2,
eWidgetType_Radio = 3,
eWidgetType_Text = 4
};
enum nsLanguageSpecificTransformType {
eLanguageSpecificTransformType_Unknown = -1,
eLanguageSpecificTransformType_None = 0,
eLanguageSpecificTransformType_Japanese
};
// supported values for cached bool types
const PRUint32 kPresContext_UseDocumentColors = 0x01;
const PRUint32 kPresContext_UseDocumentFonts = 0x02;
const PRUint32 kPresContext_UnderlineLinks = 0x03;
// supported values for cached integer pref types
const PRUint32 kPresContext_MinimumFontSize = 0x01;
// IDs for the default variable and fixed fonts (not to be changed, see nsFont.h)
// To be used for Get/SetDefaultFont(). The other IDs in nsFont.h are also supported.
const PRUint8 kPresContext_DefaultVariableFont_ID = 0x00; // kGenericFont_moz_variable
const PRUint8 kPresContext_DefaultFixedFont_ID = 0x01; // kGenericFont_moz_fixed
// An interface for presentation contexts. Presentation contexts are
// objects that provide an outer context for a presentation shell.
// hack to make egcs / gcc 2.95.2 happy
class nsPresContext_base : public nsIObserver
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESCONTEXT_IID)
};
class nsPresContext : public nsPresContext_base {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
enum nsPresContextType {
eContext_Galley, // unpaginated screen presentation
eContext_PrintPreview, // paginated screen presentation
eContext_Print // paginated printer presentation
};
nsPresContext(nsPresContextType aType) NS_HIDDEN;
/**
* Initialize the presentation context from a particular device.
*/
NS_HIDDEN_(nsresult) Init(nsIDeviceContext* aDeviceContext);
/**
* Set the presentation shell that this context is bound to.
* A presentation context may only be bound to a single shell.
*/
NS_HIDDEN_(void) SetShell(nsIPresShell* aShell);
NS_HIDDEN_(nsPresContextType) Type() const { return mType; }
/**
* Get the PresentationShell that this context is bound to.
*/
nsIPresShell* PresShell() const
{
NS_ASSERTION(mShell, "Null pres shell");
return mShell;
}
nsIPresShell* GetPresShell() const { return mShell; }
nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); }
nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); }
#ifdef _IMPL_NS_LAYOUT
nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); }
nsFrameManager* FrameManager()
{ return GetPresShell()->FrameManager(); }
#endif
/**
* Access compatibility mode for this context
*
* All users must explicitly set the compatibility mode rather than
* relying on a default.
*/
nsCompatibility CompatibilityMode() const { return mCompatibilityMode; }
NS_HIDDEN_(void) SetCompatibilityMode(nsCompatibility aMode);
/**
* Access the image animation mode for this context
*/
PRUint16 ImageAnimationMode() const { return mImageAnimationMode; }
virtual NS_HIDDEN_(void) SetImageAnimationModeExternal(PRUint16 aMode);
NS_HIDDEN_(void) SetImageAnimationModeInternal(PRUint16 aMode);
#ifdef _IMPL_NS_LAYOUT
void SetImageAnimationMode(PRUint16 aMode)
{ SetImageAnimationModeInternal(aMode); }
#else
void SetImageAnimationMode(PRUint16 aMode)
{ SetImageAnimationModeExternal(aMode); }
#endif
/**
* Get cached look and feel service. This is faster than obtaining it
* through the service manager.
*/
nsILookAndFeel* LookAndFeel() { return mLookAndFeel; }
/**
* Get medium of presentation
*/
nsIAtom* Medium() { return mMedium; }
/**
* Clear style data from the root frame downwards, and reflow.
*/
NS_HIDDEN_(void) ClearStyleDataAndReflow();
void* AllocateFromShell(size_t aSize)
{
if (mShell)
return mShell->AllocateFrame(aSize);
return nsnull;
}
void FreeToShell(size_t aSize, void* aFreeChunk)
{
if (mShell)
mShell->FreeFrame(aSize, aFreeChunk);
}
/**
* Get the font metrics for a given font.
*/
virtual NS_HIDDEN_(already_AddRefed<nsIFontMetrics>)
GetMetricsForExternal(const nsFont& aFont);
NS_HIDDEN_(already_AddRefed<nsIFontMetrics>)
GetMetricsForInternal(const nsFont& aFont);
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
{ return GetMetricsForInternal(aFont); }
#else
already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
{ return GetMetricsForExternal(aFont); }
#endif
/**
* Get the default font correponding to the given ID. This object is
* read-only, you must copy the font to modify it.
*/
virtual NS_HIDDEN_(const nsFont*) GetDefaultFontExternal(PRUint8 aFontID) const;
NS_HIDDEN_(const nsFont*) GetDefaultFontInternal(PRUint8 aFontID) const;
#ifdef _IMPL_NS_LAYOUT
const nsFont* GetDefaultFont(PRUint8 aFontID) const
{ return GetDefaultFontInternal(aFontID); }
#else
const nsFont* GetDefaultFont(PRUint8 aFontID) const
{ return GetDefaultFontExternal(aFontID); }
#endif
/** Get a cached boolean pref, by its type */
// * - initially created for bugs 31816, 20760, 22963
PRBool GetCachedBoolPref(PRUint32 aPrefType) const
{
// If called with a constant parameter, the compiler should optimize
// this switch statement away.
switch (aPrefType) {
case kPresContext_UseDocumentFonts:
return mUseDocumentFonts;
case kPresContext_UseDocumentColors:
return mUseDocumentColors;
case kPresContext_UnderlineLinks:
return mUnderlineLinks;
default:
NS_ERROR("Invalid arg passed to GetCachedBoolPref");
}
return PR_FALSE;
}
/** Get a cached integer pref, by its type */
// * - initially created for bugs 30910, 61883, 74186, 84398
PRInt32 GetCachedIntPref(PRUint32 aPrefType) const
{
// If called with a constant parameter, the compiler should optimize
// this switch statement away.
switch (aPrefType) {
case kPresContext_MinimumFontSize:
return mMinimumFontSize;
default:
NS_ERROR("invalid arg passed to GetCachedIntPref");
}
return PR_FALSE;
}
/**
* Access Nav's magic font scaler value
*/
PRInt32 FontScaler() const { return mFontScaler; }
/**
* Get the default colors
*/
const nscolor DefaultColor() const { return mDefaultColor; }
const nscolor DefaultBackgroundColor() const { return mBackgroundColor; }
const nscolor DefaultLinkColor() const { return mLinkColor; }
const nscolor DefaultActiveLinkColor() const { return mActiveLinkColor; }
const nscolor DefaultVisitedLinkColor() const { return mVisitedLinkColor; }
const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; }
const nscolor FocusTextColor() const { return mFocusTextColor; }
PRBool GetUseFocusColors() const { return mUseFocusColors; }
PRUint8 FocusRingWidth() const { return mFocusRingWidth; }
PRBool GetFocusRingOnAnything() const { return mFocusRingOnAnything; }
/**
* Load an image for the target frame. This call can be made
* repeated with only a single image ever being loaded. When the
* image's data is ready for rendering the target frame's Paint()
* method will be invoked (via the ViewManager) so that the
* appropriate damage repair is done.
*/
NS_HIDDEN_(imgIRequest*) LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame);
/**
* This method is called when a frame is being destroyed to
* ensure that the image load gets disassociated from the prescontext
*/
NS_HIDDEN_(void) StopImagesFor(nsIFrame* aTargetFrame);
NS_HIDDEN_(void) SetContainer(nsISupports* aContainer);
virtual NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerExternal();
NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerInternal();
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsISupports> GetContainer()
{ return GetContainerInternal(); }
#else
already_AddRefed<nsISupports> GetContainer()
{ return GetContainerExternal(); }
#endif
// XXX this are going to be replaced with set/get container
void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; }
nsILinkHandler* GetLinkHandler() { return mLinkHandler; }
/**
* Get the visible area associated with this presentation context.
* This is the size of the visiable area that is used for
* presenting the document. The returned value is in the standard
* nscoord units (as scaled by the device context).
*/
nsRect GetVisibleArea() { return mVisibleArea; }
/**
* Set the currently visible area. The units for r are standard
* nscoord units (as scaled by the device context).
*/
void SetVisibleArea(const nsRect& r) { mVisibleArea = r; }
/**
* Return true if this presentation context is a paginated
* context.
*/
PRBool IsPaginated() const { return mPaginated; }
/**
* Sets whether the presentation context can scroll for a paginated
* context.
*/
NS_HIDDEN_(void) SetPaginatedScrolling(PRBool aResult);
/**
* Return true if this presentation context can scroll for paginated
* context.
*/
PRBool HasPaginatedScrolling() const { return mCanPaginatedScroll; }
/**
* Gets the rect for the page dimensions,
* this includes X,Y Offsets which are used to determine
* the inclusion of margins
* Also, indicates whether the size has been overridden
*
* @param aActualRect returns the size of the actual device/surface
* @param aRect returns the adjusted size
*/
NS_HIDDEN_(void) GetPageDim(nsRect* aActualRect, nsRect* aAdjRect);
/**
* Sets the "adjusted" rect for the page Dimimensions,
* this includes X,Y Offsets which are used to determine
* the inclusion of margins
*
* @param aRect returns the adjusted size
*/
NS_HIDDEN_(void) SetPageDim(const nsRect& aRect);
float PixelsToTwips() const { return mDeviceContext->DevUnitsToAppUnits(); }
float TwipsToPixels() const { return mDeviceContext->AppUnitsToDevUnits(); }
NS_HIDDEN_(float) TwipsToPixelsForFonts() const;
//XXX this is probably not an ideal name. MMP
/**
* Do pixels to twips conversion taking into account
* differing size of a "pixel" from device to device.
*/
NS_HIDDEN_(float) ScaledPixelsToTwips() const;
/* Convenience method for converting one pixel value to twips */
nscoord IntScaledPixelsToTwips(nscoord aPixels) const
{ return NSIntPixelsToTwips(aPixels, ScaledPixelsToTwips()); }
/* Set whether twip scaling is used */
void SetScalingOfTwips(PRBool aOn) { mDoScaledTwips = aOn; }
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
nsIEventStateManager* EventStateManager() { return mEventManager; }
nsIAtom* GetLangGroup() { return mLangGroup; }
/**
* Get the language-specific transform type for the current document.
* This tells us whether we need to perform special language-dependent
* transformations such as Unicode U+005C (backslash) to Japanese
* Yen Sign (Unicode U+00A5, JIS 0x5C).
*
* @param aType returns type, must be non-NULL
*/
nsLanguageSpecificTransformType LanguageSpecificTransformType() const
{
return mLanguageSpecificTransformType;
}
struct ScrollbarStyles {
// Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
// or NS_STYLE_OVERFLOW_AUTO.
PRUint8 mHorizontal, mVertical;
ScrollbarStyles(PRUint8 h, PRUint8 v) : mHorizontal(h), mVertical(v) {}
ScrollbarStyles() {}
};
void SetViewportOverflowOverride(PRUint8 aX, PRUint8 aY)
{
mViewportStyleOverflow.mHorizontal = aX;
mViewportStyleOverflow.mVertical = aY;
}
ScrollbarStyles GetViewportOverflowOverride()
{
return mViewportStyleOverflow;
}
/**
* Set and get methods for controling the background drawing
*/
PRBool GetBackgroundImageDraw() const { return mDrawImageBackground; }
void SetBackgroundImageDraw(PRBool aCanDraw)
{
NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false");
mDrawImageBackground = aCanDraw;
}
PRBool GetBackgroundColorDraw() const { return mDrawColorBackground; }
void SetBackgroundColorDraw(PRBool aCanDraw)
{
NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false");
mDrawColorBackground = aCanDraw;
}
#ifdef IBMBIDI
/**
* Check if bidi enabled (set depending on the presence of RTL
* characters or when default directionality is RTL).
* If enabled, we should apply the Unicode Bidi Algorithm
*
* @lina 07/12/2000
*/
virtual NS_HIDDEN_(PRBool) BidiEnabledExternal() const;
NS_HIDDEN_(PRBool) BidiEnabledInternal() const;
#ifdef _IMPL_NS_LAYOUT
PRBool BidiEnabled() const { return BidiEnabledInternal(); }
#else
PRBool BidiEnabled() const { return BidiEnabledExternal(); }
#endif
/**
* Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
*
* @lina 07/12/2000
*/
NS_HIDDEN_(void) SetBidiEnabled(PRBool aBidiEnabled) const;
/**
* Set visual or implicit mode into the pres context.
*
* Visual directionality is a presentation method that displays text
* as if it were a uni-directional, according to the primary display
* direction only.
*
* Implicit directionality is a presentation method in which the
* direction is determined by the Bidi algorithm according to the
* category of the characters and the category of the adjacent
* characters, and according to their primary direction.
*
* @lina 05/02/2000
*/
void SetVisualMode(PRBool aIsVisual)
{
NS_ASSERTION(!(aIsVisual & ~1), "Value must be true or false");
mIsVisual = aIsVisual;
}
/**
* Check whether the content should be treated as visual.
*
* @lina 05/02/2000
*/
PRBool IsVisualMode() const { return mIsVisual; }
//Mohamed
/**
* Get a Bidi presentation utilities object
*/
NS_HIDDEN_(nsBidiPresUtils*) GetBidiUtils();
/**
* Set the Bidi options for the presentation context
*/
NS_HIDDEN_(void) SetBidi(PRUint32 aBidiOptions,
PRBool aForceReflow = PR_FALSE);
/**
* Get the Bidi options for the presentation context
*/
NS_HIDDEN_(PRUint32) GetBidi() const { return mBidi; }
/**
* Set the Bidi capabilities of the system
* @param aIsBidi == TRUE if the system has the capability of reordering Bidi text
*/
void SetIsBidiSystem(PRBool aIsBidi)
{
NS_ASSERTION(!(aIsBidi & ~1), "Value must be true or false");
mIsBidiSystem = aIsBidi;
}
/**
* Get the Bidi capabilities of the system
* @return TRUE if the system has the capability of reordering Bidi text
*/
PRBool IsBidiSystem() const { return mIsBidiSystem; }
#endif // IBMBIDI
/**
* Render only Selection
*/
void SetIsRenderingOnlySelection(PRBool aResult)
{
NS_ASSERTION(!(aResult & ~1), "Value must be true or false");
mIsRenderingOnlySelection = aResult;
}
PRBool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; }
/*
* Obtain a native them for rendering our widgets (both form controls and html)
*/
NS_HIDDEN_(nsITheme*) GetTheme();
/*
* Notify the pres context that the theme has changed. An internal switch
* means it's one of our Mozilla themes that changed (e.g., Modern to Classic).
* Otherwise, the OS is telling us that the native theme for the platform
* has changed.
*/
NS_HIDDEN_(void) ThemeChanged();
/*
* Notify the pres context that a system color has changed
*/
NS_HIDDEN_(void) SysColorChanged();
/** Printing methods below should only be used for Medium() == print **/
NS_HIDDEN_(void) SetPrintSettings(nsIPrintSettings *aPrintSettings);
nsIPrintSettings* GetPrintSettings() { return mPrintSettings; }
/* Accessor for table of frame properties */
nsPropertyTable* PropertyTable() { return &mPropertyTable; }
#ifdef MOZ_REFLOW_PERF
NS_HIDDEN_(void) CountReflows(const char * aName,
PRUint32 aType, nsIFrame * aFrame);
NS_HIDDEN_(void) PaintCount(const char * aName,
nsIRenderingContext* aRendingContext,
nsIFrame * aFrame, PRUint32 aColor);
#endif
/**
* This table maps border-width enums 'thin', 'medium', 'thick'
* to actual nscoord values.
*/
const nscoord* GetBorderWidthTable() { return mBorderWidthTable; }
protected:
NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
NS_HIDDEN_(void) GetDocumentColorPreferences();
NS_HIDDEN_(void) PreferenceChanged(const char* aPrefName);
static NS_HIDDEN_(int) PR_CALLBACK PrefChangedCallback(const char*, void*);
NS_HIDDEN_(void) GetUserPreferences();
NS_HIDDEN_(void) GetFontPreferences();
NS_HIDDEN_(void) UpdateCharSet(const nsAFlatCString& aCharSet);
// IMPORTANT: The ownership implicit in the following member variables
// has been explicitly checked. If you add any members to this class,
// please make the ownership explicit (pinkerton, scc).
nsPresContextType mType;
nsIPresShell* mShell; // [WEAK]
nsIDeviceContext* mDeviceContext; // [STRONG] could be weak, but
// better safe than sorry.
// Cannot reintroduce cycles
// since there is no dependency
// from gfx back to layout.
nsIEventStateManager* mEventManager; // [STRONG]
nsILookAndFeel* mLookAndFeel; // [STRONG]
nsIAtom* mMedium; // initialized by subclass ctors;
// weak pointer to static atom
nsILinkHandler* mLinkHandler; // [WEAK]
nsIAtom* mLangGroup; // [STRONG]
nsSupportsHashtable mImageLoaders;
nsWeakPtr mContainer;
#ifdef IBMBIDI
nsBidiPresUtils* mBidiUtils;
#endif
nsCOMPtr<nsITheme> mTheme;
nsCOMPtr<nsILanguageAtomService> mLangService;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
nsPropertyTable mPropertyTable;
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
PRInt32 mFontScaler;
nscoord mMinimumFontSize;
nsRect mVisibleArea;
nsRect mPageDim;
nscolor mDefaultColor;
nscolor mBackgroundColor;
nscolor mLinkColor;
nscolor mActiveLinkColor;
nscolor mVisitedLinkColor;
nscolor mFocusBackgroundColor;
nscolor mFocusTextColor;
ScrollbarStyles mViewportStyleOverflow;
PRUint8 mFocusRingWidth;
nsCompatibility mCompatibilityMode;
PRUint16 mImageAnimationMode;
PRUint16 mImageAnimationModePref;
nsFont mDefaultVariableFont;
nsFont mDefaultFixedFont;
nsFont mDefaultSerifFont;
nsFont mDefaultSansSerifFont;
nsFont mDefaultMonospaceFont;
nsFont mDefaultCursiveFont;
nsFont mDefaultFantasyFont;
nscoord mBorderWidthTable[3];
unsigned mUseDocumentFonts : 1;
unsigned mUseDocumentColors : 1;
unsigned mUnderlineLinks : 1;
unsigned mUseFocusColors : 1;
unsigned mFocusRingOnAnything : 1;
unsigned mDrawImageBackground : 1;
unsigned mDrawColorBackground : 1;
unsigned mNeverAnimate : 1;
unsigned mIsRenderingOnlySelection : 1;
unsigned mNoTheme : 1;
unsigned mPaginated : 1;
unsigned mCanPaginatedScroll : 1;
unsigned mDoScaledTwips : 1;
unsigned mEnableJapaneseTransform : 1;
#ifdef IBMBIDI
unsigned mIsVisual : 1;
unsigned mIsBidiSystem : 1;
PRUint32 mBidi;
#endif
#ifdef DEBUG
PRBool mInitialized;
#endif
private:
~nsPresContext() NS_HIDDEN;
// these are private, use the list in nsFont.h if you want a public list
enum {
eDefaultFont_Variable,
eDefaultFont_Fixed,
eDefaultFont_Serif,
eDefaultFont_SansSerif,
eDefaultFont_Monospace,
eDefaultFont_Cursive,
eDefaultFont_Fantasy,
eDefaultFont_COUNT
};
};
// Bit values for StartLoadImage's aImageStatus
#define NS_LOAD_IMAGE_STATUS_ERROR 0x1
#define NS_LOAD_IMAGE_STATUS_SIZE 0x2
#define NS_LOAD_IMAGE_STATUS_BITS 0x4
#ifdef MOZ_REFLOW_PERF
#define DO_GLOBAL_REFLOW_COUNT(_name, _type) \
aPresContext->CountReflows((_name), (_type), (nsIFrame*)this);
#else
#define DO_GLOBAL_REFLOW_COUNT(_name, _type)
#endif // MOZ_REFLOW_PERF
#if defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend) \
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, 0); \
}
#define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just) \
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, (_just)); \
}
#else
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend)
#define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just)
#endif // MOZ_REFLOW_PERF_DSP
#endif /* nsPresContext_h___ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,204 +0,0 @@
/* -*- 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
* 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 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 "nsCOMPtr.h"
#include "nsIPresState.h"
#include "nsHashtable.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsLayoutErrors.h"
class nsPresState: public nsIPresState
{
NS_DECL_ISUPPORTS
NS_IMETHOD GetStatePropertyAsSupports(const nsAString& aName, nsISupports** aResult);
NS_IMETHOD SetStatePropertyAsSupports(const nsAString& aName, nsISupports* aValue);
NS_IMETHOD GetStateProperty(const nsAString& aProperty, nsAString& aResult);
NS_IMETHOD SetStateProperty(const nsAString& aProperty, const nsAString& aValue);
NS_IMETHOD RemoveStateProperty(const nsAString& aProperty);
public:
nsPresState();
virtual ~nsPresState();
// Static members
// Internal member functions
protected:
// MEMBER VARIABLES
protected:
// A string table that holds property/value pairs.
nsSupportsHashtable* mPropertyTable;
};
// Static initialization
// Implementation /////////////////////////////////////////////////////////////////
// Implement our nsISupports methods
NS_IMPL_ISUPPORTS1(nsPresState, nsIPresState)
// Constructors/Destructors
nsPresState::nsPresState(void)
:mPropertyTable(nsnull)
{
}
nsPresState::~nsPresState(void)
{
delete mPropertyTable;
}
// nsIPresState Interface ////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsPresState::GetStateProperty(const nsAString& aName,
nsAString& aResult)
{
nsresult rv = NS_STATE_PROPERTY_NOT_THERE;
aResult.Truncate();
// Retrieve from hashtable.
if (mPropertyTable) {
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
nsCOMPtr<nsISupportsCString> supportsStr =
dont_AddRef(NS_STATIC_CAST(nsISupportsCString*,
mPropertyTable->Get(&key)));
if (supportsStr) {
nsCAutoString data;
supportsStr->GetData(data);
CopyUTF8toUTF16(data, aResult);
rv = NS_STATE_PROPERTY_EXISTS;
}
}
return rv;
}
NS_IMETHODIMP
nsPresState::SetStateProperty(const nsAString& aName, const nsAString& aValue)
{
if (!mPropertyTable) {
mPropertyTable = new nsSupportsHashtable(8);
NS_ENSURE_TRUE(mPropertyTable, NS_ERROR_OUT_OF_MEMORY);
}
// Add to hashtable
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
nsCOMPtr<nsISupportsCString> supportsStr(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY);
supportsStr->SetData(NS_ConvertUCS2toUTF8(aValue));
mPropertyTable->Put(&key, supportsStr);
return NS_OK;
}
NS_IMETHODIMP
nsPresState::RemoveStateProperty(const nsAString& aName)
{
if (!mPropertyTable)
return NS_OK;
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
mPropertyTable->Remove(&key);
return NS_OK;
}
NS_IMETHODIMP
nsPresState::GetStatePropertyAsSupports(const nsAString& aName, nsISupports** aResult)
{
// Retrieve from hashtable.
nsCOMPtr<nsISupports> supp;
if (mPropertyTable) {
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
supp = dont_AddRef(NS_STATIC_CAST(nsISupports*, mPropertyTable->Get(&key)));
}
*aResult = supp;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsPresState::SetStatePropertyAsSupports(const nsAString& aName, nsISupports* aValue)
{
if (!mPropertyTable) {
mPropertyTable = new nsSupportsHashtable(8);
NS_ENSURE_TRUE(mPropertyTable, NS_ERROR_OUT_OF_MEMORY);
}
// Add to hashtable
const nsPromiseFlatString& flatString = PromiseFlatString(aName);
nsStringKey key(flatString);
mPropertyTable->Put(&key, aValue);
return NS_OK;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewPresState(nsIPresState** aResult)
{
*aResult = new nsPresState;
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}

View File

@@ -1,279 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:cindent:ts=2:et:sw=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
* Esben Mose Hansen.
*
* Contributor(s):
* Esben Mose Hansen <esben@oek.dk> (original author)
* L. David Baron <dbaron@dbaron.org>
*
* 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 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 "nsQuoteList.h"
#include "nsIDOMCharacterData.h"
#include "nsCSSPseudoElements.h"
#include "nsLayoutUtils.h"
#include "nsReadableUtils.h"
const nsString*
nsQuoteListNode::Text()
{
NS_ASSERTION(mType == eStyleContentType_OpenQuote ||
mType == eStyleContentType_CloseQuote,
"should only be called when mText should be non-null");
const nsStyleQuotes* styleQuotes = mPseudoFrame->GetStyleQuotes();
PRInt32 quotesCount = styleQuotes->QuotesCount(); // 0 if 'quotes:none'
PRInt32 quoteDepth = Depth();
// Reuse the last pair when the depth is greater than the number of
// pairs of quotes. (Also make 'quotes: none' and close-quote from
// a depth of 0 equivalent for the next test.)
if (quoteDepth >= quotesCount)
quoteDepth = quotesCount - 1;
const nsString *result;
if (quoteDepth == -1) {
// close-quote from a depth of 0 or 'quotes: none' (we want a node
// with the empty string so dynamic changes are easier to handle)
result = & EmptyString();
} else {
result = eStyleContentType_OpenQuote == mType
? styleQuotes->OpenQuoteAt(quoteDepth)
: styleQuotes->CloseQuoteAt(quoteDepth);
}
return result;
}
void
nsQuoteList::Calc(nsQuoteListNode* aNode)
{
if (aNode == mFirstNode) {
aNode->mDepthBefore = 0;
} else {
aNode->mDepthBefore = Prev(aNode)->DepthAfter();
}
}
void
nsQuoteList::RecalcAll()
{
nsQuoteListNode *node = mFirstNode;
if (!node)
return;
do {
PRInt32 oldDepth = node->mDepthBefore;
Calc(node);
if (node->mDepthBefore != oldDepth && node->mText)
node->mText->SetData(*node->Text());
// Next node
node = Next(node);
} while (node != mFirstNode);
}
#ifdef DEBUG
void
nsQuoteList::PrintChain()
{
printf("Chain: \n");
if (!mFirstNode) {
return;
}
nsQuoteListNode* node = mFirstNode;
do {
printf(" %p %d - ", node, node->mDepthBefore);
switch(node->mType) {
case (eStyleContentType_OpenQuote):
printf("open");
break;
case (eStyleContentType_NoOpenQuote):
printf("noOpen");
break;
case (eStyleContentType_CloseQuote):
printf("close");
break;
case (eStyleContentType_NoCloseQuote):
printf("noClose");
break;
default:
printf("unknown!!!");
}
printf(" %d - %d,", node->Depth(), node->DepthAfter());
if (node->mText) {
nsAutoString data;
node->mText->GetData(data);
printf(" \"%s\",", NS_ConvertUCS2toUTF8(data).get());
}
printf("\n");
node = Next(node);
} while (node != mFirstNode);
}
#endif
void
nsQuoteList::Clear()
{
//Delete entire list
if (!mFirstNode)
return;
for (nsQuoteListNode *node = Next(mFirstNode); node != mFirstNode;
node = Next(mFirstNode))
{
Remove(node);
delete node;
}
delete mFirstNode;
mFirstNode = nsnull;
mSize = 0;
}
PRBool
nsQuoteList::DestroyNodesFor(nsIFrame* aFrame)
{
if (!mFirstNode)
return PR_FALSE; // list empty
nsQuoteListNode* node;
PRBool destroyed = PR_FALSE;
while (mFirstNode->mPseudoFrame == aFrame) {
destroyed = PR_TRUE;
node = Next(mFirstNode);
if (node == mFirstNode) { // Last link
mFirstNode = nsnull;
delete node;
return PR_TRUE;
}
else {
Remove(mFirstNode);
delete mFirstNode;
mFirstNode = node;
}
}
node = Next(mFirstNode);
while (node != mFirstNode) {
if (node->mPseudoFrame == aFrame) {
destroyed = PR_TRUE;
nsQuoteListNode *nextNode = Next(node);
Remove(node);
delete node;
node = nextNode;
} else {
node = Next(node);
}
}
return destroyed;
}
// return -1 for ::before and +1 for ::after
inline PRBool PseudoCompareType(nsIFrame *aFrame)
{
nsIAtom *pseudo = aFrame->GetStyleContext()->GetPseudoType();
NS_ASSERTION(pseudo == nsCSSPseudoElements::before ||
pseudo == nsCSSPseudoElements::after,
"not a pseudo-element frame");
return pseudo == nsCSSPseudoElements::before ? -1 : 1;
}
static PRBool NodeAfter(nsQuoteListNode* aNode1, nsQuoteListNode* aNode2)
{
nsIFrame *frame1 = aNode1->mPseudoFrame;
nsIFrame *frame2 = aNode2->mPseudoFrame;
if (frame1 == frame2) {
NS_ASSERTION(aNode2->mContentIndex != aNode1->mContentIndex, "identical");
return aNode1->mContentIndex > aNode2->mContentIndex;
}
PRInt32 pseudoType1 = PseudoCompareType(frame1);
PRInt32 pseudoType2 = PseudoCompareType(frame2);
nsIContent *content1 = frame1->GetContent();
nsIContent *content2 = frame2->GetContent();
if (content1 == content2) {
NS_ASSERTION(pseudoType1 != pseudoType2, "identical");
return pseudoType1 == 1;
}
PRInt32 cmp = nsLayoutUtils::DoCompareTreePosition(content1, content2,
pseudoType1, -pseudoType2);
NS_ASSERTION(cmp != 0, "same content, different frames");
return cmp > 0;
}
void
nsQuoteList::Insert(nsQuoteListNode* aNode)
{
if (mFirstNode) {
// Check for append.
if (NodeAfter(aNode, Prev(mFirstNode))) {
PR_INSERT_BEFORE(aNode, mFirstNode);
}
else {
// Binary search.
// the range of indices at which |aNode| could end up.
PRUint32 first = 0, last = mSize - 1;
// A cursor to avoid walking more than the length of the list.
nsQuoteListNode *curNode = Prev(mFirstNode);
PRUint32 curIndex = mSize - 1;
while (first != last) {
PRUint32 test = (first + last) / 2;
if (last == curIndex) {
for ( ; curIndex != test; --curIndex)
curNode = Prev(curNode);
} else {
for ( ; curIndex != test; ++curIndex)
curNode = Next(curNode);
}
if (NodeAfter(aNode, curNode)) {
first = test + 1;
// if we exit the loop, we need curNode to be right
++curIndex;
curNode = Next(curNode);
} else {
last = test;
}
}
PR_INSERT_BEFORE(aNode, curNode);
if (curNode == mFirstNode) {
mFirstNode = aNode;
}
}
}
else {
// initialize list with first node
PR_INIT_CLIST(aNode);
mFirstNode = aNode;
}
++mSize;
Calc(aNode);
}

View File

@@ -1,156 +0,0 @@
/* -*- 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
* Esben Mose Hansen.
*
* Contributor(s):
* Esben Mose Hansen <esben@oek.dk> (original author)
* L. David Baron <dbaron@dbaron.org>
*
* 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 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 nsQuoteList_h___
#define nsQuoteList_h___
#include "nsIFrame.h"
#include "nsStyleStruct.h"
#include "prclist.h"
#include "nsIDOMCharacterData.h"
#include "nsCSSPseudoElements.h"
struct nsQuoteListNode : public PRCList {
// open-quote, close-quote, no-open-quote, or no-close-quote
const nsStyleContentType mType;
// Quote depth before this quote, which is always non-negative.
PRInt32 mDepthBefore;
// Index within the list of things specified by the 'content' property,
// which is needed to do 'content: open-quote open-quote' correctly.
const PRUint32 mContentIndex;
// null for 'content:no-open-quote', 'content:no-close-quote'
nsCOMPtr<nsIDOMCharacterData> mText;
// The wrapper frame for all of the pseudo-element's content. This
// frame has useful style data and has the NS_FRAME_GENERATED_CONTENT
// bit set (so we use it to track removal).
nsIFrame* const mPseudoFrame;
nsQuoteListNode(nsStyleContentType& aType, nsIFrame* aPseudoFrame,
PRUint32 aContentIndex)
: mType(aType)
, mDepthBefore(0)
, mContentIndex(aContentIndex)
, mPseudoFrame(aPseudoFrame)
{
NS_ASSERTION(aType == eStyleContentType_OpenQuote ||
aType == eStyleContentType_CloseQuote ||
aType == eStyleContentType_NoOpenQuote ||
aType == eStyleContentType_NoCloseQuote,
"incorrect type");
NS_ASSERTION(aPseudoFrame->GetStateBits() & NS_FRAME_GENERATED_CONTENT,
"not generated content");
NS_ASSERTION(aPseudoFrame->GetStyleContext()->GetPseudoType() ==
nsCSSPseudoElements::before ||
aPseudoFrame->GetStyleContext()->GetPseudoType() ==
nsCSSPseudoElements::after,
"not :before/:after generated content");
NS_ASSERTION(aContentIndex <
aPseudoFrame->GetStyleContent()->ContentCount(),
"index out of range");
}
// is this 'open-quote' or 'no-open-quote'?
PRBool IsOpenQuote() {
return mType == eStyleContentType_OpenQuote ||
mType == eStyleContentType_NoOpenQuote;
}
// is this 'close-quote' or 'no-close-quote'?
PRBool IsCloseQuote() {
return !IsOpenQuote();
}
// is this 'open-quote' or 'close-quote'?
PRBool IsRealQuote() {
return mType == eStyleContentType_OpenQuote ||
mType == eStyleContentType_CloseQuote;
}
// is this 'no-open-quote' or 'no-close-quote'?
PRBool IsHiddenQuote() {
return !IsRealQuote();
}
// Depth of the quote for *this* node. Either non-negative or -1.
// -1 means this is a closing quote that tried to decrement the
// counter below zero (which means no quote should be rendered).
PRInt32 Depth() {
return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1;
}
// always non-negative
PRInt32 DepthAfter() {
return IsOpenQuote() ? mDepthBefore + 1
: (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
}
// The text that should be displayed for this quote.
const nsString* Text();
};
class nsQuoteList {
private:
nsQuoteListNode* mFirstNode;
PRUint32 mSize;
// assign the correct |mDepthBefore| value to a node that has been inserted
void Calc(nsQuoteListNode* aNode);
public:
nsQuoteList() : mFirstNode(nsnull), mSize(0) {}
~nsQuoteList() { Clear(); }
void Clear();
nsQuoteListNode* Next(nsQuoteListNode* aNode) {
return NS_STATIC_CAST(nsQuoteListNode*, PR_NEXT_LINK(aNode));
}
nsQuoteListNode* Prev(nsQuoteListNode* aNode) {
return NS_STATIC_CAST(nsQuoteListNode*, PR_PREV_LINK(aNode));
}
void Insert(nsQuoteListNode* aNode);
// returns whether any nodes have been destroyed
PRBool DestroyNodesFor(nsIFrame* aFrame); //destroy all nodes with aFrame as parent
void Remove(nsQuoteListNode* aNode) { PR_REMOVE_LINK(aNode); mSize--; }
void RecalcAll();
PRBool IsLast(nsQuoteListNode* aNode) { return (Next(aNode) == mFirstNode); }
#ifdef DEBUG
void PrintChain();
#endif
};
#endif /* nsQuoteList_h___ */

View File

@@ -1,146 +0,0 @@
/* -*- 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
* 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 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 "nsStyleChangeList.h"
#include "nsStyleConsts.h"
#include "nsIFrame.h"
#include "nsIContent.h"
#include "nsCRT.h"
static const PRUint32 kGrowArrayBy = 10;
MOZ_DECL_CTOR_COUNTER(nsStyleChangeList)
nsStyleChangeList::nsStyleChangeList(void)
: mArray(mBuffer),
mArraySize(kStyleChangeBufferSize),
mCount(0)
{
MOZ_COUNT_CTOR(nsStyleChangeList);
}
nsStyleChangeList::~nsStyleChangeList(void)
{
MOZ_COUNT_DTOR(nsStyleChangeList);
Clear();
}
nsresult
nsStyleChangeList::ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, nsIContent*& aContent,
nsChangeHint& aHint) const
{
if ((0 <= aIndex) && (aIndex < mCount)) {
aFrame = mArray[aIndex].mFrame;
aContent = mArray[aIndex].mContent;
aHint = mArray[aIndex].mHint;
return NS_OK;
}
return NS_ERROR_ILLEGAL_VALUE;
}
nsresult
nsStyleChangeList::ChangeAt(PRInt32 aIndex, const nsStyleChangeData** aChangeData) const
{
if ((0 <= aIndex) && (aIndex < mCount)) {
*aChangeData = &mArray[aIndex];
return NS_OK;
}
return NS_ERROR_ILLEGAL_VALUE;
}
nsresult
nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint)
{
NS_ASSERTION(aFrame || (aHint & nsChangeHint_ReconstructFrame),
"must have frame");
NS_ASSERTION(aContent || !(aHint & nsChangeHint_ReconstructFrame),
"must have content");
if ((0 < mCount) && (aHint & nsChangeHint_ReconstructFrame)) { // filter out all other changes for same content
if (aContent) {
PRInt32 index = mCount;
while (0 < index--) {
if (aContent == mArray[index].mContent) { // remove this change
mCount--;
if (index < mCount) { // move later changes down
memcpy(&mArray[index], &mArray[index + 1],
(mCount - index) * sizeof(nsStyleChangeData));
}
}
}
}
}
PRInt32 last = mCount - 1;
if ((0 < mCount) && aFrame && (aFrame == mArray[last].mFrame)) { // same as last frame
NS_UpdateHint(mArray[last].mHint, aHint);
}
else {
if (mCount == mArraySize) {
PRInt32 newSize = mArraySize + kGrowArrayBy;
nsStyleChangeData* newArray = new nsStyleChangeData[newSize];
if (newArray) {
memcpy(newArray, mArray, mCount * sizeof(nsStyleChangeData));
if (mArray != mBuffer) {
delete [] mArray;
}
mArray = newArray;
mArraySize = newSize;
}
else {
return NS_ERROR_OUT_OF_MEMORY;
}
}
mArray[mCount].mFrame = aFrame;
mArray[mCount].mContent = aContent;
mArray[mCount].mHint = aHint;
mCount++;
}
return NS_OK;
}
void
nsStyleChangeList::Clear()
{
if (mArray != mBuffer) {
delete [] mArray;
mArray = mBuffer;
mArraySize = kStyleChangeBufferSize;
}
mCount = 0;
}

View File

@@ -1,84 +0,0 @@
/* -*- 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
* 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 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 nsStyleChangeList_h___
#define nsStyleChangeList_h___
#include "nsError.h"
#include "nsChangeHint.h"
class nsIFrame;
class nsIContent;
// XXX would all platforms support putting this inside the list?
struct nsStyleChangeData {
nsIFrame* mFrame;
nsIContent* mContent;
nsChangeHint mHint;
};
static const PRUint32 kStyleChangeBufferSize = 10;
class nsStyleChangeList {
public:
nsStyleChangeList(void);
~nsStyleChangeList(void);
PRInt32 Count(void) const {
return mCount;
}
nsresult ChangeAt(PRInt32 aIndex, nsIFrame*& aFrame, nsIContent*& aContent,
nsChangeHint& aHint) const;
nsresult ChangeAt(PRInt32 aIndex, const nsStyleChangeData** aChangeData) const;
nsresult AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint);
void Clear(void);
protected:
nsStyleChangeList& operator=(const nsStyleChangeList& aCopy);
PRBool operator==(const nsStyleChangeList& aOther) const;
nsStyleChangeData* mArray;
PRInt32 mArraySize;
PRInt32 mCount;
nsStyleChangeData mBuffer[kStyleChangeBufferSize];
};
#endif /* nsStyleChangeList_h___ */

View File

@@ -1,700 +0,0 @@
/* -*- 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
* 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 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 nsStyleConsts_h___
#define nsStyleConsts_h___
#include "nsFont.h"
// XXX fold this into nsStyleContext and group by nsStyleXXX struct
// Indices into border/padding/margin arrays
#define NS_SIDE_TOP 0
#define NS_SIDE_RIGHT 1
#define NS_SIDE_BOTTOM 2
#define NS_SIDE_LEFT 3
#define NS_FOR_CSS_SIDES(var_) for (PRInt32 var_ = 0; var_ < 4; ++var_)
// {margin,padding}-{left,right}-{ltr,rtl}-source
#define NS_BOXPROP_SOURCE_PHYSICAL 0
#define NS_BOXPROP_SOURCE_LOGICAL 1
// box-sizing
#define NS_STYLE_BOX_SIZING_CONTENT 0
#define NS_STYLE_BOX_SIZING_PADDING 1
#define NS_STYLE_BOX_SIZING_BORDER 2
// float-edge
#define NS_STYLE_FLOAT_EDGE_CONTENT 0
#define NS_STYLE_FLOAT_EDGE_PADDING 1
#define NS_STYLE_FLOAT_EDGE_BORDER 2
#define NS_STYLE_FLOAT_EDGE_MARGIN 3
// key-equivalent
#define NS_STYLE_KEY_EQUIVALENT_NONE 0
// user-focus
#define NS_STYLE_USER_FOCUS_NONE 0
#define NS_STYLE_USER_FOCUS_IGNORE 1
#define NS_STYLE_USER_FOCUS_NORMAL 2
#define NS_STYLE_USER_FOCUS_SELECT_ALL 3
#define NS_STYLE_USER_FOCUS_SELECT_BEFORE 4
#define NS_STYLE_USER_FOCUS_SELECT_AFTER 5
#define NS_STYLE_USER_FOCUS_SELECT_SAME 6
#define NS_STYLE_USER_FOCUS_SELECT_MENU 7
// user-select
#define NS_STYLE_USER_SELECT_NONE 0
#define NS_STYLE_USER_SELECT_TEXT 1
#define NS_STYLE_USER_SELECT_ELEMENT 2
#define NS_STYLE_USER_SELECT_ELEMENTS 3
#define NS_STYLE_USER_SELECT_ALL 4
#define NS_STYLE_USER_SELECT_TOGGLE 5
#define NS_STYLE_USER_SELECT_TRI_STATE 6
#define NS_STYLE_USER_SELECT_AUTO 7 // internal value - please use nsFrame::IsSelectable()
#define NS_STYLE_USER_SELECT_MOZ_ALL 8 // force selection of all children - bug 48096
// user-input
#define NS_STYLE_USER_INPUT_NONE 0
#define NS_STYLE_USER_INPUT_ENABLED 1
#define NS_STYLE_USER_INPUT_DISABLED 2
#define NS_STYLE_USER_INPUT_AUTO 3
// user-modify
#define NS_STYLE_USER_MODIFY_READ_ONLY 0
#define NS_STYLE_USER_MODIFY_READ_WRITE 1
#define NS_STYLE_USER_MODIFY_WRITE_ONLY 2
// box-align
#define NS_STYLE_BOX_ALIGN_STRETCH 0
#define NS_STYLE_BOX_ALIGN_START 1
#define NS_STYLE_BOX_ALIGN_CENTER 2
#define NS_STYLE_BOX_ALIGN_BASELINE 3
#define NS_STYLE_BOX_ALIGN_END 4
// box-pack
#define NS_STYLE_BOX_PACK_START 0
#define NS_STYLE_BOX_PACK_CENTER 1
#define NS_STYLE_BOX_PACK_END 2
#define NS_STYLE_BOX_PACK_JUSTIFY 3
// box-direction
#define NS_STYLE_BOX_DIRECTION_NORMAL 0
#define NS_STYLE_BOX_DIRECTION_REVERSE 1
// box-orient
#define NS_STYLE_BOX_ORIENT_HORIZONTAL 0
#define NS_STYLE_BOX_ORIENT_VERTICAL 1
// Azimuth - See nsStyleAural
#define NS_STYLE_AZIMUTH_LEFT_SIDE 0x00
#define NS_STYLE_AZIMUTH_FAR_LEFT 0x01
#define NS_STYLE_AZIMUTH_LEFT 0x02
#define NS_STYLE_AZIMUTH_CENTER_LEFT 0x03
#define NS_STYLE_AZIMUTH_CENTER 0x04
#define NS_STYLE_AZIMUTH_CENTER_RIGHT 0x05
#define NS_STYLE_AZIMUTH_RIGHT 0x06
#define NS_STYLE_AZIMUTH_FAR_RIGHT 0x07
#define NS_STYLE_AZIMUTH_RIGHT_SIDE 0x08
#define NS_STYLE_AZIMUTH_BEHIND 0x80 // bits
#define NS_STYLE_AZIMUTH_LEFTWARDS 0x10 // bits
#define NS_STYLE_AZIMUTH_RIGHTWARDS 0x20 // bits
// See nsStyleAural
#define NS_STYLE_ELEVATION_BELOW 1
#define NS_STYLE_ELEVATION_LEVEL 2
#define NS_STYLE_ELEVATION_ABOVE 3
#define NS_STYLE_ELEVATION_HIGHER 4
#define NS_STYLE_ELEVATION_LOWER 5
// See nsStyleAural
#define NS_STYLE_PITCH_X_LOW 1
#define NS_STYLE_PITCH_LOW 2
#define NS_STYLE_PITCH_MEDIUM 3
#define NS_STYLE_PITCH_HIGH 4
#define NS_STYLE_PITCH_X_HIGH 5
// See nsStyleAural
#define NS_STYLE_SPEAK_NONE 0
#define NS_STYLE_SPEAK_NORMAL 1
#define NS_STYLE_SPEAK_SPELL_OUT 2
// See nsStyleAural
#define NS_STYLE_SPEAK_HEADER_ONCE 0
#define NS_STYLE_SPEAK_HEADER_ALWAYS 1
// See nsStyleAural
#define NS_STYLE_SPEAK_NUMERAL_DIGITS 0
#define NS_STYLE_SPEAK_NUMERAL_CONTINUOUS 1
// See nsStyleAural
#define NS_STYLE_SPEAK_PUNCTUATION_NONE 0
#define NS_STYLE_SPEAK_PUNCTUATION_CODE 1
// See nsStyleAural
#define NS_STYLE_SPEECH_RATE_X_SLOW 0
#define NS_STYLE_SPEECH_RATE_SLOW 1
#define NS_STYLE_SPEECH_RATE_MEDIUM 2
#define NS_STYLE_SPEECH_RATE_FAST 3
#define NS_STYLE_SPEECH_RATE_X_FAST 4
#define NS_STYLE_SPEECH_RATE_FASTER 10
#define NS_STYLE_SPEECH_RATE_SLOWER 11
// See nsStyleAural
#define NS_STYLE_VOLUME_SILENT 0
#define NS_STYLE_VOLUME_X_SOFT 1
#define NS_STYLE_VOLUME_SOFT 2
#define NS_STYLE_VOLUME_MEDIUM 3
#define NS_STYLE_VOLUME_LOUD 4
#define NS_STYLE_VOLUME_X_LOUD 5
// See nsStyleColor
#define NS_STYLE_COLOR_TRANSPARENT 0
#define NS_STYLE_COLOR_INVERT 1
#define NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR 2
// See nsStyleColor
#define NS_COLOR_MOZ_HYPERLINKTEXT -1
#define NS_COLOR_MOZ_VISITEDHYPERLINKTEXT -2
#define NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT -3
#define NS_COLOR_CURRENTCOLOR -4
// See nsStyleBackground
#define NS_STYLE_BG_COLOR_TRANSPARENT 0x01
#define NS_STYLE_BG_IMAGE_NONE 0x02
#define NS_STYLE_BG_X_POSITION_PERCENT 0x04
#define NS_STYLE_BG_X_POSITION_LENGTH 0x08
#define NS_STYLE_BG_Y_POSITION_PERCENT 0x10
#define NS_STYLE_BG_Y_POSITION_LENGTH 0x20
// See nsStyleBackground
#define NS_STYLE_BG_ATTACHMENT_SCROLL 0
#define NS_STYLE_BG_ATTACHMENT_FIXED 1
// See nsStyleBackground
#define NS_STYLE_BG_CLIP_BORDER 0
#define NS_STYLE_BG_CLIP_PADDING 1
// See nsStyleBackground
#define NS_STYLE_BG_INLINE_POLICY_EACH_BOX 0
#define NS_STYLE_BG_INLINE_POLICY_CONTINUOUS 1
#define NS_STYLE_BG_INLINE_POLICY_BOUNDING_BOX 2
// See nsStyleBackground
#define NS_STYLE_BG_ORIGIN_BORDER 0
#define NS_STYLE_BG_ORIGIN_PADDING 1
#define NS_STYLE_BG_ORIGIN_CONTENT 2
// See nsStyleBackground
#define NS_STYLE_BG_REPEAT_OFF 0x00
#define NS_STYLE_BG_REPEAT_X 0x01
#define NS_STYLE_BG_REPEAT_Y 0x02
#define NS_STYLE_BG_REPEAT_XY 0x03
// See nsStyleTable
#define NS_STYLE_BORDER_COLLAPSE 0
#define NS_STYLE_BORDER_SEPARATE 1
// See nsStyleBorder mBorder enum values
#define NS_STYLE_BORDER_WIDTH_THIN 0
#define NS_STYLE_BORDER_WIDTH_MEDIUM 1
#define NS_STYLE_BORDER_WIDTH_THICK 2
// XXX chopping block #define NS_STYLE_BORDER_WIDTH_LENGTH_VALUE 3
// See nsStyleBorder mBorderStyle
#define NS_STYLE_BORDER_STYLE_NONE 0
#define NS_STYLE_BORDER_STYLE_GROOVE 1
#define NS_STYLE_BORDER_STYLE_RIDGE 2
#define NS_STYLE_BORDER_STYLE_DOTTED 3
#define NS_STYLE_BORDER_STYLE_DASHED 4
#define NS_STYLE_BORDER_STYLE_SOLID 5
#define NS_STYLE_BORDER_STYLE_DOUBLE 6
#define NS_STYLE_BORDER_STYLE_INSET 7
#define NS_STYLE_BORDER_STYLE_OUTSET 8
#define NS_STYLE_BORDER_STYLE_HIDDEN 9
#define NS_STYLE_BORDER_STYLE_BG_INSET 10
#define NS_STYLE_BORDER_STYLE_BG_OUTSET 11
#define NS_STYLE_BORDER_STYLE_BG_SOLID 12
// a bit ORed onto the style for table border collapsing indicating that the style was
// derived from a table with its rules attribute set
#define NS_STYLE_BORDER_STYLE_RULES_MARKER 0x10
// See nsStyleDisplay
#define NS_STYLE_CLEAR_NONE 0
#define NS_STYLE_CLEAR_LEFT 1
#define NS_STYLE_CLEAR_RIGHT 2
#define NS_STYLE_CLEAR_LEFT_AND_RIGHT 3
#define NS_STYLE_CLEAR_LINE 4
#define NS_STYLE_CLEAR_BLOCK 5
#define NS_STYLE_CLEAR_COLUMN 6
#define NS_STYLE_CLEAR_PAGE 7
#define NS_STYLE_CLEAR_LAST_VALUE NS_STYLE_CLEAR_PAGE
// See
#define NS_STYLE_CONTENT_OPEN_QUOTE 0
#define NS_STYLE_CONTENT_CLOSE_QUOTE 1
#define NS_STYLE_CONTENT_NO_OPEN_QUOTE 2
#define NS_STYLE_CONTENT_NO_CLOSE_QUOTE 3
// See nsStyleColor
#define NS_STYLE_CURSOR_AUTO 1
#define NS_STYLE_CURSOR_CROSSHAIR 2
#define NS_STYLE_CURSOR_DEFAULT 3 // ie: an arrow
#define NS_STYLE_CURSOR_POINTER 4 // for links
#define NS_STYLE_CURSOR_MOVE 5
#define NS_STYLE_CURSOR_E_RESIZE 6
#define NS_STYLE_CURSOR_NE_RESIZE 7
#define NS_STYLE_CURSOR_NW_RESIZE 8
#define NS_STYLE_CURSOR_N_RESIZE 9
#define NS_STYLE_CURSOR_SE_RESIZE 10
#define NS_STYLE_CURSOR_SW_RESIZE 11
#define NS_STYLE_CURSOR_S_RESIZE 12
#define NS_STYLE_CURSOR_W_RESIZE 13
#define NS_STYLE_CURSOR_TEXT 14 // ie: i-beam
#define NS_STYLE_CURSOR_WAIT 15
#define NS_STYLE_CURSOR_HELP 16
#define NS_STYLE_CURSOR_COPY 17 // CSS3
#define NS_STYLE_CURSOR_ALIAS 18
#define NS_STYLE_CURSOR_CONTEXT_MENU 19
#define NS_STYLE_CURSOR_CELL 20
#define NS_STYLE_CURSOR_GRAB 21
#define NS_STYLE_CURSOR_GRABBING 22
#define NS_STYLE_CURSOR_SPINNING 23
#define NS_STYLE_CURSOR_MOZ_ZOOM_IN 24
#define NS_STYLE_CURSOR_MOZ_ZOOM_OUT 25
#define NS_STYLE_CURSOR_NOT_ALLOWED 26
#define NS_STYLE_CURSOR_COL_RESIZE 27
#define NS_STYLE_CURSOR_ROW_RESIZE 28
#define NS_STYLE_CURSOR_NO_DROP 29
#define NS_STYLE_CURSOR_VERTICAL_TEXT 30
#define NS_STYLE_CURSOR_ALL_SCROLL 31
#define NS_STYLE_CURSOR_NESW_RESIZE 32
#define NS_STYLE_CURSOR_NWSE_RESIZE 33
#define NS_STYLE_CURSOR_NS_RESIZE 34
#define NS_STYLE_CURSOR_EW_RESIZE 35
// See nsStyleDisplay
#define NS_STYLE_DIRECTION_LTR 0
#define NS_STYLE_DIRECTION_RTL 1
#define NS_STYLE_DIRECTION_INHERIT 2
// See nsStyleDisplay
#define NS_STYLE_DISPLAY_NONE 0
#define NS_STYLE_DISPLAY_BLOCK 1
#define NS_STYLE_DISPLAY_INLINE 2
#define NS_STYLE_DISPLAY_INLINE_BLOCK 3
#define NS_STYLE_DISPLAY_LIST_ITEM 4
#define NS_STYLE_DISPLAY_MARKER 5
#define NS_STYLE_DISPLAY_RUN_IN 6
#define NS_STYLE_DISPLAY_COMPACT 7
#define NS_STYLE_DISPLAY_TABLE 8
#define NS_STYLE_DISPLAY_INLINE_TABLE 9
#define NS_STYLE_DISPLAY_TABLE_ROW_GROUP 10
#define NS_STYLE_DISPLAY_TABLE_COLUMN 11
#define NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP 12
#define NS_STYLE_DISPLAY_TABLE_HEADER_GROUP 13
#define NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP 14
#define NS_STYLE_DISPLAY_TABLE_ROW 15
#define NS_STYLE_DISPLAY_TABLE_CELL 16
#define NS_STYLE_DISPLAY_TABLE_CAPTION 17
#define NS_STYLE_DISPLAY_BOX 18
#define NS_STYLE_DISPLAY_INLINE_BOX 19
#define NS_STYLE_DISPLAY_GRID 20
#define NS_STYLE_DISPLAY_INLINE_GRID 21
#define NS_STYLE_DISPLAY_GRID_GROUP 22
#define NS_STYLE_DISPLAY_GRID_LINE 23
#define NS_STYLE_DISPLAY_STACK 24
#define NS_STYLE_DISPLAY_INLINE_STACK 25
#define NS_STYLE_DISPLAY_DECK 26
#define NS_STYLE_DISPLAY_BULLETINBOARD 27
#define NS_STYLE_DISPLAY_POPUP 28
#define NS_STYLE_DISPLAY_GROUPBOX 29
#define NS_STYLE_DISPLAY_PAGE_BREAK 30
// See nsStyleDisplay
#define NS_STYLE_FLOAT_NONE 0
#define NS_STYLE_FLOAT_LEFT 1
#define NS_STYLE_FLOAT_RIGHT 2
// See nsStyleFont
#define NS_STYLE_FONT_STYLE_NORMAL 0
#define NS_STYLE_FONT_STYLE_ITALIC 1
#define NS_STYLE_FONT_STYLE_OBLIQUE 2
// See nsStyleFont
#define NS_STYLE_FONT_VARIANT_NORMAL 0
#define NS_STYLE_FONT_VARIANT_SMALL_CAPS 1
// See nsStyleFont
#define NS_STYLE_FONT_WEIGHT_NORMAL 400
#define NS_STYLE_FONT_WEIGHT_BOLD 700
#define NS_STYLE_FONT_WEIGHT_BOLDER 1
#define NS_STYLE_FONT_WEIGHT_LIGHTER -1
// See nsStyleFont
#define NS_STYLE_FONT_SIZE_XXSMALL 0
#define NS_STYLE_FONT_SIZE_XSMALL 1
#define NS_STYLE_FONT_SIZE_SMALL 2
#define NS_STYLE_FONT_SIZE_MEDIUM 3
#define NS_STYLE_FONT_SIZE_LARGE 4
#define NS_STYLE_FONT_SIZE_XLARGE 5
#define NS_STYLE_FONT_SIZE_XXLARGE 6
#define NS_STYLE_FONT_SIZE_XXXLARGE 7 // Only used by <font size="7">. Not specifiable in CSS.
#define NS_STYLE_FONT_SIZE_LARGER 8
#define NS_STYLE_FONT_SIZE_SMALLER 9
// See nsStyleFont
#define NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED -4
#define NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED -3
#define NS_STYLE_FONT_STRETCH_CONDENSED -2
#define NS_STYLE_FONT_STRETCH_SEMI_CONDENSED -1
#define NS_STYLE_FONT_STRETCH_NORMAL 0
#define NS_STYLE_FONT_STRETCH_SEMI_EXPANDED 1
#define NS_STYLE_FONT_STRETCH_EXPANDED 2
#define NS_STYLE_FONT_STRETCH_EXTRA_EXPANDED 3
#define NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED 4
#define NS_STYLE_FONT_STRETCH_WIDER 10
#define NS_STYLE_FONT_STRETCH_NARROWER -10
// See nsStyleFont mFlags
#define NS_STYLE_FONT_DEFAULT 0x00
#define NS_STYLE_FONT_FACE_MASK 0xFF // used to flag generic fonts
// See nsStyleFont - system fonts
#define NS_STYLE_FONT_CAPTION 1 // css2
#define NS_STYLE_FONT_ICON 2
#define NS_STYLE_FONT_MENU 3
#define NS_STYLE_FONT_MESSAGE_BOX 4
#define NS_STYLE_FONT_SMALL_CAPTION 5
#define NS_STYLE_FONT_STATUS_BAR 6
#define NS_STYLE_FONT_WINDOW 7 // css3
#define NS_STYLE_FONT_DOCUMENT 8
#define NS_STYLE_FONT_WORKSPACE 9
#define NS_STYLE_FONT_DESKTOP 10
#define NS_STYLE_FONT_INFO 11
#define NS_STYLE_FONT_DIALOG 12
#define NS_STYLE_FONT_BUTTON 13
#define NS_STYLE_FONT_PULL_DOWN_MENU 14
#define NS_STYLE_FONT_LIST 15
#define NS_STYLE_FONT_FIELD 16
// See nsStylePosition.mPosition
#define NS_STYLE_POSITION_STATIC 0
#define NS_STYLE_POSITION_RELATIVE 1
#define NS_STYLE_POSITION_ABSOLUTE 2
#define NS_STYLE_POSITION_FIXED 3
// See nsStylePosition.mClip
#define NS_STYLE_CLIP_AUTO 0x00
#define NS_STYLE_CLIP_RECT 0x01
#define NS_STYLE_CLIP_TYPE_MASK 0x0F
#define NS_STYLE_CLIP_LEFT_AUTO 0x10
#define NS_STYLE_CLIP_TOP_AUTO 0x20
#define NS_STYLE_CLIP_RIGHT_AUTO 0x40
#define NS_STYLE_CLIP_BOTTOM_AUTO 0x80
// FRAME/FRAMESET/IFRAME specific values including backward compatibility. Boolean values with
// the same meaning (e.g. 1 & yes) may need to be distinguished for correct mode processing
#define NS_STYLE_FRAME_YES 0
#define NS_STYLE_FRAME_NO 1
#define NS_STYLE_FRAME_0 2
#define NS_STYLE_FRAME_1 3
#define NS_STYLE_FRAME_ON 4
#define NS_STYLE_FRAME_OFF 5
#define NS_STYLE_FRAME_AUTO 6
#define NS_STYLE_FRAME_SCROLL 7
#define NS_STYLE_FRAME_NOSCROLL 8
// See nsStylePosition.mOverflow
#define NS_STYLE_OVERFLOW_VISIBLE 0
#define NS_STYLE_OVERFLOW_HIDDEN 1
#define NS_STYLE_OVERFLOW_SCROLL 2
#define NS_STYLE_OVERFLOW_AUTO 3
#define NS_STYLE_OVERFLOW_CLIP 4
#define NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL 5
#define NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL 6
// See nsStyleList
#define NS_STYLE_LIST_STYLE_NONE 0
#define NS_STYLE_LIST_STYLE_DISC 1
#define NS_STYLE_LIST_STYLE_CIRCLE 2
#define NS_STYLE_LIST_STYLE_SQUARE 3
#define NS_STYLE_LIST_STYLE_DECIMAL 4
#define NS_STYLE_LIST_STYLE_DECIMAL_LEADING_ZERO 5
#define NS_STYLE_LIST_STYLE_LOWER_ROMAN 6
#define NS_STYLE_LIST_STYLE_UPPER_ROMAN 7
#define NS_STYLE_LIST_STYLE_LOWER_GREEK 8
#define NS_STYLE_LIST_STYLE_LOWER_ALPHA 9
#define NS_STYLE_LIST_STYLE_LOWER_LATIN 9 // == ALPHA
#define NS_STYLE_LIST_STYLE_UPPER_ALPHA 10
#define NS_STYLE_LIST_STYLE_UPPER_LATIN 10 // == ALPHA
#define NS_STYLE_LIST_STYLE_HEBREW 11
#define NS_STYLE_LIST_STYLE_ARMENIAN 12
#define NS_STYLE_LIST_STYLE_GEORGIAN 13
#define NS_STYLE_LIST_STYLE_CJK_IDEOGRAPHIC 14
#define NS_STYLE_LIST_STYLE_HIRAGANA 15
#define NS_STYLE_LIST_STYLE_KATAKANA 16
#define NS_STYLE_LIST_STYLE_HIRAGANA_IROHA 17
#define NS_STYLE_LIST_STYLE_KATAKANA_IROHA 18
#define NS_STYLE_LIST_STYLE_OLD_LOWER_ROMAN 19
#define NS_STYLE_LIST_STYLE_OLD_UPPER_ROMAN 20
#define NS_STYLE_LIST_STYLE_OLD_LOWER_ALPHA 21
#define NS_STYLE_LIST_STYLE_OLD_UPPER_ALPHA 22
#define NS_STYLE_LIST_STYLE_OLD_DECIMAL 23
#define NS_STYLE_LIST_STYLE_MOZ_CJK_HEAVENLY_STEM 24
#define NS_STYLE_LIST_STYLE_MOZ_CJK_EARTHLY_BRANCH 25
#define NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_INFORMAL 26
#define NS_STYLE_LIST_STYLE_MOZ_TRAD_CHINESE_FORMAL 27
#define NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_INFORMAL 28
#define NS_STYLE_LIST_STYLE_MOZ_SIMP_CHINESE_FORMAL 29
#define NS_STYLE_LIST_STYLE_MOZ_JAPANESE_INFORMAL 30
#define NS_STYLE_LIST_STYLE_MOZ_JAPANESE_FORMAL 31
#define NS_STYLE_LIST_STYLE_MOZ_ARABIC_INDIC 32
#define NS_STYLE_LIST_STYLE_MOZ_PERSIAN 33
#define NS_STYLE_LIST_STYLE_MOZ_URDU 34
#define NS_STYLE_LIST_STYLE_MOZ_DEVANAGARI 35
#define NS_STYLE_LIST_STYLE_MOZ_GURMUKHI 36
#define NS_STYLE_LIST_STYLE_MOZ_GUJARATI 37
#define NS_STYLE_LIST_STYLE_MOZ_ORIYA 38
#define NS_STYLE_LIST_STYLE_MOZ_KANNADA 39
#define NS_STYLE_LIST_STYLE_MOZ_MALAYALAM 40
#define NS_STYLE_LIST_STYLE_MOZ_BENGALI 41
#define NS_STYLE_LIST_STYLE_MOZ_TAMIL 42
#define NS_STYLE_LIST_STYLE_MOZ_TELUGU 43
#define NS_STYLE_LIST_STYLE_MOZ_THAI 44
#define NS_STYLE_LIST_STYLE_MOZ_LAO 45
#define NS_STYLE_LIST_STYLE_MOZ_MYANMAR 46
#define NS_STYLE_LIST_STYLE_MOZ_KHMER 47
#define NS_STYLE_LIST_STYLE_MOZ_HANGUL 48
#define NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT 49
#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME 50
#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC 51
#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM 52
#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER 53
#define NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET 54
// See nsStyleList
#define NS_STYLE_LIST_STYLE_POSITION_INSIDE 0
#define NS_STYLE_LIST_STYLE_POSITION_OUTSIDE 1
// See nsStyleMargin
#define NS_STYLE_MARGIN_SIZE_AUTO 0
// See nsStyleText
//
// Note: make sure the numbers are less than the numbers that start
// the vertical_align values below!
#define NS_STYLE_TEXT_ALIGN_DEFAULT 0
#define NS_STYLE_TEXT_ALIGN_LEFT 1
#define NS_STYLE_TEXT_ALIGN_RIGHT 2
#define NS_STYLE_TEXT_ALIGN_CENTER 3
#define NS_STYLE_TEXT_ALIGN_JUSTIFY 4
#define NS_STYLE_TEXT_ALIGN_CHAR 5 //align based on a certain character, for table cell
#define NS_STYLE_TEXT_ALIGN_MOZ_CENTER 6
#define NS_STYLE_TEXT_ALIGN_MOZ_RIGHT 7
// See nsStyleText, nsStyleFont
#define NS_STYLE_TEXT_DECORATION_NONE 0
#define NS_STYLE_TEXT_DECORATION_UNDERLINE NS_FONT_DECORATION_UNDERLINE
#define NS_STYLE_TEXT_DECORATION_OVERLINE NS_FONT_DECORATION_OVERLINE
#define NS_STYLE_TEXT_DECORATION_LINE_THROUGH NS_FONT_DECORATION_LINE_THROUGH
#define NS_STYLE_TEXT_DECORATION_BLINK 0x08
#define NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL 0x10
#define NS_STYLE_TEXT_DECORATION_PREF_ANCHORS 0x20
#define NS_STYLE_TEXT_DECORATION_LINES_MASK (NS_STYLE_TEXT_DECORATION_UNDERLINE | NS_STYLE_TEXT_DECORATION_OVERLINE | NS_STYLE_TEXT_DECORATION_LINE_THROUGH)
// See nsStyleText
#define NS_STYLE_TEXT_TRANSFORM_NONE 0
#define NS_STYLE_TEXT_TRANSFORM_CAPITALIZE 1
#define NS_STYLE_TEXT_TRANSFORM_LOWERCASE 2
#define NS_STYLE_TEXT_TRANSFORM_UPPERCASE 3
// See nsStyleText
// Note: these values pickup after the text-align values because there
// are a few html cases where an object can have both types of
// alignment applied with a single attribute
#define NS_STYLE_VERTICAL_ALIGN_BASELINE 10
#define NS_STYLE_VERTICAL_ALIGN_SUB 11
#define NS_STYLE_VERTICAL_ALIGN_SUPER 12
#define NS_STYLE_VERTICAL_ALIGN_TOP 13
#define NS_STYLE_VERTICAL_ALIGN_TEXT_TOP 14
#define NS_STYLE_VERTICAL_ALIGN_MIDDLE 15
#define NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM 16
#define NS_STYLE_VERTICAL_ALIGN_BOTTOM 17
// See nsStyleDisplay
#define NS_STYLE_VISIBILITY_HIDDEN 0
#define NS_STYLE_VISIBILITY_VISIBLE 1
#define NS_STYLE_VISIBILITY_COLLAPSE 2
// See nsStyleText
#define NS_STYLE_WHITESPACE_NORMAL 0
#define NS_STYLE_WHITESPACE_PRE 1
#define NS_STYLE_WHITESPACE_NOWRAP 2
#define NS_STYLE_WHITESPACE_MOZ_PRE_WRAP 3
// See nsStyleText
#define NS_STYLE_UNICODE_BIDI_NORMAL 0
#define NS_STYLE_UNICODE_BIDI_EMBED 1
#define NS_STYLE_UNICODE_BIDI_OVERRIDE 2
// See nsStyleTable (here for HTML 4.0 for now, should probably change to side flags)
#define NS_STYLE_TABLE_FRAME_NONE 0
#define NS_STYLE_TABLE_FRAME_ABOVE 1
#define NS_STYLE_TABLE_FRAME_BELOW 2
#define NS_STYLE_TABLE_FRAME_HSIDES 3
#define NS_STYLE_TABLE_FRAME_VSIDES 4
#define NS_STYLE_TABLE_FRAME_LEFT 5
#define NS_STYLE_TABLE_FRAME_RIGHT 6
#define NS_STYLE_TABLE_FRAME_BOX 7
#define NS_STYLE_TABLE_FRAME_BORDER 8
// See nsStyleTable
#define NS_STYLE_TABLE_RULES_NONE 0
#define NS_STYLE_TABLE_RULES_GROUPS 1
#define NS_STYLE_TABLE_RULES_ROWS 2
#define NS_STYLE_TABLE_RULES_COLS 3
#define NS_STYLE_TABLE_RULES_ALL 4
#define NS_STYLE_TABLE_COLS_NONE (-1)
#define NS_STYLE_TABLE_COLS_ALL PRInt32(1 << 30)
#define NS_STYLE_TABLE_LAYOUT_AUTO 0
#define NS_STYLE_TABLE_LAYOUT_FIXED 1
#define NS_STYLE_TABLE_EMPTY_CELLS_HIDE 0
#define NS_STYLE_TABLE_EMPTY_CELLS_SHOW 1
#define NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND 2
// CAPTION_SIDE uses NS_SIDE_*
// constants for cell "scope" attribute
#define NS_STYLE_CELL_SCOPE_ROW 0
#define NS_STYLE_CELL_SCOPE_COL 1
#define NS_STYLE_CELL_SCOPE_ROWGROUP 2
#define NS_STYLE_CELL_SCOPE_COLGROUP 3
// See nsStylePage
#define NS_STYLE_PAGE_MARKS_NONE 0x00
#define NS_STYLE_PAGE_MARKS_CROP 0x01
#define NS_STYLE_PAGE_MARKS_REGISTER 0x02
// See nsStylePage
#define NS_STYLE_PAGE_SIZE_AUTO 0
#define NS_STYLE_PAGE_SIZE_PORTRAIT 1
#define NS_STYLE_PAGE_SIZE_LANDSCAPE 2
// See nsStyleBreaks
#define NS_STYLE_PAGE_BREAK_AUTO 0
#define NS_STYLE_PAGE_BREAK_ALWAYS 1
#define NS_STYLE_PAGE_BREAK_AVOID 2
#define NS_STYLE_PAGE_BREAK_LEFT 3
#define NS_STYLE_PAGE_BREAK_RIGHT 4
// See nsStyleColumn
#define NS_STYLE_COLUMN_COUNT_AUTO 0
#define NS_STYLE_COLUMN_COUNT_UNLIMITED (-1)
#ifdef MOZ_SVG
// Some of our constants must map to the same values as those defined in
// nsISVG{,Path,Glyph}GeometrySource.idl/
// I don't want to add a dependency on the SVG module
// everywhere by #include'ing nsISVG{,Path,Glyph}GeometrySource.h, so these consts
// have to be kept in sync manually.
// dominant-baseline
#define NS_STYLE_DOMINANT_BASELINE_AUTO 0
#define NS_STYLE_DOMINANT_BASELINE_USE_SCRIPT 1
#define NS_STYLE_DOMINANT_BASELINE_NO_CHANGE 2
#define NS_STYLE_DOMINANT_BASELINE_RESET_SIZE 3
#define NS_STYLE_DOMINANT_BASELINE_ALPHABETIC 4
#define NS_STYLE_DOMINANT_BASELINE_HANGING 5
#define NS_STYLE_DOMINANT_BASELINE_IDEOGRAPHIC 6
#define NS_STYLE_DOMINANT_BASELINE_MATHEMATICAL 7
#define NS_STYLE_DOMINANT_BASELINE_CENTRAL 8
#define NS_STYLE_DOMINANT_BASELINE_MIDDLE 9
#define NS_STYLE_DOMINANT_BASELINE_TEXT_AFTER_EDGE 10
#define NS_STYLE_DOMINANT_BASELINE_TEXT_BEFORE_EDGE 11
#define NS_STYLE_DOMINANT_BASELINE_TEXT_TOP 12
#define NS_STYLE_DOMINANT_BASELINE_TEXT_BOTTOM 13
// fill-rule
#define NS_STYLE_FILL_RULE_NONZERO 0 /* == nsISVGGeometrySource::FILL_RULE_NONZERO */
#define NS_STYLE_FILL_RULE_EVENODD 1 /* == nsISVGGeometrySource::FILL_RULE_EVENODD */
// pointer-events
#define NS_STYLE_POINTER_EVENTS_NONE 0
#define NS_STYLE_POINTER_EVENTS_VISIBLEPAINTED 1
#define NS_STYLE_POINTER_EVENTS_VISIBLEFILL 2
#define NS_STYLE_POINTER_EVENTS_VISIBLESTROKE 3
#define NS_STYLE_POINTER_EVENTS_VISIBLE 4
#define NS_STYLE_POINTER_EVENTS_PAINTED 5
#define NS_STYLE_POINTER_EVENTS_FILL 6
#define NS_STYLE_POINTER_EVENTS_STROKE 7
#define NS_STYLE_POINTER_EVENTS_ALL 8
// shape-rendering
#define NS_STYLE_SHAPE_RENDERING_AUTO 0 /* == nsISVGPathGeometrySource::SHAPE_RENDERING_AUTO */
#define NS_STYLE_SHAPE_RENDERING_OPTIMIZESPEED 1 /* == nsISVGPathGeometrySource::SHAPE_RENDERING_OPTIMIZESPEED */
#define NS_STYLE_SHAPE_RENDERING_CRISPEDGES 2 /* == nsISVGPathGeometrySource::SHAPE_RENDERING_CRISPEDGES */
#define NS_STYLE_SHAPE_RENDERING_GEOMETRICPRECISION 3 /* == nsISVGPathGeometrySource::SHAPE_RENDERING_GEOMETRICPRECISION */
// stroke-linecap
#define NS_STYLE_STROKE_LINECAP_BUTT 0 /* == nsISVGGeometrySource::STROKE_LINECAP_BUTT */
#define NS_STYLE_STROKE_LINECAP_ROUND 1 /* == nsISVGGeometrySource::STROKE_LINECAP_ROUND */
#define NS_STYLE_STROKE_LINECAP_SQUARE 2 /* == nsISVGGeometrySource::STROKE_LINECAP_SQUARE */
// stroke-linejoin
#define NS_STYLE_STROKE_LINEJOIN_MITER 0 /* == nsISVGGeometrySource::STROKE_LINEJOIN_MITER */
#define NS_STYLE_STROKE_LINEJOIN_ROUND 1 /* == nsISVGGeometrySource::STROKE_LINEJOIN_ROUND */
#define NS_STYLE_STROKE_LINEJOIN_BEVEL 2 /* == nsISVGGeometrySource::STROKE_LINEJOIN_BEVEL */
// text-anchor
#define NS_STYLE_TEXT_ANCHOR_START 0
#define NS_STYLE_TEXT_ANCHOR_MIDDLE 1
#define NS_STYLE_TEXT_ANCHOR_END 2
// text-rendering
#define NS_STYLE_TEXT_RENDERING_AUTO 0 /* == nsISVGGlyphGeometrySource::TEXT_RENDERING_AUTO */
#define NS_STYLE_TEXT_RENDERING_OPTIMIZESPEED 1 /* == nsISVGG.G.S.::TEXT_RENDERING_OPTIMIZESPEED */
#define NS_STYLE_TEXT_RENDERING_OPTIMIZELEGIBILITY 2 /* == nsISVGG.G.S.::TEXT_RENDERING_OPTIMIZELEGIBILITY */
#define NS_STYLE_TEXT_RENDERING_GEOMETRICPRECISION 3 /* == nsISVGG.G.S.::TEXT_RENDERING_GEOMETRICPRECISION */
#endif // MOZ_SVG
#endif /* nsStyleConsts_h___ */

View File

@@ -1,169 +0,0 @@
/* -*- 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 IBM code.
*
* The Initial Developer of the Original Code is
* IBM. Portions created by IBM are Copyright (C) International Business Machines Corporation, 2000. All Rights Reserved. /.
* 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 ***** */
/*
DO NOT EDIT THIS DOCUMENT !!! THIS DOCUMENT IS GENERATED BY
mozilla/intl/unicharutil/tools/gensymmtable.pl
*/
/* Block U00__ */
const static PRUint8 symmtable_00[256] = {
/* _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F */
/* 0_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 1_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 2_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0x1, 0, 0, 0, 0, 0, 0,
/* 3_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2, 0, 0x2, 0,
/* 4_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 5_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x6, 0, 0x6, 0, 0,
/* 6_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 7_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x6, 0, 0x6, 0, 0,
/* 8_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 9_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* A_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0, 0,
/* B_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0, 0,
/* C_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* D_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* E_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* F_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
/* Block U20__ */
const static PRUint8 symmtable_20[256] = {
/* _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F */
/* 0_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 1_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 2_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 3_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0x3, 0, 0, 0, 0, 0,
/* 4_ */ 0, 0, 0, 0, 0, 0x3, 0x3, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 5_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 6_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 7_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0x3, 0,
/* 8_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0x3, 0,
/* 9_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* A_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* B_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* C_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* D_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* E_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* F_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
/* Block U22__ */
const static PRUint8 symmtable_22[256] = {
/* _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F */
/* 0_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0x5, 0x7, 0x3, 0x5, 0x7, 0, 0,
/* 1_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 2_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 3_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0x1, 0, 0,
/* 4_ */ 0, 0, 0, 0x8e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 5_ */ 0, 0, 0x1, 0x1, 0x1, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 6_ */ 0, 0, 0, 0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0, 0, 0x1, 0x1,
/* 7_ */ 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
/* 8_ */ 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0, 0, 0, 0x1f,
/* 9_ */ 0x1f, 0x3, 0x3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* A_ */ 0, 0, 0x1, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* B_ */ 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0, 0, 0, 0, 0, 0, 0, 0,
/* C_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0x3, 0x7, 0x7, 0x8e, 0, 0,
/* D_ */ 0x1, 0x1, 0, 0, 0, 0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
/* E_ */ 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0, 0,
/* F_ */ 0x1, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
/* Block U23__ */
const static PRUint8 symmtable_23[256] = {
/* _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F */
/* 0_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0x1, 0x1, 0x1, 0, 0, 0, 0,
/* 1_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 2_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0x3, 0, 0, 0, 0, 0,
/* 3_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 4_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 5_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 6_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 7_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 8_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 9_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* A_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* B_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* C_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* D_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* E_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* F_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
/* Block U30__ */
const static PRUint8 symmtable_30[256] = {
/* _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F */
/* 0_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
/* 1_ */ 0x1, 0x1, 0, 0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0, 0, 0, 0,
/* 2_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 3_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 4_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 5_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 6_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 7_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 8_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 9_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* A_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* B_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* C_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* D_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* E_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* F_ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
static PRUint32 Mirrored(PRUint32 u)
{
switch (u & 0xFFFFFF00) {
// XOR the character with the bitmap in the conversion table to give the symmetric equivalent
case 0:
u ^= symmtable_00[u & 0xff];
break;
case 0x2000:
u ^= symmtable_20[u & 0xff];
break;
case 0x2200:
u ^= symmtable_22[u & 0xff];
break;
case 0x2300:
u ^= symmtable_23[u & 0xff];
break;
case 0x3000:
u ^= symmtable_30[u & 0xff];
break;
}
return u;
}

View File

@@ -1,72 +0,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) 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 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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
REQUIRES = xpcom \
gfx \
$(NULL)
include $(DEPTH)/config/autoconf.mk
CPPSRCS = \
TestSpaceManager.cpp \
$(NULL)
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
LOCAL_INCLUDES = \
-I$(srcdir)/../src \
$(NULL)
EXTRA_DSO_LIBS = gkbase_s gkgfx
LIBS += \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(MOZ_JS_LIBS) \
$(TK_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_LAYOUT

View File

@@ -1,750 +0,0 @@
/* -*- 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
* 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 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 "nscore.h"
#include "nsCRT.h"
#include "nsSpaceManager.h"
class MySpaceManager: public nsSpaceManager {
public:
MySpaceManager(nsIPresShell* aPresShell, nsIFrame* aFrame)
: nsSpaceManager(aPresShell, aFrame) {}
PRBool TestAddBand();
PRBool TestAddBandOverlap();
PRBool TestAddRectToBand();
PRBool TestRemoveRegion();
PRBool TestGetBandData();
struct BandInfo {
nscoord yOffset;
nscoord height;
BandRect* firstRect;
PRIntn numRects;
};
struct BandsInfo {
PRIntn numBands;
BandInfo bands[25];
};
protected:
void GetBandsInfo(BandsInfo&);
};
void MySpaceManager::GetBandsInfo(BandsInfo& aBandsInfo)
{
aBandsInfo.numBands = 0;
if (!mBandList.IsEmpty()) {
BandRect* band = mBandList.Head();
while (nsnull != band) {
BandInfo& info = aBandsInfo.bands[aBandsInfo.numBands];
info.yOffset = band->mTop;
info.height = band->mBottom - band->mTop;
info.firstRect = band;
aBandsInfo.numBands++;
// Get the next band, and count the number of rects in this band
info.numRects = 0;
while (info.yOffset == band->mTop) {
info.numRects++;
band = band->Next();
if (band == &mBandList) {
// No bands left
band = nsnull;
break;
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
//
// Test of adding a rect region that causes a new band to be created (no
// overlap with an existing band)
//
// This tests the following:
// 1. when there are no existing bands
// 2. adding a new band above the topmost band
// 3. inserting a new band between two existing bands
// 4. adding a new band below the bottommost band
PRBool MySpaceManager::TestAddBand()
{
BandsInfo bandsInfo;
nsresult status;
// Clear any existing regions
ClearRegions();
NS_ASSERTION(mBandList.IsEmpty(), "clear regions failed");
/////////////////////////////////////////////////////////////////////////////
// #1. Add a rect region. Verify the return status, and that a band rect is
// added
status = AddRectRegion((nsIFrame*)0x01, nsRect(10, 100, 100, 100));
if (NS_FAILED(status)) {
printf("TestAddBand: add failed (#1)\n");
return PR_FALSE;
}
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 1) {
printf("TestAddBand: wrong number of bands (#1): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if ((bandsInfo.bands[0].yOffset != 100) || (bandsInfo.bands[0].height != 100)) {
printf("TestAddBand: wrong band size (#1)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #2. Add another band rect completely above the first band rect
status = AddRectRegion((nsIFrame*)0x02, nsRect(10, -10, 100, 20));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 2) {
printf("TestAddBand: wrong number of bands (#2): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if ((bandsInfo.bands[0].yOffset != -10) || (bandsInfo.bands[0].height != 20) ||
(bandsInfo.bands[1].yOffset != 100) || (bandsInfo.bands[1].height != 100)) {
printf("TestAddBand: wrong band sizes (#2)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #3. Now insert a new band between the two existing bands
status = AddRectRegion((nsIFrame*)0x03, nsRect(10, 40, 100, 30));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 3) {
printf("TestAddBand: wrong number of bands (#3): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if ((bandsInfo.bands[0].yOffset != -10) || (bandsInfo.bands[0].height != 20) ||
(bandsInfo.bands[1].yOffset != 40) || (bandsInfo.bands[1].height != 30) ||
(bandsInfo.bands[2].yOffset != 100) || (bandsInfo.bands[2].height != 100)) {
printf("TestAddBand: wrong band sizes (#3)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #4. Append a new bottommost band
status = AddRectRegion((nsIFrame*)0x04, nsRect(10, 210, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 4) {
printf("TestAddBand: wrong number of bands (#4): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if ((bandsInfo.bands[0].yOffset != -10) || (bandsInfo.bands[0].height != 20) ||
(bandsInfo.bands[1].yOffset != 40) || (bandsInfo.bands[1].height != 30) ||
(bandsInfo.bands[2].yOffset != 100) || (bandsInfo.bands[2].height != 100) ||
(bandsInfo.bands[3].yOffset != 210) || (bandsInfo.bands[3].height != 100)) {
printf("TestAddBand: wrong band sizes (#4)\n");
return PR_FALSE;
}
return PR_TRUE;
}
// Test of adding a rect region that overlaps an existing band
//
// This tests the following:
// 1. Adding a rect that's above and partially overlaps an existing band
// 2. Adding a rect that's completely contained by an existing band
// 3. Adding a rect that overlaps and is below an existing band
// 3. Adding a rect that contains an existing band
PRBool MySpaceManager::TestAddBandOverlap()
{
BandsInfo bandsInfo;
nsresult status;
// Clear any existing regions
ClearRegions();
NS_ASSERTION(mBandList.IsEmpty(), "clear regions failed");
// Add a new band
status = AddRectRegion((nsIFrame*)0x01, nsRect(100, 25, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
/////////////////////////////////////////////////////////////////////////////
// #1. Add a rect region that's above and partially overlaps an existing band
status = AddRectRegion((nsIFrame*)0x02, nsRect(10, -25, 50, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 3) {
printf("TestAddBandOverlap: wrong number of bands (#1): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if ((bandsInfo.bands[0].yOffset != -25) || (bandsInfo.bands[0].height != 50) ||
(bandsInfo.bands[1].yOffset != 25) || (bandsInfo.bands[1].height != 50) ||
(bandsInfo.bands[2].yOffset != 75) || (bandsInfo.bands[2].height != 50)) {
printf("TestAddBandOverlap: wrong band sizes (#1)\n");
return PR_FALSE;
}
if ((bandsInfo.bands[0].numRects != 1) ||
(bandsInfo.bands[1].numRects != 2) ||
(bandsInfo.bands[2].numRects != 1)) {
printf("TestAddBandOverlap: wrong number of rects (#1)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #2. Add a rect region that's contained by the first band
status = AddRectRegion((nsIFrame*)0x03, nsRect(200, -15, 50, 10));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 5) {
printf("TestAddBandOverlap: wrong number of bands (#2): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if ((bandsInfo.bands[0].yOffset != -25) || (bandsInfo.bands[0].height != 10) ||
(bandsInfo.bands[1].yOffset != -15) || (bandsInfo.bands[1].height != 10) ||
(bandsInfo.bands[2].yOffset != -5) || (bandsInfo.bands[2].height != 30) ||
(bandsInfo.bands[3].yOffset != 25) || (bandsInfo.bands[3].height != 50) ||
(bandsInfo.bands[4].yOffset != 75) || (bandsInfo.bands[4].height != 50)) {
printf("TestAddBandOverlap: wrong band sizes (#2)\n");
return PR_FALSE;
}
if ((bandsInfo.bands[0].numRects != 1) ||
(bandsInfo.bands[1].numRects != 2) ||
(bandsInfo.bands[2].numRects != 1) ||
(bandsInfo.bands[3].numRects != 2) ||
(bandsInfo.bands[4].numRects != 1)) {
printf("TestAddBandOverlap: wrong number of rects (#2)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #3. Add a rect that overlaps and is below an existing band
status = AddRectRegion((nsIFrame*)0x04, nsRect(200, 100, 50, 50));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 7) {
printf("TestAddBandOverlap: wrong number of bands (#3): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if ((bandsInfo.bands[0].yOffset != -25) || (bandsInfo.bands[0].height != 10) ||
(bandsInfo.bands[1].yOffset != -15) || (bandsInfo.bands[1].height != 10) ||
(bandsInfo.bands[2].yOffset != -5) || (bandsInfo.bands[2].height != 30) ||
(bandsInfo.bands[3].yOffset != 25) || (bandsInfo.bands[3].height != 50) ||
(bandsInfo.bands[4].yOffset != 75) || (bandsInfo.bands[4].height != 25) ||
(bandsInfo.bands[5].yOffset != 100) || (bandsInfo.bands[5].height != 25) ||
(bandsInfo.bands[6].yOffset != 125) || (bandsInfo.bands[6].height != 25)) {
printf("TestAddBandOverlap: wrong band sizes (#3)\n");
return PR_FALSE;
}
if ((bandsInfo.bands[0].numRects != 1) ||
(bandsInfo.bands[1].numRects != 2) ||
(bandsInfo.bands[2].numRects != 1) ||
(bandsInfo.bands[3].numRects != 2) ||
(bandsInfo.bands[4].numRects != 1) ||
(bandsInfo.bands[5].numRects != 2) ||
(bandsInfo.bands[6].numRects != 1)) {
printf("TestAddBandOverlap: wrong number of rects (#3)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #4. Now test adding a rect that contains an existing band
ClearRegions();
status = AddRectRegion((nsIFrame*)0x01, nsRect(100, 100, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
// Now add a rect that contains the existing band vertically
status = AddRectRegion((nsIFrame*)0x02, nsRect(200, 50, 100, 200));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 3) {
printf("TestAddBandOverlap: wrong number of bands (#4): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if ((bandsInfo.bands[0].yOffset != 50) || (bandsInfo.bands[0].height != 50) ||
(bandsInfo.bands[1].yOffset != 100) || (bandsInfo.bands[1].height != 100) ||
(bandsInfo.bands[2].yOffset != 200) || (bandsInfo.bands[2].height != 50)) {
printf("TestAddBandOverlap: wrong band sizes (#4)\n");
return PR_FALSE;
}
if ((bandsInfo.bands[0].numRects != 1) ||
(bandsInfo.bands[1].numRects != 2) ||
(bandsInfo.bands[2].numRects != 1)) {
printf("TestAddBandOverlap: wrong number of rects (#4)\n");
return PR_FALSE;
}
return PR_TRUE;
}
// Test of adding rects within an existing band
//
// This tests the following:
// 1. Add a rect to the left of an existing rect
// 2. Add a rect to the right of the rightmost rect
// 3. Add a rect that's to the left of an existing rect and that overlaps it
// 4. Add a rect that's to the right of an existing rect and that overlaps it
// 5. Add a rect over top of an existing rect (existing rect contains new rect)
// 6. Add a new rect that completely contains an existing rect
PRBool MySpaceManager::TestAddRectToBand()
{
BandsInfo bandsInfo;
BandRect* bandRect;
nsresult status;
// Clear any existing regions
ClearRegions();
NS_ASSERTION(mBandList.IsEmpty(), "clear regions failed");
// Add a new band
status = AddRectRegion((nsIFrame*)0x01, nsRect(100, 100, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
/////////////////////////////////////////////////////////////////////////////
// #1. Add a rect region that's to the left of the existing rect
status = AddRectRegion((nsIFrame*)0x02, nsRect(10, 100, 50, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 1) {
printf("TestAddRectToBand: wrong number of bands (#1): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if (bandsInfo.bands[0].numRects != 2) {
printf("TestAddRectToBand: wrong number of rects (#1): %i\n", bandsInfo.bands[0].numRects);
return PR_FALSE;
}
bandRect = bandsInfo.bands[0].firstRect;
if ((bandRect->mLeft != 10) || (bandRect->mRight != 60)) {
printf("TestAddRectToBand: wrong first rect (#1)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 100) || (bandRect->mRight != 200)) {
printf("TestAddRectToBand: wrong second rect (#1)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #2. Add a rect region that's to the right of the rightmost rect
status = AddRectRegion((nsIFrame*)0x03, nsRect(250, 100, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
NS_ASSERTION(bandsInfo.numBands == 1, "wrong number of bands");
if (bandsInfo.bands[0].numRects != 3) {
printf("TestAddRectToBand: wrong number of rects (#2): %i\n", bandsInfo.bands[0].numRects);
return PR_FALSE;
}
bandRect = bandsInfo.bands[0].firstRect;
if ((bandRect->mLeft != 10) || (bandRect->mRight != 60)) {
printf("TestAddRectToBand: wrong first rect (#2)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 100) || (bandRect->mRight != 200)) {
printf("TestAddRectToBand: wrong second rect (#2)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 250) || (bandRect->mRight != 350)) {
printf("TestAddRectToBand: wrong third rect (#2)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #3. Add a rect region that's to the left of an existing rect and that
// overlaps the rect
status = AddRectRegion((nsIFrame*)0x04, nsRect(80, 100, 40, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
NS_ASSERTION(bandsInfo.numBands == 1, "wrong number of bands");
if (bandsInfo.bands[0].numRects != 5) {
printf("TestAddRectToBand: wrong number of rects (#3): %i\n", bandsInfo.bands[0].numRects);
return PR_FALSE;
}
bandRect = bandsInfo.bands[0].firstRect;
if ((bandRect->mLeft != 10) || (bandRect->mRight != 60)) {
printf("TestAddRectToBand: wrong first rect (#3)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 80) || (bandRect->mRight != 100)) {
printf("TestAddRectToBand: wrong second rect (#3)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 100) || (bandRect->mRight != 120) ||
(bandRect->mNumFrames != 2) || !bandRect->IsOccupiedBy((nsIFrame*)0x04)) {
printf("TestAddRectToBand: wrong third rect (#3)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 120) || (bandRect->mRight != 200)) {
printf("TestAddRectToBand: wrong fourth rect (#3)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 250) || (bandRect->mRight != 350)) {
printf("TestAddRectToBand: wrong fifth rect (#3)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #4. Add a rect region that's to the right of an existing rect and that
// overlaps the rect
status = AddRectRegion((nsIFrame*)0x05, nsRect(50, 100, 20, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
NS_ASSERTION(bandsInfo.numBands == 1, "wrong number of bands");
if (bandsInfo.bands[0].numRects != 7) {
printf("TestAddRectToBand: wrong number of rects (#4): %i\n", bandsInfo.bands[0].numRects);
return PR_FALSE;
}
bandRect = bandsInfo.bands[0].firstRect;
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 10) || (bandRect->mRight != 50)) {
printf("TestAddRectToBand: wrong first rect (#4)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 50) || (bandRect->mRight != 60) ||
(bandRect->mNumFrames != 2) || !bandRect->IsOccupiedBy((nsIFrame*)0x05)) {
printf("TestAddRectToBand: wrong second rect (#4)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 60) || (bandRect->mRight != 70)) {
printf("TestAddRectToBand: wrong third rect (#4)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 80) || (bandRect->mRight != 100)) {
printf("TestAddRectToBand: wrong fourth rect (#4)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #5. Add a new rect over top of an existing rect (existing rect contains
// the new rect)
status = AddRectRegion((nsIFrame*)0x06, nsRect(20, 100, 20, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
NS_ASSERTION(bandsInfo.numBands == 1, "wrong number of bands");
if (bandsInfo.bands[0].numRects != 9) {
printf("TestAddRectToBand: wrong number of rects (#5): %i\n", bandsInfo.bands[0].numRects);
return PR_FALSE;
}
bandRect = bandsInfo.bands[0].firstRect;
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 10) || (bandRect->mRight != 20)) {
printf("TestAddRectToBand: wrong first rect (#5)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 20) || (bandRect->mRight != 40) ||
(bandRect->mNumFrames != 2) || !bandRect->IsOccupiedBy((nsIFrame*)0x06)) {
printf("TestAddRectToBand: wrong second rect (#5)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 40) || (bandRect->mRight != 50)) {
printf("TestAddRectToBand: wrong third rect (#5)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 50) || (bandRect->mRight != 60) || (bandRect->mNumFrames != 2)) {
printf("TestAddRectToBand: wrong fourth rect (#5)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #6. Add a new rect that completely contains an existing rect
status = AddRectRegion((nsIFrame*)0x07, nsRect(0, 100, 30, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
NS_ASSERTION(bandsInfo.numBands == 1, "wrong number of bands");
if (bandsInfo.bands[0].numRects != 11) {
printf("TestAddRectToBand: wrong number of rects (#6): %i\n", bandsInfo.bands[0].numRects);
return PR_FALSE;
}
bandRect = bandsInfo.bands[0].firstRect;
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 0) || (bandRect->mRight != 10)) {
printf("TestAddRectToBand: wrong first rect (#6)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 10) || (bandRect->mRight != 20) ||
(bandRect->mNumFrames != 2) || !bandRect->IsOccupiedBy((nsIFrame*)0x07)) {
printf("TestAddRectToBand: wrong second rect (#6)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 20) || (bandRect->mRight != 30) ||
(bandRect->mNumFrames != 3) || !bandRect->IsOccupiedBy((nsIFrame*)0x07)) {
printf("TestAddRectToBand: wrong third rect (#6)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
if ((bandRect->mLeft != 30) || (bandRect->mRight != 40) || (bandRect->mNumFrames != 2)) {
printf("TestAddRectToBand: wrong fourth rect (#6)\n");
return PR_FALSE;
}
bandRect = bandRect->Next();
NS_ASSERTION(1 == bandRect->mNumFrames, "unexpected shared rect");
if ((bandRect->mLeft != 40) || (bandRect->mRight != 50)) {
printf("TestAddRectToBand: wrong fifth rect (#6)\n");
return PR_FALSE;
}
return PR_TRUE;
}
// Test of removing regions. We especially need to test that we correctly
// coalesce adjacent rects and bands
//
// This tests the following:
// 1. simple test of removing the one and only band rect
// 2. removing a shared rect and verifying adjacent rects are coalesced
// 3. removing a band rect and making sure adjacent bands are combined
PRBool MySpaceManager::TestRemoveRegion()
{
BandsInfo bandsInfo;
BandRect* bandRect;
nsresult status;
// Clear any existing regions
ClearRegions();
NS_ASSERTION(mBandList.IsEmpty(), "clear regions failed");
/////////////////////////////////////////////////////////////////////////////
// #1. A simple test of removing the one and only band rect
status = AddRectRegion((nsIFrame*)0x01, nsRect(10, 100, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
status = RemoveRegion((nsIFrame*)0x01);
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 0) {
printf("TestRemoveRegion: wrong number of bands (#1): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #2. Test removing a rect that's shared. Make sure adjacent rects are
// coalesced
status = AddRectRegion((nsIFrame*)0x01, nsRect(10, 100, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
status = AddRectRegion((nsIFrame*)0x02, nsRect(40, 100, 20, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
// Verify there are three rects in the band
GetBandsInfo(bandsInfo);
if (bandsInfo.bands[0].numRects != 3) {
printf("TestRemoveRegion: wrong number of rects (#2): %i\n", bandsInfo.bands[0].numRects);
return PR_FALSE;
}
// Remove the region associated with the second frame
status = RemoveRegion((nsIFrame*)0x02);
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.bands[0].numRects != 1) {
printf("TestRemoveRegion: failed to coalesce adjacent rects (#2)\n");
return PR_FALSE;
}
bandRect = bandsInfo.bands[0].firstRect;
if ((bandRect->mLeft != 10) || (bandRect->mRight != 110)) {
printf("TestRemoveRegion: wrong size rect (#2)\n");
return PR_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// #3. Test removing a band rect and making sure adjacent bands are combined
status = AddRectRegion((nsIFrame*)0x02, nsRect(10, 140, 20, 20));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
// Verify there are three bands and that each band has three rects
GetBandsInfo(bandsInfo);
if (bandsInfo.numBands != 3) {
printf("TestRemoveRegion: wrong number of bands (#3): %i\n", bandsInfo.numBands);
return PR_FALSE;
}
if (bandsInfo.bands[0].numRects != 1) {
printf("TestRemoveRegion: band #1 wrong number of rects (#3): %i\n", bandsInfo.bands[0].numRects);
return PR_FALSE;
}
if (bandsInfo.bands[1].numRects != 2) {
printf("TestRemoveRegion: band #2 wrong number of rects (#3): %i\n", bandsInfo.bands[1].numRects);
return PR_FALSE;
}
if (bandsInfo.bands[2].numRects != 1) {
printf("TestRemoveRegion: band #3 wrong number of rects (#3): %i\n", bandsInfo.bands[2].numRects);
return PR_FALSE;
}
// Remove the region associated with the second frame
status = RemoveRegion((nsIFrame*)0x02);
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
GetBandsInfo(bandsInfo);
if (bandsInfo.bands[0].numRects != 1) {
printf("TestRemoveRegion: failed to coalesce adjacent rects (#3)\n");
return PR_FALSE;
}
bandRect = bandsInfo.bands[0].firstRect;
if ((bandRect->mLeft != 10) || (bandRect->mRight != 110)) {
printf("TestRemoveRegion: wrong size rect (#3)\n");
return PR_FALSE;
}
return PR_TRUE;
}
// Test of getting the band data
PRBool MySpaceManager::TestGetBandData()
{
nsresult status;
nscoord yMost;
// Clear any existing regions
ClearRegions();
NS_ASSERTION(mBandList.IsEmpty(), "clear regions failed");
// Make sure YMost() returns the correct result
if (NS_ERROR_ABORT != YMost(yMost)) {
printf("TestGetBandData: YMost() returned wrong result (#1)\n");
return PR_FALSE;
}
// Make a band with three rects
status = AddRectRegion((nsIFrame*)0x01, nsRect(100, 100, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
status = AddRectRegion((nsIFrame*)0x02, nsRect(300, 100, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
status = AddRectRegion((nsIFrame*)0x03, nsRect(500, 100, 100, 100));
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
// Verify that YMost() is correct
if ((NS_OK != YMost(yMost)) || (yMost != 200)) {
printf("TestGetBandData: YMost() returned wrong value (#2)\n");
return PR_FALSE;
}
// Get the band data using a very large clip rect and a band data struct
// that's large enough
nsBandData bandData;
nsBandTrapezoid trapezoids[16];
bandData.mSize = 16;
bandData.mTrapezoids = trapezoids;
status = GetBandData(100, nsSize(10000,10000), bandData);
NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");
// Verify that there are seven trapezoids
if (bandData.mCount != 7) {
printf("TestGetBandData: wrong trapezoid count (#3)\n");
return PR_FALSE;
}
// Get the band data using a very large clip rect and a band data struct
// that's too small
bandData.mSize = 3;
status = GetBandData(100, nsSize(10000,10000), bandData);
if (NS_SUCCEEDED(status)) {
printf("TestGetBandData: ignored band data count (#4)\n");
return PR_FALSE;
}
// Make sure the count has been updated to reflect the number of trapezoids
// required
if (bandData.mCount <= bandData.mSize) {
printf("TestGetBandData: bad band data count (#5)\n");
return PR_FALSE;
}
// XXX We need lots more tests here...
return PR_TRUE;
}
///////////////////////////////////////////////////////////////////////////////
//
int main(int argc, char** argv)
{
// Create a space manager
MySpaceManager* spaceMgr = new MySpaceManager(nsnull, nsnull);
// Test adding rect regions
if (!spaceMgr->TestAddBand()) {
delete spaceMgr;
return -1;
}
// Test adding rect regions that overlap existing bands
if (!spaceMgr->TestAddBandOverlap()) {
delete spaceMgr;
return -1;
}
// Test adding rects within an existing band
if (!spaceMgr->TestAddRectToBand()) {
delete spaceMgr;
return -1;
}
// Test removing regions
if (!spaceMgr->TestRemoveRegion()) {
return -1;
}
// Test getting the band data
if (!spaceMgr->TestGetBandData()) {
return -1;
}
delete spaceMgr;
return 0;
}

View File

@@ -1,281 +0,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) 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 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 *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
# Solaris' sh blows
ifeq ($(OS_ARCH),SunOS)
SHELL := ksh
endif
BUILD_DATE = gbdate.h
BUILD_DATE_TS = gbdate.tstamp
MODULE = layout
LIBRARY_NAME = gklayout
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsLayoutModule
GRE_MODULE = 1
PACKAGE_FILE = layout.pkg
PACKAGE_VARS += MOZ_XUL
ifndef MOZ_ENABLE_LIBXUL
EXTRA_DSO_LIBS = gkgfx
endif
ifdef MOZ_PERF_METRICS
EXTRA_DSO_LIBS += mozutil_s
endif
REQUIRES = xpcom \
string \
content \
gfx \
widget \
view \
locale \
necko \
dom \
editor \
webshell \
docshell \
htmlparser \
js \
xpconnect \
uriloader \
caps \
necko2 \
rdf \
xuldoc \
imglib2 \
pref \
unicharutil \
xul \
xultmpl \
lwbrk \
plugin \
commandhandler \
webbrwsr \
uconv \
$(NULL)
CPPSRCS = \
nsLayoutModule.cpp \
nsContentHTTPStartup.cpp \
nsContentDLF.cpp \
$(NULL)
EXPORTS = nsLayoutCID.h
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)gkbase_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkgeneric_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkstyle_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkprinting_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gktable_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkxulbase_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconbase_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconevents_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconhtmlcon_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconhtmldoc_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconxmlcon_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconxmldoc_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconxbl_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconxulcon_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconxuldoc_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkview_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)jsdombase_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)jsdomevents_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)jsurl_s.$(LIB_SUFFIX) \
$(NULL)
ifdef HTML_FORMS
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/$(LIB_PREFIX)gkforms_s.$(LIB_SUFFIX) \
$(NULL)
endif
ifdef MOZ_XUL
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/$(LIB_PREFIX)gkxultree_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkxulgrid_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconxultmpl_s.$(LIB_SUFFIX) \
$(NULL)
endif
ifdef MOZ_MATHML
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/$(LIB_PREFIX)gkmathmlcon_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkmathmlbase_s.$(LIB_SUFFIX) \
$(NULL)
endif
ifdef MOZ_XTF
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/$(LIB_PREFIX)gkcontentxtf_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkxtfbase_s.$(LIB_SUFFIX) \
$(NULL)
endif
ifdef MOZ_SVG
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/$(LIB_PREFIX)gksvgbase_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkconsvgdoc_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)gkcontentsvg_s.$(LIB_SUFFIX) \
$(NULL)
ifdef MOZ_SVG_RENDERER_GDIPLUS
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/$(LIB_PREFIX)gksvgrenderergdiplus_s.$(LIB_SUFFIX) \
$(NULL)
OS_LIBS += \
Gdiplus.lib \
$(NULL)
endif
ifdef MOZ_SVG_RENDERER_LIBART
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/$(LIB_PREFIX)gksvgrendererlibart_s.$(LIB_SUFFIX) \
$(NULL)
endif
ifdef MOZ_SVG_RENDERER_CAIRO
SHARED_LIBRARY_LIBS += \
$(DIST)/lib/$(LIB_PREFIX)gksvgrenderercairo_s.$(LIB_SUFFIX) \
$(NULL)
endif
endif
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(MOZ_JS_LIBS) \
$(NULL)
ifdef NS_TRACE_MALLOC
EXTRA_DSO_LIBS += tracemalloc
endif
ifdef MOZ_SVG_RENDERER_LIBART
EXTRA_DSO_LDOPTS += $(MOZ_LIBART_LIBS) \
$(NULL)
endif
ifdef MOZ_SVG_RENDERER_CAIRO
EXTRA_DSO_LDOPTS += $(MOZ_CAIRO_LIBS) \
$(NULL)
endif
ifdef MOZ_ENABLE_GTK2
EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) \
$(NULL)
endif
ifdef MOZ_ENABLE_CAIRO
# don't add twice
ifndef MOZ_SVG_RENDERER_CAIRO
EXTRA_DSO_LDOPTS += $(MOZ_CAIRO_LIBS) \
$(NULL)
endif
endif
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
EXTRA_DSO_LDOPTS += \
$(TK_LIBS) \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += -I$(srcdir)/../base \
-I$(srcdir)/../generic \
-I$(srcdir)/../forms \
-I$(srcdir)/../style \
-I$(srcdir)/../xul/content/src \
-I$(srcdir)/../xul/base/src \
-I$(srcdir)/../../content/base/src \
-I$(srcdir)/../../content/html/content/src \
-I$(srcdir)/../../content/html/document/src \
-I$(srcdir)/../../content/html/style/src \
-I$(srcdir)/../../content/xul/content/src \
-I$(srcdir)/../../content/xul/templates/src \
-I$(srcdir)/../../content/events/src \
-I$(srcdir)/../../content/xbl/src \
-I$(topsrcdir)/view/src \
-I$(topsrcdir)/dom/src/base \
-I$(topsrcdir)/dom/src/jsurl \
-I. \
$(NULL)
ifdef MOZ_MATHML
LOCAL_INCLUDES += -I$(srcdir)/../mathml/content/src
endif
ifdef MOZ_SVG
LOCAL_INCLUDES += -I$(srcdir)/../../content/svg/content/src
endif
DEFINES += -D_IMPL_NS_LAYOUT
GARBAGE += $(BUILD_DATE) $(BUILD_DATE_TS)
ifeq ($(OS_ARCH),IRIX)
ifeq ($(GNU_CXX),1)
LDFLAGS += -Wl,-LD_LAYOUT:lgot_buffer=50
endif
endif
export:: $(BUILD_DATE)
$(BUILD_DATE_TS): FORCE
@for f in $(SHARED_LIBRARY_LIBS); do \
if [ $$f -nt $@ ]; then \
touch $@; \
fi; \
done
$(BUILD_DATE):: gbdate.pl $(BUILD_DATE_TS)
$(RM) $@
$(PERL) $(srcdir)/gbdate.pl > $@

View File

@@ -1,53 +0,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) 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 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 *****
$given_date = $ENV{"MOZ_BUILD_DATE"};
if ($given_date ne "") {
# The gecko date does not use hour resolution
chop($given_date);
chop($given_date);
printf("#define PRODUCT_VERSION \"%08d\"\n", $given_date);
exit(0);
}
# XP way of doing the build date.
# 1998091509 = 1998, September, 15th, 9am local time zone
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
# localtime returns year minus 1900
$year = $year + 1900;
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);

View File

@@ -1,64 +0,0 @@
[gecko]
#if SHARED_LIBRARY
dist/bin/components/@SHARED_LIBRARY@
#else
!staticcomp @LIBRARY@ @MODULE_NAME@
#endif
!xpt dist/bin/components/xuldoc.xpt
!xpt dist/bin/components/layout_base.xpt
!xpt dist/bin/components/layout_printing.xpt
!xpt dist/bin/components/layout_xul.xpt
!xpt dist/bin/components/content_base.xpt
!xpt dist/bin/components/content_html.xpt
!xpt dist/bin/components/content_htmldoc.xpt
!xpt dist/bin/components/content_xmldoc.xpt
!xpt dist/bin/components/content_xslt.xpt
!xpt dist/bin/components/dom.xpt
!xpt dist/bin/components/dom_base.xpt
!xpt dist/bin/components/dom_core.xpt
!xpt dist/bin/components/dom_css.xpt
!xpt dist/bin/components/dom_events.xpt
!xpt dist/bin/components/dom_html.xpt
!xpt dist/bin/components/dom_range.xpt
!xpt dist/bin/components/dom_stylesheets.xpt
!xpt dist/bin/components/dom_traversal.xpt
!xpt dist/bin/components/dom_views.xpt
!xpt dist/bin/components/dom_xbl.xpt
!xpt dist/bin/components/dom_xul.xpt
!xpt dist/bin/components/dom_xpath.xpt
!xpt dist/bin/components/jsurl.xpt
#if MOZ_XUL
!xpt dist/bin/components/xultmpl.xpt
!xpt dist/bin/components/layout_xul_tree.xpt
#endif
dist/bin/res/html.css
dist/bin/res/quirk.css
dist/bin/res/viewsource.css
dist/bin/res/forms.css
dist/bin/res/arrow.gif
dist/bin/res/arrowd.gif
dist/bin/res/ua.css
dist/bin/res/broken-image.gif
dist/bin/res/loading-image.gif
dist/bin/res/builtin/htmlBindings.xml
dist/bin/res/builtin/platformHTMLBindings.xml
dist/bin/res/html/gopher-audio.gif
dist/bin/res/html/gopher-binary.gif
dist/bin/res/html/gopher-find.gif
dist/bin/res/html/gopher-image.gif
dist/bin/res/html/gopher-menu.gif
dist/bin/res/html/gopher-movie.gif
dist/bin/res/html/gopher-sound.gif
dist/bin/res/html/gopher-telnet.gif
dist/bin/res/html/gopher-text.gif
dist/bin/res/html/gopher-unknown.gif
dist/bin/res/dtd/xhtml11.dtd
[gecko-tests]
dist/bin/bloaturls.txt
dist/bin/res/bloatcycle.html
#if ENABLE_TESTS
dist/bin/TestSpaceManager@BINS@
dist/bin/ParseCSS@BINS@
dist/bin/TestCSSPropertyLookup@BINS@
#endif

View File

@@ -1,626 +0,0 @@
/* -*- 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 Communicator client 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):
*
* 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 "nsCOMPtr.h"
#include "nsContentDLF.h"
#include "nsGenericHTMLElement.h"
#include "nsHTMLAtoms.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsICategoryManager.h"
#include "nsIDocumentLoader.h"
#include "nsIDocumentLoaderFactory.h"
#include "nsIDocument.h"
#include "nsIDocumentViewer.h"
#include "nsIHTMLContent.h"
#include "nsIURL.h"
#include "nsICSSStyleSheet.h"
#include "nsNodeInfo.h"
#include "nsNodeInfoManager.h"
#include "nsString.h"
#include "nsContentCID.h"
#include "prprf.h"
#include "nsNetUtil.h"
#include "nsICSSLoader.h"
#include "nsCRT.h"
#include "nsIViewSourceChannel.h"
#include "nsRDFCID.h"
#include "nsIRDFResource.h"
#include "imgILoader.h"
// plugins
#include "nsIPluginManager.h"
#include "nsIPluginHost.h"
static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
static NS_DEFINE_CID(kPluginDocumentCID, NS_PLUGINDOCUMENT_CID);
// URL for the "user agent" style sheet
#define UA_CSS_URL "resource://gre/res/ua.css"
// Factory code for creating variations on html documents
#undef NOISY_REGISTRY
static NS_DEFINE_IID(kHTMLDocumentCID, NS_HTMLDOCUMENT_CID);
static NS_DEFINE_IID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
#ifdef MOZ_SVG
static NS_DEFINE_IID(kSVGDocumentCID, NS_SVGDOCUMENT_CID);
#endif
static NS_DEFINE_IID(kImageDocumentCID, NS_IMAGEDOCUMENT_CID);
static NS_DEFINE_IID(kXULDocumentCID, NS_XULDOCUMENT_CID);
nsresult
NS_NewDocumentViewer(nsIDocumentViewer** aResult);
static const char* const gHTMLTypes[] = {
"text/html",
"text/plain",
"text/css",
"text/javascript",
"application/x-javascript",
#ifdef MOZ_VIEW_SOURCE
"application/x-view-source", //XXX I wish I could just use nsMimeTypes.h here
#endif
"application/xhtml+xml",
0
};
static const char* const gXMLTypes[] = {
"text/xml",
"application/xml",
0
};
#ifdef MOZ_SVG
static char* gSVGTypes[] = {
"image/svg+xml",
0
};
#endif
static const char* const gRDFTypes[] = {
"application/rdf+xml",
"text/rdf",
"application/vnd.mozilla.xul+xml",
"mozilla.application/cached-xul",
0
};
nsICSSStyleSheet* nsContentDLF::gUAStyleSheet;
nsresult
NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult)
{
NS_PRECONDITION(aResult, "null OUT ptr");
if (!aResult) {
return NS_ERROR_NULL_POINTER;
}
nsContentDLF* it = new nsContentDLF();
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aResult);
}
nsContentDLF::nsContentDLF()
{
}
nsContentDLF::~nsContentDLF()
{
}
NS_IMPL_ISUPPORTS1(nsContentDLF,
nsIDocumentLoaderFactory)
NS_IMETHODIMP
nsContentDLF::CreateInstance(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
const char* aContentType,
nsISupports* aContainer,
nsISupports* aExtraInfo,
nsIStreamListener** aDocListener,
nsIContentViewer** aDocViewer)
{
EnsureUAStyleSheet();
// Are we viewing source?
#ifdef MOZ_VIEW_SOURCE
nsCOMPtr<nsIViewSourceChannel> viewSourceChannel = do_QueryInterface(aChannel);
if (viewSourceChannel)
{
aCommand = "view-source";
// The parser freaks out when it sees the content-type that a
// view-source channel normally returns. Get the actual content
// type of the data. If it's known, use it; otherwise use
// text/plain.
nsCAutoString type;
viewSourceChannel->GetOriginalContentType(type);
PRBool knownType = PR_FALSE;
PRInt32 typeIndex;
for (typeIndex = 0; gHTMLTypes[typeIndex] && !knownType; ++typeIndex) {
if (type.Equals(gHTMLTypes[typeIndex]) &&
!type.EqualsLiteral("application/x-view-source")) {
knownType = PR_TRUE;
}
}
for (typeIndex = 0; gXMLTypes[typeIndex] && !knownType; ++typeIndex) {
if (type.Equals(gXMLTypes[typeIndex])) {
knownType = PR_TRUE;
}
}
#ifdef MOZ_SVG
for (typeIndex = 0; gSVGTypes[typeIndex] && !knownType; ++typeIndex) {
if (type.Equals(gSVGTypes[typeIndex])) {
knownType = PR_TRUE;
}
}
#endif // MOZ_SVG
for (typeIndex = 0; gRDFTypes[typeIndex] && !knownType; ++typeIndex) {
if (type.Equals(gRDFTypes[typeIndex])) {
knownType = PR_TRUE;
}
}
if (knownType) {
viewSourceChannel->SetContentType(type);
} else {
viewSourceChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
}
} else if (0 == PL_strcmp("application/x-view-source", aContentType)) {
aChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
aContentType = "text/plain";
}
#endif
// Try html
int typeIndex=0;
while(gHTMLTypes[typeIndex]) {
if (0 == PL_strcmp(gHTMLTypes[typeIndex++], aContentType)) {
return CreateDocument(aCommand,
aChannel, aLoadGroup,
aContainer, kHTMLDocumentCID,
aDocListener, aDocViewer);
}
}
// Try XML
typeIndex = 0;
while(gXMLTypes[typeIndex]) {
if (0== PL_strcmp(gXMLTypes[typeIndex++], aContentType)) {
return CreateDocument(aCommand,
aChannel, aLoadGroup,
aContainer, kXMLDocumentCID,
aDocListener, aDocViewer);
}
}
#ifdef MOZ_SVG
// Try SVG
typeIndex = 0;
while(gSVGTypes[typeIndex]) {
if (!PL_strcmp(gSVGTypes[typeIndex++], aContentType)) {
return CreateDocument(aCommand,
aChannel, aLoadGroup,
aContainer, kSVGDocumentCID,
aDocListener, aDocViewer);
}
}
#endif
// Try RDF
typeIndex = 0;
while (gRDFTypes[typeIndex]) {
if (0 == PL_strcmp(gRDFTypes[typeIndex++], aContentType)) {
return CreateRDFDocument(aCommand,
aChannel, aLoadGroup,
aContentType, aContainer,
aExtraInfo, aDocListener, aDocViewer);
}
}
// Try image types
nsCOMPtr<imgILoader> loader(do_GetService("@mozilla.org/image/loader;1"));
PRBool isReg = PR_FALSE;
loader->SupportImageWithMimeType(aContentType, &isReg);
if (isReg) {
return CreateDocument(aCommand,
aChannel, aLoadGroup,
aContainer, kImageDocumentCID,
aDocListener, aDocViewer);
}
nsCOMPtr<nsIPluginHost> ph (do_GetService(kPluginManagerCID));
if(ph && NS_SUCCEEDED(ph->IsPluginEnabledForType(aContentType))) {
return CreateDocument(aCommand,
aChannel, aLoadGroup,
aContainer, kPluginDocumentCID,
aDocListener, aDocViewer);
}
// If we get here, then we weren't able to create anything. Sorry!
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsContentDLF::CreateInstanceForDocument(nsISupports* aContainer,
nsIDocument* aDocument,
const char *aCommand,
nsIContentViewer** aDocViewerResult)
{
nsresult rv = NS_ERROR_FAILURE;
EnsureUAStyleSheet();
do {
nsCOMPtr<nsIDocumentViewer> docv;
rv = NS_NewDocumentViewer(getter_AddRefs(docv));
if (NS_FAILED(rv))
break;
docv->SetUAStyleSheet(NS_STATIC_CAST(nsIStyleSheet*, gUAStyleSheet));
// Bind the document to the Content Viewer
nsIContentViewer* cv = NS_STATIC_CAST(nsIContentViewer*, docv.get());
rv = cv->LoadStart(aDocument);
NS_ADDREF(*aDocViewerResult = cv);
} while (PR_FALSE);
return rv;
}
NS_IMETHODIMP
nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup, nsIDocument **aDocument)
{
*aDocument = nsnull;
nsresult rv = NS_ERROR_FAILURE;
// create a new blank HTML document
nsCOMPtr<nsIDocument> blankDoc(do_CreateInstance(kHTMLDocumentCID));
if (blankDoc) {
// initialize
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:blank"));
if (uri) {
blankDoc->ResetToURI(uri, aLoadGroup);
rv = NS_OK;
}
}
// add some simple content structure
if (NS_SUCCEEDED(rv)) {
rv = NS_ERROR_FAILURE;
nsNodeInfoManager *nim = blankDoc->NodeInfoManager();
nsCOMPtr<nsINodeInfo> htmlNodeInfo;
// generate an html html element
nim->GetNodeInfo(nsHTMLAtoms::html, 0, kNameSpaceID_None,
getter_AddRefs(htmlNodeInfo));
nsCOMPtr<nsIHTMLContent> htmlElement =
NS_NewHTMLHtmlElement(htmlNodeInfo);
// generate an html head element
nim->GetNodeInfo(nsHTMLAtoms::head, 0, kNameSpaceID_None,
getter_AddRefs(htmlNodeInfo));
nsCOMPtr<nsIHTMLContent> headElement =
NS_NewHTMLHeadElement(htmlNodeInfo);
// generate an html body element
nim->GetNodeInfo(nsHTMLAtoms::body, 0, kNameSpaceID_None,
getter_AddRefs(htmlNodeInfo));
nsCOMPtr<nsIHTMLContent> bodyElement =
NS_NewHTMLBodyElement(htmlNodeInfo);
// blat in the structure
if (htmlElement && headElement && bodyElement) {
htmlElement->SetDocument(blankDoc, PR_FALSE, PR_TRUE);
blankDoc->SetRootContent(htmlElement);
htmlElement->AppendChildTo(headElement, PR_FALSE, PR_FALSE);
bodyElement->SetContentID(blankDoc->GetAndIncrementContentID());
htmlElement->AppendChildTo(bodyElement, PR_FALSE, PR_FALSE);
rv = NS_OK;
}
}
// add a nice bow
if (NS_SUCCEEDED(rv)) {
*aDocument = blankDoc;
NS_ADDREF(*aDocument);
}
return rv;
}
nsresult
nsContentDLF::CreateDocument(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
const nsCID& aDocumentCID,
nsIStreamListener** aDocListener,
nsIContentViewer** aDocViewer)
{
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> aURL;
rv = aChannel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
#ifdef NOISY_CREATE_DOC
if (nsnull != aURL) {
nsAutoString tmp;
aURL->ToString(tmp);
fputs(NS_LossyConvertUCS2toASCII(tmp).get(), stdout);
printf(": creating document\n");
}
#endif
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIDocumentViewer> docv;
do {
// Create the document
doc = do_CreateInstance(aDocumentCID, &rv);
if (NS_FAILED(rv))
break;
// Create the document viewer XXX: could reuse document viewer here!
rv = NS_NewDocumentViewer(getter_AddRefs(docv));
if (NS_FAILED(rv))
break;
docv->SetUAStyleSheet(gUAStyleSheet);
doc->SetContainer(aContainer);
// Initialize the document to begin loading the data. An
// nsIStreamListener connected to the parser is returned in
// aDocListener.
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, PR_TRUE);
if (NS_FAILED(rv))
break;
// Bind the document to the Content Viewer
rv = docv->LoadStart(doc);
*aDocViewer = docv;
NS_IF_ADDREF(*aDocViewer);
} while (PR_FALSE);
return rv;
}
// ...common work for |CreateRDFDocument| and |CreateXULDocumentFromStream|
nsresult
nsContentDLF::CreateRDFDocument(nsISupports* aExtraInfo,
nsCOMPtr<nsIDocument>* doc,
nsCOMPtr<nsIDocumentViewer>* docv)
{
nsresult rv = NS_ERROR_FAILURE;
// Create the XUL document
*doc = do_CreateInstance(kXULDocumentCID, &rv);
if (NS_FAILED(rv)) return rv;
// Create the image content viewer...
rv = NS_NewDocumentViewer(getter_AddRefs(*docv));
if (NS_FAILED(rv)) return rv;
// Load the UA style sheet if we haven't already done that
(*docv)->SetUAStyleSheet(gUAStyleSheet);
return NS_OK;
}
// ...note, this RDF document _may_ be XUL :-)
nsresult
nsContentDLF::CreateRDFDocument(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
const char* aContentType,
nsISupports* aContainer,
nsISupports* aExtraInfo,
nsIStreamListener** aDocListener,
nsIContentViewer** aDocViewer)
{
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIDocumentViewer> docv;
nsresult rv = CreateRDFDocument(aExtraInfo, address_of(doc), address_of(docv));
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIURI> aURL;
rv = aChannel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
/*
* Initialize the document to begin loading the data...
*
* An nsIStreamListener connected to the parser is returned in
* aDocListener.
*/
doc->SetContainer(aContainer);
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
/*
* Bind the document to the Content Viewer...
*/
rv = docv->LoadStart(doc);
*aDocViewer = docv;
NS_IF_ADDREF(*aDocViewer);
}
return rv;
}
static nsresult
RegisterTypes(nsICategoryManager* aCatMgr,
const char* const* aTypes)
{
nsresult rv = NS_OK;
while (*aTypes) {
const char* contentType = *aTypes++;
#ifdef NOISY_REGISTRY
printf("Register %s => %s\n", contractid, aPath);
#endif
// add the MIME types layout can handle to the handlers category.
// this allows users of layout's viewers (the docshell for example)
// to query the types of viewers layout can create.
rv = aCatMgr->AddCategoryEntry("Gecko-Content-Viewers", contentType,
"@mozilla.org/content/document-loader-factory;1",
PR_TRUE, PR_TRUE, nsnull);
if (NS_FAILED(rv)) break;
}
return rv;
}
static nsresult UnregisterTypes(nsICategoryManager* aCatMgr,
const char* const* aTypes)
{
nsresult rv = NS_OK;
while (*aTypes) {
const char* contentType = *aTypes++;
rv = aCatMgr->DeleteCategoryEntry("Gecko-Content-Viewers", contentType, PR_TRUE);
if (NS_FAILED(rv)) break;
}
return rv;
}
NS_IMETHODIMP
nsContentDLF::RegisterDocumentFactories(nsIComponentManager* aCompMgr,
nsIFile* aPath,
const char *aLocation,
const char *aType,
const nsModuleComponentInfo* aInfo)
{
nsresult rv;
nsCOMPtr<nsICategoryManager> catmgr(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
do {
rv = RegisterTypes(catmgr, gHTMLTypes);
if (NS_FAILED(rv))
break;
rv = RegisterTypes(catmgr, gXMLTypes);
if (NS_FAILED(rv))
break;
#ifdef MOZ_SVG
rv = RegisterTypes(catmgr, gSVGTypes);
if (NS_FAILED(rv))
break;
#endif
rv = RegisterTypes(catmgr, gRDFTypes);
if (NS_FAILED(rv))
break;
} while (PR_FALSE);
return rv;
}
NS_IMETHODIMP
nsContentDLF::UnregisterDocumentFactories(nsIComponentManager* aCompMgr,
nsIFile* aPath,
const char* aRegistryLocation,
const nsModuleComponentInfo* aInfo)
{
nsresult rv;
nsCOMPtr<nsICategoryManager> catmgr(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
do {
rv = UnregisterTypes(catmgr, gHTMLTypes);
if (NS_FAILED(rv))
break;
rv = UnregisterTypes(catmgr, gXMLTypes);
if (NS_FAILED(rv))
break;
#ifdef MOZ_SVG
rv = UnregisterTypes(catmgr, gSVGTypes);
if (NS_FAILED(rv))
break;
#endif
rv = UnregisterTypes(catmgr, gRDFTypes);
if (NS_FAILED(rv))
break;
} while (PR_FALSE);
return rv;
}
/* static */ nsresult
nsContentDLF::EnsureUAStyleSheet()
{
if (gUAStyleSheet)
return NS_OK;
// Load the UA style sheet
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING(UA_CSS_URL));
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}
nsCOMPtr<nsICSSLoader> cssLoader;
NS_NewCSSLoader(getter_AddRefs(cssLoader));
if (!cssLoader)
return NS_ERROR_OUT_OF_MEMORY;
rv = cssLoader->LoadAgentSheet(uri, &gUAStyleSheet);
#ifdef DEBUG
if (NS_FAILED(rv))
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}

View File

@@ -1,111 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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) 2000
* 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 nsContentDLF_h__
#define nsContentDLF_h__
#include "nsIDocumentLoaderFactory.h"
#include "nsIDocumentViewer.h"
#include "nsIDocument.h"
class nsICSSStyleSheet;
class nsIChannel;
class nsIComponentManager;
class nsIContentViewer;
class nsIDocumentViewer;
class nsIFile;
class nsIInputStream;
class nsILoadGroup;
class nsIStreamListener;
struct nsModuleComponentInfo;
class nsContentDLF : public nsIDocumentLoaderFactory
{
public:
nsContentDLF();
virtual ~nsContentDLF();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOCUMENTLOADERFACTORY
nsresult InitUAStyleSheet();
nsresult CreateDocument(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
const nsCID& aDocumentCID,
nsIStreamListener** aDocListener,
nsIContentViewer** aDocViewer);
nsresult CreateRDFDocument(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
const char* aContentType,
nsISupports* aContainer,
nsISupports* aExtraInfo,
nsIStreamListener** aDocListener,
nsIContentViewer** aDocViewer);
nsresult CreateRDFDocument(nsISupports*,
nsCOMPtr<nsIDocument>*,
nsCOMPtr<nsIDocumentViewer>*);
static nsICSSStyleSheet* gUAStyleSheet;
static NS_IMETHODIMP
RegisterDocumentFactories(nsIComponentManager* aCompMgr,
nsIFile* aPath,
const char *aLocation,
const char *aType,
const nsModuleComponentInfo* aInfo);
static NS_IMETHODIMP
UnregisterDocumentFactories(nsIComponentManager* aCompMgr,
nsIFile* aPath,
const char* aRegistryLocation,
const nsModuleComponentInfo* aInfo);
private:
static nsresult EnsureUAStyleSheet();
};
nsresult
NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
#endif

View File

@@ -1,113 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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 Communicator client 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):
* Alec Flett <alecf@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 ***** */
#include "nsIServiceManager.h"
#include "nsICategoryManager.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsCRT.h"
#include "nsContentHTTPStartup.h"
#include "nsIHttpProtocolHandler.h"
#include "gbdate.h"
#define PRODUCT_NAME "Gecko"
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
nsresult
nsContentHTTPStartup::Observe( nsISupports *aSubject,
const char *aTopic,
const PRUnichar *aData)
{
if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0)
return NS_OK;
nsresult rv = nsnull;
nsCOMPtr<nsIHttpProtocolHandler> http(do_QueryInterface(aSubject));
if (NS_FAILED(rv)) return rv;
rv = http->SetProduct(NS_LITERAL_CSTRING(PRODUCT_NAME));
if (NS_FAILED(rv)) return rv;
rv = http->SetProductSub(NS_LITERAL_CSTRING(PRODUCT_VERSION));
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsresult
nsContentHTTPStartup::RegisterHTTPStartup(nsIComponentManager* aCompMgr,
nsIFile* aPath,
const char* aRegistryLocation,
const char* aComponentType,
const nsModuleComponentInfo* aInfo)
{
nsresult rv;
nsCOMPtr<nsICategoryManager>
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString previousEntry;
rv = catMan->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY,
"Content UserAgent Setter",
NS_CONTENTHTTPSTARTUP_CONTRACTID,
PR_TRUE, PR_TRUE,
getter_Copies(previousEntry));
return rv;
}
nsresult
nsContentHTTPStartup::UnregisterHTTPStartup(nsIComponentManager* aCompMgr,
nsIFile* aPath,
const char* aRegistryLocation,
const nsModuleComponentInfo* aInfo)
{
nsresult rv;
nsCOMPtr<nsICategoryManager>
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
return NS_OK;
}

View File

@@ -1,78 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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 Communicator client 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):
* Alec Flett <alecf@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 ***** */
#include "nsIObserver.h"
#define NS_CONTENTHTTPSTARTUP_CONTRACTID \
"@mozilla.org/content/http-startup;1"
/* c2f6ef7e-afd5-4be4-a1f5-c824efa4231b */
#define NS_CONTENTHTTPSTARTUP_CID \
{ 0xc2f6ef7e, 0xafd5, 0x4be4, \
{0xa1, 0xf5, 0xc8, 0x24, 0xef, 0xa4, 0x23, 0x1b} }
struct nsModuleComponentInfo;
class nsIFile;
class nsContentHTTPStartup : public nsIObserver
{
public:
nsContentHTTPStartup() { }
virtual ~nsContentHTTPStartup() {}
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
public:
static NS_IMETHODIMP
RegisterHTTPStartup(nsIComponentManager* aCompMgr,
nsIFile* aPath,
const char* aRegistryLocation,
const char* aComponentType,
const nsModuleComponentInfo* aInfo);
static NS_IMETHODIMP
UnregisterHTTPStartup(nsIComponentManager* aCompMgr,
nsIFile* aPath,
const char* aRegistryLocation,
const nsModuleComponentInfo* aInfo);
private:
nsresult setUserAgent();
};

View File

@@ -1,246 +0,0 @@
/* -*- 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
* 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 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 nsLayoutCID_h__
#define nsLayoutCID_h__
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
// {1691E1F4-EE41-11d4-9885-00C04FA0CF4B}
#define NS_FRAMETRAVERSAL_CID \
{ 0x1691e1f4, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
/* a6cf90fa-15b3-11d2-932e-00805f8add32 */
#define NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID \
{ 0xa6cf90fa, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
/* a6cf90f9-15b3-11d2-932e-00805f8add32 */
#define NS_LAYOUT_DEBUGGER_CID \
{ 0xa6cf90f9, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
#define NS_HTMLDOCUMENT_CID \
{ /* 5d0fcdd0-4daa-11d2-b328-00805f8a3859 */ \
0x5d0fcdd0, 0x4daa, 0x11d2, \
{0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
#define NS_XMLDOCUMENT_CID \
{ /* a6cf9063-15b3-11d2-932e-00805f8add32 */ \
0xa6cf9063, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
#define NS_IMAGEDOCUMENT_CID \
{ /* e11a6080-4daa-11d2-b328-00805f8a3859 */ \
0xe11a6080, 0x4daa, 0x11d2, \
{0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
#define NS_HTMLIMAGEELEMENT_CID \
{ /* d6008c40-4dad-11d2-b328-00805f8a3859 */ \
0xd6008c40, 0x4dad, 0x11d2, \
{0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
#define NS_HTMLOPTIONELEMENT_CID \
{ /* a6cf90f5-15b3-11d2-932e-00805f8add32 */ \
0xa6cf90f5, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
#define NS_NAMESPACEMANAGER_CID \
{ /* d9783472-8fe9-11d2-9d3c-0060088f9ff7 */ \
0xd9783472, 0x8fe9, 0x11d2, \
{0x9d, 0x3c, 0x00, 0x60, 0x08, 0x8f, 0x9f, 0xf7}}
/* a6cf90d7-15b3-11d2-932e-00805f8add32 */
#define NS_FRAME_UTIL_CID \
{ 0xa6cf90d5, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
// XXX This should really be factored into a style-specific DLL so
// that all the HTML, generic layout, and style stuff isn't munged
// together.
// {2E363D60-872E-11d2-B531-000000000000}
#define NS_CSSPARSER_CID \
{ 0x2e363d60, 0x872e, 0x11d2, { 0xb5, 0x31, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
// {E6FD9940-899D-11d2-8EAE-00805F29F370}
#define NS_PRESSHELL_CID \
{ 0xe6fd9940, 0x899d, 0x11d2, { 0x8e, 0xae, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {A1FDE861-E802-11d4-9885-00C04FA0CF4B}
#define NS_PRESSTATE_CID \
{ 0xa1fde861, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
// {95F46161-D177-11d2-BF86-00105A1B0627}
#define NS_HTML_CSS_STYLESHEET_CID \
{ 0x95f46161, 0xd177, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
// {eaca2576-0d4a-11d3-9d7e-0060088f9ff7}
#define NS_CSS_LOADER_CID \
{ 0xeaca2576, 0x0d4a, 0x11d3, { 0x9d, 0x7e, 0x00, 0x60, 0x08, 0x8f, 0x9f, 0xf7 } }
// {96882B72-8A27-11d2-8EAF-00805F29F370}
#define NS_SELECTION_CID \
{ 0x96882b72, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
#define NS_FRAMESELECTION_CID \
{/* {905F80F1-8A7B-11d2-918C-0080C8E44DB5}*/ \
0x905f80f1, 0x8a7b, 0x11d2, { 0x91, 0x8c, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } }
#define NS_DOMSELECTION_CID \
{/* {C87A37FC-8109-4ce2-A322-8CDEC925379F}*/ \
0xc87a37fc, 0x8109, 0x4ce2, { 0xa3, 0x22, 0x8c, 0xde, 0xc9, 0x25, 0x37, 0x9f } }
#define NS_RANGE_CID \
{/* {56AD2981-8A87-11d2-918C-0080C8E44DB5}*/ \
0x56ad2981, 0x8a87, 0x11d2, { 0x91, 0x8c, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } }
#define NS_CONTENTITERATOR_CID \
{/* {a6cf90e3-15b3-11d2-932e-00805f8add32}*/ \
0xa6cf90e3, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
#define NS_GENERATEDSUBTREEITERATOR_CID \
{/* {9A45253B-EB8F-49f1-B925-E9EA90D3EB3A}*/ \
0x9a45253b, 0xeb8f, 0x49f1, { 0xb9, 0x25, 0xe9, 0xea, 0x90, 0xd3, 0xeb, 0x3a } }
#define NS_GENERATEDCONTENTITERATOR_CID \
{/* {A364930F-E353-49f1-AC69-91637EB8B757}*/ \
0xa364930f, 0xe353, 0x49f1, { 0xac, 0x69, 0x91, 0x63, 0x7e, 0xb8, 0xb7, 0x57 } }
#define NS_SUBTREEITERATOR_CID \
{/* {a6cf90e5-15b3-11d2-932e-00805f8add32}*/ \
0xa6cf90e5, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
// {64F300A1-C88C-11d3-97FB-00400553EEF0}
#define NS_XBLSERVICE_CID \
{ 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
// {15671AF5-39F9-4c70-8CE3-72C97111B52D}
#define NS_BINDINGMANAGER_CID \
{ 0x15671af5, 0x39f9, 0x4c70, { 0x8c, 0xe3, 0x72, 0xc9, 0x71, 0x11, 0xb5, 0x2d } }
// {D750A964-2D14-484c-B3AA-8ED7823B5C7B}
#define NS_BOXOBJECT_CID \
{ 0xd750a964, 0x2d14, 0x484c, { 0xb3, 0xaa, 0x8e, 0xd7, 0x82, 0x3b, 0x5c, 0x7b } }
// {C2710D40-6F4D-4b7f-9778-76AE5166648C}
#define NS_LISTBOXOBJECT_CID \
{ 0xc2710d40, 0x6f4d, 0x4b7f, { 0x97, 0x78, 0x76, 0xae, 0x51, 0x66, 0x64, 0x8c } }
// {56E2ADA8-4631-11d4-BA11-001083023C1E}
#define NS_SCROLLBOXOBJECT_CID \
{ 0x56e2ada8, 0x4631, 0x11d4, { 0xba, 0x11, 0x0, 0x10, 0x83, 0x2, 0x3c, 0x1e } }
// {AA40253B-4C42-4056-8132-37BCD07862FD}
#define NS_MENUBOXOBJECT_CID \
{ 0xaa40253b, 0x4c42, 0x4056, { 0x81, 0x32, 0x37, 0xbc, 0xd0, 0x78, 0x62, 0xfd } }
// {6C392C62-1AB1-4de7-BFC6-ED4F9FC7749A}
#define NS_POPUPBOXOBJECT_CID \
{ 0x6c392c62, 0x1ab1, 0x4de7, { 0xbf, 0xc6, 0xed, 0x4f, 0x9f, 0xc7, 0x74, 0x9a } }
// {31246420-A2F7-4933-AE71-79BBD5D94B04}
#define NS_BROWSERBOXOBJECT_CID \
{ 0x31246420, 0xa2f7, 0x4933, { 0xae, 0x71, 0x79, 0xbb, 0xd5, 0xd9, 0x4b, 0x4 } }
// {8852AB1F-0AA2-46ef-A147-A908896E0D0B}
#define NS_EDITORBOXOBJECT_CID \
{ 0x8852ab1f, 0xaa2, 0x46ef, { 0xa1, 0x47, 0xa9, 0x8, 0x89, 0x6e, 0xd, 0xb } }
// {9580E69B-8FD6-414e-80CD-3A1821017646}
#define NS_IFRAMEBOXOBJECT_CID \
{ 0x9580e69b, 0x8fd6, 0x414e, { 0x80, 0xcd, 0x3a, 0x18, 0x21, 0x1, 0x76, 0x46 } }
// {3B581FD4-3497-426c-8F61-3658B971CB80}
#define NS_TREEBOXOBJECT_CID \
{ 0x3b581fd4, 0x3497, 0x426c, { 0x8f, 0x61, 0x36, 0x58, 0xb9, 0x71, 0xcb, 0x80 } }
// {8775CA39-4072-4cc0-92D3-A7C2B820089C}
#define NS_AUTOCOPYSERVICE_CID \
{ 0x8775ca39, 0x4072, 0x4cc0, { 0x92, 0xd3, 0xa7, 0xc2, 0xb8, 0x20, 0x8, 0x9c } }
// 3a9cd622-264d-11d4-ba06-0060b0fc76dd
#define NS_DOM_IMPLEMENTATION_CID \
{ 0x3a9cd622, 0x264d, 0x11d4, {0xba, 0x06, 0x00, 0x60, 0xb0, 0xfc, 0x76, 0xdd } }
// {AE52FE52-683A-437D-B661-DE55F4E0A873}
#define NS_NODEINFOMANAGER_CID \
{ 0xae52fe52, 0x683a, 0x437d, { 0xb6, 0x61, 0xde, 0x55, 0xf4, 0xe0, 0xa8, 0x73 } }
// {ECEA1B28-AE54-4047-8BBE-C624235106B4}
#define NS_COMPUTEDDOMSTYLE_CID \
{ 0xecea1b28, 0xae54, 0x4047, { 0x8b, 0xbe, 0xc6, 0x24, 0x23, 0x51, 0x06, 0xb4 } }
// {4aef38b7-6364-4e23-a5e7-12f837fbbd9c}
#define NS_XMLCONTENTSERIALIZER_CID \
{ 0x4aef38b7, 0x6364, 0x4e23, { 0xa5, 0xe7, 0x12, 0xf8, 0x37, 0xfb, 0xbd, 0x9c } }
// {9d3f70da-86e9-11d4-95ec-00b0d03e37b7}
#define NS_HTMLCONTENTSERIALIZER_CID \
{ 0x9d3f70da, 0x86e9, 0x11d4, { 0x95, 0xec, 0x00, 0xb0, 0xd0, 0x3e, 0x37, 0xb7 } }
// {6030f7ef-32ed-46a7-9a63-6a5d3f90445f}
#define NS_PLAINTEXTSERIALIZER_CID \
{ 0x6030f7ef, 0x32ed, 0x46a7, { 0x9a, 0x63, 0x6a, 0x5d, 0x3f, 0x90, 0x44, 0x5f } }
// {5C5AF390-34BE-11d5-A03B-0010A4EF48C9}
#define NS_LAYOUT_HISTORY_STATE_CID \
{ 0x5c5af390, 0x34be, 0x11d5, { 0xa0, 0x3b, 0x00, 0x10, 0xa4, 0xef, 0x48, 0xc9 } }
// {9d1001b1-e59a-456b-99dc-cc3f1283236e}
#define NS_SELECTIONIMAGESERVICE_CID \
{ 0x9d1001b1, 0xe59a, 0x456b, { 0x99, 0xdc, 0xcc, 0x3f, 0x12, 0x83, 0x23, 0x6e } }
// {E14B66F6-BFC5-11d2-B57E-00105AA83B2F}
#define NS_CARET_CID \
{ 0xe14b66f6, 0xbfc5, 0x11d2, { 0xb5, 0x7e, 0x0, 0x10, 0x5a, 0xa8, 0x3b, 0x2f } }
// {f96f5ec9-755b-447e-b1f3-717d1a84bb41}
#define NS_PLUGINDOCUMENT_CID \
{ 0xf96f5ec9, 0x755b, 0x447e, { 0xb1, 0xf3, 0x71, 0x7d, 0x1a, 0x84, 0xbb, 0x41 } }
#ifdef MOZ_ENABLE_CAIRO
// {ba9112c9-10bf-40c7-98b9-315c86e2d99d}
#define NS_CANVASBOXOBJECT_CID \
{ 0xba9112c9, 0x10bf, 0x40c7, { 0x98, 0xb9, 0x31, 0x5c, 0x86, 0xe2, 0xd9, 0x9d } }
// {a35d1cd4-c505-4d2d-a0f9-aef00b7ce5a5}
#define NS_CANVASRENDERINGCONTEXT2D_CID \
{ 0xa35d1cd4, 0xc505, 0x4d2d, { 0xa0, 0xf9, 0xae, 0xf0, 0x0b, 0x7c, 0xe5, 0xa5 } }
#endif /* MOZ_ENABLE_CAIRO */
#endif /* nsLayoutCID_h__ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,739 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Detailed Design Template</title>
</head>
<body>
<h1><font color="#cc0000">Gecko Layout Detailed Design Document</font></h1>
<h1>Space Manger Detailed Design</h1>
<h2>Overview</h2>
<p>
The Space Manager and related classes and structures are an important of
the Gecko Layout system, specifically Block Layout. &nbsp;See the High Level
Design document for an overview of the Space Manager, and as an introduction
to the classes, structures and algorithms container in this, the Detailed
Design Document.
</p>
<hr width="100%" size="2">
<h2>nsSpaceManager</h2>
<p>
The Space Manger is the central class is a group of classes that manage
the occupied and available space that exists in horizontal bands across
a canvas. &nbsp;The primary goal of the Space Manager is to provide information
about those bands of space to support the CSS notion of floated elements.
</p>
<p>
There are three important parts to the Space Manger API: the parts that
deal with the coordinate space of the Space Manager, the parts that deal with
the regions managed by the Space Manager, and the parts that manage float
impact intervals.
</p>
<p>
The class nsSpaceManager is declared in the file <a href="http://lxr.mozilla.org/seamonkey/source/layout/base/src/nsSpaceManager.h">
nsSpaceManger.h</a>
. &nbsp;The class is only used in the layout module and cannot be exported
outside of that module (nor does it need to be). &nbsp;It is not a general
purpose class, and is not intended to be subclasses<font color="#cc0000">
.</font>
</p>
<p>
Here is the class declaration, taken from the source file as of 01.08.02
</p>
<pre>/**
* Class for dealing with bands of available space. The space manager
* defines a coordinate space with an origin at (0, 0) that grows down
* and to the right.
*/
class nsSpaceManager {
public:
nsSpaceManager(nsIPresShell* aPresShell, nsIFrame* aFrame);
~nsSpaceManager();
void* operator new(size_t aSize);
void operator delete(void* aPtr, size_t aSize);
static void Shutdown();
/*
* Get the frame that's associated with the space manager. This frame
* created the space manager, and the world coordinate space is
* relative to this frame.
*
* You can use QueryInterface() on this frame to get any additional
* interfaces.
*/
nsIFrame* GetFrame() const { return mFrame; }
/**
* Translate the current origin by the specified (dx, dy). This
* creates a new local coordinate space relative to the current
* coordinate space.
*/
void Translate(nscoord aDx, nscoord aDy) { mX += aDx; mY += aDy; }
/**
* Returns the current translation from local coordinate space to
* world coordinate space. This represents the accumulated calls to
* Translate().
*/
void GetTranslation(nscoord&amp; aX, nscoord&amp; aY) const { aX = mX; aY = mY; }
/**
* Returns the y-most of the bottommost band or 0 if there are no bands.
*
* @return PR_TRUE if there are bands and PR_FALSE if there are no bands
*/
PRBool YMost(nscoord&amp; aYMost) const;
/**
* Returns a band starting at the specified y-offset. The band data
* indicates which parts of the band are available, and which parts
* are unavailable
*
* The band data that is returned is in the coordinate space of the
* local coordinate system.
*
* The local coordinate space origin, the y-offset, and the max size
* describe a rectangle that's used to clip the underlying band of
* available space, i.e.
* {0, aYOffset, aMaxSize.width, aMaxSize.height} in the local
* coordinate space
*
* @param aYOffset the y-offset of where the band begins. The coordinate is
* relative to the upper-left corner of the local coordinate space
* @param aMaxSize the size to use to constrain the band data
* @param aBandData [in,out] used to return the list of trapezoids that
* describe the available space and the unavailable space
* @return NS_OK if successful and NS_ERROR_FAILURE if the band data is not
* not large enough. The 'count' member of the band data struct
* indicates how large the array of trapezoids needs to be
*/
nsresult GetBandData(nscoord aYOffset,
const nsSize&amp; aMaxSize,
nsBandData&amp; aBandData) const;
/**
* Add a rectangular region of unavailable space. The space is
* relative to the local coordinate system.
*
* The region is tagged with a frame
*
* @param aFrame the frame used to identify the region. Must not be NULL
* @param aUnavailableSpace the bounding rect of the unavailable space
* @return NS_OK if successful
* NS_ERROR_FAILURE if there is already a region tagged with aFrame
*/
nsresult AddRectRegion(nsIFrame* aFrame,
const nsRect&amp; aUnavailableSpace);
/**
* Resize the rectangular region associated with aFrame by the specified
* deltas. The height change always applies to the bottom edge or the existing
* rect. You specify whether the width change applies to the left or right edge
*
* Returns NS_OK if successful, NS_ERROR_INVALID_ARG if there is no region
* tagged with aFrame
*/
enum AffectedEdge {LeftEdge, RightEdge};
nsresult ResizeRectRegion(nsIFrame* aFrame,
nscoord aDeltaWidth,
nscoord aDeltaHeight,
AffectedEdge aEdge = RightEdge);
/**
* Offset the region associated with aFrame by the specified amount.
*
* Returns NS_OK if successful, NS_ERROR_INVALID_ARG if there is no region
* tagged with aFrame
*/
nsresult OffsetRegion(nsIFrame* aFrame, nscoord dx, nscoord dy);
/**
* Remove the region associated with aFrane.
*
* Returns NS_OK if successful and NS_ERROR_INVALID_ARG if there is no region
* tagged with aFrame
*/
nsresult RemoveRegion(nsIFrame* aFrame);
/**
* Clears the list of regions representing the unavailable space.
*/
void ClearRegions();
/**
* Methods for dealing with the propagation of float damage during
* reflow.
*/
PRBool HasFloatDamage()
{
return !mFloatDamage.IsEmpty();
}
void IncludeInDamage(nscoord aIntervalBegin, nscoord aIntervalEnd)
{
mFloatDamage.IncludeInterval(aIntervalBegin + mY, aIntervalEnd + mY);
}
PRBool IntersectsDamage(nscoord aIntervalBegin, nscoord aIntervalEnd)
{
return mFloatDamage.Intersects(aIntervalBegin + mY, aIntervalEnd + mY);
}
#ifdef DEBUG
/**
* Dump the state of the spacemanager out to a file
*/
nsresult List(FILE* out);
void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
#endif
private:
// Structure that maintains information about the region associated
// with a particular frame
struct FrameInfo {
nsIFrame* const mFrame;
nsRect mRect; // rectangular region
FrameInfo* mNext;
FrameInfo(nsIFrame* aFrame, const nsRect&amp; aRect);
#ifdef NS_BUILD_REFCNT_LOGGING
~FrameInfo();
#endif
};
// Doubly linked list of band rects
struct BandRect : PRCListStr {
nscoord mLeft, mTop;
nscoord mRight, mBottom;
PRIntn mNumFrames; // number of frames occupying this rect
union {
nsIFrame* mFrame; // single frame occupying the space
nsVoidArray* mFrames; // list of frames occupying the space
};
BandRect(nscoord aLeft, nscoord aTop,
nscoord aRight, nscoord aBottom,
nsIFrame*);
BandRect(nscoord aLeft, nscoord aTop,
nscoord aRight, nscoord aBottom,
nsVoidArray*);
~BandRect();
// List operations
BandRect* Next() const {return (BandRect*)PR_NEXT_LINK(this);}
BandRect* Prev() const {return (BandRect*)PR_PREV_LINK(this);}
void InsertBefore(BandRect* aBandRect) {PR_INSERT_BEFORE(aBandRect, this);}
void InsertAfter(BandRect* aBandRect) {PR_INSERT_AFTER(aBandRect, this);}
void Remove() {PR_REMOVE_LINK(this);}
// Split the band rect into two vertically, with this band rect becoming
// the top part, and a new band rect being allocated and returned for the
// bottom part
//
// Does not insert the new band rect into the linked list
BandRect* SplitVertically(nscoord aBottom);
// Split the band rect into two horizontally, with this band rect becoming
// the left part, and a new band rect being allocated and returned for the
// right part
//
// Does not insert the new band rect into the linked list
BandRect* SplitHorizontally(nscoord aRight);
// Accessor functions
PRBool IsOccupiedBy(const nsIFrame*) const;
void AddFrame(const nsIFrame*);
void RemoveFrame(const nsIFrame*);
PRBool HasSameFrameList(const BandRect* aBandRect) const;
PRInt32 Length() const;
};
// Circular linked list of band rects
struct BandList : BandRect {
BandList();
// Accessors
PRBool IsEmpty() const {return PR_CLIST_IS_EMPTY((PRCListStr*)this);}
BandRect* Head() const {return (BandRect*)PR_LIST_HEAD(this);}
BandRect* Tail() const {return (BandRect*)PR_LIST_TAIL(this);}
// Operations
void Append(BandRect* aBandRect) {PR_APPEND_LINK(aBandRect, this);}
// Remove and delete all the band rects in the list
void Clear();
};
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);
FrameInfo* CreateFrameInfo(nsIFrame* aFrame, const nsRect&amp; aRect);
void DestroyFrameInfo(FrameInfo*);
void ClearFrameInfo();
void ClearBandRects();
BandRect* GetNextBand(const BandRect* aBandRect) const;
void DivideBand(BandRect* aBand, nscoord aBottom);
PRBool CanJoinBands(BandRect* aBand, BandRect* aPrevBand);
PRBool JoinBands(BandRect* aBand, BandRect* aPrevBand);
void AddRectToBand(BandRect* aBand, BandRect* aBandRect);
void InsertBandRect(BandRect* aBandRect);
nsresult GetBandAvailableSpace(const BandRect* aBand,
nscoord aY,
const nsSize&amp; aMaxSize,
nsBandData&amp; aAvailableSpace) const;
nsIFrame* const mFrame; // frame associated with the space manager
nscoord mX, mY; // translation from local to global coordinate space
BandList mBandList; // header/sentinel for circular linked list of band rects
FrameInfo* mFrameInfoMap;
nsIntervalSet mFloatDamage;
static PRInt32 sCachedSpaceManagerCount;
static void* sCachedSpaceManagers[NS_SPACE_MANAGER_CACHE_SIZE];
nsSpaceManager(const nsSpaceManager&amp;); // no implementation
void operator=(const nsSpaceManager&amp;); // no implementation
};
</pre>
<h3>Public API</h3>
<h4>Life Cycle:</h4>
<p>
The Constructor requires a Presentation Shell, used for arena allocations
mostly, and a frame that this Space Manager is rooted on. &nbsp;The coordinate
space of this Space Manger is relative to the frame passed in to the constructor.
</p>
<pre> nsSpaceManager(nsIPresShell* aPresShell, nsIFrame* aFrame);
~nsSpaceManager();
</pre>
<p>
Operators 'new' and 'delete' are overridden to support a recycler. &nbsp;Space
Manager instances come and go pretty frequently, and this recycler prevents
excessive heap allocations and the performance penalties associated with
it. The #define NS_SPACE_MANAGER_CACHE_SIZE is used to control the number
of Space Manager instances that can be present in the recycler, currently
4. &nbsp;If more than NS_SPACE_MANAGER_CACHE_SIZE are allocated at a time,
then standard allocation is used.
</p>
<pre>
void* operator new(size_t aSize);
void operator delete(void* aPtr, size_t aSize);
</pre>
<p>
A Static method is used to shutdown the Space Manager recycling. &nbsp;This
method deletes all of the Space Mangers inthe recycler,and prevents further
recycling. &nbsp;It is meant to be called only when the layout module is being
terminated.
</p>
<pre> static void Shutdown();
</pre>
<h4>Origin / Coordinate Space Translation</h4>
<pre> /**
* Translate the current origin by the specified (dx, dy). This
* creates a new local coordinate space relative to the current
* coordinate space.
*/
void Translate(nscoord aDx, nscoord aDy) { mX += aDx; mY += aDy; }
/**
* Returns the current translation from local coordinate space to
* world coordinate space. This represents the accumulated calls to
* Translate().
*/
void GetTranslation(nscoord&amp; aX, nscoord&amp; aY) const { aX = mX; aY = mY; }
/**
* Returns the y-most of the bottommost band or 0 if there are no bands.
*
* @return PR_TRUE if there are bands and PR_FALSE if there are no bands
*/
PRBool YMost(nscoord&amp; aYMost) const;
</pre>
<h4>Region Management</h4>
<pre> /**
* Returns a band starting at the specified y-offset. The band data
* indicates which parts of the band are available, and which parts
* are unavailable
*
* The band data that is returned is in the coordinate space of the
* local coordinate system.
*
* The local coordinate space origin, the y-offset, and the max size
* describe a rectangle that's used to clip the underlying band of
* available space, i.e.
* {0, aYOffset, aMaxSize.width, aMaxSize.height} in the local
* coordinate space
*
* @param aYOffset the y-offset of where the band begins. The coordinate is
* relative to the upper-left corner of the local coordinate space
* @param aMaxSize the size to use to constrain the band data
* @param aBandData [in,out] used to return the list of trapezoids that
* describe the available space and the unavailable space
* @return NS_OK if successful and NS_ERROR_FAILURE if the band data is not
* not large enough. The 'count' member of the band data struct
* indicates how large the array of trapezoids needs to be
*/
nsresult GetBandData(nscoord aYOffset,
const nsSize&amp; aMaxSize,
nsBandData&amp; aBandData) const;
/**
* Add a rectangular region of unavailable space. The space is
* relative to the local coordinate system.
*
* The region is tagged with a frame
*
* @param aFrame the frame used to identify the region. Must not be NULL
* @param aUnavailableSpace the bounding rect of the unavailable space
* @return NS_OK if successful
* NS_ERROR_FAILURE if there is already a region tagged with aFrame
*/
nsresult AddRectRegion(nsIFrame* aFrame,
const nsRect&amp; aUnavailableSpace);
/**
* Resize the rectangular region associated with aFrame by the specified
* deltas. The height change always applies to the bottom edge or the existing
* rect. You specify whether the width change applies to the left or right edge
*
* Returns NS_OK if successful, NS_ERROR_INVALID_ARG if there is no region
* tagged with aFrame
*/
enum AffectedEdge {LeftEdge, RightEdge};
nsresult ResizeRectRegion(nsIFrame* aFrame,
nscoord aDeltaWidth,
nscoord aDeltaHeight,
AffectedEdge aEdge = RightEdge);
/**
* Offset the region associated with aFrame by the specified amount.
*
* Returns NS_OK if successful, NS_ERROR_INVALID_ARG if there is no region
* tagged with aFrame
*/
nsresult OffsetRegion(nsIFrame* aFrame, nscoord dx, nscoord dy);
/**
* Remove the region associated with aFrane.
*
* Returns NS_OK if successful and NS_ERROR_INVALID_ARG if there is no region
* tagged with aFrame
*/
nsresult RemoveRegion(nsIFrame* aFrame);
/**
* Clears the list of regions representing the unavailable space.
*/
void ClearRegions();
</pre>
<h4>Float Impact</h4>
<pre> /**
* Methods for dealing with the propagation of float damage during
* reflow.
*/
PRBool HasFloatDamage()
{
return !mFloatDamage.IsEmpty();
}
void IncludeInDamage(nscoord aIntervalBegin, nscoord aIntervalEnd)
{
mFloatDamage.IncludeInterval(aIntervalBegin + mY, aIntervalEnd + mY);
}
PRBool IntersectsDamage(nscoord aIntervalBegin, nscoord aIntervalEnd)
{
return mFloatDamage.Intersects(aIntervalBegin + mY, aIntervalEnd + mY);
}
</pre>
<h4>Debug Only Methods</h4>
<pre> /**
* Dump the state of the spacemanager out to a file
*/
nsresult List(FILE* out);
void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
</pre>
<h4>Unused / Obsolete Methods</h4>
<pre> /*
* Get the frame that's associated with the space manager. This frame
* created the space manager, and the world coordinate space is
* relative to this frame.
*
* You can use QueryInterface() on this frame to get any additional
* interfaces.
*/
nsIFrame* GetFrame() const { return mFrame; }
</pre>
<h3>Implementation Notes</h3>
<h4></h4>
<h4>Algorithm 1: GetBandData</h4>
<p>
GetBandData is used to provide information to clients about what space if
available and unavailable in a band of space. &nbsp;The client provides a
vertical offset, the yOffset, that corresponds to the band that is of interest.
&nbsp;This will be the y offset of the frame that is being reflowed. &nbsp;The
caller also provides a collection of BandData objects (an array) and the
number of items that the collection can handle. &nbsp;If the collection is
too small, then an error is returned and the count is updated to indicate
the size required.
</p>
<p>
The algorithm to provide the band data is as follows:
</p>
<ul>
<li>Get a &nbsp;vertical offset in world coordinates (instead of frame-relative
coordinates) by adding the y-origin of the SpaceManager to the y offset passed
in</li>
<li>If the (adjusted) y value passed in is greater than the greatest band
being managed, then all space is available so a single trapezoid is returned,
marked as available and sized to the maximum size value (passed in).</li>
<li>If the (adjusted) y offset intersects a band, then gather the band
data:</li>
<ul>
<li>walk the internal bandData list from head to tail</li>
<li>for each band data entry, see if the top of the band is greater than
the (adjusted) y offset requested</li>
<li>if it is, then band is below the offset requested, so the area between
the band and the y offset is available - create a trapezoid with that region
and return it.</li>
<li>if the (adjusted) y offset is between the band top and bottom, then
get the available space for the band by calling GetBandAvailableSpace</li>
<li>otherwise, move to the next band</li>
</ul>
</ul>
<h5>GetBandAvailableSpace:</h5>
This method is called from GetBandData only. It walks all of the bands in
the space manager and determines which bands intersect with the band passed
in, and if within those bands there are regions that are available or occupied.
<ul>
<li>First, walk all of the bands until a band that is to the right of the
desired offset is located</li>
<li>Starting at that band, &nbsp;walk the remaining bands:</li>
<ul>
<li>if the current band is to the right of the requested band, then there
is available space.&nbsp;</li>
<ul>
<li>if there is more room in the bandData collection, then add a trapezoid
to the bandData collection such that it is marked as available and has a
rect that represents the space between the reference band tna dht band being
examined</li>
<li>if there is no more room in the BandData collection, estimate the
number of entries requires as the current count + twice the number of bands
below the reference band, plus two. &nbsp;Return an error code so the caller
can reallocate the collection and try again.</li>
</ul>
<li>check the size of the collection again, if there is no room left
then estimate the number of items requires as the current count + twice the
number of bands below the band in question plus one.&nbsp;</li>
<li>create a new trapezoid in the band collection that has a region corresponding
to the reference band rect, marked as occupied by either a single or multiple
frames.</li>
<li>move to the next band</li>
</ul>
<li>after walking all of the band data, se if we have reached the right
edge of the band.&nbsp;</li>
<ul>
<li>If not, then check for space in the band collection</li>
<ul>
<li>if there is no room left, then set the count to the current count
plus 1 and return an error.</li>
<li>otherwise, create another entry in the band collection, marked
as available, and with a rect corresponding to the area remainin in the band
(eg. from the right edge of the last band rect to the right edge of the band).</li>
</ul>
</ul>
</ul>
<h4>Algorithm 2: AddRectRegion</h4>
Clients call into this method to notify the Space Manger that a new frame
is occupying some space.
<ul>
<li>First, try to get frame info for the frame. If it is found, return
an error since the frame is already associated with a region in the Space
Manager.</li>
<li>Next, create a rect from the occupied space passed in by the caller,
transforming it first to world-coordinates by adding the Space Manager's
offset to the occupied space rect passed in.</li>
<li>Create a new Frame Info instance for the frame and rect, returning
an error if allocation fails.</li>
<li>Check if the occupied space rect (adjusted) is empty, if so, return
an error &nbsp;(<font color="#cc0000">NOTE: this could be done earlier, or
prevented by the caller</font>)</li>
<li>Allocate a new BandRect instance with the rect and frame as constructor
arguments, and insert it into the collection via InsertBandRect</li>
</ul>
<h5>InsertBandRect:</h5>
Internal method to insert a band rect into the BandList in the correct location.
There are several cases it has to handle, as specified in the source file
comments:
<pre>// When comparing a rect to a band there are seven cases to consider.
// 'R' is the rect and 'B' is the band.
//
// Case 1 Case 2 Case 3 Case 4
// ------ ------ ------ ------
// +-----+ +-----+ +-----+ +-----+
// | R | | R | +-----+ +-----+ | | | |
// +-----+ +-----+ | | | R | | B | | B |
// +-----+ | B | +-----+ | | +-----+ | |
// | | | | +-----+ | R | +-----+
// | B | +-----+ +-----+
// | |
// +-----+
//
//
//
// Case 5 Case 6 Case 7
// ------ ------ ------
// +-----+ +-----+ +-----+ +-----+
// | | | R | | B | | | +-----+
// | B | +-----+ +-----+ | R | | B |
// | | | | +-----+
// +-----+ +-----+
// +-----+
// | R |
// +-----+
//
</pre>
<ul>
<li>First, check for the easiest case, where there are no existing band
rects, or the band rect passed in is below the bottommost rect. In this case,
just append the band rect and return.</li>
<li>Starting at the head of the list of bandRects, check for intersection
with the rect passed in:</li>
<ul>
<li>case #1: the rect is totally above the current band rect, so insert
a new band rect before the current bandRect</li>
<li>cases #2 and #7: the rect is partially above the band rect, so it
is divided into two bandRects, one entirely above the band, and one containing
the remainder of the rect. &nbsp;Insert the part that is totally above the
bandRect before the current bandRect, as in case #1 above, and adjust the
other band rect to exclude the part already added.</li>
<li>case #5: the rect is totally below the current bandRect, so just
skip to the next band</li>
<li>case #3 and #4: rect is at least partially intersection with the
bandRect, so divide the current band into two parts, where the top part is
above the current rect. &nbsp;Move to the new band just created, which is
the next band.</li>
<li>case #6: the rect shares the bottom and height with the bandRect,
so just add the rect to the band.</li>
<li>case #4 and #7: create a new rect for the part that overlaps the
bandRect, and add it to the current bandRect (similar to case #6) and then
move on to the next band, removing that part from the rect passed in. &nbsp;If
no more bands, append the rect passed in to the end of the bandRect list.</li>
</ul>
</ul>
<i>This algorithm is pretty confusing - basically what needs to happen is
that rects and bands need to be divided up so that complicated cases like
#2, #4, and #7, are reduced to simpler cases where the rects is totally above,
below, or between a band rect. &nbsp;From the current implementation, it
might be worth verifying that the final result of the inserts is a correctly
ordered liest of bandRects (debug mode only).</i>
<h4>Algorithm 3: RemoveRegion</h4>
When a float is removed, the Space Manager is notified by a call to RemoveRegion,
passing in the frame that is being removed.
<ul>
<li>Get the FrameInfo for the frame passed in. If not found, an error is
returned.</li>
<li>If the rect for the frame is not empty, then visit each band in the
bandList:</li>
<ul>
<li>for each rect in the band:
</li>
</ul>
<ul>
<ul>
<li>if the bandRect is occupied by the frame, either remove the frame
from the bandRect (if there are other frames sharing it) and remember that
it was shared</li>
<li>otherwise simply remove the bandRect (no other frames share it).</li>
<li>if the bandRect was shared, then try to coalesce adjacent bandRects</li>
<ul>
<li>if the previous bandRect is directly next to the current bandRect,
and they have the same frame list, then make the current bandRect cover the
previous bandRect's full region (adjust the left edge to be that of the previous
bandRect) and remvoe the previous bandRect.</li>
</ul>
</ul>
</ul>
<ul>
<li>if the current band or prior band had a rect occupied byu the frame,
then try to join the two bands via JoinBands</li>
</ul>
<li>Finally, destroy the frameInfo for the frame.
</li>
</ul>
<br>
<hr width="100%" size="2">
<h2>Cross-Component Algorithms</h2>
<br>
<hr width="100%" size="2">
<h2>Tech Notes</h2>
<ul>
<li>
</li>
</ul>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -1,241 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Space Manager High Level Design</title>
<meta name="author" content="Marc Attinasi (attinasi@netscape.com)">
</head>
<body>
<h1><font color="#cc0000">Gecko Layout High Level Design Document</font></h1>
<h1>Space Manager High Level Design</h1>
<br>
<h2>Overview</h2>
The Space Manager and associated classes and strructures are used by Block
and Line layout to manage rectangular regions that are occupied and available,
for correct handling of floated elements and the elements that flow around
them. &nbsp;When elements are floated to the left or right in a layout, they
take up space and influence where other elements can be placed. &nbsp;The
Space Manager is responsible for keeping track of where space is taken up
and where it is available. This information is used by block layout to correctly
compute where other floated elements should be placed, and how much space
is available to normal in-flow elements that flow around the floated bits.<br>
<br>
The Space Manager works in concert with several other classes to do its
job. The classes that are considered part of the Space Manager are:<br>
<ul>
<li>nsSpaceManager</li>
<li>nsBandData</li>
<li>nsBlockBandData</li>
<li>BandRect / BandList (private structs)</li>
<li>FrameInfo (private struct)</li>
<li>nsBandtrapezoid</li>
</ul>
Outside of the Space Manager itself, the clients of the Space Manager also
play an inportant part in the management of he available and used space.
&nbsp;The primary classes that interact witht eh Space Manager are:<br>
<ul>
<li>nsBlockReflowState</li>
<li>nsBlockFrame</li>
<li>nsBoxToBlockAdaptor</li>
</ul>
The general interaction model is to create a Space Manager for a block
frame in the context of a Reflow, and to associate it with the BlockReflowState
so it is passed down to child frames' reflow methods. After reflow, the
Space Manager is destroyed. &nbsp;During reflow, the space manager stores
the space taken up by floats (UpdateSpaceManager in nsBlockFrame) and
provides information about the space available for other elements (GetAvailableSpace
in nsBlockReflowState). &nbsp;<br>
<br>
Additionally, there is a need to manage impacts to lines caused by
changes to floated elements. &nbsp;This is referred to as Propagation
of Float Damage and is handled by the Block Frame, making use of the
Space Manager. When a float is incrementally reflowed, the Space
Manger is notified if the float's region has changed. If so, the
vertical space that has been affected (including both the float's old
region and the float's new region) is noted in the internal
nsIntervalSet as potential float damage (the method is
IncludeInDamage). During the incremental reflow of dirty lines the
block frame may encounter lines that are NOT dirty. In this case the
Space Manager is also asked if &nbsp;there is any float damage, and
if there is then the block further checks to see if that damage
intersects the area of the non-dirty line, marking it dirty if there
is intersection. &nbsp;Thus, changes to floats on other lines may
cause impact to otherwise clean lines, and the Space Manager
facilitates the detection of this. <h2>Data Model</h2>
<h4>Class/Component Diagram</h4>
<blockquote>
<div align="Left"><img src="SpaceManagerClasses.png" alt="SpaceManager Class Diagram" idth="500" eight="459" title="Example Class Diagram">
<br>
</div>
</blockquote>
<ul>
<li>nsSpaceManager: The central point of management of the space taken
up by floats in a block</li>
<li>nsBandData: Provides information about the frames occupying a band
of occupied or available space</li>
<li>nsBlockBandData: A specialization of nsBandData that is used by
nsBlockReflowState to determine the available space, float impacts, and
where floats are cleared. &nbsp;Essentially a CSS-specific wrapper for
generic nsBandData.</li>
<li>BandRect: Keeps the bounds of a band, along with the frames associated
with the band. &nbsp;BandRects are a linked list (provided by PRCListStr
super-class) and also provide some geometry-management methods (SplitVertically,
SplitHorizontally) and some methods that query or manipulate the frames associated
with the band (IsOccupiedBy, AddFrame, RemoveFrame).</li>
<li>BandList: A subclass of BandRect that provides a list interface
- Head(), Tail(), IsEmpty(), etc.</li>
<li>FrameInfo: A structure that keeps information about the rectangle
associated with a specific frame, in a linked list.</li>
<li>nsBandTrapezoid: Represents the discrete regions within a band that
are either Available, Occupied by a single frame, or Occupied by several
frames. &nbsp;This is used to communicate information about the space in
the band to the clients of the SpaceManager. &nbsp;There is no internal use
of the nsBandTrapezoid by the Space Manager, rather it uses its internal
BandList to create a BandData collection, which is largely made up of nsTrapezoid
data.<br>
</li>
</ul>
<h2>Use Case</h2>
<h4>Use Case 1: Space Manger is Created / Destroyed</h4>
Space Manager instances are created in the nsBlockFrame's Reflow method.
&nbsp;<br>
<ul>
<li>An instance is created&nbsp;</li>
<li>The BlockReflowState's previous Space Manger is saved off.</li>
<li>The new Space Manger instance is associated with the BlockReflowState.
&nbsp;</li>
<li>After the block frame's Reflow has completed, the old Space Manager
instance is re-associated with the BlockReflowState</li>
<li>The new Space Manager is destroyed.</li>
</ul>
If the BlockReflowState already had a Space Manager instance associated
with it, it is stored off before being replaced, and the returned to the
BlockReflowState instance after the new one has been destroyed. &nbsp;Thus,
Space Managers are effectively 'nested' during reflow, with each new block
introducing its own Space Manager.
<h4>Use Case 2: Float is added to the Space Manager</h4> After a Space Manager is created for a block context's reflow chain, a
floated block may be added to it. &nbsp;This happens in the method <i>nsBlockReflowState::RecoverFloats</i> and
<i>nsBlockReflowState::FlowAndPlaceFloat</i> (formerly this was done in nsBlockFrame::UpdateSpaceManager). &nbsp;<br>
<br>
The general algorightm in <i>nsBlockReflowState::RecoverFloats</i> is:<br>
<ul>
<li>For each line in the block, see if it has floated blocks</li>
<li>If floats are in the line, iterate over the floats and add each
one to the Space Manger via the AddRectRegion method. &nbsp;The actual rect
for the frame is cached in an nsFloatCache so it does not have to be recomputed.</li>
<li>If the block has any block children, then translate the Space Manager
to the child block's origin and update the space manager in the context
for the child block, recursively. When done with the child, restore the Space
Managers coordinates by translating by the negative of the child block's
origin.&nbsp; <br>
</li>
</ul><br>
The general algorightm in <i>nsBlockReflowState::FlowAndPlaceFloat</i> is:<br>
<ul>
<li>The region that the float currently occupies is recorded.</li>
<li>The band of available space is searched (with nsBlockReflowState::GetAvailableSpace);</li>
<li>The float frame that is get from the passed nsFloatCache argument is reflowed
and its rect is retriven with GetRect;</li>
<li>The floats margins are added;</li>
<li>Check if the float can be placed in the acutal band: if not advance to the next band;</li>
<li>Check the float type and if it can be added to the space manager;</li>
<li>Align the float to its containing block top if rule
<a href="http://www.w3.org/TR/REC-CSS2/visuren.html#float-position">CSS2/9.5.1/4</a>
is not respected;</li>
<li>Add the float using <i>nsSpaceManager::AddRectRegion</i> </li>
<li>Compare the area that the float used to occupy with the area that it now occupies: if different,
record the vertically affected interval using <i>nsSpaceManager::IncludeInDamage</i></li>
</ul>
<h4>Use Case 3: Space Manager is used to find available space to reflow
into</h4>
The nsBlockFrame makes use of the Space Manager indirectly to get the available
space to reflow a child block or inline frame into. The block frame uses
a helper method on the nsBlockReflowState class to do the actual computation
of available space based on the data in the Space Manger. Here is how it
works for reflowing an inline frame within a block (this also occurs for
reflowing a block frame and, partially, for preparing for a resize reflow).<br>
<ul>
<li>nsBlockFrame first frees all float information for the line that
is being reflowed.</li>
<li>GetAvailableSpace is called on the BlockReflowState</li>
<li>the BlockReflowState calls GetAvailableSpace on its BlockBandData
instance (which was setup in the BlockReflowState's constructor based on
the SpaceManager passed in and computed content area).</li>
<li>BlockBandData then gets the band data from the space manager via
a call to the Space Manager associated with the BlockBandData instance.</li>
<li>The BlockBandData then walks the collection of trapezoids that were
returned by the SpaceManager method GetBandData (as nsBandData wrappers)
and determines the right-most edge of the available space.</li>
<li>The BlockReflowState then stores this available space rect for use
in the rest of the reflow chain.<br>
</li>
</ul>
<h4>Use Case 4: Propagation of Float Damage: detecting and handling float
damage</h4>
This process is driven by the Block Frame.<br>
<ul>
<li>A non-dirty line is encountered by the Block Frame in ReflowDirtyLines</li>
<li>Block Frame calls its PropagateFloatDamage method</li>
<li>The Space Manger is checked to see if ther is any float damage</li>
<li>If there is, then the block frame asks the Space Manager if the
line in question intersects the float damage</li>
<li>If the line does intersect a damage interval, then the line is marked
dirty</li>
<li>If the line does not intersect a damage interval, it may still be
marked dirty if:</li>
<ul>
<li>it was impacted by floats before, but is not any longer</li>
<li>it was not impacted by floats befre, but is now</li>
<li><a name="block-line-impact"></a>
it is impacted by floats and is a block<br>
</li>
</ul>
</ul>
<br>
<hr width="100%" size="2"><br>
<h1><font color="#ff0000">Problems / bugs found during documentation:</font></h1>
<ul>
<li>BandRect and BandList are public in nsSpaceManager.h - should be
private (compiles fine)</li>
<li>nsSpaceManager data members are declared protected, but there are
no subclasses. Should be private (compiles fine)</li>
<li>nsBlockFrame::Paint is mucking with nsBlockBandData in and #if 0
block - remove that and the include (compiles fine)</li>
<li>nsSpaceManger has no way of clearing the float damage interval
set - this might be needed if the SpaceManager persists beyond a Reflow</li>
</ul>
<br>
<br>
</body>
</html>

View File

@@ -1,350 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Layout Overview</title>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1>Layout System Overview</h1>
<br>
<h3>Layout's Job: Provide the Presentation</h3>
Layout is primarily concerned with providing a presentation to an HTML or
XML document. This presentation is typically formatted in accordance with
the requirements of the <a href="http://www.w3.org/TR/REC-CSS1">CSS1</a>
and <a href="http://www.w3.org/TR/REC-CSS2/">CSS2</a> specifications from
the W3C. Presentation formatting is also required to provide compatibility
with legacy browsers (Microsoft Internet Explorer and Netscape Navigator
4.x). The decision about when to apply CSS-specified formatting and when
to apply legacy formatting is controlled by the document's DOCTYPE specification.
These layout modes are refered to as 'Standards' and 'NavQuirks' modes. (DOCTYPE
and modes are explained in more detail <a
href="http://www.mozilla.org/quality/help/bugzilla-helper.html">here</a>).<br>
<br>
The presentation generally is constrained by the width of the window in which
the presentation is to be displayed, and a height that extends as far as
necessary. This is referred to as the Galley Mode presentation, and is what
one expects from a typical browser. Additionally, layout must support a paginated
presentation, where the width of the presentation is constrained by the dimensions
of the printed output (paper) and the height of each page is fixed. This
paged presentation presents several challenges not present in the galley
presentation, namely how to break up elements that are larger than a single
page, and how to handle changes to page dimensions.<br>
<br>
The original design of the Layout system allowed for multiple, possibly different,
presentations to be supported simultaneously from the same content model.
In other words, the same HTML or XML document could be viewed as a normal
galley presentation in a browser window, while simultaneously being presented
in a paged presentation to a printer, or even an aural presentation to a
speech-synthesizer. To date the only real use of this multiple presentation
ability is seen in printing, where multiple presentations are managed, all
connected to the same content model. (note: it is unclear if this is really
a benefit - it may have been better to use a copy of the content model for
each presentation, and to remove the complexity of managing separate presentations
- analysis is needed here). The idea of supporting a non-visual presentation
is interesting. Layout's support for aural presentations is undeveloped,
though conceptually, it is possible and supported by the architecture.<br>
<br>
<h3>How Layout Does its Job: Frames and Reflow</h3>
So, layout is concerned with providing a presentation, in galley or paged
mode. Given a content model, how does the layout system actually create the
presentation? Through the creation and management of frames. Frames are an
encapsulation of a region on the screen, a region that contains geometry
(size and location, stacking order). Generally frames correspond to the content
elements, though there is often a one-to-many correspondence between content
elements and frames. Layout creates frames for content based on either the
specific HTML rules for an element or based on the CSS display type of the
element. In the case of the HTML-specific elements, the frame types that
correspond to the element are hard-coded, but in the more general case where
the display type is needes, the layout system must determine that display
type by using the Style System. A content element is passed to the Style
System and a request is made to resolve the style for that element. This
causes the Style System to apply all style rules that correspond to the element
and results in a resolved Style Context - the style data specific to that
element. The Layout module looks at the 'display' field of the style context
to determine what kind of frame to create (block, inline, table, etc.). The
style context is associated with the frame via a reference because it is
needed for many other computations during the formatting of the frames.<br>
<br>
Once a frame is created for a content element, it must be formatted. We refer
to this as 'laying out' the frame, or as 'reflowing' the frame. Each frame
implements a Reflow method to compute its position and size, among other
things. For more details on the Reflow mechanism, see the Reflow Overview
document... &nbsp;The CSS formatting requirements present two distinct layout
models: 1) the in-flow model, where the geometry of an element is influenced
by the geometry of the elements that preceed it, and 2) the positioned model,
where the geometry of an element is not influenced by the geometry of the
elements that preceed it, or in any case, is influenced more locally. The
in-flow cased is considered the 'normal' case, and corresponds to normal
HTML formatting. The later case, called 'out of flow' puts the document author
in control of the layout, and the author must specify the locations and sizes
of all of the elements that are positioned. There is, of course, some complexity
involved with managing these two models simultanelusly...<br>
<br>
So far the general flow of layout looks like this:<br>
<br>
1) Obtain a document's content model<br>
2) Utilize the Style System to resolve the style of each element in the content
model<br>
3) Construct the frames that correspond to the content model, according to
the resolved style data.<br>
4) Perform the initial layout, or initial reflow, on the newly constructed
frame.<br>
<br>
This is pretty straight-forward, but is complicated somewhat by the notion
of <i>incrementalism</i>. One of the goals of the Layout system's design
is to create parts of the presentation as they become available, rather than
waiting for the entire document to be read, parsed, and then presented. This
is a major benefit for large documents because the user does not have to wait
for the 200th page of text to be read in before the first page can be displayed
- they can start reading something right away. So really, this sequence of
operations Resolve Style, Create Frame, Layout Frame, gets repeated many
times as the content becomes available. In the normal in-flow case this is
quite natural because the sequential addition of new content results in sequential
addition of new frames, and because everything is in-flow, the new frames
do not influence the geometry of the frames that have already been formatted.
When out-of-flow frames are present this is a more difficult problem, however.
Sometimes a content element comes in incrementally, and invalidates the formatting
of some of the frames that preceed it, frame that have already been formatted.
In this case the Layout System has to detect that impact and reflow again
the impacted frames. This is referred to as an <i>incremental reflow</i>.<br>
<br>
<a name="DHTML_interaction"></a>Another responsibility of layout is to manage
dynamic changes to the content model, changes that occur after the document
has been loaded and (possibly) presented. These dynamic changes are caused
by manipulations of the content model via the&nbsp;<acronym
title="Document Object Model">DOM<acronym></acronym></acronym> (generally
through java script). When a content element is modified, added or removed,
Layout is notified. If content elements have been inserted, new frames are
created and formatted (and impacts to other frames are managed by performing
further incremental reflows). If content is removed, the corresponding frames
are destroyed (again, impacts to other elements are managed). If a content
element is modified, layout must determine if the chage influences the formatting
of that or other elements' presentations, and must then reformat, or re-reflow,
the impacted elements. In all cases, the determination of the impact is critical
to avoid either the problem of not updating impacted elements, thus presenting
an invalid presentation, or updating too much of the presentation and thus
doing too much work, potentially causing performance problems.<br>
<br>
One very special case of dynamic content manipulation is the HTML Editor.
Layout is used to implement both a full-blown WYSIWYG HTML editor, and a single
and multi-line text entry control. In both cases, the content is manipulated
by the user (via the DOM) and the resulting visual impacts must be shown as
quickly as possible, without disconcerting flicker or other artifacts that
might bother the user. Consider a text entry field: the user types text into
a form on the web. As the user types a new character it is inserted into
the content model. This causes layout to be notified that a new piece of
content has been entered, which causes Layout to create a new frame and format
it. This must happen very fast, so the user's typing is not delayed. In the
case of the WYSIWYG HTML editor, the user expects that the modifications
they make to the document will apear immediately, not seconds later. This
is especially critical when the user is typing into the document: it would
be quite unusable if typing a character at the end of a document in the HTML
editor caused the entire document to be reformated - it would be too slow,
at least on low-end machines. Thus the HTML editor and text controls put
considerable performance requirements on the layout system's handling of dynamic
content manipulation.<br>
<h3>The Fundamentals of Frames: Block and Line</h3>
There are many types of frames that are designed to model various formatting
requirements of different HTML and XML elements. CSS2 defines several (block,
inline, list-item, marker, run-in, compact, and various table types) and
the standard HTML form controls require their own special frame types to
be formatted as expected. The most essential frame types are Block and Inline,
and these correspond to the most important Layout concepts, the Block and
Line.<br>
<br>
A block is a rectangular region that is composed of one or more lines. A
line is a single row of text or other presentational elements. All layout
happens in the context of a block, and all of the contents of a block are
formatted into lines within that block. As the width of a block is changed,
the contents of the lines must be reformatted. consider for example a large
paragraph of text sitting in paragraph:<br>
<br>
<pre>&lt;p&gt;<br> We need documentation for users, web developers, and developers working
on Mozilla. If you write your own code, document it. Much of the
existing code &lt;b&gt;isn&#8217;t very well documented&lt;/b&gt;. In the process of figuring
things out, try and document your discoveries.
If you&#8217;d like to contribute, let us know.<br>&lt;/p&gt;</pre>
There is one block that corresponds to the &lt;p&gt; element, and then a number
of lines of text that correspond to the text. As the width of the block changes
(due to the window being resized, for example) the length of the lines within
it changes, and thus more or less text appears on each line. The block is
responsible for managing the lines. Note that lines may contain only inline
elements, whereas block may contain both inline elements and other blocks.<br>
<h3>Other Layout Models: XUL</h3>
In addition to managing CSS-defined formatting, the layout system provides
a way to integrate other layout schemes into the presentation. Currently
layout supports the formatting of XUL elements, which utilize a constraint-based
layout language. The Box is introduced into the layout system's frame model
via an adapter (BoxToBlockAdapter) that translates the normal layout model
into the box formatting model. Conceptually, this could be used to introduce
other layout systems, but it might be worth noting that there was no specific
facility designed into the layout system to accommodate this. Layout deals
with frames, but as long as the layout system being considered has no need
to influence presentational elements from other layout systems, it can be
adapted using a frame-based adapter, ala XUL.<br>
<br>
<h2>Core Classes</h2>
At the highest level, the layout system is a group of classes that manages
the presentation within a fixed width and either unlimited height (galley
presentation) or discrete page heights (paged presentation). Digging just
a tiny bit deeper into the system we find that the complexity (and interest)
mushrooms very rapidly. The idea of formatting text and graphics to fit within
a given screen area sounds simple, but the interaction of in-flow and out-of-flow
elements, the considerations of incremental page rendering, and the performance
concerns of dynamic content changes makes for a system that has a lot of
work to do, and a lot of data to manage. Here are the high-level classes
that make up the layout system. Of course this is a small percentage of the
total clases in layout (see the detailed design documents for the details
on all of the classes, in the context of their actual role).<br>
<h3>Presentation Shell / Presentation Context</h3>
Together the presentation shell and the presentation context provide the
root of the current presentation. The original design provided for a single
Presentation Shell to manage multiple Presentation Contexts, to allow a single
shell to handle multiple presentations. It is unclear if this is really possible,
however, and in general it is assumed that there is a one-to-one correspondence
between a presentation shell and a presentation context. The two classes
should probably be folded into one, or the distinction between them formalized
and utilized in the code. The Presentation Shell currently owns a controlling
reference to the Presentation Context. Further references to the Presentation
Shell and Presentation Context will be made by using the term Presentation
Shell.<br>
<br>
The Presentation Shell is the root of the presentation, and as such it owns
and manges a lot of layout objects that are used to create and maintain a
presentation (<font color="#990000">note that the DocumentViewer is the owner
of the Presentation Shell, and in some cases the creator of the objects
used by the Presentation Shell to manage the presentation. More details
of the Document Viewer are needed here...</font>). The Presentation Shell,
or PresShell, is first and foremost the owner of the formatting objects,
the frames. Management of the frames is facilitated by the Frame Manager,
an instance of which the PresShell owns. Additionally, the PresShell provides
a specialized storage heap for frames, called an Arena, that is used to make
allocation and deallocation of frames faster and less likely to fragment
the global heap. <br>
<br>
The Presentation Shell also owns the root of the Style System, the Style
Set. In many cases the Presentation Shell provides pass-through methods to
the Style Set, and generally uses the Style Set to do style resolution and
Style Sheet management.<br>
<br>
One of the critical aspects of the Presentation Shell is the handling of
frame formatting, or reflow. The Presentation Shell owns and maintains a
Reflow Queue where requests for reflow are held until it is time to perform
a reflow, and then pulled out and executed.<br>
<br>
It is also important to see the Presentation Shell as an observer of many
kinds of events in the system. For example, the Presentation Shell receives
notifications of document load events, which are used to trigger updates
to the formatting of the frames in some cases. The Presentation Shell also
receives notifications about changes in cursor and focus states, whereby
the selection and caret updates can be made visible.<br>
<br>
There are dozens of other data objects managed by the Presentation Shell
and Presentation Context, all necessary for the internal implementation.
These data members and their roles will be discussed in the Presentation
Shell design documents. For this overview, the Frames, Style Set, and Reflow
Queue are the most important high-level parts of the Presentation Shell.<br>
<h3>Frame Manager</h3>
The Frame Manager is used to, well, manage frames. Frames are basic formatting
objects used in layout, and the Frame Manager is responsible for making frames
available to clients. There are several collections of frames maintained
by the Frame Manager. The most basic is a list of all of the frames starting
at the root frame. Clients generally do not want to incur the expense of
traversing all of the frames from the root to find the frame they are interested
in, so the Frame Manager provides some other mappings based on the needs of
the clients.<br>
<br>
The most crucial mapping is the Primary Frame Map. This collection provides
access to a frame that is designated as the primary frame for a piece of
content. When a frame is created for a piece of content, it may be the 'primary
frame' for that content element (content elements that require multiple
frames have primary and secondary frames; only the primary frame is mapped).
The Frame Manager is then instructed to store the mapping from a content
element to the primary frame. This mapping facilitates updates to frames
that result in changes to content (see <a href="#DHTML_interaction">discussion
above</a>).<br>
<br>
Another important mapping maintained by the Frame Manager is that of the
undisplayed content. When a content element is defined as having no display
(via the CSS property 'display:none') it is noted by a special entry in the
undisplayed map. This is important because no frame is generated for these
elements yet changes to their style values and to the content elements still
need to be handled by layout, in case their display state changes from 'none'
to something else. The Undisplayed Map keeps track of all content and style
data for elements that currently have no frames. (<font color="#990000">note:
the original architecture of the layout system included the creation of frames
for elements with no display. This changed somewhere along the line, but
there is no indication of why the change was made. Presumably it is more
time and space-efficient to prevent frame creation for elements with no display.)</font><br>
<br>
The Frame Manager also maintains a list of Forms and Form Controls, as <i>content
nodes</i>. This is presumably related to the fact that layout is responsible
for form submission, but this is a design flaw that is being corrected by
moving form submission into the content world. These collections of Forms
and Form Controls should be removed eventually.<br>
<br>
<h3>CSS Frame Constructor</h3>
The Frame Constructor is responsible for resolving style values for content
elements and creating the appropriate frames corresponding to that element.
In addition to managing the creation of frames, the Frame Constructor is
responsible for managing changes to the frames. Frame Construction is generally
achieved by the use of stateless methods, but in some cases there is the
need to provide context to frames created as children of a container. The
Frame Manager uses the Frame Constructor State class to manage the important
information about the container of a frame being created (<font
color="#990000">and lots of other state-stuff too - need to describe more
fully</font>).<br>
<h3>Frame</h3>
The Frame is the most fundamental layout object. The class nsFrame is the
base class for all frames, and it inherits from the base class nsIFrame (note:
nsIFrame is NOT an interface, it is an abstract base class. It was once an
interface but was changed to be a base class when the Style System was modified
- the name was not changed to reflect that it is not an interface). The Frame
provides generic functionality that can be used by subclasses but cannot
itself be instantiated.<br>
<br>
nsFrame:<br>
The Frame provides a mechanism to navigate to a parent frame as well as child
frames. All frames have a parent except for the root frame. The Frame is
able to provide a reference to its parent and to its children upon request.
The basic data that all frames maintain include: a rectangle describing the
dimensions of the frame, a pointer to the content that the frame is representing,
the style context representing all of the stylistic data corresponding to
the frame, a parent frame pointer, a sibling frame pointer, and a series
of state bits.<br>
<br>
Frames are chained primarily by the sibling links. Given a frame, one can
walk the sibling of that frame, and can also navigate back up to the parent
frame. Specializations of the frame also allow for the management of child
frames; this functionality is provided by the Container Frame.<br>
<br>
Container Frames:<br>
The Container Frame is a specialization of the base frame class that introduces
the ability to manage a list of child frames. All frames that need to manage
child frames (e.g. frames that are not themselves leaf frames) derive from
Container Frame.<br>
<br>
<br>
<br>
<h3>Block Frame<br>
</h3>
<h3>Reflow State</h3>
<h3>Reflow Metrics<br>
</h3>
<h3>Space Manager<br>
</h3>
<h3>StyleSet</h3>
<h3>StyleContext</h3>
<br>
<br>
<hr width="100%" size="2"><br>
<b>Document History:<br>
</b>
<ul>
<li>05/20/2002 - Marc Attinasi: &nbsp;created, wrote highest level introduction
to general layout concepts, links to relevant specs and existing documents.<br>
</li>
</ul>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

View File

@@ -1,486 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="author" content="Marc Attinasi"><title>Adding a new style property - layout cookbook</title></head>
<body>
<h1>Adding a new style property</h1>
<blockquote>
<h4>Document history:</h4>
<ul>
<li>03/21/2002: Marc Attinasi (attinasi@netscape.com) created document
/ implementing -moz-force-broken-image-icon for bug <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=58646">
58646</a></li>
<li>
6/18/2002: David Baron (dbaron@dbaron.org): corrected support
for 'inherit' and '-moz-initial' (didn't test with code, though),
and explained what the final boolean in CheckPropertyData is for.
</li>
<li>
11/09/2002: Christopher Aillon (caillon@returnzero.com): updated
nsCSSPropList.h macro description and added information about
nsIDOMCSS2Properties.idl.
</li>
</ul>
<p>
<b>NOTE</b>: This document is still missing a few pieces. I need to
add information on adding to <code>nsComputedDOMStyle</code>.
</p>
</blockquote>
<h2>Overview</h2>
When a new style property is needed there are many places in the code that
need to be updated. This document outlines the proceedure used to add a new
property, in this case the property is a proprietary one called '-moz-force-broken-image-icons'
and is used as a way for a stylesheet to force broken image icons to be displayed.
This is all being done in the context of <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=58646">
bug 58646</a>.
<h2>Analysis</h2>
<p>Up front you have to decide some things about the new property:</p>
<p><b>Questions:</b></p>
<ol>
<li>Is the property proprietary or specified by the CSS standard?</li>
<li>Is the property inherited?</li>
<li>What types of values can the property have?</li>
<li>Does it logically fit with other existing properties?</li>
<li>What is the impact to the layout of a page if that property changes?</li>
<li>What do you want to name it?</li>
</ol>
<p><b>Answers:</b></p>
<ol>
<li>In our specific case, we want a property that is used internally,
so it is a proprietary property.</li>
<li>The property is to be used for images, which are leaf elements, so
there is no need to inherit it.</li>
<li>The property is used simply to force a broken image to be represented
by an icon, so it only supports the values '0' and '1' as numerics. </li>
<li>It is hard to see how this property fits logically in with other
properties, but if we stretch our imaginations we could say that it is a
sort of UI property.</li>
<li>If this property changes, the image frame has to be recreated. This
is because the decision about whether to display the icon or not will impact
the decision to replace the image frame with an inline text frame for the
ALT text, so if the ALT text inline is already made, there is no image frame
left around to reflow or otherwise modify.</li>
<li>Finally, the name will be '-moz-force-broken-image-icons' - that
should be pretty self-describing (by convention we start proprietary property
names with '-moz-').</li>
</ol>
<h2>Implementation</h2>
<p>There are several places that need to be educated about a new style property.
They are:
</p>
<ul>
<li><a href="#CSSPropList">CSS Property Names and Hint Tables</a>: the new
property name must be made formally know to the system</li>
<li><a href="#CSSDeclaration">CSS Declaration</a>: the declaration must be
able to hold the property and its value(s)</li>
<li><a href="#Parser">CSS Parser</a>: the parser must be able to parse the
property name, validate the values, and provide a declaration for the property
and value</li>
<li><a href="#StyleContext">Style Context</a>: the StyleContext must be able
to hold the resolved value of the property, and provide a means to retrieve the
property value. Additionally, the StyleContext has to know what kind of impact a
change to this property causes.</li>
<li><a href="#RuleNode">Rule Nodes</a>: the RuleNodes need to know how the
property is inherited and how it is shared by other elements.</li>
<li><a href="#DOM">DOM</a>: Your style should be accessible from the DOM so
users may dynamically set/get its property value.</li>
<li><a href="#Layout">Layout</a>: layout has to know what to do with the
property, in other words, the meaning of the property.</li>
</ul>
<h3><a name="CSSPropList">CSS Property Name / Constants / Hints</a></h3>
<p>
First, add the new name to the property list in <a href="http://lxr.mozilla.org/seamonkey/source/content/shared/public/nsCSSPropList.h">
nsCSSPropList.h</a>
 Insert the property in the list alphabetically, using the existing
property names as a template. The format of the entry you will create is:
</p>
<pre>CSS_PROP(-moz-force-broken-image-icons, force_broken_image_icons, MozForceBrokenImageIcons, NS_STYLE_HINT_FRAMECHANGE) // bug 58646</pre>
<p>The first value is the formal property name, in other words the property
name as it is seen by the CSS parser.<br>
The second value is the name of the property as it will appear internally.<br>
The third value is the name of the DOM property used to access your style.<br>
The last value indicates what must change when the value of the property
changes. It should be an
<a href="http://lxr.mozilla.org/seamonkey/source/content/shared/public/nsChangeHint.h">nsChangeHint</a>.</p>
<p>If you need to introduce new constants for the values of the property, they
must be added to <a href="http://lxr.mozilla.org/seamonkey/source/layout/base/public/nsStyleConsts.h">
nsStyleConsts.h</a>
and to the appropriate keyword tables in <a href="http://lxr.mozilla.org/seamonkey/source/content/shared/src/nsCSSProps.cpp">
nsCSSProps.cpp</a>
(note: this cookbook does not do this since the new property does not require
any new keywords for the property values).
<h3><a name="CSSDeclaration">CSS Declaration</a></h3>
Changes will need to be made to the structs and classes defined in <a href="http://lxr.mozilla.org/seamonkey/source/content/html/style/src/nsCSSDeclaration.h">
nsCSSDeclaration.h </a>
and <a href="http://lxr.mozilla.org/seamonkey/source/content/html/style/src/nsCSSDeclaration.cpp">
nsCSSDeclaration.cpp</a>
<br>
<br>
First, find the declaration of the struct that will hold the new property
value (in the header file). For this example it is the struct <b>nsCSSUserInterface</b>
. Modify the struct declaration to include a new data member for the new
property, of the type CSSValue. Next, open the implementation file (the cpp)
and modify the struct's constructors. <br>
<br>
Next, the <a href="http://lxr.mozilla.org/seamonkey/source/content/html/style/src/nsCSSDeclaration.cpp#1410">
AppendValue</a>
method must be updated to support your new property. The CSSParser will
call this to build up a declaration. Find the portion of that method that
deals with the other properties in the struct that you are adding your property
to (or create a new section if you are creating a new style struct). For
this example we will find the 'UserInterface' section and add our new property
<a href="#AppendValueCase">there</a>
.<br>
<pre> // nsCSSUserInterface
case eCSSProperty_user_input:
case eCSSProperty_user_modify:
case eCSSProperty_user_select:
case eCSSProperty_key_equivalent:
case eCSSProperty_user_focus:
case eCSSProperty_resizer:
case eCSSProperty_cursor:
case eCSSProperty_force_broken_image_icons: {
CSS_ENSURE(UserInterface) {
switch (aProperty) {
case eCSSProperty_user_input: theUserInterface-&gt;mUserInput = aValue; break;
case eCSSProperty_user_modify: theUserInterface-&gt;mUserModify = aValue; break;
case eCSSProperty_user_select: theUserInterface-&gt;mUserSelect = aValue; break;
case eCSSProperty_key_equivalent:
CSS_ENSURE_DATA(theUserInterface-&gt;mKeyEquivalent, nsCSSValueList) {
theUserInterface-&gt;mKeyEquivalent-&gt;mValue = aValue;
CSS_IF_DELETE(theUserInterface-&gt;mKeyEquivalent-&gt;mNext);
}
break;
case eCSSProperty_user_focus: theUserInterface-&gt;mUserFocus = aValue; break;
case eCSSProperty_resizer: theUserInterface-&gt;mResizer = aValue; break;
case eCSSProperty_cursor:
CSS_ENSURE_DATA(theUserInterface-&gt;mCursor, nsCSSValueList) {
theUserInterface-&gt;mCursor-&gt;mValue = aValue;
CSS_IF_DELETE(theUserInterface-&gt;mCursor-&gt;mNext);
}
break;
<b> <a name="AppendValueCase"></a>case eCSSProperty_force_broken_image_icons: theUserInterface-&gt;mForceBrokenImageIcon = aValue; break;
</b>
CSS_BOGUS_DEFAULT; // make compiler happy
}
}
break;
}
</pre>
The GetValue method must be similarly <a href="#GetValueCase">modified</a>
:<br>
<pre> // nsCSSUserInterface
case eCSSProperty_user_input:
case eCSSProperty_user_modify:
case eCSSProperty_user_select:
case eCSSProperty_key_equivalent:
case eCSSProperty_user_focus:
case eCSSProperty_resizer:
case eCSSProperty_cursor:
case eCSSProperty_force_broken_image_icons: {
CSS_VARONSTACK_GET(UserInterface);
if (nsnull != theUserInterface) {
switch (aProperty) {
case eCSSProperty_user_input: aValue = theUserInterface-&gt;mUserInput; break;
case eCSSProperty_user_modify: aValue = theUserInterface-&gt;mUserModify; break;
case eCSSProperty_user_select: aValue = theUserInterface-&gt;mUserSelect; break;
case eCSSProperty_key_equivalent:
if (nsnull != theUserInterface-&gt;mKeyEquivalent) {
aValue = theUserInterface-&gt;mKeyEquivalent-&gt;mValue;
}
break;
case eCSSProperty_user_focus: aValue = theUserInterface-&gt;mUserFocus; break;
case eCSSProperty_resizer: aValue = theUserInterface-&gt;mResizer; break;
case eCSSProperty_cursor:
if (nsnull != theUserInterface-&gt;mCursor) {
aValue = theUserInterface-&gt;mCursor-&gt;mValue;
}
break;
<b> <a name="GetValueCase"></a>case eCSSProperty_force_broken_image_icons: aValue = theUserInterface-&gt;mForceBrokenImageIcons; break;
</b>
CSS_BOGUS_DEFAULT; // make compiler happy
}
}
else {
aValue.Reset();
}
break;
}
</pre>
Finally <a href="#ListCase">modify </a>
the 'List' method to output the property value.<br>
<pre>void nsCSSUserInterface::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index &gt;= 0; ) fputs(" ", out);
nsAutoString buffer;
mUserInput.AppendToString(buffer, eCSSProperty_user_input);
mUserModify.AppendToString(buffer, eCSSProperty_user_modify);
mUserSelect.AppendToString(buffer, eCSSProperty_user_select);
nsCSSValueList* keyEquiv = mKeyEquivalent;
while (nsnull != keyEquiv) {
keyEquiv-&gt;mValue.AppendToString(buffer, eCSSProperty_key_equivalent);
keyEquiv= keyEquiv-&gt;mNext;
}
mUserFocus.AppendToString(buffer, eCSSProperty_user_focus);
mResizer.AppendToString(buffer, eCSSProperty_resizer);
nsCSSValueList* cursor = mCursor;
while (nsnull != cursor) {
cursor-&gt;mValue.AppendToString(buffer, eCSSProperty_cursor);
cursor = cursor-&gt;mNext;
}
<b> <a name="ListCase"></a>mForceBrokenImageIcon.AppendToString(buffer,eCSSProperty_force_broken_image_icons);</b>
fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out);
}
</pre>
<h3><a name="Parser">CSS Parser</a></h3>
Next, the CSSParser must be educated about this new property so that it can
read in the formal declarations and build up the internal declarations that
will be used to build the rules. If you are adding a simple property that
takes a single value, you simply add your new property to the ParseSingleProperty
method. If a more complex parsing is required you will have to write a new
method to handle it, modeling it off of one of the existing parsing helper
methods (see <a href="http://lxr.mozilla.org/seamonkey/source/content/html/style/src/nsCSSParser.cpp#4151">
ParseBackground</a>
, for and example). We are just adding a simple single-value property here.<br>
<br>
Open nsCSSParser.cpp and look for the method <a href="http://lxr.mozilla.org/seamonkey/source/content/html/style/src/nsCSSParser.cpp#3580">
ParseSingleProperty</a>
. This method is responsible for calling the relevant helper routine to parse
the value(s). Find an existing property that is similar to the property you
are adding. For our example we are adding a property that takes a numeric
value so we will model it after the 'height' property and call ParsePositiveVariant.
Add a new case for the new property and call the appropriate parser-helper
and make a call to ParseVariant passing the <a href="http://lxr.mozilla.org/seamonkey/source/content/html/style/src/nsCSSParser.cpp#2754">
variant flag</a>
that makes sense for your property. In our case<br>
<br>
<pre>  case eCSSProperty_force_broken_image_icons:</pre>
<pre>    return ParsePositiveVariant(aErrorCode, aValue, VARIANT_INTEGER, nsnull);</pre>
This will parse the value as a positive integer value, which is what we want.<br>
<br>
<h3><a name="StyleContext">Style Context</a></h3>
Having implemented support for the new property in the CSS Parser and CSS
Declaration classes in the content module, it is now time to provide support
for the new property in layout. The Style Context must be given a new data
member corresponding to the declaration's new data member, so the computed
value can be held for the layout objects to use.<br>
<br>
First look into <a href="http://lxr.mozilla.org/seamonkey/source/content/shared/public/nsStyleStruct.h">
nsStyleStruct.h</a>
to see the existing style strucs. Find the one that you want to store the
data on. In this example, we want to put it on the nsStyleUserInterface struct,
however there is also a class nsStyleUIReset that holds the non-inherited
values, so we will use that one (remember, our property is not inherited).
Add a <a href="#StyleContextMember">data member</a>
to hold the value:
<pre>struct nsStyleUIReset: public nsStyleStruct {
nsStyleUIReset(void);
nsStyleUIReset(const nsStyleUIReset&amp; aOther);
~nsStyleUIReset(void);
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_UIReset)
void* operator new(size_t sz, nsPresContext* aContext) {
return aContext->AllocateFromShell(sz);
}
void Destroy(nsPresContext* aContext) {
this-&gt;~nsStyleUIReset();
aContext-&gt;FreeToShell(sizeof(nsStyleUIReset), this);
};
PRInt32 CalcDifference(const nsStyleUIReset&amp; aOther) const;
PRUint8 mUserSelect; // [reset] (selection-style)
PRUnichar mKeyEquivalent; // [reset] XXX what type should this be?
PRUint8 mResizer; // [reset]
<b><a name="StyleContextMember"></a>PRUint8 mForceBrokenImageIcon; // [reset] (0 if not forcing, otherwise forcing)</b>
};
</pre>
In the implementation file <a href="http://lxr.mozilla.org/seamonkey/source/content/shared/src/nsStyleStruct.cpp">
nsStyleContext.cpp </a>
add the new data member to the constructors of the style struct and the CalcDifference
method, which must return the correct style-change hint when a change to
your new property is detected. The constructor changes are obvious, but here
is the CalcDifference change for our example:<br>
<pre>PRInt32 nsStyleUIReset::CalcDifference(const nsStyleUIReset&amp; aOther) const
{
<b> if (mForceBrokenImageIcon == aOther.mForceBrokenImageIcon) {</b>
if (mResizer == aOther.mResizer) {
if (mUserSelect == aOther.mUserSelect) {
if (mKeyEquivalent == aOther.mKeyEquivalent) {
return NS_STYLE_HINT_NONE;
}
return NS_STYLE_HINT_CONTENT;
}
return NS_STYLE_HINT_VISUAL;
}
return NS_STYLE_HINT_VISUAL;
}
<b>return NS_STYLE_HINT_FRAMECHANGE;
</b>}
</pre>
<h3>CSSStyleRule</h3>
The nsCSSStyleRule must be updated to manage mapping the declaration to the
style struct. In the file <a href="http://lxr.mozilla.org/seamonkey/source/content/html/style/src/nsCSSStyleRule.cpp">
nsCSSStyleRule.cpp</a>
, locate the Declaration mapping function corresponding to the style struct
you have added your property to. For example, we <a href="http://bugzilla.mozilla.org/MapUIForDeclChange">
update </a>
MapUIForDeclaration:<br>
<pre>static nsresult
MapUIForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID&amp; aID, nsCSSUserInterface&amp; aUI)
{
if (!aDecl)
return NS_OK; // The rule must have a declaration.
nsCSSUserInterface* ourUI = (nsCSSUserInterface*)aDecl-&gt;GetData(kCSSUserInterfaceSID);
if (!ourUI)
return NS_OK; // We don't have any rules for UI.
if (aID == eStyleStruct_UserInterface) {
if (aUI.mUserFocus.GetUnit() == eCSSUnit_Null &amp;&amp; ourUI-&gt;mUserFocus.GetUnit() != eCSSUnit_Null)
aUI.mUserFocus = ourUI-&gt;mUserFocus;
if (aUI.mUserInput.GetUnit() == eCSSUnit_Null &amp;&amp; ourUI-&gt;mUserInput.GetUnit() != eCSSUnit_Null)
aUI.mUserInput = ourUI-&gt;mUserInput;
if (aUI.mUserModify.GetUnit() == eCSSUnit_Null &amp;&amp; ourUI-&gt;mUserModify.GetUnit() != eCSSUnit_Null)
aUI.mUserModify = ourUI-&gt;mUserModify;
if (!aUI.mCursor &amp;&amp; ourUI-&gt;mCursor)
aUI.mCursor = ourUI-&gt;mCursor;
}
else if (aID == eStyleStruct_UIReset) {
if (aUI.mUserSelect.GetUnit() == eCSSUnit_Null &amp;&amp; ourUI-&gt;mUserSelect.GetUnit() != eCSSUnit_Null)
aUI.mUserSelect = ourUI-&gt;mUserSelect;
if (!aUI.mKeyEquivalent &amp;&amp; ourUI-&gt;mKeyEquivalent)
aUI.mKeyEquivalent = ourUI-&gt;mKeyEquivalent;
if (aUI.mResizer.GetUnit() == eCSSUnit_Null &amp;&amp; ourUI-&gt;mResizer.GetUnit() != eCSSUnit_Null)
aUI.mResizer = ourUI-&gt;mResizer;
<b>
<a name="MapUIForDeclChange"></a>if (aUI.mForceBrokenImageIcon.GetUnit() == eCSSUnit_Null &amp;&amp; ourUI-&gt;mForceBrokenImageIcon.GetUnit() == eCSSUnit_Integer)
aUI.mForceBrokenImageIcon = ourUI-&gt;mForceBrokenImageIcon;</b>
}
return NS_OK;
}
</pre>
<h3><a name="RuleNode">Rule Node</a></h3>
Now we have to update the RuleNode code to know about the new property. First,
locate the PropertyCheckData array for the data that you added the new property
to. For this example, we add the following:<br>
<pre>static const PropertyCheckData UIResetCheckProperties[] = {
CHECKDATA_PROP(nsCSSUserInterface, mUserSelect, CHECKDATA_VALUE, PR_FALSE),
CHECKDATA_PROP(nsCSSUserInterface, mResizer, CHECKDATA_VALUE, PR_FALSE),
CHECKDATA_PROP(nsCSSUserInterface, mKeyEquivalent, CHECKDATA_VALUELIST, PR_FALSE)
<b>CHECKDATA_PROP(nsCSSUserInterface, mForceBrokenImageIcon, CHECKDATA_VALUE, PR_FALSE)</b>
};
</pre>
The first two arguments correspond to the structure and data member from
the CSSDeclaration, the third is the data type, the fourth indicates
whether it is a coord value that uses an explicit inherit value on the
style data struct that must be computed by layout.<br>
<br>
Next, we have to make sure the ComputeXXX method for the structure the property
was added to is updated to mange the new value. In this example we need to
modify the nsRuleNode::ComputeUIResetData method to handle the CSS Declaration
to the style struct:<br>
<pre> ...
// resizer: auto, none, enum, inherit
if (eCSSUnit_Enumerated == uiData.mResizer.GetUnit()) {
ui-&gt;mResizer = uiData.mResizer.GetIntValue();
}
else if (eCSSUnit_Auto == uiData.mResizer.GetUnit()) {
ui-&gt;mResizer = NS_STYLE_RESIZER_AUTO;
}
else if (eCSSUnit_None == uiData.mResizer.GetUnit()) {
ui-&gt;mResizer = NS_STYLE_RESIZER_NONE;
}
else if (eCSSUnit_Inherit == uiData.mResizer.GetUnit()) {
inherited = PR_TRUE;
ui-&gt;mResizer = parentUI-&gt;mResizer;
}
<b>// force-broken-image-icons: integer, inherit, -moz-initial
if (eCSSUnit_Integer == uiData.mForceBrokenImageIcons.GetUnit()) {
ui-&gt;mForceBrokenImageIcons = uiData.mForceBrokenImageIcons.GetIntValue();
} else if (eCSSUnit_Inherit == uiData.mForceBrokenImageIcons.GetUnit()) {
inherited = PR_TRUE;
ui-&gt;mForceBrokenImageIcons = parentUI-&gt;mForceBrokenImageIcons;
} else if (eCSSUnit_Initial == uiData.mForceBrokenImageIcons.GetUnit()) {
ui-&gt;mForceBrokenImageIcons = 0;
}</b>
if (inherited)
// We inherited, and therefore can't be cached in the rule node. We have to be put right on the
// style context.
aContext-&gt;SetStyle(eStyleStruct_UIReset, *ui);
else {
// We were fully specified and can therefore be cached right on the rule node.
if (!aHighestNode-&gt;mStyleData.mResetData)
aHighestNode-&gt;mStyleData.mResetData = new (mPresContext) nsResetStyleData;
aHighestNode-&gt;mStyleData.mResetData-&gt;mUIData = ui;
// Propagate the bit down.
PropagateDependentBit(NS_STYLE_INHERIT_UI_RESET, aHighestNode);
}
...
</pre>
<h3><a name="DOM">DOM</a></h3>
Users in scripts, or anywhere outside of layout/ or content/ may need to access
the new property. This is done using the CSS OM, specifically
<code>nsIDOMCSSStyleDeclaration</code>, <code>nsIDOMCSS2Properties</code>, and
<code>nsIDOMNSCSS2Properties</code>. By the magic of C++ pre-processing, the
CSS2Properties interfaces will be implemented automatically when you
<a href="#CSSPropList">add your property</a> to <a href="http://lxr.mozilla.org/seamonkey/source/content/shared/public/nsCSSPropList.h">
nsCSSPropList.h</a>. Because of this, if you fail to add your property to the
DOM interface, you will be rewarded with compiler errors. All you have to do
is modify <a href="http://lxr.mozilla.org/mozilla/source/dom/public/idl/css/nsIDOMCSS2Properties.idl">
nsIDOMCSS2Properties.idl</a> and add the appropriate attribute to the
<code>nsIDOMNSCSS2Properties</code> interface (lower in the file).
For example:<br>
<pre> attribute DOMString MozForceBrokenImageIcon;
// raises(DOMException) on setting
</pre>
<h3><a name="Layout">Layout</a></h3>
OK, finally the style system is supporting the new property. It is time to
actually make use of it now.<br>
<br>
In layout, retrieve the styleStruct that has the new property from the frame's
style context. Access the new property and get its value. It is that simple.
For this example, it looks like this, in nsImageFrame:<br>
<pre> PRBool forceIcon = PR_FALSE;
const nsStyleUIReset* styleData;
GetStyleData(eStyleStruct_UIReset, (const nsStyleStruct*&amp;) styleData);
if (styleData-&gt;mForceBrokenImageIcon) {
forceIcon = PR_TRUE;
}
</pre>
Create some testcases with style rules that use the new property, make sure
it is being parsed correctly. Test it in an external stylesheet and in inline
style. Test that it is inherited correctly, or not inherited as appropriate
to your property. Update this document with any further details, or correcting
any errors.<br>
</body></html>

View File

@@ -1,112 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Layout Detailed Design Template</title>
<meta name="author" content="Marc Attinasi (attinasi@netscape.com)">
</head>
<body>
<h1><font color="#cc0000">Gecko Layout Detailed Design Document Template</font></h1>
[Use this template to start your detailed design. Replace items in square
brackets with the appropriate text for your component, class or system. &nbsp;Keep
in mind that this is just a general template intended for most designs.
Your specific design may require different organization or topics - the
goal is to provide detailed information about the software to the reader.]<br>
<br>
<h1>[Component / Class Name] Detailed Design</h1>
<h2>Overview</h2>
[Introduce the scope of this design document: what is being documented here.
Provide a reference back to the High Level design(s) that correspond.]<br>
<hr width="100%" size="2">
<h2>[Class / Component A]</h2>
[Briefly refresh the reader with the purpose of the class or component.
Provide enough information to make accessible the following sections on the
public API, private methods and members, and algorithms. Bring up and tricky
or otherwise interesting relationships that will be detailed.]<br>
<br>
<h3>Public API</h3>
[Show the public API for the component, as IDL, C++ header file, or as a
pseudo-code description. &nbsp;If using a source file, the comments in the
source file should cover most of the detail needed. If they do not, then add
that detail there. &nbsp;See the Overview document for more details on the
scope of information that should be presented.]<br>
<h3>Protected API</h3>
[If there is a protected API, list the methods and members and indicate
the responsibilities of the callers with respect o calling the base class,
enforcing base class invariants, etc.]<br>
<br>
<h3>Implementation Notes</h3>
[The nasty details of the implementation get exposed here. This section
can be broken down into subsections as necessary, and should include details
of particularly important algorithms, performance characteristics or constraints,
memory usage, tricky ownership issues, and anything else that would make understanding
the implementation easier for the reader.]<br>
<h4>Algorithms</h4>
<h5>[Interesting Algorithm 1: The internally maintained sorted list]</h5>
[explain the nature of the algorithm, the reason it was chosen, the types
of input is is expected to operate on, etc. Annotated pseudo-code is a good
idea here, but actual code is often too detailed to b of much use by itself.
It the actual code is sufficient to understand it, then this subsection is
probably not needed.]<br>
<h5>[Interesting Algorithm 2: Handling overflow of the input buffer]</h5>
[your description here]<br>
<h4></h4>
<hr width="100%" size="2">
<h2>[Class / Component B]</h2>
[Repeat the structure for the next class or component.]<br>
<br>
<hr width="100%" size="2">
<h2>Cross-Component Algorithms</h2>
[specify the details of algorithms that cross a single component. refer
to each component, describe the flow of control, the responsibilities of each
component along the way, the error handling, the state-management if any,
and the expected results for a given input. Generally each of these algorithms
gets its own subsection.]<br>
<h3>[Turning a byte-stream into a fully parsed token-tree]</h3>
[Detailed description, pesudo-code, state transitions, etc.]<br>
<h3>[Managing updates to the the document]</h3>
[Detailed description, pesudo-code, state transitions, etc.]<br>
<br>
<hr width="100%" size="2">
<h2>Tech Notes</h2>
[This section contains links to tech notes related to the implementations
covered in this design. &nbsp;Tech Notes tend to be extremely specific, often
recipes for how to do something or how to fix a class of defects. &nbsp;If
the tech note is more general, it may be a good idea to move it into the Detailed
design itself.]<br>
<ul>
<li>[<a href="link%20to%20tech%20note">Debugging buffer overflows</a>
]</li>
<li>[<a href="link%20to%20tech%20note">Adding new element or attribute
types</a>
]</li>
<li>[<a href="link%20to%20tech%20note">How To detect and fix problems
with the alignment of elements</a>
]</li>
<li>[<a href="link%20to%20tech%20note">Fix for Bug 666: ownership of tokens
was mistakenly transferred</a>
]</li>
</ul>
<br>
</body>
</html>

View File

@@ -1,241 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {font-family:arial}
.log {background-color:silver; color:blue}
pre.log {display:table-cell}
</style>
<title>Debugging facilities in HTML-Table code</title>
</head>
<body>
<h1>Debugging facilities in HTML-table code</h1>
<h2>Reflow</h2>
<p>The most efficient tool to claim that html-table code is the victim and not the source of layout bugs is a <a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/frame_reflow_debug.html">frame reflow debug log</a>. Look there especially how the maxElementsize (MES) and desired size are propagated.
<h2>Block Reflow</h2>
<p>
Another possibilty to debug the reflow process is implemented inside <a href="http://lxr.mozilla.org/seamonkey/source/layout/html/base/src/nsBlockFrame.cpp">nsBlockFrame.cpp</a>. It can be invoked by<p>
<code>set GECKO_BLOCK_DEBUG_FLAGS=reflow</code>
<p>
The available options are:
<ul>
<li><code>reflow</code>
<li> <code>really-noisy-reflow</code>
<li><code>max-element-size</code>
<li><code> space-manager</code>
<li><code>verify-lines</code>
<li><code>damage-repair</code>
<li><code>lame-paint-metrics</code>
<li><code>lame-reflow-metrics</code>
<li><code>disable-resize-opt</code>
</ul>
<p>
These options can be combined with a comma separated list
Messages generated by the <code>reflow</code> switch:
<ul>
<li><code> Block(div)(1)@00BE5AC4: reflowing dirty lines computedWidth=9000 computedHeight=1500</code>
<ul>
<li> this message is generated inside of <br>
<code>nsresult nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)</code>
<li> it first shows the Block ID and Address
<li>and then the computed width and Height from the HTMLReflowState.
</ul>
</ul>
<h2>DEBUG_TABLE_STRATEGY</h2>
<p>
The table layout strategy can be visualized by defining in the <a href="http://lxr.mozilla.org/seamonkey/source/layout/html/table/src/Makefile.in">makefiles</a> the constant DEBUG_TABLE_STRATEGY.
If one takes for instance the following table
<table cellspacing="10"><tr><th>rendering</th><th>code</th></tr>
<tr valign="top"><td valign="top" style="padding-top:10px">
<table border width="300">
<colgroup>
<col>
<col width="50%">
<col width="1*">
<col>
</colgroup>
<tr>
<td style="width:80px">cell 1</td>
<td>cell 2</td>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
</td>
<td valign="top"><pre class="log">
&lt;table border width="300"&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col width="50%"&gt;
&lt;col width="1*"&gt;
&lt;col&gt;
&lt;/colgroup&gt;
&lt;tr&gt;
&lt;td style="width:80px"&gt;cell 1&lt;/td&gt;
&lt;td&gt;cell 2&lt;/td&gt;
&lt;td&gt;cell 3&lt;/td&gt;
&lt;td&gt;cell 4&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</pre>
</td>
</tr>
</table>
<p>
it will produce the following log at the entrance of <code>AssignNonPctColWidths</code>:
<p>
<table class="log"><tr><td>
<pre>
AssignNonPctColWidths en max=4500 count=0
***START TABLE DUMP***
mColWidths=-1 -1 -1 -1
col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780
**START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 **END COL DUMP**
**START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 **END COL DUMP**
**START COL DUMP** colIndex=2 isAnonymous=0 constraint=0
widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 **END COL DUMP**
**START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 **END COL DUMP**
***END TABLE DUMP***
</pre>
</td></tr></table>
<p>
The <span class="log">en</span> stands for entrance (<span class="log">ex</span> for leaving a routine). The first line of the data dump shows that no width has yet been assigned to the columns <span class="log">mColWidths=-1 -1 -1 -1</span>, <code>-1</code> stands for:
<pre>
#define WIDTH_NOT_SET -1
</pre>
<p>
This is followed by a reference to the column frame pointers:
<p>
<pre class="log">
col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780
</pre>
<p>
This is followed by the information which width has been set for each column. The index of the column, whether it is anonymous and what kind of constrained has been applied<span class="log">colIndex=0 isAnonymous=0 constraint=0</span>. The following constraint types are known:
<p>
<pre>
eNoConstraint = 0,
ePixelConstraint = 1, // pixel width
ePercentConstraint = 2, // percent width
eProportionConstraint = 3, // 1*, 2*, etc. cols attribute assigns 1*
e0ProportionConstraint = 4 // 0*, means to force to min width
</pre>
<p>
After this follows the width information for each column:
<p>
<pre class="log">
widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
</pre>
<p>
The table code knows ten different width's:
<pre>
#define NUM_WIDTHS 10
#define NUM_MAJOR_WIDTHS 3 // MIN, DES, FIX
#define MIN_CON 0 // minimum width required of the content + padding
#define DES_CON 1 // desired width of the content + padding
#define FIX 2 // fixed width either from the content or cell, col, etc. + padding
#define MIN_ADJ 3 // minimum width + padding due to col spans
#define DES_ADJ 4 // desired width + padding due to col spans
#define FIX_ADJ 5 // fixed width + padding due to col spans
#define PCT 6 // percent width of cell or col
#define PCT_ADJ 7 // percent width of cell or col from percent colspan
#define MIN_PRO 8 // desired width due to proportional &lt;col&gt;s or cols attribute
#define FINAL 9 // width after the table has been balanced, considering all of the others
</pre>
<p>
In the last log snippet none of these width's has been set.
Leaving AssignNonPctColWidths shows that already to all columns a width of 360 twips has been assigned
<pre class="log">
AssignNonPctColWidths ex
***START TABLE DUMP***
mColWidths=360 360 360 360
col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780
**START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
widths=360 540 1230 -1 -1 -1 -1 -1 -1 360 **END COL DUMP**
**START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
widths=360 540 -1 -1 -1 -1 -1 -1 -1 360 **END COL DUMP**
**START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
widths=360 540 -1 -1 -1 -1 -1 -1 540 360 **END COL DUMP**
**START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
widths=360 540 -1 -1 -1 -1 -1 -1 -1 360 **END COL DUMP**
***END TABLE DUMP***
</pre>
<p>
The first column has already the minimum content width, the table column can't shrink below that, the desired content width of <span class="log">540</span> twips, thats the space to layout <code>cell 1</code> without wrapping the text and the <span class="log">1230</span> which correspond to the <code>style="width:80px"</code> at the first cell. At this step the final size is <span class="log">360</span> twips.
<p>
<table cellpadding="8">
<tr>
<th> MIN_CON</th><th>DES_CON</th><th>FIX</th><th>MIN_ADJ</th><th>DES_ADJ</th><th>FIX_ADJ</th><th>PCT</th><th> PCT_ADJ</th><th> MIN_PRO</th><th>FINAL</th>
</tr>
<tr align="center">
<td>360</td><td> 540</td><td> 1230 </td><td>-1</td><td> -1 </td><td>-1</td><td> -1</td><td> -1</td><td> -1</td><td> 360</td></tr></table>
<p>
There was no change till the entrance of <code>BalanceColumnWidths
</code>
<p>
<pre class="log">
BalanceColumnWidths en count=1
***START TABLE DUMP***
mColWidths=360 360 360 360
col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780
**START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
widths=360 540 1230 -1 -1 -1 -1 -1 -1 360 **END COL DUMP**
**START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
widths=360 540 -1 -1 -1 -1 -1 -1 -1 360 **END COL DUMP**
**START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
widths=360 540 -1 -1 -1 -1 -1 -1 540 360 **END COL DUMP**
**START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
widths=360 540 -1 -1 -1 -1 -1 -1 -1 360 **END COL DUMP**
***END TABLE DUMP***
</pre>
<p>
But at the end the final distribution between the columns has been reached.
<p>
<pre class="log">
BalanceColumnWidths ex
***START TABLE DUMP***
mColWidths=1230 2160 465 465
col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780
**START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
widths=360 540 1230 -1 -1 -1 -1 -1 -1 1230 **END COL DUMP**
**START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
widths=360 540 -1 -1 -1 -1 2160 -1 -1 2160 **END COL DUMP**
**START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
widths=360 540 -1 -1 -1 -1 -1 -1 540 465 **END COL DUMP**
**START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
widths=360 540 -1 -1 -1 -1 -1 -1 -1 465 **END COL DUMP**
***END TABLE DUMP***
</pre>
<p>
The column dump is implemented in <code>nsTableColFrame.cpp</code> in the routine:
<code>void nsTableColFrame::Dump(PRInt32 aIndent)</code>.
<h2>DEBUG_TABLE_REFLOW_TIMING</h2>
<p>needs to be written
<hr>
<p style="text-align:right">author: Bernd Mielke <br>2002-06-05</p>
</body>
</html>

View File

@@ -1,221 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
body {font-family:arial}
.log {background-color:silver; color:blue}
</style>
<title> Debugging Frame Reflow</title>
</head>
<body>
<h1>Debugging Frame Reflow HowTo</h1>
<h2>General Overview</h2>
<p> The frame reflow can be logged with the debug capabilties implemented in <a href="http://lxr.mozilla.org/seamonkey/source/layout/html/base/src/nsFrame.cpp"><code>nsFrame.cpp</code></a>.
It provides the following information for each frame at the
start of its reflow
<ul>
<li>reflow reason
<li>available width, available height
<li>computed width, computed height
<li>the previous and the next frame in flow
<li>and a count number.
</ul>
<p>When the frame's reflow is finished the following information is displayed :</p>
<ul>
<li>reflow metric (desired) width, height
<li>max. element size (MES) width
<li>maximum Width
<li>frame status
<li>overflow area
</ul>
<h2>Getting the log</h2>
<ul>
<li>Make sure that your build is a <b>debug</b> build.
<li>Create a text file (for instance <code>reflow_rules.txt</code>).
<li>Enter this line in the text file <pre>* 1</pre>
<li>Save the text file in the <code>%DIST%</code> directory
<li>Go to the <code>%DIST%</code> directory
<li>enter from command line: <code>set GECKO_DISPLAY_REFLOW_RULES_FILE=reflow_rules.txt</code>
<li> Run <code>viewer &gt; logfile.txt</code> and load your testcase. The
logfile will contain all the promised information.
</ul>
<h2>Log File analyis</h2>
<p>The logfile for a simple table like</p>
<pre>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table width="100"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;foo&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p> will create the following log:</p>
<table class="log"><tr><td>
<pre>
VP 00B97C30 r=0 a=9180,4470 c=9180,4470 cnt=856
scroll 00B97EE0 r=0 a=9180,4470 c=9180,4470 cnt=857
scroll 00B97EE0 r=0 a=9180,4470 c=9180,4470 cnt=858
canvas 00B97C6C r=0 a=9180,UC c=9180,4470 cnt=859
area 02D7AFE4 r=0 a=9180,UC c=9180,UC cnt=860
text 02D7B150 r=0 a=9180,UC c=UC,UC cnt=861
text 02D7B150 d=0,0
block 02D7B210 r=0 a=9180,UC c=8940,UC cnt=862
block 02D7B210 d=8940,0
area 02D7AFE4 d=9180,120
canvas 00B97C6C d=9180,4470
scroll 00B97EE0 d=9180,4470
scroll 00B97EE0 d=9180,4470
VP 00B97C30 d=9180,4470
VP 00B97C30 r=1 a=9180,4470 c=9180,4470 cnt=863
scroll 00B97EE0 r=1 a=9180,4470 c=9180,4470 cnt=864
scroll 00B97EE0 r=1 a=9180,4470 c=9180,4470 cnt=865
canvas 00B97C6C r=1 a=9180,UC c=9180,4470 cnt=866
area 02D7AFE4 r=1 a=9180,UC c=9180,UC cnt=867
block 02D7B210 r=1 a=9180,UC c=8940,UC cnt=868
text 02D7B3F8 r=0 a=8940,UC c=UC,UC cnt=869
text 02D7B3F8 d=0,0
tblO 02D7B5F0 r=0 a=8940,UC c=0,0 cnt=870
tbl 02D7B7EC r=0 a=8940,UC c=1500,UC cnt=871
rowG 00B984A4 r=0 a=UC,UC c=UC,UC cnt=872
row 02D7BAF8 r=0 a=UC,UC c=UC,UC cnt=873
cell 02D7BC98 r=0 a=UC,UC c=UC,UC cnt=874
block 02D7BCF8 r=0 a=UC,UC c=UC,UC cnt=875
text 02D7BE84 r=0 a=UC,UC c=UC,UC cnt=876
text 02D7BE84 d=300,285 me=300
block 02D7BCF8 d=300,300 me=300
cell 02D7BC98 d=330,330 me=330
row 02D7BAF8 d=UC,330
rowG 00B984A4 d=UC,330
colG 02D7BFB0 r=0 a=UC,UC c=UC,UC cnt=877
col 02D7C0D8 r=0 a=0,0 c=1500,UC cnt=878
col 02D7C0D8 d=0,0
colG 02D7BFB0 d=0,0
rowG 00B984A4 r=2 a=1500,UC c=1500,UC cnt=879
row 02D7BAF8 r=2 a=1500,UC c=1500,UC cnt=880
cell 02D7BC98 r=2 a=1440,UC c=1410,UC cnt=881
block 02D7BCF8 r=2 a=1410,UC c=1410,UC cnt=882
block 02D7BCF8 d=1410,300
cell 02D7BC98 d=1440,330
row 02D7BAF8 d=1500,330
rowG 00B984A4 d=1500,330
colG 02D7BFB0 r=2 a=1500,UC c=1500,UC cnt=883
col 02D7C0D8 r=0 a=0,0 c=1500,UC cnt=884
col 02D7C0D8 d=0,0
colG 02D7BFB0 d=0,0
tbl 02D7B7EC d=1500,390
tblO 02D7B5F0 d=1500,390
text 02D7C130 r=0 a=8940,UC c=UC,UC cnt=885
text 02D7C130 d=0,0
block 02D7B210 d=8940,390
area 02D7AFE4 d=9180,630
canvas 00B97C6C d=9180,4470
scroll 00B97EE0 d=9180,4470
scroll 00B97EE0 d=9180,4470
VP 00B97C30 d=9180,4470
</pre>
</td></tr></table>
<p>
The first line shows the reflow of the viewport (<code class="log">VP</code>). This viewport has the address <code class="log">00B97C30</code>. It is the initial reflow: <code class="log">r=0</code>. Other reflow reasons are: </p>
<table>
<tr><td>1</td><td>incremental reflow</td></tr>
<tr><td>2</td><td>resize reflow</td></tr>
<tr><td>3</td><td>style change reflow</td></tr>
<tr><td>4</td><td>dirty reflow.</td></tr>
</table>
<p>The available width is 9180 twips. The available height is 4470 twips (<code class="log">a=9180,4470</code>). The computed width is 9180 twips. The computed height is 4470 twips (<code class="log">c=9180,4470</code>). The line count is 856 (<code class="log">cnt=856</code>).
<p>
Below this is a line that reads:<p><code class="log">tblO 02D7B5F0 r=0 a=8940,UC c=0,0 cnt=870</code></p><p> Here the <code class="log">UC</code> shows that on initial reflow the available height for the outer table frame is unconstrained.
<p>
The table cell requires its children to compute the MES. It is reported back from the block as:
<p><code class="log">block 02D7BCF8 d=300,300 me=300</code></p>
<p>The block max. element size is 300 twips.
<p> The second table reflow is started at
<p><code class="log">rowG 00B984A4 r=2 a=1500,UC c=1500,UC cnt=879</code></p>
<p>where the previous information is used.
The block has been required to compute the max. element size only once and it reports now:
<p> <code class="log">block 02D7BCF8 d=1410,300</code></p>
<p>The block shows the same address as the previous one.
<p>Frames with children that overflow the parent have the <code>NS_FRAME_OUTSIDE_CHILDREN</code> flag set. For these frames
the overflowarea is displayed as <code class="log">block 025ED8F0 d=8940,1020 o=(0,0) 9180 x 1020</code>. The overflow area is specified as (x,y) origin and width x height.
<p> The reflow finishes at the same level where it started.
<h2>Advanced reflow debugging</h2>
<p>The previously described technique dumps the data for every frame. Sometimes the log is clearer if only the main frames are shown.
The entries in the reflow log can be controlled on a frame level. For instance adding <code>text 0</code> to the rules in <code>reflow_rules.txt</code> would hide the text entries from the reflow. The display of the following frames can be turned on by adding a line with the frame name and <code>1</code> or turned off by adding a line with the frame name and <code>0</code>:</p>
<table cellspacing="5">
<tr><th style="text-align:left">short name</th><th style="text-align:left">layout tag</th></tr>
<tr><td>area</td><td>area</td></tr>
<tr><td>block</td><td>block</td></tr>
<tr><td>br</td><td>br</td></tr>
<tr><td>bullet</td><td>bullet</td></tr>
<tr><td>button</td><td>gfxButtonControl</td></tr>
<tr><td>hr</td><td>hr</td></tr>
<tr><td>frameI</td><td>htmlFrameInner</td></tr>
<tr><td>frameO</td><td>htmlFrameOuter</td></tr>
<tr><td>img</td><td>image</td></tr>
<tr><td>inline</td><td>inline</td></tr>
<tr><td>letter</td><td>letter</td></tr>
<tr><td>line</td><td>line</td></tr>
<tr><td>select</td><td>select</td></tr>
<tr><td>obj</td><td>object</td></tr>
<tr><td>page</td><td>page</td></tr>
<tr><td>place</td><td>placeholder</td></tr>
<tr><td>posInline</td><td>positionedInline</td></tr>
<tr><td>canvas</td><td>canvas</td></tr>
<tr><td>root</td><td>root</td></tr>
<tr><td>scroll</td><td>scroll</td></tr>
<tr><td>caption</td><td>tableCaption</td></tr>
<tr><td>cell</td><td>tableCell</td></tr>
<tr><td>bcCell</td><td>bcTableCell</td></tr>
<tr><td>col</td><td>tableCol</td></tr>
<tr><td>colG</td><td>tableColGroup</td></tr>
<tr><td> tbl</td><td>table</td></tr>
<tr><td>tblO</td><td>tableOuter</td></tr>
<tr><td>rowG</td><td>tableRowGroup</td></tr>
<tr><td>row</td><td>tableRow</td></tr>
<tr><td>textCtl</td><td>textInput</td></tr>
<tr><td>text</td><td>text</td></tr>
<tr><td>VP</td><td>viewport</td></tr>
</table>
<p>Once the problem is reduced to a single frame level, placing a breakpoint at <code>DisplayReflowEnterPrint</code> in <a href="http://lxr.mozilla.org/seamonkey/source/layout/html/base/src/nsFrame.cpp"><code>nsFrame.cpp</code></a> is a very efficient way to step through
the reflow tree.
<h2>Other reflow debug options</h2>
<h3>GECKO_DISPLAY_REFLOW_FLAG_PIXEL_ERRORS</h3>
<p>
Setting this option via <code>set GECKO_DISPLAY_REFLOW_FLAG_PIXEL_ERRORS = 1</code> enables a verification for each coordinate value that the coordinates are aligned at pixel boundaries.
<table class="log"><tr><td>
<pre>
row 0268A594 r=0 a=UC,UC c=UC,20 cnt=870
VALUE 20 is not a whole pixel
cell 0268A6C0 r=0 a=UC,UC c=UC,15 cnt=871
block 0268A764 r=0 a=UC,UC c=UC,UC cnt=872
block 0268A764 d=0,0 me=0
cell 0268A6C0 d=0,0 me=0
row 0268A594 d=UC,20
VALUE 20 is not a whole pixel
rowG 0268A02C d=UC,695
VALUE 695 is not a whole pixel</pre>
</td></tr></table>
<p>
While unaligned values at the entrance of a frame reflow can be ignored, when they appear at the exit of a routine this can cause display errors like stray lines. OS2 is very vulnerable to pixel alignement errors as text is drawn on pixel boundaries.
<h3>GECKO_DISPLAY_REFLOW_INDENT_UNDISPLAYED_FRAMES</h3>
<p>
Setting this option via <code>set GECKO_DISPLAY_REFLOW_INDENT_UNDISPLAYED_FRAMES = 1</code> will cause an advance of the indent even for frames which are blocked via the reflow rules file.
</body>
</html>

View File

@@ -1,105 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Layout High Level design Template</title>
<meta name="author" content="Marc Attinasi (attinasi@netscape.com)">
</head>
<body>
<h1><font color="#cc0000">Gecko Layout High Level Design Document Template</font></h1>
[Use this template to start your high level design. Replace items in square
brackets with the appropriate text for your component, class or system. &nbsp;Keep
in mind that this is just a general template intended for most designs.
Your specific design may require different organization or topics - the
goal is to provide high-level information about the software to the reader.]<br>
<br>
<h1>[Component/Class/System Name] High Level Design</h1>
<br>
<h2>Overview</h2>
[Provide a descriptive overview of the component, class, or system that
you are documenting. Describe what the system is supposed to do, where it
is in the overall system, who the clients are, how it is expected to perform,
and any other information that is important to convey to somebody interested
in understanding what the documented system is all about.]<br>
<br>
<h2>Data Model</h2>
[This section describes the classes or components that make up the data
model for the system being documented. It can include a graphical representation
of the classes and their relationships to each other (derivation, aggregation,
ownership, usership, etc.). No implementation details are to be included
here, but general relationships and inter-relationships should be shown and
briefly described. The reader should be able to understand the players in
the system, and the extent to which those players interact with or are related
to the other players.]<br>
<h4>Class/Component Diagram</h4>
<blockquote>
<div align="Left"><img src="ExampleClassDiagram.jpg" alt="Example Class Diagram" width="324" height="270" title="Example Class Diagram">
<br>
</div>
</blockquote>
<ul>
<li>[Class/<a href="Link%20To%20Component%20A%20Detailed%20Design">
Component A</a>
]: This class is used to...</li>
<li>[Class/<a href="Link%20To%20Component%20B%20Detailed%20Design">
Component B</a>
]: This class works with Class A to...<br>
</li>
</ul>
<br>
<h2>Use Case</h2>
[Use Cases describe interactions between specific instances of the objects
or components described in the Data Model. &nbsp;There will generally be
use cases for each &nbsp; interesting runtime interaction between the objects
in the system. An extremely simple system will have at least one use case
describing the behavior of the simple system in action, but most systems
have many use cases corresponding to the any things that the system does.
&nbsp;The reader should be able to find the use case (or cases) that correspond
to the situation they are interested in understanding, and they should be
able to learn how data flows through the system, what objects are involved,
how &nbsp;object and data life-cycles are managed (e.g. where allocations
ad deallocations occur, and who maintains ownership). This section makes up
the bulk of the document. It touches on implementations and algorithms, but
rather than describing them in detail, it stays high-level and links to the
detailed designs that correspond.]<br>
<h4>[Use Case 1: Component is Created]</h4>
The component is created by a client with...<br>
&nbsp;[Image could go here if it were interesting enough...]<br>
<br>
<h4>[Use Case 2: Component is Destroyed]</h4>
When the client is finished with the instance they created (or were given
ownership of) the destroy it by calling...<br>
<br>
<h4>[Use Case 3: Component is used to find all invalid links on the page]</h4>
Descriptive text of how the component is invoked goes here. The other
components that it uses to carry out its task are shown, and the general
flow of data is documented.<br>
[Picture of the component instance with annotations showing data flow,
ownership, etc. goes here]<br>
<h2>State Transitions</h2>
[Where appropriate, the discrete states of a system should be enumerated
and the transitions between the states defined. &nbsp;Not all systems require
full state transition diagrams, but most systems have at least a handful
of interesting states, and at least a small number of interesting stimuli
that cause transitions from one state to another. &nbsp; Of course, classes
or components that are not stateful have no need for this section.]<br>
<br>
<br>
</body>
</html>

View File

@@ -1,122 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Layout Documentation Index Page</title>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<style>
/* colors for status of documents */
*.ood { color: red !important; }
*.good { color: black !important; }
*.wip { color: blue !important; }
*.unassigned { color: green !important; }
/* inherit the colors into the links */
p > a { color: inherit; }
</style>
</head>
<body>
<h1>Layout Technical Documentation: Primary Index</h1>
<p class="wip">Document Status: Work In Progress (attinasi)
<p>The goal of this document is to provide extensive links to documentation
on the Gecko Layout components and classes. There are two sections containing
links to the documents, and there is overlap between these sections by
design. First, there is a '<a href="#TopicIndex">Topics</a>' section,
where documentation is listed by generic topics, more or less free-form
and ad-hoc. Second, there is a '<a href="#ClasscomponentIndex">Class and
Component</a>' section, where specific classes and components are listed,
mapping naturally to the source code. All documents should be indexed in
both sections, so pick the index that corresponds to what you are thinking
about. A <a href="#HowTo">Tech Notes section</a> is also included to help
contributors find information on small topics and issues, including simple
'How To' cookbooks.
<p><blockquote>
<i>For information about the structure of layout documents, see the <a
href="http://lxr.mozilla.org/seamonkey/source/layout/doc/overview.html">Layout
Documentation Overview</a>&nbsp; and the Layout DocumentationTemplates
(<a
href="http://lxr.mozilla.org/seamonkey/source/layout/doc/hld-template.html">High
Level Design Template</a> / <a
href="http://lxr.mozilla.org/seamonkey/source/layout/doc/dd-template.html">Detailed
Design Template</a>).
</i>
</blockquote>
<hr width="100%" size="2">
<div align="left"
style="border: 1px solid blue; margin: auto; width: 65%;"><big><b>Legend</b></big>
<ul>
<li class="good">Black: complete and believed to be up to date (class='good')</li>
<li class="wip">Blue: incomplete or work in progress (class='wip')</li>
<li class="ood">Red: out of date or innacurate (class='ood', bug should be filed and bug number / link noted)</li>
<li class="unassigned">Green: unassigned work</li>
</li>
</ul>
</div>
<h2><a name="TopicIndex"></a>Topic Indices</h2>
<div style="border: 1px solid black; margin: 1em; padding: 1em;">
<p class="wip">What is Layout? The High Level Layout Overview (attinasi)
<p class="wip">Debugging Layout (bernd)
<p class="unassigned">How Reflow works
<p class="wip">Tables balancing (karnaze)
<p class="wip">Table Borders collapsing (karnaze)
<p class="wip">Block in Inline situations (kin)
<p class="good"><a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/HLD-SpaceManager.html">Managing Floats</a>
<p class="unassigned">Text Measurement and Text Breaking
<p class="unassigned">Image loading and display
<p class="unassigned">Margin Collapsing
<p class="unassigned">Scrolling Blocks
<p class="unassigned">Box and Block interactions
<p class="wip">Printing and Print Preview (rods)
<p class="unassigned">Plugins: the object frame and related layout classes
</div>
<h2><a name="ClasscomponentIndex"></a>Class and Component Indices</h2>
<div style="border: 1px solid black; margin: 1em; padding: 1em;">
<p class="unassigned">Presentation Shell and Context: High Level / Detailed
<p class="unassigned">Frames and the Frame Manager: High Level / Detailed
<p class="good">Reflow: <a href="http://www.mozilla.org/newlayout/doc/reflow.html">High Level (waterson)</a> / <span class="unassigned">Detailed</span>
<p class="unassigned">Block and Line layout: High Level / Detailed
<p class="unassigned">TextFrame - Text Measurement and Line Breaking: High Level / Detailed
<p class="wip">PageSequenceFrame and PageFrame: High Level / Detailed (rods)
<p class="unassigned">Object Frame: High Level / Detailed
<p class="good">Space Manager:
<a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/HLD-SpaceManager.html">High Level</a> /
<a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/DD-SpaceManager.html">Detailed</a>
<p class="wip">Layout Debug Plugin: high Level / Detailed (dcone)
</div>
<h2><a name="HowTo"></a>How To / Tech Notes</h2>
<div style="border: 1px solid black; margin: 1em; padding: 1em;">
<p class="good"><a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/frame_reflow_debug.html">How to Debug Reflow </a>
<p class="good"><a href="http://www.mozilla.org/newlayout/doc/block-and-line.html">Waterson's Block and Line Cheat Sheet</a>
<p class="good"><a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/adding-style-props.html">How to add Style Properties</a>
<p class="unassigned">Measuring Layout Performance
<p class="wip"><a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/regression_tests.html">Running the Regression Tests (bernd/dcone)</a>
<p class="good"><a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/debugtable.html">Debugging Table Reflow</a>
</div>
<hr width="100%" size="2">
<p>Authors:
<ul>
<li>Marc Attinasi (attinasi@netscape.com)</li>
</ul>
<p>Document History:
<ul>
<li>05/06/2002 - Marc Attinasi: created</li>
<li>05/13/2002 - Marc Attinasi: added Block and Line Cheat Sheet, and link to existing Reflow document</li>
<li>05/21/2002 - Marc Attinasi: added Bernd's Table Reflow Debugging How-To (thanks Bernd!)</li>
<li>05/21/2002 - Bernd Mielke: added Frame Reflow Debugging How-To</li>
<li>06/16/2002 - Bernd Mielke: added layout regression test description</li>
</ul>
</body>
</html>

View File

@@ -1,205 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.5-22 i686) [Netscape]">
</head>
<body>
<h1>
<u>Block Layout</u></h1>
This document attempts to describe how "block" layout works in the mozilla
layout engine.
<p><tt>nsBlockFrame</tt> implements layout behavior that conforms to the
CSS "display:block" and "display: list-item" layout. It has several responsibilities:
<ol>
<li>
&nbsp;Line layout. The block is responsible for flowing inline elements
into "lines" and applying all of the css behavior as one might expect,
including line-height, vertical-align, relative positioning, etc.</li>
<li>
Float management. The block is responsible for the reflow and placement
of floating elements.</li>
<li>
Child block management. Blocks can contain inline elements and block elements.
Hence, blocks are responsible for reflowing child blocks. The majority
of that logic has been split out into nsBlockReflowContext, but a fair
amount remains here.</li>
<li>
Supporting table reflow. The block has to carefully compute the "max-element-size"
information needed by tables. Hence, any time changes are made here one
should always run the table regression tests because the odds are you broke
one of them!</li>
</ol>
<h3>
<u>The Big Picture for Block Reflow</u></h3>
The block frame uses a list of nsLineBox's to keep track of each "line"
of frames it manages. There are two types of lines:
<blockquote>"inline" lines which contain only inline elements
<br>"block" lines which contain exactly one block element</blockquote>
Each line has a "dirty" bit which indicates that it needs reflow. Reflow
consists of identifying which lines need to be marked dirty and then reflowing
all lines. For lines which are "clean" the reflow logic will endeavor to
recover the state of reflow <i>as if the line had been reflowed</i>. This
saves time and allows for a faster incremental reflow. For lines which
are dirty, the line is reflowed appropriately.
<p>The only special thing about incremental reflow command handling is
that it marks lines dirty before proceeding, and keeps track of the child
frame that is the next frame on the reflow command path.
<p>Here is a list of the various classes involved in block layout:
<p><b>nsBlockFrame</b>
<blockquote>The primary culprit.</blockquote>
<b>nsBlockReflowState</b>
<blockquote>This helper class is used to augment the nsHTMLReflowState
with other information needed by the block reflow logic during reflow.
It is a temporary object that is designed to live on the processor stack
and contains "running" state used by the blocks reflow logic.</blockquote>
<b>nsBlockBandData</b>
<blockquote>Another helper class that wraps up management of a space manager
(nsISpaceManager, nsSpaceManager) and nsBandData. It also assists in management
of floating elements. While nsSpaceManager is policy free, nsBlockBandData
provides specific HTML and CSS policy.</blockquote>
<b>nsBlockReflowContext</b>
<blockquote>A helper class that encapsulates the logic needed to reflow
a child block frame. This is used by the block code reflow a child block
and to reflow floating elements (which are to be treated as blocks according
to the CSS2 spec).</blockquote>
<b>nsLineBox</b>
<blockquote>A data class used to store line information for the block frame
code. Each line has a list of children (though the frames are linked together
across lines to maintain the sibling list for nsIFrame::FirstChild) and
some other state used to assist in incremental reflow.</blockquote>
<b>nsLineLayout</b>
<blockquote>This class is the line layout engine. Its a passive entity
in the sense that its the responsibility of the block/inline code to use
the class (this is done so that the line layout engine doesn't have to
manage child frame lists so that both nsBlockFrame and nsInlineFrame can
use the class).</blockquote>
<b>nsTextRun</b>
<blockquote>This is a data class used to store text run information. Text
runs are <i>logically</i> contiguous runs of text (they may or may not
be structurally contiguous). The block frame stores a pointer to a list
of nsTextRun's and during line layout provides the list to the nsLineLayout
engine so that when text is reflowed the text layout code (nsTextFrame)
can find related text to properly handle word breaking.</blockquote>
<h3>
<u>Frame construction methods</u></h3>
When the blocks child list is modified (AppendFrames, InsertFrames, RemoveFrame)
the block code updates its nsLineBox list. Since each nsLineBox is typed
(some are marked "inline" and some are marked "block"), the update logic
maintains the invariant of "one block frame per block line".
<p>When structural changes are made to the blocks children (append/insert/remove)
the block code updates the line's and then marks the affected lines "dirty"
(each nsLineBox has a dirty bit). After the structural changes are finished
then the block will generate an incremental reflow command of type "ReflowDirty".
<h3>
<u>Line Layout</u></h3>
Line layout consists of the placement of inline elements on a line until
there is no more room on the line. At that point the line is "broken" and
continued on the next line. This process continues until all inline elements
have been exhausted. The block code maintains a list of "nsLineBox"'s to
facilitate this. These are used instead of frames because they use less
memory and because it allows the block to directly control their behavior.
<p>The helper class nsLineLayout provides the majority of the line layout
behavior needed by the block.
<p>The block does keep "text-run" information around for the nsLineLayout
logic to use during reflow. Text runs keep track of logically adjacent
pieces of text within a block. This information is essential for properly
computing line and word breaking. Why? Well, because in html you can write
something like this:
<p>&nbsp; &lt;p>I &lt;b>W&lt;/b>as thinking one day&lt;/p>
<p>Notice that the word "Was" is composed of two pieces of text, and that
they do <i>not</i> have the same parent (content or frame). To properly
reflow this and not break the word prematurely after the "W", the text-run
information is used by the text frame code to "look ahead" and prevent
premature breaking.
<p>Lines also keep track of the type of "break" that occurred on the line.
This is used, for example, to support html's "&lt;br clear=left>" behavior.
<h3>
<u>Float Management</u></h3>
Since child block elements are containing blocks for floats, the only
place where a block frame will see a float is as part of an inline line.
Consequently, the nsLineBox will only keep track of floats on inline
lines (saving storage for block lines).
<p>The nsLineLayout class and the block frame cooperate in the management
of floats. Since the frame construction code leaves a "placeholder" frame
in-flow where the float was found, when nsLineLayout reflows a placeholder
frame it knows to inform the block about it. That triggers the blocks "AddFloat"
logic which then determines where the float should be placed (on the
current line or below the current line).
<p>The block frame uses the space manager to manage the effects of floats,
namely the consumption of available space. For example, for a left aligned
floating element, the inline elements must be placed to the right of the
float. To simplify this process, the spacemanager is used to keep track
of available and busy space. Floats when placed mark space as busy and
the spacemanager will them compute the available space. Most of this logic
is handled by the nsBlockReflowState which uses a helper class, nsBlockBandData,
in concert with the space manager, to do the available space computations.
<h3>
<u>Child Block Placement</u></h3>
Child block reflow is done primarily by using the nsBlockReflowContext
code. However, a key detail worth mentioning here is how margins are handled.
When the nsHTMLReflowState was created, we placed into it the logic for
computing margins, border and padding (among other things). Unfortunately,
given the css rules for sibling and generational margin collapsing, the
nsHTMLReflowState is unable to properly compute top and bottom margins.
Hence, the block frame and the nsBlockReflowContext code perform that function.
At the time that the nsBlockReflowContext was designed and implemented
we thought that it could compute the top-margin itself and then proceed
to place the child block element. However, that turned out to be wrong
(oh well) because the correct available space isn't known until <i>after</i>
the top margin is computed. Hence, there is some unfortunate duplication
of reflow state calculations present in the block frame code.
<h3>
<u>Bullets</u></h3>
Another type of block frame is the "display: list-item". List-items use
nsBulletFrame's to manage bullet reflow. However, the block is responsible
for bullet placement. In most situations, the nsLineLayout class is used
to do the placement. However, if the first effective child of the block
is another block, then the block has to do the placement itself.
<h3>
<u>Blank lines</u></h3>
Because our content model contains as much of the original source documents
content as possible, we end up with a lot of white space that ends up being
compressed into nothingness. This white space ends up impacting this logic
in several ways. For example:
<p>&nbsp; &lt;div>
<br>&nbsp;&nbsp; &lt;p>abc&lt;/p>
<br>&nbsp;&nbsp; &lt;p>def&lt;/p>
<br>&nbsp; &lt;/div>
<p>In the content model for the above html, there is white space between
the various block elements (some after the &lt;div>, some after the first
&lt;/p>, again after the second &lt;/p>).
<p>For css margin collapsing to work properly, each of those instances
of white space has to behave as if they didn't exist. Consequently, there
is special logic in the inline line reflow code, and in the nsBlockReflowContext
code and in the GetTopBlockChild method, to basically ignore such lines.
<h3>
<u>First-letter style</u></h3>
The block contributes, in a small way, to first-letter style reflow. The
frame construction code is responsible for creating the list of child frames
for all frames, including the block. It manages the creation of letter-frames,
where appropriate, so that all the block has to do is reflow them almost
normally like other inline frames.
<p>There are two things different that the block does:
<p>It is responsible for calling nsLineLayout::SetFirstLetterStyleOK
<br>It is responsible for continuing to place frames on a line, even after
a frame has said "it can't fit". Normally during inline reflow, if a frame
comes back and says it can't fit, the block will end the line, push all
remaining frames to the next line and pick up the reflow from there after
making sure the frame that didn't fit is continued. For letter-frames,
this would result in the first-letter being on one line with the remaining
text on subsequent lines. Hence, the block code handles this special case.
<br>&nbsp;
<h3>
<u>First-line style</u></h3>
First-line is handled entirely by the frame construction code.
<br>&nbsp;
<br>&nbsp;
</body>
</html>

View File

@@ -1,97 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Nisheeth Ranjan">
<meta name="GENERATOR" content="Mozilla/4.5 [en]C-NSCP (WinNT; U) [Netscape]">
<title>HTML Layout Internals</title>
</head>
<body>
<h1>
HTML Layout Internals</h1>
<h2>
Big picture</h2>
An HTML document comes in from netlib into the HTML parser.&nbsp; The parser
creates parser nodes and feeds them to the content sink.&nbsp; The content
sink constructs a content model that represents the hierarchical structure
of the document.&nbsp; As different sub-trees in the content model are
fully available, the stylesheet processor iterates over them and creates
the corresponding frame hierarchy.&nbsp; The frames recursively layout
and render themselves.
<p>The part that we are going to drill down into is the code in the block
and inline frame classes.&nbsp; Block and inline are the two primary display
types specified in CSS and are used in the layout of most of the HTML tags.&nbsp;
The table related tags have their own display types like "table-cell",
"table-row", etc. and their implementation is a separate topic in itself.
<h2>
Block and inline code</h2>
The main classes involved in the layout of HTML documents are nsBlockFrame
and nsInlineFrame, both of which inherit from nsHTMLContainerFrame (why?).&nbsp;
These classes are persistent across reflows and are organized in a hierarchy
to constitute the frame model of the Gecko system.&nbsp; The frame model
is derived by applying style and presentation semantics to the content
model.&nbsp; Each frame in the frame model has a one to one correspondence
with a rectangular region on the presentation context (screen, printer,
etc.) and contains the formatting information needed to render that rectangle.&nbsp;
The block and inline frame classes implement the nsIFrame and nsIHTMLReflow
interfaces.&nbsp; The nsIFrame interface contains methods for managing
child frames and linkage with sibling frames, accessing the style context
associated with the frame, painting the frame, and handling events that
are passed in from the widget hierarchy.&nbsp; The nsIHTMLReflow interface
inherits from the nsIReflow interface and adds methods related to word
breaking and whitespace querying.&nbsp; The nsIReflow interface defines
the Reflow() method that initiates the reflow process along with the WillReflow()
and DidReflow() methods that get called before and after the reflow process
respectively.&nbsp; nsReflowState and nsReflowMetrics are parameters to
the templatized nsIReflow interface: the former is used to hold state during
reflow of a frame and the latter is used to return the frame's desired
size and alignment to the parent frame during the reflow process.
<p>nsBlockReflowContext and nsBlockReflowState both hold state information
during the reflow process.&nbsp; nsBlockReflowContext encapsulates the
state and algorithm for reflowing child block frames.&nbsp; nsBlockReflowState
contains state and methods used by a block frame to reflow itself.&nbsp;
Both these classes are instantiated once per block frame.
<p>The nsLineLayout class is the engine used by the block and inline frame
classes to layout themselves on a line.&nbsp; Frames get passed in to the
nsLineLayout class via the BeginSpan() and EndSpan() methods.&nbsp; Each
span represents a run of frames with the same style data (???).&nbsp; Other
methods exist on the nsLineLayout class to position and size the frames
on the current line.
<p>nsBlockBandData is the class used to manage the processing of the space-manager
(nsSpaceManager) band data.&nbsp; It provides HTML/CSS specific semantics
on top of the general space management facilities provided by nsSpaceManager.
<p>nsSpaceManager is a class that is told about regions that reserve space
and exposes methods to query for available space in a given band.
<p>The nsLineBox class represents a horizontal line of frames and is singly
linked to the next line box in the document.&nbsp; It is basically a container
of a frame list that share the property of being on the same line in the
formatted output of the document.
<p>The nsTextRun class holds on to a list of frames containing pieces of
text that form a logical text run.&nbsp; This is needed because a single
text run can occur on leaves at many levels of the document's content tree.&nbsp;
This class gives the text layout process an efficient way to get access
to text runs and, so, determine where word breaks should occur.
<h2>
Questions</h2>
What are anonymous blocks (nsBlockFrame.h)?
<br>What is the difference between a span and a band (nsLineLayout)?
<br>Why do nsBlockFrame and nsInlineFrame both inherit from nsHTMLContainerFrame?
<h2>
To Do</h2>
<ol>
<li>
Provide more information about methods and state of each of the classes
above.</li>
<li>
Give a description of how the above classes interact with each other as
a simple HTML document is laid out.&nbsp; Then, add in different features
to the HTML that exercise different areas of the code, like floats, anonymous
blocks, etc.</li>
</ol>
</body>
</html>

View File

@@ -1,120 +0,0 @@
@namespace xlink url("http://www.w3.org/1999/xlink");
Documentation {
display: block;
font-family: Verdana, sans-serif;
font-size: 11pt;
margin: 8px;
}
Author {
display: block;
font-size: 90%;
}
Author:before {
content: "Author: ";
font-weight: bold;
}
UpdateDate {
display: block;
font-size: 90%;
}
UpdateDate:before {
content: "Updated: ";
font-weight: bold;
}
Title {
display: block;
font-size: 250%;
font-weight: bold;
letter-spacing: -1.25pt;
margin-top: 0;
margin-bottom: .5em;
}
SectionHeading {
display: block;
font-size: 125%;
font-weight: bold;
margin-top: 2em;
margin-bottom: .5em;
}
Body {
display: block;
margin-top: 1em;
margin-bottom: .5em;
}
SectionHeading + Body { /* body after section heading */
margin-top: 0;
}
Components {
display: block;
margin-top: 1em;
margin-left: .5in;
border: dotted 1px black;
}
:link:hover {
background-color: blue;
color: white;
cursor: pointer;
}
/* workaround for above rule not working */
*[xlink|type] {
cursor: pointer;
}
/* workaround for above rule not working */
*[xlink|show="replace"] {
cursor: pointer;
}
Term {
display: block;
font-weight: bold;
background-color: lightyellow;
padding-left: .5em;
}
Definition {
display: block;
margin-left: 40px;
}
Interfaces, Characteristics, Items, Categories {
display: block;
margin-left: 40px;
list-style-position: outside;
list-style-type: disc;
}
Purposes {
display: block;
margin-left: 40px;
list-style-position: outside;
list-style-type: decimal;
counter-reset: -html-counter 0;
}
Interface, Characteristic, Purpose, Item, Category {
display: list-item;
}
RunIn {
display: inline;
font-weight: bold;
}
Note {
width: 2in;
height: auto;
float: right;
font-size: 90%;
margin-left: 1em;
margin-right: .5em;
border-top: solid 2px black;
border-bottom: solid 1px black;
padding: .5em 0;
}
Note:before {
content: "Note";
font-weight: bold;
display: inline;
background-color: black;
color: white;
margin-right: .25em;
padding: .5em .25em 0 .25em;
}

View File

@@ -1,275 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="layout.css" type="text/css"?>
<!DOCTYPE Documentation>
<Documentation xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xlink="http://www.w3.org/1999/xlink">
<Title>Gecko Layout Engine</Title>
<Author xlink:type="simple" xlink:show="new" xlink:href="mailto:troy@netscape.com">Troy Chevalier</Author>
<UpdateDate>8 August 1999</UpdateDate>
<SectionHeading>Overview</SectionHeading>
<Body>Gecko is Mozilla's new layout engine. It is based on the HTML4, CSS1, XML 1.0,
and DOM Internet standards, and it is built using a modular XPCOM-based
architecture.</Body>
<Body>When we talk about layout, we're referring to the formatting process that applies
presentation styles to a source document. The formatting process is controlled
by the style specification.</Body>
<SectionHeading>Components</SectionHeading>
<Body>Here are a list of components and terms that will be referenced by this document.</Body>
<Components>
<Term>Parser</Term>
<Definition>Either the <A xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozilla.org/newlayout/doc/parser.html">HTML</A>
or XML parser. Processes the document and makes calls to the content sink.</Definition>
<Term>Content sink</Term>
<Definition>Called by the parser. Responsible for building the content model.</Definition>
<Term><A xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozilla.org/newlayout/doc/contentmodel.html">Content model</A></Term>
<Definition>Consists of document object and a tree of content objects. Changes to the
content model result in modifications of the frame model.</Definition>
<Term>Frame model</Term>
<Definition><A xlink:type="simple" xlink:show="replace" xlink:href="#Frames">Frames</A> are formatting
objects. Each frame defines a particular set of formatting characteristics.</Definition>
<Term><A xlink:type="simple" xlink:show="replace" xlink:href="#Reflow">Reflow</A></Term>
<Definition>The formatting process. Reflow of the frame model defines the visual appearance
of the formatted document.</Definition>
<Term><A xlink:type="simple" xlink:show="replace" xlink:href="#FrameConstruction">Frame construction</A></Term>
<Definition>Initial creation and updating of the frame model in response to changes to the
content model and changes to the style data.</Definition>
<Term><A xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozilla.org/newlayout/doc/style.html">Style system</A></Term>
<Definition>Provide the mapping and management of style data onto document content in a given
presentation. Major components are style set, style sheets, style sheet and
rules, style context, and style sheet loader.</Definition>
<Term>Presentation shell</Term>
<Definition>Controlling point for managing the presentation of a document.</Definition>
<Term><A xlink:type="simple" xlink:show="replace" xlink:href="http://www.mozilla.org/newlayout/doc/viewsystem.html">View system</A></Term>
<Definition>Consists of a view manager and view objects arranged in a tree hierarchy.
Views support overlapped positioning, z-order sorting, and opacity levels.</Definition>
</Components>
<SectionHeading>Document Loading</SectionHeading>
<Body>The basic flow of control is as follows: as the parser encounters tokens it notifies
the content sink that a new node (or child node) is encountered. The content sink
creates the appropriate type content object and inserts it into the content model.</Body>
<Body>Whenever the content model changes the document's observers are notified. The presentation
shell is one of the document observers. The presentation shell forwards the document
change notification to the style set object</Body>
<Body>The style set passes the notification to the frame construction code, the
frame construction code creates new frames and inserts them into the frame model. The
document is reflowed, and the formatted changes are displayed.
</Body>
<Body>
The actual interfaces involved are:
<Interfaces>
<Interface>nsIDocument</Interface>
<Interface>nsIDocumentObserver</Interface>
<Interface>nsIPresShell</Interface>
<Interface>nsIStyleSet</Interface>
<Interface>nsIStyleFrameConstruction</Interface>
<Interface>nsIFrame</Interface>
</Interfaces>
</Body>
<Body>All of the interface files are located in the mozilla/layout/base/public
directory.</Body>
<SectionHeading>Object Lifetimes</SectionHeading>
<Body>Gecko supports multiple views of the same document. This means you can print the
same document that you're viewing on the screen, and there's only one content
model. Because there's just a single content model, each of the content objects
is referenced counted. The document holds a reference to the root content object,
and each content node holds a reference to its child content nodes.</Body>
<Body>Each view of the document has a separate presentation shell, style manager,
style set, and frame hierarchy. The presentation shell is the controlling point for
the presentation of a document, and it holds a reference to the document object.</Body>
<Body>Frames and views are not referenced counted. The lifetime of the frame hierarchy
is bounded by the lifetime of the presentation shell which owns the frames. The
lifetime of the view hierarchy is bounded by the lifetime of the view manager
that owns the views.</Body>
<SectionHeading><html:a name="Frames">Frames</html:a></SectionHeading>
<Body>Each frame defines a particular set of formatting characteristics. Frames have
the opportunity to:
<Characteristics>
<Characteristic>reflow (format) their child frames</Characteristic>
<Characteristic>render their appearance</Characteristic>
<Characteristic>handle mouse and keyboard events</Characteristic>
<Characteristic>display a cursor</Characteristic>
<Characteristic>have an associated view object</Characteristic>
</Characteristics>
</Body>
<Body>Frames can have multiple child lists, the default unnamed child list
(referred to as the principal child list) and additional named child lists.
There is an ordering of frames within a child list, but no ordering
between frames in different child lists of the same parent frame.</Body>
<Body>The principal child list contains the flowed children, and the additional
child lists are for out-of-flow frames like floated elements and absolutely
positioned elements.</Body>
<Body>Child frames are linked together in a singly linked list. Each frame
defines its own local coordinate space. Frame bounding rects are in twips,
and the origin is relative to the upper-left corner of its parent frame.
The bounding rect includes the content area, borders, and padding.</Body>
<SectionHeading><html:a name="FrameConstruction">Frame Construction</html:a></SectionHeading>
<Body>The frame construction process begins with a notification that content
has been added or removed or that style has changed.</Body>
<Body>The first step is to resolve style information for the content element.
This process creates a style context that is stored in the frame (see
nsIStyleContext).</Body>
<Body>Once style is resolved construction rules are used to decide the type of
frame to create. First we look at the element's tag and special case some
things like IMG elements. If we don't create a frame that way, then we use
the 'display' property to dictate what type of frame to create. Typically
it's a block or inline frame.</Body>
<Body>For a 'display' value of 'none' no frame is created. For elements that are
out of the flow (for example, a floated element or an absolutely positioned
element), a placeholder frame is also created. The placeholder frame is inserted
into the flow exactly where the out-of-flow frame would have been inserted.
The out-of-flow frame is then inserted as a child of its containing block in
one of the additional child lists. Floated frames are inserted into the
"Float-list" and absolutely positioned frames are inserted into the
"Absolute-list".</Body>
<SectionHeading>Frame Manager</SectionHeading>
<Body>The frame manager is owned by the presentation shell and used by both the
presentation shell and the frame construction code. It serves two main
purposes:
<Purposes>
<Purpose>provides a service for mapping from content object to frame and from out-of-flow
frame to placeholder frame</Purpose>
<Purpose>coordinates structural modifications to the frame model</Purpose>
</Purposes>
</Body>
<Body>In many places in the frame code we need to find the frame associated with
a particular content object. In order to quickly implement this operation we
maintain a mapping from content objects to frames. The frame construction adds
and removes entries from the map as frames are created and destroyed.</Body>
<Body>When creating new frames and removing existing frames, the frame construction
code doesn't directly modify the frame hierarchy. Instead if informs the frame
manager and has it coordinate the request. If the frame model lock is available,
the change is processed immediately; otherwise, the request is queued and
processed later.</Body>
<Body>The frame manager also coordinates processing of replaced elements that can't
be rendered (for example, an IMG or OBJECT element), and it allows client to
register to be notified when a particular frame is being destroyed. This is
needed because frames are not reference counted. It's used by the event manager
and other clients to ensure that any outstanding references to the frame are
cleaned up.</Body>
<SectionHeading><html:a name="Reflow">Reflow</html:a> Process</SectionHeading>
<Note>The fact that are two reflow interfaces reflects an early
goal of having core layout and HTML specific layout. The core reflow process would
be the same for all frames, and each class of formatting objects (for
example, CSS and DSSSL) would have their own reflow additions.</Note>
<Body>The reflow process is a top-down protocol where a frame is given some
available space and asked to reflow its child frames and return a desired
size.</Body>
<Body>The reflow process is not part of the nsIFrame interface. The generic reflow
interface is defined in the nsIFrameReflow interface, and the HTML/CSS specific
reflow interface is defined in the nsIHTMLReflow interface.</Body>
<Body>An important part of the reflow process is the calculation of the computed
values for the CSS properties. This includes things like 'width', 'height',
and 'margin', and involves calculation of the containing block width and height
and percentage based values and properties whose value is inherited.</Body>
<Body>This process is encapsulated in the HTML specific reflow state struct
(struct nsHTMLReflowState) that is passed in as part of reflow. The reflow
states are linked together with the reflow state for a child frame pointing
to its parent frame's reflow state. This allows us to walk up the reflow state
structures and calculate containing block width and height and percentage
based values.</Body>
<Body>In addition to the computed values for the CSS box model properties, the
following items are also included:
<Items>
<Item>reflow reason that indicates why the frame is being reflowed</Item>
<Item>a rendering context that can be used to measure text</Item>
<Item>reflow command (only used for incremental reflow)</Item>
<Item>space manager</Item>
</Items>
</Body>
<Body>The most common reflow reasons are 'eReflowReason_Resize' (the viewport
has changed size) and 'eReflowReason_Incremental' (processing of an incremental
reflow command).</Body>
<Body>Reflow commands (see nsHTMLReflowCommand in mozilla/layout/html/base/src) are used
to kick off an incremental reflow. They're generated either by the style system
(in response to a style change) or by a frame itself (for example, if a frame has
dirty child frames that need to be reflowed it will generate a reflow command).</Body>
<Body>Reflow commands are queued by the presentation shell and then dispatched. Reflow
commands have a target frame, which is the frame for which the reflow command
is destined. In the example above the target frame is the frame with dirty child
frames that need to be reflowed. Reflow command processing follows a path from
the root frame down to the target frame.</Body>
<Body>The space manager (see nsISpaceManager in mozilla/layout/base/public) is used
when flowing text around floated elements. It has an API for managing bands of
unavailable space (space that is reserved for a floated element). Internally it
organizes the band data similar to how a region data structure works.</Body>
<SectionHeading>Frame Classes</SectionHeading>
<Body>There are four main categories of frame classes, all of which are located
in mozilla/layout/html/src:
<Categories>
<Category>core frame classes</Category>
<Category>table frame classes</Category>
<Category>form frame classes</Category>
<Category>frameset frame classes</Category>
</Categories>
</Body>
<Body><RunIn>The core frame classes</RunIn> implement the CSS viewport abstraction, scrolling,
block and inline display of flowed elements, floats, and absolute positioning.</Body>
<Body>For more information on block layout, click
<A xlink:type="simple" xlink:show="replace" xlink:href="block.html">here</A>. For more information about
line layout, click <A xlink:type="simple" xlink:show="replace" xlink:href="line-layout.html">here</A>.</Body>
<Body><RunIn>The table frame classes</RunIn> correspond to the HTML4 table spec, and in addition
to the table frame there are row group frames, row frames, column group frames,
column frames, and cell frames. There is an "outer" table frame as well that's
really an anonymous frame that contains the caption frame and the table frame
itself.</Body>
<Body>Table layout is determined in a 3-step process. In the first step, the table
is flowed into an infinitely wide and tall space. This gives us the minimum and
desired sizes for every cell in the table. In the second step, the table constraints
are factored in and widths are assigned to every cell. In the third step, heights are
assigned to every cell based on the computed width constraint. The results of the first
step are cached and only need to be recomputed when content or constraints are changed.</Body>
<SectionHeading>Event Manager</SectionHeading>
<Body>To be written</Body>
</Documentation>

View File

@@ -1,114 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.5-22 i686) [Netscape]">
</head>
<body>
<h1>
<u>Line Layout</u></h1>
Line layout is the process of placing inline frames horizontally (left
to right or right to left depending on the CSS direction property value).
An attempt is made to describe how it works.
<p>nsLineLayout is the class that provides support for line layout. The
container frames nsBlockFrame and nsInlineFrame use nsLineLayout to perform
line layout and span layout. Span layout is a subset of line layout used
for inline container classes - for example, the HTML "B" element). Because
of spans, nsLineLayout handles the nested nature of line layout.
<p>Line layout as a process contains the following steps:
<ol>
<li>
Initialize the nsLineLayout object (done in nsBlockFrame). This prepares
the line layout engine for reflow by initializing its internal data structures.</li>
<br>&nbsp;
<li>
Reflowing of inline frames. The block code uses nsLineLayout's <b>ReflowFrame</b>
method to reflow each inline frame in a line. This continues until the
line runs out of room or the block runs out of frames. The block may be
reflowing a span (an instance of nsInlineFrame) which will recursively
use nsLineLayout for reflow and placement of the frames in the span.</li>
<p><br>Note that the container frames (nsBlockFrame/nsInlineFrame) call
nsLineLayout's ReflowFrame method instead of having the line layout code
process a list of children. This is done so that the container frames can
handle the issues of "pushing" and "pulling" of frames across continuations.
Because block and inline maintain different data structures for their child
lists, and because we don't want to mandate a common base class, the line
layout code doesn't control the "outer loop" of frame reflow.
<br>&nbsp;
<li>
Finish line layout by vertically aligning the frames, horizontally aligning
the frames and relatively positioning the frames on the line.</li>
</ol>
nsLineLayout is also used by nsBlockFrame to construct text-run information;
this process is independent of normal line layout is pretty much a hack.
<p>When frames are reflowed they return a reflow status. During line layout,
there are several additions to the basic reflow status used by most frames:
<ul>
<li>
NS_FRAME_COMPLETE - this is a normal reflow status and indicates that the
frame is complete and doesn't need to be continued.</li>
<li>
NS_FRAME_NOT_COMPLETE - this is another normal reflow status and indicates
that the frame is not complete and will need a continuation frame created
for it (if it doesn't already have one).</li>
<li>
NS_INLINE_BREAK - some kind of break has been requested. Breaks types include
simple line breaks (like the BR tag in html sometime does) and more complex
breaks like page breaks, float breaks, etc. Currently, we only support
line breaks, and float clearing breaks. Breaks can occur before the frame
(NS_INLINE_IS_BREAK_BEFORE) or after the frame (NS_INLINE_IS_BREAK_AFTER)</li>
</ul>
The handling of the reflow status is done by the container frame using
nsLineLayout.
<h3>
<u>Line Breaking</u></h3>
Another aspect of nsLineLayout is that it supports line breaking. At the
highest level, line breaking consists of identifying where it is appropriate
to break a line that doesn't fit in the available horizontal space. At
a lower level, some frames are breakable (e.g. text) and some frames are
not (e.g. images).
<p>In order to break text properly, some out-of-band information is needed
by the text frame code (nsTextFrame). In particular, because a "word" (a
non-breakable unit of text) may span several frames (for example: <b>"&lt;B>H&lt;/B>ello
there"</b> is breakable after the <b>"o"</b> in "<b>ello</b>" but not after
the <b>"H"</b>), text-run information is used to allow the text frame to
find adjacent text and look at them to determine where the next breakable
point is. nsLineLayout supports this by keeping track of the text-runs
as well as both storing and interrogating "word" state.
<h3>
<u>White-space</u></h3>
To support the white-space property, the line layout logic keeps track
of the presence of white-space in the line as it told to reflow each inline
frame. This allows for the compression of leading whitespace and the compression
of adjacent whitespace that is in separate inline elements.
<p>As a post-processing step, the TrimTrailingWhiteSpace logic is used
to remove those pesky pices of white-space that end up being placed at
the end of a line, that shouldn't really be seen.
<p>To support pre-formatted text that contains tab characters, the line
layout class keeps track of the current column on behalf of the text frame
code.
<h3>
<u>Vertical Alignment</u></h3>
Vertical alignment is peformed as a two and a half pass process. The first
pass is done during nsInlineFrame reflow: the child frames of the nsInlineFrame
are vertically aligned as best as can be done at the time. There are certain
values for the vertical-align property that require the alignment be done
after the lines entire height is known; those frames are placed during
the last half pass.
<p>The second pass is done by the block frame when all of the frames for
a line are known. This is where the final height of the line
<br>(not the line-height property) is known and where the final half pass
can be done to place all of the top and bottom aligned elements.
<br>&nbsp;
<h3>
<u>Horizontal Alignment</u></h3>
After all frames on a line have been placed vertically, the block code
will use nsLineLayout to perform horizontal alignment within the extra
space.
</body>
</html>

View File

@@ -1,898 +0,0 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Kipp E.B. HIckman">
<META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (WinNT; I) [Netscape]">
<TITLE>HTML</TITLE>
<BASE HREF="file:///s|/ns/xena/htmlpars/testhtml/">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#FF0000" VLINK="#800080" ALINK="#0000FF">
<H2>
HTML</H2>
This documents describes the complete handling of HTML in magellan. The
document covers the parsing process - how HTML is lexically analysized
and then interprted. After the parsing process is discussed we give a detailed
analysis of each HTML tag and the attributes that are supported, the values
for the attributes and how the tag is treated by magellan.
<H2>
Parsing</H2>
HTML is tokenized by an HTML scanner. The scanner is fed unicode data to
parse. Stream converters are used to translate from various encodings to
unicode. The scanner separates the input stream into tokens which consist
of:
<UL>
<LI>
text</LI>
<LI>
tags</LI>
<LI>
entities</LI>
<LI>
script-entities</LI>
<LI>
comments</LI>
<LI>
conditional comments</LI>
</UL>
The HTML parsing engine uses the HTML scanner for lexical anlaysis. The
parsing engine operates by attacking the input stream in a set of well
defined steps:
<UL>
<LI>
The parser processes the head portion of the document first, without emitting
any output. This is done to discover a few special features of html:</LI>
<UL>
<LI>
The parser processes META tags looking for META TARGET</LI>
<LI>
The parser processes META tags looking for META tags which affect the character
set. Nav4 handles the very first character set defining meta tag (all others
are ingored) by reloading the document with the proper character conversion
module inserted into the stream pipeline.</LI>
</UL>
<LI>
After the head portion is processed the parser then proceeds to process
the body of the document</LI>
</UL>
<H3>
Tag Processing</H3>
Tags are processed by the parser by locating a <B>"tag handler"</B> for
the tag. The HTML parser serves as the tag handler for all of the builtin
tags documented below. Tag attribute handling is done during translation
of tags into content. This mapping translates the tag attributes into content
data and into style data. The translation to style data is documented below
by indicating the mapping from tag attributes to their CSS1 (plus extensions)
equivalents.
<H3>
Special Hacks</H3>
The following list describes hacks added to the magellan parsing engine
to deal with navigator compatability. These are just the parser hacks,
not the layout or presentation hacks. Most hacks are intriduced for HTML
syntax error recovering. HTML doesn't specify much how to handle those
error conditions. Netscape has made big effort to render pages with non-prefect
HTML. For many reasons, new browsers need to keep compatible in thsi area.
<UL>
<LI>
Entities can be used as escape in quoted string. For value string in name-value
pair,&nbsp; see <A HREF="../testhtml/quote001.html">compatibility test
quote001.html</A>. Test line 70 shows that an entity quote at the begining
means the value is NOT quoted. Test line 90 shows that if the value is
started with a quote, then an entity quote does NOT terminate the value
string.</LI>
<LI>
Wrapping tags are special tags such as title, textarea, server, script,
style, and etc.. The comment in ns\lib\libparse\pa_parse.c says:</LI>
<BR>&nbsp; /*
<BR>&nbsp;&nbsp; * These tags are special in that, after opening one of
them, all other tags are ignored until the matching
<BR>&nbsp;&nbsp; * closing tag.
<BR>&nbsp;&nbsp; */
<BR>During the searching of an end tag, comments and quoted strings are
observed. see <A HREF="../testhtml/title01.html">compatibility test title01.html</A>.
6.0 handles coments now, need to add quoeted string.
<LI>
If a &lt;tr> or &lt;td> tag is seen outside any &lt;table> scope, it is
ignored. see <A HREF="../testhtml/table110.htm">compatibility test table110.htm</A>.</LI>
<LI>
<FONT COLOR="#000000">In case of table in table but not in cell, table
tags before the last table tag are ignored. We found this problem in some
Netscape public pages, see bug #85118. For example, &lt;table> &lt;table
border> .....,or &lt;table> &lt;tr> &lt;table border>...,&nbsp; the table
will be displayed with border.&nbsp;</FONT> <A HREF="../testhtml/table201.html">compatibility
test table201.html</A>. There table and tr tags are buffered for this recovery.
When a TD or CAPTION tag is open, the buffer is flushed out, because we
cannot buffer contents of TD or CAPTION for performance and memory constrains.
They are subdoc's and can be very big. If we see a &lt;table> outside cell
after previous table is flushed out, the new &lt;table> tag is ignored.
Nav4.0 can discard previous table in such case. <A HREF="../testhtml/tableall.html">tableall.html
</A>is the index for table test cases.</LI>
<LI>
Caption is not a commonly used feature. In Nav4.0, captions can be anywhere.
For Captions outside cells, the first one takes effect. For captions inside
cells, the last one takes effect, and they also close TD and TR. In 6.0,
caption is limited to the standard position: after &lt;table>. Captions
in other places are ignored, their contents are treated as text. See test
case table05a.html to table05o.html.</LI>
<LI>
<FONT COLOR="#000000">For &lt;table> &lt;tr> &lt;tr>, the first &lt;tr>
takes effect.</FONT></LI>
<LI>
The nav4 parser notices when it hits EOF and it's in the middle of scanning
in a comment. When this happens, the parser goes back and looks for an
improperly closed comment (e.g. a simple > instead of a -->). If it finds
one, it reparses the input after closing out the comment.</LI>
<LI>
<FONT COLOR="#FF0000">XXX Brendan also pointed out that there is something
similar done for tags, but I don't recall what it is right now.</FONT></LI>
<LI>
<FONT COLOR="#000000">When Nav4.0 sees the '&lt;' sign, it searchs for
'>', observing quoted values. If it cannot find one till EOF, the '&lt;'
sign is treated as text. In Xena 6.0, a limit is set for how far the '>'
is searched. the default limit is 4096 char, and there is a API HTMLScanner.setMaxTagLength()
to changed it. setting -1 means no limit, which is same as Nav4.0.</FONT></LI>
</UL>
<FONT COLOR="#FF0000">TODO:</FONT>
<UL><FONT COLOR="#FF0000">Document the mapping of tag attributes into CSS1
style, including any new "css1" attributes</FONT>
<BR>&nbsp;</UL>
<B>List of 6.0 features incompatible with 4.0</B>
<UL>
<LI>
Navigator 4.0 value string is truncated at 82 characters. XENA60 limit
is MAX_STRING_LENGTH = 2000.</LI>
<BR>&nbsp;</UL>
<HR WIDTH="100%">
<H2>
Tags (Categorically sorted)</H2>
All line breaks are conditional. If the x coordinate is at the current
left margin then a soft line break does nothing. Hard line breaks are ignored
if the last tag did a hard line break.
<P><B>divalign</B> = left | right | center | justify
<BR><B>alignparam</B> = abscenter | left | right | texttop | absbottom
| baseline | center | bottom | top | middle | absmiddle
<BR><B>colorspec</B> = named-color | #xyz | #xxyyzz | #xxxyyyzzz | #xxxxyyyyzzzz
<BR><B>clip</B> = [auto | value-or-pct-xy](1..4) (pct of width for even
coordinates; pct of height for odd coordinates)
<BR><B>value-or-pct = </B>an integer with an optional %; ifthe percent
is present any following characters are ignored!
<BR><B>coord-list</B> = <FONT COLOR="#DD0000">XXX</FONT>
<BR><FONT COLOR="#000000"><B>whitespace-strip</B> = remove leading and
trailing and any embedded whitespace that is not an actual space (e.g.
newlines)</FONT>
<H1>
Head objects:</H1>
<B>TITLE</B>
<UL>The TITLE tag is a container tag whose contents are not HTML. The contents
are pure text and are processed by the parser until the closing tag is
found. There are no attributes on the tag and any whitespace present in
the tag is compressed down with leading and trailing whitespace eliminated.
The first TITLE tag found by the parser is used as the document's title
(subsequent tags are ignored).</UL>
<B>BASE</B>
<UL>Sets the base element in the head portion of the document. Defines
the base URL for <FONT COLOR="#DD0000">all</FONT>? links in the document.
<BR>Attributes:
<UL><B>HREF</B>=url [This is an absolute URL]
<BR><B>TARGET</B>=string [must start with XP_ALPHA|XP_DIGIT|underscore
otherwise nav4 ignores it]</UL>
</UL>
<B>META</B>
<UL>Can define several header fields (content-encoding, author, etc.)
<BR>Attributes:
<UL><B>REL</B>=SMALL_BOOKMARK_ICON|LARGE_BOOKMARK_ICON
<UL><B>SRC</B>=string</UL>
<B>HTTP-EQUIV</B>="header: value"
<UL><B>CONTENT</B>=string</UL>
</UL>
HTTP-EQUIV values (from libnet/mkutils.c NET_ParseMimeHeader):
<UL>ACCEPT-RANGES
<BR>CONTENT-DISPOSITION
<BR>CONTENT-ENCODING
<BR>CONTENT-RANGE
<BR>CONTENT-TYPE [ defines character set only ]
<BR>CONNECTION
<BR>DATE
<BR>EXPIRES
<BR>EXT-CACHE
<BR>LOCATION
<BR>LAST-MODIFIED
<BR>LINK
<BR>PROXY-AUTHENTICATE
<BR>PROXY-CONNECTION
<BR>PRAGMA
<BR>RANGE
<BR>REFRESH
<BR>SET-COOKIE
<BR>SERVER
<BR>WWW-AUTHENTICATE
<BR>WWW-PROTECTION-TEMPLATE
<BR>WINDOW-TARGET</UL>
Style sheets and HTML w3c spec adds this:
<UL>CONTENT-STYLE-TYPE [ last one wins; overrides header from server if
any ]</UL>
</UL>
<B>LINK</B>
<UL>List related resources. Used by extensions mechanism to find tag handlers.
<FONT COLOR="#0000FF">/LINK == LINK!</FONT>
<BR>Attributes:
<UL><B>REL</B>=FONTDEF
<UL><B>SRC</B>=url</UL>
<B>REL</B>=STYLESHEET [ If MEDIA param is defined it must ==nc screen ]
<UL><B>LANGUAGE</B>=LiveScript|Mocha|JavaScript1.1|JavaScript1.2
<BR><B>TYPE</B>="text/javascript" | "text/css"
<BR><B>HREF</B>=url
<BR><B>ARCHIVE</B>=url
<BR><B>CODEBASE</B>=url
<BR><B>ID</B>=string
<BR><B>SRC</B>=url</UL>
</UL>
Note: HREF takes precedence over SRC in nav4.</UL>
<B>HEAD</B>
<UL>/HEAD clears the "in_head" flag (but leaves the "in_body" flag alone.
<BR>Text in head clears in_head, and set in_body true, just as if the author
forgot the /HEAD tag.
<BR>Attributes: none</UL>
<B>HTML</B>
<UL>Ignored.
<BR>Attributes: none</UL>
<B>STYLE</B>
<UL>Allowed anywhere in the document. Note that entities are not parsed
in the style tag's content.
<BR>Attributes:
<UL><B>LANGUAGE</B>=LiveScript|Mocha|JavaScript1.1|JavaScript1.2
<BR><B>TYPE</B>="text/javascript" | "text/css"
<BR><B>HREF</B>=url
<BR><B>ARCHIVE</B>=url
<BR><B>CODEBASE</B>=url
<BR><B>ID</B>=string
<BR><B>SRC</B>=url</UL>
</UL>
<B>FRAMESET</B>
<UL>Frameset with rows=1 and cols=1 is ignored.
<BR>Attributes:
<UL><B>FRAMEBORDER</B>= no | 0 (zero) [default is no_edges=false]
<BR><B>BORDER</B>= int [clamped: >= 0 &amp;&amp; &lt;= 100]
<BR><B>BORDERCOLOR</B>= color
<BR><B>ROWS</B>= pct-list
<BR><B>COLS</B>= pct-list</UL>
</UL>
<B>FRAME</B>
<UL>Border width of zero disables edges.
<BR>Attributes:
<UL><B>FRAMEBORDER</B>= no | 0 (zero) [default is framesets value]
<BR><B>BORDER</B>= int [clamped; >= 0 &amp;&amp; &lt;= 100]
<BR><B>BORDERCOLOR</B>= color
<BR><B>NORESIZE</B>= true [default is false]
<BR><B>SCROLLING</B>= yes | scroll | on | no | noscroll | off
<BR><B>SRC</B>= url [clamped: prevent recursion by eliminating any anscestor
references]
<BR><B>NAME</B>= string
<BR><B>MARGINWIDTH</B>= int (clamped: >= 1)
<BR><B>MARGINHEIGHT</B>= int (clamped: >= 1)</UL>
</UL>
<B>NOFRAMES</B>
<UL>Used when frames are disabled or for backrev browsers. Has no stylistic
consequences.</UL>
<H1>
<HR WIDTH="100%">Body objects:</H1>
&nbsp;<B>BODY</B>
<UL>The tag is only processed on open tags and it is always processed.
See ns\lib\layout\laytags.c, searching for "case P_BODY". During tag processing
the in_head flag is set to false and the in_body flag is set to true. An
attribute is ignored if the document already has that attribute set. Attributes
can be set by style sheets, or by previous BODY tags. see <A HREF="../testhtml/head02.html">test
head02.html</A>.
<BR>Attributes:
<UL><B>MARGINWIDTH</B>=int [clamped: >= 0 &amp;&amp; &lt; (windowWidth/2
- 1)]
<BR><B>MARGINHEIGHT</B>=int [clamped: >= 0 &amp;&amp; &lt; (windowHeight/2
- 1)]
<BR><B>BACKGROUND</B>=url
<BR><B>BGCOLOR</B>=colorspec
<BR><B>TEXT</B>=colorspec
<BR><B>LINK</B>=colorspec
<BR><B>VLINK</B>=colorspec
<BR><B>ALINK</B>=colorspec
<BR><B>ONLOAD, ONUNLOAD, UNFOCUS, ONBLUR, ONHELP</B>=script
<BR><B>ID</B>=string</UL>
</UL>
<B>LAYER, ILAYER</B>
<UL>Open layer/ilayer tag automaticly close out an open form if one is
open. It does something to the soft linebreak state too.
<BR>Attributes:
<UL><B>LEFT</B>=value-or-pct (pct of <TT>right-left</TT> margin)
<BR><B>PAGEX</B>=x (if no LEFT)
<BR><B>TOP</B>=value-or-pct
<BR><B>PAGEY</B>=y (if no TOP)
<BR><B>CLIP</B>=clip
<BR><B>WIDTH</B>=value-or-pct (pct of <TT>right-left</TT> margin)
<BR><B>HEIGHT</B>=value-or-pct
<BR><B>OVERFLOW</B>=string
<BR><B>NAME</B>=string
<BR><B>ID</B>=string
<BR><B>ABOVE</B>=string
<BR><B>BELOW</B>=string
<BR><B>ZINDEX</B>=int [any value]
<BR><B>VISIBILITY</B>=string
<BR><B>BGCOLOR</B>=colorspec
<BR><B>BACKGROUND</B>=url</UL>
</UL>
<B>NOLAYER</B>
<UL>Container for content which is used when layers are disabled or unsupported.
The content has no style consequences (though it could if somebody stuck
in some CSS1 style rules for it).</UL>
<B>P</B>
<UL>Closes the paragraph. If the attribute is present then an alignment
gets pushed on the alignment stack. All values are supported by nav4.
<BR>Attributes:
<UL><B>ALIGN</B>=divalign</UL>
</UL>
<B>ADDRESS</B>
<UL>There are no attributes. ADDRESS closes out the open paragraph. The
open tag does a conditional soft line break and then pushes a merge of
the current style with italics enabled onto the style stack. The close
always pop the style stack and also does a conditional soft line break.</UL>
<B>PLAINTEXT, XMP</B>
<UL>PLAINTEXT causes the remaining content to no longer be parsed. XMP
causes the content to not parse entities or other tags. The XMP can be
closed by it's own tag (on any boundary); PLAINTEXT is not closed (html3.2
allows it to be closed). Both tags change the style to a fixed font of
a</UL>
<B>LISTING</B>
<UL>Closes the paragraph. Does a hard line break on open and close. Open
pushes a fixed width font style of a particular font size on the style
stack. The close tag pops the top of the style stack.
<BR>Attributes: none</UL>
<B>PRE</B>
<UL>Closes the paragraph. The open tag does a hard line break. A fixed
font style (unless VARIABLE is present) is pushed on the style stack. The
close tag pops the top of the style stack. It also does a hard line break.
<BR>Attributes:
<UL><B>WRAP</B>
<BR><B>COLS</B>=int [clamped: >= 0]
<BR><B>TABSTOP</B>=int [clamped: >= 0; clamped value is replaced with default
value]
<BR><B>VARIABLE</B></UL>
</UL>
<B>NOBR</B>
<UL>This tag doesn't nest. Instead it just sets or clears a flag in the
state machine. It has no effect on any other state.</UL>
<B>CENTER</B>
<UL>Closes the paragraph. Always does a conditional soft line break. The
open tag pushes an alignment on the aligment stack. The close tag pops
the top alighment off.
<BR>Attributes: none</UL>
<B>DIV</B>
<UL>Closes the paragraph. Always does a conditional soft line break. COLS
defines the number of columns to layout in (like MULTICOL). The open tag
pushes an alignment on the alignment stack (if COLS > 1 then it pretends
to be a MULTICOL tag). The close tag pops an aligment from the alignment
stack.
<BR>Attributes:
<UL><B>ALIGN</B>=divalign
<BR><B>COLS</B>=int [if cols > 1 then DIV acts like a MULTICOL tag else
DIV is just a container]
<UL><B>GUTTER</B>= int (clamped: >= 1)
<BR><B>WIDTH</B>= value-or-pct [pct of right-left margin; clamped >= 1/0
(strange code)]</UL>
</UL>
</UL>
<B>H1-H6</B>
<UL>Closes the paragraph. The open tag does a hard line break and pushes
a style item which enables bold and disables fixed and italic. The close
tag always pops the top item from the style stack. It also does a hard
line break. If the <B>ALIGN</B> attribute is present then the open tag
pushes an alignment on the alignment stack. The close tag will look at
the top of the alignment stack and if its a header of any kind (H1 through
H6) then the alignment is popped. In either case the close tag also does
a conditional soft line break (this happens before the hard line break).
<BR>Attributes:
<UL><B>ALIGN</B>=divalign</UL>
</UL>
A note regarding closing paragraphs: Any time a close paragraph is done
(for any tag) if the top of the alignment stack has a tag named "P" then
a conditional soft line break is done and the alignment is popped.
<H3>
<HR ALIGN=LEFT WIDTH="50%"></H3>
<B>TABLE</B>
<UL>Close the paragraph.
<BR>Attributes:
<UL><B>ALIGN=</B>left|right|center|abscenter
<BR><B>BORDER</B>=int [clamped: if null then -1, if &lt; 1 then 1 ]
<BR><B>BORDERCOLOR</B>=string [if not supplied then set to the text color
]
<BR><B>VSPACE</B>=int [ clamped: >= 0 ]
<BR><B>HSPACE</B>=int [ clamped: >= 0 ]
<BR><B>BGCOLOR</B>=color
<BR><B>BACKGROUND</B>=url
<BR><B>WIDTH</B>=value-or-pct [ % of win.width minus margins; clamped:
>= 0 ]
<BR><B>HEIGHT</B>=value-or-pct [ % of win.height minus margins; clamped:
>= 0 ]
<BR><B>CELLPADDING</B>=int [clamped: >= 0; separate pads take precedence
]
<BR><B>TOPPADDING</B>= int [clamped: >= 0 ]
<BR><B>BOTTOMPADDING</B>= int [clamped: >= 0 ]
<BR><B>LEFTPADDING</B>= int [clamped: >= 0 ]
<BR><B>RIGHTPADDING</B>= int [clamped: >= 0 ]
<BR><B>CELLSPACING</B>= int [clamped: >= 0 ]
<BR><B>COLS</B>=int [clamped: >= 0]</UL>
The code supports more attributes in the Table attribute handler than it
does in the code that gets the attributes from the tag! They are border_top,
border_left, border_right, border_bottom, border_style (defaults to outset;
allows for outset/dotted/none/dashed/solid/double/groove/ridge/inset).</UL>
<B>TR</B>
<UL>Open TR automatically closes an open table row (and an open table cell
if one is open). It also automatically closes a CAPTION tag.
<BR>Attributes:
<UL><B>BGCOLOR</B>=color
<BR><B>BACKGROUND</B>=url
<BR><B>VALIGN</B>=top|bottom|middle|center(==middle)|baseline; default
is top
<BR><B>ALIGN</B>=left|right|middle|center(==middle); default is left</UL>
</UL>
<B>TH, TD</B>
<UL>If no table then the tag is ignored (open or close). If no row is currently
opened or the current row is current done (because of a &lt;/TR> tag) then
a new row is begun. Oddly enough the tag parameters for the row come from
the TH/TD tag in this case. An open of either of these tags will automatically
close the previous cell.
<BR>Attributes:
<UL><B>COLSPAN</B>=int [clamped: >= 1 &amp;&amp; &lt;= 1000 ]
<BR><B>ROWSPAN</B>=int [clamped: >= 1 &amp;&amp; &lt;= 10000 ]
<BR><B>NOWRAP</B> [boolean: disables wrapping ]
<BR><B>BGCOLOR</B>=color [default: inherit from the row; if not row then
table; if not table then inherit from an outer table cell; this works because
the style is flattened so the outer table cell will have a color]
<BR><B>BACKGROUND</B>=url [same rules as bgcolor for inheritance; tile
mode is inherited too and not settable by TH/TD attributes (have to use
style sheets for that)]
<BR><B>VALIGN</B>=top|bottom|middle|center(==middle)|baseline; default
is top
<BR><B>ALIGN</B>=left|right|middle|center(==middle); default is left
<BR><B>WIDTH</B>=value-or-pct [ clamped: >= 0 ]
<BR><B>HEIGHT</B>=value-or-pct [ clamped: >= 0 ]</UL>
</UL>
<B>CAPTION</B>
<UL>An open caption tag will automatically close an open table row (and
an open cell).
<BR>Attributes:
<UL><B>ALIGN</B>=bottom</UL>
The code sets the vertical alignment to top w/o providing a mechanism for
the user to set it (there is no VALIGN attribute).</UL>
<B>MULTICOL</B>
<UL>The open tag does a hard line break. The close tag checks to see if
the state machine has an open multicol and if it does then it does a conditional
soft line break and then continues to break until both margins are cleared
of floating elements. It recomputes the margins based on the list indenting
level (?). After the synthetic table is output the close tag does a hard
line break.
<P>This tag will treat the input as source for a table with one row and
COLS columns. The data is laid out using the width divided by the number
of columns. After the total height is known, the content is partitioned
as evenly as possible between the columns in the table.
<BR>Attributes:
<UL><B>COLS</B>=int [clamped: values less than 2 cause the tag to be ignored]
<BR><B>GUTTER</B>=int [clamped: >= 1]
<BR><B>WIDTH</B>=value-or-pct [pct of right-left margin; clamped: >= 1/0
(strange code)]</UL>
</UL>
<H3>
<HR ALIGN=LEFT WIDTH="50%"></H3>
<B>BLOCKQUOTE</B>
<UL>Closes the paragraph. The open tag does a hard line break. A list with
the empty-bullet style is pushed on the list stack (unless TYPE=cite/jwz
then a styled list is pushed). The close tag pops any list and does a hard
line break.
<BR>Attributes:
<UL><B>TYPE</B>=cite | jwz</UL>
</UL>
<B>UL, OL, MENU, DIR</B>
<UL>For top-level lists (lists not in lists) a hard break is done on the
open tag, otherwise a conditional-soft-break is done. Tag always does a
close paragrah. The close tag does a conditional soft line break when nested;
when not nested the close tag does a hard line break (even if no list is
open). The open tag pushes the list on the list stack. The close tag pops
any list off the list stack.
<BR>Attributes:
<UL><B>TYPE</B>= none | disc | circle | round | square | decimal | lower-roman
| upper-roman | lower-alpha | upper-alpha | A | a | I | i [clamped: if
none of the above is picked and OL then the bullet type is "number" otherwise
the bullet type is "basic"]
<BR><B>START</B>=int [clamped: >= 1]
<BR><B>COMPACT</B></UL>
</UL>
<B>DL</B>
<UL>Closes the paragraph. For the open tag, if the list is nested then
a conditional soft line break is done otherwise a hard line break is done.
The open tag pushes a list on the list stack. The close tag pops any list
from the list stack. Closing the list acts like other lists closes.
<BR>Attributes:
<UL><B>COMPACT</B></UL>
</UL>
<B>LI</B>
<UL>Closes the paragraph. The open tag does a conditional soft line break.
Close tags are ignored (except for closing the paragraph).
<BR>Attributes:
<UL><B>TYPE</B>= A | a | I | i (if the containing list is an <B>OL</B>)
<BR><B>TYPE</B>= round | circle | square (if the containing list is not
<B>OL</B> and not <B>DL</B>)
<BR><B>VALUE</B>=int [clamped: >= 1]</UL>
The magellan html parser allows the full set of list item styles from the
OL/DL tag instead of just the limited set that nav4 allows.</UL>
<B>DD</B>
<UL>Closes the paragraph. Close tags are ignored (except for closing the
paragraph). DD outside a DL just advances the X coordinate of layout by
a small constant. DD inside a DL does a conditional soft line break and
other margin crud.
<BR>Attributes: none.</UL>
<B>DT</B>
<UL>Closes the paragraph (open or close). Close tags are otherwise ignored.
Does a conditional soft line break. Moves the X layout coordinate to the
left margin.
<BR>Attributes: none</UL>
<H3>
<HR ALIGN=LEFT WIDTH="50%"></H3>
<B>A</B>
<UL>Open anchors push a style on the style stack if the anchor has an <B>HREF</B>.
Close anchors pop as many styles off the top of the style stack that are
anchor tags (anchor tags don't nest in other words). In addition, any styles
on the stack that have the ANCHOR bit set have it cleared and fiddle with
the foreground and background colors.
<BR>Attributes:
<UL><B>NAME</B>=string
<BR><B>HREF</B>=url
<UL><B>TARGET</B>=target
<BR><B>SUPPRESS</B>=true</UL>
</UL>
</UL>
<B>STRIKE, S, TT, CODE, SAMPLE, KBD, B, STRONG, I, EM, VAR, CITE, BLINK,
BIG, SMALL, U, INLINEINPUT, SPELL</B>
<UL>The open tag pushes onto the style stack. The close tag always pops
the top item from the style stack.
<BR>Attributes: none</UL>
<B>SUP, SUB</B>
<UL>The open tag pushes a font size descrease on the style stack. The close
tag always pops the top of the style stack. The open and close tag impacts
the baselineThe only difference between SUP and SUB is how they impact
the baseline. Note that the baseline information is forgotten after a line
break; therefore a close SUP/SUB on the next line will do strange things.
<BR>Attributes: none</UL>
<B>SPAN</B>
<UL>Ignored by the navigator.
<BR>Attributes: none</UL>
<B>FONT</B>
<UL>The open font tag with no attributes resets the font size to the base
font size. The open tag always pushes a style stack entry. The close tag
always pops the top item off the style stack.
<BR>Attributes:
<UL><B>SIZE</B>=[+ int | - int | int ]&nbsp; [clamped: >=1 &amp;&amp; &lt;=
7]
<BR><B>POINT-SIZE=</B>[+ int | - int | int ] [clamped: >= 1 &amp;&amp;
&lt;= 1600]
<BR><B>FONT-WEIGHT</B>=[+ int | - int | int ] [clamped: >= 100 &amp;&amp;
&lt;= 900]
<BR><B>COLOR</B>=colorspec
<BR><B>FACE</B>=string</UL>
</UL>
A note regarding the style stack: The pop of the stack checks to see if
the top of the stack is an ANCHOR tag. If it is not an anchor then the
top item is unconditionally popped. If the top of the style stack is an
anchor tag then the code searches for either the bottom of the stack or
the first style stack entry not created by an anchor tag. If the entry
is followed by another entry then the entry is removed from the stack (an
out-of-order pop in other words). In this case the anchor style stack entry
is left untouched.
<H3>
<HR ALIGN=LEFT WIDTH="50%"></H3>
<B>text, entities</B>
<UL>These are basic content objects that get fed directly to the output.
In navigator the text is processed by doing line-breaking (entities have
been converted to text already by the parser). The line-breaking is controlled
by the margin settings and the list depth, the floating elements, the style
attributes (font size, etc.), the preformatted flag, the no-break flag
and so on.</UL>
<B>IMG, IMAGE</B>
<UL>Close tag is ignored.
<BR>Attributes:
<UL><B>ISMAP</B>
<BR><B>USEMAP</B>=url
<BR><B>ALIGN</B>=alignparam
<BR><B>SRC</B>=url [ whitespace is stripped ]
<BR><B>LOWSRC</B>=url
<BR><B>ALT</B>=string
<BR><B>WIDTH</B>=value-or-pct (pct of <TT>right-left</TT> width)
<BR><B>HEIGHT</B>=value-or-pct (pct of window height)
<BR><B>BORDER</B>=int [clamped: >= 0]
<BR><B>VSPACE</B>=int [clamped: >= 0]
<BR><B>HSPACE</B>=int [clamped: >= 0]
<BR><B>SUPPRESS</B>=true | false (only in blocked image layout???)</UL>
</UL>
<B>HR</B>
<UL>Closes the paragraph. If an open tag then does a conditional soft line
break. The rule inherits alignment from the parent container unless there
is no container (then it's centered) or if the tag defines it's own alignment.
After the object is inserted into the layout stream a soft line break is
inserted as well.
<BR>Attributes:
<UL><B>ALIGN</B>=divalign (sort of; in laytags.c it's divalign; in layhrule.c
it's left or right only)
<BR><B>SIZE</B>=int (1 to 100 inclusive)
<BR><B>WIDTH</B>=val-or-pct (pct of <TT>right-left</TT> width)
<BR><B>NOSHADE</B></UL>
</UL>
<B>BR</B>
<UL>Does an unconditional soft break. If clear is set then it will also
soft break until either the left or right or both margins are clear of
floating elements. Note that<FONT COLOR="#0000FF"> /BR == BR!</FONT>
<BR>Attributes:
<UL><B>CLEAR</B>=left | right | all | both</UL>
</UL>
<B>WBR</B>
<UL>Soft word break.
<BR>Attributes: none</UL>
<B>EMBED</B>
<UL>Close tag does nothing. Embed's operate inline just like images (they
don't close the paragraph).
<BR>Attributes:
<UL><B>HIDDEN</B>=no | false | off
<BR><B>ALIGN</B>=alignparam
<BR><B>SRC</B>=url
<BR><B>WIDTH</B>=val-or-pct (pct of <TT>right-left</TT> width)
<BR><B>HEIGHT</B>=val-of-pct; if val is &lt; 1 (sometimes) the element
gets HIDDEN automatically
<BR><B>BORDER</B>=int (unsupported by navigator)
<BR><B>VSPACE</B>=int [clamped: >= 0]
<BR><B>HSPACE</B>=int [clamped: >= 0]</UL>
</UL>
<B>NOEBMED</B>
<UL>Used when EMBED's are disabled. It is a container for regular content
that has no stylistic consequences (no line breaking, no style stack effect,
etc.).</UL>
<B>APPLET</B>
<UL>Applet tags don't nest (there is a notion of current_applet). The open
tag automatically closes an open applet tag.
<BR>Attributes:
<UL><B>ALIGN</B>=alignparam
<BR><B>CODE</B>=string
<BR><B>CODEBASE</B>=string
<BR><B>ARCHIVE</B>=string
<BR><B>MAYSCRIPT</B>
<BR><B>NAME</B>=string [clamped: white space is stripped out]
<BR><B>WIDTH</B>=value-or-pct [pct of right-left width; clamped: >= 1]
<BR><B>HEIGHT</B>=value-or-pct [pct of window height; clamped >= 1]
<BR><B>BORDER</B>=int [clamped: >= 0]
<BR><B>HSPACE</B>=int [clamped: >= 0]
<BR><B>VSPACE</B>=int [clamped: >= 0]</UL>
If no width is provided:
<UL>if a height was provided, use the height. Otherwise, use 90% of the
window width if percentage widths are allowed, otherwise use a value of
600.
<BR>&nbsp;</UL>
If no height is provided:
<UL>if a width was provided, use the width. Otherwise, use 50% of the window
height if percentage widths are allowed, otherwise use a value of 400.</UL>
If the applet is hidden, then the widht/height get forced to zero.</UL>
<B>PARAM</B>
<UL>The param tag is supported when contained by the APPLET tag or the
OBJECT tag. It has no stylistic consequences. The attribute values from
the tag are passed to the containing APPLET or OBJECT. Note that <FONT COLOR="#0000FF">/PARAM
== PARAM</FONT>.
<BR>Attributes:
<UL><B>NAME</B>=string [clamped: white space is stripped out]
<BR><B>VALUE</B>=string [clamped: white space is stripped out]</UL>
White space being stripped is done as follows: leading and trailing whitespace
is removed. Any embedded whitespace is left alone except if it's a non-space
whitespace in which case it is removed.</UL>
<B>OBJECT</B>
<UL>The open tag pushes an object onto the object stack. The close tag
pops from the object stack. I don't understand how the data stuff works.
<BR>Attributes:
<UL><B>CLASSID</B>=string (clsid:, java:, javaprogram:, javabean: are the
supported prefixes; maybe it's a url if no prefix shown?)
<BR><B>TYPE</B>=string (a mime type)
<BR><B>DATA</B>=string (data: prefix mentions a url)</UL>
There are more attributes that depend on the type of object being embedded
in the page. If the object is a java bean (?) then the applet parameters
are supported:
<UL>CLASSID
<BR>HIDDEN
<BR>ALIGN
<BR>CLASSID (instead of CODE)
<BR>CODEBASE
<BR>ARCHIVE
<BR>MAYSCRIPT
<BR>ID (applets use NAME)
<BR>WIDTH
<BR>HEIGHT
<BR>BORDER
<BR>HSPACE
<BR>VSPACE</UL>
</UL>
<B>MAP</B>
<UL>The open tag automatically closes an open map (maps don't nest). There
is no stylistic consequence of the map nor does it provide any visible
presentation in the normal layout case (an editor would do something different).
The map can be declared anywhere in the document.
<BR>Attributes:
<UL><B>NAME</B>=string [clamped: white space is stripped out]</UL>
</UL>
<B>AREA</B>
<UL>Does nothing if there is no current map or the tag is a close tag.
<BR>Attributes:
<UL><B>SHAPE</B>=default | rect | circle | poly | polygon
<BR><B>ALT</B>=string [clamped: newlines are stripped]
<BR><B>COORDS</B>=coord-list
<BR><B>HREF=</B>url
<UL><B>TARGET</B>=target (only if HREF is specified)</UL>
<B>SUPPRESS</B></UL>
</UL>
<B>SERVER</B>
<UL>A container for server-side javascript. Not evaluated by the client
(parsed and ignored). Note: The navigator parser doesn't expand entities
in a <B>SERVER </B>tag.</UL>
<B>SPACER</B>
<UL>Close tag is ignored. Open tag provides whitespace during layout: <B>TYPE</B>=line/vert/vertical
causes a conditional soft line break and then adds <B>SIZE </B>to the Y
layout coordinate. <B>TYPE</B>=word causes a conditional soft word break
and then adds <B>SIZE </B>to the X layout coordinate. <B>TYPE</B>=block
causes <FONT COLOR="#DD0000">blockish </FONT>layout stuff to happen.
<BR>Attributes:
<UL><B>TYPE</B>=line | vert | vertical | block (default: word)
<UL><B>ALIGN</B>=alignparam (these 3 params are only for <B>TYPE</B>=block)
<BR><B>WIDTH</B>=value-or-pct
<BR><B>HEIGHT</B>=value-or-pct</UL>
<B>SIZE</B>=int [clampled: >= 0]</UL>
</UL>
<H3>
<HR ALIGN=LEFT WIDTH="50%"></H3>
<B>SCRIPT</B>
<UL>Note: The navigator parser doesn't expand entities in a SCRIPT tag.
<BR>Attributes:
<UL><B>LANGUAGE</B>=LiveScript | Mocha | JavaScript1.1 | JavaScript1.2
<BR><B>TYPE</B>="text/javascript" | "text/css"
<BR><B>HREF</B>=url
<BR><B>ARCHIVE</B>=url
<BR><B>CODEBASE</B>=url
<BR><B>ID</B>=string
<BR><B>SRC</B>=url</UL>
</UL>
<B>NOSCRIPT</B>
<UL>Used when scripting is off or by backrev browsers. It is a container
that has no stylistic consequences.</UL>
<H3>
<HR ALIGN=LEFT WIDTH="50%"></H3>
<B>FORM&nbsp;</B>
<UL>Attributes:
<UL><B>ACTION</B>=href
<BR><B>ENCODING</B>=string
<BR><B>TARGET</B>=string
<BR><B>METHOD</B>=get | post</UL>
</UL>
<B>ISINDEX&nbsp;</B>
<UL>This tag is a shortcut for creating a form element with a submit button
and a single text field. If the PROMPT attribute is not present in the
tag then the value used is <B>"This is a searchable index. Enter search
keywords:"</B>.
<P>Attributes:
<UL><B>PROMPT</B>=string
<BR><B>ACTION</B>=href
<BR><B>ENCODING</B>=string
<BR><B>TARGET</B>=string
<BR><B>METHOD</B>=get | post</UL>
</UL>
<B>INPUT&nbsp;</B>
<UL>Attributes vary according to type:
<UL><B>TYPE</B>= text | radio | checkbox | hidden | submit | reset | password
| button | image | file | jot | readonly | object
<BR><B>NAME</B>= string
<BR>&nbsp;</UL>
<B>TYPE</B>=image
<UL>attributes are from the IMG tag (!)</UL>
<B>TYPE</B>= text | password | file
<UL>font style is forced to fixed
<BR><B>VALUE</B>= string
<BR><B>SIZE</B>= int (clamped; >= 1)
<BR><B>MAXLENGTH</B>= int (not clamped!)</UL>
<B>TYPE</B>= submit | reset | button | hidden | readonly
<UL><B>VALUE</B>=string; default if no value to the attribute varies according
to the type:
<UL><B>submit</B> -> "Submit Query"
<BR><B>reset</B> -> "Reset"
<BR>others -> "&nbsp; " (2 spaces)
<BR>Note also that the value has newlines stripped from it</UL>
<B>WIDTH</B>=int (clamped >=0 &amp;&amp; &lt;= 1000) (only for submit,
reset or button)
<BR><B>HEIGHT</B>=int (clamped >=0 &amp;&amp; &lt;= 1000) (only for submit,
reset or button)</UL>
<B>TYPE</B>=radio | checkbox
<UL><B>CHECKED</B> (flag - if present then set to true)
<BR><B>VALUE</B>= string (the default value is "on")</UL>
</UL>
<B>SELECT&nbsp;</B>
<UL>Attributes:
<UL><B>MULTIPLE</B> (boolean)
<BR><B>SIZE</B>= int (clamped >= 1)
<BR><B>NAME=</B> string
<BR><B>WIDTH</B>= int (clampled >= 0 &amp;&amp; &lt;= 1000)
<BR><B>HEIGHT</B>= int (clamped >= 0 &amp;&amp; &lt;= 1000; only examined
for single entry lists (!multiple || size==1))</UL>
</UL>
<B>OPTION&nbsp;</B>
<UL>Lives inside the SELECT tag (ignored otherwise).
<BR>Attributes:
<UL><B>VALUE</B>=string
<BR><B>SELECTED</B> boolean</UL>
</UL>
<B>TEXTAREA&nbsp;</B>
<UL>Attributes:
<UL><B>NAME</B>=string
<BR><B>ROWS</B>=int (clamped; >= 1)
<BR><B>COLS</B>=int (clamped; >= 1)
<BR><B>WRAP</B>= off | hard | soft (default is off; any value which is
not known turns into soft)</UL>
</UL>
<B>KEYGEN&nbsp;</B>
<UL>Attributes:
<UL><B>NAME</B>=string
<BR><B>CHALLENGE</B>=string
<BR><B>PQG</B>=string
<BR><B>KEYTYPE</B>=string</UL>
</UL>
<H3>
<HR ALIGN=LEFT WIDTH="50%"></H3>
<B>BASEFONT&nbsp;</B>
<UL>Sets the base font value which +/- size values in FONT tags are relative
to.
<BR>Attributes:
<UL>SIZE=+ int | - int | int (just like FONT)</UL>
</UL>
<H2>
<HR WIDTH="100%">Unsupported</H2>
<B>NSCP_CLOSE, NSCP_OPEN, NSCP_REBLOCK, MQUOTE, CELL, SUBDOC, CERTIFICATE,
INLINEINPUTTHICK, INLINEINPUTDOTTED, COLORMAP, HYPE, SPELL, NSDT</B>
<UL>These tags are unsupported because they are used internally by netscape
and are never seen in real content. If somebody does use them between 4.0
and magellan, tough beans. We never documented them so they lose.</UL>
</BODY>
</HTML>

View File

@@ -1,176 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Layout Documentation Overview</title>
</head>
<body>
<h1>Layout Documentation Overview</h1>
<blockquote> Authors: <br>
<ul>
<li>Marc Attinasi (attinasi@netscape.com)</li>
</ul>
History: <br>
<ul>
<li>12/17/2001 - created<br>
</li>
</ul>
</blockquote>
<h2>Background</h2>
The Layout module of Gecko has not been documented very well. This has lead
to some predictable problems: difficult maintenance, hard to get new people
involved in the module, problems assessing the risk of changes, hard to know
where bugs are likely to be in the source. &nbsp;One extreme result of the
lack of comprehensive has been an urge to rewrite some of the more impenetrable
parts of the layout component, the block and Line Layout areas. &nbsp;Rather
than throwing it all away and rewriting it, we have decided to put significant
effort into thoroughly documenting what we already have. this effort will
help us to understand what parts of the system we want to keep as-is, incrementally
revise, or wholesale rewrite. Additionally, we will make the code base more
accessible to new (and not-so-new) engineers.<br>
<br>
<h2>Strategy:</h2>
Documenting all of Block and Line layout is a large task, so it will be
divided up among knowledgeable and interested engineers. Progress will be
tracked in bugzilla <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=115310">
bug 115310</a>
. &nbsp;This document lays out the basic documentation scope and formatting
so that all of the individual contributions can be combined into a relatively
cohesive unit of linked documents. <br>
<br>
<h2>Scope:</h2>
The documentation will generally cover two levels of detail. There is room
for deviation from this as needed, but generally a High Level Design document
and a Detailed Design document will provide the necessary level of detail
for those trying to understand the system as a whole, and those trying to
get into the code.<br>
<br>
<h3>High Level Designs</h3>
High level designs provided an overview of the system being documented.
The general concept of the component is described, and the classes involved
are described briefly (no details of the class implementations). &nbsp;In
some cases the high level design vocabulary consists of other components
and not classes. &nbsp;The important thing is to describe the interactions
between the classes and/or components such that the reader gets an understanding
of which pieces talk to which other pieces, what kinds of data are shared
by various components or classes, how the data is modified and by whom, beginning
states and end states of a process, and external constraints or inputs into
the system begin described. <br>
<br>
A fundamental piece of the high-level design is the<b> data model</b>. This
is generally a graphical representation of the classes or components involved
in the system, showing the relationships between them in terms of has-a,
is-a, uses, owns, etc. the specific representation is not as important as
the content of the representation. For example, using UML or Booch notation
is fine, as is an ad-hoc diagram that shows the same types of information.<br>
<br>
Another important piece of the high-level design is a set of <b>use-cases</b>
that describe specific interaction that result from specific events in
the system. For example, we might want to show specifically what happens
when an attribute is changed on an element via the DOM. Use cases differ
from data models in that they show specific instances of objects or components,
actual data values where interesting or important, and often give a glimpse
into the algorithms employed. All of the components or objects in the use
cases must be documented in the data model.<br>
<b><br>
State Transition Diagrams</b> may be important to some systems, and they
should be documented in the high-level design as well. These should be described
in terms of the abstract states that the system may be in, not in terms of
how the state-machine is actually implemented.<br>
<br>
The high-level documents provide an overview of the components and classes
that make up a system. It can be used as a road map to the related detailed
design documents for the components and classes involved in the system. thus,
the classes, components, and algorithms referenced in the high-level design
document should be linked to the detailed design documents that correspond.
This link generally occurs at the first reference to the class or component,
but it can be provided in other contexts as well, for convenience to the reader.
&nbsp;Missing or invalid links are considered errors in the high-level design.
<br>
&nbsp;&nbsp; <br>
<h3>Detailed Designs</h3>
Detailed design documents provide specific information needed to implement
(or understand the implementation of) the components and classes described
in the high-level design. Users of the classes or components should also be
able to understand from the detailed design just how the classes, components
and API's are to be used. Special performance characteristics of methods or
interactions should be documented where pertinent.<br>
<br>
<h4>Public API</h4>
The public API of the component or class being documented is essential to
the detailed design. Each publicly accessible interface, method and data member
must be documented. Ideally this information is contained in the implementation
files for a class, interface or component. If this is the case, the actual
IDL or class header file can be used as the documentation for the public API.
This should be done as a link or embedded document to avoid the perpetual
need to keep the document up to date with the source file. &nbsp;Specific
items that are important to the description of the publicly available aspects
of the component, class, or interface include:<br>
<ul>
<li>entry-point semantics: what does the method do, or what does the data
member mean? Is the universe of expected clients limited or open (e.g.. who
can call it)?<br>
</li>
<li>preconditions: what are the legal states for the instance to be in
before the entry point is called? what are the legal values for the arguments?
what are the required states for the objects or components used in the entry-point?</li>
<li>postconditions: what is guaranteed when the entry-point is returned
from? what return values are legal? what is the status of the output arguments
for various return states?</li>
<li>special performance characteristics: if there are special concerns
about performance of the method, explain them. for example, is the method
O(n^2)? Is there considerable memory required? Is the method recursive?</li>
</ul>
Beyond the public interfaces, the private and protected methods need to
be documented as well. For protected methods and members, the expectations
of the subclasses must be made clear (e.g.. should the subclass call the
base class method? if so, when?) &nbsp;As with the public methods, the semantics,
preconditions, postconditions, and special performance considerations should
be described. Again, this may be by direct inclusion of the source code files
where appropriate.<br>
<br>
<h4>Algorithms</h4>
There is often a need to document specific algorithms used in methods and
functions. &nbsp;Generally, it is not a good idea to include this sort of
information in the source files, so they must be described fully in the detailed
design document. &nbsp;The extent of this information varies wildly from one
design to another. &nbsp;Be sure to include an Algorithms section to the
document when there are interesting or critical algorithms that the classes
or components employ. &nbsp;Spell out the algorithms in as much detail as
possible using pseudo-code or diagrams. Ideally, it should be possible to
implement the algorithm from the information in the design.<br>
<br>
<br>
Algorithms that involve several different components or object instances
require special attention. These algorithms tend to be more complex and more
difficult to completely specify. &nbsp;Start out by referring to the related
use cases in the high level design, and then drill down into the responsibilities
and requirements of the individual instances involved. &nbsp;Here, diagrams
and pseudo-code are indispensable in communicating how the algorithm is carried
out across the system.<br>
<h4></h4>
<h4> Tech Notes</h4>
The end of the detailed design document should contain a list of links to
Tech Notes. These will vary in depth and scope, but generally they provide
information geared toward helping developers work on the system. &nbsp;Tech
Notes might contain information about &nbsp;how code has been modified, how
a new feature was added, how to debug a certain class of problem, how to
use built-in debugging r logging facilities, or how to maintain or extend
unit tests. &nbsp;The Tech Notes should be stored in a publibly accessable
location, as a comment or attachment in a bugzilla bug, for example. &nbsp;The
text that holds the link should be descriptive of what the Tech Note addresses.<br>
<br>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -1,244 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!-- ***** 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 a description how to run the layout regression tests.
-
- The Initial Developer of the Original Code is
- Bernd Mielke.
- Portions created by the Initial Developer are Copyright (C) 2___
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- 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 MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. 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 ***** -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Layout Regression tests</title>
<style type="text/css">
body {font-family:arial}
.screen {background-color:silver; color:blue}
pre.screen {display:table-cell}
</style>
</head>
<body>
<h1>Table Regression Tests</h1>
<h6>Bernd Mielke</h6>
<h2>About This Document</h2>
<p>
This document describes my guerilla approach to successfully running the table layout regression tests. It should encourage more people to run those tests.
<h2>Subject Overview</h2>
<p>
The table element and its children are one of the major layout components that can create some structure on the screen. They are widely (ab)used by page authors. Every small change in the table code can generate a bunch of bugzilla entries and a lot of seemingly unrelated dupes. With the high frequency of checkins in to the source tree it is difficult and time consuming to track the regression down to a single checkin. The risk of becoming very infamous can be reduced by running the layout regression tests.
<h2>Prerequisites</h2>
<p>
In order to run these tests, you will need to have:
<ol>
<li>a debug build with a working viewer, an optimized build will not work!
<li>a mozilla tree with the testfiles at <code>%MOZ_SRC%/layout/html/tests</code>,
<li> <code>DISABLE_TESTS</code> should not be defined,
<li>patience and time.
</ol>
<h2>Test Runs</h2>
<ul>
<li>Go to the <code>%MOZ_SRC%/layout/html/tests/block</code> directory.
<li> Avoid the nasty assertions to pop up by <code>set XPCOM_DEBUG_BREAK=warn</code>, the world would be a much better place if we could <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=152015">first fix those assertions</a>.
<li>The following shell scripts need a <code>sh</code> before the command under WinXX.
<li>Execute <code>rtest.sh baseline</code>
<li>Execute <code>rtest.sh verify&gt;outputfile.txt</code>
<li>Make a note which tests have failed (these are false positives. If you are in bad mood file a bug against Chris Waterson about them)
<li>you can grep the failures by:<br>
<code>grep 'rgd failed' &lt;outputfile.txt &gt;false_positive.txt</code>
<li> Make a copy of <code>gklayout.dll</code> and <code>gkcontent.dll</code> in the <code>dist</code> directory. If you would like to switch back, you will need them.
<li>Make your changes to the source, compile and install.
<li>execute in the <code>layout/html/tests/block</code> directory <code>rtest.sh verify &gt;regression.txt</code>
<li>Check how many tests have failed and analyse your results:
<ul>
<li>If the regression tests have failed at the same place as the previous diagnosted false positives =&gt; ignore
<ol>
<li>copy <code>rtest.sh</code> to <code>my_rtest.sh</code>
<li>create a new directory <code>my_files</code>.
<li>create in this diretory a file <code>file_list.txt</code>, where you put the url's of your remaining test failures
<li>change <code>my_rtest.sh</code> to use only directory <code>my_files</code>
<li>go back to the original gklayout.dll and gkcontent.dll and repeat the regression test procedure on a much smaller set now.
</ol>
<li>Try to figure out what the other regressions are: Are they
improving the picture or are they regressions?
<li>Note the difficult to explain testfailures.
</ul>
<li> Change the source if necessary until the regression tests indicate that your patch does not hork the block and table layout
<li> Submit your patch and lists the remaining differences in the bug
</ul>
<p>Be prepared to cycle.
<h2>How the layout regression tests work</h2>
<p>First the URL's to test are red from <code>file_list.txt</code>.<p>
<table><caption>snippet from file_list.txt</caption><tr><td>
<pre>file:///s|/mozilla/layout/html/tests/table/dom/appendCells1.html
file:///s|/mozilla/layout/html/tests/table/dom/appendCellsRebuild1.html
file:///s|/mozilla/layout/html/tests/table/dom/appendCol1.html
file:///s|/mozilla/layout/html/tests/table/dom/appendCol2.html
file:///s|/mozilla/layout/html/tests/table/dom/appendColGroup1.html
file:///s|/mozilla/layout/html/tests/table/dom/appendRowsExpand1.html</pre>
</td></tr></table>
<p>The regression tests compare the frame tree dumps recorded at two different times. The URL's to test are red from <code>file_list.txt</code>
For every file in <code>file_list.txt</code>viewer takes the root frame and dumps the whole tree via
<a href="http://lxr.mozilla.org/seamonkey/search?string=nsFrame%3A%3ADumpRegression">
nsFrame::DumpRegression</a>.
<p>
The frame tree dumps are invoked by the <code>-o</code> switch to the <code>viewer</code> (see <a href="http://lxr.mozilla.org/seamonkey/ident?i=PrintHelpInfo">commandline arguments </a>).
When <code>-o</code> is specifed together with a output directory for instance (<code>-o s:\mozilla\layout\html\tests\table\dom\</code>),
the frame trees are dumped to separate files in that directory for all URL's in <code>file_list.txt</code> (see:
<a href="http://lxr.mozilla.org/seamonkey/search?string=nsWebCrawler%3A%3ADumpRegression">
nsWebCrawler::DumpRegressionData</a>) .
<p>Theire name is generated by replacing the old extension <code>.html</code> or <code>.xml</code> with <code>.rgd</code>. For <code>file:///s|/mozilla/layout/html/tests/table/dom/appendCells1.html</code> a file <code>appendCells1.rgd</code> will be created in the <code>s:\mozilla\layout\html\tests\table\dom\</code> directory.
<p>
There is a special type of frame dumps - the printing regression tests, they are invoked by the <code>-Prt</code> command line argument to the <code>viewer</code> and include first a display then a frame dump taking into account the printer pages. A typical beginning of a dump (<code>*.rgd</code> file) looks like:<p>
<pre class="screen">
&lt;frame va="15022440" type="Viewport(-1)" state="270340" parent="0"&gt;
&lt;view va="47171904"&gt;
&lt;/view&gt;
&lt;stylecontext va="15022232"&gt;
&lt;font serif 240 240 0 /&gt;
&lt;color data="-16777216"/&gt;
&lt;background data="0 2 3 -1 0 0 "/&gt;
&lt;spacing data="left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0" /&gt;
&lt;list data="100 100 " /&gt;
&lt;position data="left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 0 Auto " /&gt;
&lt;text data="0 0 0 Normal Normal 0[0x0]tw Normal " /&gt;
&lt;textreset data="0 10[0xa]enum " /&gt;
&lt;display data="0 1 0 0 0 0 0 0 0 0 0 0 " /&gt;
&lt;visibility data="0 1 1.000000" /&gt;
&lt;table data="0 0 4 -1 1 " /&gt;
&lt;tableborder data="1 Null Null 0 2 " /&gt;
&lt;content data="0 0 0 Null " /&gt;
&lt;quotes data="0 " /&gt;
&lt;ui data="3 0 0 1 " /&gt;
&lt;uireset data="7 0 4" /&gt;
&lt;xul data="0 0 0 0 0 1 &lt;svg data="0 1.000000 1.000000 0 1.000000" /&gt;
&lt;/stylecontext&gt;</pre>
<p>The first run of the regression tests is started with the argument <code>baseline</code> and it creates the reference frame dumps.
<p>The <code>baseline</code> log will look like:
<pre class="screen">
Type Manifest File: C:\MOZ_SOUR\MOZILLA\MOZILLA\DIST\WIN32_D.OBJ\BIN\components\xpti.dat
nsNativeComponentLoader: autoregistering begins.
nsNativeComponentLoader: autoregistering succeeded
Going to create the event queue
WEBSHELL+ = 1
Note: verifyreflow is disabled
Note: styleverifytree is disabled
Note: frameverifytree is disabled
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendCells1.html: done loading (11810 msec)
appendCells1.rgd - being written
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendCellsRebuild1.html: done loading (1260 msec)
appendCellsRebuild1.rgd - being written
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendCol1.html: done loading (270 msec)
appendCol1.rgd - being written
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendCol2.html: done loading (220 msec)
appendCol2.rgd - being written
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendColGroup1.html: done loading (390 msec)
appendColGroup1.rgd - being written
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendRowsExpand1.html: done loading (220 msec)
appendRowsExpand1.rgd - being written
</pre>
<p>
The second run with the argument <code>verify</code> creates first the frame dumps in a subdirectory (<code>verify</code>) and <a href="http://lxr.mozilla.org/seamonkey/search?string=nsFrameUtil%3A%3ACompareTrees">compares</a> each frame dump with the corresponding reference frame dump. If they differ in critical points the test fails.
<p>A typical part of the <code>verify</code> log would look like:
<pre class="screen">
Type Manifest File: C:\MOZ_SOUR\MOZILLA\MOZILLA\DIST\WIN32_D.OBJ\BIN\components\xpti.dat
nsNativeComponentLoader: autoregistering begins.
nsNativeComponentLoader: autoregistering succeeded
Going to create the event queue
WEBSHELL+ = 1
Note: verifyreflow is disabled
Note: styleverifytree is disabled
Note: frameverifytree is disabled
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendCells1.html: done loading (2200 msec)
frame bbox mismatch: 0,285,930,435 vs. 0,285,1305,435
Node 1:
TableOuter(table)(1) 0x10004 0,285,930,435, |null attr|-16777216|left: 0[0x0]tw top: 0[0x0]tw right: 0[0x0]tw bottom: 0[0x0]tw left: 0[0x0]tw top: 0[0x0]tw right: 0[0x0]tw bottom: 0[0x0]tw left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Inherit top: Inherit right: Inherit bottom: Inherit 0[0x0]tw 0[0x0]tw Null 0[0x0]tw 0[0x0]tw Null 0 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 8 0 0 0 0 0 1 0 0 0 0 |0 0 4 -1 1 |0 0 0 Null
Node 2:
TableOuter(table)(1) 0x10004 0,285,1305,435, |null attr|-16777216|left: 0[0x0]tw top: 0[0x0]tw right: 0[0x0]tw bottom: 0[0x0]tw left: 0[0x0]tw top: 0[0x0]tw right: 0[0x0]tw bottom: 0[0x0]tw left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Inherit top: Inherit right: Inherit bottom: Inherit 0[0x0]tw 0[0x0]tw Null 0[0x0]tw 0[0x0]tw Null 0 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 8 0 0 0 0 0 1 0 0 0 0 |0 0 4 -1 1 |0 0 0 Null
frame bbox mismatch: 0,0,930,435 vs. 0,0,1305,435
Node 1:
Table(table)(1) 0x10004 0,0,930,435, |null attr|-16777216|left: Null top: 0[0x0]tw right: Null bottom: 0[0x0]tw left: Null top: Null right: Null bottom: Null left: 15[0xf]tw top: 15[0xf]tw right: 15[0xf]tw bottom: 15[0xf]tw left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 2 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 8 0 0 0 0 0 0 0 0 0 0 |0 8 4 -1 1 |0 0 0 Null
Node 2:
Table(table)(1) 0x10004 0,0,1305,435, |null attr|-16777216|left: Null top: 0[0x0]tw right: Null bottom: 0[0x0]tw left: Null top: Null right: Null bottom: Null left: 15[0xf]tw top: 15[0xf]tw right: 15[0xf]tw bottom: 15[0xf]tw left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 2 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 8 0 0 0 0 0 0 0 0 0 0 |0 8 4 -1 1 |0 0 0 Null
frame bbox mismatch: 45,15,840,405 vs. 45,15,1215,405
Node 1:
TableColGroup(table)(1) 0x80010004 45,15,840,405, |null attr|-16777216|left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 0 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 12 0 0 0 0 0 0 0 0 0 0 |0 0 4 -1 1 |0 0 0 Null
Node 2:
TableColGroup(table)(1) 0x80010004 45,15,1215,405, |null attr|-16777216|left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 0 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 12 0 0 0 0 0 0 0 0 0 0 |0 0 4 -1 1 |0 0 0 Null
frame state mismatch: 0x30010406 vs. 0x30010004
Node 1:
TableCol(table)(1) 0x30010406 0,0,0,0, |null attr|-16777216|left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 0 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 11 0 0 0 0 0 0 0 0 0 0 |0 0 4 -1 1 |0 0 0 Null
Node 2:
TableCol(table)(1) 0x30010004 870,0,345,405, |null attr|-16777216|left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 0 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 11 0 0 0 0 0 0 0 0 0 0 |0 0 4 -1 1 |0 0 0 Null
frame bbox mismatch: 0,0,0,0 vs. 870,0,345,405
Node 1:
TableCol(table)(1) 0x30010406 0,0,0,0, |null attr|-16777216|left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 0 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 11 0 0 0 0 0 0 0 0 0 0 |0 0 4 -1 1 |0 0 0 Null
Node 2:
TableCol(table)(1) 0x30010004 870,0,345,405, |null attr|-16777216|left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null left: 1[0x1]enum top: 1[0x1]enum right: 1[0x1]enum bottom: 1[0x1]enum left: Null top: Null right: Null bottom: Null left: Null top: Null right: Null bottom: Null 1[0x1]enum 0|100 100 |left: Auto top: Auto right: Auto bottom: Auto Auto 0[0x0]tw Null Auto 0[0x0]tw Null 0 Auto |0 0 0 Normal Normal 0[0x0]tw Normal |0 11 0 0 0 0 0 0 0 0 0 0 |0 0 4 -1 1 |0 0 0 Null
regression test s:\mozilla\layout\html\tests\table\dom\verify\appendCells1.rgd failed
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendCellsRebuild1.html: done loading (390 msec)
044regression test s:\mozilla\layout\html\tests\table\dom\verify\appendCellsRebuild1.rgd passed
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendCol1.html: done loading (280 msec)
regression test s:\mozilla\layout\html\tests\table\dom\verify\appendCol1.rgd passed
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendCol2.html: done loading (220 msec)
regression test s:\mozilla\layout\html\tests\table\dom\verify\appendCol2.rgd passed
+++ file:///s|/mozilla/layout/html/tests/table/dom/appendColGroup1.html: done loading (220 msec)
regression test s:\mozilla\layout\html\tests\table\dom\verify\appendColGroup1.rgd passed
</pre>
<p>
The first regression test has failed and it is marked so.
<h2>Adding new regression tests</h2>
<p>
Once you have checked in the code:
<ul>
<li> please add your testcase for the bug to the regression tests.
<li>A testcase should only contain local files.
<li>Place the images in <code>table/images</code> (don't forget <code> cvs commit -kb </code>)
<li>and the testfile in the <code>table/bugs</code> directory.
<li>Update the <code>file_list<b>x</b>.txt</code> in order to include your file.
</ul>
<p>I would like to thank Chris Karnaze for his guidance and fantasai for his language support.
<div style="text-align:right"><i>&lt;regression.html&gt;&nbsp; &lt;Last updated:
2002-06-16 <a href="mailto:bernd.mielke@snafu.de">Bernd Mielke</a></i></div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More