Merge backout.

This commit is contained in:
Ms2ger 2013-04-26 13:24:11 +02:00
commit fdf63ebd54
33 changed files with 474 additions and 570 deletions

View File

@ -382,5 +382,11 @@ Attr::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
return AttrBinding::Wrap(aCx, aScope, this);
}
Element*
Attr::GetContentInternal() const
{
return mAttrMap ? mAttrMap->GetContent() : nullptr;
}
} // namespace dom
} // namespace mozilla

View File

@ -17,7 +17,6 @@
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsINodeInfo.h"
#include "nsDOMAttributeMap.h"
#include "nsCycleCollectionParticipant.h"
#include "nsStubMutationObserver.h"
@ -107,10 +106,7 @@ protected:
private:
already_AddRefed<nsIAtom> GetNameAtom(nsIContent* aContent);
mozilla::dom::Element *GetContentInternal() const
{
return mAttrMap ? mAttrMap->GetContent() : nullptr;
}
mozilla::dom::Element* GetContentInternal() const;
nsString mValue;
};

View File

@ -790,14 +790,7 @@ Element::SetAttributeNode(Attr& aNewAttr, ErrorResult& aError)
{
OwnerDoc()->WarnOnceAbout(nsIDocument::eSetAttributeNode);
nsCOMPtr<nsIDOMAttr> attr;
aError = Attributes()->SetNamedItem(&aNewAttr, getter_AddRefs(attr));
if (aError.Failed()) {
return nullptr;
}
nsRefPtr<Attr> returnAttr = static_cast<Attr*>(attr.get());
return returnAttr.forget();
return Attributes()->SetNamedItem(aNewAttr, aError);
}
already_AddRefed<Attr>
@ -805,22 +798,7 @@ Element::RemoveAttributeNode(Attr& aAttribute,
ErrorResult& aError)
{
OwnerDoc()->WarnOnceAbout(nsIDocument::eRemoveAttributeNode);
nsAutoString name;
aError = aAttribute.GetName(name);
if (aError.Failed()) {
return nullptr;
}
nsCOMPtr<nsIDOMAttr> attr;
aError = Attributes()->RemoveNamedItem(name, getter_AddRefs(attr));
if (aError.Failed()) {
return nullptr;
}
nsRefPtr<Attr> returnAttr = static_cast<Attr*>(attr.get());
return returnAttr.forget();
return Attributes()->RemoveNamedItem(aAttribute.NodeName(), aError);
}
void
@ -904,7 +882,7 @@ Element::SetAttributeNodeNS(Attr& aNewAttr,
ErrorResult& aError)
{
OwnerDoc()->WarnOnceAbout(nsIDocument::eSetAttributeNodeNS);
return Attributes()->SetNamedItemNS(&aNewAttr, aError);
return Attributes()->SetNamedItemNS(aNewAttr, aError);
}
already_AddRefed<nsIHTMLCollection>

View File

