Merge last green changeset from mozilla-inbound to mozilla-central

This commit is contained in:
Marco Bonardo 2011-08-01 16:04:07 +02:00
commit d9feaaf1ec
244 changed files with 2617 additions and 2148 deletions

View File

@ -67,6 +67,8 @@
#include "nsMaiInterfaceDocument.h"
#include "nsMaiInterfaceImage.h"
using namespace mozilla::a11y;
nsAccessibleWrap::EAvailableAtkSignals nsAccessibleWrap::gAvailableAtkSignals =
eUnknown;

View File

@ -39,6 +39,8 @@
#include "States.h"
using namespace mozilla::a11y;
AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) :
mPosInSet(0), mSetSize(0), mParent(nsnull)
{

View File

@ -87,7 +87,12 @@ EXPORTS = \
nsAccessible.h \
nsAccessNode.h \
nsARIAMap.h \
States.h \
$(NULL)
EXPORTS_NAMESPACES = mozilla/a11y
EXPORTS_mozilla/a11y = \
States.h \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

View File

@ -42,6 +42,8 @@
#include <prtypes.h>
namespace mozilla {
namespace a11y {
namespace states {
/**
@ -303,7 +305,9 @@ namespace states {
* @see EXPANDED and COLLAPSED states.
*/
const PRUint64 EXPANDABLE = ((PRUint64) 0x1) << 46;
}
} // namespace states
} // namespace a11y
} // namespace mozilla
#endif

View File

@ -41,6 +41,8 @@
#include "nsAccUtils.h"
#include "States.h"
using namespace mozilla::a11y;
bool
filters::GetSelected(nsAccessible* aAccessible)
{

View File

@ -45,6 +45,8 @@
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsARIAGridAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -45,6 +45,8 @@
#include "nsAccessibilityAtoms.h"
#include "nsIContent.h"
using namespace mozilla::a11y;
/**
* This list of WAI-defined roles are currently hardcoded.
* Eventually we will most likely be loading an RDF resource that contains this information

View File

@ -57,6 +57,8 @@
#include "nsIWebNavigation.h"
#include "nsServiceManagerUtils.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsAccDocManager
////////////////////////////////////////////////////////////////////////////////

View File

@ -57,6 +57,8 @@
#include "nsWhitespaceTokenizer.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla::a11y;
void
nsAccUtils::GetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom *aAttrName, nsAString& aAttrValue)

View File

@ -108,6 +108,8 @@
#include "mozilla/FunctionTimer.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsAccessibilityService
////////////////////////////////////////////////////////////////////////////////

View File

@ -108,6 +108,7 @@
#include "mozilla/dom/Element.h"
using namespace mozilla;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
@ -723,22 +724,33 @@ nsAccessible::NativeState()
/* readonly attribute boolean focusedChild; */
NS_IMETHODIMP
nsAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
{
nsAccessible *focusedChild = nsnull;
if (gLastFocusedNode == mContent) {
focusedChild = this;
}
else if (gLastFocusedNode) {
focusedChild = GetAccService()->GetAccessible(gLastFocusedNode);
if (focusedChild && focusedChild->Parent() != this)
focusedChild = nsnull;
}
nsAccessible::GetFocusedChild(nsIAccessible** aChild)
{
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nsnull;
NS_IF_ADDREF(*aFocusedChild = focusedChild);
if (IsDefunct())
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aChild = FocusedChild());
return NS_OK;
}
nsAccessible*
nsAccessible::FocusedChild()
{
if (!gLastFocusedNode)
return nsnull;
if (gLastFocusedNode == mContent)
return this;
nsAccessible* focusedChild = GetDocAccessible()->GetAccessible(gLastFocusedNode);
if (!focusedChild || focusedChild->Parent() != this)
return nsnull;
return focusedChild;
}
// nsAccessible::ChildAtPoint()
nsAccessible*
nsAccessible::ChildAtPoint(PRInt32 aX, PRInt32 aY,

View File

@ -40,7 +40,7 @@
#define _nsAccessible_H_
#include "nsAccessNodeWrap.h"
#include "States.h"
#include "mozilla/a11y/States.h"
#include "nsIAccessible.h"
#include "nsIAccessibleHyperLink.h"
@ -217,6 +217,11 @@ public:
virtual nsAccessible* ChildAtPoint(PRInt32 aX, PRInt32 aY,
EWhichChildAtPoint aWhichChild);
/**
* Return the focused child if any.
*/
virtual nsAccessible* FocusedChild();
/**
* Return calculated group level based on accessible hierarchy.
*/
@ -453,7 +458,7 @@ public:
// Perhaps we can get information about invalid links from the cache
// In the mean time authors can use role="link" aria-invalid="true"
// to force it for links they internally know to be invalid
return (0 == (State() & states::INVALID));
return (0 == (State() & mozilla::a11y::states::INVALID));
}
/**

View File

@ -53,6 +53,8 @@
#include "nsServiceManagerUtils.h"
#include "mozilla/Services.h"
using namespace mozilla::a11y;
nsApplicationAccessible::nsApplicationAccessible() :
nsAccessibleWrap(nsnull, nsnull)
{

View File

@ -53,6 +53,8 @@
#include "nsINameSpaceManager.h"
#include "nsIURI.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsLeafAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -78,6 +78,7 @@
#endif
namespace dom = mozilla::dom;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// Static member initialization
@ -349,18 +350,15 @@ nsDocAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
return NS_OK;
}
NS_IMETHODIMP nsDocAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
nsAccessible*
nsDocAccessible::FocusedChild()
{
// XXXndeakin P3 accessibility shouldn't be caching the focus
if (!gLastFocusedNode) {
*aFocusedChild = nsnull;
return NS_OK;
}
// Return an accessible for the current global focus, which does not have to
// be contained within the current document.
NS_IF_ADDREF(*aFocusedChild = GetAccService()->GetAccessible(gLastFocusedNode));
return NS_OK;
return gLastFocusedNode ? GetAccService()->GetAccessible(gLastFocusedNode) :
nsnull;
}
NS_IMETHODIMP nsDocAccessible::TakeFocus()

View File

@ -94,7 +94,6 @@ public:
// nsIAccessible
NS_IMETHOD GetName(nsAString& aName);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
NS_IMETHOD TakeFocus(void);
// nsIScrollPositionListener
@ -114,6 +113,7 @@ public:
// nsAccessible
virtual void Description(nsString& aDescription);
virtual nsAccessible* FocusedChild();
virtual PRUint32 NativeRole();
virtual PRUint64 NativeState();
virtual void ApplyARIAState(PRUint64* aState);

View File

@ -42,6 +42,8 @@
#include "nsAccUtils.h"
#include "nsDocAccessible.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsOuterDocAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -86,6 +86,7 @@
#endif
using namespace mozilla;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsISupports

View File

@ -60,6 +60,8 @@
#include "nsIServiceManager.h"
#include "nsITextControlFrame.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsHTMLCheckboxAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -53,6 +53,8 @@
#include "nsIDOMDocument.h"
#include "nsPIDOMWindow.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsHTMLImageAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -45,6 +45,8 @@
#include "nsEventStates.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsHTMLLinkAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -57,6 +57,8 @@
#include "nsIServiceManager.h"
#include "nsIMutableArray.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsHTMLSelectListAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -66,6 +66,8 @@
#include "nsLayoutErrors.h"
#include "nsArrayUtils.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsHTMLTableCellAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -52,6 +52,8 @@
#include "nsISelectionController.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsHTMLTextAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -66,6 +66,8 @@
#include "nsTextFragment.h"
#include "gfxSkipChars.h"
using namespace mozilla::a11y;
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
////////////////////////////////////////////////////////////////////////////////

View File

@ -52,6 +52,8 @@
#include "nsRootAccessible.h"
using namespace mozilla::a11y;
// These constants are only defined in OS X SDK 10.4, so we define them in order
// to be able to use for earlier OS versions.
const NSString *kInstanceDescriptionAttribute = @"AXDescription"; // NSAccessibilityDescriptionAttribute
@ -334,9 +336,7 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
if (mIsExpired)
return nil;
nsCOMPtr<nsIAccessible> focusedGeckoChild;
mGeckoAccessible->GetFocusedChild (getter_AddRefs (focusedGeckoChild));
nsAccessible* focusedGeckoChild = mGeckoAccessible->FocusedChild();
if (focusedGeckoChild) {
mozAccessible *focusedChild = GetNativeFromGeckoAccessible(focusedGeckoChild);
if (focusedChild)

View File

@ -41,6 +41,8 @@
#include "nsObjCExceptions.h"
using namespace mozilla::a11y;
extern const NSString *kInstanceDescriptionAttribute; // NSAccessibilityDescriptionAttribute
extern const NSString *kTopLevelUIElementAttribute; // NSAccessibilityTopLevelUIElementAttribute

View File

@ -3,6 +3,8 @@
#import "mozTextAccessible.h"
using namespace mozilla::a11y;
extern const NSString *kInstanceDescriptionAttribute; // NSAccessibilityDescriptionAttribute
extern const NSString *kTopLevelUIElementAttribute; // NSAccessibilityTopLevelUIElementAttribute

View File

@ -86,7 +86,7 @@ class nsAccessibleWrap : public nsAccessible
PRInt32 GetUnignoredChildCount(PRBool aDeepCount);
PRBool HasPopup () {
return (NativeState() & states::HASPOPUP);
return (NativeState() & mozilla::a11y::states::HASPOPUP);
}
// return this accessible's all children, adhering to "flat" accessibles by not returning their children.

View File

@ -50,6 +50,8 @@
#include "nsIDOMCSSPrimitiveValue.h"
#include "nsIDOMNSRGBAColor.h"
using namespace mozilla::a11y;
enum {
IA2AlphaShift = 24,
IA2RedShift = 16,

View File

@ -67,6 +67,8 @@
#include "nsEventMap.h"
#include "nsArrayUtils.h"
using namespace mozilla::a11y;
/* For documentation of the accessibility architecture,
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
*/
@ -522,8 +524,7 @@ __try {
VariantInit(pvarChild);
// Return the current IAccessible child that has focus
nsCOMPtr<nsIAccessible> focusedAccessible;
GetFocusedChild(getter_AddRefs(focusedAccessible));
nsAccessible* focusedAccessible = FocusedChild();
if (focusedAccessible == this) {
pvarChild->vt = VT_I4;
pvarChild->lVal = CHILDID_SELF;

View File

@ -40,6 +40,8 @@
#include "States.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsHTMLWin32ObjectOwnerAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -52,6 +52,8 @@
#include "nsIXFormsUtilityService.h"
#include "nsIPlaintextEditor.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXFormsAccessibleBase
////////////////////////////////////////////////////////////////////////////////

View File

@ -41,6 +41,8 @@
#include "States.h"
#include "nsTextEquivUtils.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXFormsLabelAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -40,6 +40,8 @@
#include "States.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXFormsDropmarkerWidgetAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -39,6 +39,8 @@
#include "States.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULAlertAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -46,6 +46,7 @@
#include "nsIDOMElement.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULColorPickerTileAccessible

View File

@ -47,6 +47,8 @@
#include "nsIDOMXULMenuListElement.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULComboboxAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -62,6 +62,8 @@
#include "nsINameSpaceManager.h"
#include "nsITextControlFrame.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULButtonAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -48,6 +48,8 @@
#include "nsIDOMXULMultSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULColumnsAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -61,7 +61,7 @@
#include "mozilla/dom/Element.h"
using namespace mozilla;
using namespace mozilla::a11y;
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);

View File

@ -45,6 +45,8 @@
#include "nsIDOMDocumentXBL.h"
#include "nsIFrame.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULSliderAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -50,6 +50,8 @@
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsIDOMXULRelatedElement.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULTabAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -53,6 +53,8 @@
#include "nsString.h"
#include "nsNetUtil.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULTextAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -52,6 +52,8 @@
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeAccessible
////////////////////////////////////////////////////////////////////////////////
@ -200,17 +202,11 @@ nsXULTreeAccessible::NativeRole()
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeAccessible: nsIAccessible implementation
NS_IMETHODIMP
nsXULTreeAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
nsAccessible*
nsXULTreeAccessible::FocusedChild()
{
NS_ENSURE_ARG_POINTER(aFocusedChild);
*aFocusedChild = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
if (gLastFocusedNode != mContent)
return NS_OK;
return nsnull;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect =
do_QueryInterface(mContent);
@ -218,10 +214,10 @@ nsXULTreeAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
PRInt32 row = -1;
multiSelect->GetCurrentIndex(&row);
if (row >= 0)
NS_IF_ADDREF(*aFocusedChild = GetTreeItemAccessible(row));
return GetTreeItemAccessible(row);
}
return NS_OK;
return nsnull;
}
////////////////////////////////////////////////////////////////////////////////
@ -661,17 +657,11 @@ NS_IMPL_RELEASE_INHERITED(nsXULTreeItemAccessibleBase, nsAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeItemAccessibleBase: nsIAccessible implementation
NS_IMETHODIMP
nsXULTreeItemAccessibleBase::GetFocusedChild(nsIAccessible **aFocusedChild)
nsAccessible*
nsXULTreeItemAccessibleBase::FocusedChild()
{
NS_ENSURE_ARG_POINTER(aFocusedChild);
*aFocusedChild = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
if (gLastFocusedNode != mContent)
return NS_OK;
return nsnull;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect =
do_QueryInterface(mContent);
@ -680,10 +670,10 @@ nsXULTreeItemAccessibleBase::GetFocusedChild(nsIAccessible **aFocusedChild)
PRInt32 row = -1;
multiSelect->GetCurrentIndex(&row);
if (row == mRow)
NS_ADDREF(*aFocusedChild = this);
return this;
}
return NS_OK;
return nsnull;
}
NS_IMETHODIMP

View File

@ -76,7 +76,6 @@ public:
// nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
// nsAccessNode
virtual bool IsDefunct() const;
@ -87,6 +86,7 @@ public:
virtual PRUint64 NativeState();
virtual nsAccessible* ChildAtPoint(PRInt32 aX, PRInt32 aY,
EWhichChildAtPoint aWhichChild);
virtual nsAccessible* FocusedChild();
virtual nsAccessible* GetChildAt(PRUint32 aIndex);
virtual PRInt32 GetChildCount();
@ -182,8 +182,6 @@ public:
nsAccessibleWrap)
// nsIAccessible
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
NS_IMETHOD GetBounds(PRInt32 *aX, PRInt32 *aY,
PRInt32 *aWidth, PRInt32 *aHeight);
@ -209,6 +207,7 @@ public:
// nsAccessible
virtual PRUint64 NativeState();
virtual PRInt32 IndexInParent() const;
virtual nsAccessible* FocusedChild();
// nsXULTreeItemAccessibleBase
NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEITEMBASEACCESSIBLE_IMPL_CID)

