Merge mozilla-central

This commit is contained in:
Ben Turner 2010-05-04 17:39:59 -07:00
commit aa26c81638
680 changed files with 17700 additions and 12394 deletions

View File

@ -3,7 +3,7 @@
# Filenames that should be ignored wherever they appear
~$
\.py(c|o)$
(^|/)TAGS$
(?i)(^|/)TAGS$
(^|/)ID$
(^|/)\.DS_Store$

View File

@ -98,7 +98,7 @@ interface nsIAccessibleProvider : nsISupports
/** A combination of a tabs object and a tabpanels object */
const long XULTabBox = 0x00001018;
/** The collection of tab objects, useable in the TabBox and independant of
/** The collection of tab objects, usable in the TabBox and independent of it
as well */
const long XULTabs = 0x00001019;

View File

@ -72,6 +72,7 @@
#include "nsRootAccessible.h"
#include "nsFocusManager.h"
#include "nsIObserverService.h"
#include "mozilla/Services.h"
/* For documentation of the accessibility architecture,
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
@ -281,14 +282,15 @@ void nsAccessNode::InitXPAccessibility()
void nsAccessNode::NotifyA11yInitOrShutdown(PRBool aIsInit)
{
nsCOMPtr<nsIObserverService> obsService =
do_GetService("@mozilla.org/observer-service;1");
mozilla::services::GetObserverService();
NS_ASSERTION(obsService, "No observer service to notify of a11y init/shutdown");
if (obsService) {
static const PRUnichar kInitIndicator[] = { '1', 0 };
static const PRUnichar kShutdownIndicator[] = { '0', 0 };
obsService->NotifyObservers(nsnull, "a11y-init-or-shutdown",
aIsInit ? kInitIndicator : kShutdownIndicator);
}
if (!obsService)
return;
static const PRUnichar kInitIndicator[] = { '1', 0 };
static const PRUnichar kShutdownIndicator[] = { '0', 0 };
obsService->NotifyObservers(nsnull, "a11y-init-or-shutdown",
aIsInit ? kInitIndicator : kShutdownIndicator);
}
void nsAccessNode::ShutdownXPAccessibility()

View File

@ -85,6 +85,7 @@
#include "nsIWebProgress.h"
#include "nsNetError.h"
#include "nsDocShellLoadTypes.h"
#include "mozilla/Services.h"
#ifdef MOZ_XUL
#include "nsXULAlertAccessible.h"
@ -119,8 +120,8 @@ PRBool nsAccessibilityService::gIsShutdown = PR_TRUE;
nsAccessibilityService::nsAccessibilityService()
{
// Add observers.
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (!observerService)
return;
@ -155,11 +156,11 @@ nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic,
if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
// Remove observers.
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
if (observerService) {
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService)
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
}
nsCOMPtr<nsIWebProgress> progress(do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID));
if (progress)
progress->RemoveProgressListener(static_cast<nsIWebProgressListener*>(this));

View File

@ -405,7 +405,7 @@ nsAccessible::GetKeyboardShortcut(nsAString& aAccessKey)
return NS_ERROR_FAILURE;
PRUint32 key = nsCoreUtils::GetAccessKeyFor(content);
if (!key && content->IsNodeOfType(nsIContent::eELEMENT)) {
if (!key && content->IsElement()) {
// Copy access key from label node unless it is labeled
// via an ancestor <label>, in which case that would be redundant
nsCOMPtr<nsIContent> labelContent(nsCoreUtils::GetLabelContent(content));
@ -741,7 +741,7 @@ nsAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
if (isDisabled) {
*aState |= nsIAccessibleStates::STATE_UNAVAILABLE;
}
else if (content->IsNodeOfType(nsINode::eELEMENT)) {
else if (content->IsElement()) {
nsIFrame *frame = GetFrame();
if (frame && frame->IsFocusable()) {
*aState |= nsIAccessibleStates::STATE_FOCUSABLE;
@ -1305,7 +1305,7 @@ nsAccessible::HandleAccEvent(nsAccEvent *aEvent)
NS_ENSURE_TRUE(nsAccUtils::IsNodeRelevant(eventNode), NS_ERROR_FAILURE);
nsCOMPtr<nsIObserverService> obsService =
do_GetService("@mozilla.org/observer-service;1");
mozilla::services::GetObserverService();
NS_ENSURE_TRUE(obsService, NS_ERROR_FAILURE);
return obsService->NotifyObservers(aEvent, NS_ACCESSIBLE_EVENT_TOPIC, nsnull);

View File

@ -242,7 +242,7 @@ nsCoreUtils::GetDOMElementFor(nsIDOMNode *aNode)
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
nsIDOMElement *element = nsnull;
if (node->IsNodeOfType(nsINode::eELEMENT))
if (node->IsElement())
CallQueryInterface(node, &element);
else if (node->IsNodeOfType(nsINode::eTEXT)) {
@ -276,7 +276,7 @@ nsCoreUtils::GetDOMNodeFromDOMPoint(nsIDOMNode *aNode, PRUint32 aOffset)
nsIDOMNode *resultNode = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
if (content && content->IsNodeOfType(nsINode::eELEMENT)) {
if (content && content->IsElement()) {
PRUint32 childCount = content->GetChildCount();
NS_ASSERTION(aOffset >= 0 && aOffset <= childCount,

View File

@ -76,6 +76,8 @@
#include "nsIDOMNSEventTarget.h"
#include "nsIDOMDocumentEvent.h"
#include "nsFocusManager.h"
#include "Element.h"
#ifdef MOZ_XUL
#include "nsXULTreeAccessible.h"
@ -83,6 +85,8 @@
#include "nsIXULWindow.h"
#endif
using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
@ -143,9 +147,9 @@ nsRootAccessible::GetRoleInternal(PRUint32 *aRole)
}
// If it's a <dialog> or <wizard>, use nsIAccessibleRole::ROLE_DIALOG instead
nsIContent *rootContent = mDocument->GetRootContent();
if (rootContent) {
nsCOMPtr<nsIDOMElement> rootElement(do_QueryInterface(rootContent));
Element *root = mDocument->GetRootElement();
if (root) {
nsCOMPtr<nsIDOMElement> rootElement(do_QueryInterface(root));
if (rootElement) {
nsAutoString name;
rootElement->GetLocalName(name);

View File

@ -407,7 +407,7 @@ nsHTMLTableHeaderCellAccessible::GetRoleInternal(PRUint32 *aRole)
for (PRInt32 idx = indexInParent - 1; idx >= 0; idx--) {
nsIContent* sibling = parent->GetChildAt(idx);
if (sibling && sibling->IsNodeOfType(nsINode::eELEMENT)) {
if (sibling && sibling->IsElement()) {
if (nsCoreUtils::IsHTMLTableHeader(sibling))
*aRole = nsIAccessibleRole::ROLE_COLUMNHEADER;
else
@ -420,7 +420,7 @@ nsHTMLTableHeaderCellAccessible::GetRoleInternal(PRUint32 *aRole)
PRInt32 childCount = parent->GetChildCount();
for (PRInt32 idx = indexInParent + 1; idx < childCount; idx++) {
nsIContent* sibling = parent->GetChildAt(idx);
if (sibling && sibling->IsNodeOfType(nsINode::eELEMENT)) {
if (sibling && sibling->IsElement()) {
if (nsCoreUtils::IsHTMLTableHeader(sibling))
*aRole = nsIAccessibleRole::ROLE_COLUMNHEADER;
else

View File

@ -1133,7 +1133,7 @@ nsHyperTextAccessible::GetTextAttributes(PRBool aIncludeDefAttrs,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
if (content && content->IsNodeOfType(nsINode::eELEMENT))
if (content && content->IsElement())
node = do_QueryInterface(content->GetChildAt(nodeOffset));
if (!node)

View File

@ -501,7 +501,7 @@ __try {
if (!content)
return E_FAIL;
if (content->IsNodeOfType(nsINode::eELEMENT)) {
if (content->IsElement()) {
nsAutoString roleString;
if (msaaRole != ROLE_SYSTEM_CLIENT &&
!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::role, roleString)) {

View File

@ -45,13 +45,15 @@ relativesrcdir = accessible/states
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
# temporarily disabled test (bug 562328)
# test_frames.html \
_TEST_FILES =\
test_aria.html \
test_aria_imgmap.html \
test_doc.html \
test_docarticle.html \
test_editablebody.html \
test_frames.html \
test_link.html \
test_popup.xul \
test_tree.xul \

View File

@ -904,13 +904,21 @@ pref("toolbar.customization.usesheet", true);
pref("toolbar.customization.usesheet", false);
#endif
// The default for this pref reflects whether the build is capable of IPC.
// (Turning it on in a no-IPC build will have no effect.)
#ifdef XP_MACOSX
// OSX still has only partial support for IPC. Note that the PowerPC
// and x86 builds must generate identical copies of this file, so we
// can't make the prefs indicate that IPC is not available at all in
// PowerPC builds.
pref("dom.ipc.plugins.enabled", false);
// These plug-ins will run OOP by default
pref("dom.ipc.plugins.enabled.flash player.plugin", true);
pref("dom.ipc.plugins.enabled.javaplugin2_npapi.plugin", true);
#else
#elifdef MOZ_IPC
pref("dom.ipc.plugins.enabled", true);
#else
pref("dom.ipc.plugins.enabled", false);
#endif
#ifdef XP_WIN

View File

@ -41,13 +41,47 @@ function test() {
let testURL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_463205_sample.html";
let doneURL = "done";
let mainURL = testURL;
let frame1URL = "data:text/html,<input%20id='original'>";
let frame2URL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_463205_helper.html";
let frame3URL = "data:text/html,mark2";
let frameCount = 0;
var frameCount = 0;
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
// wait for all frames to load completely
if (frameCount++ < 3)
if (frame1URL != doneURL && aEvent.target.location.href == frame1URL) {
frame1URL = doneURL;
if (frameCount++ < 3) {
return;
}
}
if (frame2URL != doneURL && aEvent.target.location.href == frame2URL) {
frame2URL = doneURL;
if (frameCount++ < 3) {
return;
}
}
if (frame3URL != doneURL && aEvent.target.location.href == frame3URL) {
frame3URL = doneURL;
if (frameCount++ < 3) {
return;
}
}
if (mainURL != doneURL && aEvent.target.location.href == mainURL) {
mainURL = doneURL;
if (frameCount++ < 3) {
return;
}
}
if (frameCount < 3) {
return;
}
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
function typeText(aTextField, aValue) {
@ -62,13 +96,47 @@ function test() {
let win = tab.linkedBrowser.contentWindow;
typeText(win.frames[0].document.getElementById("original"), uniqueValue);
typeText(win.frames[1].document.getElementById("original"), uniqueValue);
mainURL = testURL;
frame1URL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser/browser_463205_helper.html";
frame2URL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_463205_helper.html";
frame3URL = "data:text/html,mark2";
frameCount = 0;
let tab2 = gBrowser.duplicateTab(tab);
tab2.linkedBrowser.addEventListener("load", function(aEvent) {
// wait for all frames to load (and reload!) completely
if (frameCount++ < 4)
if (frame1URL != doneURL && aEvent.target.location.href == frame1URL) {
frame1URL = doneURL;
if (frameCount++ < 3) {
return;
}
}
if (frame2URL != doneURL && (aEvent.target.location.href == frame2URL ||
aEvent.target.location.href == frame2URL + "#original")) {
frame2URL = doneURL;
if (frameCount++ < 3) {
return;
}
}
if (frame3URL != doneURL && aEvent.target.location.href == frame3URL) {
frame3URL = doneURL;
if (frameCount++ < 3) {
return;
}
}
if (mainURL != doneURL && aEvent.target.location.href == mainURL) {
mainURL = doneURL;
if (frameCount++ < 3) {
return;
}
}
if (frameCount < 3) {
return;
}
tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
let win = tab2.linkedBrowser.contentWindow;

File diff suppressed because it is too large Load Diff

View File

@ -211,7 +211,7 @@
<!ENTITY viewSidebarMenu.accesskey "e">
<!ENTITY viewCustomizeToolbar.label "Customize…">
<!ENTITY viewCustomizeToolbar.accesskey "C">
<!ENTITY viewTabsOnTop.label "Tabs on top">
<!ENTITY viewTabsOnTop.label "Tabs on Top">
<!ENTITY viewTabsOnTop.accesskey "T">
<!ENTITY historyMenu.label "History">

View File

@ -1133,13 +1133,16 @@ statusbarpanel#statusbar-display {
}
.tabbrowser-tab {
border: none !important;
padding: 0 2px;
padding: 0 2px 2px;
margin-bottom: 1px;
min-height: 25px; /* reserve space for the sometimes hidden close button */
}
.tabbrowser-tab[selected="true"] {
margin-bottom: 0px;
margin-bottom: 0;
padding-top: 2px; /* compensates the top margin of background tabs */
padding-bottom: 3px; /* compensates the bottom margin of background tabs */
min-height: 28px;
}
.tab-icon-image {
@ -1221,12 +1224,11 @@ statusbarpanel#statusbar-display {
.tab-close-button > .toolbarbutton-icon {
/* XXX Buttons have padding in widget/ that we don't want here but can't override with good CSS, so we must
use evil CSS to give the impression of smaller content */
margin: -3px !important;
margin: -4px;
}
.tab-close-button {
padding: 0px;
border: none;
padding: 0;
list-style-image: url("moz-icon://stock/gtk-close?size=menu");
}

View File

@ -1048,20 +1048,11 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
.editBookmarkPanelHeaderButton,
.editBookmarkPanelBottomButton {
-moz-appearance: none;
background: url("chrome://browser/skin/hud-style-button-middle-background.png") repeat-x #464646 center center;
border-width: 3px;
border-style: solid;
-moz-border-radius: 20px;
-moz-border-top-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
-moz-border-right-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
-moz-border-bottom-colors: rgba(128,128,128,0.35) rgba(0,0,0,0.5) rgba(255,255,255,0.15);
-moz-border-left-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
@hudButton@
padding: 0 9px;
margin: 6px;
min-width: 79px;
min-height: 22px;
color: #ffffff;
}
.editBookmarkPanelHeaderButton:hover:active,
@ -1136,18 +1127,11 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
}
#editBMPanel_folderMenuList {
-moz-appearance: none;
background: url("chrome://browser/skin/hud-style-button-middle-background.png") repeat-x #464646 center center;
border: 3px solid;
@hudButton@
-moz-border-radius: 5px;
-moz-border-top-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
-moz-border-right-colors: rgba(53,53,53,1) rgba(53,53,53,1) rgba(162,162,162,1);
-moz-border-bottom-colors: rgba(128,128,128,0.35) rgba(0,0,0,0.5) rgba(255,255,255,0.15);
-moz-border-left-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
margin: 0 3px !important;
min-height: 22px;
-moz-padding-start: 2px;
color: #ffffff !important;
}
#editBMPanel_folderMenuList:focus {
@ -1271,21 +1255,14 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
#editBookmarkPanel .expander-up,
#editBookmarkPanel .expander-down {
-moz-appearance: none;
background: url("chrome://browser/skin/hud-style-button-middle-background.png") repeat-x #464646 center center;
border: 3px solid;
@hudButton@
-moz-border-radius: 5px;
-moz-border-top-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
-moz-border-right-colors: rgba(53,53,53,1) rgba(53,53,53,1) rgba(162,162,162,1);
-moz-border-bottom-colors: rgba(128,128,128,0.35) rgba(0,0,0,0.5) rgba(255,255,255,0.15);
-moz-border-left-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
-moz-margin-start: 4px;
-moz-margin-end: 2px;
padding: 0;
-moz-padding-start: 4px;
min-width: 10px;
min-height: 22px;
color: #ffffff !important;
}
#editBookmarkPanel .expander-up:focus,
@ -1926,18 +1903,10 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
/* Popup Buttons */
#identity-popup-more-info-button {
-moz-appearance: none;
background: url("chrome://browser/skin/hud-style-button-middle-background.png") repeat-x #464646 center center;
border: 3px solid;
-moz-border-top-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
-moz-border-right-colors: rgba(53,53,53,1) rgba(53,53,53,1) rgba(162,162,162,1);
-moz-border-bottom-colors: rgba(128,128,128,0.35) rgba(0,0,0,0.5) rgba(255,255,255,0.15);
-moz-border-left-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4);
-moz-border-radius: 20px;
@hudButton@
padding: 1px 9px;
margin: 10px 0 0;
min-height: 0px;
color: #fff;
}
#identity-popup-more-info-button > .button-box > .button-text {

View File

@ -1 +1,3 @@
%include ../../../../toolkit/themes/pinstripe/global/shared.inc
%define hudButton -moz-appearance: none; background: url("chrome://browser/skin/hud-style-button-middle-background.png") repeat-x #464646 center center; border: 3px solid; -moz-border-top-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4); -moz-border-right-colors: rgba(53,53,53,1) rgba(53,53,53,1) rgba(162,162,162,1); -moz-border-bottom-colors: rgba(128,128,128,0.35) rgba(0,0,0,0.5) rgba(255,255,255,0.15); -moz-border-left-colors: rgba(0,0,0,0.35) rgba(26,26,26,0.5) rgba(255,255,255,0.4); -moz-border-radius: 20px; color: #fff;

View File

@ -310,7 +310,7 @@ toolbar[mode="full"] .toolbarbutton-menubutton-button {
#TabsToolbar > toolbarpaletteitem > .toolbarbutton-1 {
-moz-appearance: toolbarbutton;
margin: 0;
padding: 3px;
padding: 0 3px;
border: none !important;
color: inherit !important;
background: transparent !important;
@ -1197,7 +1197,8 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
width: 31px;
}
.tabs-newtab-button:hover:active {
.tabs-newtab-button:hover:active,
#TabsToolbar > #new-tab-button:hover:active {
-moz-image-region: rect(0, 32px, 18px, 16px);
}

View File

@ -524,7 +524,8 @@ nsChromeRegistry::Init()
}
}
nsCOMPtr<nsIObserverService> obsService (do_GetService("@mozilla.org/observer-service;1"));
nsCOMPtr<nsIObserverService> obsService =
mozilla::services::GetObserverService();
if (obsService) {
obsService->AddObserver(this, "command-line-startup", PR_TRUE);
obsService->AddObserver(this, "profile-initial-state", PR_TRUE);
@ -904,7 +905,7 @@ void
nsChromeRegistry::FlushSkinCaches()
{
nsCOMPtr<nsIObserverService> obsSvc =
do_GetService("@mozilla.org/observer-service;1");
mozilla::services::GetObserverService();
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
obsSvc->NotifyObservers(static_cast<nsIChromeRegistry*>(this),
@ -1030,7 +1031,7 @@ void
nsChromeRegistry::FlushAllCaches()
{
nsCOMPtr<nsIObserverService> obsSvc =
do_GetService("@mozilla.org/observer-service;1");
mozilla::services::GetObserverService();
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
obsSvc->NotifyObservers((nsIChromeRegistry*) this,

View File

@ -137,7 +137,6 @@ MOZ_UPDATER = @MOZ_UPDATER@
MOZ_UPDATE_PACKAGING = @MOZ_UPDATE_PACKAGING@
MOZ_NO_ACTIVEX_SUPPORT = @MOZ_NO_ACTIVEX_SUPPORT@
MOZ_ACTIVEX_SCRIPTING_SUPPORT = @MOZ_ACTIVEX_SCRIPTING_SUPPORT@
MOZ_DISABLE_VISTA_SDK_REQUIREMENTS = @MOZ_DISABLE_VISTA_SDK_REQUIREMENTS@
MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
XPC_IDISPATCH_SUPPORT = @XPC_IDISPATCH_SUPPORT@
NS_ENABLE_TSF = @NS_ENABLE_TSF@
@ -363,6 +362,8 @@ INTEL_CXX = @INTEL_CXX@
STL_FLAGS = @STL_FLAGS@
WRAP_STL_INCLUDES = @WRAP_STL_INCLUDES@
MOZ_MSVC_STL_WRAP__Throw= @MOZ_MSVC_STL_WRAP__Throw@
MOZ_MSVC_STL_WRAP__RAISE= @MOZ_MSVC_STL_WRAP__RAISE@
HOST_CC = @HOST_CC@
HOST_CXX = @HOST_CXX@

View File

@ -20,6 +20,7 @@ new
algorithm
deque
iostream
limits
list
map
memory

View File

@ -480,7 +480,6 @@ case "$target" in
;;
esac
MOZ_ARG_WITH_STRING(windows-version,
[ --with-windows-version=WINSDK_TARGETVER
Highest Windows version to target using this SDK
@ -500,28 +499,13 @@ case "$WINSDK_TARGETVER" in
esac
dnl Vista SDK specific api (deprecated)
MOZ_ARG_DISABLE_BOOL(vista-sdk-requirements,
[ --disable-vista-sdk-requirements
Do not build Vista SDK specific code],
MOZ_DISABLE_VISTA_SDK_REQUIREMENTS=1,
MOZ_DISABLE_VISTA_SDK_REQUIREMENTS=$_PLATFORM_MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
if test -n "$COMPILE_ENVIRONMENT"; then
if test -n "$MOZ_DISABLE_VISTA_SDK_REQUIREMENTS"; then
AC_MSG_WARN([--disable-vista-sdk-requirements is deprecated, use --with-windows-version=502 instead])
MOZ_WINSDK_TARGETVER=05020000
fi
if test "$MOZ_WINSDK_TARGETVER" -lt "06000000"; then
MOZ_DISABLE_VISTA_SDK_REQUIREMENTS=1
AC_DEFINE(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
# We can't build parental controls either
MOZ_DISABLE_PARENTAL_CONTROLS=1
fi
fi
AC_SUBST(MOZ_DISABLE_VISTA_SDK_REQUIREMENTS)
case "$target" in
*-cygwin*|*-mingw*|*-msvc*|*-mks*|*-wince|*-winmo)
if test "$GCC" != "yes"; then
@ -713,28 +697,56 @@ EOF
AC_LANG_RESTORE
])
if test "$ac_cv_have_std__Throw" = "no"; then
AC_MSG_ERROR([Your MSVC/SDK doesn't export std::_Throw. This breaks assumptions in Gecko. Please file a bug describing this error along with your build configuration.])
if test "$ac_cv_have_std__Throw" == "yes"; then
AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
ac_cv_have_dllimport_exception_bug,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
AC_TRY_LINK([#include <vector>],
[std::vector<int> v; return v.at(1);],
ac_cv_have_dllimport_exception_bug="no",
ac_cv_have_dllimport_exception_bug="yes")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
WRAP_STL_INCLUDES=1
MOZ_MSVC_STL_WRAP__Throw=1
AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
fi
else
AC_CACHE_CHECK(for overridable _RAISE,
ac_cv_have__RAISE,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
AC_TRY_COMPILE([#include <xstddef>
#undef _RAISE
#define _RAISE(x) externallyDefinedFunction((x).what())
#include <vector>
],
[std::vector<int> v; return v.at(1);],
ac_cv_have__RAISE="no",
ac_cv_have__RAISE="yes")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_have__RAISE" = "yes"; then
WRAP_STL_INCLUDES=1
MOZ_MSVC_STL_WRAP__RAISE=1
AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
else
AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK. Please file a bug describing this error and your build configuration.])
fi
fi
AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
ac_cv_have_dllimport_exception_bug,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
AC_TRY_LINK([#include <vector>],
[std::vector<int> v; return v.at(1);],
ac_cv_have_dllimport_exception_bug="no",
ac_cv_have_dllimport_exception_bug="yes")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
if test "$WRAP_STL_INCLUDES" = "1"; then
STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
WRAP_STL_INCLUDES=1
fi
else
# Check w32api version
@ -846,6 +858,8 @@ AC_SUBST(INTEL_CXX)
AC_SUBST(STL_FLAGS)
AC_SUBST(WRAP_STL_INCLUDES)
AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
dnl ========================================================
dnl Checks for programs.
@ -2111,7 +2125,6 @@ ia64*-hpux*)
*-wince*|*-winmo*)
TARGET_COMPILER_ABI=msvc
_PLATFORM_DEFAULT_TOOLKIT=cairo-windows
_PLATFORM_MOZ_DISABLE_VISTA_SDK_REQUIREMENTS=1
MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
AR_LIST="$AR -list"
@ -5059,8 +5072,6 @@ MOZ_ARG_HEADER(Toolkit Options)
AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
fi
AC_DEFINE_UNQUOTED(MOZ_DEFAULT_TOOLKIT,"$MOZ_WIDGET_TOOLKIT")
dnl ========================================================
dnl = Enable the toolkit as needed =
dnl ========================================================
@ -5180,7 +5191,6 @@ if test "$COMPILE_ENVIRONMENT"; then
fi # COMPILE_ENVIRONMENT
AC_SUBST(MOZ_DEFAULT_TOOLKIT)
AC_SUBST(MOZ_FS_LAYOUT)
dnl ========================================================

View File

@ -0,0 +1,27 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
<title>Testcase for bug 552651</title>
<script class="testbody" type="text/javascript">
function testCancel() {
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function(e) {
if (xhr.readyState == 3) // NOTE : only leaks for state == 3
xhr.abort();
}, false);
xhr.open("GET", "552651.xml", true);
xhr.send();
setTimeout(function f() {
document.documentElement.className = "";
}, 1000);
}
</script>
</head>
<body onload="testCancel()">
This test should not leak...
</body>
</html>

View File

@ -0,0 +1,2 @@
<foo>test</foo>

View File

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var child = document.createTextNode("a");
var attr = document.createAttribute("a");
try {
attr.appendChild(child);
}
catch (e) {
}
</script>
</head>
</html>

View File

@ -61,3 +61,5 @@ load 490760-1.xhtml
load 494810-1.html
load 529670.html
load 554230-1.xhtml
load 552651.html
load 558973.html

View File

@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 et :
* ***** 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
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Boris Zbarsky <bzbarsky@mit.edu> (Original Author)
*
* 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 mozilla_dom_Element_h__
#define mozilla_dom_Element_h__
#include "nsIContent.h"
namespace mozilla {
namespace dom {
class Element : public nsIContent
{
public:
#ifdef MOZILLA_INTERNAL_API
Element(nsINodeInfo* aNodeInfo) : nsIContent(aNodeInfo) {}
#endif // MOZILLA_INTERNAL_API
};
} // namespace dom
} // namespace mozilla
inline mozilla::dom::Element* nsINode::AsElement() {
NS_ASSERTION(IsElement(), "Not an element?");
return static_cast<mozilla::dom::Element*>(this);
}
#endif // mozilla_dom_Element_h__

View File

@ -78,6 +78,7 @@ nsDOMFile.h \
nsLineBreaker.h \
nsReferencedElement.h \
nsXMLNameSpaceMap.h \
Element.h \
$(NULL)
ifndef DISABLE_XFORMS_HOOKS

View File

@ -137,7 +137,11 @@ typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *);
namespace mozilla {
class IHistory;
}
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
extern const char kLoadAsData[];
@ -232,8 +236,8 @@ public:
* This method fills the |aArray| with all ancestor nodes of |aNode|
* including |aNode| at the zero index.
*/
static nsresult GetAncestors(nsIDOMNode* aNode,
nsTArray<nsIDOMNode*>* aArray);
static nsresult GetAncestors(nsINode* aNode,
nsTArray<nsINode*>& aArray);
/*
* This method fills |aAncestorNodes| with all ancestor nodes of |aNode|
@ -1362,7 +1366,7 @@ public:
* If aContent is an HTML element with a DOM level 0 'name', then
* return the name. Otherwise return null.
*/
static nsIAtom* IsNamedItem(nsIContent* aContent);
static nsIAtom* IsNamedItem(mozilla::dom::Element* aElement);
/**
* Get the application manifest URI for this document. The manifest URI

View File

@ -615,20 +615,7 @@ public:
IME_STATUS_PASSWORD | IME_STATUS_PLUGIN,
IME_STATUS_MASK_OPENED = IME_STATUS_OPEN | IME_STATUS_CLOSE
};
virtual PRUint32 GetDesiredIMEState()
{
if (!IsEditableInternal())
return IME_STATUS_DISABLE;
nsIContent *editableAncestor = nsnull;
for (nsIContent* parent = GetParent();
parent && parent->HasFlag(NODE_IS_EDITABLE);
parent = parent->GetParent())
editableAncestor = parent;
// This is in another editable content, use the result of it.
if (editableAncestor)
return editableAncestor->GetDesiredIMEState();
return IME_STATUS_ENABLE;
}
virtual PRUint32 GetDesiredIMEState();
/**
* Gets content node with the binding (or native code, possibly on the

View File

@ -40,20 +40,15 @@
#include "nsISupports.h"
class nsIDOMText; /* forward declaration */
class nsIDOMCDATASection; /* forward declaration */
class nsIDOMProcessingInstruction; /* forward declaration */
class nsIDOMComment; /* forward declaration */
class nsIDOMDocumentType; /* forward declaration */
class nsIDOMElement; /* forward declaration */
class nsIDOMDocument; /* forward declaration */
class nsIContent;
class nsIDocument;
class nsAString;
/* starting interface: nsIContentSerializer */
#define NS_ICONTENTSERIALIZER_IID \
{ 0x34769de0, 0x30d0, 0x4cef, \
{ 0x89, 0x4a, 0xfc, 0xd8, 0xbb, 0x27, 0xc4, 0xb4 } }
{ 0xb1ee32f2, 0xb8c4, 0x49b9, \
{ 0x93, 0xdf, 0xb6, 0xfa, 0xb5, 0xd5, 0x46, 0x88 } }
class nsIContentSerializer : public nsISupports {
public:
@ -64,29 +59,29 @@ class nsIContentSerializer : public nsISupports {
const char* aCharSet, PRBool aIsCopying,
PRBool aIsWholeDocument) = 0;
NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
NS_IMETHOD AppendText(nsIContent* aText, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr) = 0;
NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
PRInt32 aStartOffset, PRInt32 aEndOffset,
nsAString& aStr) = 0;
NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr) = 0;
NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr) = 0;
NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
nsAString& aStr) = 0;
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr) = 0;
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
NS_IMETHOD AppendElementEnd(nsIContent *aElement,
nsAString& aStr) = 0;
NS_IMETHOD Flush(nsAString& aStr) = 0;
@ -96,7 +91,7 @@ class nsIContentSerializer : public nsISupports {
* serialized by other methods. XML declaration is the most likely
* thing this method can produce.
*/
NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr) = 0;
};

