mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Added GetPrimaryFrame utility method.
This commit is contained in:
parent
3e75b8c0d2
commit
e342fc0ca1
@ -32,8 +32,15 @@
|
|||||||
#include "nsIForm.h"
|
#include "nsIForm.h"
|
||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
#include "nsITextWidget.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 "nsICheckButton.h"
|
||||||
#include "nsIRadioButton.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
|
// 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(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||||
static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID);
|
static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID);
|
||||||
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||||
|
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||||
|
|
||||||
class nsHTMLInputElement : public nsIDOMHTMLInputElement,
|
class nsHTMLInputElement : public nsIDOMHTMLInputElement,
|
||||||
public nsIScriptObjectOwner,
|
public nsIScriptObjectOwner,
|
||||||
@ -131,6 +139,9 @@ protected:
|
|||||||
nsIForm* mForm;
|
nsIForm* mForm;
|
||||||
PRInt32 mType;
|
PRInt32 mType;
|
||||||
|
|
||||||
|
// Return the primary frame associated with this content
|
||||||
|
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame);
|
||||||
|
|
||||||
PRBool IsImage() const {
|
PRBool IsImage() const {
|
||||||
nsAutoString tmp;
|
nsAutoString tmp;
|
||||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
|
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
|
||||||
@ -661,3 +672,27 @@ nsHTMLInputElement::GetStyleHintForAttributeChange(
|
|||||||
|
|
||||||
return NS_OK;
|
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 "nsIForm.h"
|
||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
#include "nsITextWidget.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 "nsICheckButton.h"
|
||||||
#include "nsIRadioButton.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
|
// 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(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||||
static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID);
|
static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID);
|
||||||
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||||
|
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||||
|
|
||||||
class nsHTMLInputElement : public nsIDOMHTMLInputElement,
|
class nsHTMLInputElement : public nsIDOMHTMLInputElement,
|
||||||
public nsIScriptObjectOwner,
|
public nsIScriptObjectOwner,
|
||||||
@ -131,6 +139,9 @@ protected:
|
|||||||
nsIForm* mForm;
|
nsIForm* mForm;
|
||||||
PRInt32 mType;
|
PRInt32 mType;
|
||||||
|
|
||||||
|
// Return the primary frame associated with this content
|
||||||
|
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame);
|
||||||
|
|
||||||
PRBool IsImage() const {
|
PRBool IsImage() const {
|
||||||
nsAutoString tmp;
|
nsAutoString tmp;
|
||||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
|
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
|
||||||
@ -661,3 +672,27 @@ nsHTMLInputElement::GetStyleHintForAttributeChange(
|
|||||||
|
|
||||||
return NS_OK;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user