View File

@ -47,6 +47,8 @@
#include "nsITreeSelection.h"
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridAccessible
////////////////////////////////////////////////////////////////////////////////
@ -848,13 +850,10 @@ NS_IMPL_RELEASE_INHERITED(nsXULTreeGridCellAccessible, nsLeafAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridCellAccessible: nsIAccessible implementation
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
nsAccessible*
nsXULTreeGridCellAccessible::FocusedChild()
{
NS_ENSURE_ARG_POINTER(aFocusedChild);
*aFocusedChild = nsnull;
return IsDefunct() ? NS_ERROR_FAILURE : NS_OK;
return nsnull;
}
NS_IMETHODIMP

View File

@ -143,7 +143,6 @@ public:
nsLeafAccessible)
// nsIAccessible
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
NS_IMETHOD GetName(nsAString& aName);
NS_IMETHOD GetBounds(PRInt32 *aX, PRInt32 *aY,
@ -162,6 +161,7 @@ public:
virtual bool IsPrimaryForNode() const;
// nsAccessible
virtual nsAccessible* FocusedChild();
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual PRUint32 NativeRole();
virtual PRUint64 NativeState();

View File

@ -46,17 +46,23 @@
#
topsrcdir=$1
for _config in "$MOZCONFIG" \
"$MOZ_MYCONFIG"
do
if [ -n "$_config" ] && ! [ -f "$_config" ]; then
echo "Specified MOZCONFIG \"$_config\" does not exist!"
absolute_path() {
if [ -n "${1%%/*}" ]; then
echo $topsrcdir/$1
else
echo $1
fi
}
if [ -n "$MOZCONFIG" ]; then
MOZCONFIG=`absolute_path "$MOZCONFIG"`
if ! [ -f "$MOZCONFIG" ]; then
echo "Specified MOZCONFIG \"$MOZCONFIG\" does not exist!"
exit 1
fi
done
fi
for _config in "$MOZCONFIG" \
"$MOZ_MYCONFIG" \
"$topsrcdir/.mozconfig" \
"$topsrcdir/mozconfig" \
"$topsrcdir/mozconfig.sh" \

View File

@ -80,6 +80,8 @@ static fp_except_t oldmask = fpsetmask(~allmask);
#include "nsINode.h"
#include "nsHashtable.h"
#include "nsIDOMNode.h"
#include "nsAHtml5FragmentParser.h"
#include "nsIFragmentContentSink.h"
struct nsNativeKeyEvent; // Don't include nsINativeKeyBindings.h here: it will force strange compilation error!
@ -1037,15 +1039,48 @@ public:
*
* @param aContextNode the node which is used to resolve namespaces
* @param aFragment the string which is parsed to a DocumentFragment
* @param aWillOwnFragment is PR_TRUE if ownership of the fragment should be
* transferred to the caller.
* @param aReturn [out] the created DocumentFragment
* @param aReturn the resulting fragment
* @param aPreventScriptExecution whether to mark scripts as already started
*/
static nsresult CreateContextualFragment(nsINode* aContextNode,
const nsAString& aFragment,
PRBool aWillOwnFragment,
PRBool aPreventScriptExecution,
nsIDOMDocumentFragment** aReturn);
/**
* Invoke the fragment parsing algorithm (innerHTML) using the HTML parser.
*
* @param aSourceBuffer the string being set as innerHTML
* @param aTargetNode the target container
* @param aContextLocalName local name of context node
* @param aContextNamespace namespace of context node
* @param aQuirks true to make <table> not close <p>
* @param aPreventScriptExecution true to prevent scripts from executing;
* don't set to false when parsing into a target node that has been
* bound to tree.
*/
static void ParseFragmentHTML(const nsAString& aSourceBuffer,
nsIContent* aTargetNode,
nsIAtom* aContextLocalName,
PRInt32 aContextNamespace,
PRBool aQuirks,
PRBool aPreventScriptExecution);
/**
* Invoke the fragment parsing algorithm (innerHTML) using the XML parser.
*
* @param aSourceBuffer the string being set as innerHTML
* @param aTargetNode the target container
* @param aTagStack the namespace mapping context
* @param aPreventExecution whether to mark scripts as already started
* @param aReturn the result fragment
*/
static nsresult ParseFragmentXML(const nsAString& aSourceBuffer,
nsIDocument* aDocument,
nsTArray<nsString>& aTagStack,
PRBool aPreventScriptExecution,
nsIDOMDocumentFragment** aReturn);
/**
* Creates a new XML document, which is marked to be loaded as data.
*
@ -1664,6 +1699,12 @@ public:
*/
static PRBool IsFocusedContent(const nsIContent *aContent);
static void GetShiftText(nsAString& text);
static void GetControlText(nsAString& text);
static void GetMetaText(nsAString& text);
static void GetAltText(nsAString& text);
static void GetModifierSeparatorText(nsAString& text);
/**
* Returns if aContent has a tabbable subdocument.
* A sub document isn't tabbable when it's a zombie document.
@ -1688,6 +1729,11 @@ public:
*/
static bool AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal);
/**
* Perform cleanup that's appropriate for XPCOM shutdown.
*/
static void XPCOMShutdown();
enum ContentViewerType
{
TYPE_UNSUPPORTED,
@ -1750,6 +1796,10 @@ private:
nsIXPConnectJSObjectHolder** aHolder,
PRBool aAllowWrapping);
static void InitializeModifierStrings();
static void DropFragmentParsers();
static nsIDOMScriptObjectFactory *sDOMScriptObjectFactory;
static nsIXPConnect *sXPConnect;
@ -1812,6 +1862,16 @@ private:
static PRBool sIsHandlingKeyBoardEvent;
static PRBool sAllowXULXBL_for_file;
static nsAHtml5FragmentParser* sHTMLFragmentParser;
static nsIParser* sXMLFragmentParser;
static nsIFragmentContentSink* sXMLFragmentSink;
static nsString* sShiftText;
static nsString* sControlText;
static nsString* sMetaText;
static nsString* sAltText;
static nsString* sModifierSeparator;
};
#define NS_HOLD_JS_OBJECTS(obj, clazz) \

View File