@ -8,15 +8,17 @@
*/
#include "nsDOMAttributeMap.h"
#include "mozilla/dom/Attr.h"
#include "nsIDOMDocument.h"
#include "mozilla/dom/Element.h"
#include "nsIDocument.h"
#include "nsINameSpaceManager.h"
#include "nsError.h"
#include "nsContentUtils.h"
#include "nsNodeInfoManager.h"
#include "mozilla/dom/MozNamedAttrMapBinding.h"
#include "nsAttrName.h"
#include "nsContentUtils.h"
#include "nsError.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsINameSpaceManager.h"
#include "nsNodeInfoManager.h"
#include "nsUnicharUtils.h"
using namespace mozilla;
@ -30,6 +32,7 @@ nsDOMAttributeMap::nsDOMAttributeMap(Element* aContent)
// We don't add a reference to our content. If it goes away,
// we'll be told to drop our reference
mAttributeCache.Init();
SetIsDOMBinding();
}
/**
@ -58,6 +61,7 @@ nsDOMAttributeMap::DropReference()
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMAttributeMap)
tmp->DropReference();
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -75,18 +79,17 @@ TraverseMapEntry(nsAttrHashKey::KeyType aKey, nsRefPtr<Attr>& aData,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMAttributeMap)
tmp->mAttributeCache.Enumerate(TraverseMapEntry, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
DOMCI_DATA(MozNamedAttrMap, nsDOMAttributeMap)
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsDOMAttributeMap)
// QueryInterface implementation for nsDOMAttributeMap
NS_INTERFACE_TABLE_HEAD(nsDOMAttributeMap)
NS_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsDOMAttributeMap)
NS_INTERFACE_TABLE_ENTRY(nsDOMAttributeMap, nsIDOMMozNamedAttrMap)
NS_OFFSET_AND_INTERFACE_TABLE_END
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
NS_INTERFACE_TABLE1(nsDOMAttributeMap, nsIDOMMozNamedAttrMap)
NS_INTERFACE_TABLE_TO_MAP_SEGUE
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDOMAttributeMap)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozNamedAttrMap)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMAttributeMap)
@ -172,17 +175,25 @@ nsDOMAttributeMap::GetAttribute(nsINodeInfo* aNodeInfo, bool aNsAware)
}
Attr*
nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName)
nsDOMAttributeMap::NamedGetter(const nsAString& aAttrName, bool& aFound)
{
if (mContent) {
nsCOMPtr<nsINodeInfo> ni =
mContent->GetExistingAttrNameFromQName(aAttrName);
if (ni) {
return GetAttribute(ni, false);
}
aFound = false;
NS_ENSURE_TRUE(mContent, nullptr);
nsCOMPtr<nsINodeInfo> ni = mContent->GetExistingAttrNameFromQName(aAttrName);
if (!ni) {
return nullptr;
}
return nullptr;
aFound = true;
return GetAttribute(ni, false);
}
Attr*
nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName)
{
bool dummy;
return NamedGetter(aAttrName, dummy);
}
NS_IMETHODIMP
@ -199,128 +210,115 @@ nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName,
NS_IMETHODIMP
nsDOMAttributeMap::SetNamedItem(nsIDOMAttr* aAttr, nsIDOMAttr** aReturn)
{
Attr* attribute = static_cast<Attr*>(aAttr);
NS_ENSURE_ARG(attribute);
ErrorResult rv;
*aReturn = SetNamedItemInternal(aAttr, false, rv).get();
*aReturn = SetNamedItem(*attribute, rv).get();
return rv.ErrorCode();
}
NS_IMETHODIMP
nsDOMAttributeMap::SetNamedItemNS(nsIDOMAttr* aAttr, nsIDOMAttr** aReturn)
{
Attr* attribute = static_cast<Attr*>(aAttr);
NS_ENSURE_ARG(attribute);
ErrorResult rv;
*aReturn = SetNamedItemInternal(aAttr, true, rv).get();
*aReturn = SetNamedItemNS(*attribute, rv).get();
return rv.ErrorCode();
}
already_AddRefed<Attr>
nsDOMAttributeMap::SetNamedItemInternal(nsIDOMAttr* aAttr,
nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
bool aWithNS,
ErrorResult& aError)
{
if (mContent) {
// XXX should check same-origin between mContent and aAttr however
// nsContentUtils::CheckSameOrigin can't deal with attributenodes yet
nsCOMPtr<nsIAttribute> iAttribute(do_QueryInterface(aAttr));
if (!iAttribute) {
aError.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
NS_ENSURE_TRUE(mContent, nullptr);
// XXX should check same-origin between mContent and aAttr however
// nsContentUtils::CheckSameOrigin can't deal with attributenodes yet
// Check that attribute is not owned by somebody else
nsDOMAttributeMap* owner = aAttr.GetMap();
if (owner) {
if (owner != this) {
aError.Throw(NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR);
return nullptr;
}
Attr *attribute = static_cast<Attr*>(iAttribute.get());
// Check that attribute is not owned by somebody else
nsDOMAttributeMap* owner = iAttribute->GetMap();
if (owner) {
if (owner != this) {
aError.Throw(NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR);
return nullptr;
}
// setting a preexisting attribute is a no-op, just return the same
// node.
NS_ADDREF(attribute);
return attribute;
}
nsresult rv;
if (!mContent->HasSameOwnerDoc(iAttribute)) {
nsCOMPtr<nsIDOMDocument> domDoc =
do_QueryInterface(mContent->OwnerDoc(), &rv);
if (NS_FAILED(rv)) {
aError.Throw(rv);
return nullptr;
}
nsCOMPtr<nsIDOMNode> adoptedNode;
rv = domDoc->AdoptNode(aAttr, getter_AddRefs(adoptedNode));
if (NS_FAILED(rv)) {
aError.Throw(rv);
return nullptr;
}
NS_ASSERTION(adoptedNode == aAttr, "Uh, adopt node changed nodes?");
}
// Get nodeinfo and preexisting attribute (if it exists)
nsAutoString name;
nsCOMPtr<nsINodeInfo> ni;
nsRefPtr<Attr> attr;
// SetNamedItemNS()
if (aWithNS) {
// Return existing attribute, if present
ni = iAttribute->NodeInfo();
if (mContent->HasAttr(ni->NamespaceID(), ni->NameAtom())) {
attr = RemoveAttribute(ni);
}
}
else { // SetNamedItem()
attribute->GetName(name);
// get node-info of old attribute
ni = mContent->GetExistingAttrNameFromQName(name);
if (ni) {
attr = RemoveAttribute(ni);
}
else {
if (mContent->IsInHTMLDocument() &&
mContent->IsHTML()) {
nsContentUtils::ASCIIToLower(name);
}
rv = mContent->NodeInfo()->NodeInfoManager()->
GetNodeInfo(name, nullptr, kNameSpaceID_None,
nsIDOMNode::ATTRIBUTE_NODE, getter_AddRefs(ni));
if (NS_FAILED(rv)) {
aError.Throw(rv);
return nullptr;
}
// value is already empty
}
}
nsAutoString value;
attribute->GetValue(value);
// Add the new attribute to the attribute map before updating
// its value in the element. @see bug 364413.
nsAttrKey attrkey(ni->NamespaceID(), ni->NameAtom());
mAttributeCache.Put(attrkey, attribute);
iAttribute->SetMap(this);
rv = mContent->SetAttr(ni->NamespaceID(), ni->NameAtom(),
ni->GetPrefixAtom(), value, true);
if (NS_FAILED(rv)) {
aError.Throw(rv);
DropAttribute(ni->NamespaceID(), ni->NameAtom());
}
return attr.forget();
// setting a preexisting attribute is a no-op, just return the same
// node.
nsRefPtr<Attr> attribute = &aAttr;
return attribute.forget();
}
return nullptr;
nsresult rv;
if (!mContent->HasSameOwnerDoc(&aAttr)) {
nsCOMPtr<nsINode> adoptedNode =
mContent->OwnerDoc()->AdoptNode(aAttr, aError);
if (aError.Failed()) {
return nullptr;
}
NS_ASSERTION(adoptedNode == &aAttr, "Uh, adopt node changed nodes?");
}
// Get nodeinfo and preexisting attribute (if it exists)
nsAutoString name;
nsCOMPtr<nsINodeInfo> ni;
nsRefPtr<Attr> attr;
// SetNamedItemNS()
if (aWithNS) {
// Return existing attribute, if present
ni = aAttr.NodeInfo();
if (mContent->HasAttr(ni->NamespaceID(), ni->NameAtom())) {
attr = RemoveAttribute(ni);
}
} else { // SetNamedItem()
aAttr.GetName(name);
// get node-info of old attribute
ni = mContent->GetExistingAttrNameFromQName(name);
if (ni) {
attr = RemoveAttribute(ni);
}
else {
if (mContent->IsInHTMLDocument() &&
mContent->IsHTML()) {
nsContentUtils::ASCIIToLower(name);
}
rv = mContent->NodeInfo()->NodeInfoManager()->
GetNodeInfo(name, nullptr, kNameSpaceID_None,
nsIDOMNode::ATTRIBUTE_NODE, getter_AddRefs(ni));
if (NS_FAILED(rv)) {
aError.Throw(rv);
return nullptr;
}
// value is already empty
}
}
nsAutoString value;
aAttr.GetValue(value);
// Add the new attribute to the attribute map before updating
// its value in the element. @see bug 364413.
nsAttrKey attrkey(ni->NamespaceID(), ni->NameAtom());
mAttributeCache.Put(attrkey, &aAttr);
aAttr.SetMap(this);
rv = mContent->SetAttr(ni->NamespaceID(), ni->NameAtom(),
ni->GetPrefixAtom(), value, true);
if (NS_FAILED(rv)) {
aError.Throw(rv);
DropAttribute(ni->NamespaceID(), ni->NameAtom());
}
return attr.forget();
}
NS_IMETHODIMP
@ -328,64 +326,76 @@ nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName,
nsIDOMAttr** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nullptr;
nsresult rv = NS_OK;
ErrorResult rv;
*aReturn = RemoveNamedItem(aName, rv).get();
return rv.ErrorCode();
}
if (mContent) {
nsCOMPtr<nsINodeInfo> ni = mContent->GetExistingAttrNameFromQName(aName);
if (!ni) {
return NS_ERROR_DOM_NOT_FOUND_ERR;
}
already_AddRefed<Attr>
nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName, ErrorResult& aError)
{
NS_ENSURE_TRUE(mContent, nullptr);
NS_ADDREF(*aReturn = GetAttribute(ni, true));
// This removes the attribute node from the attribute map.
rv = mContent->UnsetAttr(ni->NamespaceID(), ni->NameAtom(), true);
nsCOMPtr<nsINodeInfo> ni = mContent->GetExistingAttrNameFromQName(aName);
if (!ni) {
aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
return nullptr;
}
return rv;
nsRefPtr<Attr> attribute = GetAttribute(ni, true);
// This removes the attribute node from the attribute map.
aError = mContent->UnsetAttr(ni->NamespaceID(), ni->NameAtom(), true);
return attribute.forget();
}
Attr*
nsDOMAttributeMap::GetItemAt(uint32_t aIndex)
nsDOMAttributeMap::IndexedGetter(uint32_t aIndex, bool& aFound)
{
Attr* node = nullptr;
aFound = false;
NS_ENSURE_TRUE(mContent, nullptr);
const nsAttrName* name;
if (mContent && (name = mContent->GetAttrNameAt(aIndex))) {
// Don't use the nodeinfo even if one exists since it can
// have the wrong owner document.
nsCOMPtr<nsINodeInfo> ni;
ni = mContent->NodeInfo()->NodeInfoManager()->
GetNodeInfo(name->LocalName(), name->GetPrefix(), name->NamespaceID(),
nsIDOMNode::ATTRIBUTE_NODE);
node = GetAttribute(ni, true);
}
const nsAttrName* name = mContent->GetAttrNameAt(aIndex);
NS_ENSURE_TRUE(name, nullptr);
return node;
aFound = true;
// Don't use the nodeinfo even if one exists since it can have the wrong
// owner document.
nsCOMPtr<nsINodeInfo> ni = mContent->NodeInfo()->NodeInfoManager()->
GetNodeInfo(name->LocalName(), name->GetPrefix(), name->NamespaceID(),
nsIDOMNode::ATTRIBUTE_NODE);
return GetAttribute(ni, true);
}
Attr*
nsDOMAttributeMap::Item(uint32_t aIndex)
{
bool dummy;
return IndexedGetter(aIndex, dummy);
}
NS_IMETHODIMP
nsDOMAttributeMap::Item(uint32_t aIndex, nsIDOMAttr** aReturn)
{
NS_IF_ADDREF(*aReturn = GetItemAt(aIndex));
NS_IF_ADDREF(*aReturn = Item(aIndex));
return NS_OK;
}
uint32_t
nsDOMAttributeMap::Length() const
{
NS_ENSURE_TRUE(mContent, 0);
return mContent->GetAttrCount();
}
nsresult
nsDOMAttributeMap::GetLength(uint32_t *aLength)
{
NS_ENSURE_ARG_POINTER(aLength);
if (mContent) {
*aLength = mContent->GetAttrCount();
}
else {
*aLength = 0;
}
*aLength = Length();
return NS_OK;
}
@ -455,20 +465,27 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
nsIDOMAttr** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nullptr;
ErrorResult rv;
*aReturn = RemoveNamedItemNS(aNamespaceURI, aLocalName, rv).get();
return rv.ErrorCode();
}
already_AddRefed<Attr>
nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName,
ErrorResult& aError)
{
nsCOMPtr<nsINodeInfo> ni = GetAttrNodeInfo(aNamespaceURI, aLocalName);
if (!ni) {
return NS_ERROR_DOM_NOT_FOUND_ERR;
aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
return nullptr;
}
nsRefPtr<Attr> attr = RemoveAttribute(ni);
nsINodeInfo *attrNi = attr->NodeInfo();
nsINodeInfo* attrNi = attr->NodeInfo();
mContent->UnsetAttr(attrNi->NamespaceID(), attrNi->NameAtom(), true);
attr.forget(aReturn);
return NS_OK;
return attr.forget();
}
uint32_t
@ -503,3 +520,9 @@ nsDOMAttributeMap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
// NB: mContent is non-owning and thus not counted.
return n;
}
/* virtual */ JSObject*
nsDOMAttributeMap::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return MozNamedAttrMapBinding::Wrap(aCx, aScope, this);
}