View File

@ -111,6 +111,7 @@ class Loader;
namespace dom {
class Link;
class Element;
} // namespace dom
} // namespace mozilla
@ -470,32 +471,34 @@ public:
virtual nsIContent *FindContentForSubDocument(nsIDocument *aDocument) const = 0;
/**
* Return the root content object for this document.
* Return the root element for this document.
*/
nsIContent *GetRootContent() const
mozilla::dom::Element *GetRootElement() const
{
return (mCachedRootContent &&
mCachedRootContent->GetNodeParent() == this) ?
reinterpret_cast<nsIContent*>(mCachedRootContent.get()) :
GetRootContentInternal();
return (mCachedRootElement &&
mCachedRootElement->GetNodeParent() == this) ?
reinterpret_cast<mozilla::dom::Element*>(mCachedRootElement.get()) :
GetRootElementInternal();
}
virtual nsIContent *GetRootContentInternal() const = 0;
protected:
virtual mozilla::dom::Element *GetRootElementInternal() const = 0;
public:
// Get the root <html> element, or return null if there isn't one (e.g.
// if the root isn't <html>)
nsIContent* GetHtmlContent();
mozilla::dom::Element* GetHtmlElement();
// Returns the first child of GetHtmlContent which has the given tag,
// or nsnull if that doesn't exist.
nsIContent* GetHtmlChildContent(nsIAtom* aTag);
mozilla::dom::Element* GetHtmlChildElement(nsIAtom* aTag);
// Get the canonical <body> element, or return null if there isn't one (e.g.
// if the root isn't <html> or if the <body> isn't there)
nsIContent* GetBodyContent() {
return GetHtmlChildContent(nsGkAtoms::body);
mozilla::dom::Element* GetBodyElement() {
return GetHtmlChildElement(nsGkAtoms::body);
}
// Get the canonical <head> element, or return null if there isn't one (e.g.
// if the root isn't <html> or if the <head> isn't there)
nsIContent* GetHeadContent() {
return GetHtmlChildContent(nsGkAtoms::head);
mozilla::dom::Element* GetHeadElement() {
return GetHtmlChildElement(nsGkAtoms::head);
}
/**
@ -1379,10 +1382,10 @@ protected:
// This is just a weak pointer; the parent document owns its children.
nsIDocument* mParentDocument;
// A reference to the content last returned from GetRootContent().
// This should be an nsIContent, but that would force us to pull in
// nsIContent.h
nsCOMPtr<nsINode> mCachedRootContent;
// A reference to the element last returned from GetRootElement().
// This should be an Element, but that would force us to pull in
// Element.h and therefore nsIContent.h.
nsCOMPtr<nsINode> mCachedRootElement;
// We'd like these to be nsRefPtrs, but that'd require us to include
// additional headers that we don't want to expose.

View File

@ -302,7 +302,7 @@ interface nsIDocumentEncoder : nsISupports
/**
* Encode the document into a string. Stores the extra context information
* into the two arguments.
* @param [OUT] aContextString The string where the parent heirarchy
* @param [OUT] aContextString The string where the parent hierarchy
* information will be stored.
* @param [OUT] aInfoString The string where extra context info will
* be stored.

View File

@ -66,6 +66,12 @@ class nsNodeWeakReference;
class nsNodeSupportsWeakRefTearoff;
class nsIEditor;
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
enum {
// This bit will be set if the node doesn't have nsSlots
NODE_DOESNT_HAVE_SLOTS = 0x00000001U,
@ -154,8 +160,11 @@ enum {
// node(s) with NODE_NEEDS_FRAME and the root content.
NODE_DESCENDANTS_NEED_FRAMES = 0x00100000U,
// Set if the node is an element.
NODE_IS_ELEMENT = 0x00200000U,
// Four bits for the script-type ID
NODE_SCRIPT_TYPE_OFFSET = 21,
NODE_SCRIPT_TYPE_OFFSET = 22,
NODE_SCRIPT_TYPE_SIZE = 4,
@ -298,27 +307,25 @@ public:
eDOCUMENT = 1 << 1,
/** nsIAttribute nodes */
eATTRIBUTE = 1 << 2,
/** elements */
eELEMENT = 1 << 3,
/** text nodes */
eTEXT = 1 << 4,
eTEXT = 1 << 3,
/** xml processing instructions */
ePROCESSING_INSTRUCTION = 1 << 5,
ePROCESSING_INSTRUCTION = 1 << 4,
/** comment nodes */
eCOMMENT = 1 << 6,
eCOMMENT = 1 << 5,
/** form control elements */
eHTML_FORM_CONTROL = 1 << 7,
eHTML_FORM_CONTROL = 1 << 6,
/** svg elements */
eSVG = 1 << 8,
eSVG = 1 << 7,
/** document fragments */
eDOCUMENT_FRAGMENT = 1 << 9,
eDOCUMENT_FRAGMENT = 1 << 8,
/** data nodes (comments, PIs, text). Nodes of this type always
returns a non-null value for nsIContent::GetText() */
eDATA_NODE = 1 << 10,
eDATA_NODE = 1 << 19,
/** nsHTMLMediaElement */
eMEDIA = 1 << 11,
eMEDIA = 1 << 10,
/** animation elements */
eANIMATION = 1 << 12
eANIMATION = 1 << 11
};
/**
@ -331,6 +338,19 @@ public:
*/
virtual PRBool IsNodeOfType(PRUint32 aFlags) const = 0;
/**
* Return whether the node is an Element node
*/
PRBool IsElement() const {
return HasFlag(NODE_IS_ELEMENT);
}
/**
* Return this node as an Element. Should only be used for nodes
* for which IsElement() is true.
*/
mozilla::dom::Element* AsElement();
/**
* Get the number of children
* @return the number of children
@ -420,6 +440,10 @@ public:
return NS_ERROR_NULL_POINTER;
}
if (IsNodeOfType(eDATA_NODE)) {
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
}
PRInt32 index = IndexOf(aOldChild);
if (index == -1) {
// aOldChild isn't one of our children.
@ -443,7 +467,7 @@ public:
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
* than one element node as a child of a document. Doing this will also
* assert -- you shouldn't be doing it! Check with
* nsIDocument::GetRootContent() first if you're not sure. Apart from this
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
* one constraint, this doesn't do any checking on whether aKid is a valid
* child of |this|.
*
@ -464,7 +488,7 @@ public:
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
* than one element node as a child of a document. Doing this will also
* assert -- you shouldn't be doing it! Check with
* nsIDocument::GetRootContent() first if you're not sure. Apart from this
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
* one constraint, this doesn't do any checking on whether aKid is a valid
* child of |this|.
*

View File

@ -165,7 +165,7 @@ mozSanitizingHTMLSerializer::Flush(nsAString& aStr)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
mozSanitizingHTMLSerializer::AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr)
{
return NS_OK;
@ -225,7 +225,7 @@ mozSanitizingHTMLSerializer::GetIdForContent(nsIContent* aContent)
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::AppendText(nsIDOMText* aText,
mozSanitizingHTMLSerializer::AppendText(nsIContent* aText,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
@ -241,14 +241,13 @@ mozSanitizingHTMLSerializer::AppendText(nsIDOMText* aText,
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
mozSanitizingHTMLSerializer::AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
mContent = do_QueryInterface(aElement);
NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);
mContent = aElement;
mOutputString = &aStr;
@ -271,13 +270,12 @@ mozSanitizingHTMLSerializer::AppendElementStart(nsIDOMElement *aElement,
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::AppendElementEnd(nsIDOMElement *aElement,
mozSanitizingHTMLSerializer::AppendElementEnd(nsIContent *aElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
mContent = do_QueryInterface(aElement);
NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);
mContent = aElement;
mOutputString = &aStr;

View File

@ -73,29 +73,29 @@ public:
NS_IMETHOD Init(PRUint32 flags, PRUint32 dummy, const char* aCharSet,
PRBool aIsCopying, PRBool aIsWholeDocument);
NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
NS_IMETHOD AppendText(nsIContent* aText, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr);
NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
PRInt32 aStartOffset, PRInt32 aEndOffset,
nsAString& aStr)
{ return NS_OK; }
NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
{ return NS_OK; }
NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr)
{ return NS_OK; }
NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype, nsAString& aStr)
NS_IMETHOD AppendDoctype(nsIContent *aDoctype, nsAString& aStr)
{ return NS_OK; }
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement, nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIContent *aElement, nsAString& aStr);
NS_IMETHOD Flush(nsAString& aStr);
NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr);
// nsIContentSink

View File

@ -50,6 +50,7 @@
#include "nsISHEntry.h"
#include "nsISHContainer.h"
#include "nsIWindowWatcher.h"
#include "mozilla/Services.h"
static PRBool sInited = 0;
PRUint32 nsCCUncollectableMarker::sGeneration = 0;
@ -67,10 +68,12 @@ nsCCUncollectableMarker::Init()
nsCOMPtr<nsIObserver> marker = new nsCCUncollectableMarker;
NS_ENSURE_TRUE(marker, NS_ERROR_OUT_OF_MEMORY);
nsresult rv;
nsCOMPtr<nsIObserverService> obs =
do_GetService("@mozilla.org/observer-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::services::GetObserverService();
if (!obs)
return NS_ERROR_FAILURE;
nsresult rv;
// This makes the observer service hold an owning reference to the marker
rv = obs->AddObserver(marker, "xpcom-shutdown", PR_FALSE);
@ -186,12 +189,11 @@ nsresult
nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
const PRUnichar* aData)
{
nsresult rv;
if (!strcmp(aTopic, "xpcom-shutdown")) {
nsCOMPtr<nsIObserverService> obs =
do_GetService("@mozilla.org/observer-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::services::GetObserverService();
if (!obs)
return NS_ERROR_FAILURE;
// No need for kungFuDeathGrip here, yay observerservice!
obs->RemoveObserver(this, "xpcom-shutdown");
@ -209,6 +211,8 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
++sGeneration;
}
nsresult rv;
// Iterate all toplevel windows
nsCOMPtr<nsISimpleEnumerator> windowList;
nsCOMPtr<nsIWindowMediator> med =

View File

@ -67,6 +67,9 @@ NS_NewPreContentIterator(nsIContentIterator** aInstancePtrResult);
#define ASSERT_IN_SYNC PR_BEGIN_MACRO PR_END_MACRO
#endif
using namespace mozilla::dom;
nsBaseContentList::~nsBaseContentList()
{
}
@ -605,8 +608,7 @@ nsContentList::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
PRInt32 aModType)
{
NS_PRECONDITION(aContent, "Must have a content node to work with");
NS_PRECONDITION(aContent->IsNodeOfType(nsINode::eELEMENT),
"Should be an element");
NS_PRECONDITION(aContent->IsElement(), "Should be an element");
if (!mFunc || !mFuncMayDependOnAttr || mState == LIST_DIRTY ||
!MayContainRelevantNodes(aContent->GetNodeParent()) ||
@ -616,7 +618,7 @@ nsContentList::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
return;
}
if (Match(aContent)) {
if (Match(aContent->AsElement())) {
if (mElements.IndexOf(aContent) == -1) {
// We match aContent now, and it's not in our list already. Just dirty
// ourselves; this is simpler than trying to figure out where to insert
@ -714,8 +716,8 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
iter.Next()) {
PRUint32 limit = PRUint32(-1);
nsIContent* newContent = iter;
if (newContent->IsNodeOfType(nsINode::eELEMENT)) {
PopulateWith(newContent, limit);
if (newContent->IsElement()) {
PopulateWith(newContent->AsElement(), limit);
}
}
@ -762,20 +764,14 @@ nsContentList::ContentRemoved(nsIDocument *aDocument,
}
PRBool
nsContentList::Match(nsIContent *aContent)
nsContentList::Match(Element *aElement)
{
if (!aContent)
return PR_FALSE;
NS_ASSERTION(aContent->IsNodeOfType(nsINode::eELEMENT),
"Must have element here");
if (mFunc) {
return (*mFunc)(aContent, mMatchNameSpaceId, mMatchAtom, mData);
return (*mFunc)(aElement, mMatchNameSpaceId, mMatchAtom, mData);
}
if (mMatchAtom) {
nsINodeInfo *ni = aContent->NodeInfo();
nsINodeInfo *ni = aElement->NodeInfo();
if (mMatchNameSpaceId == kNameSpaceID_Unknown) {
return (mMatchAll || ni->QualifiedNameEquals(mMatchAtom));
@ -799,11 +795,11 @@ nsContentList::MatchSelf(nsIContent *aContent)
NS_PRECONDITION(mDeep || aContent->GetNodeParent() == mRootNode,
"MatchSelf called on a node that we can't possibly match");
if (!aContent->IsNodeOfType(nsINode::eELEMENT)) {
if (!aContent->IsElement()) {
return PR_FALSE;
}
if (Match(aContent))
if (Match(aContent->AsElement()))
return PR_TRUE;
if (!mDeep)
@ -819,17 +815,15 @@ nsContentList::MatchSelf(nsIContent *aContent)
}
void
nsContentList::PopulateWith(nsIContent *aContent, PRUint32& aElementsToAppend)
nsContentList::PopulateWith(Element *aElement, PRUint32& aElementsToAppend)
{
NS_PRECONDITION(mDeep || aContent->GetNodeParent() == mRootNode,
NS_PRECONDITION(mDeep || aElement->GetNodeParent() == mRootNode,
"PopulateWith called on nodes we can't possibly match");
NS_PRECONDITION(aContent != mRootNode,
NS_PRECONDITION(aElement != mRootNode,
"We should never be trying to match mRootNode");
NS_PRECONDITION(aContent->IsNodeOfType(nsINode::eELEMENT),
"Should be an element");
if (Match(aContent)) {
mElements.AppendObject(aContent);
if (Match(aElement)) {
mElements.AppendObject(aElement);
--aElementsToAppend;
if (aElementsToAppend == 0)
return;
@ -839,10 +833,10 @@ nsContentList::PopulateWith(nsIContent *aContent, PRUint32& aElementsToAppend)
if (!mDeep)
return;
for (nsINode::ChildIterator iter(aContent); !iter.IsDone(); iter.Next()) {
for (nsINode::ChildIterator iter(aElement); !iter.IsDone(); iter.Next()) {
nsIContent* curContent = iter;
if (curContent->IsNodeOfType(nsINode::eELEMENT)) {
PopulateWith(curContent, aElementsToAppend);
if (curContent->IsElement()) {
PopulateWith(curContent->AsElement(), aElementsToAppend);
if (aElementsToAppend == 0)
break;
}
@ -875,8 +869,8 @@ nsContentList::PopulateWithStartingAfter(nsINode *aStartRoot,
!iter.IsDone();
iter.Next()) {
nsIContent* content = iter;
if (content->IsNodeOfType(nsINode::eELEMENT)) {
PopulateWith(content, aElementsToAppend);
if (content->IsElement()) {
PopulateWith(content->AsElement(), aElementsToAppend);
NS_ASSERTION(aElementsToAppend + mElements.Count() == invariant,
"Something is awry in PopulateWith!");
@ -1024,7 +1018,7 @@ nsContentList::AssertInSync()
// elements that are outside of the document element.
nsIContent *root;
if (mRootNode->IsNodeOfType(nsINode::eDOCUMENT)) {
root = static_cast<nsIDocument*>(mRootNode)->GetRootContent();
root = static_cast<nsIDocument*>(mRootNode)->GetRootElement();
}
else {
root = static_cast<nsIContent*>(mRootNode);
@ -1049,7 +1043,7 @@ nsContentList::AssertInSync()
break;
}
if (cur->IsNodeOfType(nsINode::eELEMENT) && Match(cur)) {
if (cur->IsElement() && Match(cur->AsElement())) {
NS_ASSERTION(cnt < mElements.Count() && mElements[cnt] == cur,
"Elements is out of sync");
++cnt;

View File

@ -56,6 +56,7 @@
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "nsCRT.h"
#include "Element.h"
// Magic namespace id that means "match all namespaces". This is
// negative so it won't collide with actual namespace constants.
@ -238,8 +239,7 @@ public:
* @param aFunc the function to be called to determine whether we match.
* This function MUST NOT ever cause mutation of the DOM.
* The nsContentList implementation guarantees that everything
* passed to the function will be
* IsNodeOfType(nsINode::eELEMENT).
* passed to the function will be IsElement().
* @param aDestroyFunc the function that will be called to destroy aData
* @param aData closure data that will need to be passed back to aFunc
* @param aDeep If false, then look only at children of the root, nothing
@ -308,12 +308,12 @@ public:
protected:
/**
* Returns whether the content element matches our criterion
* Returns whether the element matches our criterion
*
* @param aContent the content to attempt to match
* @param aElement the element to attempt to match
* @return whether we match
*/
PRBool Match(nsIContent *aContent);
PRBool Match(mozilla::dom::Element *aElement);
/**
* Match recursively. See if anything in the subtree rooted at
* aContent matches our criterion.
@ -324,19 +324,18 @@ protected:
PRBool MatchSelf(nsIContent *aContent);
/**
* Add elements in the subtree rooted in aContent that match our
* Add elements in the subtree rooted in aElement that match our
* criterion to our list until we've picked up aElementsToAppend
* elements. This function enforces the invariant that
* |aElementsToAppend + mElements.Count()| is a constant.
*
* @param aContent the root of the subtree we want to traverse. This node
* @param aElement the root of the subtree we want to traverse. This element
* is always included in the traversal and is thus the
* first node tested. This must be
* IsNodeOfType(nsINode::eELEMENT).
* first element tested.
* @param aElementsToAppend how many elements to append to the list
* before stopping
*/
void NS_FASTCALL PopulateWith(nsIContent *aContent,
void NS_FASTCALL PopulateWith(mozilla::dom::Element *aElement,
PRUint32 & aElementsToAppend);
/**

View File

@ -1096,7 +1096,7 @@ void
nsContentSink::ProcessOfflineManifest(nsIContent *aElement)
{
// Only check the manifest for root document nodes.
if (aElement != mDocument->GetRootContent()) {
if (aElement != mDocument->GetRootElement()) {
return;
}

View File

@ -61,6 +61,7 @@
#include "nsIContentUtils.h"
#include "nsIXPConnect.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIDocument.h"
#include "nsINodeInfo.h"
#include "nsReadableUtils.h"
@ -193,6 +194,8 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "jsregexp.h"
#include "jstypedarray.h"
using namespace mozilla::dom;
const char kLoadAsData[] = "loadAsData";
static const char kJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1";
@ -887,7 +890,7 @@ nsContentUtils::IsHTMLWhitespace(PRUnichar aChar)
void
nsContentUtils::GetOfflineAppManifest(nsIDocument *aDocument, nsIURI **aURI)
{
nsCOMPtr<nsIContent> docElement = aDocument->GetRootContent();
Element* docElement = aDocument->GetRootElement();
if (!docElement) {
return;
}
@ -1186,7 +1189,7 @@ nsContentUtils::InProlog(nsINode *aNode)
}
nsIDocument* doc = static_cast<nsIDocument*>(parent);
nsIContent* root = doc->GetRootContent();
nsIContent* root = doc->GetRootElement();
return !root || doc->IndexOf(aNode) < doc->IndexOf(root);
}
@ -1460,20 +1463,13 @@ nsContentUtils::ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
// static
nsresult
nsContentUtils::GetAncestors(nsIDOMNode* aNode,
nsTArray<nsIDOMNode*>* aArray)
nsContentUtils::GetAncestors(nsINode* aNode,
nsTArray<nsINode*>& aArray)
{
NS_ENSURE_ARG_POINTER(aNode);
nsCOMPtr<nsIDOMNode> node(aNode);
nsCOMPtr<nsIDOMNode> ancestor;
do {
aArray->AppendElement(node.get());
node->GetParentNode(getter_AddRefs(ancestor));
node.swap(ancestor);
} while (node);
while (aNode) {
aArray.AppendElement(aNode);
aNode = aNode->GetNodeParent();
}
return NS_OK;
}
@ -3494,7 +3490,7 @@ void
nsContentUtils::RegisterShutdownObserver(nsIObserver* aObserver)
{
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
mozilla::services::GetObserverService();
if (observerService) {
observerService->AddObserver(aObserver,
NS_XPCOM_SHUTDOWN_OBSERVER_ID,
@ -3507,7 +3503,7 @@ void
nsContentUtils::UnregisterShutdownObserver(nsIObserver* aObserver)
{
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
mozilla::services::GetObserverService();
if (observerService) {
observerService->RemoveObserver(aObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
}
@ -3534,6 +3530,12 @@ nsContentUtils::HasMutationListeners(nsINode* aNode,
return PR_FALSE;
}
NS_ASSERTION((aNode->IsNodeOfType(nsINode::eCONTENT) &&
static_cast<nsIContent*>(aNode)->
IsInNativeAnonymousSubtree()) ||
sScriptBlockerCount == sRemovableScriptBlockerCount,
"Want to fire mutation events, but it's not safe");
// global object will be null for documents that don't have windows.
nsPIDOMWindow* window = doc->GetInnerWindow();
// This relies on nsEventListenerManager::AddEventListener, which sets
@ -3765,9 +3767,9 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> contextAsContent = do_QueryInterface(aContextNode);
if (contextAsContent && !contextAsContent->IsNodeOfType(nsINode::eELEMENT)) {
if (contextAsContent && !contextAsContent->IsElement()) {
contextAsContent = contextAsContent->GetParent();
if (contextAsContent && !contextAsContent->IsNodeOfType(nsINode::eELEMENT)) {
if (contextAsContent && !contextAsContent->IsElement()) {
// can this even happen?
contextAsContent = nsnull;
}
@ -3796,10 +3798,10 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
nsAutoString uriStr, nameStr;
nsCOMPtr<nsIContent> content = do_QueryInterface(aContextNode);
// just in case we have a text node
if (content && !content->IsNodeOfType(nsINode::eELEMENT))
if (content && !content->IsElement())
content = content->GetParent();
while (content && content->IsNodeOfType(nsINode::eELEMENT)) {
while (content && content->IsElement()) {
nsString& tagName = *tagStack.AppendElement();
NS_ENSURE_TRUE(&tagName, NS_ERROR_OUT_OF_MEMORY);
@ -4008,7 +4010,7 @@ static void AppendNodeTextContentsRecurse(nsINode* aNode, nsAString& aResult)
nsIContent* child;
PRUint32 i;
for (i = 0; (child = aNode->GetChildAt(i)); ++i) {
if (child->IsNodeOfType(nsINode::eELEMENT)) {
if (child->IsElement()) {
AppendNodeTextContentsRecurse(child, aResult);
}
else if (child->IsNodeOfType(nsINode::eTEXT)) {
@ -5009,13 +5011,13 @@ nsAutoGCRoot::Shutdown()
}
nsIAtom*
nsContentUtils::IsNamedItem(nsIContent* aContent)
nsContentUtils::IsNamedItem(Element* aElement)
{
// Only the content types reflected in Level 0 with a NAME
// attribute are registered. Images, layers and forms always get
// reflected up to the document. Applets and embeds only go
// to the closest container (which could be a form).
nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aContent);
nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aElement);
if (!elm) {
return nsnull;
}
@ -5425,7 +5427,7 @@ nsContentUtils::StripNullChars(const nsAString& aInStr, nsAString& aOutStr)
namespace {
const size_t kCloneStackFrameStackSize = 20;
const unsigned int kCloneStackFrameStackSize = 20;
class CloneStackFrame
{
@ -5635,25 +5637,14 @@ CloneSimpleValues(JSContext* cx,
NS_ASSERTION(JSVAL_IS_OBJECT(val), "Not an object!");
JSObject* obj = JSVAL_TO_OBJECT(val);
// See if this JSObject is backed by some C++ object. If it is then we assume
// that it is inappropriate to clone.
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
nsContentUtils::XPConnect()->
GetWrappedNativeOfJSObject(cx, obj, getter_AddRefs(wrapper));
if (wrapper) {
return SetPropertyOnValueOrObject(cx, JSVAL_NULL, rval, robj, rid);
// Dense arrays of primitives can be cloned quickly.
JSObject* newArray;
if (!js_CloneDensePrimitiveArray(cx, obj, &newArray)) {
return NS_ERROR_FAILURE;
}
// Security wrapped objects are auto-nulled as well.
JSClass* clasp = JS_GET_CLASS(cx, obj);
if ((clasp->flags & JSCLASS_IS_EXTENDED) &&
((JSExtendedClass*)clasp)->wrappedObject) {
return SetPropertyOnValueOrObject(cx, JSVAL_NULL, rval, robj, rid);
}
// Function objects don't get cloned.
if (JS_ObjectIsFunction(cx, obj)) {
return SetPropertyOnValueOrObject(cx, JSVAL_NULL, rval, robj, rid);
if (newArray) {
return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newArray), rval, robj,
rid);
}
// Date objects.
@ -5710,6 +5701,27 @@ CloneSimpleValues(JSContext* cx,
// Do we support Blob?
// Do we support FileList?
// Function objects don't get cloned.
if (JS_ObjectIsFunction(cx, obj)) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
// Security wrapped objects are not allowed either.
JSClass* clasp = JS_GET_CLASS(cx, obj);
if ((clasp->flags & JSCLASS_IS_EXTENDED) &&
((JSExtendedClass*)clasp)->wrappedObject) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
// See if this JSObject is backed by some C++ object. If it is then we assume
// that it is inappropriate to clone.
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
nsContentUtils::XPConnect()->
GetWrappedNativeOfJSObject(cx, obj, getter_AddRefs(wrapper));
if (wrapper) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
*wasCloned = PR_FALSE;
return NS_OK;
}
@ -5854,6 +5866,13 @@ nsContentUtils::ReparentClonedObjectToScope(JSContext* cx,
return NS_ERROR_FAILURE;
}
// Primitive arrays don't need to be enumerated either but the proto and
// parent needed to be fixed above. Now we can just move on.
if (js_IsDensePrimitiveArray(data.obj)) {
objectData.RemoveElementAt(objectData.Length() - 1);
continue;
}
// And now enumerate the object's properties.
if (!(data.ids = JS_Enumerate(cx, data.obj))) {
return NS_ERROR_FAILURE;

View File

@ -682,7 +682,7 @@ nsCopySupport::FireClipboardEvent(PRInt32 aType, nsIPresShell* aPresShell, nsISe
// if no content node was set, just get the root
if (!content) {
content = doc->GetRootContent();
content = doc->GetRootElement();
if (!content)
return PR_FALSE;
}

View File

@ -52,7 +52,7 @@
#include "nsGkAtoms.h"
#include "nsWhitespaceTokenizer.h"
#include "nsIChannelEventSink.h"
#include "nsCommaSeparatedTokenizer.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsXMLHttpRequest.h"
static PRBool gDisableCORS = PR_FALSE;
@ -291,7 +291,7 @@ nsCrossSiteListenerProxy::CheckRequestApproved(nsIRequest* aRequest,
headerVal);
PRBool foundMethod = mPreflightMethod.EqualsLiteral("GET") ||
mPreflightMethod.EqualsLiteral("POST");
nsCCommaSeparatedTokenizer methodTokens(headerVal);
nsCCharSeparatedTokenizer methodTokens(headerVal, ',');
while(methodTokens.hasMoreTokens()) {
const nsDependentCSubstring& method = methodTokens.nextToken();
if (method.IsEmpty()) {
@ -310,7 +310,7 @@ nsCrossSiteListenerProxy::CheckRequestApproved(nsIRequest* aRequest,
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"),
headerVal);
nsTArray<nsCString> headers;
nsCCommaSeparatedTokenizer headerTokens(headerVal);
nsCCharSeparatedTokenizer headerTokens(headerVal, ',');
while(headerTokens.hasMoreTokens()) {
const nsDependentCSubstring& header = headerTokens.nextToken();
if (header.IsEmpty()) {

View File

@ -375,13 +375,13 @@ nsDOMAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
NS_IMETHODIMP
nsDOMAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
{
return NS_ERROR_NOT_IMPLEMENTED;
return ReplaceOrInsertBefore(PR_FALSE, aNewChild, aRefChild, aReturn);
}
NS_IMETHODIMP
nsDOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
{
return NS_ERROR_NOT_IMPLEMENTED;
return ReplaceOrInsertBefore(PR_TRUE, aNewChild, aOldChild, aReturn);
}
NS_IMETHODIMP
@ -393,7 +393,7 @@ nsDOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
NS_IMETHODIMP
nsDOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
{
return NS_ERROR_NOT_IMPLEMENTED;
return InsertBefore(aNewChild, nsnull, aReturn);
}
nsresult
@ -842,7 +842,10 @@ nsDOMAttribute::EnsureChildState(PRBool aSetText, PRBool &aHasChild) const
aHasChild = !value.IsEmpty();
if (aSetText && aHasChild) {
mChild->SetText(value, PR_TRUE);
// aNotify should probably be PR_TRUE sometimes, but it's unlikely that
// anyone cares. And we aren't updating the node when the attribute changes
// anyway so any notifications are way late.
mChild->SetText(value, PR_FALSE);
}
return NS_OK;

View File

@ -78,6 +78,7 @@
#include "nsIDOMDocumentView.h"
#include "nsIDOMAbstractView.h"
#include "nsIDOMDocumentXBL.h"
#include "mozilla/FunctionTimer.h"
#include "nsGenericElement.h"
#include "nsGenericHTMLElement.h"
#include "nsIDOMEventGroup.h"
@ -181,6 +182,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
#endif // MOZ_MEDIA
#include "mozAutoDocUpdate.h"
#include "nsGlobalWindow.h"
#ifdef MOZ_SMIL
#include "nsSMILAnimationController.h"
@ -257,17 +259,17 @@ nsIdentifierMapEntry::CreateNameContentList()
return NS_OK;
}
nsIContent*
nsIdentifierMapEntry::GetIdContent()
Element*
nsIdentifierMapEntry::GetIdElement()
{
return static_cast<nsIContent*>(mIdContentList.SafeElementAt(0));
return static_cast<Element*>(mIdContentList.SafeElementAt(0));
}
void
nsIdentifierMapEntry::AppendAllIdContent(nsCOMArray<nsIContent>* aElements)
{
for (PRInt32 i = 0; i < mIdContentList.Count(); ++i) {
aElements->AppendObject(static_cast<nsIContent*>(mIdContentList[i]));
aElements->AppendObject(static_cast<Element*>(mIdContentList[i]));
}
}
@ -300,8 +302,8 @@ nsIdentifierMapEntry::RemoveContentChangeCallback(nsIDocument::IDTargetObserver
}
struct FireChangeArgs {
nsIContent* mFrom;
nsIContent* mTo;
Element* mFrom;
Element* mTo;
};
static PLDHashOperator
@ -313,35 +315,35 @@ FireChangeEnumerator(nsIdentifierMapEntry::ChangeCallbackEntry *aEntry, void *aA
}
void
nsIdentifierMapEntry::FireChangeCallbacks(nsIContent* aOldContent,
nsIContent* aNewContent)
nsIdentifierMapEntry::FireChangeCallbacks(Element* aOldElement,
Element* aNewElement)
{
if (!mChangeCallbacks)
return;
FireChangeArgs args = { aOldContent, aNewContent };
FireChangeArgs args = { aOldElement, aNewElement };
mChangeCallbacks->EnumerateEntries(FireChangeEnumerator, &args);
}
PRBool
nsIdentifierMapEntry::AddIdContent(nsIContent* aContent)
nsIdentifierMapEntry::AddIdElement(Element* aElement)
{
NS_PRECONDITION(aContent, "Must have content");
NS_PRECONDITION(aElement, "Must have element");
NS_PRECONDITION(mIdContentList.IndexOf(nsnull) < 0,
"Why is null in our list?");
#ifdef DEBUG
nsIContent* currentContent =
static_cast<nsIContent*>(mIdContentList.SafeElementAt(0));
Element* currentElement =
static_cast<Element*>(mIdContentList.SafeElementAt(0));
#endif
// Common case
if (mIdContentList.Count() == 0) {
if (!mIdContentList.AppendElement(aContent))
if (!mIdContentList.AppendElement(aElement))
return PR_FALSE;
NS_ADDREF(aContent);
NS_ASSERTION(currentContent == nsnull, "How did that happen?");
FireChangeCallbacks(nsnull, aContent);
NS_ADDREF(aElement);
NS_ASSERTION(currentElement == nsnull, "How did that happen?");
FireChangeCallbacks(nsnull, aElement);
return PR_TRUE;
}
@ -355,56 +357,57 @@ nsIdentifierMapEntry::AddIdContent(nsIContent* aContent)
PRInt32 cur = (start + end) / 2;
NS_ASSERTION(cur >= start && cur < end, "What happened here?");
nsIContent* curContent = static_cast<nsIContent*>(mIdContentList[cur]);
if (curContent == aContent) {
Element* curElement = static_cast<Element*>(mIdContentList[cur]);
if (curElement == aElement) {
// Already in the list, so already in the right spot. Get out of here.
// XXXbz this only happens because XUL does all sorts of random
// UpdateIdTableEntry calls. Hate, hate, hate!
return PR_TRUE;
}
if (nsContentUtils::PositionIsBefore(aContent, curContent)) {
if (nsContentUtils::PositionIsBefore(aElement, curElement)) {
end = cur;
} else {
start = cur + 1;
}
} while (start != end);
if (!mIdContentList.InsertElementAt(aContent, start))
if (!mIdContentList.InsertElementAt(aElement, start))
return PR_FALSE;
NS_ADDREF(aContent);
NS_ADDREF(aElement);
if (start == 0) {
nsIContent* oldContent =
static_cast<nsIContent*>(mIdContentList.SafeElementAt(1));
NS_ASSERTION(currentContent == oldContent, "How did that happen?");
FireChangeCallbacks(oldContent, aContent);
Element* oldElement =
static_cast<Element*>(mIdContentList.SafeElementAt(1));
NS_ASSERTION(currentElement == oldElement, "How did that happen?");
FireChangeCallbacks(oldElement, aElement);
}
return PR_TRUE;
}
PRBool
nsIdentifierMapEntry::RemoveIdContent(nsIContent* aContent)
nsIdentifierMapEntry::RemoveIdElement(Element* aElement)
{
// This should only be called while the document is in an update.
// Assertions near the call to this method guarantee this.
// XXXbz should this ever Compact() I guess when all the content is gone
// we'll just get cleaned up in the natural order of things...
nsIContent* currentContent = static_cast<nsIContent*>(mIdContentList.SafeElementAt(0));
if (!mIdContentList.RemoveElement(aContent))
Element* currentElement =
static_cast<Element*>(mIdContentList.SafeElementAt(0));
if (!mIdContentList.RemoveElement(aElement))
return PR_FALSE;
if (currentContent == aContent) {
FireChangeCallbacks(currentContent,
static_cast<nsIContent*>(mIdContentList.SafeElementAt(0)));
if (currentElement == aElement) {
FireChangeCallbacks(currentElement,
static_cast<Element*>(mIdContentList.SafeElementAt(0)));
}
// Make sure the release happens after the check above, since it'll
// null out aContent.
NS_RELEASE(aContent);
NS_RELEASE(aElement);
return mIdContentList.Count() == 0 && !mNameContentList && !mChangeCallbacks;
}
void
nsIdentifierMapEntry::AddNameContent(nsIContent* aContent)
nsIdentifierMapEntry::AddNameElement(Element* aElement)
{
if (!mNameContentList || mNameContentList == NAME_NOT_VALID)
return;
@ -413,16 +416,17 @@ nsIdentifierMapEntry::AddNameContent(nsIContent* aContent)
// content notifications when we do document.foo resolution. So
// aContent may be in our list already and just now getting notified
// for!
if (mNameContentList->IndexOf(aContent, PR_FALSE) < 0) {
mNameContentList->AppendElement(aContent);
// XXXbz with the HTML5 parser we can stop doing this!
if (mNameContentList->IndexOf(aElement, PR_FALSE) < 0) {
mNameContentList->AppendElement(aElement);
}
}
void
nsIdentifierMapEntry::RemoveNameContent(nsIContent* aContent)
nsIdentifierMapEntry::RemoveNameElement(Element* aElement)
{
if (mNameContentList && mNameContentList != NAME_NOT_VALID) {
mNameContentList->RemoveElement(aContent);
mNameContentList->RemoveElement(aElement);
}
}
@ -1457,7 +1461,7 @@ nsDocument::~nsDocument()
mChildren.ChildAt(indx)->UnbindFromTree();
mChildren.RemoveChildAt(indx);
}
mCachedRootContent = nsnull;
mCachedRootElement = nsnull;
// Let the stylesheets know we're going away
indx = mStyleSheets.Count();
@ -1647,7 +1651,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_USERDATA
// Traverse all nsIDocument pointer members.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCachedRootContent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCachedRootElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mNodeInfoManager,
nsNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSecurityInfo)
@ -1714,7 +1718,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
tmp->mChildren.RemoveChildAt(indx);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCachedRootContent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCachedRootElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDisplayDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstBaseNodeWithHref)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDOMImplementation)
@ -1806,7 +1810,7 @@ nsPropertyTable*
nsIDocument::GetExtraPropertyTable(PRUint16 aCategory)
{
NS_ASSERTION(aCategory > 0, "Category 0 should have already been handled");
while (aCategory - 1 >= mExtraPropertyTables.Length()) {
while (aCategory >= mExtraPropertyTables.Length() + 1) {
mExtraPropertyTables.AppendElement(new nsPropertyTable());
}
return mExtraPropertyTables[aCategory - 1];
@ -1902,7 +1906,7 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
content->UnbindFromTree();
}
}
mCachedRootContent = nsnull;
mCachedRootElement = nsnull;
// Reset our stylesheets
ResetStylesheetsToURI(aURI);
@ -2328,12 +2332,12 @@ nsDocument::GetLastModified(nsAString& aLastModified)
}
void
nsDocument::UpdateNameTableEntry(nsIContent *aContent)
nsDocument::UpdateNameTableEntry(Element *aElement)
{
if (!mIsRegularHTML)
return;
nsIAtom* name = nsContentUtils::IsNamedItem(aContent);
nsIAtom* name = nsContentUtils::IsNamedItem(aElement);
if (!name)
return;
@ -2343,16 +2347,16 @@ nsDocument::UpdateNameTableEntry(nsIContent *aContent)
return;
}
entry->AddNameContent(aContent);
entry->AddNameElement(aElement);
}
void
nsDocument::RemoveFromNameTable(nsIContent *aContent)
nsDocument::RemoveFromNameTable(Element *aElement)
{
if (!mIsRegularHTML)
return;
nsIAtom* name = nsContentUtils::IsNamedItem(aContent);
nsIAtom* name = nsContentUtils::IsNamedItem(aElement);
if (!name)
return;
@ -2362,27 +2366,27 @@ nsDocument::RemoveFromNameTable(nsIContent *aContent)
return;
}
entry->RemoveNameContent(aContent);
entry->RemoveNameElement(aElement);
}
void
nsDocument::UpdateIdTableEntry(nsIContent *aContent)
nsDocument::UpdateIdTableEntry(Element *aElement)
{
nsIAtom* id = aContent->GetID();
nsIAtom* id = aElement->GetID();
if (!id)
return;
nsIdentifierMapEntry *entry = mIdentifierMap.PutEntry(id);
if (entry) { /* True except on OOM */
entry->AddIdContent(aContent);
entry->AddIdElement(aElement);
}
}
void
nsDocument::RemoveFromIdTable(nsIContent *aContent)
nsDocument::RemoveFromIdTable(Element *aElement)
{
nsIAtom* id = aContent->GetID();
nsIAtom* id = aElement->GetID();
if (!id)
return;
@ -2390,7 +2394,7 @@ nsDocument::RemoveFromIdTable(nsIContent *aContent)
if (!entry) /* Should be false unless we had OOM when adding the entry */
return;
if (entry->RemoveIdContent(aContent)) {
if (entry->RemoveIdElement(aElement)) {
mIdentifierMap.RemoveEntry(id);
}
}
@ -2398,13 +2402,13 @@ nsDocument::RemoveFromIdTable(nsIContent *aContent)
void
nsDocument::UnregisterNamedItems(nsIContent *aContent)
{
if (!aContent->IsNodeOfType(nsINode::eELEMENT)) {
if (!aContent->IsElement()) {
// non-element nodes are not named items nor can they have children.
return;
}
RemoveFromNameTable(aContent);
RemoveFromIdTable(aContent);
RemoveFromNameTable(aContent->AsElement());
RemoveFromIdTable(aContent->AsElement());
for (nsINode::ChildIterator iter(aContent); !iter.IsDone(); iter.Next()) {
UnregisterNamedItems(iter);
@ -2414,13 +2418,13 @@ nsDocument::UnregisterNamedItems(nsIContent *aContent)
void
nsDocument::RegisterNamedItems(nsIContent *aContent)
{
if (!aContent->IsNodeOfType(nsINode::eELEMENT)) {
if (!aContent->IsElement()) {
// non-element nodes are not named items nor can they have children.
return;
}
UpdateNameTableEntry(aContent);
UpdateIdTableEntry(aContent);
UpdateNameTableEntry(aContent->AsElement());
UpdateIdTableEntry(aContent->AsElement());
for (nsINode::ChildIterator iter(aContent); !iter.IsDone(); iter.Next()) {
RegisterNamedItems(iter);
@ -2472,15 +2476,15 @@ nsDocument::AttributeWillChange(nsIDocument* aDocument,
nsIContent* aContent, PRInt32 aNameSpaceID,
nsIAtom* aAttribute, PRInt32 aModType)
{
NS_ABORT_IF_FALSE(aContent, "Null content!");
NS_ABORT_IF_FALSE(aContent && aContent->IsElement(), "Null content!");
NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!");
if (aNameSpaceID != kNameSpaceID_None)
return;
if (aAttribute == nsGkAtoms::name) {
RemoveFromNameTable(aContent);
RemoveFromNameTable(aContent->AsElement());
} else if (aAttribute == aContent->GetIDAttributeName()) {
RemoveFromIdTable(aContent);
RemoveFromIdTable(aContent->AsElement());
}
}
@ -2491,15 +2495,15 @@ nsDocument::AttributeChanged(nsIDocument* aDocument,
{
NS_ASSERTION(aDocument == this, "unexpected doc");
NS_ABORT_IF_FALSE(aContent, "Null content!");
NS_ABORT_IF_FALSE(aContent && aContent->IsElement(), "Null content!");
NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!");
if (aNameSpaceID != kNameSpaceID_None)
return;
if (aAttribute == nsGkAtoms::name) {
UpdateNameTableEntry(aContent);
UpdateNameTableEntry(aContent->AsElement());
} else if (aAttribute == aContent->GetIDAttributeName()) {
UpdateIdTableEntry(aContent);
UpdateIdTableEntry(aContent->AsElement());
}
}
@ -2705,7 +2709,7 @@ nsDocument::ElementFromPointHelper(float aX, float aY,
// or a node that isn't an element (such as a text frame node),
// replace it with the first non-anonymous parent node of type element.
while (ptContent &&
(!ptContent->IsNodeOfType(nsINode::eELEMENT) ||
(!ptContent->IsElement() ||
ptContent->IsInAnonymousSubtree())) {
// XXXldb: Faster to jump to GetBindingParent if non-null?
ptContent = ptContent->GetParent();
@ -2789,7 +2793,7 @@ nsDocument::NodesFromRectHelper(float aX, float aY,
// or a node that isn't an element or a text node,
// replace it with the first non-anonymous parent node.
while (ptContent &&
(!(ptContent->IsNodeOfType(nsINode::eELEMENT) ||
(!(ptContent->IsElement() ||
ptContent->IsNodeOfType(nsINode::eTEXT)) ||
ptContent->IsInAnonymousSubtree())) {
// XXXldb: Faster to jump to GetBindingParent if non-null?
@ -2940,7 +2944,7 @@ void
nsDocument::GetBaseTarget(nsAString &aBaseTarget)
{
aBaseTarget.Truncate();
nsIContent* head = GetHeadContent();
Element* head = GetHeadElement();
if (!head) {
return;
}
@ -3059,7 +3063,7 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAString& aData)
// Set the default script-type on the root element.
if (aHeaderField == nsGkAtoms::headerContentScriptType) {
nsIContent *root = GetRootContent();
Element *root = GetRootElement();
if (root) {
// Get the script-type ID for this value.
nsresult rv;
@ -3328,21 +3332,21 @@ nsDocument::IsNodeOfType(PRUint32 aFlags) const
return !(aFlags & ~eDOCUMENT);
}
nsIContent*
nsDocument::GetRootContentInternal() const
Element*
nsDocument::GetRootElementInternal() const
{
// Loop backwards because any non-elements, such as doctypes and PIs
// are likely to appear before the root element.
PRUint32 i;
for (i = mChildren.ChildCount(); i > 0; --i) {
nsIContent* child = mChildren.ChildAt(i - 1);
if (child->IsNodeOfType(nsINode::eELEMENT)) {
const_cast<nsDocument*>(this)->mCachedRootContent = child;
return child;
if (child->IsElement()) {
const_cast<nsDocument*>(this)->mCachedRootElement = child;
return child->AsElement();
}
}
const_cast<nsDocument*>(this)->mCachedRootContent = nsnull;
const_cast<nsDocument*>(this)->mCachedRootElement = nsnull;
return nsnull;
}
@ -3375,8 +3379,7 @@ nsresult
nsDocument::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify)
{
if (aKid->IsNodeOfType(nsINode::eELEMENT) &&
GetRootContent()) {
if (aKid->IsElement() && GetRootElement()) {
NS_ERROR("Inserting element child when we already have one");
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
}
@ -3405,7 +3408,7 @@ nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent
return NS_OK;
}
if (oldKid->IsNodeOfType(nsINode::eELEMENT)) {
if (oldKid->IsElement()) {
// Destroy the link map up front before we mess with the child list.
DestroyLinkMap();
}
@ -3413,7 +3416,7 @@ nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent
nsresult rv = nsGenericElement::doRemoveChildAt(aIndex, aNotify, oldKid,
nsnull, this, mChildren,
aMutationEvent);
mCachedRootContent = nsnull;
mCachedRootElement = nsnull;
return rv;
}
@ -3968,7 +3971,7 @@ nsDocument::GetElementByIdInternal(nsIAtom* aID)
nsIdentifierMapEntry *entry = mIdentifierMap.PutEntry(aID);
NS_ENSURE_TRUE(entry, nsnull);
if (entry->GetIdContent())
if (entry->GetIdElement())
return entry;
// Now we have to flush. It could be that we know nothing about this ID yet
@ -4006,7 +4009,7 @@ nsDocument::GetElementById(const nsAString& aElementId,
nsIdentifierMapEntry *entry = GetElementByIdInternal(idAtom);
NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
nsIContent *e = entry->GetIdContent();
Element *e = entry->GetIdElement();
if (!e)
return NS_OK;
@ -4024,7 +4027,7 @@ nsDocument::AddIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
NS_ENSURE_TRUE(entry, nsnull);
entry->AddContentChangeCallback(aObserver, aData);
return entry->GetIdContent();
return entry->GetIdElement();
}
void
@ -4048,6 +4051,7 @@ nsDocument::RemoveIDTargetObserver(nsIAtom* aID,
void
nsDocument::DispatchContentLoadedEvents()
{
NS_TIME_FUNCTION;
// If you add early returns from this method, make sure you're
// calling UnblockOnload properly.
@ -4126,7 +4130,7 @@ nsDocument::DispatchContentLoadedEvents()
// If the document has a manifest attribute, fire a MozApplicationManifest
// event.
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::manifest)) {
nsContentUtils::DispatchChromeEvent(this, static_cast<nsIDocument*>(this),
NS_LITERAL_STRING("MozApplicationManifest"),
@ -4253,7 +4257,7 @@ nsDocument::GetDocumentElement(nsIDOMElement** aDocumentElement)
{
NS_ENSURE_ARG_POINTER(aDocumentElement);
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (root) {
return CallQueryInterface(root, aDocumentElement);
}
@ -5012,20 +5016,20 @@ nsDocument::GetLocation(nsIDOMLocation **_retval)
return w->GetLocation(_retval);
}
nsIContent*
nsIDocument::GetHtmlContent()
Element*
nsIDocument::GetHtmlElement()
{
nsIContent* rootContent = GetRootContent();
if (rootContent && rootContent->Tag() == nsGkAtoms::html &&
rootContent->IsHTML())
return rootContent;
Element* rootElement = GetRootElement();
if (rootElement && rootElement->Tag() == nsGkAtoms::html &&
rootElement->IsHTML())
return rootElement;
return nsnull;
}
nsIContent*
nsIDocument::GetHtmlChildContent(nsIAtom* aTag)
Element*
nsIDocument::GetHtmlChildElement(nsIAtom* aTag)
{
nsIContent* html = GetHtmlContent();
Element* html = GetHtmlElement();
if (!html)
return nsnull;
@ -5034,7 +5038,7 @@ nsIDocument::GetHtmlChildContent(nsIAtom* aTag)
for (PRUint32 i = 0; i < html->GetChildCount(); ++i) {
nsIContent* result = html->GetChildAt(i);
if (result->Tag() == aTag && result->IsHTML())
return result;
return result->AsElement();
}
return nsnull;
}
@ -5072,21 +5076,21 @@ nsDocument::GetTitle(nsAString& aTitle)
{
aTitle.Truncate();
nsIContent *rootContent = GetRootContent();
if (!rootContent)
nsIContent *rootElement = GetRootElement();
if (!rootElement)
return NS_OK;
nsAutoString tmp;
switch (rootContent->GetNameSpaceID()) {
switch (rootElement->GetNameSpaceID()) {
#ifdef MOZ_XUL
case kNameSpaceID_XUL:
rootContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, tmp);
rootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::title, tmp);
break;
#endif
#ifdef MOZ_SVG
case kNameSpaceID_SVG:
if (rootContent->Tag() == nsGkAtoms::svg) {
if (rootElement->Tag() == nsGkAtoms::svg) {
GetTitleFromElement(kNameSpaceID_SVG, tmp);
break;
} // else fall through
@ -5104,18 +5108,18 @@ nsDocument::GetTitle(nsAString& aTitle)
NS_IMETHODIMP
nsDocument::SetTitle(const nsAString& aTitle)
{
nsIContent *rootContent = GetRootContent();
if (!rootContent)
Element *rootElement = GetRootElement();
if (!rootElement)
return NS_OK;
switch (rootContent->GetNameSpaceID()) {
switch (rootElement->GetNameSpaceID()) {
#ifdef MOZ_SVG
case kNameSpaceID_SVG:
return NS_OK; // SVG doesn't support setting a title
#endif
#ifdef MOZ_XUL
case kNameSpaceID_XUL:
return rootContent->SetAttr(kNameSpaceID_None, nsGkAtoms::title,
return rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::title,
aTitle, PR_TRUE);
#endif
}
@ -5126,7 +5130,7 @@ nsDocument::SetTitle(const nsAString& aTitle)
nsIContent* title = GetTitleContent(kNameSpaceID_XHTML);
if (!title) {
nsIContent *head = GetHeadContent();
Element *head = GetHeadElement();
if (!head)
return NS_OK;
@ -5848,7 +5852,7 @@ NS_IMETHODIMP
nsDocument::LookupPrefix(const nsAString& aNamespaceURI,
nsAString& aPrefix)
{
nsCOMPtr<nsIDOM3Node> root(do_QueryInterface(GetRootContent()));
nsCOMPtr<nsIDOM3Node> root(do_QueryInterface(GetRootElement()));
if (root) {
return root->LookupPrefix(aNamespaceURI, aPrefix);
}
@ -5861,7 +5865,7 @@ NS_IMETHODIMP
nsDocument::LookupNamespaceURI(const nsAString& aNamespacePrefix,
nsAString& aNamespaceURI)
{
if (NS_FAILED(nsContentUtils::LookupNamespaceURI(GetRootContent(),
if (NS_FAILED(nsContentUtils::LookupNamespaceURI(GetRootElement(),
aNamespacePrefix,
aNamespaceURI))) {
SetDOMStringToNull(aNamespaceURI);
@ -5986,7 +5990,7 @@ static void
BlastSubtreeToPieces(nsINode *aNode)
{
PRUint32 i, count;
if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
if (aNode->IsElement()) {
nsGenericElement *element = static_cast<nsGenericElement*>(aNode);
const nsDOMAttributeMap *map = element->GetAttributeMap();
if (map) {
@ -6248,8 +6252,8 @@ nsDocument::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
// Load events must not propagate to |window| object, see bug 335251.
if (aVisitor.mEvent->message != NS_LOAD) {
nsCOMPtr<nsPIDOMEventTarget> parentTarget = do_QueryInterface(GetWindow());
aVisitor.mParentTarget = parentTarget;
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(GetWindow());
aVisitor.mParentTarget = static_cast<nsPIDOMEventTarget*>(window);
}
return NS_OK;
}
@ -7368,7 +7372,7 @@ nsDocument::OnPageShow(PRBool aPersisted,
EnumerateFreezableElements(NotifyActivityChanged, nsnull);
EnumerateExternalResources(NotifyPageShow, &aPersisted);
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (aPersisted && root) {
// Send out notifications that our <link> elements are attached.
nsRefPtr<nsContentList> links = NS_GetContentList(root,
@ -7418,7 +7422,7 @@ nsDocument::OnPageHide(PRBool aPersisted,
{
// Send out notifications that our <link> elements are detached,
// but only if this is not a full unload.
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (aPersisted && root) {
nsRefPtr<nsContentList> links = NS_GetContentList(root,
nsGkAtoms::link,

View File

@ -164,8 +164,8 @@ public:
void SetInvalidName();
PRBool IsInvalidName();
void AddNameContent(nsIContent* aContent);
void RemoveNameContent(nsIContent* aContent);
void AddNameElement(mozilla::dom::Element* aElement);
void RemoveNameElement(mozilla::dom::Element* aElement);
PRBool HasNameContentList() {
return mNameContentList != nsnull;
}
@ -178,7 +178,7 @@ public:
* Returns the element if we know the element associated with this
* id. Otherwise returns null.
*/
nsIContent* GetIdContent();
mozilla::dom::Element* GetIdElement();
/**
* Append all the elements with this id to aElements
*/
@ -188,12 +188,12 @@ public:
* @return true if the content could be added, false if we failed due
* to OOM.
*/
PRBool AddIdContent(nsIContent* aContent);
PRBool AddIdElement(mozilla::dom::Element* aElement);
/**
* This can fire ID change callbacks.
* @return true if this map entry should be removed
*/
PRBool RemoveIdContent(nsIContent* aContent);
PRBool RemoveIdElement(mozilla::dom::Element* aElement);
PRBool HasContentChangeCallback() { return mChangeCallbacks != nsnull; }
void AddContentChangeCallback(nsIDocument::IDTargetObserver aCallback, void* aData);
@ -236,12 +236,14 @@ public:
};
private:
void FireChangeCallbacks(nsIContent* aOldContent, nsIContent* aNewContent);
void FireChangeCallbacks(mozilla::dom::Element* aOldElement,
mozilla::dom::Element* aNewElement);
// empty if there are no nodes with this ID.
// The content nodes are stored addrefed.
// empty if there are no elementswith this ID.
// The elementsnodes are stored addrefed.
nsSmallVoidArray mIdContentList;
// NAME_NOT_VALID if this id cannot be used as a 'name'
// NAME_NOT_VALID if this id cannot be used as a 'name'. Otherwise
// stores Elements.
nsBaseContentList *mNameContentList;
nsRefPtr<nsContentList> mDocAllList;
nsAutoPtr<nsTHashtable<ChangeCallbackEntry> > mChangeCallbacks;
@ -589,7 +591,7 @@ public:
nsIDocument* aSubDoc);
virtual nsIDocument* GetSubDocumentFor(nsIContent *aContent) const;
virtual nsIContent* FindContentForSubDocument(nsIDocument *aDocument) const;
virtual nsIContent* GetRootContentInternal() const;
virtual mozilla::dom::Element* GetRootElementInternal() const;
/**
* Get the style sheets owned by this document.
@ -946,10 +948,10 @@ protected:
friend class nsNodeUtils;
void RegisterNamedItems(nsIContent *aContent);
void UnregisterNamedItems(nsIContent *aContent);
void UpdateNameTableEntry(nsIContent *aContent);
void UpdateIdTableEntry(nsIContent *aContent);
void RemoveFromNameTable(nsIContent *aContent);
void RemoveFromIdTable(nsIContent *aContent);
void UpdateNameTableEntry(mozilla::dom::Element *aElement);
void UpdateIdTableEntry(mozilla::dom::Element *aElement);
void RemoveFromNameTable(mozilla::dom::Element *aElement);
void RemoveFromIdTable(mozilla::dom::Element *aElement);
/**
* Check that aId is not empty and log a message to the console

View File

@ -62,6 +62,7 @@
#include "nsIDOMProcessingInstruction.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMNodeList.h"
#include "nsIRange.h"
#include "nsIDOMRange.h"
#include "nsIDOMDocument.h"
#include "nsICharsetConverterManager.h"
@ -98,38 +99,38 @@ public:
protected:
void Initialize();
nsresult SerializeNodeStart(nsIDOMNode* aNode, PRInt32 aStartOffset,
nsresult SerializeNodeStart(nsINode* aNode, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr,
nsIDOMNode* aOriginalNode = nsnull);
nsresult SerializeToStringRecursive(nsIDOMNode* aNode,
nsINode* aOriginalNode = nsnull);
nsresult SerializeToStringRecursive(nsINode* aNode,
nsAString& aStr,
PRBool aDontSerializeRoot);
nsresult SerializeNodeEnd(nsIDOMNode* aNode, nsAString& aStr);
nsresult SerializeRangeToString(nsIDOMRange *aRange,
nsresult SerializeNodeEnd(nsINode* aNode, nsAString& aStr);
nsresult SerializeRangeToString(nsIRange *aRange,
nsAString& aOutputString);
nsresult SerializeRangeNodes(nsIDOMRange* aRange,
nsIDOMNode* aNode,
nsresult SerializeRangeNodes(nsIRange* aRange,
nsINode* aNode,
nsAString& aString,
PRInt32 aDepth);
nsresult SerializeRangeContextStart(const nsTArray<nsIDOMNode*>& aAncestorArray,
nsresult SerializeRangeContextStart(const nsTArray<nsINode*>& aAncestorArray,
nsAString& aString);
nsresult SerializeRangeContextEnd(const nsTArray<nsIDOMNode*>& aAncestorArray,
nsresult SerializeRangeContextEnd(const nsTArray<nsINode*>& aAncestorArray,
nsAString& aString);
nsresult FlushText(nsAString& aString, PRBool aForce);
static PRBool IsTag(nsIDOMNode* aNode, nsIAtom* aAtom);
static PRBool IsTag(nsIContent* aContent, nsIAtom* aAtom);
virtual PRBool IncludeInContext(nsIDOMNode *aNode);
virtual PRBool IncludeInContext(nsINode *aNode);
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsISelection> mSelection;
nsCOMPtr<nsIDOMRange> mRange;
nsCOMPtr<nsIDOMNode> mNode;
nsCOMPtr<nsIRange> mRange;
nsCOMPtr<nsINode> mNode;
nsCOMPtr<nsIOutputStream> mStream;
nsCOMPtr<nsIContentSerializer> mSerializer;
nsCOMPtr<nsIUnicodeEncoder> mUnicodeEncoder;
nsCOMPtr<nsIDOMNode> mCommonParent;
nsCOMPtr<nsINode> mCommonParent;
nsCOMPtr<nsIDocumentEncoderNodeFixup> mNodeFixup;
nsCOMPtr<nsICharsetConverterManager> mCharsetConverterManager;
@ -141,7 +142,7 @@ protected:
PRUint32 mEndDepth;
PRInt32 mStartRootIndex;
PRInt32 mEndRootIndex;
nsAutoTArray<nsIDOMNode*, 8> mCommonAncestors;
nsAutoTArray<nsINode*, 8> mCommonAncestors;
nsAutoTArray<nsIContent*, 8> mStartNodes;
nsAutoTArray<PRInt32, 8> mStartOffsets;
nsAutoTArray<nsIContent*, 8> mEndNodes;
@ -220,7 +221,7 @@ nsDocumentEncoder::SetSelection(nsISelection* aSelection)
NS_IMETHODIMP
nsDocumentEncoder::SetRange(nsIDOMRange* aRange)
{
mRange = aRange;
mRange = do_QueryInterface(aRange);
return NS_OK;
}
@ -228,7 +229,7 @@ NS_IMETHODIMP
nsDocumentEncoder::SetNode(nsIDOMNode* aNode)
{
mNodeIsContainer = PR_FALSE;
mNode = aNode;
mNode = do_QueryInterface(aNode);
return NS_OK;
}
@ -236,7 +237,7 @@ NS_IMETHODIMP
nsDocumentEncoder::SetContainerNode(nsIDOMNode *aContainer)
{
mNodeIsContainer = PR_TRUE;
mNode = aContainer;
mNode = do_QueryInterface(aContainer);
return NS_OK;
}
@ -256,28 +257,33 @@ nsDocumentEncoder::GetMimeType(nsAString& aMimeType)
PRBool
nsDocumentEncoder::IncludeInContext(nsIDOMNode *aNode)
nsDocumentEncoder::IncludeInContext(nsINode *aNode)
{
return PR_FALSE;
}
nsresult
nsDocumentEncoder::SerializeNodeStart(nsIDOMNode* aNode,
nsDocumentEncoder::SerializeNodeStart(nsINode* aNode,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr,
nsIDOMNode* aOriginalNode)
nsINode* aOriginalNode)
{
PRUint16 type;
nsCOMPtr<nsIDOMNode> node;
nsINode* node = nsnull;
nsCOMPtr<nsINode> fixedNodeKungfuDeathGrip;
// Caller didn't do fixup, so we'll do it ourselves
if (!aOriginalNode) {
aOriginalNode = aNode;
if (mNodeFixup) {
PRBool dummy;
mNodeFixup->FixupNode(aNode, &dummy, getter_AddRefs(node));
nsCOMPtr<nsIDOMNode> domNodeIn = do_QueryInterface(aNode);
nsCOMPtr<nsIDOMNode> domNodeOut;
mNodeFixup->FixupNode(domNodeIn, &dummy, getter_AddRefs(domNodeOut));
fixedNodeKungfuDeathGrip = do_QueryInterface(domNodeOut);
node = fixedNodeKungfuDeathGrip;
}
}
@ -290,85 +296,82 @@ nsDocumentEncoder::SerializeNodeStart(nsIDOMNode* aNode,
switch (type) {
case nsIDOMNode::ELEMENT_NODE:
{
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(node);
nsCOMPtr<nsIDOMElement> originalElement = do_QueryInterface(aOriginalNode);
mSerializer->AppendElementStart(element, originalElement, aStr);
nsIContent* originalElement =
aOriginalNode && aOriginalNode->IsElement() ?
static_cast<nsIContent*>(aOriginalNode) : nsnull;
mSerializer->AppendElementStart(static_cast<nsIContent*>(node),
originalElement, aStr);
break;
}
case nsIDOMNode::TEXT_NODE:
{
nsCOMPtr<nsIDOMText> text = do_QueryInterface(node);
mSerializer->AppendText(text, aStartOffset, aEndOffset, aStr);
mSerializer->AppendText(static_cast<nsIContent*>(node),
aStartOffset, aEndOffset, aStr);
break;
}
case nsIDOMNode::CDATA_SECTION_NODE:
{
nsCOMPtr<nsIDOMCDATASection> cdata = do_QueryInterface(node);
mSerializer->AppendCDATASection(cdata, aStartOffset, aEndOffset, aStr);
mSerializer->AppendCDATASection(static_cast<nsIContent*>(node),
aStartOffset, aEndOffset, aStr);
break;
}
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
{
nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(node);
mSerializer->AppendProcessingInstruction(pi, aStartOffset, aEndOffset,
aStr);
mSerializer->AppendProcessingInstruction(static_cast<nsIContent*>(node),
aStartOffset, aEndOffset, aStr);
break;
}
case nsIDOMNode::COMMENT_NODE:
{
nsCOMPtr<nsIDOMComment> comment = do_QueryInterface(node);
mSerializer->AppendComment(comment, aStartOffset, aEndOffset, aStr);
mSerializer->AppendComment(static_cast<nsIContent*>(node),
aStartOffset, aEndOffset, aStr);
break;
}
case nsIDOMNode::DOCUMENT_TYPE_NODE:
{
nsCOMPtr<nsIDOMDocumentType> doctype = do_QueryInterface(node);
mSerializer->AppendDoctype(doctype, aStr);
mSerializer->AppendDoctype(static_cast<nsIContent*>(node), aStr);
break;
}
}
return NS_OK;
}
nsresult
nsDocumentEncoder::SerializeNodeEnd(nsIDOMNode* aNode,
nsDocumentEncoder::SerializeNodeEnd(nsINode* aNode,
nsAString& aStr)
{
PRUint16 type;
aNode->GetNodeType(&type);
switch (type) {
case nsIDOMNode::ELEMENT_NODE:
{
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
mSerializer->AppendElementEnd(element, aStr);
break;
}
if (aNode->IsElement()) {
mSerializer->AppendElementEnd(static_cast<nsIContent*>(aNode), aStr);
}
return NS_OK;
}
nsresult
nsDocumentEncoder::SerializeToStringRecursive(nsIDOMNode* aNode,
nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
nsAString& aStr,
PRBool aDontSerializeRoot)
{
nsresult rv = NS_OK;
PRBool serializeClonedChildren = PR_FALSE;
nsCOMPtr<nsIDOMNode> maybeFixedNode;
if (mNodeFixup)
mNodeFixup->FixupNode(aNode, &serializeClonedChildren, getter_AddRefs(maybeFixedNode));
nsINode* maybeFixedNode = nsnull;
// Keep the node from FixupNode alive.
nsCOMPtr<nsINode> fixedNodeKungfuDeathGrip;
if (mNodeFixup) {
nsCOMPtr<nsIDOMNode> domNodeIn = do_QueryInterface(aNode);
nsCOMPtr<nsIDOMNode> domNodeOut;
mNodeFixup->FixupNode(domNodeIn, &serializeClonedChildren, getter_AddRefs(domNodeOut));
fixedNodeKungfuDeathGrip = do_QueryInterface(domNodeOut);
maybeFixedNode = fixedNodeKungfuDeathGrip;
}
if (!maybeFixedNode)
maybeFixedNode = aNode;
if (mIsCopying) {
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content){
nsIFrame* frame = content->GetPrimaryFrame();
if (aNode->IsNodeOfType(nsINode::eCONTENT)) {
nsIFrame* frame = static_cast<nsIContent*>(aNode)->GetPrimaryFrame();
if (frame) {
PRBool isSelectable;
frame->IsSelectable(&isSelectable, nsnull);
@ -384,32 +387,11 @@ nsDocumentEncoder::SerializeToStringRecursive(nsIDOMNode* aNode,
NS_ENSURE_SUCCESS(rv, rv);
}
nsIDOMNode *node;
if (serializeClonedChildren)
node = maybeFixedNode;
else
node = aNode;
nsINode* node = serializeClonedChildren ? maybeFixedNode : aNode;
PRBool hasChildren = PR_FALSE;
node->HasChildNodes(&hasChildren);
if (hasChildren) {
nsCOMPtr<nsIDOMNodeList> childNodes;
rv = node->GetChildNodes(getter_AddRefs(childNodes));
NS_ENSURE_TRUE(childNodes, NS_SUCCEEDED(rv) ? NS_ERROR_FAILURE : rv);
PRInt32 index, count;
childNodes->GetLength((PRUint32*)&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> child;
rv = childNodes->Item(index, getter_AddRefs(child));
NS_ENSURE_SUCCESS(rv, rv);
rv = SerializeToStringRecursive(child, aStr, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
}
for (nsINode::ChildIterator iter(node); !iter.IsDone(); iter.Next()) {
rv = SerializeToStringRecursive(iter, aStr, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
}
if (!aDontSerializeRoot) {
@ -421,10 +403,9 @@ nsDocumentEncoder::SerializeToStringRecursive(nsIDOMNode* aNode,
}
PRBool
nsDocumentEncoder::IsTag(nsIDOMNode* aNode, nsIAtom* aAtom)
nsDocumentEncoder::IsTag(nsIContent* aContent, nsIAtom* aAtom)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
return content && content->Tag() == aAtom;
return aContent && aContent->Tag() == aAtom;
}
static nsresult
@ -635,15 +616,9 @@ static nsresult GetNextNode(nsIDOMNode* aNode, nsTArray<PRInt32>& aIndexArray,
}
#endif
static PRBool IsTextNode(nsIDOMNode *aNode)
static PRBool IsTextNode(nsINode *aNode)
{
if (!aNode) return PR_FALSE;
PRUint16 nodeType;
aNode->GetNodeType(&nodeType);
if (nodeType == nsIDOMNode::TEXT_NODE ||
nodeType == nsIDOMNode::CDATA_SECTION_NODE)
return PR_TRUE;
return PR_FALSE;
return aNode && aNode->IsNodeOfType(nsINode::eTEXT);
}
static nsresult GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount)
@ -673,8 +648,8 @@ static nsresult GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount)
}
nsresult
nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
nsIDOMNode* aNode,
nsDocumentEncoder::SerializeRangeNodes(nsIRange* aRange,
nsINode* aNode,
nsAString& aString,
PRInt32 aDepth)
{
@ -704,19 +679,18 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
{
// due to implementation it is impossible for text node to be both start and end of
// range. We would have handled that case without getting here.
//XXXsmaug What does this all mean?
if (IsTextNode(aNode))
{
if (startNode == content)
{
PRInt32 startOffset;
aRange->GetStartOffset(&startOffset);
PRInt32 startOffset = aRange->StartOffset();
rv = SerializeNodeStart(aNode, startOffset, -1, aString);
NS_ENSURE_SUCCESS(rv, rv);
}
else
{
PRInt32 endOffset;
aRange->GetEndOffset(&endOffset);
PRInt32 endOffset = aRange->EndOffset();
rv = SerializeNodeStart(aNode, 0, endOffset, aString);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -741,7 +715,7 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
// do some calculations that will tell us which children of this
// node are in the range.
nsCOMPtr<nsIDOMNode> childAsNode;
nsIContent* childAsNode = nsnull;
PRInt32 startOffset = 0, endOffset = -1;
if (startNode == content && mStartRootIndex >= aDepth)
startOffset = mStartOffsets[mStartRootIndex - aDepth];
@ -761,9 +735,7 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
// intermediate points on the list use the endOffset of the
// location of the ancestor, rather than just past it. So we need
// to add one here in order to include it in the children we serialize.
nsCOMPtr<nsIDOMNode> endParent;
aRange->GetEndContainer(getter_AddRefs(endParent));
if (aNode != endParent)
if (aNode != aRange->GetEndParent())
{
endOffset++;
}
@ -771,7 +743,7 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
// serialize the children of this node that are in the range
for (j=startOffset; j<endOffset; j++)
{
childAsNode = do_QueryInterface(content->GetChildAt(j));
childAsNode = content->GetChildAt(j);
if ((j==startOffset) || (j==endOffset-1))
rv = SerializeRangeNodes(aRange, childAsNode, aString, aDepth+1);
@ -793,14 +765,14 @@ nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,
}
nsresult
nsDocumentEncoder::SerializeRangeContextStart(const nsTArray<nsIDOMNode*>& aAncestorArray,
nsDocumentEncoder::SerializeRangeContextStart(const nsTArray<nsINode*>& aAncestorArray,
nsAString& aString)
{
PRInt32 i = aAncestorArray.Length();
nsresult rv = NS_OK;
while (i > 0) {
nsIDOMNode *node = aAncestorArray.ElementAt(--i);
nsINode *node = aAncestorArray.ElementAt(--i);
if (!node)
break;
@ -817,7 +789,7 @@ nsDocumentEncoder::SerializeRangeContextStart(const nsTArray<nsIDOMNode*>& aAnce
}
nsresult
nsDocumentEncoder::SerializeRangeContextEnd(const nsTArray<nsIDOMNode*>& aAncestorArray,
nsDocumentEncoder::SerializeRangeContextEnd(const nsTArray<nsINode*>& aAncestorArray,
nsAString& aString)
{
PRInt32 i = 0;
@ -825,7 +797,7 @@ nsDocumentEncoder::SerializeRangeContextEnd(const nsTArray<nsIDOMNode*>& aAncest
nsresult rv = NS_OK;
while (i < count) {
nsIDOMNode *node = aAncestorArray.ElementAt(i++);
nsINode *node = aAncestorArray.ElementAt(i++);
if (!node)
break;
@ -842,34 +814,24 @@ nsDocumentEncoder::SerializeRangeContextEnd(const nsTArray<nsIDOMNode*>& aAncest
}
nsresult
nsDocumentEncoder::SerializeRangeToString(nsIDOMRange *aRange,
nsDocumentEncoder::SerializeRangeToString(nsIRange *aRange,
nsAString& aOutputString)
{
if (!aRange)
if (!aRange || aRange->Collapsed())
return NS_OK;
PRBool collapsed;
aRange->GetCollapsed(&collapsed);
if (collapsed)
return NS_OK;
nsCOMPtr<nsIDOMNode> startParent, endParent;
PRInt32 startOffset, endOffset;
aRange->GetCommonAncestorContainer(getter_AddRefs(mCommonParent));
mCommonParent = aRange->GetCommonAncestor();
if (!mCommonParent)
return NS_OK;
aRange->GetStartContainer(getter_AddRefs(startParent));
nsINode* startParent = aRange->GetStartParent();
NS_ENSURE_TRUE(startParent, NS_ERROR_FAILURE);
aRange->GetStartOffset(&startOffset);
PRInt32 startOffset = aRange->StartOffset();
aRange->GetEndContainer(getter_AddRefs(endParent));
nsINode* endParent = aRange->GetEndParent();
NS_ENSURE_TRUE(endParent, NS_ERROR_FAILURE);
aRange->GetEndOffset(&endOffset);
PRInt32 endOffset = aRange->EndOffset();
mCommonAncestors.Clear();
mStartNodes.Clear();
@ -877,10 +839,12 @@ nsDocumentEncoder::SerializeRangeToString(nsIDOMRange *aRange,
mEndNodes.Clear();
mEndOffsets.Clear();
nsContentUtils::GetAncestors(mCommonParent, &mCommonAncestors);
nsContentUtils::GetAncestorsAndOffsets(startParent, startOffset,
nsContentUtils::GetAncestors(mCommonParent, mCommonAncestors);
nsCOMPtr<nsIDOMNode> sp = do_QueryInterface(startParent);
nsContentUtils::GetAncestorsAndOffsets(sp, startOffset,
&mStartNodes, &mStartOffsets);
nsContentUtils::GetAncestorsAndOffsets(endParent, endOffset,
nsCOMPtr<nsIDOMNode> ep = do_QueryInterface(endParent);
nsContentUtils::GetAncestorsAndOffsets(ep, endOffset,
&mEndNodes, &mEndOffsets);
nsCOMPtr<nsIContent> commonContent = do_QueryInterface(mCommonParent);
@ -953,23 +917,27 @@ nsDocumentEncoder::EncodeToString(nsAString& aOutputString)
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
if (node != prevNode) {
if (prevNode) {
rv = SerializeNodeEnd(prevNode, aOutputString);
nsCOMPtr<nsINode> p = do_QueryInterface(prevNode);
rv = SerializeNodeEnd(p, aOutputString);
NS_ENSURE_SUCCESS(rv, rv);
prevNode = nsnull;
}
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
if (content && content->Tag() == nsGkAtoms::tr) {
rv = SerializeNodeStart(node, 0, -1, aOutputString);
nsCOMPtr<nsINode> n = do_QueryInterface(node);
rv = SerializeNodeStart(n, 0, -1, aOutputString);
NS_ENSURE_SUCCESS(rv, rv);
prevNode = node;
}
}
rv = SerializeRangeToString(range, aOutputString);
nsCOMPtr<nsIRange> r = do_QueryInterface(range);
rv = SerializeRangeToString(r, aOutputString);
NS_ENSURE_SUCCESS(rv, rv);
}
if (prevNode) {
rv = SerializeNodeEnd(prevNode, aOutputString);
nsCOMPtr<nsINode> p = do_QueryInterface(prevNode);
rv = SerializeNodeEnd(p, aOutputString);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -982,13 +950,10 @@ nsDocumentEncoder::EncodeToString(nsAString& aOutputString)
rv = SerializeToStringRecursive(mNode, aOutputString, mNodeIsContainer);
mNode = nsnull;
} else {
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));
rv = mSerializer->AppendDocumentStart(domdoc, aOutputString);
rv = mSerializer->AppendDocumentStart(mDocument, aOutputString);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMNode> doc(do_QueryInterface(mDocument));
rv = SerializeToStringRecursive(doc, aOutputString, PR_FALSE);
rv = SerializeToStringRecursive(mDocument, aOutputString, PR_FALSE);
}
}
@ -1099,7 +1064,7 @@ protected:
PRBool IsFirstNode(nsIDOMNode *aNode);
PRBool IsLastNode(nsIDOMNode *aNode);
PRBool IsEmptyTextContent(nsIDOMNode* aNode);
virtual PRBool IncludeInContext(nsIDOMNode *aNode);
virtual PRBool IncludeInContext(nsINode *aNode);
PRBool mIsTextWidget;
};
@ -1274,7 +1239,7 @@ nsHTMLCopyEncoder::EncodeToStringWithContext(nsAString& aContextString,
// leaf of ancestors might be text node. If so discard it.
PRInt32 count = mCommonAncestors.Length();
PRInt32 i;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsINode> node;
if (count > 0)
node = mCommonAncestors.ElementAt(0);
@ -1315,7 +1280,7 @@ nsHTMLCopyEncoder::EncodeToStringWithContext(nsAString& aContextString,
PRBool
nsHTMLCopyEncoder::IncludeInContext(nsIDOMNode *aNode)
nsHTMLCopyEncoder::IncludeInContext(nsINode *aNode)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
@ -1471,7 +1436,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32
if (aWhere == kStart)
{
// some special casing for text nodes
if (IsTextNode(aNode))
nsCOMPtr<nsINode> t = do_QueryInterface(aNode);
if (IsTextNode(t))
{
// if not at beginning of text node, we are done
if (offset > 0)
@ -1551,7 +1517,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32
if (aWhere == kEnd)
{
// some special casing for text nodes
if (IsTextNode(aNode))
nsCOMPtr<nsINode> n = do_QueryInterface(aNode);
if (IsTextNode(n))
{
// if not at end of text node, we are done
PRUint32 len;
@ -1653,7 +1620,8 @@ nsHTMLCopyEncoder::GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset)
PRBool
nsHTMLCopyEncoder::IsMozBR(nsIDOMNode* aNode)
{
if (IsTag(aNode, nsGkAtoms::br))
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (IsTag(content, nsGkAtoms::br))
{
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(aNode);
if (elem)
@ -1696,14 +1664,15 @@ nsHTMLCopyEncoder::GetNodeLocation(nsIDOMNode *inChild,
PRBool
nsHTMLCopyEncoder::IsRoot(nsIDOMNode* aNode)
{
if (aNode)
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content)
{
if (mIsTextWidget)
return (IsTag(aNode, nsGkAtoms::div));
else
return (IsTag(aNode, nsGkAtoms::body) ||
IsTag(aNode, nsGkAtoms::td) ||
IsTag(aNode, nsGkAtoms::th));
return (IsTag(content, nsGkAtoms::div));
return (IsTag(content, nsGkAtoms::body) ||
IsTag(content, nsGkAtoms::td) ||
IsTag(content, nsGkAtoms::th));
}
return PR_FALSE;
}

View File

@ -182,6 +182,7 @@ NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
nsDocumentFragment::nsDocumentFragment(nsINodeInfo *aNodeInfo)
: nsGenericElement(aNodeInfo)
{
UnsetFlags(NODE_IS_ELEMENT);
}
nsDocumentFragment::~nsDocumentFragment()

View File

@ -110,37 +110,20 @@ public:
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
nsIDOMNode** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
return ReplaceOrInsertBefore(PR_FALSE, aNewChild, aRefChild, aReturn);
}
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
nsIDOMNode** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
/*
* Data nodes can't have children.
*/
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
return ReplaceOrInsertBefore(PR_TRUE, aNewChild, aOldChild, aReturn);
}
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
/*
* Data nodes can't have children, i.e. aOldChild can't be a child of
* this node.
*/
return NS_ERROR_DOM_NOT_FOUND_ERR;
return nsINode::RemoveChild(aOldChild, aReturn);
}
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
return InsertBefore(aNewChild, nsnull, aReturn);
}
nsresult GetNamespaceURI(nsAString& aNamespaceURI);
nsresult GetLocalName(nsAString& aLocalName);

View File

@ -125,6 +125,7 @@
#include "nsIDOMUserDataHandler.h"
#include "nsGenericHTMLElement.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsIEditorDocShell.h"
#include "nsEventDispatcher.h"
#include "nsContentCreatorFunctions.h"
@ -158,19 +159,7 @@
#include "nsSVGFeatures.h"
#endif /* MOZ_SVG */
#ifdef DEBUG_waterson
/**
* List a content tree to stdout. Meant to be called from gdb.
*/
void
DebugListContentTree(nsIContent* aElement)
{
aElement->List(stdout, 0);
printf("\n");
}
#endif
using namespace mozilla::dom;
NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
@ -339,8 +328,8 @@ nsINode::GetTextEditorRootContent(nsIEditor** aEditor)
if (aEditor)
*aEditor = nsnull;
for (nsINode* node = this; node; node = node->GetNodeParent()) {
if (!node->IsNodeOfType(eELEMENT) ||
!static_cast<nsIContent*>(node)->IsHTML())
if (!node->IsElement() ||
!node->AsElement()->IsHTML())
continue;
nsCOMPtr<nsIEditor> editor;
@ -391,7 +380,7 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell)
NS_ENSURE_TRUE(aPresShell, nsnull);
if (IsNodeOfType(eDOCUMENT))
return static_cast<nsIDocument*>(this)->GetRootContent();
return static_cast<nsIDocument*>(this)->GetRootElement();
if (!IsNodeOfType(eCONTENT))
return nsnull;
@ -440,7 +429,7 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell)
if (!content) {
nsIDocument* doc = aPresShell->GetDocument();
NS_ENSURE_TRUE(doc, nsnull);
content = doc->GetRootContent();
content = doc->GetRootElement();
if (!content)
return nsnull;
}
@ -648,6 +637,47 @@ nsIContent::GetFlattenedTreeParent() const
return parent;
}
PRUint32
nsIContent::GetDesiredIMEState()
{
if (!IsEditableInternal()) {
return IME_STATUS_DISABLE;
}
nsIContent *editableAncestor = nsnull;
for (nsIContent* parent = GetParent();
parent && parent->HasFlag(NODE_IS_EDITABLE);
parent = parent->GetParent()) {
editableAncestor = parent;
}
// This is in another editable content, use the result of it.
if (editableAncestor) {
return editableAncestor->GetDesiredIMEState();
}
nsIDocument* doc = GetCurrentDoc();
if (!doc) {
return IME_STATUS_DISABLE;
}
nsIPresShell* ps = doc->GetPrimaryShell();
if (!ps) {
return IME_STATUS_DISABLE;
}
nsPresContext* pc = ps->GetPresContext();
if (!pc) {
return IME_STATUS_DISABLE;
}
nsIEditor* editor = GetHTMLEditor(pc);
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(editor);
if (!imeEditor) {
return IME_STATUS_DISABLE;
}
// Use "enable" for the default value because IME is disabled unexpectedly,
// it makes serious a11y problem.
PRUint32 state = IME_STATUS_ENABLE;
nsresult rv = imeEditor->GetPreferredIMEState(&state);
NS_ENSURE_SUCCESS(rv, IME_STATUS_ENABLE);
return state;
}
//----------------------------------------------------------------------
NS_IMPL_ADDREF(nsChildContentList)
@ -853,28 +883,46 @@ nsNode3Tearoff::AreNodesEqual(nsIContent* aContent1,
}
}
if (aContent1->IsNodeOfType(nsINode::eELEMENT)) {
// aContent1 is an element. Do the check on attributes.
PRUint32 attrCount = aContent1->GetAttrCount();
if (attrCount != aContent2->GetAttrCount()) {
if (aContent1->IsElement()) {
// aContent1 is an element. So is aContent2, since the nodeinfos
// were equal. Do the check on attributes.
Element* element1 = aContent1->AsElement();
Element* element2 = aContent2->AsElement();
PRUint32 attrCount = element1->GetAttrCount();
if (attrCount != element2->GetAttrCount()) {
return PR_FALSE;
}
// Iterate over attributes.
for (PRUint32 i = 0; i < attrCount; ++i) {
const nsAttrName* attrName1 = aContent1->GetAttrNameAt(i);
const nsAttrName* attrName1 = element1->GetAttrNameAt(i);
#ifdef DEBUG
PRBool hasAttr =
#endif
aContent1->GetAttr(attrName1->NamespaceID(),
attrName1->LocalName(),
string1);
element1->GetAttr(attrName1->NamespaceID(),
attrName1->LocalName(),
string1);
NS_ASSERTION(hasAttr, "Why don't we have an attr?");
if (!aContent2->AttrValueIs(attrName1->NamespaceID(),
attrName1->LocalName(),
string1,
eCaseMatters)) {
if (!element2->AttrValueIs(attrName1->NamespaceID(),
attrName1->LocalName(),
string1,
eCaseMatters)) {
return PR_FALSE;
}
}
// Child nodes count.
PRUint32 childCount = element1->GetChildCount();
if (childCount != element2->GetChildCount()) {
return PR_FALSE;
}
// Iterate over child nodes.
for (PRUint32 i = 0; i < childCount; ++i) {
nsIContent* child1 = element1->GetChildAt(i);
nsIContent* child2 = element2->GetChildAt(i);
if (!AreNodesEqual(child1, child2)) {
return PR_FALSE;
}
}
@ -890,21 +938,6 @@ nsNode3Tearoff::AreNodesEqual(nsIContent* aContent1,
}
}
// Child nodes count.
PRUint32 childCount = aContent1->GetChildCount();
if (childCount != aContent2->GetChildCount()) {
return PR_FALSE;
}
// Iterate over child nodes.
for (PRUint32 i = 0; i < childCount; ++i) {
nsIContent* child1 = aContent1->GetChildAt(i);
nsIContent* child2 = aContent2->GetChildAt(i);
if (!AreNodesEqual(child1, child2)) {
return PR_FALSE;
}
}
return PR_TRUE;
}
@ -1018,7 +1051,7 @@ nsNSElementTearoff::GetFirstElementChild(nsIDOMElement** aResult)
PRUint32 i, count = children.ChildCount();
for (i = 0; i < count; ++i) {
nsIContent* child = children.ChildAt(i);
if (child->IsNodeOfType(nsINode::eELEMENT)) {
if (child->IsElement()) {
return CallQueryInterface(child, aResult);
}
}
@ -1035,7 +1068,7 @@ nsNSElementTearoff::GetLastElementChild(nsIDOMElement** aResult)
PRUint32 i = children.ChildCount();
while (i > 0) {
nsIContent* child = children.ChildAt(--i);
if (child->IsNodeOfType(nsINode::eELEMENT)) {
if (child->IsElement()) {
return CallQueryInterface(child, aResult);
}
}
@ -1053,7 +1086,7 @@ nsNSElementTearoff::GetPreviousElementSibling(nsIDOMElement** aResult)
return NS_OK;
}
NS_ASSERTION(parent->IsNodeOfType(nsINode::eELEMENT) ||
NS_ASSERTION(parent->IsElement() ||
parent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT),
"Parent content must be an element or a doc fragment");
@ -1067,7 +1100,7 @@ nsNSElementTearoff::GetPreviousElementSibling(nsIDOMElement** aResult)
PRUint32 i = index;
while (i > 0) {
nsIContent* child = children.ChildAt((PRUint32)--i);
if (child->IsNodeOfType(nsINode::eELEMENT)) {
if (child->IsElement()) {
return CallQueryInterface(child, aResult);
}
}
@ -1085,7 +1118,7 @@ nsNSElementTearoff::GetNextElementSibling(nsIDOMElement** aResult)
return NS_OK;
}
NS_ASSERTION(parent->IsNodeOfType(nsINode::eELEMENT) ||
NS_ASSERTION(parent->IsElement() ||
parent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT),
"Parent content must be an element or a doc fragment");
@ -1099,7 +1132,7 @@ nsNSElementTearoff::GetNextElementSibling(nsIDOMElement** aResult)
PRUint32 i, count = children.ChildCount();
for (i = (PRUint32)index + 1; i < count; ++i) {
nsIContent* child = children.ChildAt(i);
if (child->IsNodeOfType(nsINode::eELEMENT)) {
if (child->IsElement()) {
return CallQueryInterface(child, aResult);
}
}
@ -1272,8 +1305,8 @@ nsNSElementTearoff::GetScrollFrame(nsIFrame **aStyledFrame)
nsIDocument* doc = mContent->GetOwnerDoc();
PRBool quirksMode = doc->GetCompatibilityMode() == eCompatibility_NavQuirks;
nsIContent* elementWithRootScrollInfo =
quirksMode ? doc->GetBodyContent() : doc->GetRootContent();
Element* elementWithRootScrollInfo =
quirksMode ? doc->GetBodyElement() : doc->GetRootElement();
if (mContent == elementWithRootScrollInfo) {
// In quirks mode, the scroll info for the body element should map to the
// root scrollable frame.
@ -1786,11 +1819,12 @@ nsGenericElement::nsDOMSlots::~nsDOMSlots()
}
nsGenericElement::nsGenericElement(nsINodeInfo *aNodeInfo)
: nsIContent(aNodeInfo)
: Element(aNodeInfo)
{
// Set the default scriptID to JS - but skip SetScriptTypeID as it
// does extra work we know isn't necessary here...
SetFlags(nsIProgrammingLanguage::JAVASCRIPT << NODE_SCRIPT_TYPE_OFFSET);
SetFlags(NODE_IS_ELEMENT |
(nsIProgrammingLanguage::JAVASCRIPT << NODE_SCRIPT_TYPE_OFFSET));
}
nsGenericElement::~nsGenericElement()
@ -3250,7 +3284,7 @@ nsGenericElement::GetBindingParent() const
PRBool
nsGenericElement::IsNodeOfType(PRUint32 aFlags) const
{
return !(aFlags & ~(eCONTENT | eELEMENT));
return !(aFlags & ~eCONTENT);
}
//----------------------------------------------------------------------
@ -3588,7 +3622,7 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
"Must have ref content for replace");
NS_PRECONDITION(aParent->IsNodeOfType(nsINode::eDOCUMENT) ||
aParent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT) ||
aParent->IsNodeOfType(nsINode::eELEMENT),
aParent->IsElement(),
"Nodes that are not documents, document fragments or "
"elements can't be parents!");
#ifdef DEBUG
@ -3622,12 +3656,12 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
return PR_TRUE;
}
nsIContent* rootContent =
static_cast<nsIDocument*>(aParent)->GetRootContent();
if (rootContent) {
Element* rootElement =
static_cast<nsIDocument*>(aParent)->GetRootElement();
if (rootElement) {
// Already have a documentElement, so this is only OK if we're
// replacing it.
return aIsReplace && rootContent == aRefContent;
return aIsReplace && rootElement == aRefContent;
}
// We don't have a documentElement yet. Our one remaining constraint is
@ -3677,9 +3711,9 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
// We don't have a doctype yet. Our one remaining constraint is
// that the doctype must come before the documentElement.
nsIContent* rootContent =
static_cast<nsIDocument*>(aParent)->GetRootContent();
if (!rootContent) {
Element* rootElement =
static_cast<nsIDocument*>(aParent)->GetRootElement();
if (!rootElement) {
// It's all good
return PR_TRUE;
}
@ -3689,12 +3723,12 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
return PR_FALSE;
}
PRInt32 rootIndex = aParent->IndexOf(rootContent);
PRInt32 rootIndex = aParent->IndexOf(rootElement);
PRInt32 insertIndex = aParent->IndexOf(aRefContent);
// Now we're OK if and only if insertIndex <= rootIndex. Indeed, either
// we end up replacing aRefContent or we end up before it. Either one is
// ok as long as aRefContent is not after rootContent.
// ok as long as aRefContent is not after rootElement.
return insertIndex <= rootIndex;
}
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE :
@ -3712,7 +3746,7 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
for (PRUint32 index = 0; index < count; ++index) {
nsIContent* childContent = aNewChild->GetChildAt(index);
NS_ASSERTION(childContent, "Something went wrong");
if (childContent->IsNodeOfType(nsINode::eELEMENT)) {
if (childContent->IsElement()) {
if (sawElement) {
// Can't put two elements into a document
return PR_FALSE;
@ -3743,6 +3777,28 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
return PR_FALSE;
}
void
nsGenericElement::FireNodeInserted(nsIDocument* aDoc,
nsINode* aParent,
nsCOMArray<nsIContent>& aNodes)
{
PRInt32 count = aNodes.Count();
for (PRInt32 i = 0; i < count; ++i) {
nsIContent* childContent = aNodes[i];
if (nsContentUtils::HasMutationListeners(childContent,
NS_EVENT_BITS_MUTATION_NODEINSERTED, aParent)) {
mozAutoRemovableBlockerRemover blockerRemover(aDoc);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED);
mutation.mRelatedNode = do_QueryInterface(aParent);
mozAutoSubtreeModified subtree(aDoc, aParent);
nsEventDispatcher::Dispatch(childContent, nsnull, &mutation);
}
}
}
nsresult
nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
nsINode* aRefChild)
@ -3751,6 +3807,14 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
return NS_ERROR_NULL_POINTER;
}
if (IsNodeOfType(eDATA_NODE)) {
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
}
if (IsNodeOfType(eATTRIBUTE)) {
return NS_ERROR_NOT_IMPLEMENTED;
}
nsIContent* refContent;
nsresult res = NS_OK;
PRInt32 insPos;
@ -3911,7 +3975,8 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
}
}
PRBool appending = !IsNodeOfType(eDOCUMENT) && insPos == GetChildCount();
PRBool appending =
!IsNodeOfType(eDOCUMENT) && PRUint32(insPos) == GetChildCount();
PRBool firstInsPos = insPos;
// Iterate through the fragment's children, and insert them in the new
@ -3943,23 +4008,11 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
// Fire mutation events. Optimize for the case when there are no listeners
nsPIDOMWindow* window = nsnull;
if (doc && (window = doc->GetInnerWindow()) &&
window->HasMutationListeners(NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
for (i = 0; i < count; ++i, ++insPos) {
nsIContent* childContent = fragChildren[i];
if (nsContentUtils::HasMutationListeners(childContent,
NS_EVENT_BITS_MUTATION_NODEINSERTED, this)) {
mozAutoRemovableBlockerRemover blockerRemover(doc);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED);
mutation.mRelatedNode = do_QueryInterface(this);
mozAutoSubtreeModified subtree(doc, this);
nsEventDispatcher::Dispatch(childContent, nsnull, &mutation);
}
}
if (doc &&
(((window = doc->GetInnerWindow()) &&
window->HasMutationListeners(NS_EVENT_BITS_MUTATION_NODEINSERTED)) ||
!window)) {
nsGenericElement::FireNodeInserted(doc, this, fragChildren);
}
}
else {
@ -4792,6 +4845,8 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent,
ListAttributes(out);
fprintf(out, " intrinsicstate=[%08x]", IntrinsicState());
fprintf(out, " flags=[%08x]", GetFlags());
fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
fprintf(out, " refcount=%d<", mRefCnt.get());
PRUint32 i, length = GetChildCount();
@ -5181,11 +5236,11 @@ TryMatchingElementsInSubtree(nsINode* aRoot,
PRBool continueIteration = PR_TRUE;
for (nsINode::ChildIterator iter(aRoot); !iter.IsDone(); iter.Next()) {
nsIContent* kid = iter;
if (!kid->IsNodeOfType(nsINode::eELEMENT)) {
if (!kid->IsElement()) {
continue;
}
/* See whether we match */
new (data) RuleProcessorData(aPresContext, kid, nsnull);
new (data) RuleProcessorData(aPresContext, kid->AsElement(), nsnull);
NS_ASSERTION(!data->mParentData, "Shouldn't happen");
NS_ASSERTION(!data->mPreviousSiblingData, "Shouldn't happen");
data->mParentData = aParentData;
@ -5322,17 +5377,18 @@ nsNSElementTearoff::MozMatchesSelector(const nsAString& aSelector, PRBool* aRetu
/* static */
PRBool
nsGenericElement::doMatchesSelector(nsIContent* aNode, const nsAString& aSelector)
nsGenericElement::doMatchesSelector(Element* aElement,
const nsAString& aSelector)
{
nsAutoPtr<nsCSSSelectorList> selectorList;
nsPresContext* presContext;
PRBool matches = PR_FALSE;
if (NS_SUCCEEDED(ParseSelectorList(aNode, aSelector,
if (NS_SUCCEEDED(ParseSelectorList(aElement, aSelector,
getter_Transfers(selectorList),
&presContext)))
{
RuleProcessorData data(presContext, aNode, nsnull);
RuleProcessorData data(presContext, aElement, nsnull);
matches = nsCSSRuleProcessor::SelectorListMatches(data, selectorList);
}

View File

@ -46,7 +46,7 @@
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDOMEventTarget.h"
@ -332,7 +332,7 @@ class nsNSElementTearoff;
* A generic base class for DOM elements, implementing many nsIContent,
* nsIDOMNode and nsIDOMElement methods.
*/
class nsGenericElement : public nsIContent
class nsGenericElement : public mozilla::dom::Element
{
public:
nsGenericElement(nsINodeInfo *aNodeInfo);
@ -637,6 +637,14 @@ public:
nsAttrAndChildArray& aChildArray,
PRBool aMutationEvent);
/**
* If there are listeners for DOMNodeInserted event, fires the event on all
* aNodes
*/
static void FireNodeInserted(nsIDocument* aDoc,
nsINode* aParent,
nsCOMArray<nsIContent>& aNodes);
/**
* Helper methods for implementing querySelector/querySelectorAll
*/
@ -645,7 +653,8 @@ public:
static nsresult doQuerySelectorAll(nsINode* aRoot,
const nsAString& aSelector,
nsIDOMNodeList **aReturn);
static PRBool doMatchesSelector(nsIContent* aNode, const nsAString& aSelector);
static PRBool doMatchesSelector(mozilla::dom::Element* aElement,
const nsAString& aSelector);
/**
* Default event prehandling for content objects. Handles event retargeting.

View File

@ -1281,13 +1281,16 @@ GK_ATOM(accumulate, "accumulate")
GK_ATOM(additive, "additive")
GK_ATOM(attributeName, "attributeName")
GK_ATOM(attributeType, "attributeType")
GK_ATOM(auto_reverse, "auto-reverse")
GK_ATOM(begin, "begin")
GK_ATOM(by, "by")
GK_ATOM(calcMode, "calcMode")
GK_ATOM(css, "CSS")
GK_ATOM(dur, "dur")
GK_ATOM(keyPoints, "keyPoints")
GK_ATOM(keySplines, "keySplines")
GK_ATOM(keyTimes, "keyTimes")
GK_ATOM(mozAnimateMotionDummyAttr, "_mozAnimateMotionDummyAttr")
GK_ATOM(repeatCount, "repeatCount")
GK_ATOM(repeatDur, "repeatDur")
GK_ATOM(restart, "restart")

View File

@ -92,7 +92,7 @@ nsHTMLContentSerializer::~nsHTMLContentSerializer()
NS_IMETHODIMP
nsHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
nsHTMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr)
{
return NS_OK;
@ -100,7 +100,7 @@ nsHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
void
nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aTagPrefix,
const nsAString& aTagNamespaceURI,
nsIAtom* aTagName,
@ -190,14 +190,13 @@ nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
}
NS_IMETHODIMP
nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
nsHTMLContentSerializer::AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
if (!content) return NS_ERROR_FAILURE;
nsIContent* content = aElement;
PRBool forceFormat = PR_FALSE;
if (!CheckElementStart(content, forceFormat, aStr)) {
@ -250,7 +249,8 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
// Store its start attribute value in olState->startVal.
nsAutoString start;
PRInt32 startAttrVal = 0;
aElement->GetAttribute(NS_LITERAL_STRING("start"), start);
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::start, start);
if (!start.IsEmpty()){
PRInt32 rv = 0;
startAttrVal = start.ToInteger(&rv);
@ -298,13 +298,12 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
}
NS_IMETHODIMP
nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
nsHTMLContentSerializer::AppendElementEnd(nsIContent *aElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
if (!content) return NS_ERROR_FAILURE;
nsIContent* content = aElement;
nsIAtom *name = content->Tag();

View File

@ -57,19 +57,19 @@ class nsHTMLContentSerializer : public nsXHTMLContentSerializer {
nsHTMLContentSerializer();
virtual ~nsHTMLContentSerializer();
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
NS_IMETHOD AppendElementEnd(nsIContent *aElement,
nsAString& aStr);
NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr);
protected:
virtual void SerializeHTMLAttributes(nsIContent* aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aTagPrefix,
const nsAString& aTagNamespaceURI,
nsIAtom* aTagName,

View File

@ -39,6 +39,7 @@
#include "nsContentUtils.h"
#include "nsINode.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIMutationObserver.h"
#include "nsIDocument.h"
#include "nsIDOMUserDataHandler.h"
@ -60,6 +61,8 @@
#include "nsHTMLMediaElement.h"
#endif // MOZ_MEDIA
using namespace mozilla::dom;
// This macro expects the ownerDocument of content_ to be in scope as
// |nsIDocument* doc|
#define IMPL_MUTATION_NOTIFICATION(func_, content_, params_) \
@ -262,10 +265,10 @@ nsNodeUtils::LastRelease(nsINode* aNode)
aNode->UnsetFlags(NODE_HAS_LISTENERMANAGER);
}
if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
if (aNode->IsElement()) {
nsIDocument* ownerDoc = aNode->GetOwnerDoc();
if (ownerDoc) {
ownerDoc->ClearBoxObjectFor(static_cast<nsIContent*>(aNode));
ownerDoc->ClearBoxObjectFor(aNode->AsElement());
}
}
@ -465,58 +468,6 @@ nsNodeUtils::CloneNodeImpl(nsINode *aNode, PRBool aDeep, nsIDOMNode **aResult)
return NS_OK;
}
class AdoptFuncData {
public:
AdoptFuncData(nsGenericElement *aElement,
nsNodeInfoManager *aNewNodeInfoManager, JSContext *aCx,
JSObject *aOldScope, JSObject *aNewScope,
nsCOMArray<nsINode> &aNodesWithProperties)
: mElement(aElement),
mNewNodeInfoManager(aNewNodeInfoManager),
mCx(aCx),
mOldScope(aOldScope),
mNewScope(aNewScope),
mNodesWithProperties(aNodesWithProperties)
{
}
nsGenericElement *mElement;
nsNodeInfoManager *mNewNodeInfoManager;
JSContext *mCx;
JSObject *mOldScope;
JSObject *mNewScope;
nsCOMArray<nsINode> &mNodesWithProperties;
};
PLDHashOperator
AdoptFunc(nsAttrHashKey::KeyType aKey, nsIDOMNode *aData, void* aUserArg)
{
nsCOMPtr<nsIAttribute> attr = do_QueryInterface(aData);
NS_ASSERTION(attr, "non-nsIAttribute somehow made it into the hashmap?!");
AdoptFuncData *data = static_cast<AdoptFuncData*>(aUserArg);
// If we were passed an element we need to clone the attribute nodes and
// insert them into the element.
PRBool clone = data->mElement != nsnull;
nsCOMPtr<nsINode> node;
nsresult rv = nsNodeUtils::CloneAndAdopt(attr, clone, PR_TRUE,
data->mNewNodeInfoManager,
data->mCx, data->mOldScope,
data->mNewScope,
data->mNodesWithProperties,
nsnull, getter_AddRefs(node));
if (NS_SUCCEEDED(rv) && clone) {
nsCOMPtr<nsIDOMAttr> dummy, attribute = do_QueryInterface(node, &rv);
if (NS_SUCCEEDED(rv)) {
rv = data->mElement->SetAttributeNode(attribute, getter_AddRefs(dummy));
}
}
return NS_SUCCEEDED(rv) ? PL_DHASH_NEXT : PL_DHASH_STOP;
}
/* static */
nsresult
nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
@ -569,7 +520,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
nodeInfo = newNodeInfo;
}
nsGenericElement *elem = aNode->IsNodeOfType(nsINode::eELEMENT) ?
nsGenericElement *elem = aNode->IsElement() ?
static_cast<nsGenericElement*>(aNode) :
nsnull;
@ -597,10 +548,10 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
else if (nodeInfoManager) {
nsIDocument* oldDoc = aNode->GetOwnerDoc();
PRBool wasRegistered = PR_FALSE;
if (oldDoc && aNode->IsNodeOfType(nsINode::eELEMENT)) {
nsIContent* content = static_cast<nsIContent*>(aNode);
oldDoc->ClearBoxObjectFor(content);
wasRegistered = oldDoc->UnregisterFreezableElement(content);
if (oldDoc && aNode->IsElement()) {
Element* element = aNode->AsElement();
oldDoc->ClearBoxObjectFor(element);
wasRegistered = oldDoc->UnregisterFreezableElement(element);
}
aNode->mNodeInfo.swap(newNodeInfo);
@ -610,7 +561,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
// XXX what if oldDoc is null, we don't know if this should be
// registered or not! Can that really happen?
if (wasRegistered) {
newDoc->RegisterFreezableElement(static_cast<nsIContent*>(aNode));
newDoc->RegisterFreezableElement(aNode->AsElement());
}
nsPIDOMWindow* window = newDoc->GetInnerWindow();
@ -654,22 +605,10 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
}
}
if (elem) {
// aNode's attributes.
const nsDOMAttributeMap *map = elem->GetAttributeMap();
if (map) {
// If we're cloning we need to insert the cloned attribute nodes into the
// cloned element. We assume that the clone of an nsGenericElement is also
// an nsGenericElement.
nsGenericElement* elemClone =
aClone ? static_cast<nsGenericElement*>(clone.get()) : nsnull;
AdoptFuncData data(elemClone, nodeInfoManager, aCx, aOldScope, aNewScope,
aNodesWithProperties);
PRUint32 count = map->Enumerate(AdoptFunc, &data);
NS_ENSURE_TRUE(count == map->Count(), NS_ERROR_FAILURE);
}
}
// XXX If there are any attribute nodes on this element with UserDataHandlers
// we should technically adopt/clone/import such attribute nodes and notify
// those handlers. However we currently don't have code to do so without
// also notifying when it's not safe so we're not doing that at this time.
// The DOM spec says to always adopt/clone/import the children of attribute
// nodes.
@ -723,7 +662,8 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
// cloning, so kids of the new node aren't confused about whether they're
// in a document.
#ifdef MOZ_XUL
if (aClone && !aParent && aNode->IsNodeOfType(nsINode::eELEMENT) && static_cast<nsIContent*>(aNode)->IsXUL()) {
if (aClone && !aParent && aNode->IsElement() &&
aNode->AsElement()->IsXUL()) {
nsXULElement *xulElem = static_cast<nsXULElement*>(elem);
if (!xulElem->mPrototype || xulElem->IsInDoc()) {
clone->SetFlags(NODE_FORCE_XBL_BINDINGS);

View File

@ -290,7 +290,7 @@ nsPlainTextSerializer::Initialize(nsAString* aOutString,
}
NS_IMETHODIMP
nsPlainTextSerializer::AppendText(nsIDOMText* aText,
nsPlainTextSerializer::AppendText(nsIContent* aText,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
@ -309,7 +309,7 @@ nsPlainTextSerializer::AppendText(nsIDOMText* aText,
PRInt32 length = 0;
nsAutoString textstr;
nsCOMPtr<nsIContent> content = do_QueryInterface(aText);
nsIContent* content = aText;
const nsTextFragment* frag;
if (!content || !(frag = content->GetText())) {
return NS_ERROR_FAILURE;
@ -372,7 +372,7 @@ nsPlainTextSerializer::AppendText(nsIDOMText* aText,
}
NS_IMETHODIMP
nsPlainTextSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
nsPlainTextSerializer::AppendCDATASection(nsIContent* aCDATASection,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
@ -381,14 +381,13 @@ nsPlainTextSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
}
NS_IMETHODIMP
nsPlainTextSerializer::AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
nsPlainTextSerializer::AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
mContent = do_QueryInterface(aElement);
if (!mContent) return NS_ERROR_FAILURE;
mContent = aElement;
nsresult rv;
PRInt32 id = GetIdForContent(mContent);
@ -415,13 +414,12 @@ nsPlainTextSerializer::AppendElementStart(nsIDOMElement *aElement,
}
NS_IMETHODIMP
nsPlainTextSerializer::AppendElementEnd(nsIDOMElement *aElement,
nsPlainTextSerializer::AppendElementEnd(nsIContent *aElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
mContent = do_QueryInterface(aElement);
if (!mContent) return NS_ERROR_FAILURE;
mContent = aElement;
nsresult rv;
PRInt32 id = GetIdForContent(mContent);
@ -456,8 +454,8 @@ nsPlainTextSerializer::Flush(nsAString& aStr)
}
NS_IMETHODIMP
nsPlainTextSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
nsAString& aStr)
nsPlainTextSerializer::AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr)
{
return NS_OK;
}

View File

@ -71,27 +71,27 @@ public:
const char* aCharSet, PRBool aIsCopying,
PRBool aIsWholeDocument);
NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
NS_IMETHOD AppendText(nsIContent* aText, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr);
NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
PRInt32 aStartOffset, PRInt32 aEndOffset,
nsAString& aStr);
NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr) { return NS_OK; }
NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr) { return NS_OK; }
NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
nsAString& aStr) { return NS_OK; }
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
NS_IMETHOD AppendElementEnd(nsIContent *aElement,
nsAString& aStr);
NS_IMETHOD Flush(nsAString& aStr);
NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr);
// nsIContentSink

View File

@ -869,8 +869,8 @@ RangeSubtreeIterator::Init(nsIDOMRange *aRange)
PRInt32 startIndex;
aRange->GetStartOffset(&startIndex);
nsCOMPtr<nsINode> iNode = do_QueryInterface(node);
if (iNode->IsNodeOfType(nsINode::eELEMENT) &&
PRInt32(iNode->GetChildCount()) == startIndex) {
if (iNode->IsElement() &&
PRInt32(iNode->AsElement()->GetChildCount()) == startIndex) {
mStart = node;
}
}
@ -889,7 +889,7 @@ RangeSubtreeIterator::Init(nsIDOMRange *aRange)
PRInt32 endIndex;
aRange->GetEndOffset(&endIndex);
nsCOMPtr<nsINode> iNode = do_QueryInterface(node);
if (iNode->IsNodeOfType(nsINode::eELEMENT) && endIndex == 0) {
if (iNode->IsElement() && endIndex == 0) {
mEnd = node;
}
}
@ -1345,10 +1345,10 @@ nsresult nsRange::CutContents(nsIDOMDocumentFragment** aFragment)
if (!handled && (node == endContainer || node == startContainer))
{
nsCOMPtr<nsINode> iNode = do_QueryInterface(node);
if (iNode && iNode->IsNodeOfType(nsINode::eELEMENT) &&
if (iNode && iNode->IsElement() &&
((node == endContainer && endOffset == 0) ||
(node == startContainer &&
PRInt32(iNode->GetChildCount()) == startOffset)))
PRInt32(iNode->AsElement()->GetChildCount()) == startOffset)))
{
if (retval) {
nsCOMPtr<nsIDOMNode> clone;
@ -1624,10 +1624,11 @@ nsresult nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
{
nsCOMPtr<nsIDOMNode> node(iter.GetCurrentNode());
nsCOMPtr<nsINode> iNode = do_QueryInterface(node);
PRBool deepClone = !(iNode->IsNodeOfType(nsINode::eELEMENT)) ||
PRBool deepClone = !iNode->IsElement() ||
(!(iNode == mEndParent && mEndOffset == 0) &&
!(iNode == mStartParent &&
mStartOffset == PRInt32(iNode->GetChildCount())));
mStartOffset ==
PRInt32(iNode->AsElement()->GetChildCount())));
// Clone the current subtree!

View File

@ -48,6 +48,7 @@
#include "nsICharsetConverterManager.h"
#include "nsIUnicodeDecoder.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsGkAtoms.h"
#include "nsNetUtil.h"
#include "nsIScriptGlobalObject.h"
@ -79,6 +80,7 @@
static PRLogModuleInfo* gCspPRLog;
#endif
using namespace mozilla::dom;
//////////////////////////////////////////////////////////////
// Per-request data structure
@ -384,11 +386,11 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
return NS_ERROR_NOT_AVAILABLE;
}
// Default script language is whatever the root content specifies
// Default script language is whatever the root element specifies
// (which may come from a header or http-meta tag), or if there
// is no root content, from the script global object.
nsCOMPtr<nsIContent> rootContent = mDocument->GetRootContent();
PRUint32 typeID = rootContent ? rootContent->GetScriptTypeID() :
// is no root element, from the script global object.
Element* rootElement = mDocument->GetRootElement();
PRUint32 typeID = rootElement ? rootElement->GetScriptTypeID() :
context->GetScriptTypeID();
PRUint32 version = 0;
nsAutoString language, type, src;

View File

@ -266,7 +266,7 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
NS_ENSURE_TRUE(mLoadSuccess, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(document->GetRootContent(), NS_ERROR_FAILURE);
NS_ENSURE_TRUE(document->GetRootElement(), NS_ERROR_FAILURE);
return CallQueryInterface(document, aResult);
}

View File

@ -272,7 +272,7 @@ nsTextFragment::CopyTo(PRUnichar *aDest, PRInt32 aOffset, PRInt32 aCount)
aOffset = 0;
}
if (aOffset + aCount > GetLength()) {
if (PRUint32(aOffset + aCount) > GetLength()) {
aCount = mState.mLength - aOffset;
}

View File

@ -236,6 +236,8 @@ nsTextNode::List(FILE* out, PRInt32 aIndent) const
fprintf(out, "Text@%p", static_cast<const void*>(this));
fprintf(out, " intrinsicstate=[%08x]", IntrinsicState());
fprintf(out, " flags=[%08x]", GetFlags());
fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
fprintf(out, " refcount=%d<", mRefCnt.get());
nsAutoString tmp;

View File

@ -82,7 +82,7 @@ nsresult nsTraversal::TestNode(nsINode* aNode, PRInt16* _filtered)
PRUint16 nodeType = 0;
// Check the most common cases
if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
if (aNode->IsElement()) {
nodeType = nsIDOMNode::ELEMENT_NODE;
}
else if (aNode->IsNodeOfType(nsINode::eCONTENT)) {

View File

@ -155,7 +155,7 @@ nsXHTMLContentSerializer::HasLongLines(const nsString& text, PRInt32& aLastNewli
}
NS_IMETHODIMP
nsXHTMLContentSerializer::AppendText(nsIDOMText* aText,
nsXHTMLContentSerializer::AppendText(nsIContent* aText,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
@ -260,7 +260,7 @@ nsXHTMLContentSerializer::EscapeURI(nsIContent* aContent, const nsAString& aURI,
void
nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aTagPrefix,
const nsAString& aTagNamespaceURI,
nsIAtom* aTagName,
@ -306,9 +306,8 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
else if (aTagName == nsGkAtoms::li) {
mIsFirstChildOfOL = IsFirstChildOfOL(aOriginalElement);
if (mIsFirstChildOfOL) {
nsCOMPtr<nsIDOMElement> element (do_QueryInterface(aContent));
// If OL is parent of this LI, serialize attributes in different manner.
SerializeLIValueAttribute(element, aStr);
SerializeLIValueAttribute(aContent, aStr);
}
}
}
@ -445,7 +444,7 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
void
nsXHTMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
nsXHTMLContentSerializer::AppendEndOfElementStart(nsIContent *aOriginalElement,
nsIAtom * aName,
PRInt32 aNamespaceID,
nsAString& aStr)
@ -460,7 +459,7 @@ nsXHTMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElemen
return;
}
nsCOMPtr<nsIContent> content = do_QueryInterface(aOriginalElement);
nsIContent* content = aOriginalElement;
// for non empty elements, even if they are not a container, we always
// serialize their content, because the XHTML element could contain non XHTML
@ -487,7 +486,7 @@ nsXHTMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElemen
void
nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aStr)
{
nsIAtom *name = aContent->Tag();
@ -550,7 +549,7 @@ nsXHTMLContentSerializer::AfterElementEnd(nsIContent * aContent,
NS_IMETHODIMP
nsXHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
nsXHTMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr)
{
if (!mBodyOnly)
@ -979,7 +978,7 @@ nsXHTMLContentSerializer::MaybeLeaveFromPreContent(nsIContent* aNode)
}
void
nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIDOMElement* aElement,
nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIContent* aElement,
nsAString& aStr)
{
// We are copying and we are at the "first" LI node of OL in selected range.
@ -1050,7 +1049,7 @@ nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIDOMElement* aElement,
}
PRBool
nsXHTMLContentSerializer::IsFirstChildOfOL(nsIDOMElement* aElement)
nsXHTMLContentSerializer::IsFirstChildOfOL(nsIContent* aElement)
{
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
nsAutoString parentName;

View File

@ -62,12 +62,12 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
const char* aCharSet, PRBool aIsCopying,
PRBool aRewriteEncodingDeclaration);
NS_IMETHOD AppendText(nsIDOMText* aText,
NS_IMETHOD AppendText(nsIContent* aText,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr);
NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr);
protected:
@ -77,13 +77,13 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
PRBool & aForceFormat,
nsAString& aStr);
virtual void AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
virtual void AppendEndOfElementStart(nsIContent *aOriginalElement,
nsIAtom * aName,
PRInt32 aNamespaceID,
nsAString& aStr);
virtual void AfterElementStart(nsIContent * aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aStr);
virtual PRBool CheckElementEnd(nsIContent * aContent,
@ -105,7 +105,7 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
virtual void MaybeLeaveFromPreContent(nsIContent* aNode);
virtual void SerializeAttributes(nsIContent* aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aTagPrefix,
const nsAString& aTagNamespaceURI,
nsIAtom* aTagName,
@ -113,9 +113,9 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
PRUint32 aSkipAttr,
PRBool aAddNSAttr);
PRBool IsFirstChildOfOL(nsIDOMElement* aElement);
PRBool IsFirstChildOfOL(nsIContent* aElement);
void SerializeLIValueAttribute(nsIDOMElement* aElement,
void SerializeLIValueAttribute(nsIContent* aElement,
nsAString& aStr);
PRBool IsShorthandAttr(const nsIAtom* aAttrName,
const nsIAtom* aElementName);

View File

@ -148,13 +148,13 @@ nsXMLContentSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn,
}
nsresult
nsXMLContentSerializer::AppendTextData(nsIDOMNode* aNode,
nsXMLContentSerializer::AppendTextData(nsIContent* aNode,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr,
PRBool aTranslateEntities)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
nsIContent* content = aNode;
const nsTextFragment* frag;
if (!content || !(frag = content->GetText())) {
return NS_ERROR_FAILURE;
@ -194,7 +194,7 @@ nsXMLContentSerializer::AppendTextData(nsIDOMNode* aNode,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendText(nsIDOMText* aText,
nsXMLContentSerializer::AppendText(nsIContent* aText,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
@ -225,7 +225,7 @@ nsXMLContentSerializer::AppendText(nsIDOMText* aText,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
nsXMLContentSerializer::AppendCDATASection(nsIContent* aCDATASection,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
@ -260,21 +260,22 @@ nsXMLContentSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
nsXMLContentSerializer::AppendProcessingInstruction(nsIContent* aPI,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
{
NS_ENSURE_ARG(aPI);
nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(aPI);
NS_ENSURE_ARG(pi);
nsresult rv;
nsAutoString target, data, start;
MaybeAddNewlineForRootNode(aStr);
rv = aPI->GetTarget(target);
rv = pi->GetTarget(target);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
rv = aPI->GetData(data);
rv = pi->GetData(data);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
start.AppendLiteral("<?");
@ -308,16 +309,17 @@ nsXMLContentSerializer::AppendProcessingInstruction(nsIDOMProcessingInstruction*
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendComment(nsIDOMComment* aComment,
nsXMLContentSerializer::AppendComment(nsIContent* aComment,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr)
{
NS_ENSURE_ARG(aComment);
nsCOMPtr<nsIDOMComment> comment = do_QueryInterface(aComment);
NS_ENSURE_ARG(comment);
nsresult rv;
nsAutoString data;
rv = aComment->GetData(data);
rv = comment->GetData(data);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
if (aStartOffset || (aEndOffset != -1)) {
@ -360,20 +362,21 @@ nsXMLContentSerializer::AppendComment(nsIDOMComment* aComment,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendDoctype(nsIDOMDocumentType *aDoctype,
nsXMLContentSerializer::AppendDoctype(nsIContent* aDocType,
nsAString& aStr)
{
NS_ENSURE_ARG(aDoctype);
nsCOMPtr<nsIDOMDocumentType> docType = do_QueryInterface(aDocType);
NS_ENSURE_ARG(docType);
nsresult rv;
nsAutoString name, publicId, systemId, internalSubset;
rv = aDoctype->GetName(name);
rv = docType->GetName(name);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
rv = aDoctype->GetPublicId(publicId);
rv = docType->GetPublicId(publicId);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
rv = aDoctype->GetSystemId(systemId);
rv = docType->GetSystemId(systemId);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
rv = aDoctype->GetInternalSubset(internalSubset);
rv = docType->GetInternalSubset(internalSubset);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
MaybeAddNewlineForRootNode(aStr);
@ -427,7 +430,7 @@ nsXMLContentSerializer::AppendDoctype(nsIDOMDocumentType *aDoctype,
}
AppendToString(kGreaterThan, aStr);
MaybeFlagNewlineForRootNode(aDoctype);
MaybeFlagNewlineForRootNode(aDocType);
return NS_OK;
}
@ -435,7 +438,7 @@ nsXMLContentSerializer::AppendDoctype(nsIDOMDocumentType *aDoctype,
nsresult
nsXMLContentSerializer::PushNameSpaceDecl(const nsAString& aPrefix,
const nsAString& aURI,
nsIDOMElement* aOwner)
nsIContent* aOwner)
{
NameSpaceDecl* decl = mNameSpaceStack.AppendElement();
if (!decl) return NS_ERROR_OUT_OF_MEMORY;
@ -449,7 +452,7 @@ nsXMLContentSerializer::PushNameSpaceDecl(const nsAString& aPrefix,
}
void
nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIDOMElement* aOwner)
nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIContent* aOwner)
{
PRInt32 index, count;
@ -465,7 +468,7 @@ nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIDOMElement* aOwner)
PRBool
nsXMLContentSerializer::ConfirmPrefix(nsAString& aPrefix,
const nsAString& aURI,
nsIDOMElement* aElement,
nsIContent* aElement,
PRBool aIsAttribute)
{
if (aPrefix.EqualsLiteral(kXMLNS)) {
@ -716,7 +719,7 @@ nsXMLContentSerializer::SerializeAttr(const nsAString& aPrefix,
PRUint32
nsXMLContentSerializer::ScanNamespaceDeclarations(nsIContent* aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
const nsAString& aTagNamespaceURI)
{
PRUint32 index, count;
@ -812,7 +815,7 @@ nsXMLContentSerializer::IsJavaScript(nsIContent * aContent, nsIAtom* aAttrNameAt
void
nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aTagPrefix,
const nsAString& aTagNamespaceURI,
nsIAtom* aTagName,
@ -892,14 +895,13 @@ nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
nsXMLContentSerializer::AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
nsCOMPtr<nsIContent> content(do_QueryInterface(aElement));
if (!content) return NS_ERROR_FAILURE;
nsIContent* content = aElement;
PRBool forceFormat = PR_FALSE;
if (!CheckElementStart(content, forceFormat, aStr)) {
@ -907,9 +909,9 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
}
nsAutoString tagPrefix, tagLocalName, tagNamespaceURI;
aElement->GetPrefix(tagPrefix);
aElement->GetLocalName(tagLocalName);
aElement->GetNamespaceURI(tagNamespaceURI);
aElement->NodeInfo()->GetPrefix(tagPrefix);
aElement->NodeInfo()->GetLocalName(tagLocalName);
aElement->NodeInfo()->GetNamespaceURI(tagNamespaceURI);
PRUint32 skipAttr = ScanNamespaceDeclarations(content,
aOriginalElement, tagNamespaceURI);
@ -979,15 +981,13 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
}
void
nsXMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
nsXMLContentSerializer::AppendEndOfElementStart(nsIContent *aOriginalElement,
nsIAtom * aName,
PRInt32 aNamespaceID,
nsAString& aStr)
{
// We don't output a separate end tag for empty elements
PRBool hasChildren = PR_FALSE;
if (NS_FAILED(aOriginalElement->HasChildNodes(&hasChildren)) ||
!hasChildren) {
if (!aOriginalElement->GetChildCount()) {
AppendToString(NS_LITERAL_STRING("/>"), aStr);
}
else {
@ -996,13 +996,12 @@ nsXMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
nsXMLContentSerializer::AppendElementEnd(nsIContent *aElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
nsCOMPtr<nsIContent> content(do_QueryInterface(aElement));
if (!content) return NS_ERROR_FAILURE;
nsIContent* content = aElement;
PRBool forceFormat = PR_FALSE, outputElementEnd;
outputElementEnd = CheckElementEnd(content, forceFormat, aStr);
@ -1021,9 +1020,9 @@ nsXMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
nsAutoString tagPrefix, tagLocalName, tagNamespaceURI;
aElement->GetPrefix(tagPrefix);
aElement->GetLocalName(tagLocalName);
aElement->GetNamespaceURI(tagNamespaceURI);
aElement->NodeInfo()->GetPrefix(tagPrefix);
aElement->NodeInfo()->GetLocalName(tagLocalName);
aElement->NodeInfo()->GetNamespaceURI(tagNamespaceURI);
#ifdef DEBUG
PRBool debugNeedToPushNamespace =
@ -1077,18 +1076,13 @@ nsXMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
nsXMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr)
{
NS_ENSURE_ARG_POINTER(aDocument);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDocument));
if (!doc) {
return NS_OK;
}
nsAutoString version, encoding, standalone;
doc->GetXMLDeclaration(version, encoding, standalone);
aDocument->GetXMLDeclaration(version, encoding, standalone);
if (version.IsEmpty())
return NS_OK; // A declaration must have version, or there is no decl
@ -1134,17 +1128,10 @@ nsXMLContentSerializer::CheckElementEnd(nsIContent * aContent,
nsAString& aStr)
{
// We don't output a separate end tag for empty element
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aContent));
PRBool hasChildren;
aForceFormat = PR_FALSE;
if (NS_SUCCEEDED(node->HasChildNodes(&hasChildren)) && !hasChildren) {
return PR_FALSE;
}
return PR_TRUE;
return aContent->GetChildCount() > 0;
}
void
nsXMLContentSerializer::AppendToString(const PRUnichar* aStr,
PRInt32 aLength,
@ -1245,14 +1232,11 @@ nsXMLContentSerializer::MaybeAddNewlineForRootNode(nsAString& aStr)
}
void
nsXMLContentSerializer::MaybeFlagNewlineForRootNode(nsIDOMNode* aNode)
nsXMLContentSerializer::MaybeFlagNewlineForRootNode(nsINode* aNode)
{
nsCOMPtr<nsIDOMNode> parent;
aNode->GetParentNode(getter_AddRefs(parent));
nsINode* parent = aNode->GetNodeParent();
if (parent) {
PRUint16 type;
parent->GetNodeType(&type);
mAddNewlineForRootNode = type == nsIDOMNode::DOCUMENT_NODE;
mAddNewlineForRootNode = parent->IsNodeOfType(nsINode::eDOCUMENT);
}
}

View File

@ -70,34 +70,34 @@ class nsXMLContentSerializer : public nsIContentSerializer {
const char* aCharSet, PRBool aIsCopying,
PRBool aRewriteEncodingDeclaration);
NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
NS_IMETHOD AppendText(nsIContent* aText, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr);
NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
PRInt32 aStartOffset, PRInt32 aEndOffset,
nsAString& aStr);
NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr);
NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
PRInt32 aEndOffset, nsAString& aStr);
NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
nsAString& aStr);
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
nsIDOMElement *aOriginalElement,
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
NS_IMETHOD AppendElementEnd(nsIContent *aElement,
nsAString& aStr);
NS_IMETHOD Flush(nsAString& aStr) { return NS_OK; }
NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
nsAString& aStr);
protected:
@ -185,7 +185,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* retrieve the text content of the node and append it to the given string
* It doesn't increment the column position
*/
nsresult AppendTextData(nsIDOMNode* aNode,
nsresult AppendTextData(nsIContent* aNode,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString& aStr,
@ -193,8 +193,8 @@ class nsXMLContentSerializer : public nsIContentSerializer {
virtual nsresult PushNameSpaceDecl(const nsAString& aPrefix,
const nsAString& aURI,
nsIDOMElement* aOwner);
void PopNameSpaceDeclsFor(nsIDOMElement* aOwner);
nsIContent* aOwner);
void PopNameSpaceDeclsFor(nsIContent* aOwner);
/**
* The problem that ConfirmPrefix fixes is that anyone can insert nodes
@ -216,7 +216,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
*/
PRBool ConfirmPrefix(nsAString& aPrefix,
const nsAString& aURI,
nsIDOMElement* aElement,
nsIContent* aElement,
PRBool aIsAttribute);
/**
* GenerateNewPrefix generates a new prefix and writes it to aPrefix
@ -224,11 +224,11 @@ class nsXMLContentSerializer : public nsIContentSerializer {
void GenerateNewPrefix(nsAString& aPrefix);
PRUint32 ScanNamespaceDeclarations(nsIContent* aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
const nsAString& aTagNamespaceURI);
virtual void SerializeAttributes(nsIContent* aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aTagPrefix,
const nsAString& aTagNamespaceURI,
nsIAtom* aTagName,
@ -263,7 +263,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* this method is responsible to finish the start tag,
* in particulary to append the "greater than" sign
*/
virtual void AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
virtual void AppendEndOfElementStart(nsIContent *aOriginalElement,
nsIAtom * aName,
PRInt32 aNamespaceID,
nsAString& aStr);
@ -274,7 +274,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* (called at the end of AppendElementStart)
*/
virtual void AfterElementStart(nsIContent * aContent,
nsIDOMElement *aOriginalElement,
nsIContent *aOriginalElement,
nsAString& aStr) { };
/**
@ -328,7 +328,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
// Functions to check for newlines that needs to be added between nodes in
// the root of a document. See mAddNewlineForRootNode
void MaybeAddNewlineForRootNode(nsAString& aStr);
void MaybeFlagNewlineForRootNode(nsIDOMNode* aNode);
void MaybeFlagNewlineForRootNode(nsINode* aNode);
// Functions to check if we enter in or leave from a preformated content
virtual void MaybeEnterInPreContent(nsIContent* aNode);
@ -339,7 +339,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
struct NameSpaceDecl {
nsString mPrefix;
nsString mURI;
nsIDOMElement* mOwner;
nsIContent* mOwner;
};
nsTArray<NameSpaceDecl> mNameSpaceStack;

View File

@ -94,7 +94,7 @@
#include "nsIStorageStream.h"
#include "nsIPromptFactory.h"
#include "nsIWindowWatcher.h"
#include "nsCommaSeparatedTokenizer.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsIConsoleService.h"
#include "nsIChannelPolicy.h"
#include "nsChannelPolicy.h"
@ -382,7 +382,7 @@ nsACProxyListener::AddResultToCache(nsIRequest *aRequest)
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Methods"),
headerVal);
nsCCommaSeparatedTokenizer methods(headerVal);
nsCCharSeparatedTokenizer methods(headerVal, ',');
while(methods.hasMoreTokens()) {
const nsDependentCSubstring& method = methods.nextToken();
if (method.IsEmpty()) {
@ -412,7 +412,7 @@ nsACProxyListener::AddResultToCache(nsIRequest *aRequest)
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"),
headerVal);
nsCCommaSeparatedTokenizer headers(headerVal);
nsCCharSeparatedTokenizer headers(headerVal, ',');
while(headers.hasMoreTokens()) {
const nsDependentCSubstring& header = headers.nextToken();
if (header.IsEmpty()) {
@ -2100,9 +2100,13 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
mRequestObserver->OnStopRequest(request, ctxt, status);
}
// Don't do anything if we have been aborted
if (mState & XML_HTTP_REQUEST_UNINITIALIZED)
// make sure to notify the listener if we were aborted
// XXX in fact, why don't we do the cleanup below in this case??
if (mState & XML_HTTP_REQUEST_UNINITIALIZED) {
if (mXMLParserStreamListener)
(void) mXMLParserStreamListener->OnStopRequest(request, ctxt, status);
return NS_OK;
}
nsCOMPtr<nsIParser> parser;

View File

@ -380,6 +380,7 @@ _TEST_FILES = test_bug5141.html \
file_csp_redirects_resource.sjs \
test_bug346485.html \
test_bug560780.html \
test_bug562652.html \
$(NULL)
# This test fails on the Mac for some reason

View File

@ -0,0 +1,55 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=562652
-->
<head>
<title>Test for Bug 562652</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=562652">Mozilla Bug 562652</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="testtarget">_</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 562652 **/
var testCount = 0;
function createHTMLDoc() {
var dtd = document.implementation.createDocumentType("HTML", "-//W3C//DTD HTML 4.01//EN", null);
var d = document.implementation.createDocument(null, null, dtd);
d.appendChild(d.createElement("html"));
d.documentElement.appendChild(d.createElement("body"));
d.body.setAttribute("id", "testtarget");
return d;
}
function test(d) {
var t = d.getElementById("testtarget");
d.addEventListener("DOMNodeInserted", function(e) { ++testCount; }, false);
t.innerHTML = "_";
}
function runTests() {
test(document);
test(createHTMLDoc());
is(testCount, 2, "DOMNodeInserted should have fired 2 times!");
SimpleTest.finish();
}
addLoadEvent(runTests);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

View File

@ -38,6 +38,7 @@
#include "nsICanvasRenderingContextWebGL.h"
#include "WebGLArray.h"
#include "nsDOMClassInfoID.h"
#define DUMMY(func,rtype) nsresult func (rtype ** aResult) { return NS_ERROR_FAILURE; }
@ -50,3 +51,11 @@ DUMMY(NS_NewWebGLUnsignedShortArray, nsISupports)
DUMMY(NS_NewWebGLIntArray, nsISupports)
DUMMY(NS_NewWebGLUnsignedIntArray, nsISupports)
DUMMY(NS_NewWebGLArrayBuffer, nsISupports)
DOMCI_DATA(CanvasRenderingContextWebGL, void)
DOMCI_DATA(WebGLBuffer, void)
DOMCI_DATA(WebGLTexture, void)
DOMCI_DATA(WebGLProgram, void)
DOMCI_DATA(WebGLShader, void)
DOMCI_DATA(WebGLFramebuffer, void)
DOMCI_DATA(WebGLRenderbuffer, void)

View File

@ -2021,8 +2021,8 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
if (content && content->IsInDoc()) {
// inherit from the canvas element
parentContext = nsComputedDOMStyle::GetStyleContextForContent(
content,
parentContext = nsComputedDOMStyle::GetStyleContextForElement(
content->AsElement(),
nsnull,
presShell);
} else {
@ -2372,7 +2372,7 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
if (content && content->IsInDoc()) {
// try to find the closest context
nsRefPtr<nsStyleContext> canvasStyle =
nsComputedDOMStyle::GetStyleContextForContent(content,
nsComputedDOMStyle::GetStyleContextForElement(content->AsElement(),
nsnull,
presShell);
if (!canvasStyle)

View File

@ -21066,7 +21066,7 @@ function runTests() {
//test_2d_gradient_radial_touch3();
/**
* These 19 tests recieve special makefile treatment
* These 19 tests receive special makefile treatment
*/
//test_2d_composite_uncovered_image_destination_atop();
//test_2d_composite_uncovered_image_destination_in();

View File

@ -43,6 +43,7 @@
#include "nsEventListenerManager.h"
#include "nsContentUtils.h"
#include "nsDOMError.h"
#include "mozilla/FunctionTimer.h"
#include "nsMutationEvent.h"
#include NEW_H
#include "nsFixedSizeAllocator.h"
@ -470,6 +471,13 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(aEvent),
NS_ERROR_ILLEGAL_VALUE);
NS_ASSERTION(!aTargets || !aEvent->message, "Wrong parameters!");
#ifdef NS_FUNCTION_TIMER
const char* timer_event_name = nsDOMEvent::GetEventName(aEvent->message);
NS_TIME_FUNCTION_MIN_FMT(20, "Dispatching '%s' event",
timer_event_name ? timer_event_name : "<other>");
#endif
nsCOMPtr<nsPIDOMEventTarget> target = do_QueryInterface(aTarget);
if (aEvent->flags & NS_EVENT_FLAG_ONLY_CHROME_DISPATCH) {

View File

@ -66,6 +66,7 @@
#include "nsLayoutUtils.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIFrame.h"
#include "nsIView.h"
#include "nsIViewManager.h"
@ -96,6 +97,8 @@
#include "nsDOMEvent.h"
#include "nsIContentSecurityPolicy.h"
using namespace mozilla::dom;
#define EVENT_TYPE_EQUALS( ls, type, userType ) \
(ls->mEventType && ls->mEventType == type && \
(ls->mEventType != NS_USER_DEFINED_EVENT || ls->mTypeAtom == userType))
@ -778,7 +781,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
nameSpace = content->GetNameSpaceID();
}
else if (doc) {
nsCOMPtr<nsIContent> root = doc->GetRootContent();
Element* root = doc->GetRootElement();
if (root)
nameSpace = root->GetNameSpaceID();
}

View File

@ -153,6 +153,7 @@
#endif
#include "nsIController.h"
#include "nsICommandParams.h"
#include "mozilla/Services.h"
#ifdef XP_MACOSX
#import <ApplicationServices/ApplicationServices.h>
@ -272,10 +273,10 @@ NS_IMPL_ISUPPORTS1(nsUITimerCallback, nsITimerCallback)
NS_IMETHODIMP
nsUITimerCallback::Notify(nsITimer* aTimer)
{
nsresult rv;
nsCOMPtr<nsIObserverService> obs =
do_GetService("@mozilla.org/observer-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::services::GetObserverService();
if (!obs)
return NS_ERROR_FAILURE;
if ((gMouseOrKeyboardEventCounter == mPreviousCount) || !aTimer) {
gMouseOrKeyboardEventCounter = 0;
obs->NotifyObservers(nsnull, "user-interaction-inactive", nsnull);
@ -789,10 +790,10 @@ nsEventStateManager::nsEventStateManager()
NS_IMETHODIMP
nsEventStateManager::Init()
{
nsresult rv;
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::services::GetObserverService();
if (!observerService)
return NS_ERROR_FAILURE;
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
@ -832,7 +833,7 @@ nsEventStateManager::Init()
prefBranch->AddObserver("dom.popup_allowed_events", this, PR_TRUE);
}
return rv;
return NS_OK;
}
nsEventStateManager::~nsEventStateManager()
@ -861,11 +862,9 @@ nsEventStateManager::~nsEventStateManager()
// gets called from xpcom shutdown observer. And we don't want to remove
// from the service in that case.
nsresult rv;
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_SUCCEEDED(rv)) {
mozilla::services::GetObserverService();
if (observerService) {
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
}
}
@ -1047,7 +1046,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
aEvent->eventStructType == NS_KEY_EVENT)) {
if (gMouseOrKeyboardEventCounter == 0) {
nsCOMPtr<nsIObserverService> obs =
do_GetService("@mozilla.org/observer-service;1");
mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(nsnull, "user-interaction-active", nsnull);
}
@ -2761,7 +2760,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// designMode. In designMode, all contents are not focusable.
if (newFocus && !newFocus->IsEditable()) {
nsIDocument *doc = newFocus->GetCurrentDoc();
if (doc && newFocus == doc->GetRootContent()) {
if (doc && newFocus == doc->GetRootElement()) {
nsIContent *bodyContent =
nsLayoutUtils::GetEditableRootContentByContentEditable(doc);
if (bodyContent) {
@ -3617,7 +3616,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsGUIEvent* aEvent)
// We're always over the document root, even if we're only
// over dead space in a page (whose frame is not associated with
// any content) or in print preview dead space
targetElement = mDocument->GetRootContent();
targetElement = mDocument->GetRootElement();
}
if (targetElement) {
NotifyMouseOver(aEvent, targetElement);

View File

@ -83,7 +83,7 @@ nsIMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)
nsCOMPtr<nsIWidget> widget = GetWidget(sPresContext);
if (widget) {
PRUint32 newState = GetNewIMEState(sPresContext, nsnull);
SetIMEState(sPresContext, newState, widget);
SetIMEState(newState, widget);
}
sContent = nsnull;
sPresContext = nsnull;
@ -108,7 +108,7 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
if (NS_FAILED(rv))
widget->ResetInputState();
PRUint32 newState = GetNewIMEState(sPresContext, nsnull);
SetIMEState(sPresContext, newState, widget);
SetIMEState(newState, widget);
}
sContent = nsnull;
@ -162,7 +162,7 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
if (newState != nsIContent::IME_STATUS_NONE) {
// Update IME state for new focus widget
SetIMEState(aPresContext, newState, widget);
SetIMEState(newState, widget);
}
sPresContext = aPresContext;
@ -178,6 +178,26 @@ nsIMEStateManager::OnInstalledMenuKeyboardListener(PRBool aInstalling)
OnChangeFocus(sPresContext, sContent);
}
void
nsIMEStateManager::ChangeIMEStateTo(PRUint32 aNewIMEState)
{
if (!sPresContext) {
NS_WARNING("ISM doesn't know which editor has focus");
return;
}
NS_PRECONDITION(aNewIMEState != 0, "aNewIMEState doesn't specify new state.");
nsCOMPtr<nsIWidget> widget = GetWidget(sPresContext);
if (!widget) {
NS_WARNING("focused widget is not found");
return;
}
// commit current composition
widget->ResetInputState();
SetIMEState(aNewIMEState, widget);
}
PRUint32
nsIMEStateManager::GetNewIMEState(nsPresContext* aPresContext,
nsIContent* aContent)
@ -204,18 +224,17 @@ nsIMEStateManager::GetNewIMEState(nsPresContext* aPresContext,
}
void
nsIMEStateManager::SetIMEState(nsPresContext* aPresContext,
PRUint32 aState,
nsIWidget* aKB)
nsIMEStateManager::SetIMEState(PRUint32 aState,
nsIWidget* aWidget)
{
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
PRUint32 state =
nsContentUtils::GetWidgetStatusFromIMEStatus(aState);
aKB->SetIMEEnabled(state);
aWidget->SetIMEEnabled(state);
}
if (aState & nsIContent::IME_STATUS_MASK_OPENED) {
PRBool open = !!(aState & nsIContent::IME_STATUS_OPEN);
aKB->SetIMEOpenState(open);
aWidget->SetIMEOpenState(open);
}
}

View File

@ -80,10 +80,11 @@ public:
// Get the focused editor's selection and root
static nsresult GetFocusSelectionAndRoot(nsISelection** aSel,
nsIContent** aRoot);
// This method changes the current IME state forcedly.
// So, the caller should check whether you're focused or not.
static void ChangeIMEStateTo(PRUint32 aNewIMEState);
protected:
static void SetIMEState(nsPresContext* aPresContext,
PRUint32 aState,
nsIWidget* aKB);
static void SetIMEState(PRUint32 aState, nsIWidget* aWidget);
static PRUint32 GetNewIMEState(nsPresContext* aPresContext,
nsIContent* aContent);

View File

@ -427,7 +427,7 @@ nsXMLEventsManager::ContentRemoved(nsIDocument* aDocument,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
if (!aChild || !aChild->IsNodeOfType(nsINode::eELEMENT))
if (!aChild || !aChild->IsElement())
return;
//Note, we can't use IDs here, the observer may not always have an ID.
//And to remember: the same observer can be referenced by many

View File

@ -803,8 +803,8 @@ GetSubmissionFromForm(nsGenericHTMLElement* aForm,
nsFormSubmission** aFormSubmission)
{
// Get all the information necessary to encode the form data
nsIDocument* doc = aForm->GetCurrentDoc();
NS_ASSERTION(doc, "Should have doc if we're building submission!");
NS_ASSERTION(aForm->GetCurrentDoc(),
"Should have doc if we're building submission!");
// Get encoding type (default: urlencoded)
PRInt32 enctype = NS_FORM_ENCTYPE_URLENCODED;
@ -826,16 +826,16 @@ GetSubmissionFromForm(nsGenericHTMLElement* aForm,
enctype == NS_FORM_ENCTYPE_TEXTPLAIN) {
*aFormSubmission = new nsFSTextPlain(charset);
} else {
nsIDocument* doc = aForm->GetOwnerDoc();
if (enctype == NS_FORM_ENCTYPE_MULTIPART ||
enctype == NS_FORM_ENCTYPE_TEXTPLAIN) {
nsAutoString enctypeStr;
aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::enctype, enctypeStr);
const PRUnichar* enctypeStrPtr = enctypeStr.get();
SendJSWarning(aForm->GetOwnerDoc(), "ForgotPostWarning",
SendJSWarning(doc, "ForgotPostWarning",
&enctypeStrPtr, 1);
}
*aFormSubmission = new nsFSURLEncoded(charset, method,
aForm->GetOwnerDoc());
*aFormSubmission = new nsFSURLEncoded(charset, method, doc);
}
NS_ENSURE_TRUE(*aFormSubmission, NS_ERROR_OUT_OF_MEMORY);

View File

@ -109,6 +109,7 @@
#include "nsLayoutUtils.h"
#include "nsContentCreatorFunctions.h"
#include "mozAutoDocUpdate.h"
#include "nsHtml5Module.h"
class nsINodeInfo;
class nsIDOMNodeList;
@ -452,7 +453,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
parent = parent->GetParent();
}
nsIContent* docElement = GetCurrentDoc()->GetRootContent();
Element* docElement = GetCurrentDoc()->GetRootElement();
nsIContent* content = frame->GetContent();
if (content && (IsBody(content) || content == docElement)) {
@ -657,36 +658,66 @@ nsGenericHTMLElement::GetInnerHTML(nsAString& aInnerHTML)
nsresult
nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
{
nsIDocument* doc = GetOwnerDoc();
NS_ENSURE_STATE(doc);
nsresult rv = NS_OK;
// This BeginUpdate/EndUpdate pair is important to make us reenable the
// scriptloader before the last EndUpdate call.
mozAutoDocUpdate updateBatch(GetCurrentDoc(), UPDATE_CONTENT_MODEL, PR_TRUE);
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, PR_TRUE);
// Batch possible DOMSubtreeModified events.
mozAutoSubtreeModified subtree(GetOwnerDoc(), nsnull);
mozAutoSubtreeModified subtree(doc, nsnull);
// Remove childnodes
nsContentUtils::SetNodeTextContent(this, EmptyString(), PR_FALSE);
nsCOMPtr<nsIDOMDocumentFragment> df;
nsCOMPtr<nsIDocument> doc = GetOwnerDoc();
// Strong ref since appendChild can fire events
nsRefPtr<nsScriptLoader> loader;
PRBool scripts_enabled = PR_FALSE;
nsRefPtr<nsScriptLoader> loader = doc->ScriptLoader();
PRBool scripts_enabled = loader->GetEnabled();
loader->SetEnabled(PR_FALSE);
if (doc) {
loader = doc->ScriptLoader();
scripts_enabled = loader->GetEnabled();
loader->SetEnabled(PR_FALSE);
}
if (doc->IsHTML() && nsHtml5Module::sEnabled) {
nsCOMPtr<nsIParser> parser = doc->GetFragmentParser();
if (parser) {
parser->Reset();
} else {
parser = nsHtml5Module::NewHtml5Parser();
NS_ENSURE_TRUE(parser, NS_ERROR_OUT_OF_MEMORY);
}
nsresult rv = nsContentUtils::CreateContextualFragment(this, aInnerHTML,
PR_FALSE,
getter_AddRefs(df));
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
if (NS_SUCCEEDED(rv)) {
static_cast<nsINode*>(this)->AppendChild(fragment, &rv);
PRInt32 oldChildCount = GetChildCount();
parser->ParseFragment(aInnerHTML, this, Tag(), GetNameSpaceID(),
doc->GetCompatibilityMode() == eCompatibility_NavQuirks);
doc->SetFragmentParser(parser);
// HTML5 parser has notified, but not fired mutation events.
// Fire mutation events. Optimize for the case when there are no listeners
nsPIDOMWindow* window = nsnull;
PRInt32 newChildCount = GetChildCount();
if (newChildCount &&
(((window = doc->GetInnerWindow()) &&
window->HasMutationListeners(NS_EVENT_BITS_MUTATION_NODEINSERTED)) ||
!window)) {
nsCOMArray<nsIContent> childNodes;
NS_ASSERTION(newChildCount - oldChildCount >= 0,
"What, some unexpected dom mutation has happened?");
childNodes.SetCapacity(newChildCount - oldChildCount);
for (nsINode::ChildIterator iter(this); !iter.IsDone(); iter.Next()) {
childNodes.AppendObject(iter);
}
nsGenericElement::FireNodeInserted(doc, this, childNodes);
}
} else {
rv = nsContentUtils::CreateContextualFragment(this, aInnerHTML, PR_FALSE,
getter_AddRefs(df));
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
if (NS_SUCCEEDED(rv)) {
static_cast<nsINode*>(this)->AppendChild(fragment, &rv);
}
}
if (scripts_enabled) {
@ -1145,12 +1176,6 @@ nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const
}
}
PRBool
nsGenericHTMLElement::IsNodeOfType(PRUint32 aFlags) const
{
return !(aFlags & ~(eCONTENT | eELEMENT));
}
//----------------------------------------------------------------------
@ -1571,6 +1596,9 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttribu
void
nsGenericHTMLFormElement::UpdateEditableFormControlState()
{
// nsCSSFrameConstructor::MaybeConstructLazily is based on the logic of this
// function, so should be kept in sync with that.
ContentEditableTristate value = GetContentEditableValue();
if (value != eInherit) {
SetEditableFlag(!!value);
@ -2240,7 +2268,7 @@ NS_IMPL_QUERY_INTERFACE_INHERITED1(nsGenericHTMLFormElement,
PRBool
nsGenericHTMLFormElement::IsNodeOfType(PRUint32 aFlags) const
{
return !(aFlags & ~(eCONTENT | eELEMENT | eHTML_FORM_CONTROL));
return !(aFlags & ~(eCONTENT | eHTML_FORM_CONTROL));
}
void

View File

@ -175,7 +175,6 @@ public:
PRBool aNotify);
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
PRBool aNotify);
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull, PRBool aWithMouse = PR_FALSE)
{
PRBool isFocusable = PR_FALSE;

View File

@ -295,10 +295,9 @@ nsHTMLDNSPrefetch::nsDeferrals::Activate()
progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT);
// Register as an observer for xpcom shutdown events so we can drop any element refs
nsresult rv;
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_SUCCEEDED(rv))
mozilla::services::GetObserverService();
if (observerService)
observerService->AddObserver(this, "xpcom-shutdown", PR_TRUE);
}

View File

@ -906,16 +906,16 @@ nsHTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
}
// Notify observers that the form is being submitted.
nsresult rv = NS_OK;
nsCOMPtr<nsIObserverService> service =
do_GetService("@mozilla.org/observer-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::services::GetObserverService();
if (!service)
return NS_ERROR_FAILURE;
nsCOMPtr<nsISimpleEnumerator> theEnum;
rv = service->EnumerateObservers(aEarlyNotify ?
NS_EARLYFORMSUBMIT_SUBJECT :
NS_FORMSUBMIT_SUBJECT,
getter_AddRefs(theEnum));
nsresult rv = service->EnumerateObservers(aEarlyNotify ?
NS_EARLYFORMSUBMIT_SUBJECT :
NS_FORMSUBMIT_SUBJECT,
getter_AddRefs(theEnum));
NS_ENSURE_SUCCESS(rv, rv);
if (theEnum) {

View File

@ -71,7 +71,7 @@
#include "nsIDOMProgressEvent.h"
#include "nsHTMLMediaError.h"
#include "nsICategoryManager.h"
#include "nsCommaSeparatedTokenizer.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsMediaStream.h"
#include "nsIDOMHTMLVideoElement.h"
@ -1320,7 +1320,7 @@ static CanPlayStatus GetCanPlay(const nsAString& aType)
CanPlayStatus result = CANPLAY_YES;
// See http://www.rfc-editor.org/rfc/rfc4281.txt for the description
// of the 'codecs' parameter
nsCommaSeparatedTokenizer tokenizer(codecs);
nsCharSeparatedTokenizer tokenizer(codecs, ',');
PRBool expectMoreTokens = PR_FALSE;
while (tokenizer.hasMoreTokens()) {
const nsSubstring& token = tokenizer.nextToken();
@ -1329,7 +1329,7 @@ static CanPlayStatus GetCanPlay(const nsAString& aType)
// Totally unsupported codec
return CANPLAY_NO;
}
expectMoreTokens = tokenizer.lastTokenEndedWithComma();
expectMoreTokens = tokenizer.lastTokenEndedWithSeparator();
}
if (expectMoreTokens) {
// Last codec name was empty
@ -2049,7 +2049,7 @@ nsresult nsHTMLMediaElement::Observe(nsISupports* aSubject,
PRBool
nsHTMLMediaElement::IsNodeOfType(PRUint32 aFlags) const
{
return !(aFlags & ~(eCONTENT | eELEMENT | eMEDIA));
return !(aFlags & ~(eCONTENT | eMEDIA));
}
void nsHTMLMediaElement::NotifyAddedSource()

View File

@ -360,7 +360,7 @@ NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height)
NS_IMPL_INT_ATTR(nsHTMLObjectElement, Hspace, hspace)
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name)
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby)
NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex)
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLObjectElement, TabIndex, tabindex, 0)
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type)
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap)
NS_IMPL_INT_ATTR(nsHTMLObjectElement, Vspace, vspace)

View File

@ -432,7 +432,7 @@ void
SetBaseURIUsingFirstBaseWithHref(nsIContent* aHead, nsIContent* aMustMatch)
{
NS_PRECONDITION(aHead && aHead->GetOwnerDoc() &&
aHead->GetOwnerDoc()->GetHeadContent() == aHead,
aHead->GetOwnerDoc()->GetHeadElement() == aHead,
"Bad head");
nsIDocument* doc = aHead->GetOwnerDoc();
@ -483,7 +483,7 @@ nsHTMLSharedElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
aNameSpaceID == kNameSpaceID_None &&
IsInDoc() &&
(head = GetParent()) &&
head == GetOwnerDoc()->GetHeadContent()) {
head == GetOwnerDoc()->GetHeadElement()) {
SetBaseURIUsingFirstBaseWithHref(head, this);
}
@ -506,7 +506,7 @@ nsHTMLSharedElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
aNameSpaceID == kNameSpaceID_None &&
IsInDoc() &&
(head = GetParent()) &&
head == GetOwnerDoc()->GetHeadContent()) {
head == GetOwnerDoc()->GetHeadElement()) {
SetBaseURIUsingFirstBaseWithHref(head, nsnull);
}
@ -528,7 +528,7 @@ nsHTMLSharedElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (mNodeInfo->Equals(nsGkAtoms::base, kNameSpaceID_XHTML) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::href) &&
aDocument && aParent &&
aDocument->GetHeadContent() == aParent) {
aDocument->GetHeadElement() == aParent) {
SetBaseURIUsingFirstBaseWithHref(aParent, this);
}
@ -554,7 +554,7 @@ nsHTMLSharedElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
if (inHeadBase) {
// We might have gotten here as a result of the <head> being removed
// from the document. In that case we need to call SetBaseURI(nsnull)
nsIContent* head = doc->GetHeadContent();
Element* head = doc->GetHeadElement();
if (head) {
SetBaseURIUsingFirstBaseWithHref(head, nsnull);
}

View File

@ -158,6 +158,7 @@ _TEST_FILES = test_bug589.html \
test_bug536891.html \
test_bug536895.html \
test_bug458037.xhtml \
test_bug556645.html \
test_bug559284.html \
test_bug551670.html \
test_bug346485.html \

View File

@ -141,6 +141,7 @@ var focusableElements = [
"<input type=\"text\" tabindex=\"1\">",
"<input type=\"text\" contenteditable=\"true\">",
"<object></object>",
"<object tabindex=\"-1\"></object>",
"<object tabindex=\"0\"></object>",
"<object tabindex=\"1\"></object>",
@ -240,7 +241,6 @@ var nonFocusableElements = [
"<input type=\"text\" tabindex=\"0\" disabled>",
"<input type=\"text\" disabled>",
"<object></object>",
"<object tabindex=\"0\" disabled></object>",
"<object disabled></object>",
@ -348,9 +348,12 @@ var focusableInContentEditable = [
"<input type=\"text\" tabindex=\"1\">",
"<input type=\"text\" contenteditable=\"true\">",
"<object></object>",
"<object tabindex=\"-1\"></object>",
"<object tabindex=\"0\"></object>",
"<object tabindex=\"1\"></object>",
"<object contenteditable=\"true\"></object>",
"<select></select>",
"<select tabindex=\"-1\"></select>",
"<select tabindex=\"0\"></select>",

View File

@ -0,0 +1,50 @@
<html>
<head>
<title>Test for Bug 556645</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTest()">
<script>
SimpleTest.waitForExplicitFinish();
function runTest()
{
var obj = document.getElementById("obj");
var childDoc = obj.contentDocument;
var body = childDoc.body;
is(document.activeElement, document.body, "focus in parent before");
is(childDoc.activeElement, body, "focus in child before");
var button = childDoc.getElementsByTagName("button")[0];
button.focus();
childDoc.defaultView.focus();
is(document.activeElement, obj, "focus in parent after focus()");
is(childDoc.activeElement, button, "focus in child after focus()");
button.blur();
var pbutton = document.getElementById("pbutton");
pbutton.focus();
synthesizeKey("VK_TAB", { });
is(document.activeElement, obj, "focus in parent after tab");
is(childDoc.activeElement, childDoc.documentElement, "focus in child after tab");
synthesizeKey("VK_TAB", { });
is(document.activeElement, obj, "focus in parent after tab 2");
is(childDoc.activeElement, button, "focus in child after tab 2");
SimpleTest.finish();
}
</script>
<button id="pbutton">Parent</button>
<object id="obj" type="text/html"
data="data:text/html,%3Cbody%3E%3Cbutton%3EChild%3C/button%3E%3C/body%3E"
width="200" height="200"></object>
</body>
</html>

View File

@ -63,6 +63,7 @@
#include "nsInt64.h"
#include "nsNodeUtils.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsGenericHTMLElement.h"
@ -123,6 +124,8 @@
#include "nsContentCreatorFunctions.h"
#include "mozAutoDocUpdate.h"
using namespace mozilla::dom;
#ifdef NS_DEBUG
static PRLogModuleInfo* gSinkLogModuleInfo;
@ -1615,25 +1618,16 @@ HTMLContentSink::Init(nsIDocument* aDoc,
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
// Make root part
nsIContent *doc_root = mDocument->GetRootContent();
if (doc_root) {
// If the document already has a root we'll use it. This will
// happen when we do document.open()/.write()/.close()...
mRoot = static_cast<nsGenericHTMLElement*>(doc_root);
} else {
mRoot = NS_NewHTMLHtmlElement(nodeInfo);
if (!mRoot) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ASSERTION(mDocument->GetChildCount() == 0,
"Document should have no kids here!");
rv = mDocument->AppendChildTo(mRoot, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
mRoot = NS_NewHTMLHtmlElement(nodeInfo);
if (!mRoot) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ASSERTION(mDocument->GetChildCount() == 0,
"Document should have no kids here!");
rv = mDocument->AppendChildTo(mRoot, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
// Make head part
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head,
nsnull, kNameSpaceID_XHTML);
@ -2982,7 +2976,7 @@ HTMLContentSink::DumpContentModel()
FILE* out = ::fopen("rtest_html.txt", "a");
if (out) {
if (mDocument) {
nsIContent* root = mDocument->GetRootContent();
Element* root = mDocument->GetRootElement();
if (root) {
if (mDocumentURI) {
nsCAutoString buf;

View File

@ -143,6 +143,9 @@
#include "nsCCUncollectableMarker.h"
#include "nsHtml5Module.h"
#include "prprf.h"
#include "Element.h"
using namespace mozilla::dom;
#define NS_MAX_DOCUMENT_WRITE_DEPTH 20
@ -1602,7 +1605,7 @@ nsHTMLDocument::GetBody(nsIDOMHTMLElement** aBody)
{
*aBody = nsnull;
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (body) {
// There is a body element, return that as the body.
@ -1634,7 +1637,7 @@ NS_IMETHODIMP
nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
{
nsCOMPtr<nsIContent> newBody = do_QueryInterface(aBody);
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
// The body element must be either a body tag or a frameset tag. And we must
// have a html root tag, otherwise GetBody will not return the newly set
@ -1650,7 +1653,7 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
nsCOMPtr<nsIDOMNode> tmp;
// Use DOM methods so that we pass through the appropriate security checks.
nsCOMPtr<nsIDOMNode> currentBody = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMNode> currentBody = do_QueryInterface(GetBodyElement());
if (currentBody) {
return rootElem->ReplaceChild(aBody, currentBody, getter_AddRefs(tmp));
}
@ -2361,7 +2364,7 @@ nsHTMLDocument::GetBodySize(PRInt32* aWidth,
// Find the <body> element: this is what we'll want to use for the
// document's width and height values.
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (!body) {
return NS_OK;
}
@ -2402,7 +2405,7 @@ nsHTMLDocument::GetAlinkColor(nsAString& aAlinkColor)
{
aAlinkColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetALink(aAlinkColor);
}
@ -2413,7 +2416,7 @@ nsHTMLDocument::GetAlinkColor(nsAString& aAlinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetAlinkColor(const nsAString& aAlinkColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetALink(aAlinkColor);
}
@ -2426,7 +2429,7 @@ nsHTMLDocument::GetLinkColor(nsAString& aLinkColor)
{
aLinkColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetLink(aLinkColor);
}
@ -2437,7 +2440,7 @@ nsHTMLDocument::GetLinkColor(nsAString& aLinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetLinkColor(const nsAString& aLinkColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetLink(aLinkColor);
}
@ -2450,7 +2453,7 @@ nsHTMLDocument::GetVlinkColor(nsAString& aVlinkColor)
{
aVlinkColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetVLink(aVlinkColor);
}
@ -2461,7 +2464,7 @@ nsHTMLDocument::GetVlinkColor(nsAString& aVlinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetVlinkColor(const nsAString& aVlinkColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetVLink(aVlinkColor);
}
@ -2474,7 +2477,7 @@ nsHTMLDocument::GetBgColor(nsAString& aBgColor)
{
aBgColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetBgColor(aBgColor);
}
@ -2485,7 +2488,7 @@ nsHTMLDocument::GetBgColor(nsAString& aBgColor)
NS_IMETHODIMP
nsHTMLDocument::SetBgColor(const nsAString& aBgColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetBgColor(aBgColor);
}
@ -2498,7 +2501,7 @@ nsHTMLDocument::GetFgColor(nsAString& aFgColor)
{
aFgColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetText(aFgColor);
}
@ -2509,7 +2512,7 @@ nsHTMLDocument::GetFgColor(nsAString& aFgColor)
NS_IMETHODIMP
nsHTMLDocument::SetFgColor(const nsAString& aFgColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetText(aFgColor);
}
@ -2640,24 +2643,26 @@ FindNamedItems(nsIAtom* aName, nsIContent *aContent,
NS_ASSERTION(!aEntry->IsInvalidName(),
"Entry that should never have a list passed to FindNamedItems()!");
if (aContent->IsNodeOfType(nsINode::eTEXT)) {
// Text nodes are not named items nor can they have children.
if (!aContent->IsElement()) {
// non-elements are not named items nor can they have children.
return;
}
if (aName == nsContentUtils::IsNamedItem(aContent)) {
aEntry->AddNameContent(aContent);
Element* element = aContent->AsElement();
if (aName == nsContentUtils::IsNamedItem(element)) {
aEntry->AddNameElement(element);
}
if (!aEntry->GetIdContent() &&
if (!aEntry->GetIdElement() &&
// Maybe this node has the right id?
aName == aContent->GetID()) {
aEntry->AddIdContent(aContent);
aName == element->GetID()) {
aEntry->AddIdElement(element);
}
PRUint32 i, count = aContent->GetChildCount();
PRUint32 i, count = element->GetChildCount();
for (i = 0; i < count; ++i) {
FindNamedItems(aName, aContent->GetChildAt(i), aEntry);
FindNamedItems(aName, element->GetChildAt(i), aEntry);
}
}
@ -2714,7 +2719,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
if (NS_FAILED(rv))
return rv;
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (root && !aName.IsEmpty()) {
FindNamedItems(name, root, entry);
}
@ -2788,7 +2793,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
// for aName, so we're guaranteed that if there is an element with
// the id aName, it'll be entry's IdContent.
nsIContent *e = entry->GetIdContent();
Element *e = entry->GetIdElement();
if (e && e->IsHTML()) {
nsIAtom *tag = e->Tag();
@ -2835,7 +2840,7 @@ nsHTMLDocument::PrePopulateIdentifierMap()
/* virtual */ nsIContent*
nsHTMLDocument::GetBodyContentExternal()
{
return GetBodyContent();
return GetBodyElement();
}
// forms related stuff
@ -3123,7 +3128,7 @@ nsHTMLDocument::GetDocumentAllResult(const nsAString& aID, nsISupports** aResult
nsIdentifierMapEntry *entry = mIdentifierMap.PutEntry(id);
NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (!root) {
return NS_OK;
}

View File

@ -73,6 +73,9 @@
#include "nsIDocShellTreeItem.h"
#include "nsThreadUtils.h"
#include "nsIScrollableFrame.h"
#include "Element.h"
using namespace mozilla::dom;
#define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing"
#define CLICK_IMAGE_RESIZING_PREF "browser.enable_click_image_resizing"
@ -400,7 +403,7 @@ nsImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObjec
nsHTMLDocument::SetScriptGlobalObject(aScriptGlobalObject);
if (aScriptGlobalObject) {
if (!GetRootContent()) {
if (!GetRootElement()) {
// Create synthetic document
#ifdef DEBUG
nsresult rv =
@ -643,7 +646,7 @@ nsImageDocument::CreateSyntheticDocument()
nsresult rv = nsMediaDocument::CreateSyntheticDocument();
NS_ENSURE_SUCCESS(rv, rv);
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on image document!");
return NS_ERROR_FAILURE;
@ -692,14 +695,14 @@ nsImageDocument::CheckOverflowing(PRBool changeState)
nsPresContext *context = shell->GetPresContext();
nsRect visibleArea = context->GetVisibleArea();
nsIContent* content = GetBodyContent();
if (!content) {
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on image document!");
return NS_ERROR_FAILURE;
}
nsRefPtr<nsStyleContext> styleContext =
context->StyleSet()->ResolveStyleFor(content, nsnull);
context->StyleSet()->ResolveStyleFor(body, nsnull);
nsMargin m;
if (styleContext->GetStyleMargin()->GetMargin(m))

View File

@ -46,6 +46,9 @@
#include "nsContentCreatorFunctions.h"
#include "nsContentPolicyUtils.h"
#include "nsIPropertyBag2.h"
#include "Element.h"
using namespace mozilla::dom;
class nsPluginDocument : public nsMediaDocument,
public nsIPluginDocument
@ -274,7 +277,7 @@ nsPluginDocument::CreateSyntheticPluginDocument()
NS_ENSURE_SUCCESS(rv, rv);
// then attach our plugin
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on plugin document!");
return NS_ERROR_FAILURE;

View File

@ -41,6 +41,9 @@
#include "nsContentCreatorFunctions.h"
#include "nsHTMLMediaElement.h"
#include "nsIDocShellTreeItem.h"
#include "Element.h"
using namespace mozilla::dom;
class nsVideoDocument : public nsMediaDocument
{
@ -100,7 +103,7 @@ nsVideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
nsresult rv = nsMediaDocument::CreateSyntheticDocument();
NS_ENSURE_SUCCESS(rv, rv);
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on video document!");
return NS_ERROR_FAILURE;

View File

@ -407,7 +407,7 @@ nsMathMLElement::IntrinsicState() const
PRBool
nsMathMLElement::IsNodeOfType(PRUint32 aFlags) const
{
return !(aFlags & ~(eCONTENT | eELEMENT));
return !(aFlags & ~eCONTENT);
}
void

View File

@ -767,7 +767,7 @@ nsresult nsOggPlayStateMachine::Run()
!mDecoder->GetCurrentStream()->IsDataCachedToEndOfStream(mDecoder->mDecoderPosition) &&
!mDecoder->GetCurrentStream()->IsSuspendedByCache() &&
((HasAudio() && mReader->mAudioQueue.Duration() < LOW_AUDIO_MS) ||
(HasVideo() && mReader->mVideoQueue.GetSize() < LOW_VIDEO_FRAMES)))
(HasVideo() && (PRUint32)mReader->mVideoQueue.GetSize() < LOW_VIDEO_FRAMES)))
{
// There is at most one frame in the queue and there's
// more data to load. Let's buffer to make sure we can play a

View File

@ -324,6 +324,7 @@ TheoraVersion(th_info* info,
return (th_ver >= ver) ? 1 : 0;
}
#ifdef DEBUG
// Ensures that all the VideoData in aFrames array are stored in increasing
// order by timestamp. Used in assertions in debug builds.
static PRBool
@ -341,6 +342,7 @@ AllFrameTimesIncrease(nsTArray<VideoData*>& aFrames)
}
return PR_TRUE;
}
#endif
static void Clear(nsTArray<VideoData*>& aFrames) {
for (PRUint32 i = 0; i < aFrames.Length(); ++i) {

View File

@ -91,6 +91,7 @@ endif # ENABLE_TESTS
EXPORTS += \
nsISMILAnimationElement.h \
nsISMILAttr.h \
nsISMILType.h \
nsSMILAnimationController.h \
nsSMILCompositorTable.h \
nsSMILCSSProperty.h \

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