@ -126,8 +126,8 @@ class Element;
#define NS_IDOCUMENT_IID \
{ 0x18e4d4bd, 0x006b, 0x4008, \
{ 0x90, 0x05, 0x27, 0x57, 0x35, 0xf0, 0xd4, 0x85 } }
{ 0xfac563fb, 0x2b6a, 0x4ac8, \
{ 0x85, 0xf7, 0xd5, 0x14, 0x4b, 0x3e, 0xce, 0x78 } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -1147,16 +1147,6 @@ public:
mMayStartLayout = aMayStartLayout;
}
// This method should return an addrefed nsIParser* or nsnull. Implementations
// should transfer ownership of the parser to the caller.
virtual already_AddRefed<nsIParser> GetFragmentParser() {
return nsnull;
}
virtual void SetFragmentParser(nsIParser* aParser) {
// Do nothing.
}
already_AddRefed<nsIDocumentEncoder> GetCachedEncoder()
{
return mCachedEncoder.forget();
@ -1386,7 +1376,8 @@ public:
* to nsPreloadURIs::PreloadURIs() in file nsParser.cpp whenever the
* parser-module is linked with gklayout-module.
*/
virtual void MaybePreLoadImage(nsIURI* uri) = 0;
virtual void MaybePreLoadImage(nsIURI* uri,
const nsAString& aCrossOriginAttr) = 0;
/**
* Called by nsParser to preload style sheets. Can also be merged into

View File

@ -103,6 +103,7 @@
#include "nsHTMLDNSPrefetch.h"
#include "nsISupportsPrimitives.h"
#include "mozilla/Preferences.h"
#include "nsParserConstants.h"
using namespace mozilla;
@ -335,6 +336,7 @@ nsContentSink::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
PRBool aWasAlternate,
nsresult aStatus)
{
NS_ASSERTION(!mFragmentMode, "How come a fragment parser observed sheets?");
if (!aWasAlternate) {
NS_ASSERTION(mPendingSheetCount > 0, "How'd that happen?");
--mPendingSheetCount;
@ -641,7 +643,7 @@ nsContentSink::ProcessLinkHeader(nsIContent* aElement,
while (*end != kNullCh && *end != kSemicolon && *end != kComma) {
PRUnichar ch = *end;
if (ch == kApostrophe || ch == kQuote || ch == kLessThan) {
if (ch == kQuote || ch == kLessThan) {
// quoted string
PRUnichar quote = ch;
@ -723,8 +725,7 @@ nsContentSink::ProcessLinkHeader(nsIContent* aElement,
value++;
}
if (((*value == kApostrophe) || (*value == kQuote)) &&
(*value == *last)) {
if ((*value == kQuote) && (*value == *last)) {
*last = kNullCh;
value++;
}
@ -874,12 +875,13 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
return NS_OK;
}
// If this is a fragment parser, we don't want to observe.
PRBool isAlternate;
rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, aAlternate,
this, &isAlternate);
mFragmentMode ? nsnull : this, &isAlternate);
NS_ENSURE_SUCCESS(rv, rv);
if (!isAlternate) {
if (!isAlternate && !mFragmentMode) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}

View File

@ -349,6 +349,8 @@ protected:
PRUint8 mIsDocumentObserver : 1;
// True if this is a fragment parser
PRUint8 mFragmentMode : 1;
// True to call prevent script execution in the fragment mode.
PRUint8 mPreventScriptExecution : 1;
//
// -- Can interrupt parsing members --

View File

@ -202,6 +202,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsHTMLMediaElement.h"
#endif
#include "nsDOMTouchEvent.h"
#include "nsIScriptElement.h"
#include "mozilla/Preferences.h"
@ -256,8 +257,18 @@ nsIInterfaceRequestor* nsContentUtils::sSameOriginChecker = nsnull;
PRBool nsContentUtils::sIsHandlingKeyBoardEvent = PR_FALSE;
PRBool nsContentUtils::sAllowXULXBL_for_file = PR_FALSE;
nsString* nsContentUtils::sShiftText = nsnull;
nsString* nsContentUtils::sControlText = nsnull;
nsString* nsContentUtils::sMetaText = nsnull;
nsString* nsContentUtils::sAltText = nsnull;
nsString* nsContentUtils::sModifierSeparator = nsnull;
PRBool nsContentUtils::sInitialized = PR_FALSE;
nsAHtml5FragmentParser* nsContentUtils::sHTMLFragmentParser = nsnull;
nsIParser* nsContentUtils::sXMLFragmentParser = nsnull;
nsIFragmentContentSink* nsContentUtils::sXMLFragmentSink = nsnull;
static PLDHashTable sEventListenerManagersHash;
class EventListenerManagerMapEntry : public PLDHashEntryHdr
@ -382,6 +393,81 @@ nsContentUtils::Init()
return NS_OK;
}
void
nsContentUtils::GetShiftText(nsAString& text)
{
if (!sShiftText)
InitializeModifierStrings();
text.Assign(*sShiftText);
}
void
nsContentUtils::GetControlText(nsAString& text)
{
if (!sControlText)
InitializeModifierStrings();
text.Assign(*sControlText);
}
void
nsContentUtils::GetMetaText(nsAString& text)
{
if (!sMetaText)
InitializeModifierStrings();
text.Assign(*sMetaText);
}
void
nsContentUtils::GetAltText(nsAString& text)
{
if (!sAltText)
InitializeModifierStrings();
text.Assign(*sAltText);
}
void
nsContentUtils::GetModifierSeparatorText(nsAString& text)
{
if (!sModifierSeparator)
InitializeModifierStrings();
text.Assign(*sModifierSeparator);
}
void
nsContentUtils::InitializeModifierStrings()
{
//load the display strings for the keyboard accelerators
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
nsCOMPtr<nsIStringBundle> bundle;
nsresult rv = NS_OK;
if (bundleService) {
rv = bundleService->CreateBundle( "chrome://global-platform/locale/platformKeys.properties",
getter_AddRefs(bundle));
}
NS_ASSERTION(NS_SUCCEEDED(rv) && bundle, "chrome://global/locale/platformKeys.properties could not be loaded");
nsXPIDLString shiftModifier;
nsXPIDLString metaModifier;
nsXPIDLString altModifier;
nsXPIDLString controlModifier;
nsXPIDLString modifierSeparator;
if (bundle) {
//macs use symbols for each modifier key, so fetch each from the bundle, which also covers i18n
bundle->GetStringFromName(NS_LITERAL_STRING("VK_SHIFT").get(), getter_Copies(shiftModifier));
bundle->GetStringFromName(NS_LITERAL_STRING("VK_META").get(), getter_Copies(metaModifier));
bundle->GetStringFromName(NS_LITERAL_STRING("VK_ALT").get(), getter_Copies(altModifier));
bundle->GetStringFromName(NS_LITERAL_STRING("VK_CONTROL").get(), getter_Copies(controlModifier));
bundle->GetStringFromName(NS_LITERAL_STRING("MODIFIER_SEPARATOR").get(), getter_Copies(modifierSeparator));
}
//if any of these don't exist, we get an empty string
sShiftText = new nsString(shiftModifier);
sMetaText = new nsString(metaModifier);
sAltText = new nsString(altModifier);
sControlText = new nsString(controlModifier);
sModifierSeparator = new nsString(modifierSeparator);
}
bool nsContentUtils::sImgLoaderInitialized;
void
@ -1146,6 +1232,17 @@ nsContentUtils::Shutdown()
delete sBlockedScriptRunners;
sBlockedScriptRunners = nsnull;
delete sShiftText;
sShiftText = nsnull;
delete sControlText;
sControlText = nsnull;
delete sMetaText;
sMetaText = nsnull;
delete sAltText;
sAltText = nsnull;
delete sModifierSeparator;
sModifierSeparator = nsnull;
NS_IF_RELEASE(sSameOriginChecker);
nsTextEditorState::ShutDown();
@ -3514,14 +3611,12 @@ nsContentUtils::IsValidNodeName(nsIAtom *aLocalName, nsIAtom *aPrefix,
nsresult
nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
const nsAString& aFragment,
PRBool aWillOwnFragment,
PRBool aPreventScriptExecution,
nsIDOMDocumentFragment** aReturn)
{
*aReturn = nsnull;
NS_ENSURE_ARG(aContextNode);
nsresult rv;
// If we don't have a document here, we can't get the right security context
// for compiling event handlers... so just bail out.
nsCOMPtr<nsIDocument> document = aContextNode->GetOwnerDoc();
@ -3533,24 +3628,9 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
NS_ASSERTION(!isHTML || htmlDoc, "Should have HTMLDocument here!");
#endif
if (isHTML && nsHtml5Module::sEnabled) {
// See if the document has a cached fragment parser. nsHTMLDocument is the
// only one that should really have one at the moment.
nsCOMPtr<nsIParser> parser = document->GetFragmentParser();
if (parser) {
// Get the parser ready to use.
parser->Reset();
}
else {
// Create a new parser for this operation.
parser = nsHtml5Module::NewHtml5Parser();
if (!parser) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
if (isHTML) {
nsCOMPtr<nsIDOMDocumentFragment> frag;
rv = NS_NewDocumentFragment(getter_AddRefs(frag), document->NodeInfoManager());
NS_ENSURE_SUCCESS(rv, rv);
NS_NewDocumentFragment(getter_AddRefs(frag), document->NodeInfoManager());
nsCOMPtr<nsIContent> contextAsContent = do_QueryInterface(aContextNode);
if (contextAsContent && !contextAsContent->IsElement()) {
@ -3561,31 +3641,26 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
}
}
nsAHtml5FragmentParser* asFragmentParser =
static_cast<nsAHtml5FragmentParser*> (parser.get());
nsCOMPtr<nsIContent> fragment = do_QueryInterface(frag);
if (contextAsContent &&
!(nsGkAtoms::html == contextAsContent->Tag() &&
contextAsContent->IsHTML())) {
asFragmentParser->ParseHtml5Fragment(aFragment,
fragment,
contextAsContent->Tag(),
contextAsContent->GetNameSpaceID(),
(document->GetCompatibilityMode() ==
eCompatibility_NavQuirks),
PR_FALSE);
if (contextAsContent && !contextAsContent->IsHTML(nsGkAtoms::html)) {
ParseFragmentHTML(aFragment,
fragment,
contextAsContent->Tag(),
contextAsContent->GetNameSpaceID(),
(document->GetCompatibilityMode() ==
eCompatibility_NavQuirks),
aPreventScriptExecution);
} else {
asFragmentParser->ParseHtml5Fragment(aFragment,
fragment,
nsGkAtoms::body,
kNameSpaceID_XHTML,
(document->GetCompatibilityMode() ==
eCompatibility_NavQuirks),
PR_FALSE);
ParseFragmentHTML(aFragment,
fragment,
nsGkAtoms::body,
kNameSpaceID_XHTML,
(document->GetCompatibilityMode() ==
eCompatibility_NavQuirks),
aPreventScriptExecution);
}
frag.swap(*aReturn);
document->SetFragmentParser(parser);
frag.forget(aReturn);
return NS_OK;
}
@ -3644,84 +3719,94 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
content = content->GetParent();
}
nsCAutoString contentType;
nsAutoString buf;
document->GetContentType(buf);
LossyCopyUTF16toASCII(buf, contentType);
return ParseFragmentXML(aFragment,
document,
tagStack,
aPreventScriptExecution,
aReturn);
}
// See if the document has a cached fragment parser. nsHTMLDocument is the
// only one that should really have one at the moment.
nsCOMPtr<nsIParser> parser = document->GetFragmentParser();
if (parser) {
// Get the parser ready to use.
parser->Reset();
/* static */
void
nsContentUtils::DropFragmentParsers()
{
NS_IF_RELEASE(sHTMLFragmentParser);
NS_IF_RELEASE(sXMLFragmentParser);
NS_IF_RELEASE(sXMLFragmentSink);
}
/* static */
void
nsContentUtils::XPCOMShutdown()
{
nsContentUtils::DropFragmentParsers();
}
/* static */
void
nsContentUtils::ParseFragmentHTML(const nsAString& aSourceBuffer,
nsIContent* aTargetNode,
nsIAtom* aContextLocalName,
PRInt32 aContextNamespace,
PRBool aQuirks,
PRBool aPreventScriptExecution)
{
if (!sHTMLFragmentParser) {
sHTMLFragmentParser =
static_cast<nsAHtml5FragmentParser*>(nsHtml5Module::NewHtml5Parser().get());
// Now sHTMLFragmentParser owns the object
}
else {
// Create a new parser for this operation.
parser = do_CreateInstance(kCParserCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
sHTMLFragmentParser->ParseHtml5Fragment(aSourceBuffer,
aTargetNode,
aContextLocalName,
aContextNamespace,
aQuirks,
aPreventScriptExecution);
sHTMLFragmentParser->Reset();
}
/* static */
nsresult
nsContentUtils::ParseFragmentXML(const nsAString& aSourceBuffer,
nsIDocument* aDocument,
nsTArray<nsString>& aTagStack,
PRBool aPreventScriptExecution,
nsIDOMDocumentFragment** aReturn)
{
if (!sXMLFragmentParser) {
nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID);
parser.forget(&sXMLFragmentParser);
// sXMLFragmentParser now owns the parser
}
if (!sXMLFragmentSink) {
NS_NewXMLFragmentContentSink(&sXMLFragmentSink);
// sXMLFragmentSink now owns the sink
}
nsCOMPtr<nsIContentSink> contentsink = do_QueryInterface(sXMLFragmentSink);
NS_ABORT_IF_FALSE(contentsink, "Sink doesn't QI to nsIContentSink!");
sXMLFragmentParser->SetContentSink(contentsink);
sXMLFragmentSink->SetTargetDocument(aDocument);
sXMLFragmentSink->SetPreventScriptExecution(aPreventScriptExecution);
nsresult rv =
sXMLFragmentParser->ParseFragment(aSourceBuffer,
aTagStack);
if (NS_FAILED(rv)) {
// Drop the fragment parser and sink that might be in an inconsistent state
NS_IF_RELEASE(sXMLFragmentParser);
NS_IF_RELEASE(sXMLFragmentSink);
return rv;
}
// See if the parser already has a content sink that we can reuse.
nsCOMPtr<nsIFragmentContentSink> sink;
nsCOMPtr<nsIContentSink> contentsink = parser->GetContentSink();
if (contentsink) {
// Make sure it's the correct type.
if (isHTML) {
nsCOMPtr<nsIHTMLContentSink> htmlsink = do_QueryInterface(contentsink);
sink = do_QueryInterface(htmlsink);
}
else {
nsCOMPtr<nsIXMLContentSink> xmlsink = do_QueryInterface(contentsink);
sink = do_QueryInterface(xmlsink);
}
}
rv = sXMLFragmentSink->FinishFragmentParsing(aReturn);
if (!sink) {
// Either there was no cached content sink or it was the wrong type. Make a
// new one.
if (isHTML) {
rv = NS_NewHTMLFragmentContentSink(getter_AddRefs(sink));
} else {
rv = NS_NewXMLFragmentContentSink(getter_AddRefs(sink));
}
NS_ENSURE_SUCCESS(rv, rv);
contentsink = do_QueryInterface(sink);
NS_ASSERTION(contentsink, "Sink doesn't QI to nsIContentSink!");
parser->SetContentSink(contentsink);
}
sink->SetTargetDocument(document);
nsDTDMode mode = eDTDMode_autodetect;
switch (document->GetCompatibilityMode()) {
case eCompatibility_NavQuirks:
mode = eDTDMode_quirks;
break;
case eCompatibility_AlmostStandards:
mode = eDTDMode_almost_standards;
break;
case eCompatibility_FullStandards:
mode = eDTDMode_full_standards;
break;
default:
NS_NOTREACHED("unknown mode");
break;
}
rv = parser->ParseFragment(aFragment, nsnull, tagStack,
!isHTML, contentType, mode);
if (NS_SUCCEEDED(rv)) {
rv = sink->GetFragment(aWillOwnFragment, aReturn);
}
document->SetFragmentParser(parser);
sXMLFragmentParser->Reset();
return rv;
}
/* static */
nsresult
nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,

View File

@ -203,6 +203,8 @@
#include "mozilla/Preferences.h"
#include "imgILoader.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -7668,7 +7670,7 @@ FireOrClearDelayedEvents(nsTArray<nsCOMPtr<nsIDocument> >& aDocuments,
}
void
nsDocument::MaybePreLoadImage(nsIURI* uri)
nsDocument::MaybePreLoadImage(nsIURI* uri, const nsAString &aCrossOriginAttr)
{
// Early exit if the img is already present in the img-cache
// which indicates that the "real" load has already started and
@ -7680,6 +7682,16 @@ nsDocument::MaybePreLoadImage(nsIURI* uri)
return;
}
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
if (aCrossOriginAttr.LowerCaseEqualsLiteral("anonymous")) {
loadFlags |= imgILoader::LOAD_CORS_ANONYMOUS;
} else if (aCrossOriginAttr.LowerCaseEqualsLiteral("use-credentials")) {
loadFlags |= imgILoader::LOAD_CORS_USE_CREDENTIALS;
}
// else should we err on the side of not doing the preload if
// aCrossOriginAttr is nonempty? Let's err on the side of doing the
// preload as CORS_NONE.
// Image not in cache - trigger preload
nsCOMPtr<imgIRequest> request;
nsresult rv =
@ -7688,7 +7700,7 @@ nsDocument::MaybePreLoadImage(nsIURI* uri)
NodePrincipal(),
mDocumentURI, // uri of document used as referrer
nsnull, // no observer
nsIRequest::LOAD_NORMAL,
loadFlags,
getter_AddRefs(request));
// Pin image-reference to avoid evicting it from the img-cache before

View File

@ -885,7 +885,8 @@ public:
void MaybeEndOutermostXBLUpdate();
virtual void MaybePreLoadImage(nsIURI* uri);
virtual void MaybePreLoadImage(nsIURI* uri,
const nsAString &aCrossOriginAttr);
virtual void PreloadStyle(nsIURI* uri, const nsAString& charset);

View File

@ -4313,20 +4313,15 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aEventName,
}
NS_PRECONDITION(aEventName, "Must have event name!");
nsCOMPtr<nsISupports> target;
PRBool defer = PR_TRUE;
nsRefPtr<nsEventListenerManager> manager;
GetEventListenerManagerForAttr(getter_AddRefs(manager),
getter_AddRefs(target),
&defer);
nsEventListenerManager* manager = GetEventListenerManagerForAttr(&defer);
if (!manager) {
return NS_OK;
}
defer = defer && aDefer; // only defer if everyone agrees...
PRUint32 lang = GetScriptTypeID();
manager->AddScriptEventListener(target, aEventName, aValue, lang, defer,
manager->AddScriptEventListener(aEventName, aValue, lang, defer,
!nsContentUtils::IsChromeDoc(ownerDoc));
return NS_OK;
}
@ -4595,17 +4590,11 @@ nsGenericElement::SetMappedAttribute(nsIDocument* aDocument,
return PR_FALSE;
}
nsresult
nsGenericElement::GetEventListenerManagerForAttr(nsEventListenerManager** aManager,
nsISupports** aTarget,
PRBool* aDefer)
nsEventListenerManager*
nsGenericElement::GetEventListenerManagerForAttr(PRBool* aDefer)
{
*aManager = GetListenerManager(PR_TRUE);
*aDefer = PR_TRUE;
NS_ENSURE_STATE(*aManager);
NS_ADDREF(*aManager);
NS_ADDREF(*aTarget = static_cast<nsIContent*>(this));
return NS_OK;
return GetListenerManager(PR_TRUE);
}
nsGenericElement::nsAttrInfo

View File