View File

@ -10,12 +10,13 @@
#ifndef nsDOMAttributeMap_h
#define nsDOMAttributeMap_h
#include "nsIDOMMozNamedAttrMap.h"
#include "nsStringGlue.h"
#include "nsRefPtrHashtable.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIDOMAttr.h"
#include "mozilla/dom/Attr.h"
#include "mozilla/ErrorResult.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIDOMMozNamedAttrMap.h"
#include "nsRefPtrHashtable.h"
#include "nsStringGlue.h"
#include "nsWrapperCache.h"
class nsIAtom;
class nsINodeInfo;
@ -23,7 +24,6 @@ class nsIDocument;
namespace mozilla {
namespace dom {
class Attr;
class Element;
} // namespace dom
} // namespace mozilla
@ -88,14 +88,18 @@ private:
// Helper class that implements the nsIDOMMozNamedAttrMap interface.
class nsDOMAttributeMap : public nsIDOMMozNamedAttrMap
, public nsWrapperCache
{
public:
typedef mozilla::dom::Attr Attr;
typedef mozilla::dom::Element Element;
typedef mozilla::ErrorResult ErrorResult;
nsDOMAttributeMap(Element *aContent);
virtual ~nsDOMAttributeMap();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMAttributeMap)
// nsIDOMMozNamedAttrMap interface
NS_DECL_NSIDOMMOZNAMEDATTRMAP
@ -128,7 +132,7 @@ public:
*/
uint32_t Count() const;
typedef nsRefPtrHashtable<nsAttrHashKey, mozilla::dom::Attr> AttrCache;
typedef nsRefPtrHashtable<nsAttrHashKey, Attr> AttrCache;
/**
* Enumerates over the attribute nodess in the map and calls aFunc for each
@ -138,36 +142,44 @@ public:
*/
uint32_t Enumerate(AttrCache::EnumReadFunction aFunc, void *aUserArg) const;
mozilla::dom::Attr* GetItemAt(uint32_t aIndex);
mozilla::dom::Attr* GetNamedItem(const nsAString& aAttrName);
static nsDOMAttributeMap* FromSupports(nsISupports* aSupports)
Element* GetParentObject() const
{
#ifdef DEBUG
{
nsCOMPtr<nsIDOMMozNamedAttrMap> map_qi = do_QueryInterface(aSupports);
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIDOMMozNamedAttrMap pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(map_qi == static_cast<nsIDOMMozNamedAttrMap*>(aSupports),
"Uh, fix QI!");
}
#endif
return static_cast<nsDOMAttributeMap*>(aSupports);
return mContent;
}
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMAttributeMap)
// WebIDL
Attr* GetNamedItem(const nsAString& aAttrName);
Attr* NamedGetter(const nsAString& aAttrName, bool& aFound);
already_AddRefed<Attr>
SetNamedItem(Attr& aAttr, ErrorResult& aError)
{
return SetNamedItemInternal(aAttr, false, aError);
}
already_AddRefed<Attr>
RemoveNamedItem(const nsAString& aName, ErrorResult& aError);
Attr* Item(uint32_t aIndex);
Attr* IndexedGetter(uint32_t aIndex, bool& aFound);
uint32_t Length() const;
mozilla::dom::Attr* GetNamedItemNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName);
already_AddRefed<mozilla::dom::Attr> SetNamedItemNS(nsIDOMAttr *aNode,
mozilla::ErrorResult& aError)
Attr*
GetNamedItemNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName);
already_AddRefed<Attr>
SetNamedItemNS(Attr& aNode, ErrorResult& aError)
{
return SetNamedItemInternal(aNode, true, aError);
}
already_AddRefed<Attr>
RemoveNamedItemNS(const nsAString& aNamespaceURI, const nsAString& aLocalName,
ErrorResult& aError);
void GetSupportedNames(nsTArray<nsString>& aNames)
{
// No supported names we want to show up in iteration.
}
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
@ -183,21 +195,19 @@ private:
* SetNamedItem() (aWithNS = false) and SetNamedItemNS() (aWithNS =
* true) implementation.
*/
already_AddRefed<mozilla::dom::Attr>
SetNamedItemInternal(nsIDOMAttr *aNode,
bool aWithNS,
mozilla::ErrorResult& aError);
already_AddRefed<Attr>
SetNamedItemInternal(Attr& aNode, bool aWithNS, ErrorResult& aError);
already_AddRefed<nsINodeInfo>
GetAttrNodeInfo(const nsAString& aNamespaceURI,
const nsAString& aLocalName);
mozilla::dom::Attr* GetAttribute(nsINodeInfo* aNodeInfo, bool aNsAware);
Attr* GetAttribute(nsINodeInfo* aNodeInfo, bool aNsAware);
/**
* Remove an attribute, returns the removed node.
*/
already_AddRefed<mozilla::dom::Attr> RemoveAttribute(nsINodeInfo* aNodeInfo);
already_AddRefed<Attr> RemoveAttribute(nsINodeInfo* aNodeInfo);
};

View File

