Added GetPrimaryFrame utility method.

This commit is contained in:
kmcclusk%netscape.com 1999-01-26 23:43:52 +00:00
Родитель 3e75b8c0d2
Коммит e342fc0ca1
2 изменённых файлов: 70 добавлений и 0 удалений

Просмотреть файл

@ -32,8 +32,15 @@
#include "nsIForm.h"
#include "nsIWidget.h"
#include "nsITextWidget.h"
// XXX: All of the header files related to accessing widgets directly
// should be removed when all widget references are replaced with
// frame references.
#include "nsICheckButton.h"
#include "nsIRadioButton.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIFormControlFrame.h"
#include "nsIFrame.h"
// XXX align=left, hspace, vspace, border? other nav4 attrs
@ -44,6 +51,7 @@ static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID);
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
class nsHTMLInputElement : public nsIDOMHTMLInputElement,
public nsIScriptObjectOwner,
@ -131,6 +139,9 @@ protected:
nsIForm* mForm;
PRInt32 mType;
// Return the primary frame associated with this content
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame);
PRBool IsImage() const {
nsAutoString tmp;
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
@ -661,3 +672,27 @@ nsHTMLInputElement::GetStyleHintForAttributeChange(
return NS_OK;
}
nsresult nsHTMLInputElement::GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame)
{
nsIDocument* doc = nsnull;
nsresult res;
// Get the document
if (NS_OK == GetDocument(doc)) {
// Get presentation shell 0
nsIPresShell* presShell = doc->GetShellAt(0);
if (nsnull != presShell) {
nsIFrame *frame = nsnull;
presShell->GetPrimaryFrameFor(this, frame);
if (nsnull != frame) {
res = frame->QueryInterface(kIFormControlFrameIID, (void**)&aFormControlFrame);
}
NS_RELEASE(presShell);
}
NS_RELEASE(doc);
}
return res;
}

Просмотреть файл

@ -32,8 +32,15 @@
#include "nsIForm.h"
#include "nsIWidget.h"
#include "nsITextWidget.h"
// XXX: All of the header files related to accessing widgets directly
// should be removed when all widget references are replaced with
// frame references.
#include "nsICheckButton.h"
#include "nsIRadioButton.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIFormControlFrame.h"
#include "nsIFrame.h"
// XXX align=left, hspace, vspace, border? other nav4 attrs
@ -44,6 +51,7 @@ static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID);
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
class nsHTMLInputElement : public nsIDOMHTMLInputElement,
public nsIScriptObjectOwner,
@ -131,6 +139,9 @@ protected:
nsIForm* mForm;
PRInt32 mType;
// Return the primary frame associated with this content
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame);
PRBool IsImage() const {
nsAutoString tmp;
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
@ -661,3 +672,27 @@ nsHTMLInputElement::GetStyleHintForAttributeChange(
return NS_OK;
}
nsresult nsHTMLInputElement::GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame)
{
nsIDocument* doc = nsnull;
nsresult res;
// Get the document
if (NS_OK == GetDocument(doc)) {
// Get presentation shell 0
nsIPresShell* presShell = doc->GetShellAt(0);
if (nsnull != presShell) {
nsIFrame *frame = nsnull;
presShell->GetPrimaryFrameFor(this, frame);
if (nsnull != frame) {
res = frame->QueryInterface(kIFormControlFrameIID, (void**)&aFormControlFrame);
}
NS_RELEASE(presShell);
}
NS_RELEASE(doc);
}
return res;
}