@ -784,10 +784,8 @@ protected:
* Hook to allow subclasses to produce a different nsEventListenerManager if
* needed for attachment of attribute-defined handlers
*/
virtual nsresult
GetEventListenerManagerForAttr(nsEventListenerManager** aManager,
nsISupports** aTarget,
PRBool* aDefer);
virtual nsEventListenerManager*
GetEventListenerManagerForAttr(PRBool* aDefer);
/**
* Copy attributes and state to another element

View File

@ -73,6 +73,7 @@
#include "nsIEditor.h"
#include "nsIHTMLEditor.h"
#include "mozilla/dom/Element.h"
#include "nsParserConstants.h"
using namespace mozilla::dom;

View File

@ -40,12 +40,12 @@
*/
#include "nsParserUtils.h"
#include "nsIParser.h" // for kQuote et. al.
#include "jsapi.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "nsContentUtils.h"
#include "nsIParserService.h"
#include "nsParserConstants.h"
#define SKIP_WHITESPACE(iter, end_iter, end_res) \
while ((iter) != (end_iter) && nsCRT::IsAsciiSpace(*(iter))) { \

View File

@ -2054,7 +2054,7 @@ nsRange::CreateContextualFragment(const nsAString& aFragment,
{
if (mIsPositioned) {
return nsContentUtils::CreateContextualFragment(mStartParent, aFragment,
PR_TRUE, aReturn);
PR_FALSE, aReturn);
}
return NS_ERROR_FAILURE;
}

View File

@ -68,6 +68,7 @@
#include "nsLWBrkCIID.h"
#include "nsIScriptElement.h"
#include "nsAttrName.h"
#include "nsParserConstants.h"
static const char kMozStr[] = "moz";

View File

@ -65,6 +65,7 @@
#include "nsAttrName.h"
#include "nsILineBreaker.h"
#include "mozilla/dom/Element.h"
#include "nsParserConstants.h"
using namespace mozilla::dom;

View File

@ -588,7 +588,6 @@ nsEventListenerManager::FindJSEventListener(PRUint32 aEventType,
nsresult
nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
void *aScopeObject,
nsISupports *aObject,
nsIAtom* aName,
PRBool aIsString,
PRBool aPermitUntrustedEvents)
@ -601,7 +600,7 @@ nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
// If we didn't find a script listener or no listeners existed
// create and add a new one.
nsCOMPtr<nsIDOMEventListener> scriptListener;
rv = NS_NewJSEventListener(aContext, aScopeObject, aObject, aName,
rv = NS_NewJSEventListener(aContext, aScopeObject, mTarget, aName,
getter_AddRefs(scriptListener));
if (NS_SUCCEEDED(rv)) {
AddEventListener(scriptListener, eventType, aName, nsnull,
@ -624,8 +623,7 @@ nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
}
nsresult
nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
nsIAtom *aName,
nsEventListenerManager::AddScriptEventListener(nsIAtom *aName,
const nsAString& aBody,
PRUint32 aLanguage,
PRBool aDeferCompilation,
@ -646,11 +644,10 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsINode> node(do_QueryInterface(aObject));
nsCOMPtr<nsINode> node(do_QueryInterface(mTarget));
nsCOMPtr<nsIDocument> doc;
nsISupports *objiSupp = aObject;
nsCOMPtr<nsIScriptGlobalObject> global;
if (node) {
@ -661,7 +658,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
if (doc)
global = doc->GetScriptGlobalObject();
} else {
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aObject));
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mTarget));
if (win) {
NS_ASSERTION(win->IsInnerWindow(),
"Event listener added to outer window!");
@ -671,7 +668,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
doc = do_QueryInterface(domdoc);
global = do_QueryInterface(win);
} else {
global = do_QueryInterface(aObject);
global = do_QueryInterface(mTarget);
}
}
@ -702,7 +699,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
uri->GetAsciiSpec(asciiSpec);
nsAutoString scriptSample, attr, tagName(NS_LITERAL_STRING("UNKNOWN"));
aName->ToString(attr);
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(aObject));
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mTarget));
if (domNode)
domNode->GetNodeName(tagName);
// build a "script sample" based on what we know about this element
@ -733,7 +730,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
if (!aDeferCompilation) {
nsCOMPtr<nsIScriptEventHandlerOwner> handlerOwner =
do_QueryInterface(aObject);
do_QueryInterface(mTarget);
nsScriptObjectHolder handler(context);
PRBool done = PR_FALSE;
@ -741,7 +738,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
if (handlerOwner) {
rv = handlerOwner->GetCompiledEventHandler(aName, handler);
if (NS_SUCCEEDED(rv) && handler) {
rv = context->BindCompiledEventHandler(aObject, scope, aName, handler);
rv = context->BindCompiledEventHandler(mTarget, scope, aName, handler);
if (NS_FAILED(rv))
return rv;
done = PR_TRUE;
@ -762,7 +759,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
if (handlerOwner) {
// Always let the handler owner compile the event handler, as
// it may want to use a special context or scope object.
rv = handlerOwner->CompileEventHandler(context, aObject, aName,
rv = handlerOwner->CompileEventHandler(context, mTarget, aName,
aBody, url.get(), lineNo, handler);
}
else {
@ -797,14 +794,14 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
}
NS_ENSURE_SUCCESS(rv, rv);
// And bind it.
rv = context->BindCompiledEventHandler(aObject, scope,
rv = context->BindCompiledEventHandler(mTarget, scope,
aName, handler);
}
if (NS_FAILED(rv)) return rv;
}
}
return SetJSEventListener(context, scope, objiSupp, aName, aDeferCompilation,
return SetJSEventListener(context, scope, aName, aDeferCompilation,
aPermitUntrustedEvents);
}
@ -827,7 +824,6 @@ nsEventListenerManager::sAddListenerID = JSID_VOID;
nsresult
nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
void *aScope,
nsISupports *aObject,
nsIAtom *aName)
{
// Check that we have access to set an event listener. Prevents
@ -835,7 +831,7 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
// for instance.
// You'd think it'd work just to get the JSContext from aContext,
// but that's actually the JSContext whose private object parents
// the object in aObject.
// the object in mTarget.
nsresult rv;
nsCOMPtr<nsIJSContextStack> stack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
@ -855,7 +851,7 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
if (aContext->GetScriptTypeID() == nsIProgrammingLanguage::JAVASCRIPT) {
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
jsval v;
rv = nsContentUtils::WrapNative(cx, (JSObject *)aScope, aObject, &v,
rv = nsContentUtils::WrapNative(cx, (JSObject *)aScope, mTarget, &v,
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
@ -876,14 +872,13 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
// Untrusted events are always permitted for non-chrome script
// handlers.
return SetJSEventListener(aContext, aScope, aObject, aName,
PR_FALSE, !nsContentUtils::IsCallerChrome());
return SetJSEventListener(aContext, aScope, aName, PR_FALSE,
!nsContentUtils::IsCallerChrome());
}
nsresult
nsEventListenerManager::CompileScriptEventListener(nsIScriptContext *aContext,
void *aScope,
nsISupports *aObject,
nsIAtom *aName,
PRBool *aDidCompile)
{
@ -898,7 +893,7 @@ nsEventListenerManager::CompileScriptEventListener(nsIScriptContext *aContext,
}
if (ls->mHandlerIsString) {
rv = CompileEventHandlerInternal(aContext, aScope, aObject, aName,
rv = CompileEventHandlerInternal(aContext, aScope, mTarget, aName,
ls, /*XXX fixme*/nsnull, PR_TRUE);
}

View File

@ -107,20 +107,17 @@ public:
void RemoveEventListenerByType(nsIDOMEventListener *aListener,
const nsAString& type,
PRInt32 aFlags);
nsresult AddScriptEventListener(nsISupports *aObject,
nsIAtom *aName,
nsresult AddScriptEventListener(nsIAtom *aName,
const nsAString& aFunc,
PRUint32 aLanguage,
PRBool aDeferCompilation,
PRBool aPermitUntrustedEvents);
nsresult RegisterScriptEventListener(nsIScriptContext *aContext,
void *aScopeObject,
nsISupports *aObject,
nsIAtom* aName);
void RemoveScriptEventListener(nsIAtom *aName);
nsresult CompileScriptEventListener(nsIScriptContext *aContext,
void *aScopeObject,
nsISupports *aObject,
nsIAtom* aName, PRBool *aDidCompile);
void HandleEvent(nsPresContext* aPresContext,
@ -216,7 +213,6 @@ protected:
nsListenerStruct* FindJSEventListener(PRUint32 aEventType, nsIAtom* aTypeAtom);
nsresult SetJSEventListener(nsIScriptContext *aContext,
void *aScopeGlobal,
nsISupports *aObject,
nsIAtom* aName, PRBool aIsString,
PRBool aPermitUntrustedEvents);
nsresult AddEventListener(nsIDOMEventListener *aListener,

View File

@ -1508,6 +1508,35 @@ nsEventStateManager::ExecuteAccessKey(nsTArray<PRUint32>& aAccessCharCodes,
return PR_FALSE;
}
PRBool
nsEventStateManager::GetAccessKeyLabelPrefix(nsAString& aPrefix)
{
aPrefix.Truncate();
nsAutoString separator, modifierText;
nsContentUtils::GetModifierSeparatorText(separator);
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
PRInt32 modifier = GetAccessModifierMask(container);
if (modifier & NS_MODIFIER_CONTROL) {
nsContentUtils::GetControlText(modifierText);
aPrefix.Append(modifierText + separator);
}
if (modifier & NS_MODIFIER_META) {
nsContentUtils::GetMetaText(modifierText);
aPrefix.Append(modifierText + separator);
}
if (modifier & NS_MODIFIER_ALT) {
nsContentUtils::GetAltText(modifierText);
aPrefix.Append(modifierText + separator);
}
if (modifier & NS_MODIFIER_SHIFT) {
nsContentUtils::GetShiftText(modifierText);
aPrefix.Append(modifierText + separator);
}
return !aPrefix.IsEmpty();
}
void
nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext,
nsKeyEvent *aEvent,

View File

@ -160,6 +160,8 @@ public:
*/
PRUint32 GetRegisteredAccessKey(nsIContent* aContent);
PRBool GetAccessKeyLabelPrefix(nsAString& aPrefix);
nsresult SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
PRBool aHaveHotspot, float aHotspotX, float aHotspotY,
nsIWidget* aWidget, PRBool aLockCursor);

View File

@ -463,6 +463,21 @@ nsGenericHTMLElement::SetClassName(const nsAString& aClassName)
NS_IMPL_STRING_ATTR(nsGenericHTMLElement, AccessKey, accesskey)
NS_IMETHODIMP
nsGenericHTMLElement::GetAccessKeyLabel(nsAString& aLabel)
{
nsPresContext *presContext = GetPresContext();
if (presContext &&
presContext->EventStateManager()->GetAccessKeyLabelPrefix(aLabel)) {
nsAutoString suffix;
GetAccessKey(suffix);
aLabel.Append(suffix);
}
return NS_OK;
}
static PRBool
IsBody(nsIContent *aContent)
{
@ -706,6 +721,26 @@ nsGenericHTMLElement::GetInnerHTML(nsAString& aInnerHTML)
return rv;
}
void
nsGenericHTMLElement::FireMutationEventsForDirectParsing(nsIDocument* aDoc,
nsIContent* aDest,
PRInt32 aOldChildCount)
{
// Fire mutation events. Optimize for the case when there are no listeners
PRInt32 newChildCount = aDest->GetChildCount();
if (newChildCount && nsContentUtils::
HasMutationListeners(aDoc, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
nsAutoTArray<nsCOMPtr<nsIContent>, 50> childNodes;
NS_ASSERTION(newChildCount - aOldChildCount >= 0,
"What, some unexpected dom mutation has happened?");
childNodes.SetCapacity(newChildCount - aOldChildCount);
for (nsINode::ChildIterator iter(aDest); !iter.IsDone(); iter.Next()) {
childNodes.AppendElement(iter);
}
nsGenericElement::FireNodeInserted(aDoc, aDest, childNodes);
}
}
nsresult
nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
{
@ -719,8 +754,7 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
FireNodeRemovedForChildren();
// This BeginUpdate/EndUpdate pair is important to make us reenable the
// scriptloader before the last EndUpdate call.
// Needed when innerHTML is used in combination with contenteditable
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, PR_TRUE);
// Remove childnodes.
@ -731,48 +765,20 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
nsCOMPtr<nsIDOMDocumentFragment> df;
// Strong ref since appendChild can fire events
nsRefPtr<nsScriptLoader> loader = doc->ScriptLoader();
PRBool 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);
}
if (doc->IsHTML()) {
PRInt32 oldChildCount = GetChildCount();
nsAHtml5FragmentParser* asFragmentParser =
static_cast<nsAHtml5FragmentParser*> (parser.get());
asFragmentParser->ParseHtml5Fragment(aInnerHTML,
this,
Tag(),
GetNameSpaceID(),
doc->GetCompatibilityMode() ==
eCompatibility_NavQuirks,
PR_TRUE);
doc->SetFragmentParser(parser);
nsContentUtils::ParseFragmentHTML(aInnerHTML,
this,
Tag(),
GetNameSpaceID(),
doc->GetCompatibilityMode() ==
eCompatibility_NavQuirks,
PR_TRUE);
// HTML5 parser has notified, but not fired mutation events.
// Fire mutation events. Optimize for the case when there are no listeners
PRInt32 newChildCount = GetChildCount();
if (newChildCount && nsContentUtils::
HasMutationListeners(doc, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
nsAutoTArray<nsCOMPtr<nsIContent>, 50> 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.AppendElement(iter);
}
nsGenericElement::FireNodeInserted(doc, this, childNodes);
}
FireMutationEventsForDirectParsing(doc, this, oldChildCount);
} else {
rv = nsContentUtils::CreateContextualFragment(this, aInnerHTML, PR_FALSE,
rv = nsContentUtils::CreateContextualFragment(this, aInnerHTML,
PR_TRUE,
getter_AddRefs(df));
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
if (NS_SUCCEEDED(rv)) {
@ -780,13 +786,104 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
}
}
if (scripts_enabled) {
// If we disabled scripts, re-enable them now that we're
// done. Don't fire JS timeouts when enabling the context here.
return rv;
}
loader->SetEnabled(PR_TRUE);
enum nsAdjacentPosition {
eBeforeBegin,
eAfterBegin,
eBeforeEnd,
eAfterEnd
};
nsresult
nsGenericHTMLElement::InsertAdjacentHTML(const nsAString& aPosition,
const nsAString& aText)
{
nsAdjacentPosition position;
if (aPosition.LowerCaseEqualsLiteral("beforebegin")) {
position = eBeforeBegin;
} else if (aPosition.LowerCaseEqualsLiteral("afterbegin")) {
position = eAfterBegin;
} else if (aPosition.LowerCaseEqualsLiteral("beforeend")) {
position = eBeforeEnd;
} else if (aPosition.LowerCaseEqualsLiteral("afterend")) {
position = eAfterEnd;
} else {
return NS_ERROR_DOM_SYNTAX_ERR;
}
nsCOMPtr<nsIContent> destination;
if (position == eBeforeBegin || position == eAfterEnd) {
destination = GetParent();
if (!destination) {
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
}
} else {
destination = this;
}
nsIDocument* doc = GetOwnerDoc();
NS_ENSURE_STATE(doc);
// Needed when insertAdjacentHTML is used in combination with contenteditable
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, PR_TRUE);
// Batch possible DOMSubtreeModified events.
mozAutoSubtreeModified subtree(doc, nsnull);
// Parse directly into destination if possible
if (doc->IsHTML() &&
(position == eBeforeEnd ||
(position == eAfterEnd && !GetNextSibling()) ||
(position == eAfterBegin && !GetFirstChild()))) {
PRInt32 oldChildCount = destination->GetChildCount();
PRInt32 contextNs = destination->GetNameSpaceID();
nsIAtom* contextLocal = destination->Tag();
if (contextLocal == nsGkAtoms::html && contextNs == kNameSpaceID_XHTML) {
// For compat with IE6 through IE9. Willful violation of HTML5 as of
// 2011-04-06. CreateContextualFragment does the same already.
// Spec bug: http://www.w3.org/Bugs/Public/show_bug.cgi?id=12434
contextLocal = nsGkAtoms::body;
}
nsContentUtils::ParseFragmentHTML(aText,
destination,
contextLocal,
contextNs,
doc->GetCompatibilityMode() ==
eCompatibility_NavQuirks,
PR_TRUE);
// HTML5 parser has notified, but not fired mutation events.
FireMutationEventsForDirectParsing(doc, destination, oldChildCount);
return NS_OK;
}
// couldn't parse directly
nsCOMPtr<nsIDOMDocumentFragment> df;
nsresult rv = nsContentUtils::CreateContextualFragment(destination,
aText,
PR_TRUE,
getter_AddRefs(df));
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
NS_ENSURE_SUCCESS(rv, rv);
switch (position) {
case eBeforeBegin:
destination->InsertBefore(fragment, this, &rv);
break;
case eAfterBegin:
static_cast<nsINode*>(this)->InsertBefore(fragment, GetFirstChild(), &rv);
break;
case eBeforeEnd:
static_cast<nsINode*>(this)->AppendChild(fragment, &rv);
break;
case eAfterEnd:
destination->InsertBefore(fragment, GetNextSibling(), &rv);
break;
default:
NS_NOTREACHED("Bad position.");
break;
}
return rv;
}
@ -1123,10 +1220,8 @@ nsGenericHTMLElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
aValue, aNotify);
}
nsresult
nsGenericHTMLElement::GetEventListenerManagerForAttr(nsEventListenerManager** aManager,
nsISupports** aTarget,
PRBool* aDefer)
nsEventListenerManager*
nsGenericHTMLElement::GetEventListenerManagerForAttr(PRBool* aDefer)
{
// Attributes on the body and frameset tags get set on the global object
if (mNodeInfo->Equals(nsGkAtoms::body) ||
@ -1139,36 +1234,23 @@ nsGenericHTMLElement::GetEventListenerManagerForAttr(nsEventListenerManager** aM
// XXXbz sXBL/XBL2 issue: should we instead use GetCurrentDoc() here,
// override BindToTree for those classes and munge event listeners there?
nsIDocument *document = GetOwnerDoc();
nsresult rv = NS_OK;
// FIXME (https://bugzilla.mozilla.org/show_bug.cgi?id=431767)
// nsDocument::GetInnerWindow can return an outer window in some cases,
// we don't want to stick an event listener on an outer window, so
// bail if it does.
*aDefer = PR_FALSE;
if (document &&
(win = document->GetInnerWindow()) && win->IsInnerWindow()) {
nsCOMPtr<nsIDOMEventTarget> piTarget(do_QueryInterface(win));
NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
*aManager = piTarget->GetListenerManager(PR_TRUE);
if (*aManager) {
NS_ADDREF(*aTarget = win);
NS_ADDREF(*aManager);
}
*aDefer = PR_FALSE;
} else {
*aManager = nsnull;
*aTarget = nsnull;
*aDefer = PR_FALSE;
return piTarget->GetListenerManager(PR_TRUE);
}
return rv;
return nsnull;
}
return nsGenericHTMLElementBase::GetEventListenerManagerForAttr(aManager,
aTarget,
aDefer);
return nsGenericHTMLElementBase::GetEventListenerManagerForAttr(aDefer);
}
nsresult

View File

@ -135,6 +135,8 @@ public:
nsresult GetOffsetParent(nsIDOMElement** aOffsetParent);
virtual nsresult GetInnerHTML(nsAString& aInnerHTML);
virtual nsresult SetInnerHTML(const nsAString& aInnerHTML);
virtual nsresult InsertAdjacentHTML(const nsAString& aPosition,
const nsAString& aText);
nsresult ScrollIntoView(PRBool aTop, PRUint8 optional_argc);
// Declare Focus(), Blur(), GetTabIndex(), SetTabIndex(), GetHidden(),
// SetHidden(), GetSpellcheck(), SetSpellcheck(), and GetDraggable() such that
@ -152,6 +154,7 @@ public:
NS_IMETHOD SetDraggable(PRBool aDraggable);
NS_IMETHOD GetAccessKey(nsAString &aAccessKey);
NS_IMETHOD SetAccessKey(const nsAString& aAccessKey);
NS_IMETHOD GetAccessKeyLabel(nsAString& aLabel);
nsresult GetContentEditable(nsAString& aContentEditable);
nsresult GetIsContentEditable(PRBool* aContentEditable);
nsresult SetContentEditable(const nsAString &aContentEditable);
@ -570,6 +573,18 @@ protected:
}
private:
/**
* Fire mutation events for changes caused by parsing directly into a
* context node.
*
* @param aDoc the document of the node
* @param aDest the destination node that got stuff appended to it
* @param aOldChildCount the number of children the node had before parsing
*/
void FireMutationEventsForDirectParsing(nsIDocument* aDoc,
nsIContent* aDest,
PRInt32 aOldChildCount);
void RegUnRegAccessKey(PRBool aDoReg);
protected:
@ -583,10 +598,8 @@ protected:
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify);
virtual nsresult
GetEventListenerManagerForAttr(nsEventListenerManager** aManager,
nsISupports** aTarget,
PRBool* aDefer);
virtual nsEventListenerManager*
GetEventListenerManagerForAttr(PRBool* aDefer);
virtual const nsAttrName* InternalGetExistingAttrNameFromQName(const nsAString& aStr) const;
@ -1473,6 +1486,7 @@ protected:
NS_SCRIPTABLE NS_IMETHOD SetClassName(const nsAString & aClassName) { return _to SetClassName(aClassName); } \
NS_SCRIPTABLE NS_IMETHOD GetAccessKey(nsAString & aAccessKey) { return _to GetAccessKey(aAccessKey); } \
NS_SCRIPTABLE NS_IMETHOD SetAccessKey(const nsAString & aAccessKey) { return _to SetAccessKey(aAccessKey); } \
NS_SCRIPTABLE NS_IMETHOD GetAccessKeyLabel(nsAString & aLabel) { return _to GetAccessKeyLabel(aLabel); } \
NS_SCRIPTABLE NS_IMETHOD Blur(void) { return _to Blur(); }
/**

View File

@ -512,7 +512,6 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
rv = UpdateContext(contextProps);
if (NS_FAILED(rv)) {
mCurrentContext = nsnull;
if (!forceThebes) {
// Try again with a Thebes context
forceThebes = PR_TRUE;
@ -558,10 +557,7 @@ nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
mCurrentContext->SetIsIPC(PR_TRUE);
rv = UpdateContext();
if (NS_FAILED(rv)) {
mCurrentContext = nsnull;
return rv;
}
NS_ENSURE_SUCCESS(rv, rv);
mCurrentContextId.Assign(aContextId);
} else if (!mCurrentContextId.Equals(aContextId)) {

View File

@ -278,6 +278,7 @@ _TEST_FILES = \
test_bug666200.html \
test_bug666666.html \
test_bug674558.html \
test_bug583533.html \
test_restore_from_parser_fragment.html \
$(NULL)

View File

@ -0,0 +1,76 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=583533
-->
<head>
<title>Test for Bug 583514</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=583533">Mozilla Bug 583533</a>
<p id="display"></p>
<div id="content">
<div id="e" accesskey="a">
</div>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 583533 **/
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"].
getService(Components.interfaces.nsIStringBundleService);
var bundle = sbs.createBundle("chrome://global-platform/locale/platformKeys.properties");
var shiftText = bundle.GetStringFromName("VK_SHIFT");
var altText = bundle.GetStringFromName("VK_ALT");
var controlText = bundle.GetStringFromName("VK_CONTROL");
var metaText = bundle.GetStringFromName("VK_META");
var separatorText = bundle.GetStringFromName("MODIFIER_SEPARATOR");
var modifier = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch)
.getIntPref("ui.key.contentAccess");
var domEvent = Components.interfaces.nsIDOMNSEvent;
var isShift;
var isAlt;
var isControl;
var isMeta;
is(modifier < 16 && modifier >= 0, true, "Modifier in range");
if (modifier & domEvent.META_MASK)
isMeta = true;
if (modifier & domEvent.SHIFT_MASK)
isShift = true;
if (modifier & domEvent.CONTROL_MASK)
isControl = true;
if (modifier & domEvent.ALT_MASK)
isAlt = true;
var label = "";
if (isControl)
label += controlText + separatorText;
if (isMeta)
label += metaText + separatorText;
if (isAlt)
label += altText + separatorText;
if (isShift)
label += shiftText + separatorText;
label += document.getElementById("e").accessKey;
is(label, document.getElementById("e").accessKeyLabel, "JS and C++ agree on accessKeyLabel");
</script>
</pre>
</body>
</html>

View File

@ -49,7 +49,6 @@ LIBXUL_LIBRARY = 1
CPPSRCS = \
nsHTMLContentSink.cpp \
nsHTMLFragmentContentSink.cpp \
nsHTMLDocument.cpp \
ImageDocument.cpp \
MediaDocument.cpp \

View File

@ -2632,8 +2632,10 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
ssle->SetEnableUpdates(PR_TRUE);
PRBool willNotify;
PRBool isAlternate;
result = ssle->UpdateStyleSheet(this, &willNotify, &isAlternate);
if (NS_SUCCEEDED(result) && willNotify && !isAlternate) {
result = ssle->UpdateStyleSheet(mFragmentMode ? nsnull : this,
&willNotify,
&isAlternate);
if (NS_SUCCEEDED(result) && willNotify && !isAlternate && !mFragmentMode) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}
@ -2845,8 +2847,10 @@ HTMLContentSink::ProcessSTYLEEndTag(nsGenericHTMLElement* content)
ssle->SetEnableUpdates(PR_TRUE);
PRBool willNotify;
PRBool isAlternate;
rv = ssle->UpdateStyleSheet(this, &willNotify, &isAlternate);
if (NS_SUCCEEDED(rv) && willNotify && !isAlternate) {
rv = ssle->UpdateStyleSheet(mFragmentMode ? nsnull : this,
&willNotify,
&isAlternate);
if (NS_SUCCEEDED(rv) && willNotify && !isAlternate && !mFragmentMode) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}

View File

@ -285,7 +285,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLDocument, nsDocument)
nsIDOMNodeList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mWyciwygChannel)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mMidasCommandManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFragmentParser)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLDocument, nsDocument)
@ -298,7 +297,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLDocument, nsDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFormControls)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mWyciwygChannel)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mMidasCommandManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFragmentParser)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ADDREF_INHERITED(nsHTMLDocument, nsDocument)