@ -143,9 +143,9 @@ nsDOMTouchEvent::InitTouchEvent(const nsAString& aType,
static_cast<nsInputEvent*>(mEvent)->InitBasicModifiers(aCtrlKey, aAltKey,
aShiftKey, aMetaKey);
mTouches = aTouches;
mTargetTouches = aTargetTouches;
mChangedTouches = aChangedTouches;
mTouches = static_cast<nsDOMTouchList*>(aTouches);
mTargetTouches = static_cast<nsDOMTouchList*>(aTargetTouches);
mChangedTouches = static_cast<nsDOMTouchList*>(aChangedTouches);
return NS_OK;
}
@ -153,79 +153,86 @@ NS_IMETHODIMP
nsDOMTouchEvent::GetTouches(nsIDOMTouchList** aTouches)
{
NS_ENSURE_ARG_POINTER(aTouches);
NS_ENSURE_STATE(mEvent);
nsRefPtr<nsDOMTouchList> t;
NS_ADDREF(*aTouches = Touches());
return NS_OK;
}
if (mTouches) {
return CallQueryInterface(mTouches, aTouches);
}
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
if (mEvent->message == NS_TOUCH_END || mEvent->message == NS_TOUCH_CANCEL) {
// for touchend events, remove any changed touches from the touches array
nsTArray<nsCOMPtr<nsIDOMTouch> > unchangedTouches;
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
if (!touches[i]->mChanged) {
unchangedTouches.AppendElement(touches[i]);
nsDOMTouchList*
nsDOMTouchEvent::Touches()
{
if (!mTouches) {
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
if (mEvent->message == NS_TOUCH_END || mEvent->message == NS_TOUCH_CANCEL) {
// for touchend events, remove any changed touches from the touches array
nsTArray<nsCOMPtr<nsIDOMTouch> > unchangedTouches;
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
if (!touches[i]->mChanged) {
unchangedTouches.AppendElement(touches[i]);
}
}
mTouches = new nsDOMTouchList(unchangedTouches);
} else {
mTouches = new nsDOMTouchList(touchEvent->touches);
}
t = new nsDOMTouchList(unchangedTouches);
} else {
t = new nsDOMTouchList(touchEvent->touches);
}
mTouches = t;
return CallQueryInterface(mTouches, aTouches);
return mTouches;
}
NS_IMETHODIMP
nsDOMTouchEvent::GetTargetTouches(nsIDOMTouchList** aTargetTouches)
{
NS_ENSURE_ARG_POINTER(aTargetTouches);
NS_ENSURE_STATE(mEvent);
NS_ADDREF(*aTargetTouches = TargetTouches());
return NS_OK;
}
if (mTargetTouches) {
return CallQueryInterface(mTargetTouches, aTargetTouches);
}
nsTArray<nsCOMPtr<nsIDOMTouch> > targetTouches;
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
// for touchend/cancel events, don't append to the target list if this is a
// touch that is ending
if ((mEvent->message != NS_TOUCH_END &&
mEvent->message != NS_TOUCH_CANCEL) || !touches[i]->mChanged) {
EventTarget* targetPtr = touches[i]->GetTarget();
if (targetPtr == mEvent->originalTarget) {
targetTouches.AppendElement(touches[i]);
nsDOMTouchList*
nsDOMTouchEvent::TargetTouches()
{
if (!mTargetTouches) {
nsTArray<nsCOMPtr<nsIDOMTouch> > targetTouches;
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
// for touchend/cancel events, don't append to the target list if this is a
// touch that is ending
if ((mEvent->message != NS_TOUCH_END &&
mEvent->message != NS_TOUCH_CANCEL) || !touches[i]->mChanged) {
EventTarget* targetPtr = touches[i]->GetTarget();
if (targetPtr == mEvent->originalTarget) {
targetTouches.AppendElement(touches[i]);
}
}
}
mTargetTouches = new nsDOMTouchList(targetTouches);
}
mTargetTouches = new nsDOMTouchList(targetTouches);
return CallQueryInterface(mTargetTouches, aTargetTouches);
return mTargetTouches;
}
NS_IMETHODIMP
nsDOMTouchEvent::GetChangedTouches(nsIDOMTouchList** aChangedTouches)
{
NS_ENSURE_ARG_POINTER(aChangedTouches);
NS_ENSURE_STATE(mEvent);
NS_ADDREF(*aChangedTouches = ChangedTouches());
return NS_OK;
}
if (mChangedTouches) {
return CallQueryInterface(mChangedTouches, aChangedTouches);
}
nsTArray<nsCOMPtr<nsIDOMTouch> > changedTouches;
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
if (touches[i]->mChanged) {
changedTouches.AppendElement(touches[i]);
nsDOMTouchList*
nsDOMTouchEvent::ChangedTouches()
{
if (!mChangedTouches) {
nsTArray<nsCOMPtr<nsIDOMTouch> > changedTouches;
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
if (touches[i]->mChanged) {
changedTouches.AppendElement(touches[i]);
}
}
mChangedTouches = new nsDOMTouchList(changedTouches);
}
mChangedTouches = new nsDOMTouchList(changedTouches);
return CallQueryInterface(mChangedTouches, aChangedTouches);
return mChangedTouches;
}
NS_IMETHODIMP

View File

@ -60,26 +60,9 @@ public:
return mozilla::dom::TouchEventBinding::Wrap(aCx, aScope, this);
}
already_AddRefed<nsIDOMTouchList> GetTouches()
{
nsCOMPtr<nsIDOMTouchList> t;
GetTouches(getter_AddRefs(t));
return t.forget();
}
already_AddRefed<nsIDOMTouchList> GetTargetTouches()
{
nsCOMPtr<nsIDOMTouchList> t;
GetTargetTouches(getter_AddRefs(t));
return t.forget();
}
already_AddRefed<nsIDOMTouchList> GetChangedTouches()
{
nsCOMPtr<nsIDOMTouchList> t;
GetChangedTouches(getter_AddRefs(t));
return t.forget();
}
nsDOMTouchList* Touches();
nsDOMTouchList* TargetTouches();
nsDOMTouchList* ChangedTouches();
bool AltKey()
{
@ -122,9 +105,9 @@ public:
static bool PrefEnabled();
protected:
nsCOMPtr<nsIDOMTouchList> mTouches;
nsCOMPtr<nsIDOMTouchList> mTargetTouches;
nsCOMPtr<nsIDOMTouchList> mChangedTouches;
nsRefPtr<nsDOMTouchList> mTouches;
nsRefPtr<nsDOMTouchList> mTargetTouches;
nsRefPtr<nsDOMTouchList> mChangedTouches;
};
#endif /* !defined(nsDOMTouchEvent_h_) */

View File

@ -23,9 +23,13 @@ static nsSVGAttrTearoffTable<SVGStringList, DOMSVGStringList>
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGStringList, mElement)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMSVGStringList, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMSVGStringList, Release)
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGStringList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGStringList)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGStringList)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
/* static */ already_AddRefed<DOMSVGStringList>
DOMSVGStringList::GetDOMWrapper(SVGStringList *aList,

View File

@ -43,11 +43,12 @@ class SVGStringList;
* them so it can return the same objects each time. It simply returns a new
* string each time any given item is requested.
*/
class DOMSVGStringList MOZ_FINAL : public nsWrapperCache
class DOMSVGStringList MOZ_FINAL : public nsISupports
, public nsWrapperCache
{
public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMSVGStringList)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMSVGStringList)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGStringList)
nsSVGElement* GetParentObject() const
{

View File

@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg">
<script>
document.documentElement.requiredFeatures.foo = null;
</script>
</svg>

After

Width:  |  Height:  |  Size: 123 B

View File

@ -65,3 +65,4 @@ load 761507-1.svg
load 831561.html
load 837450-1.svg
load 842463-1.html
load 864509.svg

View File

@ -94,9 +94,7 @@ nsBarProp::GetBrowserChrome()
if (!domwin)
return nullptr;
nsIWebBrowserChrome *browserChrome = nullptr;
mDOMWindow->GetWebBrowserChrome(&browserChrome);
return browserChrome;
return mDOMWindow->GetWebBrowserChrome();
}
//

View File

