mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Part 11 of fix for bug 560273 (Stop using DOM tearoffs from quickstubs) - move nsIDOMNSElement implementation to nsGenericElement. r=jst.
--HG-- extra : rebase_source : 6b39d2cbb5b6462b0d1e65ee0f204fb1804a468e
This commit is contained in:
parent
ae0b1a86f6
commit
922c155511
@ -1594,6 +1594,15 @@ public:
|
||||
{
|
||||
sIsHandlingKeyBoardEvent = aHandling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for getElementsByClassName. aRootNode is the node (either
|
||||
* document or element), which getElementsByClassName was called on.
|
||||
*/
|
||||
static nsresult GetElementsByClassName(nsINode* aRootNode,
|
||||
const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn);
|
||||
|
||||
private:
|
||||
|
||||
static PRBool InitializeEventTable();
|
||||
|
@ -195,7 +195,6 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
||||
#include "jstypedarray.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsDocument.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -5768,11 +5767,9 @@ struct ClassMatchingInfo {
|
||||
nsCaseTreatment mCaseTreatment;
|
||||
};
|
||||
|
||||
// static
|
||||
PRBool
|
||||
nsDocument::MatchClassNames(nsIContent* aContent,
|
||||
PRInt32 aNamespaceID,
|
||||
nsIAtom* aAtom, void* aData)
|
||||
static PRBool
|
||||
MatchClassNames(nsIContent* aContent, PRInt32 aNamespaceID, nsIAtom* aAtom,
|
||||
void* aData)
|
||||
{
|
||||
// We can't match if there are no class names
|
||||
const nsAttrValue* classAttr = aContent->GetClasses();
|
||||
@ -5794,19 +5791,18 @@ nsDocument::MatchClassNames(nsIContent* aContent,
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsDocument::DestroyClassNameArray(void* aData)
|
||||
static void
|
||||
DestroyClassNameArray(void* aData)
|
||||
{
|
||||
ClassMatchingInfo* info = static_cast<ClassMatchingInfo*>(aData);
|
||||
delete info;
|
||||
}
|
||||
|
||||
// static GetElementsByClassName helpers
|
||||
// static
|
||||
nsresult
|
||||
nsDocument::GetElementsByClassNameHelper(nsINode* aRootNode,
|
||||
const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn)
|
||||
nsContentUtils::GetElementsByClassName(nsINode* aRootNode,
|
||||
const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aRootNode, "Must have root node");
|
||||
|
||||
|
@ -2814,7 +2814,7 @@ NS_IMETHODIMP
|
||||
nsDocument::GetElementsByClassName(const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn)
|
||||
{
|
||||
return GetElementsByClassNameHelper(this, aClasses, aReturn);
|
||||
return nsContentUtils::GetElementsByClassName(this, aClasses, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -899,14 +899,6 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDocument,
|
||||
nsIDocument)
|
||||
|
||||
/**
|
||||
* Utility method for getElementsByClassName. aRootNode is the node (either
|
||||
* document or element), which getElementsByClassName was called on.
|
||||
*/
|
||||
static nsresult GetElementsByClassNameHelper(nsINode* aRootNode,
|
||||
const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn);
|
||||
|
||||
void DoNotifyPossibleTitleChange();
|
||||
|
||||
nsExternalResourceMap& ExternalResourceMap()
|
||||
@ -1005,12 +997,6 @@ protected:
|
||||
virtual nsPIDOMWindow *GetWindowInternal();
|
||||
virtual nsPIDOMWindow *GetInnerWindowInternal();
|
||||
|
||||
// nsContentList match functions for GetElementsByClassName
|
||||
static PRBool MatchClassNames(nsIContent* aContent, PRInt32 aNamespaceID,
|
||||
nsIAtom* aAtom, void* aData);
|
||||
|
||||
static void DestroyClassNameArray(void* aData);
|
||||
|
||||
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mObservers, nsIDocumentObserver, \
|
||||
func_, params_);
|
||||
|
@ -1232,21 +1232,104 @@ nsNode3Tearoff::IsDefaultNamespace(const nsAString& aNamespaceURI,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsGenericElement::GetFirstElementChild()
|
||||
{
|
||||
nsAttrAndChildArray& children = mAttrsAndChildren;
|
||||
PRUint32 i, count = children.ChildCount();
|
||||
for (i = 0; i < count; ++i) {
|
||||
nsIContent* child = children.ChildAt(i);
|
||||
if (child->IsElement()) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsGenericElement::GetLastElementChild()
|
||||
{
|
||||
nsAttrAndChildArray& children = mAttrsAndChildren;
|
||||
PRUint32 i = children.ChildCount();
|
||||
while (i > 0) {
|
||||
nsIContent* child = children.ChildAt(--i);
|
||||
if (child->IsElement()) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsGenericElement::GetPreviousElementSibling()
|
||||
{
|
||||
nsIContent* parent = GetParent();
|
||||
if (!parent) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_ASSERTION(parent->IsElement() ||
|
||||
parent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT),
|
||||
"Parent content must be an element or a doc fragment");
|
||||
|
||||
nsAttrAndChildArray& children =
|
||||
static_cast<nsGenericElement*>(parent)->mAttrsAndChildren;
|
||||
PRInt32 index = children.IndexOfChild(this);
|
||||
if (index < 0) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRUint32 i = index;
|
||||
while (i > 0) {
|
||||
nsIContent* child = children.ChildAt((PRUint32)--i);
|
||||
if (child->IsElement()) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsGenericElement::GetNextElementSibling()
|
||||
{
|
||||
nsIContent* parent = GetParent();
|
||||
if (!parent) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_ASSERTION(parent->IsElement() ||
|
||||
parent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT),
|
||||
"Parent content must be an element or a doc fragment");
|
||||
|
||||
nsAttrAndChildArray& children =
|
||||
static_cast<nsGenericElement*>(parent)->mAttrsAndChildren;
|
||||
PRInt32 index = children.IndexOfChild(this);
|
||||
if (index < 0) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRUint32 i, count = children.ChildCount();
|
||||
for (i = (PRUint32)index + 1; i < count; ++i) {
|
||||
nsIContent* child = children.ChildAt(i);
|
||||
if (child->IsElement()) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetFirstElementChild(nsIDOMElement** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsAttrAndChildArray& children = mContent->mAttrsAndChildren;
|
||||
PRUint32 i, count = children.ChildCount();
|
||||
for (i = 0; i < count; ++i) {
|
||||
nsIContent* child = children.ChildAt(i);
|
||||
if (child->IsElement()) {
|
||||
return CallQueryInterface(child, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
nsIContent *result = mContent->GetFirstElementChild();
|
||||
|
||||
return result ? CallQueryInterface(result, aResult) : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1254,16 +1337,9 @@ nsNSElementTearoff::GetLastElementChild(nsIDOMElement** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsAttrAndChildArray& children = mContent->mAttrsAndChildren;
|
||||
PRUint32 i = children.ChildCount();
|
||||
while (i > 0) {
|
||||
nsIContent* child = children.ChildAt(--i);
|
||||
if (child->IsElement()) {
|
||||
return CallQueryInterface(child, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
nsIContent *result = mContent->GetLastElementChild();
|
||||
|
||||
return result ? CallQueryInterface(result, aResult) : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1271,31 +1347,9 @@ nsNSElementTearoff::GetPreviousElementSibling(nsIDOMElement** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsIContent* parent = mContent->GetParent();
|
||||
if (!parent) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsIContent *result = mContent->GetPreviousElementSibling();
|
||||
|
||||
NS_ASSERTION(parent->IsElement() ||
|
||||
parent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT),
|
||||
"Parent content must be an element or a doc fragment");
|
||||
|
||||
nsAttrAndChildArray& children =
|
||||
static_cast<nsGenericElement*>(parent)->mAttrsAndChildren;
|
||||
PRInt32 index = children.IndexOfChild(mContent);
|
||||
if (index < 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint32 i = index;
|
||||
while (i > 0) {
|
||||
nsIContent* child = children.ChildAt((PRUint32)--i);
|
||||
if (child->IsElement()) {
|
||||
return CallQueryInterface(child, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return result ? CallQueryInterface(result, aResult) : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1303,41 +1357,19 @@ nsNSElementTearoff::GetNextElementSibling(nsIDOMElement** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsIContent* parent = mContent->GetParent();
|
||||
if (!parent) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsIContent *result = mContent->GetNextElementSibling();
|
||||
|
||||
NS_ASSERTION(parent->IsElement() ||
|
||||
parent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT),
|
||||
"Parent content must be an element or a doc fragment");
|
||||
|
||||
nsAttrAndChildArray& children =
|
||||
static_cast<nsGenericElement*>(parent)->mAttrsAndChildren;
|
||||
PRInt32 index = children.IndexOfChild(mContent);
|
||||
if (index < 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint32 i, count = children.ChildCount();
|
||||
for (i = (PRUint32)index + 1; i < count; ++i) {
|
||||
nsIContent* child = children.ChildAt(i);
|
||||
if (child->IsElement()) {
|
||||
return CallQueryInterface(child, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return result ? CallQueryInterface(result, aResult) : NS_OK;
|
||||
}
|
||||
|
||||
nsContentList*
|
||||
nsNSElementTearoff::GetChildrenList()
|
||||
nsGenericElement::GetChildrenList()
|
||||
{
|
||||
nsGenericElement::nsDOMSlots *slots = mContent->GetDOMSlots();
|
||||
nsGenericElement::nsDOMSlots *slots = GetDOMSlots();
|
||||
NS_ENSURE_TRUE(slots, nsnull);
|
||||
|
||||
if (!slots->mChildrenList) {
|
||||
slots->mChildrenList = new nsContentList(mContent, nsGkAtoms::_asterix,
|
||||
slots->mChildrenList = new nsContentList(this, nsGkAtoms::_asterix,
|
||||
kNameSpaceID_Wildcard, PR_FALSE);
|
||||
}
|
||||
|
||||
@ -1347,43 +1379,50 @@ nsNSElementTearoff::GetChildrenList()
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetChildElementCount(PRUint32* aResult)
|
||||
{
|
||||
*aResult = 0;
|
||||
|
||||
nsContentList* list = GetChildrenList();
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aResult = list->Length(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
return mContent->GetChildElementCount(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetChildren(nsIDOMNodeList** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
return mContent->GetChildren(aResult);
|
||||
}
|
||||
|
||||
nsContentList* list = GetChildrenList();
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsIDOMDOMTokenList*
|
||||
nsGenericElement::GetClassList(nsresult *aResult)
|
||||
{
|
||||
*aResult = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult = list);
|
||||
nsGenericElement::nsDOMSlots *slots = GetDOMSlots();
|
||||
NS_ENSURE_TRUE(slots, nsnull);
|
||||
|
||||
return NS_OK;
|
||||
if (!slots->mClassList) {
|
||||
nsCOMPtr<nsIAtom> classAttr = GetClassAttributeName();
|
||||
if (!classAttr) {
|
||||
*aResult = NS_OK;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
slots->mClassList = new nsDOMTokenList(this, classAttr);
|
||||
NS_ENSURE_TRUE(slots->mClassList, nsnull);
|
||||
}
|
||||
|
||||
*aResult = NS_OK;
|
||||
|
||||
return slots->mClassList;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetClassList(nsIDOMDOMTokenList** aResult)
|
||||
{
|
||||
nsGenericElement::nsDOMSlots *slots = mContent->GetDOMSlots();
|
||||
NS_ENSURE_TRUE(slots, nsnull);
|
||||
*aResult = nsnull;
|
||||
|
||||
if (!slots->mClassList) {
|
||||
nsCOMPtr<nsIAtom> classAttr = mContent->GetClassAttributeName();
|
||||
NS_ENSURE_TRUE(classAttr, NS_OK);
|
||||
slots->mClassList = new nsDOMTokenList(mContent, classAttr);
|
||||
NS_ENSURE_TRUE(slots->mClassList, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
nsresult rv;
|
||||
nsIDOMDOMTokenList* list = mContent->GetClassList(&rv);
|
||||
NS_ENSURE_TRUE(list, rv);
|
||||
|
||||
NS_ADDREF(*aResult = slots->mClassList);
|
||||
NS_ADDREF(*aResult = list);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1429,7 +1468,7 @@ NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetElementsByClassName(const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn)
|
||||
{
|
||||
return nsDocument::GetElementsByClassNameHelper(mContent, aClasses, aReturn);
|
||||
return mContent->GetElementsByClassName(aClasses, aReturn);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
@ -1465,18 +1504,17 @@ nsGenericElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
|
||||
}
|
||||
|
||||
nsIScrollableFrame*
|
||||
nsNSElementTearoff::GetScrollFrame(nsIFrame **aStyledFrame)
|
||||
nsGenericElement::GetScrollFrame(nsIFrame **aStyledFrame)
|
||||
{
|
||||
// it isn't clear what to return for SVG nodes, so just return nothing
|
||||
if (mContent->IsSVG()) {
|
||||
if (IsSVG()) {
|
||||
if (aStyledFrame) {
|
||||
*aStyledFrame = nsnull;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIFrame* frame =
|
||||
(static_cast<nsGenericElement*>(mContent))->GetStyledFrame();
|
||||
nsIFrame* frame = GetStyledFrame();
|
||||
|
||||
if (aStyledFrame) {
|
||||
*aStyledFrame = frame;
|
||||
@ -1493,11 +1531,11 @@ nsNSElementTearoff::GetScrollFrame(nsIFrame **aStyledFrame)
|
||||
return scrollFrame;
|
||||
}
|
||||
|
||||
nsIDocument* doc = mContent->GetOwnerDoc();
|
||||
nsIDocument* doc = GetOwnerDoc();
|
||||
PRBool quirksMode = doc->GetCompatibilityMode() == eCompatibility_NavQuirks;
|
||||
Element* elementWithRootScrollInfo =
|
||||
quirksMode ? doc->GetBodyElement() : doc->GetRootElement();
|
||||
if (mContent == elementWithRootScrollInfo) {
|
||||
if (this == elementWithRootScrollInfo) {
|
||||
// In quirks mode, the scroll info for the body element should map to the
|
||||
// root scrollable frame.
|
||||
// In strict mode, the scroll info for the root element should map to the
|
||||
@ -1508,23 +1546,26 @@ nsNSElementTearoff::GetScrollFrame(nsIFrame **aStyledFrame)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PRInt32
|
||||
nsGenericElement::GetScrollTop()
|
||||
{
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
|
||||
return sf ?
|
||||
nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollPosition().y) :
|
||||
0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetScrollTop(PRInt32* aScrollTop)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aScrollTop);
|
||||
*aScrollTop = 0;
|
||||
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
if (sf) {
|
||||
nscoord y = sf->GetScrollPosition().y;
|
||||
*aScrollTop = nsPresContext::AppUnitsToIntCSSPixels(y);
|
||||
}
|
||||
*aScrollTop = mContent->GetScrollTop();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNSElementTearoff::SetScrollTop(PRInt32 aScrollTop)
|
||||
void
|
||||
nsGenericElement::SetScrollTop(PRInt32 aScrollTop)
|
||||
{
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
if (sf) {
|
||||
@ -1532,27 +1573,36 @@ nsNSElementTearoff::SetScrollTop(PRInt32 aScrollTop)
|
||||
pt.y = nsPresContext::CSSPixelsToAppUnits(aScrollTop);
|
||||
sf->ScrollTo(pt, nsIScrollableFrame::INSTANT);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::SetScrollTop(PRInt32 aScrollTop)
|
||||
{
|
||||
mContent->SetScrollTop(aScrollTop);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PRInt32
|
||||
nsGenericElement::GetScrollLeft()
|
||||
{
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
|
||||
return sf ?
|
||||
nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollPosition().x) :
|
||||
0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetScrollLeft(PRInt32* aScrollLeft)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aScrollLeft);
|
||||
*aScrollLeft = 0;
|
||||
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
if (sf) {
|
||||
nscoord x = sf->GetScrollPosition().x;
|
||||
*aScrollLeft = nsPresContext::AppUnitsToIntCSSPixels(x);
|
||||
}
|
||||
*aScrollLeft = mContent->GetScrollLeft();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNSElementTearoff::SetScrollLeft(PRInt32 aScrollLeft)
|
||||
void
|
||||
nsGenericElement::SetScrollLeft(PRInt32 aScrollLeft)
|
||||
{
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
if (sf) {
|
||||
@ -1560,58 +1610,70 @@ nsNSElementTearoff::SetScrollLeft(PRInt32 aScrollLeft)
|
||||
pt.x = nsPresContext::CSSPixelsToAppUnits(aScrollLeft);
|
||||
sf->ScrollTo(pt, nsIScrollableFrame::INSTANT);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::SetScrollLeft(PRInt32 aScrollLeft)
|
||||
{
|
||||
mContent->SetScrollLeft(aScrollLeft);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNSElementTearoff::GetScrollHeight(PRInt32* aScrollHeight)
|
||||
PRInt32
|
||||
nsGenericElement::GetScrollHeight()
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aScrollHeight);
|
||||
*aScrollHeight = 0;
|
||||
|
||||
if (mContent->IsSVG())
|
||||
return NS_OK;
|
||||
if (IsSVG())
|
||||
return 0;
|
||||
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
if (!sf) {
|
||||
nsRect rcFrame;
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
(static_cast<nsGenericElement *>(mContent))->GetOffsetRect(rcFrame, getter_AddRefs(parent));
|
||||
*aScrollHeight = rcFrame.height;
|
||||
return NS_OK;
|
||||
GetOffsetRect(rcFrame, getter_AddRefs(parent));
|
||||
return rcFrame.height;
|
||||
}
|
||||
|
||||
nscoord height = sf->GetScrollRange().height + sf->GetScrollPortRect().height;
|
||||
*aScrollHeight = nsPresContext::AppUnitsToIntCSSPixels(height);
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(height);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetScrollHeight(PRInt32* aScrollHeight)
|
||||
{
|
||||
*aScrollHeight = mContent->GetScrollHeight();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNSElementTearoff::GetScrollWidth(PRInt32* aScrollWidth)
|
||||
PRInt32
|
||||
nsGenericElement::GetScrollWidth()
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aScrollWidth);
|
||||
*aScrollWidth = 0;
|
||||
|
||||
if (mContent->IsSVG())
|
||||
return NS_OK;
|
||||
if (IsSVG())
|
||||
return 0;
|
||||
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
if (!sf) {
|
||||
nsRect rcFrame;
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
(static_cast<nsGenericElement *>(mContent))->GetOffsetRect(rcFrame, getter_AddRefs(parent));
|
||||
*aScrollWidth = rcFrame.width;
|
||||
return NS_OK;
|
||||
GetOffsetRect(rcFrame, getter_AddRefs(parent));
|
||||
return rcFrame.width;
|
||||
}
|
||||
|
||||
nscoord width = sf->GetScrollRange().width + sf->GetScrollPortRect().width;
|
||||
*aScrollWidth = nsPresContext::AppUnitsToIntCSSPixels(width);
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(width);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetScrollWidth(PRInt32 *aScrollWidth)
|
||||
{
|
||||
*aScrollWidth = mContent->GetScrollWidth();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRect
|
||||
nsNSElementTearoff::GetClientAreaRect()
|
||||
nsGenericElement::GetClientAreaRect()
|
||||
{
|
||||
nsIFrame* styledFrame;
|
||||
nsIScrollableFrame* sf = GetScrollFrame(&styledFrame);
|
||||
@ -1632,40 +1694,36 @@ nsNSElementTearoff::GetClientAreaRect()
|
||||
return nsRect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNSElementTearoff::GetClientTop(PRInt32* aLength)
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetClientTop(PRInt32 *aClientTop)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLength);
|
||||
*aLength = nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().y);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNSElementTearoff::GetClientLeft(PRInt32* aLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLength);
|
||||
*aLength = nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().x);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNSElementTearoff::GetClientHeight(PRInt32* aLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLength);
|
||||
*aLength = nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().height);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNSElementTearoff::GetClientWidth(PRInt32* aLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLength);
|
||||
*aLength = nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().width);
|
||||
*aClientTop = mContent->GetClientTop();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetBoundingClientRect(nsIDOMClientRect** aResult)
|
||||
nsNSElementTearoff::GetClientLeft(PRInt32 *aClientLeft)
|
||||
{
|
||||
*aClientLeft = mContent->GetClientLeft();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetClientHeight(PRInt32 *aClientHeight)
|
||||
{
|
||||
*aClientHeight = mContent->GetClientHeight();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetClientWidth(PRInt32 *aClientWidth)
|
||||
{
|
||||
*aClientWidth = mContent->GetClientWidth();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::GetBoundingClientRect(nsIDOMClientRect** aResult)
|
||||
{
|
||||
// Weak ref, since we addref it below
|
||||
nsClientRect* rect = new nsClientRect();
|
||||
@ -1674,7 +1732,7 @@ nsNSElementTearoff::GetBoundingClientRect(nsIDOMClientRect** aResult)
|
||||
|
||||
NS_ADDREF(*aResult = rect);
|
||||
|
||||
nsIFrame* frame = mContent->GetPrimaryFrame(Flush_Layout);
|
||||
nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
|
||||
if (!frame) {
|
||||
// display:none, perhaps? Return the empty rect
|
||||
return NS_OK;
|
||||
@ -1687,7 +1745,13 @@ nsNSElementTearoff::GetBoundingClientRect(nsIDOMClientRect** aResult)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
nsNSElementTearoff::GetBoundingClientRect(nsIDOMClientRect** aResult)
|
||||
{
|
||||
return mContent->GetBoundingClientRect(aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
@ -1695,7 +1759,7 @@ nsNSElementTearoff::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
if (!rectList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsIFrame* frame = mContent->GetPrimaryFrame(Flush_Layout);
|
||||
nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
|
||||
if (!frame) {
|
||||
// display:none, perhaps? Return an empty list
|
||||
*aResult = rectList.forget().get();
|
||||
@ -1711,6 +1775,12 @@ nsNSElementTearoff::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
{
|
||||
return mContent->GetClientRects(aResult);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -5540,30 +5610,29 @@ nsGenericElement::doQuerySelectorAll(nsINode* aRoot,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::MozMatchesSelector(const nsAString& aSelector, PRBool* aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn, "Null out param?");
|
||||
*aReturn = nsGenericElement::doMatchesSelector(mContent, aSelector);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
PRBool
|
||||
nsGenericElement::doMatchesSelector(Element* aElement,
|
||||
const nsAString& aSelector)
|
||||
nsGenericElement::MozMatchesSelector(const nsAString& aSelector)
|
||||
{
|
||||
nsAutoPtr<nsCSSSelectorList> selectorList;
|
||||
nsPresContext* presContext;
|
||||
PRBool matches = PR_FALSE;
|
||||
|
||||
if (NS_SUCCEEDED(ParseSelectorList(aElement, aSelector,
|
||||
if (NS_SUCCEEDED(ParseSelectorList(this, aSelector,
|
||||
getter_Transfers(selectorList),
|
||||
&presContext)))
|
||||
{
|
||||
RuleProcessorData data(presContext, aElement, nsnull);
|
||||
RuleProcessorData data(presContext, this, nsnull);
|
||||
matches = nsCSSRuleProcessor::SelectorListMatches(data, selectorList);
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSElementTearoff::MozMatchesSelector(const nsAString& aSelector, PRBool* aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn, "Null out param?");
|
||||
*aReturn = mContent->MozMatchesSelector(aSelector);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMNodeSelector.h"
|
||||
#include "nsIDOMXPathNSResolver.h"
|
||||
#include "nsPresContext.h"
|
||||
|
||||
#ifdef MOZ_SMIL
|
||||
#include "nsISMILAttr.h"
|
||||
@ -644,8 +645,6 @@ public:
|
||||
static nsresult doQuerySelectorAll(nsINode* aRoot,
|
||||
const nsAString& aSelector,
|
||||
nsIDOMNodeList **aReturn);
|
||||
static PRBool doMatchesSelector(mozilla::dom::Element* aElement,
|
||||
const nsAString& aSelector);
|
||||
|
||||
/**
|
||||
* Default event prehandling for content objects. Handles event retargeting.
|
||||
@ -725,6 +724,69 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// nsIDOMNSElement methods
|
||||
nsresult GetElementsByClassName(const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn)
|
||||
{
|
||||
return nsContentUtils::GetElementsByClassName(this, aClasses, aReturn);
|
||||
}
|
||||
nsresult GetClientRects(nsIDOMClientRectList** aResult);
|
||||
nsresult GetBoundingClientRect(nsIDOMClientRect** aResult);
|
||||
PRInt32 GetScrollTop();
|
||||
void SetScrollTop(PRInt32 aScrollTop);
|
||||
PRInt32 GetScrollLeft();
|
||||
void SetScrollLeft(PRInt32 aScrollLeft);
|
||||
PRInt32 GetScrollHeight();
|
||||
PRInt32 GetScrollWidth();
|
||||
PRInt32 GetClientTop()
|
||||
{
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().y);
|
||||
}
|
||||
PRInt32 GetClientLeft()
|
||||
{
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().x);
|
||||
}
|
||||
PRInt32 GetClientHeight()
|
||||
{
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().height);
|
||||
}
|
||||
PRInt32 GetClientWidth()
|
||||
{
|
||||
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().width);
|
||||
}
|
||||
nsIContent* GetFirstElementChild();
|
||||
nsIContent* GetLastElementChild();
|
||||
nsIContent* GetPreviousElementSibling();
|
||||
nsIContent* GetNextElementSibling();
|
||||
nsresult GetChildElementCount(PRUint32* aResult)
|
||||
{
|
||||
nsContentList* list = GetChildrenList();
|
||||
if (!list) {
|
||||
*aResult = 0;
|
||||
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*aResult = list->Length(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetChildren(nsIDOMNodeList** aResult)
|
||||
{
|
||||
nsContentList* list = GetChildrenList();
|
||||
if (!list) {
|
||||
*aResult = nsnull;
|
||||
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aResult = list);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
nsIDOMDOMTokenList* GetClassList(nsresult *aResult);
|
||||
PRBool MozMatchesSelector(const nsAString& aSelector);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsGenericElement)
|
||||
|
||||
protected:
|
||||
@ -1023,6 +1085,17 @@ protected:
|
||||
* Array containing all attributes and children for this element
|
||||
*/
|
||||
nsAttrAndChildArray mAttrsAndChildren;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Get this element's client area rect in app units.
|
||||
* @return the frame's client area
|
||||
*/
|
||||
nsRect GetClientAreaRect();
|
||||
|
||||
nsIScrollableFrame* GetScrollFrame(nsIFrame **aStyledFrame = nsnull);
|
||||
|
||||
nsContentList* GetChildrenList();
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1088,24 +1161,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
nsContentList* GetChildrenList();
|
||||
|
||||
nsRefPtr<nsGenericElement> mContent;
|
||||
|
||||
/**
|
||||
* Get this element's client area rect in app units.
|
||||
* @return the frame's client area
|
||||
*/
|
||||
nsRect GetClientAreaRect();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Get the element's styled frame (the primary frame or, for tables, the inner
|
||||
* table frame) and associated scrollable frame (if any).
|
||||
* @note This method flushes pending notifications (Flush_Layout).
|
||||
* @param aFrame (optional) the styled frame [OUT]
|
||||
*/
|
||||
nsIScrollableFrame* GetScrollFrame(nsIFrame** aStyledFrame = nsnull);
|
||||
};
|
||||
|
||||
#define NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE \
|
||||
|
Loading…
Reference in New Issue
Block a user