View File

@ -194,13 +194,6 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLDocument, nsDocument)
virtual already_AddRefed<nsIParser> GetFragmentParser() {
return mFragmentParser.forget();
}
virtual void SetFragmentParser(nsIParser* aParser) {
mFragmentParser = aParser;
}
virtual nsresult SetEditingState(EditingState aState);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -342,9 +335,6 @@ protected:
// When false, the .cookies property is completely disabled
PRBool mDisableCookieAccess;
// Parser used for constructing document fragments.
nsCOMPtr<nsIParser> mFragmentParser;
};
#define NS_HTML_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \

View File

@ -1,780 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=2 et tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert Sayre <sayrer@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIFragmentContentSink.h"
#include "nsIDTD.h"
#include "nsIHTMLContentSink.h"
#include "nsIParser.h"
#include "nsIParserService.h"
#include "nsGkAtoms.h"
#include "nsHTMLTokens.h"
#include "nsGenericHTMLElement.h"
#include "nsIDOMText.h"
#include "nsIDOMComment.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMDocumentFragment.h"
#include "nsTArray.h"
#include "nsINameSpaceManager.h"
#include "nsIDocument.h"
#include "nsINodeInfo.h"
#include "prmem.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsContentUtils.h"
#include "nsEscape.h"
#include "nsNodeInfoManager.h"
#include "nsNullPrincipal.h"
#include "nsContentCreatorFunctions.h"
#include "nsNetUtil.h"
#include "nsIScriptSecurityManager.h"
#include "nsContentSink.h"
#include "nsTHashtable.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCSSParser.h"
#include "nsCSSProperty.h"
#include "mozilla/css/Declaration.h"
#include "mozilla/css/StyleRule.h"
#include "nsCSSStyleSheet.h"
#include "nsICSSRuleList.h"
#include "nsIDOMCSSRule.h"
using namespace mozilla::dom;
namespace css = mozilla::css;
//
// XXX THIS IS TEMPORARY CODE
// There's a considerable amount of copied code from the
// regular nsHTMLContentSink. All of it will be factored
// at some pointe really soon!
//
class nsHTMLFragmentContentSink : public nsIFragmentContentSink,
public nsIHTMLContentSink {
public:
/**
* @param aAllContent Whether there is context information available for the fragment.
*/
nsHTMLFragmentContentSink(PRBool aAllContent = PR_FALSE);
virtual ~nsHTMLFragmentContentSink();
// nsISupports
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHTMLFragmentContentSink,
nsIContentSink)
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
// nsIContentSink
NS_IMETHOD WillParse(void) { return NS_OK; }
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode);
NS_IMETHOD DidBuildModel(PRBool aTerminated);
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
virtual nsISupports *GetTarget() { return mTargetDocument; }
// nsIHTMLContentSink
NS_IMETHOD BeginContext(PRInt32 aID);
NS_IMETHOD EndContext(PRInt32 aID);
NS_IMETHOD OpenHead();
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn) {
*aReturn = PR_TRUE;
return NS_OK;
}
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }
NS_IMETHOD DidProcessAToken(void) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
// nsIFragmentContentSink
NS_IMETHOD GetFragment(PRBool aWillOwnFragment,
nsIDOMDocumentFragment** aFragment);
NS_IMETHOD SetTargetDocument(nsIDocument* aDocument);
NS_IMETHOD WillBuildContent();
NS_IMETHOD DidBuildContent();
NS_IMETHOD IgnoreFirstContainer();
nsIContent* GetCurrentContent();
PRInt32 PushContent(nsIContent *aContent);
nsIContent* PopContent();
virtual nsresult AddAttributes(const nsIParserNode& aNode,
nsIContent* aContent);
nsresult AddText(const nsAString& aString);
nsresult FlushText();
PRPackedBool mAllContent;
PRPackedBool mProcessing;
PRPackedBool mSeenBody;
PRPackedBool mIgnoreContainer;
PRPackedBool mIgnoreNextCloseHead;
nsCOMPtr<nsIContent> mRoot;
nsCOMPtr<nsIParser> mParser;
nsTArray<nsIContent*>* mContentStack;
PRUnichar* mText;
PRInt32 mTextLength;
PRInt32 mTextSize;
nsCOMPtr<nsIDocument> mTargetDocument;
nsRefPtr<nsNodeInfoManager> mNodeInfoManager;
nsINodeInfo* mNodeInfoCache[NS_HTML_TAG_MAX + 1];
};
static nsresult
NewHTMLFragmentContentSinkHelper(PRBool aAllContent, nsIFragmentContentSink** aResult)
{
NS_PRECONDITION(aResult, "Null out ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
nsHTMLFragmentContentSink* it = new nsHTMLFragmentContentSink(aAllContent);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aResult = it);
return NS_OK;
}
nsresult
NS_NewHTMLFragmentContentSink2(nsIFragmentContentSink** aResult)
{
return NewHTMLFragmentContentSinkHelper(PR_TRUE,aResult);
}
nsresult
NS_NewHTMLFragmentContentSink(nsIFragmentContentSink** aResult)
{
return NewHTMLFragmentContentSinkHelper(PR_FALSE,aResult);
}
nsHTMLFragmentContentSink::nsHTMLFragmentContentSink(PRBool aAllContent)
: mAllContent(aAllContent),
mProcessing(aAllContent),
mSeenBody(!aAllContent)
{
// Note: operator new zeros our memory
}
nsHTMLFragmentContentSink::~nsHTMLFragmentContentSink()
{
// Should probably flush the text buffer here, just to make sure:
//FlushText();
if (nsnull != mContentStack) {
// there shouldn't be anything here except in an error condition
PRInt32 indx = mContentStack->Length();
while (0 < indx--) {
nsIContent* content = mContentStack->ElementAt(indx);
NS_RELEASE(content);
}
delete mContentStack;
}
PR_FREEIF(mText);
PRUint32 i;
for (i = 0; i < NS_ARRAY_LENGTH(mNodeInfoCache); ++i) {
NS_IF_RELEASE(mNodeInfoCache[i]);
}
}
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsHTMLFragmentContentSink)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsHTMLFragmentContentSink)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsHTMLFragmentContentSink)
NS_INTERFACE_MAP_ENTRY(nsIFragmentContentSink)
NS_INTERFACE_MAP_ENTRY(nsIHTMLContentSink)
NS_INTERFACE_MAP_ENTRY(nsIContentSink)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentSink)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLFragmentContentSink)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHTMLFragmentContentSink)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParser)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTargetDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mRoot)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsHTMLFragmentContentSink)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mParser)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTargetDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRoot)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mNodeInfoManager,
nsNodeInfoManager)
{
PRUint32 i;
for (i = 0; i < NS_ARRAY_LENGTH(tmp->mNodeInfoCache); ++i) {
cb.NoteXPCOMChild(tmp->mNodeInfoCache[i]);
}
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMETHODIMP
nsHTMLFragmentContentSink::WillBuildModel(nsDTDMode)
{
if (mRoot) {
return NS_OK;
}
NS_ASSERTION(mNodeInfoManager, "Need a nodeinfo manager!");
nsCOMPtr<nsIDOMDocumentFragment> frag;
nsresult rv = NS_NewDocumentFragment(getter_AddRefs(frag), mNodeInfoManager);
NS_ENSURE_SUCCESS(rv, rv);
mRoot = do_QueryInterface(frag, &rv);
return rv;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::DidBuildModel(PRBool aTerminated)
{
FlushText();
// Drop our reference to the parser to get rid of a circular
// reference.
mParser = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::WillInterrupt(void)
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::WillResume(void)
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::SetParser(nsIParser* aParser)
{
mParser = aParser;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::BeginContext(PRInt32 aID)
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::EndContext(PRInt32 aID)
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenHead()
{
mIgnoreNextCloseHead = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
{
NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_NOT_INITIALIZED);
nsresult result = NS_OK;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
if (nodeType == eHTMLTag_html) {
return NS_OK;
}
// Ignore repeated BODY elements. The DTD is just sending them
// to us for compatibility reasons that don't apply here.
if (nodeType == eHTMLTag_body) {
if (mSeenBody) {
return NS_OK;
}
mSeenBody = PR_TRUE;
}
if (mProcessing && !mIgnoreContainer) {
FlushText();
nsIContent *content = nsnull;
nsCOMPtr<nsINodeInfo> nodeInfo;
if (nodeType == eHTMLTag_userdefined) {
nsAutoString lower;
nsContentUtils::ASCIIToLower(aNode.GetText(), lower);
nsCOMPtr<nsIAtom> name = do_GetAtom(lower);
nodeInfo = mNodeInfoManager->GetNodeInfo(name,
nsnull,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
}
else if (mNodeInfoCache[nodeType]) {
nodeInfo = mNodeInfoCache[nodeType];
}
else {
nsIParserService* parserService = nsContentUtils::GetParserService();
if (!parserService)
return NS_ERROR_OUT_OF_MEMORY;
nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
NS_ASSERTION(name, "This should not happen!");
nodeInfo = mNodeInfoManager->GetNodeInfo(name,
nsnull,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
}
content =
CreateHTMLElement(nodeType, nodeInfo.forget(), NOT_FROM_PARSER).get();
NS_ENSURE_TRUE(content, NS_ERROR_OUT_OF_MEMORY);
result = AddAttributes(aNode, content);
if (NS_FAILED(result)) {
NS_RELEASE(content);
return result;
}
nsIContent *parent = GetCurrentContent();
if (!parent) {
parent = mRoot;
}
parent->AppendChildTo(content, PR_FALSE);
PushContent(content);
}
else if (mProcessing && mIgnoreContainer) {
mIgnoreContainer = PR_FALSE;
}
return result;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseContainer(const nsHTMLTag aTag)
{
if (aTag == eHTMLTag_html) {
return NS_OK;
}
if (mIgnoreNextCloseHead && aTag == eHTMLTag_head) {
mIgnoreNextCloseHead = PR_FALSE;
return NS_OK;
}
if (mProcessing && (nsnull != GetCurrentContent())) {
nsIContent* content;
FlushText();
content = PopContent();
NS_RELEASE(content);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
{
NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_NOT_INITIALIZED);
nsresult result = NS_OK;
switch (aNode.GetTokenType()) {
case eToken_start:
{
FlushText();
// Create new leaf content object
nsRefPtr<nsGenericHTMLElement> content;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsIParserService* parserService = nsContentUtils::GetParserService();
if (!parserService)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsINodeInfo> nodeInfo;
if (nodeType == eHTMLTag_userdefined) {
nsAutoString lower;
nsContentUtils::ASCIIToLower(aNode.GetText(), lower);
nsCOMPtr<nsIAtom> name = do_GetAtom(lower);
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
}
else if (mNodeInfoCache[nodeType]) {
nodeInfo = mNodeInfoCache[nodeType];
}
else {
nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
NS_ASSERTION(name, "This should not happen!");
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
}
content =
CreateHTMLElement(nodeType, nodeInfo.forget(), NOT_FROM_PARSER);
NS_ENSURE_TRUE(content, NS_ERROR_OUT_OF_MEMORY);
result = AddAttributes(aNode, content);
NS_ENSURE_SUCCESS(result, result);
nsIContent *parent = GetCurrentContent();
if (!parent) {
parent = mRoot;
}
parent->AppendChildTo(content, PR_FALSE);
}
break;
case eToken_text:
case eToken_whitespace:
case eToken_newline:
result = AddText(aNode.GetText());
break;
case eToken_entity:
{
nsAutoString tmp;
PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp);
if (unicode < 0) {
result = AddText(aNode.GetText());
}
else {
result = AddText(tmp);
}
}
break;
}
return result;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::AddComment(const nsIParserNode& aNode)
{
nsCOMPtr<nsIContent> comment;
nsresult result = NS_OK;
FlushText();
result = NS_NewCommentNode(getter_AddRefs(comment), mNodeInfoManager);
if (NS_SUCCEEDED(result)) {
comment->SetText(aNode.GetText(), PR_FALSE);
nsIContent *parent = GetCurrentContent();
if (nsnull == parent) {
parent = mRoot;
}
parent->AppendChildTo(comment, PR_FALSE);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
{
return NS_OK;
}
/**
* This gets called by the parser when it encounters
* a DOCTYPE declaration in the HTML document.
*/
NS_IMETHODIMP
nsHTMLFragmentContentSink::AddDocTypeDecl(const nsIParserNode& aNode)
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::GetFragment(PRBool aWillOwnFragment,
nsIDOMDocumentFragment** aFragment)
{
if (mRoot) {
nsresult rv = CallQueryInterface(mRoot, aFragment);
if (NS_SUCCEEDED(rv) && aWillOwnFragment) {
mRoot = nsnull;
}
return rv;
}
*aFragment = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::SetTargetDocument(nsIDocument* aTargetDocument)
{
NS_ENSURE_ARG_POINTER(aTargetDocument);
mTargetDocument = aTargetDocument;
mNodeInfoManager = aTargetDocument->NodeInfoManager();
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::WillBuildContent()
{
mProcessing = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::DidBuildContent()
{
if (!mAllContent) {
FlushText();
DidBuildModel(PR_FALSE); // Release our ref to the parser now.
mProcessing = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLFragmentContentSink::IgnoreFirstContainer()
{
mIgnoreContainer = PR_TRUE;
return NS_OK;
}
nsIContent*
nsHTMLFragmentContentSink::GetCurrentContent()
{
if (nsnull != mContentStack) {
PRInt32 indx = mContentStack->Length() - 1;
if (indx >= 0)
return mContentStack->ElementAt(indx);
}
return nsnull;
}
PRInt32
nsHTMLFragmentContentSink::PushContent(nsIContent *aContent)
{
if (nsnull == mContentStack) {
mContentStack = new nsTArray<nsIContent*>();
}
mContentStack->AppendElement(aContent);
return mContentStack->Length();
}
nsIContent*
nsHTMLFragmentContentSink::PopContent()
{
nsIContent* content = nsnull;
if (nsnull != mContentStack) {
PRInt32 indx = mContentStack->Length() - 1;
if (indx >= 0) {
content = mContentStack->ElementAt(indx);
mContentStack->RemoveElementAt(indx);
}
}
return content;
}
#define NS_ACCUMULATION_BUFFER_SIZE 4096
nsresult
nsHTMLFragmentContentSink::AddText(const nsAString& aString)
{
PRInt32 addLen = aString.Length();
if (0 == addLen) {
return NS_OK;
}
// Create buffer when we first need it
if (0 == mTextSize) {
mText = (PRUnichar *) PR_MALLOC(sizeof(PRUnichar) * NS_ACCUMULATION_BUFFER_SIZE);
if (nsnull == mText) {
return NS_ERROR_OUT_OF_MEMORY;
}
mTextSize = NS_ACCUMULATION_BUFFER_SIZE;
}
// Copy data from string into our buffer; flush buffer when it fills up
PRInt32 offset = 0;
PRBool isLastCharCR = PR_FALSE;
while (0 != addLen) {
PRInt32 amount = mTextSize - mTextLength;
if (amount > addLen) {
amount = addLen;
}
if (0 == amount) {
nsresult rv = FlushText();
if (NS_OK != rv) {
return rv;
}
}
mTextLength +=
nsContentUtils::CopyNewlineNormalizedUnicodeTo(aString,
offset,
&mText[mTextLength],
amount,
isLastCharCR);
offset += amount;
addLen -= amount;
}
return NS_OK;
}
nsresult
nsHTMLFragmentContentSink::FlushText()
{
if (0 == mTextLength) {
return NS_OK;
}
nsCOMPtr<nsIContent> content;
nsresult rv = NS_NewTextNode(getter_AddRefs(content), mNodeInfoManager);
NS_ENSURE_SUCCESS(rv, rv);
// Set the text in the text node
content->SetText(mText, mTextLength, PR_FALSE);
// Add text to its parent
nsIContent *parent = GetCurrentContent();
if (!parent) {
parent = mRoot;
}
rv = parent->AppendChildTo(content, PR_FALSE);
mTextLength = 0;
return rv;
}
// XXX Code copied from nsHTMLContentSink. It should be shared.
nsresult
nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode,
nsIContent* aContent)
{
// Add tag attributes to the content attributes
PRInt32 ac = aNode.GetAttributeCount();
if (ac == 0) {
// No attributes, nothing to do. Do an early return to avoid
// constructing the nsAutoString object for nothing.
return NS_OK;
}
nsAutoString k;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
// The attributes are on the parser node in the order they came in in the
// source. What we want to happen if a single attribute is set multiple
// times on an element is that the first time should "win". That is, <input
// value="foo" value="bar"> should show "foo". So we loop over the
// attributes backwards; this ensures that the first attribute in the set
// wins. This does mean that we do some extra work in the case when the same
// attribute is set multiple times, but we save a HasAttr call in the much
// more common case of reasonable HTML.
for (PRInt32 i = ac - 1; i >= 0; i--) {
// Get lower-cased key
nsContentUtils::ASCIIToLower(aNode.GetKeyAt(i), k);
nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);
// Get value and remove mandatory quotes
static const char* kWhitespace = "\n\r\t\b";
const nsAString& v =
nsContentUtils::TrimCharsInSet(kWhitespace, aNode.GetValueAt(i));
if (nodeType == eHTMLTag_a && keyAtom == nsGkAtoms::name) {
NS_ConvertUTF16toUTF8 cname(v);
NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting()));
// Add attribute to content
aContent->SetAttr(kNameSpaceID_None, keyAtom, uv, PR_FALSE);
} else {
// Add attribute to content
aContent->SetAttr(kNameSpaceID_None, keyAtom, v, PR_FALSE);
}
}
return NS_OK;
}

View File

@ -335,12 +335,23 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(PRInt64 aTarget)
audio = nsnull;
continue;
}
if (startSample > targetSample) {
// The seek target doesn't lie in the audio block just after the last
// audio samples we've seen which were before the seek target. This
// could have been the first audio data we've seen after seek, i.e. the
// seek terminated after the seek target in the audio stream. Just
// abort the audio decode-to-target, the state machine will play
// silence to cover the gap. Typically this happens in poorly muxed
// files.
NS_WARNING("Audio not synced after seek, maybe a poorly muxed file?");
break;
}
// The seek target lies somewhere in this SoundData's samples, strip off
// any samples which lie before the seek target, so we'll begin playback
// exactly at the seek target.
NS_ASSERTION(targetSample >= startSample, "Target must at or be after data start.");
NS_ASSERTION(startSample + audio->mSamples > targetSample, "Data must end after target.");
NS_ASSERTION(targetSample < startSample + audio->mSamples, "Data must end after target.");
PRInt64 samplesToPrune = targetSample - startSample;
if (samplesToPrune > audio->mSamples) {

View File

@ -594,6 +594,13 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
) {
mConstrainSize = PR_TRUE;
if (mPreventScriptExecution) {
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aContent);
NS_ASSERTION(sele, "script did QI correctly!");
sele->PreventExecution();
return rv;
}
// Now tell the script that it's ready to go. This may execute the script
// or return NS_ERROR_HTMLPARSER_BLOCK. Or neither if the script doesn't
// need executing.
@ -631,8 +638,10 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
ssle->SetEnableUpdates(PR_TRUE);
PRBool willNotify;
PRBool isAlternate;
rv = ssle->UpdateStyleSheet(this, &willNotify, &isAlternate);
if (NS_SUCCEEDED(rv) && willNotify && !isAlternate) {
rv = ssle->UpdateStyleSheet(mFragmentMode ? nsnull : this,
&willNotify,
&isAlternate);
if (NS_SUCCEEDED(rv) && willNotify && !isAlternate && !mFragmentMode) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}
@ -1307,12 +1316,14 @@ nsXMLContentSink::HandleProcessingInstruction(const PRUnichar *aTarget,
ssle->SetEnableUpdates(PR_TRUE);
PRBool willNotify;
PRBool isAlternate;
rv = ssle->UpdateStyleSheet(this, &willNotify, &isAlternate);
rv = ssle->UpdateStyleSheet(mFragmentMode ? nsnull : this,
&willNotify,
&isAlternate);
NS_ENSURE_SUCCESS(rv, rv);
if (willNotify) {
// Successfully started a stylesheet load
if (!isAlternate) {
if (!isAlternate && !mFragmentMode) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}

View File

@ -63,6 +63,9 @@
#include "nsHashKeys.h"
#include "nsTArray.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIDocShell.h"
#include "nsScriptLoader.h"
#include "mozilla/css/Loader.h"
using namespace mozilla::dom;
@ -70,7 +73,7 @@ class nsXMLFragmentContentSink : public nsXMLContentSink,
public nsIFragmentContentSink
{
public:
nsXMLFragmentContentSink(PRBool aAllContent = PR_FALSE);
nsXMLFragmentContentSink();
virtual ~nsXMLFragmentContentSink();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
@ -106,12 +109,12 @@ public:
// nsIXMLContentSink
// nsIFragmentContentSink
NS_IMETHOD GetFragment(PRBool aWillOwnFragment,
nsIDOMDocumentFragment** aFragment);
NS_IMETHOD FinishFragmentParsing(nsIDOMDocumentFragment** aFragment);
NS_IMETHOD SetTargetDocument(nsIDocument* aDocument);
NS_IMETHOD WillBuildContent();
NS_IMETHOD DidBuildContent();
NS_IMETHOD IgnoreFirstContainer();
NS_IMETHOD SetPreventScriptExecution(PRBool aPreventScriptExecution);
protected:
virtual PRBool SetDocElement(PRInt32 aNameSpaceID,
@ -139,15 +142,12 @@ protected:
// the fragment
nsCOMPtr<nsIContent> mRoot;
PRPackedBool mParseError;
// if FALSE, take content inside endnote tag
PRPackedBool mAllContent;
};
static nsresult
NewXMLFragmentContentSinkHelper(PRBool aAllContent, nsIFragmentContentSink** aResult)
NewXMLFragmentContentSinkHelper(nsIFragmentContentSink** aResult)
{
nsXMLFragmentContentSink* it = new nsXMLFragmentContentSink(aAllContent);
nsXMLFragmentContentSink* it = new nsXMLFragmentContentSink();
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -157,21 +157,16 @@ NewXMLFragmentContentSinkHelper(PRBool aAllContent, nsIFragmentContentSink** aRe
return NS_OK;
}
nsresult
NS_NewXMLFragmentContentSink2(nsIFragmentContentSink** aResult)
{
return NewXMLFragmentContentSinkHelper(PR_TRUE, aResult);
}
nsresult
NS_NewXMLFragmentContentSink(nsIFragmentContentSink** aResult)
{
return NewXMLFragmentContentSinkHelper(PR_FALSE, aResult);
return NewXMLFragmentContentSinkHelper(aResult);
}
nsXMLFragmentContentSink::nsXMLFragmentContentSink(PRBool aAllContent)
: mParseError(PR_FALSE), mAllContent(aAllContent)
nsXMLFragmentContentSink::nsXMLFragmentContentSink()
: mParseError(PR_FALSE)
{
mFragmentMode = PR_TRUE;
}
nsXMLFragmentContentSink::~nsXMLFragmentContentSink()
@ -210,21 +205,12 @@ nsXMLFragmentContentSink::WillBuildModel(nsDTDMode aDTDMode)
mRoot = do_QueryInterface(frag);
if (mAllContent) {
// Preload content stack because we know all content goes in the fragment
PushContent(mRoot);
}
return rv;
}
NS_IMETHODIMP
nsXMLFragmentContentSink::DidBuildModel(PRBool aTerminated)
{
if (mAllContent) {
PopContent(); // remove mRoot pushed above
}
nsCOMPtr<nsIParser> kungFuDeathGrip(mParser);
// Drop our reference to the parser to get rid of a circular
@ -274,7 +260,7 @@ nsXMLFragmentContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsC
// When we aren't grabbing all of the content we, never open a doc
// element, we run into trouble on the first element, so we don't append,
// and simply push this onto the content stack.
if (!mAllContent && mContentStack.Length() == 0) {
if (mContentStack.Length() == 0) {
*aAppendContent = PR_FALSE;
}
@ -285,6 +271,13 @@ nsresult
nsXMLFragmentContentSink::CloseElement(nsIContent* aContent)
{
// don't do fancy stuff in nsXMLContentSink
if (mPreventScriptExecution && aContent->Tag() == nsGkAtoms::script &&
(aContent->GetNameSpaceID() == kNameSpaceID_XHTML ||
aContent->GetNameSpaceID() == kNameSpaceID_SVG)) {
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aContent);
NS_ASSERTION(sele, "script did QI correctly!");
sele->PreventExecution();
}
return NS_OK;
}
@ -410,18 +403,24 @@ nsXMLFragmentContentSink::StartLayout()
////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsXMLFragmentContentSink::GetFragment(PRBool aWillOwnFragment,
nsIDOMDocumentFragment** aFragment)
nsXMLFragmentContentSink::FinishFragmentParsing(nsIDOMDocumentFragment** aFragment)
{
*aFragment = nsnull;
mTargetDocument = nsnull;
mNodeInfoManager = nsnull;
mScriptLoader = nsnull;
mCSSLoader = nsnull;
mContentStack.Clear();
mDocumentURI = nsnull;
mDocShell = nsnull;
if (mParseError) {
//XXX PARSE_ERR from DOM3 Load and Save would be more appropriate
mRoot = nsnull;
mParseError = PR_FALSE;
return NS_ERROR_DOM_SYNTAX_ERR;
} else if (mRoot) {
nsresult rv = CallQueryInterface(mRoot, aFragment);
if (NS_SUCCEEDED(rv) && aWillOwnFragment) {
mRoot = nsnull;
}
mRoot = nsnull;
return rv;
} else {
return NS_OK;
@ -442,11 +441,7 @@ nsXMLFragmentContentSink::SetTargetDocument(nsIDocument* aTargetDocument)
NS_IMETHODIMP
nsXMLFragmentContentSink::WillBuildContent()
{
// If we're taking all of the content, then we've already pushed mRoot
// onto the content stack, otherwise, start here.
if (!mAllContent) {
PushContent(mRoot);
}
PushContent(mRoot);
return NS_OK;
}
@ -454,15 +449,12 @@ nsXMLFragmentContentSink::WillBuildContent()
NS_IMETHODIMP
nsXMLFragmentContentSink::DidBuildContent()
{
// If we're taking all of the content, then this is handled in DidBuildModel
if (!mAllContent) {
// Note: we need to FlushText() here because if we don't, we might not get
// an end element to do it for us, so make sure.
if (!mParseError) {
FlushText();
}
PopContent();
// Note: we need to FlushText() here because if we don't, we might not get
// an end element to do it for us, so make sure.
if (!mParseError) {
FlushText();
}
PopContent();
return NS_OK;
}
@ -479,3 +471,10 @@ nsXMLFragmentContentSink::IgnoreFirstContainer()
NS_NOTREACHED("XML isn't as broken as HTML");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsXMLFragmentContentSink::SetPreventScriptExecution(PRBool aPrevent)
{
mPreventScriptExecution = aPrevent;
return NS_OK;
}

View File

@ -512,17 +512,15 @@ nsXULElement::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
return NS_OK;
}
nsresult
nsXULElement::GetEventListenerManagerForAttr(nsEventListenerManager** aManager,
nsISupports** aTarget,
PRBool* aDefer)
nsEventListenerManager*
nsXULElement::GetEventListenerManagerForAttr(PRBool* aDefer)
{
// XXXbz sXBL/XBL2 issue: should we instead use GetCurrentDoc()
// here, override BindToTree for those classes and munge event
// listeners there?
nsIDocument* doc = GetOwnerDoc();
if (!doc)
return NS_ERROR_UNEXPECTED; // XXX
return nsnull; // XXX
nsPIDOMWindow *window;
Element *root = doc->GetRootElement();
@ -530,20 +528,12 @@ nsXULElement::GetEventListenerManagerForAttr(nsEventListenerManager** aManager,
(window = doc->GetInnerWindow()) && window->IsInnerWindow()) {
nsCOMPtr<nsIDOMEventTarget> piTarget = do_QueryInterface(window);
if (!piTarget)
return NS_ERROR_UNEXPECTED;
*aDefer = PR_FALSE;
*aManager = piTarget->GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(*aManager);
NS_ADDREF(*aManager);
NS_ADDREF(*aTarget = window);
return NS_OK;
return piTarget->GetListenerManager(PR_TRUE);
}
return nsStyledElement::GetEventListenerManagerForAttr(aManager,
aTarget,
aDefer);
return nsStyledElement::GetEventListenerManagerForAttr(aDefer);
}
// returns true if the element is not a list

View File

@ -657,10 +657,8 @@ protected:
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult
GetEventListenerManagerForAttr(nsEventListenerManager** aManager,
nsISupports** aTarget,
PRBool* aDefer);
virtual nsEventListenerManager*
GetEventListenerManagerForAttr(PRBool* aDefer);
/**
* Return our prototype's attribute, if one exists.

View File

@ -77,17 +77,6 @@ export:: sqlite-version.h
endif
endif
ifdef GNU_CC
MODULE_OPTIMIZE_FLAGS = -O2
else
ifeq ($(OS_ARCH),SunOS)
MODULE_OPTIMIZE_FLAGS = -xO5
endif
ifeq ($(OS_ARCH),WINNT)
MODULE_OPTIMIZE_FLAGS = -O2
endif
endif
EXPORTS = \
sqlite3.h \
$(NULL)

View File

@ -7762,13 +7762,13 @@ nsEventReceiverSH::RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
JSObject *scope = ::JS_GetGlobalForObject(cx, obj);
if (compile) {
nsresult rv = manager->CompileScriptEventListener(script_cx, scope, target,
nsresult rv = manager->CompileScriptEventListener(script_cx, scope,
atom, did_define);
NS_ENSURE_SUCCESS(rv, rv);
} else if (remove) {
manager->RemoveScriptEventListener(atom);
} else {
manager->RegisterScriptEventListener(script_cx, scope, target, atom);
manager->RegisterScriptEventListener(script_cx, scope, atom);
}
return NS_SUCCESS_I_DID_SOMETHING;

View File

@ -51,7 +51,7 @@
* http://www.whatwg.org/specs/web-apps/current-work/
*/
[scriptable, uuid(164c7ebd-2245-42d2-a96f-2bf2d01c1697)]
[scriptable, uuid(c6e10ab6-ecf4-48e4-aeaa-37724307dfd5)]
interface nsIDOMHTMLElement : nsIDOMElement
{
attribute DOMString id;
@ -61,6 +61,7 @@ interface nsIDOMHTMLElement : nsIDOMElement
attribute DOMString className;
attribute DOMString accessKey;
readonly attribute DOMString accessKeyLabel;
void blur();
void focus();

View File

@ -40,7 +40,7 @@
interface nsIDOMDOMStringMap;
[scriptable, uuid(cf76761d-2d93-4e88-aaf1-b637878bad65)]
[scriptable, uuid(4012e9a9-f6fb-48b3-9a80-b096c1dcb5ba)]
interface nsIDOMNSHTMLElement : nsISupports
{
readonly attribute long offsetTop;
@ -65,6 +65,10 @@ interface nsIDOMNSHTMLElement : nsISupports
// for WHAT-WG drag and drop
attribute boolean draggable;
void insertAdjacentHTML(in DOMString position,
in DOMString text)
raises(DOMException);
[optional_argc] void scrollIntoView([optional] in boolean top);
attribute boolean spellcheck;

View File

@ -1051,7 +1051,7 @@ JSObject*
CreateGenericEvent(JSContext* aCx, JSString* aType, bool aBubbles,
bool aCancelable, bool aMainRuntime)
{
JSObject* global = JS_GetGlobalObject(aCx);
JSObject* global = JS_GetGlobalForScopeChain(aCx);
return Event::Create(aCx, global, aType, aBubbles, aCancelable, aMainRuntime);
}
@ -1059,7 +1059,7 @@ JSObject*
CreateMessageEvent(JSContext* aCx, JSAutoStructuredCloneBuffer& aData,
bool aMainRuntime)
{
JSObject* global = JS_GetGlobalObject(aCx);
JSObject* global = JS_GetGlobalForScopeChain(aCx);
return MessageEvent::Create(aCx, global, aData, aMainRuntime);
}
@ -1067,7 +1067,7 @@ JSObject*
CreateErrorEvent(JSContext* aCx, JSString* aMessage, JSString* aFilename,
uint32 aLineNumber, bool aMainRuntime)
{
JSObject* global = JS_GetGlobalObject(aCx);
JSObject* global = JS_GetGlobalForScopeChain(aCx);
return ErrorEvent::Create(aCx, global, aMessage, aFilename, aLineNumber,
aMainRuntime);
}
@ -1076,7 +1076,7 @@ JSObject*
CreateProgressEvent(JSContext* aCx, JSString* aType, bool aLengthComputable,
jsdouble aLoaded, jsdouble aTotal)
{
JSObject* global = JS_GetGlobalObject(aCx);
JSObject* global = JS_GetGlobalForScopeChain(aCx);
return ProgressEvent::Create(aCx, global, aType, aLengthComputable, aLoaded,
aTotal);
}

View File

@ -1206,15 +1206,17 @@ NS_IMETHODIMP
WorkerRunnable::Run()
{
JSContext* cx;
JSObject* targetCompartmentObject;
nsIThreadJSContextStack* contextStack = nsnull;
if (mTarget == WorkerThread) {
mWorkerPrivate->AssertIsOnWorkerThread();
cx = mWorkerPrivate->GetJSContext();
targetCompartmentObject = JS_GetGlobalObject(cx);
} else {
mWorkerPrivate->AssertIsOnParentThread();
cx = mWorkerPrivate->ParentJSContext();
targetCompartmentObject = mWorkerPrivate->GetJSObject();
if (!mWorkerPrivate->GetParent()) {
AssertIsOnMainThread();
@ -1233,10 +1235,8 @@ WorkerRunnable::Run()
JSAutoRequest ar(cx);
JSObject* global = JS_GetGlobalObject(cx);
JSAutoEnterCompartment ac;
if (global && !ac.enter(cx, global)) {
if (targetCompartmentObject && !ac.enter(cx, targetCompartmentObject)) {
return false;
}

View File

@ -2689,24 +2689,17 @@ nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr,
nsCOMPtr<nsIDOMNode> *outNode,
PRBool aTrustedInput)
{
// The old code created a new parser every time. This is inefficient.
// However, the target document is not required to be an HTML document,
// So avoid using the cached parser of aDocument. Once bug 596182 is fixed,
// use the global parser here.
nsCOMPtr<nsIParser> parser = nsHtml5Module::NewHtml5Parser();
nsAHtml5FragmentParser* asFragmentParser =
static_cast<nsAHtml5FragmentParser*> (parser.get());
nsCOMPtr<nsIDOMDocumentFragment> frag;
NS_NewDocumentFragment(getter_AddRefs(frag),
aTargetDocument->NodeInfoManager());
nsCOMPtr<nsIContent> fragment = do_QueryInterface(frag);
asFragmentParser->ParseHtml5Fragment(aFragStr,
fragment,
aContextLocalName ?
aContextLocalName : nsGkAtoms::body,
kNameSpaceID_XHTML,
PR_FALSE,
PR_TRUE);
nsContentUtils::ParseFragmentHTML(aFragStr,
fragment,
aContextLocalName ?
aContextLocalName : nsGkAtoms::body,
kNameSpaceID_XHTML,
PR_FALSE,
PR_TRUE);
if (!aTrustedInput) {
nsTreeSanitizer sanitizer(!!aContextLocalName, !aContextLocalName);
sanitizer.Sanitize(fragment);

View File

@ -49,12 +49,7 @@ LIBXUL_LIBRARY = 1
ifdef GNU_CC
OS_CXXFLAGS := $(filter-out -pedantic,$(OS_CXXFLAGS))
MODULE_OPTIMIZE_FLAGS = -O2
else
ifeq ($(OS_ARCH),SunOS)
MODULE_OPTIMIZE_FLAGS = -xO5
endif
ifeq ($(OS_ARCH),WINNT)
ifeq ($(OS_TARGET),Android)
MODULE_OPTIMIZE_FLAGS = -O2
endif
endif

View File

@ -48,15 +48,8 @@ MODULE = libpixman
LIBRARY_NAME = mozlibpixman
LIBXUL_LIBRARY = 1
ifdef GNU_CC
ifeq ($(OS_TARGET),Android)
MODULE_OPTIMIZE_FLAGS = -O2
else
ifeq ($(OS_ARCH),SunOS)
MODULE_OPTIMIZE_FLAGS = -xO5
endif
ifeq ($(OS_ARCH),WINNT)
MODULE_OPTIMIZE_FLAGS = -O2
endif
endif
DEFINES += -DPIXMAN_NO_TLS

View File

@ -442,7 +442,7 @@ gfxAndroidPlatform::FindFontsInDirectory(const nsCString& aFontsDir,
strcasecmp(ent->d_name + namelen - 4, ".ttf") == 0)
{
bool isStdFont = false;
for (int i = 0; i < NS_ARRAY_LENGTH(sStandardFonts) && !isStdFont; i++) {
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(sStandardFonts) && !isStdFont; i++) {
isStdFont = strcmp(sStandardFonts[i], ent->d_name) == 0;
}
if (!isStdFont) {
@ -454,7 +454,7 @@ gfxAndroidPlatform::FindFontsInDirectory(const nsCString& aFontsDir,
}
}
closedir(d);
for (int i = 0; i < NS_ARRAY_LENGTH(sStandardFonts); i++) {
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(sStandardFonts); i++) {
nsCString s(aFontsDir);
s.Append(nsDependentCString(sStandardFonts[i]));

View File

@ -711,7 +711,7 @@ void gfxOS2FontGroup::CreateGlyphRunsFT(gfxTextRun *aTextRun, const PRUint8 *aUT
const PRUint32 appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit();
gfxOS2Platform *platform = gfxOS2Platform::GetPlatform();
aTextRun->AddGlyphRun(font0, 0);
aTextRun->AddGlyphRun(font0, gfxTextRange::kFontGroup, 0, PR_FALSE);
// a textRun likely has the same font for most of the characters, so we can
// lock it before the loop for efficiency
FT_Face face0 = cairo_ft_scaled_font_lock_face(font0->CairoScaledFont());
@ -772,7 +772,7 @@ void gfxOS2FontGroup::CreateGlyphRunsFT(gfxTextRun *aTextRun, const PRUint8 *aUT
}
// select the current font into the text run
aTextRun->AddGlyphRun(font, utf16Offset);
aTextRun->AddGlyphRun(font, gfxTextRange::kFontGroup, utf16Offset, PR_FALSE);
PRInt32 advance = 0;
if (gid == font->GetSpaceGlyph()) {
@ -874,6 +874,7 @@ void gfxOS2FontGroup::CreateGlyphRunsFT(gfxTextRun *aTextRun, const PRUint8 *aUT
// append aFontName to aClosure string array, if not already present
PRBool gfxOS2FontGroup::FontCallback(const nsAString& aFontName,
const nsACString& aGenericName,
PRBool aUseFontSet,
void *aClosure)
{
nsTArray<nsString> *sa = static_cast<nsTArray<nsString>*>(aClosure);

View File

@ -125,7 +125,9 @@ protected:
void CreateGlyphRunsFT(gfxTextRun *aTextRun, const PRUint8 *aUTF8,
PRUint32 aUTF8Length);
static PRBool FontCallback(const nsAString& aFontName,
const nsACString& aGenericName, void *aClosure);
const nsACString& aGenericName,
PRBool aUseFontSet,
void *aClosure);
private:
PRBool mEnableKerning;

View File

@ -491,8 +491,30 @@ public:
if (right.m_isPointer) {
m_assembler.ldr_un_imm(ARMRegisters::S0, right.m_value);
m_assembler.cmp_r(left, ARMRegisters::S0);
} else
m_assembler.cmp_r(left, m_assembler.getImm(right.m_value, ARMRegisters::S0));
} else {
// This is a rather cute (if not confusing) pattern.
// unfortunately, it is not quite conducive to switching from
// cmp to cmn, so I'm doing so manually.
// m_assembler.cmp_r(left, m_assembler.getImm(right.m_value, ARMRegisters::S0));
// try to shoehorn the immediate into the compare instruction
ARMWord arg = m_assembler.getOp2(right.m_value);
if (arg != m_assembler.INVALID_IMM) {
m_assembler.cmp_r(left, arg);
} else {
// if it does not fit, try to shoehorn a negative in, and use a negated compare
// p.s. why couldn't arm just include the sign bit in the imm, rather than the inst.
arg = m_assembler.getOp2(-right.m_value);
if (arg != m_assembler.INVALID_IMM) {
m_assembler.cmn_r(left, arg);
} else {
// If we get here, we *need* to use a temp register and any way of loading a value
// will enable us to load a negative easily, so there is no reason to switch from
// cmp to cmn.
m_assembler.cmp_r(left, m_assembler.getImm(right.m_value, ARMRegisters::S0));
}
}
}
return Jump(m_assembler.jmp(ARMCondition(cond), useConstantPool));
}

View File

@ -1,5 +1,6 @@
// |jit-test| error: RangeError
function g(a, b, c, d) {}
function f(a, b, c) {
arguments.length=8.64e15;
arguments.length = getMaxArgs() + 1;
g.apply(this, arguments);
}f();

View File

@ -28,7 +28,7 @@ try {
(function() {
gotIn = true;
(new Function(arg, body))(10000000);
}).apply(null, new Array(500 * 1024));
}).apply(null, new Array(getMaxArgs()));
} catch(e) {
assertEq(""+e, "InternalError: too much recursion");
threwOut = true;

View File

@ -0,0 +1,25 @@
function g(a, b, c, d) {}
function f(a, b, c)
{
arguments.length = getMaxArgs() + 1;
g.apply(this, arr);
}
var args = [[5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], let (x = []) (x.length = getMaxArgs() + 1, x)]
try
{
for (var i = 0; i < args.length; i++) { arr = args[i]; f(); }
throw new Error("didn't throw");
}
catch (e)
{
assertEq(e instanceof RangeError, true, "wrong exception: " + e);
}
try
{
for (var i = 0; i < args.length; i++) { arr = args[i]; f(); }
throw new Error("didn't throw");
}
catch (e)
{
assertEq(e instanceof RangeError, true, "wrong exception: " + e);
}

View File

@ -144,7 +144,7 @@ MSG_DEF(JSMSG_BAD_CLASS_RANGE, 57, 0, JSEXN_SYNTAXERR, "invalid range in
MSG_DEF(JSMSG_BAD_REGEXP_FLAG, 58, 1, JSEXN_SYNTAXERR, "invalid regular expression flag {0}")
MSG_DEF(JSMSG_NO_INPUT, 59, 5, JSEXN_SYNTAXERR, "no input for /{0}/{1}{2}{3}{4}")
MSG_DEF(JSMSG_CANT_OPEN, 60, 2, JSEXN_ERR, "can't open {0}: {1}")
MSG_DEF(JSMSG_UNUSED61, 61, 0, JSEXN_NONE, "")
MSG_DEF(JSMSG_TOO_MANY_FUN_APPLY_ARGS, 61, 0, JSEXN_RANGEERR, "arguments array passed to Function.prototype.apply is too large")
MSG_DEF(JSMSG_UNMATCHED_RIGHT_PAREN, 62, 0, JSEXN_SYNTAXERR, "unmatched ) in regular expression")
MSG_DEF(JSMSG_END_OF_DATA, 63, 0, JSEXN_INTERNALERR, "unexpected end of data")
MSG_DEF(JSMSG_SEEK_BEYOND_START, 64, 0, JSEXN_INTERNALERR, "illegal seek beyond start")

View File

@ -64,6 +64,7 @@ CPPSRCS = \
testFunctionProperties.cpp \
testGCChunkAlloc.cpp \
testGetPropertyDefault.cpp \
testIndexToString.cpp \
testIntString.cpp \
testIntern.cpp \
testLookup.cpp \

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