@ -102,7 +102,6 @@
#include "nsError.h"
#include "nsIDOMDOMException.h"
#include "nsIDOMNode.h"
#include "nsIDOMMozNamedAttrMap.h"
#include "nsIDOMDOMStringList.h"
// HTMLFormElement helper includes
@ -560,8 +559,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Attr, nsAttributeSH,
NODE_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozNamedAttrMap, nsNamedNodeMapSH,
ARRAY_SCRIPTABLE_FLAGS)
// Misc Core related classes
@ -1725,10 +1722,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozNamedAttrMap, nsIDOMMozNamedAttrMap)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozNamedAttrMap)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Event, nsIDOMEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -3420,6 +3413,8 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
const nsGlobalNameStruct *name_struct, JSContext *cx,
JSObject *obj, unsigned argc, jsval *argv, jsval *rval)
{
MOZ_ASSERT(obj);
nsresult rv;
nsCOMPtr<nsISupports> native;
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
@ -3935,11 +3930,7 @@ nsDOMConstructor::Construct(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
JSObject * obj, uint32_t argc, jsval * argv,
jsval * vp, bool *_retval)
{
JSObject* class_obj = JSVAL_TO_OBJECT(argv[-2]);
if (!class_obj) {
NS_ERROR("nsDOMConstructor::Construct couldn't get constructor object.");
return NS_ERROR_UNEXPECTED;
}
MOZ_ASSERT(obj);
const nsGlobalNameStruct *name_struct = GetNameStruct();
NS_ENSURE_TRUE(name_struct, NS_ERROR_FAILURE);
@ -6068,31 +6059,6 @@ nsNamedArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
}
// NamedNodeMap helper
nsISupports*
nsNamedNodeMapSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
nsWrapperCache **aCache, nsresult *aResult)
{
*aResult = NS_OK;
nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
nsINode *attr;
*aCache = attr = map->GetItemAt(aIndex);
return attr;
}
nsISupports*
nsNamedNodeMapSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsWrapperCache **aCache, nsresult *aResult)
{
nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
nsINode *attr;
*aCache = attr = map->GetNamedItem(aName);
return attr;
}
NS_IMETHODIMP
nsDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, uint32_t flags,
@ -7463,6 +7429,8 @@ nsDOMConstructorSH::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, uint32_t argc, jsval *argv, jsval *vp,
bool *_retval)
{
MOZ_ASSERT(obj);
nsDOMConstructor *wrapped =
static_cast<nsDOMConstructor *>(wrapper->Native());
@ -7482,6 +7450,8 @@ nsDOMConstructorSH::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, uint32_t argc, jsval *argv,
jsval *vp, bool *_retval)
{
MOZ_ASSERT(obj);
nsDOMConstructor *wrapped =
static_cast<nsDOMConstructor *>(wrapper->Native());

View File

@ -590,35 +590,6 @@ private:
};
// NamedNodeMap helper
class nsNamedNodeMapSH : public nsNamedArraySH
{
protected:
nsNamedNodeMapSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
{
}
virtual ~nsNamedNodeMapSH()
{
}
virtual nsISupports* GetItemAt(nsISupports *aNative, uint32_t aIndex,
nsWrapperCache **aCache, nsresult *aResult);
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsWrapperCache **cache,
nsresult *aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
return new nsNamedNodeMapSH(aData);
}
};
// Document helper, for document.location and document.on*
class nsDocumentSH : public nsNodeSH

View File

@ -19,7 +19,6 @@ DOMCI_CLASS(DOMConstructor)
DOMCI_CLASS(DOMException)
DOMCI_CLASS(Element)
DOMCI_CLASS(Attr)
DOMCI_CLASS(MozNamedAttrMap)
// Event classes
DOMCI_CLASS(Event)

View File

@ -3536,8 +3536,7 @@ nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
}
if (!primaryContent) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent));
@ -3900,9 +3899,8 @@ nsGlobalWindow::SetStatus(const nsAString& aStatus)
return NS_OK;
}
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
GetWebBrowserChrome(getter_AddRefs(browserChrome));
if(browserChrome) {
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetWebBrowserChrome();
if (browserChrome) {
browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT,
PromiseFlatString(aStatus).get());
}
@ -4031,8 +4029,7 @@ nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth)
return NS_OK;
}
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&aInnerWidth, nullptr),
NS_ERROR_FAILURE);
CheckSecurityWidthAndHeight(&aInnerWidth, nullptr);
nsRefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
@ -4048,7 +4045,8 @@ nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth)
nsRect shellArea = presContext->GetVisibleArea();
height = shellArea.height;
width = nsPresContext::CSSPixelsToAppUnits(aInnerWidth);
return SetCSSViewportWidthAndHeight(width, height);
SetCSSViewportWidthAndHeight(width, height);
return NS_OK;
}
else
{
@ -4098,8 +4096,7 @@ nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight)
return NS_OK;
}
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(nullptr, &aInnerHeight),
NS_ERROR_FAILURE);
CheckSecurityWidthAndHeight(nullptr, &aInnerHeight);
nsRefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
@ -4114,7 +4111,8 @@ nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight)
nsRect shellArea = presContext->GetVisibleArea();
width = shellArea.width;
height = nsPresContext::CSSPixelsToAppUnits(aInnerHeight);
return SetCSSViewportWidthAndHeight(width, height);
SetCSSViewportWidthAndHeight(width, height);
return NS_OK;
}
else
{
@ -4131,8 +4129,7 @@ nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight)
nsresult
nsGlobalWindow::GetOuterSize(nsIntSize* aSizeCSSPixels)
{
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
nsGlobalWindow* rootWindow =
@ -4188,14 +4185,11 @@ nsGlobalWindow::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth)
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(
aIsWidth ? &aLengthCSSPixels : nullptr,
aIsWidth ? nullptr : &aLengthCSSPixels),
NS_ERROR_FAILURE);
CheckSecurityWidthAndHeight(aIsWidth ? &aLengthCSSPixels : nullptr,
aIsWidth ? nullptr : &aLengthCSSPixels);
int32_t width, height;
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(&width, &height), NS_ERROR_FAILURE);
@ -4230,8 +4224,7 @@ nsGlobalWindow::GetScreenX(int32_t* aScreenX)
{
FORWARD_TO_OUTER(GetScreenX, (aScreenX), NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
int32_t x, y;
@ -4471,12 +4464,10 @@ nsGlobalWindow::SetScreenX(int32_t aScreenX)
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(CheckSecurityLeftAndTop(&aScreenX, nullptr),
NS_ERROR_FAILURE);
CheckSecurityLeftAndTop(&aScreenX, nullptr);
int32_t x, y;
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, &y),
@ -4495,8 +4486,7 @@ nsGlobalWindow::GetScreenY(int32_t* aScreenY)
{
FORWARD_TO_OUTER(GetScreenY, (aScreenY), NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
int32_t x, y;
@ -4522,12 +4512,10 @@ nsGlobalWindow::SetScreenY(int32_t aScreenY)
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(CheckSecurityLeftAndTop(nullptr, &aScreenY),
NS_ERROR_FAILURE);
CheckSecurityLeftAndTop(nullptr, &aScreenY);
int32_t x, y;
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, &y),
@ -4543,7 +4531,7 @@ nsGlobalWindow::SetScreenY(int32_t aScreenY)
// NOTE: Arguments to this function should have values scaled to
// CSS pixels, not device pixels.
nsresult
void
nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight)
{
#ifdef MOZ_XUL
@ -4567,8 +4555,6 @@ nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight)
}
}
}
return NS_OK;
}
// NOTE: Arguments to this function should have values in device pixels
@ -4588,7 +4574,7 @@ nsGlobalWindow::SetDocShellWidthAndHeight(int32_t aInnerWidth, int32_t aInnerHei
}
// NOTE: Arguments to this function should have values in app units
nsresult
void
nsGlobalWindow::SetCSSViewportWidthAndHeight(nscoord aInnerWidth, nscoord aInnerHeight)
{
nsRefPtr<nsPresContext> presContext;
@ -4599,12 +4585,11 @@ nsGlobalWindow::SetCSSViewportWidthAndHeight(nscoord aInnerWidth, nscoord aInner
shellArea.width = aInnerWidth;
presContext->SetVisibleArea(shellArea);
return NS_OK;
}
// NOTE: Arguments to this function should have values scaled to
// CSS pixels, not device pixels.
nsresult
void
nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop)
{
// This one is harder. We have to get the screen size and window dimensions.
@ -4623,8 +4608,7 @@ nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop)
rootWindow->FlushPendingNotifications(Flush_Layout);
}
nsCOMPtr<nsIBaseWindow> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
nsCOMPtr<nsIBaseWindow> treeOwner = GetTreeOwnerWindow();
nsCOMPtr<nsIDOMScreen> screen;
GetScreen(getter_AddRefs(screen));
@ -4680,8 +4664,6 @@ nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop)
*aTop = 0;
}
}
return NS_OK;
}
NS_IMETHODIMP
@ -4885,8 +4867,7 @@ nsGlobalWindow::WindowExists(const nsAString& aName,
already_AddRefed<nsIWidget>
nsGlobalWindow::GetMainWidget()
{
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
nsIWidget *widget = nullptr;
@ -4961,8 +4942,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
// Prevent chrome documents which are still loading from resizing
// the window after we set fullscreen mode.
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(treeOwnerAsWin));
if (aFullScreen && xulWin) {
xulWin->SetIntrinsicallySized(false);
@ -5224,8 +5204,7 @@ nsGlobalWindow::CanMoveResizeWindows()
}
// Ignore the request if we have more than one tab in the window.
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
if (treeOwner) {
uint32_t itemCount;
if (NS_SUCCEEDED(treeOwner->GetTargetableShellCount(&itemCount)) &&
@ -5268,13 +5247,6 @@ nsGlobalWindow::Alert(const nsAString& aString)
// the whole time a modal dialog is open.
nsAutoPopupStatePusher popupStatePusher(openAbused, true);
// Special handling for alert(null) in JS for backwards
// compatibility.
NS_NAMED_LITERAL_STRING(null_str, "null");
const nsAString *str = DOMStringIsNull(aString) ? &null_str : &aString;
// Before bringing up the window, unsuppress painting and flush
// pending reflows.
EnsureReflowFlushAndPaint();
@ -5285,7 +5257,7 @@ nsGlobalWindow::Alert(const nsAString& aString)
// Remove non-terminating null characters from the
// string. See bug #310037.
nsAutoString final;
nsContentUtils::StripNullChars(*str, final);
nsContentUtils::StripNullChars(aString, final);
// Check if we're being called at a point where we can't use tab-modal
// prompts, because something doesn't want reentrancy.
@ -5514,8 +5486,7 @@ nsGlobalWindow::Focus()
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
bool isActive = (rootWin == activeWindow);
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
if (treeOwnerAsWin && (canFocus || isActive)) {
bool isEnabled = true;
if (NS_SUCCEEDED(treeOwnerAsWin->GetEnabled(&isEnabled)) && !isEnabled) {
@ -5598,8 +5569,7 @@ nsGlobalWindow::Blur()
// shouldn't throw exceptions to web content.
nsresult rv = NS_OK;
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow(do_GetInterface(treeOwner));
if (siteWindow) {
// This method call may cause mDocShell to become nullptr.
@ -5793,12 +5763,10 @@ nsGlobalWindow::MoveTo(int32_t aXPos, int32_t aYPos)
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(CheckSecurityLeftAndTop(&aXPos, &aYPos),
NS_ERROR_FAILURE);
CheckSecurityLeftAndTop(&aXPos, &aYPos);
// mild abuse of a "size" object so we don't need more helper functions
nsIntSize devPos(CSSToDevIntPixels(nsIntSize(aXPos, aYPos)));
@ -5823,8 +5791,7 @@ nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif)
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
// To do this correctly we have to convert what we get from GetPosition
@ -5840,9 +5807,7 @@ nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif)
cssPos.width += aXDif;
cssPos.height += aYDif;
NS_ENSURE_SUCCESS(CheckSecurityLeftAndTop(&cssPos.width,
&cssPos.height),
NS_ERROR_FAILURE);
CheckSecurityLeftAndTop(&cssPos.width, &cssPos.height);
nsIntSize newDevPos(CSSToDevIntPixels(cssPos));
@ -5867,12 +5832,10 @@ nsGlobalWindow::ResizeTo(int32_t aWidth, int32_t aHeight)
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&aWidth, &aHeight),
NS_ERROR_FAILURE);
CheckSecurityWidthAndHeight(&aWidth, &aHeight);
nsIntSize devSz(CSSToDevIntPixels(nsIntSize(aWidth, aHeight)));
@ -5896,8 +5859,7 @@ nsGlobalWindow::ResizeBy(int32_t aWidthDif, int32_t aHeightDif)
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
int32_t width, height;
@ -5912,9 +5874,7 @@ nsGlobalWindow::ResizeBy(int32_t aWidthDif, int32_t aHeightDif)
cssSize.width += aWidthDif;
cssSize.height += aHeightDif;
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&cssSize.width,
&cssSize.height),
NS_ERROR_FAILURE);
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height);
nsIntSize newDevSize(CSSToDevIntPixels(cssSize));
@ -5957,14 +5917,11 @@ nsGlobalWindow::SizeToContent()
// Make sure the new size is following the CheckSecurityWidthAndHeight
// rules.
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
nsIntSize cssSize(DevToCSSIntPixels(nsIntSize(width, height)));
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&cssSize.width,
&cssSize.height),
NS_ERROR_FAILURE);
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height);
nsIntSize newDevSize(CSSToDevIntPixels(cssSize));
@ -7115,8 +7072,7 @@ nsGlobalWindow::ReallyCloseWindow()
// Make sure we never reenter this method.
mHavePendingClose = true;
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
// If there's no treeOwnerAsWin, this window must already be closed.
@ -9819,8 +9775,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
*aReturn = nullptr;
nsCOMPtr<nsIWebBrowserChrome> chrome;
GetWebBrowserChrome(getter_AddRefs(chrome));
nsCOMPtr<nsIWebBrowserChrome> chrome = GetWebBrowserChrome();
if (!chrome) {
// No chrome means we don't want to go through with this open call
// -- see nsIWindowWatcher.idl
@ -10754,27 +10709,27 @@ nsGlobalWindow::TimerCallback(nsITimer *aTimer, void *aClosure)
// nsGlobalWindow: Helper Functions
//*****************************************************************************
nsresult
nsGlobalWindow::GetTreeOwner(nsIDocShellTreeOwner **aTreeOwner)
already_AddRefed<nsIDocShellTreeOwner>
nsGlobalWindow::GetTreeOwner()
{
FORWARD_TO_OUTER(GetTreeOwner, (aTreeOwner), NS_ERROR_NOT_INITIALIZED);
FORWARD_TO_OUTER(GetTreeOwner, (), nullptr);
// If there's no docShellAsItem, this window must have been closed,
// in that case there is no tree owner.
if (!mDocShell) {
*aTreeOwner = nullptr;
return NS_OK;
return nullptr;
}
return mDocShell->GetTreeOwner(aTreeOwner);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
mDocShell->GetTreeOwner(getter_AddRefs(treeOwner));
return treeOwner.forget();
}
nsresult
nsGlobalWindow::GetTreeOwner(nsIBaseWindow **aTreeOwner)
already_AddRefed<nsIBaseWindow>
nsGlobalWindow::GetTreeOwnerWindow()
{
FORWARD_TO_OUTER(GetTreeOwner, (aTreeOwner), NS_ERROR_NOT_INITIALIZED);
FORWARD_TO_OUTER(GetTreeOwnerWindow, (), nullptr);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
@ -10785,24 +10740,17 @@ nsGlobalWindow::GetTreeOwner(nsIBaseWindow **aTreeOwner)
mDocShell->GetTreeOwner(getter_AddRefs(treeOwner));
}
if (!treeOwner) {
*aTreeOwner = nullptr;
return NS_OK;
}
return CallQueryInterface(treeOwner, aTreeOwner);
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(treeOwner);
return baseWindow.forget();
}
nsresult
nsGlobalWindow::GetWebBrowserChrome(nsIWebBrowserChrome **aBrowserChrome)
already_AddRefed<nsIWebBrowserChrome>
nsGlobalWindow::GetWebBrowserChrome()
{
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner));
NS_IF_ADDREF(*aBrowserChrome = browserChrome);
return NS_OK;
nsCOMPtr<nsIWebBrowserChrome> browserChrome = do_GetInterface(treeOwner);
return browserChrome.forget();
}
nsIScrollableFrame *
@ -11428,14 +11376,9 @@ nsGlobalChromeWindow::GetWindowState(uint16_t* aWindowState)
nsCOMPtr<nsIWidget> widget = GetMainWidget();
int32_t aMode = 0;
int32_t mode = widget ? widget->SizeMode() : 0;
if (widget) {
nsresult rv = widget->GetSizeMode(&aMode);
NS_ENSURE_SUCCESS(rv, rv);
}
switch (aMode) {
switch (mode) {
case nsSizeMode_Minimized:
*aWindowState = nsIDOMChromeWindow::STATE_MINIMIZED;
break;

View File

@ -889,9 +889,9 @@ protected:
static void TimerCallback(nsITimer *aTimer, void *aClosure);
// Helper Functions
nsresult GetTreeOwner(nsIDocShellTreeOwner** aTreeOwner);
nsresult GetTreeOwner(nsIBaseWindow** aTreeOwner);
nsresult GetWebBrowserChrome(nsIWebBrowserChrome** aBrowserChrome);
already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
already_AddRefed<nsIBaseWindow> GetTreeOwnerWindow();
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
nsresult SecurityCheckURL(const char *aURL);
nsresult BuildURIfromBase(const char *aURL,
nsIURI **aBuiltURI,
@ -917,11 +917,11 @@ protected:
void FlushPendingNotifications(mozFlushType aType);
void EnsureReflowFlushAndPaint();
nsresult CheckSecurityWidthAndHeight(int32_t* width, int32_t* height);
nsresult CheckSecurityLeftAndTop(int32_t* left, int32_t* top);
void CheckSecurityWidthAndHeight(int32_t* width, int32_t* height);
void CheckSecurityLeftAndTop(int32_t* left, int32_t* top);
// Arguments to this function should have values in app units
nsresult SetCSSViewportWidthAndHeight(nscoord width, nscoord height);
void SetCSSViewportWidthAndHeight(nscoord width, nscoord height);
// Arguments to this function should have values in device pixels
nsresult SetDocShellWidthAndHeight(int32_t width, int32_t height);

View File

@ -356,15 +356,6 @@ DOMInterfaces = {
'workers': True,
},
'Geolocation': {
'headerFile': 'nsGeolocation.h'
},
'UndoManager': [
{
'implicitJSContext' : [ 'undo', 'redo', 'transact' ]
}],
'FileRequest': {
'nativeType': 'mozilla::dom::file::DOMFileRequest',
},
@ -387,6 +378,10 @@ DOMInterfaces = {
'nativeType': 'nsDOMGamepad',
},
'Geolocation': {
'headerFile': 'nsGeolocation.h'
},
'HTMLAppletElement': {
'nativeType': 'mozilla::dom::HTMLSharedObjectElement'
},
@ -637,6 +632,10 @@ DOMInterfaces = {
'previousSibling', 'nextSibling' ]
},
'MozNamedAttrMap': {
'nativeType': 'nsDOMAttributeMap',
},
'Node': {
'nativeType': 'nsINode',
'concrete': False,
@ -974,7 +973,6 @@ DOMInterfaces = {
'SVGStringList': {
'nativeType': 'mozilla::DOMSVGStringList',
'headerFile': 'DOMSVGStringList.h',
'nativeOwnership': 'refcounted',
},
'SVGSVGElement': {
@ -1044,6 +1042,10 @@ DOMInterfaces = {
'hasXPConnectImpls': True
},
'UndoManager': {
'implicitJSContext' : [ 'undo', 'redo', 'transact' ],
},
'URL' : [{
'concrete': False,
},
@ -1536,7 +1538,6 @@ addExternalIface('MozTreeBoxObject', nativeType='nsITreeBoxObject',
addExternalIface('MozTreeColumn', nativeType='nsITreeColumn',
headerFile='nsITreeColumns.h')
addExternalIface('MozXULTemplateBuilder', nativeType='nsIXULTemplateBuilder')
addExternalIface('MozNamedAttrMap')
addExternalIface('nsIControllers', nativeType='nsIControllers')
addExternalIface('nsIInputStreamCallback', nativeType='nsIInputStreamCallback',
headerFile='nsIAsyncInputStream.h')

View File

@ -185,7 +185,7 @@ interface nsIDOMWindow : nsISupports
// user prompts
void alert(in DOMString text);
void alert([Null(Stringify)] in DOMString text);
boolean confirm(in DOMString text);
// prompt() should return a null string if cancel is pressed

View File

@ -38,7 +38,7 @@ interface nsIDOMTouch : nsISupports {
%}
};
[scriptable, uuid(60706eb7-d50d-4379-b01c-e78e6af84213)]
[scriptable, builtinclass, uuid(60706eb7-d50d-4379-b01c-e78e6af84213)]
interface nsIDOMTouchList : nsISupports {
readonly attribute unsigned long length;
nsIDOMTouch item(in unsigned long index);

View File

@ -13,8 +13,6 @@
* liability, trademark and document use rules apply.
*/
interface MozNamedAttrMap;
interface Element : Node {
/*
We haven't moved these from Node to Element like the spec wants.

View File

@ -0,0 +1,27 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
interface Attr;
/**
* This is a temporary, non-standard interface, to ease the transition to a
* world where Attr no longer inherits from Node.
*/
interface MozNamedAttrMap {
getter Attr? getNamedItem(DOMString name);
[Throws]
Attr? setNamedItem(Attr arg);
[Throws]
Attr removeNamedItem(DOMString name);
getter Attr? item(unsigned long index);
readonly attribute unsigned long length;
Attr? getNamedItemNS(DOMString? namespaceURI, DOMString localName);
[Throws]
Attr? setNamedItemNS(Attr arg);
[Throws]
Attr removeNamedItemNS(DOMString? namespaceURI, DOMString localName);
};

View File

@ -9,9 +9,9 @@ interface WindowProxy;
[PrefControlled]
interface TouchEvent : UIEvent {
readonly attribute TouchList? touches;
readonly attribute TouchList? targetTouches;
readonly attribute TouchList? changedTouches;
readonly attribute TouchList touches;
readonly attribute TouchList targetTouches;
readonly attribute TouchList changedTouches;
readonly attribute boolean altKey;
readonly attribute boolean metaKey;

View File

@ -163,6 +163,7 @@ webidl_files = \
MouseEvent.webidl \
MouseScrollEvent.webidl \
MozActivity.webidl \
MozNamedAttrMap.webidl \
MutationEvent.webidl \
MutationObserver.webidl \
NetDashboard.webidl \

View File

@ -956,11 +956,12 @@ XPC_WN_Helper_CheckAccess(JSContext *cx, JSHandleObject obj, JSHandleId id,
static JSBool
XPC_WN_Helper_Call(JSContext *cx, unsigned argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
// N.B. we want obj to be the callee, not JS_THIS(cx, vp)
RootedObject obj(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
RootedObject obj(cx, &args.callee());
XPCCallContext ccx(JS_CALLER, cx, obj, NullPtr(), JSID_VOIDHANDLE,
argc, JS_ARGV(cx, vp), vp);
XPCCallContext ccx(JS_CALLER, cx, obj, NullPtr(), JSID_VOIDHANDLE, args.length(),
args.array(), args.rval().address());
if (!ccx.IsValid())
return false;
@ -968,19 +969,20 @@ XPC_WN_Helper_Call(JSContext *cx, unsigned argc, jsval *vp)
SLIM_LOG_WILL_MORPH(cx, obj);
PRE_HELPER_STUB_NO_SLIM
Call(wrapper, cx, obj, argc, JS_ARGV(cx, vp), vp, &retval);
Call(wrapper, cx, obj, args.length(), args.array(), args.rval().address(), &retval);
POST_HELPER_STUB
}
static JSBool
XPC_WN_Helper_Construct(JSContext *cx, unsigned argc, jsval *vp)
{
RootedObject obj(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
RootedObject obj(cx, &args.callee());
if (!obj)
return false;
XPCCallContext ccx(JS_CALLER, cx, obj, NullPtr(), JSID_VOIDHANDLE,
argc, JS_ARGV(cx, vp), vp);
XPCCallContext ccx(JS_CALLER, cx, obj, NullPtr(), JSID_VOIDHANDLE, args.length(),
args.array(), args.rval().address());
if (!ccx.IsValid())
return false;
@ -988,7 +990,7 @@ XPC_WN_Helper_Construct(JSContext *cx, unsigned argc, jsval *vp)
SLIM_LOG_WILL_MORPH(cx, obj);
PRE_HELPER_STUB_NO_SLIM
Construct(wrapper, cx, obj, argc, JS_ARGV(cx, vp), vp, &retval);
Construct(wrapper, cx, obj, args.length(), args.array(), args.rval().address(), &retval);
POST_HELPER_STUB
}

View File

@ -57,8 +57,6 @@ members = [
'nsIDOMCanvasPattern.*',
# dom/interfaces/core
'nsIDOMMozNamedAttrMap.item',
'nsIDOMMozNamedAttrMap.length',
'nsIDOMDOMStringList.*',
'nsIDOMKeyEvent.*',

View File

@ -1473,11 +1473,8 @@ nsXULPopupManager::MayShowPopup(nsMenuPopupFrame* aPopup)
// window, so this is always disabled.
nsCOMPtr<nsIWidget> mainWidget;
baseWin->GetMainWidget(getter_AddRefs(mainWidget));
if (mainWidget) {
int32_t sizeMode;
mainWidget->GetSizeMode(&sizeMode);
if (sizeMode == nsSizeMode_Minimized)
return false;
if (mainWidget && mainWidget->SizeMode() == nsSizeMode_Minimized) {
return false;
}
// cannot open a popup that is a submenu of a menupopup that isn't open.

View File

@ -92,8 +92,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
#endif
#define NS_IWIDGET_IID \
{ 0xdaac8d94, 0x14f3, 0x4bc4, \
{ 0xa8, 0xc, 0xf0, 0xe6, 0x46, 0x1e, 0xad, 0x40 } }
{ 0x16da2e50, 0x0fee, 0x4719, \
{ 0x93, 0x37, 0xce, 0xd4, 0xdd, 0xd2, 0x22, 0x53 } }
/*
* Window shadow styles
@ -848,7 +848,7 @@ class nsIWidget : public nsISupports {
* Return size mode (minimized, maximized, normalized).
* Returns a value from nsSizeMode (see nsGUIEvent.h)
*/
NS_IMETHOD GetSizeMode(int32_t* aMode) = 0;
virtual int32_t SizeMode() = 0;
/**
* Enable or disable this Widget

View File

@ -218,8 +218,7 @@ nsresult os2FrameWindow::Show(bool aState)
ulFlags = SWP_SHOW | SWP_ACTIVATE;
uint32_t ulStyle = WinQueryWindowULong(mFrameWnd, QWL_STYLE);
int32_t sizeMode;
mOwner->GetSizeMode(&sizeMode);
int32_t sizeMode = mOwner->SizeMode();
if (!(ulStyle & WS_VISIBLE)) {
if (sizeMode == nsSizeMode_Maximized) {
ulFlags |= SWP_MAXIMIZE;
@ -314,9 +313,7 @@ void os2FrameWindow::ActivateTopLevelWidget()
// be restored as soon as the user clicks on it. When the user
// explicitly restores it, SetSizeMode() will call this method.
if (mNeedActivation) {
int32_t sizeMode;
mOwner->GetSizeMode(&sizeMode);
if (sizeMode != nsSizeMode_Minimized) {
if (mOwner->SizeMode() != nsSizeMode_Minimized) {
mNeedActivation = false;
DEBUGFOCUS(NS_ACTIVATE);
mOwner->DispatchActivationEvent(NS_ACTIVATE);
@ -333,8 +330,7 @@ void os2FrameWindow::ActivateTopLevelWidget()
nsresult os2FrameWindow::SetSizeMode(int32_t aMode)
{
int32_t previousMode;
mOwner->GetSizeMode(&previousMode);
int32_t previousMode = mOwner->SizeMode();
// save the new state
nsresult rv = mOwner->nsBaseWidget::SetSizeMode(aMode);

View File

@ -556,17 +556,6 @@ NS_IMETHODIMP nsBaseWidget::SetSizeMode(int32_t aMode)
return NS_ERROR_ILLEGAL_VALUE;
}
//-------------------------------------------------------------------------
//
// Get the size mode (minimized, maximized, that sort of thing...)
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseWidget::GetSizeMode(int32_t* aMode)
{
*aMode = mSizeMode;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get the foreground color

View File

@ -84,7 +84,10 @@ public:
nsIWidget *aWidget, bool aActivate);
NS_IMETHOD SetSizeMode(int32_t aMode);
NS_IMETHOD GetSizeMode(int32_t* aMode);
virtual int32_t SizeMode() MOZ_OVERRIDE
{
return mSizeMode;
}
virtual nscolor GetForegroundColor(void);
NS_IMETHOD SetForegroundColor(const nscolor &aColor);

View File

@ -461,11 +461,9 @@ CheckForFullscreenWindow()
windowList->GetNext(getter_AddRefs(supportsWindow));
nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(supportsWindow));
if (baseWin) {
int32_t sizeMode;
nsCOMPtr<nsIWidget> widget;
baseWin->GetMainWidget(getter_AddRefs(widget));
if (widget && NS_SUCCEEDED(widget->GetSizeMode(&sizeMode)) &&
sizeMode == nsSizeMode_Fullscreen) {
if (widget && widget->SizeMode() == nsSizeMode_Fullscreen) {
return true;
}
}

View File

@ -208,12 +208,10 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(uint32_t aLevel)
/* refuse to raise a maximized window above the normal browser level,
for fear it could hide newly opened browser windows */
if (aLevel > nsIXULWindow::normalZ) {
int32_t sizeMode;
if (mWindow) {
mWindow->GetSizeMode(&sizeMode);
if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen)
return NS_ERROR_FAILURE;
if (aLevel > nsIXULWindow::normalZ && mWindow) {
int32_t sizeMode = mWindow->SizeMode();
if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen) {
return NS_ERROR_FAILURE;
}
}
@ -1460,12 +1458,11 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
return NS_OK;
}
int32_t x, y, cx, cy;
int32_t sizeMode;
// get our size, position and mode to persist
int32_t x, y, cx, cy;
NS_ENSURE_SUCCESS(GetPositionAndSize(&x, &y, &cx, &cy), NS_ERROR_FAILURE);
mWindow->GetSizeMode(&sizeMode);
int32_t sizeMode = mWindow->SizeMode();
double scale = mWindow->GetDefaultScale();
// make our position relative to our parent, if any