This commit is contained in:
jkeiser%netscape.com 2002-03-29 05:35:47 +00:00
Родитель 6ae20dcee7
Коммит 39fe8af27c
55 изменённых файлов: 528 добавлений и 753 удалений

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

@ -309,6 +309,34 @@ public:
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) = 0;
/**
* This method is called when the parser finishes creating the element. This
* particularly means that it has done everything you would expect it to have
* done after it encounters the > at the end of the tag (for HTML or XML).
* This includes setting the attributes, setting the document / form, and
* placing the element into the tree at its proper place.
*
* For container elements, this is called *before* any of the children are
* created or added into the tree.
*
* NOTE: this is currently only called for input and button, in the HTML
* content sink. If you want to call it on your element, modify the content
* sink of your choice to do so. This is an efficiency measure.
*
* If you also need to determine whether the parser is the one creating your
* element (through createElement() or cloneNode() generally) * aFromParser to the NS_NewXXX() constructor for your element and have the
* parser pass true. See nsHTMLInputElement.cpp and
* nsHTMLContentSink::MakeContentObject().
*
* DO NOT USE THIS METHOD to get around the fact that it's hard to deal with
* attributes dynamically. If you make attributes affect your element from
* this method, it will only happen on initialization and JavaScript will not
* be able to create elements (which requires them to first create the
* element and then call setAttribute() directly, at which point
* DoneCreatingElement() has already been called and is out of the picture).
*/
NS_IMETHOD DoneCreatingElement() = 0;
#ifdef DEBUG
/**
* Get the size of the content object. The size value should include

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

@ -641,6 +641,11 @@ nsGenericDOMDataNode::GetListenerManager(nsIEventListenerManager** aResult)
return NS_OK;
}
NS_IMETHODIMP
nsGenericDOMDataNode::DoneCreatingElement()
{
return NS_OK;
}
//----------------------------------------------------------------------
// Implementation of nsIContent

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

@ -210,6 +210,7 @@ public:
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags);
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
NS_IMETHOD DoneCreatingElement();
#ifdef DEBUG
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;

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

@ -2040,6 +2040,12 @@ nsGenericElement::GetListenerManager(nsIEventListenerManager** aResult)
return rv;
}
NS_IMETHODIMP
nsGenericElement::DoneCreatingElement()
{
return NS_OK;
}
//----------------------------------------------------------------------
// Generic DOMNode implementations

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

@ -251,6 +251,7 @@ public:
NS_IMETHOD SetBindingParent(nsIContent* aParent);
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags);
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
NS_IMETHOD DoneCreatingElement();
// nsIStyledContent interface methods

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

@ -3,3 +3,4 @@
#
nsISelectElement.idl
nsITextAreaElement.idl

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

@ -31,6 +31,7 @@ XPIDL_MODULE = content_html
XPIDLSRCS = \
nsISelectElement.idl \
nsITextAreaElement.idl \
$(NULL)
EXPORTS = \

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

@ -23,6 +23,7 @@ DEPTH=..\..\..\..
XPIDLSRCS = \
.\nsISelectElement.idl \
.\nsITextAreaElement.idl \
$(NULL)
EXPORTS= \

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

@ -131,14 +131,13 @@ public:
/**
* Save to presentation state
*/
NS_IMETHOD SaveState(nsIPresContext* aPresContext,
nsIPresState** aState) = 0;
NS_IMETHOD SaveState() = 0;
/**
* Restore from presentation state
* @param aState the pres state to use to restore the control
*/
NS_IMETHOD RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState) = 0;
NS_IMETHOD RestoreState(nsIPresState* aState) = 0;
};
#endif /* nsIFormControl_h___ */

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

@ -83,16 +83,18 @@ interface nsISelectElement : nsISupports
[noscript] void removeOption(in nsIContent aContent);
/**
* Indicates that we're done adding child content
* Called when the parser is done adding child content
* to the select during document loading.
*/
void doneAddingContent(in boolean aIsDone);
void doneAddingChildren();
/**
* Returns whether we're done adding child content
* Returns whether the parser is done adding child content
* to the select during document loading.
*
* @return whether the parser is done adding children
*/
boolean isDoneAddingContent();
boolean isDoneAddingChildren();
/**
* Returns whether we're the option is selected
@ -128,8 +130,6 @@ interface nsISelectElement : nsISupports
/**
* Called to save/restore to/from pres. state
*/
[noscript] void saveState(in nsIPresContext aPresContext,
out nsIPresState aState);
[noscript] void restoreState(in nsIPresContext aPresContext,
in nsIPresState aState);
[noscript] void saveState();
[noscript] void restoreState(in nsIPresState aState);
};

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

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
/**
* This interface is used so that the parser can notify the textarea when
* it has finished loading content.
*/
[scriptable, uuid(36878df2-1dd2-11b2-99a0-ea9fab347485)]
interface nsITextAreaElement : nsISupports
{
/**
* Called when the parser is done adding child content
* to the select during document loading.
*/
void doneAddingChildren();
};

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

@ -139,6 +139,10 @@ public:
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHOD DoneCreatingElement() {
return NS_OK;
}
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, const nsAString& aValue,
PRBool aNotify) { return NS_OK; }
NS_IMETHOD SetAttr(nsINodeInfo *aNodeInfo, const nsAString& aValue,

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

@ -2951,44 +2951,98 @@ nsGenericHTMLElement::GetPrimaryPresState(nsIHTMLContent* aContent,
nsresult result = NS_OK;
// Generate the state key
nsCOMPtr<nsILayoutHistoryState> history;
nsCAutoString key;
GetLayoutHistoryAndKey(aContent, getter_AddRefs(history), key);
if (history) {
// Get the pres state for this key, if it doesn't exist, create one
result = history->GetState(key, aPresState);
if (!*aPresState) {
result = nsComponentManager::CreateInstance(kPresStateCID, nsnull,
NS_GET_IID(nsIPresState),
(void**)aPresState);
if (NS_SUCCEEDED(result)) {
result = history->AddState(key, *aPresState);
}
}
}
return result;
}
nsresult
nsGenericHTMLElement::GetLayoutHistoryAndKey(nsIHTMLContent* aContent,
nsILayoutHistoryState** aHistory,
nsACString& aKey)
{
//
// Get the pres shell
//
nsCOMPtr<nsIDocument> doc;
result = aContent->GetDocument(*getter_AddRefs(doc));
nsresult rv = aContent->GetDocument(*getter_AddRefs(doc));
if (!doc) {
return result;
return rv;
}
nsCOMPtr<nsIPresShell> presShell;
doc->GetShellAt(0, getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
//
// Get the history (don't bother with the key if the history is not there)
//
rv = presShell->GetHistoryState(aHistory);
NS_ENSURE_SUCCESS(rv, rv);
if (!*aHistory) {
return NS_OK;
}
//
// Get the state key
//
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
NS_ENSURE_TRUE(frameManager, NS_ERROR_FAILURE);
nsCAutoString stateKey;
result = frameManager->GenerateStateKey(aContent, nsIStatefulFrame::eNoID, stateKey);
NS_ENSURE_TRUE((NS_SUCCEEDED(result) && !stateKey.IsEmpty()), result);
rv = frameManager->GenerateStateKey(aContent, nsIStatefulFrame::eNoID, aKey);
NS_ENSURE_SUCCESS(rv, rv);
// Get the pres state for this key, if it doesn't exist, create one
//
// Return early if we can't get history - we don't want to create a
// new history state that is free-floating, not in history.
nsCOMPtr<nsILayoutHistoryState> history;
result = presShell->GetHistoryState(getter_AddRefs(history));
NS_ENSURE_TRUE(NS_SUCCEEDED(result) && history, result);
history->GetState(stateKey, aPresState);
if (!*aPresState) {
result = nsComponentManager::CreateInstance(kPresStateCID, nsnull,
NS_GET_IID(nsIPresState),
(void**)aPresState);
if (NS_SUCCEEDED(result)) {
result = history->AddState(stateKey, *aPresState);
}
// If the state key is blank, this is anonymous content or for
// whatever reason we are not supposed to save/restore state.
if (aKey.IsEmpty()) {
NS_RELEASE(*aHistory);
return NS_OK;
}
return result;
// Add something unique to content so layout doesn't muck us up
aKey += "-C";
return rv;
}
PRBool
nsGenericHTMLElement::RestoreFormControlState(nsIHTMLContent* aContent,
nsIFormControl* aControl)
{
nsCOMPtr<nsILayoutHistoryState> history;
nsCAutoString key;
nsresult rv = GetLayoutHistoryAndKey(aContent, getter_AddRefs(history), key);
if (!history) {
return PR_FALSE;
}
nsCOMPtr<nsIPresState> state;
// Get the pres state for this key
rv = history->GetState(key, getter_AddRefs(state));
if (state) {
rv = aControl->RestoreState(state);
history->RemoveState(key);
return NS_SUCCEEDED(rv);
}
return PR_FALSE;
}
// XXX This creates a dependency between content and frames
@ -4200,6 +4254,11 @@ nsGenericHTMLContainerFormElement::SetDocument(nsIDocument* aDocument,
{
nsresult rv = NS_OK;
// Save state before doing anything if the document is being removed
if (!aDocument) {
SaveState();
}
if (aDocument && mParent && !mForm) {
rv = FindAndSetForm(this);
} else if (!aDocument && mForm) {
@ -4226,6 +4285,7 @@ nsGenericHTMLContainerFormElement::SetDocument(nsIDocument* aDocument,
return rv;
}
nsresult
nsGenericHTMLElement::SetFormControlAttribute(nsIForm* aForm,
PRInt32 aNameSpaceID,
@ -4444,6 +4504,11 @@ nsGenericHTMLLeafFormElement::SetDocument(nsIDocument* aDocument,
{
nsresult rv = NS_OK;
// Save state before doing anything if the document is being removed
if (!aDocument) {
SaveState();
}
if (aDocument && mParent && !mForm) {
rv = FindAndSetForm(this);
} else if (!aDocument && mForm) {
@ -4470,6 +4535,13 @@ nsGenericHTMLLeafFormElement::SetDocument(nsIDocument* aDocument,
return rv;
}
NS_IMETHODIMP
nsGenericHTMLLeafFormElement::DoneCreatingElement()
{
RestoreFormControlState(this, this);
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLLeafFormElement::SetAttr(PRInt32 aNameSpaceID,
nsIAtom* aName,

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

@ -53,7 +53,6 @@
class nsIDOMAttr;
class nsIDOMEventListener;
class nsIDOMNodeList;
class nsIEventListenerManager;
class nsIFrame;
class nsHTMLAttributes;
class nsIHTMLMappedAttributes;
@ -68,6 +67,7 @@ class nsIFormControlFrame;
class nsIForm;
class nsIPresState;
class nsIScrollableView;
class nsILayoutHistoryState;
struct nsRect;
@ -357,8 +357,38 @@ public:
static nsIFormControlFrame* GetFormControlFrameFor(nsIContent* aContent,
nsIDocument* aDocument,
PRBool aFlushContent);
/**
* Get the presentation state for a piece of content, or create it if it does
* not exist. Generally used by SaveState().
*
* @param aContent the content to get presentation state for.
* @param aPresState the presentation state (out param)
*/
static nsresult GetPrimaryPresState(nsIHTMLContent* aContent,
nsIPresState** aPresState);
/**
* Get the layout history object *and* generate the key for a particular
* piece of content.
*
* @param aContent the content to generate the key for
* @param aState the history state object (out param)
* @param aKey the key (out param)
*/
static nsresult GetLayoutHistoryAndKey(nsIHTMLContent* aContent,
nsILayoutHistoryState** aState,
nsACString& aKey);
/**
* Restore the state for a form control. Ends up calling
* nsIFormControl::RestoreState().
*
* @param aContent an nsIHTMLContent* pointing to the form control
* @param aControl an nsIFormControl* pointing to the form control
* @return whether or not the RestoreState() was called and exited
* successfully.
*/
static PRBool RestoreFormControlState(nsIHTMLContent* aContent,
nsIFormControl* aControl);
static nsresult GetPresContext(nsIHTMLContent* aContent,
nsIPresContext** aPresContext);
@ -589,14 +619,8 @@ public:
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm,
PRBool aRemoveFromForm = PR_TRUE);
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
return NS_OK;
}
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
return NS_OK;
}
NS_IMETHOD SaveState() { return NS_OK; }
NS_IMETHOD RestoreState(nsIPresState* aState) { return NS_OK; }
// nsIContent
NS_IMETHOD SetParent(nsIContent *aParent);
@ -638,14 +662,8 @@ public:
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm,
PRBool aRemoveFromForm = PR_TRUE);
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
return NS_OK;
}
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
return NS_OK;
}
NS_IMETHOD SaveState() { return NS_OK; }
NS_IMETHOD RestoreState(nsIPresState* aState) { return NS_OK; }
// nsIContent
NS_IMETHOD SetParent(nsIContent *aParent);
@ -658,7 +676,7 @@ public:
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
const nsAString& aValue,
PRBool aNotify);
NS_IMETHOD DoneCreatingElement();
NS_METHOD SetAttribute(const nsAString& aName,
const nsAString& aValue)
@ -949,7 +967,8 @@ nsresult
NS_NewHTMLImageElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
nsresult
NS_NewHTMLInputElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
NS_NewHTMLInputElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
PRBool aFromParser);
nsresult
NS_NewHTMLInsElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
@ -1015,7 +1034,8 @@ nsresult
NS_NewHTMLScriptElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
nsresult
NS_NewHTMLSelectElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
NS_NewHTMLSelectElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
PRBool aFromParser);
inline nsresult
NS_NewHTMLSpacerElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo)

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

@ -1,4 +1,3 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
@ -119,6 +118,8 @@ typedef nsIGfxTextControlFrame2 textControlPlace;
#define BF_CHECKED_CHANGED 3
#define BF_CHECKED 4
#define BF_HANDLING_SELECT_EVENT 5
#define BF_SHOULD_INIT_CHECKED 6
#define BF_PARSER_CREATING 7
#define GET_BOOLBIT(bitfield, field) (((bitfield) & (0x01 << (field))) \
? PR_TRUE : PR_FALSE)
@ -133,7 +134,7 @@ class nsHTMLInputElement : public nsGenericHTMLLeafFormElement,
public nsIRadioControlElement
{
public:
nsHTMLInputElement();
nsHTMLInputElement(PRBool aFromParser);
virtual ~nsHTMLInputElement();
// nsISupports
@ -161,8 +162,8 @@ public:
NS_IMETHOD Reset();
NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,
nsIContent* aSubmitElement);
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
NS_IMETHOD SaveState();
NS_IMETHOD RestoreState(nsIPresState* aState);
// nsIContent
NS_IMETHOD SetFocus(nsIPresContext* aPresContext);
@ -212,6 +213,8 @@ public:
return rv;
}
NS_IMETHOD DoneCreatingElement();
// nsITextControlElement
NS_IMETHOD SetValueGuaranteed(const nsAString& aValue, nsIGfxTextControlFrame2* aFrame);
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
@ -226,7 +229,6 @@ public:
protected:
// Helper method
void SetPresStateChecked(nsIHTMLContent * aHTMLContent, PRBool aValue);
NS_IMETHOD SetValueSecure(const nsAString& aValue,
nsIGfxTextControlFrame2* aFrame,
PRBool aCheckSecurity);
@ -310,11 +312,12 @@ NS_METHOD NS_GetRadioGetCheckedChangedVisitor(PRBool* aCheckedChanged,
nsresult
NS_NewHTMLInputElement(nsIHTMLContent** aInstancePtrResult,
nsINodeInfo *aNodeInfo)
nsINodeInfo *aNodeInfo,
PRBool aFromParser)
{
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
nsHTMLInputElement* it = new nsHTMLInputElement();
nsHTMLInputElement* it = new nsHTMLInputElement(aFromParser);
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
@ -335,10 +338,11 @@ NS_NewHTMLInputElement(nsIHTMLContent** aInstancePtrResult,
}
nsHTMLInputElement::nsHTMLInputElement()
nsHTMLInputElement::nsHTMLInputElement(PRBool aFromParser)
{
mType = NS_FORM_INPUT_TEXT; // default value
mBitField = 0;
SET_BOOLBIT(mBitField, BF_PARSER_CREATING, aFromParser);
mValue = nsnull;
}
@ -378,7 +382,7 @@ nsHTMLInputElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
nsHTMLInputElement* it = new nsHTMLInputElement();
nsHTMLInputElement* it = new nsHTMLInputElement(PR_FALSE);
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
@ -452,10 +456,16 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
//
if (aName == nsHTMLAtoms::checked &&
!GET_BOOLBIT(mBitField, BF_CHECKED_CHANGED)) {
PRBool resetVal;
GetDefaultChecked(&resetVal);
SetChecked(resetVal);
SetCheckedChanged(PR_FALSE);
// Delay setting checked if the parser is creating this element (wait until
// everything is set)
if (GET_BOOLBIT(mBitField, BF_PARSER_CREATING)) {
SET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED, PR_TRUE);
} else {
PRBool defaultChecked;
GetDefaultChecked(&defaultChecked);
SetChecked(defaultChecked);
SetCheckedChanged(PR_FALSE);
}
}
}
@ -616,6 +626,7 @@ nsHTMLInputElement::SetValueSecure(const nsAString& aValue,
GetType(&type);
if (NS_FORM_INPUT_TEXT == type || NS_FORM_INPUT_PASSWORD == type ||
NS_FORM_INPUT_FILE == type) {
if (aCheckSecurity && NS_FORM_INPUT_FILE == type) {
nsresult rv;
nsCOMPtr<nsIScriptSecurityManager> securityManager =
@ -637,7 +648,6 @@ nsHTMLInputElement::SetValueSecure(const nsAString& aValue,
}
}
nsIGfxTextControlFrame2* textControlFrame = aFrame;
nsIFormControlFrame* formControlFrame = textControlFrame;
if (!textControlFrame) {
@ -651,7 +661,12 @@ nsHTMLInputElement::SetValueSecure(const nsAString& aValue,
}
}
// File frames always own the value (if the frame is there).
// Text frames have a bit that says whether they own the value.
PRBool frameOwnsValue = PR_FALSE;
if (type == NS_FORM_INPUT_FILE && formControlFrame) {
frameOwnsValue = PR_TRUE;
}
if (textControlFrame) {
textControlFrame->OwnsValue(&frameOwnsValue);
}
@ -699,20 +714,6 @@ nsHTMLInputElement::GetChecked(PRBool* aChecked)
return NS_OK;
}
void
nsHTMLInputElement::SetPresStateChecked(nsIHTMLContent * aHTMLContent,
PRBool aValue)
{
nsCOMPtr<nsIPresState> presState;
GetPrimaryPresState(aHTMLContent, getter_AddRefs(presState));
// Obtain the value property from the presentation state.
if (presState) {
nsAutoString value; value.AssignWithConversion( aValue ? "1" : "0" );
presState->SetStateProperty(NS_LITERAL_STRING("checked"), value);
}
}
NS_IMETHODIMP
nsHTMLInputElement::SetCheckedChanged(PRBool aCheckedChanged)
{
@ -1597,8 +1598,9 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
if (valueStr.EqualsIgnoreCase(table->tag)) {
// If the type is being changed to file, set the element value
// to the empty string. This is for security.
if (table->value == NS_FORM_INPUT_FILE)
if (table->value == NS_FORM_INPUT_FILE) {
SetValue(NS_LITERAL_STRING(""));
}
aResult.SetIntValue(table->value, eHTMLUnit_Enumerated);
mType = table->value; // set the type of this input
return NS_CONTENT_ATTR_HAS_VALUE;
@ -2009,7 +2011,7 @@ nsHTMLInputElement::Reset()
case NS_FORM_INPUT_FILE:
{
// Resetting it to blank should not perform security check
rv = SetValueSecure(NS_LITERAL_STRING(""), nsnull, PR_FALSE);
rv = SetValueGuaranteed(NS_LITERAL_STRING(""), nsnull);
break;
}
default:
@ -2234,30 +2236,37 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
NS_IMETHODIMP
nsHTMLInputElement::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
nsHTMLInputElement::SaveState()
{
nsresult rv = NS_OK;
PRInt32 type;
GetType(&type);
nsCOMPtr<nsIPresState> state;
switch (type) {
case NS_FORM_INPUT_CHECKBOX:
case NS_FORM_INPUT_RADIO:
{
PRBool checked = PR_FALSE;
GetChecked(&checked);
rv = GetPrimaryPresState(this, aState);
if (*aState) {
if (checked) {
rv = (*aState)->SetStateProperty(NS_LITERAL_STRING("checked"),
NS_LITERAL_STRING("t"));
} else {
rv = (*aState)->SetStateProperty(NS_LITERAL_STRING("checked"),
NS_LITERAL_STRING("f"));
PRBool defaultChecked = PR_FALSE;
GetDefaultChecked(&defaultChecked);
// Only save if checked != defaultChecked (bug 62713)
// (always save if it's a radio button so that the checked
// state of all radio buttons is restored)
if (type == NS_FORM_INPUT_RADIO || checked != defaultChecked) {
rv = GetPrimaryPresState(this, getter_AddRefs(state));
if (state) {
if (checked) {
rv = state->SetStateProperty(NS_LITERAL_STRING("checked"),
NS_LITERAL_STRING("t"));
} else {
rv = state->SetStateProperty(NS_LITERAL_STRING("checked"),
NS_LITERAL_STRING("f"));
}
NS_ASSERTION(NS_SUCCEEDED(rv), "checked save failed!");
}
NS_ASSERTION(NS_SUCCEEDED(rv), "checked save failed!");
}
break;
}
@ -2268,19 +2277,19 @@ nsHTMLInputElement::SaveState(nsIPresContext* aPresContext,
case NS_FORM_INPUT_TEXT:
case NS_FORM_INPUT_FILE:
{
nsresult rv = GetPrimaryPresState(this, aState);
if (*aState) {
nsString value;
GetValue(value);
// XXX Should use nsAutoString above but ConvertStringLineBreaks
// requires mOwnsBuffer!
rv = nsLinebreakConverter::ConvertStringLineBreaks(
value,
nsLinebreakConverter::eLinebreakPlatform,
nsLinebreakConverter::eLinebreakContent);
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
rv = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), value);
NS_ASSERTION(NS_SUCCEEDED(rv), "value save failed!");
if (GET_BOOLBIT(mBitField, BF_VALUE_CHANGED)) {
rv = GetPrimaryPresState(this, getter_AddRefs(state));
if (state) {
nsAutoString value;
GetValue(value);
rv = nsLinebreakConverter::ConvertStringLineBreaks(
value,
nsLinebreakConverter::eLinebreakPlatform,
nsLinebreakConverter::eLinebreakContent);
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
rv = state->SetStateProperty(NS_LITERAL_STRING("v"), value);
NS_ASSERTION(NS_SUCCEEDED(rv), "value save failed!");
}
}
break;
}
@ -2290,8 +2299,41 @@ nsHTMLInputElement::SaveState(nsIPresContext* aPresContext,
}
NS_IMETHODIMP
nsHTMLInputElement::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
nsHTMLInputElement::DoneCreatingElement()
{
SET_BOOLBIT(mBitField, BF_PARSER_CREATING, PR_FALSE);
//
// Restore state for checkbox, radio, text and file
//
PRBool restored = PR_FALSE;
switch (mType) {
case NS_FORM_INPUT_CHECKBOX:
case NS_FORM_INPUT_RADIO:
case NS_FORM_INPUT_TEXT:
case NS_FORM_INPUT_FILE:
restored = RestoreFormControlState(this, this);
break;
}
//
// If restore does not occur, we initialize .checked using the CHECKED
// property.
//
if (!restored && GET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED)) {
PRBool resetVal;
GetDefaultChecked(&resetVal);
SetChecked(resetVal);
SetCheckedChanged(PR_FALSE);
}
SET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED, PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLInputElement::RestoreState(nsIPresState* aState)
{
nsresult rv = NS_OK;
@ -2306,25 +2348,18 @@ nsHTMLInputElement::RestoreState(nsIPresContext* aPresContext,
rv = aState->GetStateProperty(NS_LITERAL_STRING("checked"), checked);
// We assume that we are the only ones who saved the state. Thus we
// know the exact value that would have been saved.
if (checked.Equals(NS_LITERAL_STRING("t"))) {
SetChecked(PR_TRUE);
} else {
SetChecked(PR_FALSE);
}
SetChecked(checked.Equals(NS_LITERAL_STRING("t")));
break;
}
// Never save passwords in session history
case NS_FORM_INPUT_PASSWORD:
break;
case NS_FORM_INPUT_TEXT:
case NS_FORM_INPUT_FILE:
{
nsAutoString value;
rv = aState->GetStateProperty(NS_LITERAL_STRING("value"), value);
rv = aState->GetStateProperty(NS_LITERAL_STRING("v"), value);
NS_ASSERTION(NS_SUCCEEDED(rv), "value restore failed!");
SetValue(value);
SetValueGuaranteed(value, nsnull);
break;
}
}

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

@ -128,7 +128,7 @@ class nsHTMLSelectElement : public nsGenericHTMLContainerFormElement,
public nsISelectElement
{
public:
nsHTMLSelectElement();
nsHTMLSelectElement(PRBool aFromParser);
virtual ~nsHTMLSelectElement();
// nsISupports
@ -238,7 +238,7 @@ protected:
nsISelectControlFrame *GetSelectFrame();
nsHTMLOptionCollection* mOptions;
PRBool mIsDoneAddingContent;
PRBool mIsDoneAddingChildren;
PRUint32 mArtifactsAtTopLevel;
PRInt32 mSelectedIndex;
nsString* mRestoreState;
@ -254,11 +254,12 @@ protected:
nsresult
NS_NewHTMLSelectElement(nsIHTMLContent** aInstancePtrResult,
nsINodeInfo *aNodeInfo)
nsINodeInfo *aNodeInfo,
PRBool aFromParser)
{
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
nsHTMLSelectElement* it = new nsHTMLSelectElement();
nsHTMLSelectElement* it = new nsHTMLSelectElement(aFromParser);
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
@ -279,9 +280,11 @@ NS_NewHTMLSelectElement(nsIHTMLContent** aInstancePtrResult,
}
nsHTMLSelectElement::nsHTMLSelectElement()
nsHTMLSelectElement::nsHTMLSelectElement(PRBool aFromParser)
{
mIsDoneAddingContent = PR_TRUE;
// DoneAddingChildren() will be called later if it's from the parser,
// otherwise it is
mIsDoneAddingChildren = !aFromParser;
mArtifactsAtTopLevel = 0;
mOptions = new nsHTMLOptionCollection(this);
@ -330,7 +333,7 @@ nsHTMLSelectElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
nsHTMLSelectElement* it = new nsHTMLSelectElement();
nsHTMLSelectElement* it = new nsHTMLSelectElement(PR_FALSE);
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
@ -1581,7 +1584,7 @@ nsHTMLSelectElement::NamedItem(const nsAString& aName,
nsresult
nsHTMLSelectElement::CheckSelectSomething()
{
if (mIsDoneAddingContent) {
if (mIsDoneAddingChildren) {
PRInt32 size = 1;
GetSize(&size);
PRBool isMultiple;
@ -1598,7 +1601,7 @@ nsresult
nsHTMLSelectElement::SelectSomething()
{
// If we're not done building the select, don't play with this yet.
if (!mIsDoneAddingContent) {
if (!mIsDoneAddingChildren) {
return NS_OK;
}
@ -1642,33 +1645,38 @@ nsHTMLSelectElement::RemoveOption(nsIContent* aContent)
}
NS_IMETHODIMP
nsHTMLSelectElement::IsDoneAddingContent(PRBool * aIsDone)
nsHTMLSelectElement::IsDoneAddingChildren(PRBool * aIsDone)
{
*aIsDone = mIsDoneAddingContent;
*aIsDone = mIsDoneAddingChildren;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLSelectElement::DoneAddingContent(PRBool aIsDone)
nsHTMLSelectElement::DoneAddingChildren()
{
mIsDoneAddingContent = aIsDone;
mIsDoneAddingChildren = PR_TRUE;
nsISelectControlFrame* sFrame = GetSelectFrame();
nsISelectControlFrame* selectFrame = GetSelectFrame();
// If we foolishly tried to restore before we were done adding
// content, restore the rest of the options proper-like
if (mIsDoneAddingContent && mRestoreState) {
if (mRestoreState) {
RestoreStateTo(mRestoreState);
delete mRestoreState;
mRestoreState = nsnull;
}
if (sFrame) {
sFrame->DoneAddingContent(mIsDoneAddingContent);
// Notify the frame
if (selectFrame) {
selectFrame->DoneAddingChildren(PR_TRUE);
}
// Now that we're done, select something
// Restore state
RestoreFormControlState(this, this);
// Now that we're done, select something (if it's a single select something
// must be selected)
CheckSelectSomething();
return NS_OK;
@ -1803,8 +1811,7 @@ nsHTMLSelectElement::GetType(PRInt32* aType)
}
NS_IMETHODIMP
nsHTMLSelectElement::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
nsHTMLSelectElement::SaveState()
{
nsAutoString stateStr;
@ -1826,24 +1833,19 @@ nsHTMLSelectElement::SaveState(nsIPresContext* aPresContext,
}
}
nsresult rv = GetPrimaryPresState(this, aState);
if (*aState) {
rv = (*aState)->SetStateProperty(NS_LITERAL_STRING("selecteditems"),
stateStr);
nsCOMPtr<nsIPresState> state;
nsresult rv = GetPrimaryPresState(this, getter_AddRefs(state));
if (state) {
rv = state->SetStateProperty(NS_LITERAL_STRING("selecteditems"),
stateStr);
NS_ASSERTION(NS_SUCCEEDED(rv), "selecteditems set failed!");
}
return rv;
}
NS_IMETHODIMP
nsHTMLSelectElement::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
nsHTMLSelectElement::RestoreState(nsIPresState* aState)
{
// XXX This works right now, but since this is only called from
// RestoreState() in the frame, this will happen at the first frame
// creation. If JavaScript makes changes before then, and the page
// is being reloaded, these changes will be lost.
//
// If RestoreState() is called a second time after SaveState() was
// called, this will do nothing.
@ -1880,7 +1882,7 @@ nsHTMLSelectElement::GetBoxObject(nsIBoxObject** aResult)
nsresult
nsHTMLSelectElement::RestoreStateTo(nsAString* aNewSelected)
{
if (!mIsDoneAddingContent) {
if (!mIsDoneAddingChildren) {
mRestoreState = new nsString;
if (!mRestoreState) {
return NS_OK;

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

@ -73,6 +73,7 @@
#include "nsIDOMText.h"
#include "nsReadableUtils.h"
#include "nsITextContent.h"
#include "nsITextAreaElement.h"
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
@ -80,7 +81,8 @@ static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
class nsHTMLTextAreaElement : public nsGenericHTMLContainerFormElement,
public nsIDOMHTMLTextAreaElement,
public nsIDOMNSHTMLTextAreaElement,
public nsITextControlElement
public nsITextControlElement,
public nsITextAreaElement
{
public:
nsHTMLTextAreaElement();
@ -104,13 +106,16 @@ public:
// nsIDOMNSHTMLTextAreaElement
NS_DECL_NSIDOMNSHTMLTEXTAREAELEMENT
// nsITextAreaElement
NS_DECL_NSITEXTAREAELEMENT
// nsIFormControl
NS_IMETHOD GetType(PRInt32* aType);
NS_IMETHOD Reset();
NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,
nsIContent* aSubmitElement);
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
NS_IMETHOD SaveState();
NS_IMETHOD RestoreState(nsIPresState* aState);
// nsITextControlElement
NS_IMETHOD SetValueGuaranteed(const nsAString& aValue, nsIGfxTextControlFrame2* aFrame);
@ -197,6 +202,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTextAreaElement,
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLTextAreaElement)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLTextAreaElement)
NS_INTERFACE_MAP_ENTRY(nsITextControlElement)
NS_INTERFACE_MAP_ENTRY(nsITextAreaElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLTextAreaElement)
NS_HTML_CONTENT_INTERFACE_MAP_END
@ -789,6 +795,14 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
return rv;
}
// nsITextAreaElement
NS_IMETHODIMP
nsHTMLTextAreaElement::DoneAddingChildren()
{
RestoreFormControlState(this, this);
return NS_OK;
}
// nsIFormControl
NS_IMETHODIMP
@ -914,30 +928,33 @@ nsHTMLTextAreaElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
NS_IMETHODIMP
nsHTMLTextAreaElement::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
nsHTMLTextAreaElement::SaveState()
{
nsresult rv = GetPrimaryPresState(this, aState);
if (*aState) {
nsString value;
GetValue(value);
// XXX Should use nsAutoString above but ConvertStringLineBreaks requires
// mOwnsBuffer!
rv = nsLinebreakConverter::ConvertStringLineBreaks(
value,
nsLinebreakConverter::eLinebreakPlatform,
nsLinebreakConverter::eLinebreakContent);
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
rv = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), value);
NS_ASSERTION(NS_SUCCEEDED(rv), "value save failed!");
nsresult rv = NS_OK;
// Only save if value != defaultValue (bug 62713)
if (mValueChanged) {
nsCOMPtr<nsIPresState> state;
rv = GetPrimaryPresState(this, getter_AddRefs(state));
if (state) {
nsAutoString value;
GetValue(value);
rv = nsLinebreakConverter::ConvertStringLineBreaks(
value,
nsLinebreakConverter::eLinebreakPlatform,
nsLinebreakConverter::eLinebreakContent);
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
rv = state->SetStateProperty(NS_LITERAL_STRING("value"), value);
NS_ASSERTION(NS_SUCCEEDED(rv), "value save failed!");
}
}
return rv;
}
NS_IMETHODIMP
nsHTMLTextAreaElement::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
nsHTMLTextAreaElement::RestoreState(nsIPresState* aState)
{
nsresult rv = NS_OK;

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

@ -123,6 +123,7 @@
#include "nsIParserService.h"
#include "nsParserCIID.h"
#include "nsISelectElement.h"
#include "nsITextAreaElement.h"
#include "nsIPref.h"
@ -810,8 +811,9 @@ MakeContentObject(nsHTMLTag aNodeType,
nsIDOMHTMLFormElement* aForm,
nsIWebShell* aWebShell,
nsIHTMLContent** aResult,
const nsAString* aSkippedContent = nsnull,
PRBool aInsideNoXXXTag = PR_FALSE);
const nsAString* aSkippedContent,
PRBool aInsideNoXXXTag,
PRBool aFromParser);
/**
@ -858,7 +860,8 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
}
// Make the content object
rv = MakeContentObject(aNodeType, nodeInfo, aForm, aWebShell,
aResult, skippedContent, !!mInsideNoXXXTag);
aResult, skippedContent, !!mInsideNoXXXTag,
PR_TRUE);
PRInt32 id;
mDocument->GetAndIncrementContentID(&id);
@ -895,7 +898,7 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
if (aCaseSensitive) {
rv = MakeContentObject(nsHTMLTag(id), aNodeInfo, nsnull, nsnull,
aResult);
aResult, nsnull, PR_FALSE, PR_FALSE);
} else {
// Revese map id to name to get the correct character case in
// the tag name.
@ -922,7 +925,8 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
}
}
rv = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull, nsnull, aResult);
rv = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull, nsnull, aResult,
nsnull, PR_FALSE, PR_FALSE);
}
}
@ -994,7 +998,8 @@ MakeContentObject(nsHTMLTag aNodeType,
nsIWebShell* aWebShell,
nsIHTMLContent** aResult,
const nsAString* aSkippedContent,
PRBool aInsideNoXXXTag)
PRBool aInsideNoXXXTag,
PRBool aFromParser)
{
nsresult rv = NS_OK;
switch (aNodeType) {
@ -1105,7 +1110,7 @@ MakeContentObject(nsHTMLTag aNodeType,
rv = NS_NewHTMLImageElement(aResult, aNodeInfo);
break;
case eHTMLTag_input:
rv = NS_NewHTMLInputElement(aResult, aNodeInfo);
rv = NS_NewHTMLInputElement(aResult, aNodeInfo, aFromParser);
if (!aInsideNoXXXTag)
SetForm(*aResult, aForm);
break;
@ -1170,7 +1175,7 @@ MakeContentObject(nsHTMLTag aNodeType,
rv = NS_NewHTMLScriptElement(aResult, aNodeInfo);
break;
case eHTMLTag_select:
rv = NS_NewHTMLSelectElement(aResult, aNodeInfo);
rv = NS_NewHTMLSelectElement(aResult, aNodeInfo, aFromParser);
if (!aInsideNoXXXTag) {
SetForm(*aResult, aForm);
}
@ -1421,13 +1426,6 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
return rv;
}
if (nodeType == eHTMLTag_select) {
nsCOMPtr<nsISelectElement> select(do_QueryInterface(content));
if (select) {
select->DoneAddingContent(PR_FALSE);
}
}
mStack[mStackPos].mType = nodeType;
mStack[mStackPos].mContent = content;
mStack[mStackPos].mFlags = 0;
@ -1607,9 +1605,8 @@ SinkContext::CloseContainer(const nsIParserNode& aNode)
case eHTMLTag_select:
{
nsCOMPtr<nsISelectElement> select = do_QueryInterface(content, &result);
if (NS_SUCCEEDED(result)) {
result = select->DoneAddingContent(PR_TRUE);
if (select) {
result = select->DoneAddingChildren();
}
}
break;
@ -1884,6 +1881,22 @@ SinkContext::AddLeaf(const nsIParserNode& aNode)
// Add new leaf to its parent
AddLeaf(content);
// Notify input and button that they are now fully created
switch (nodeType) {
case eHTMLTag_input:
case eHTMLTag_button:
content->DoneCreatingElement();
break;
case eHTMLTag_textarea:
// XXX textarea deserves to be treated like the container it is.
nsCOMPtr<nsITextAreaElement> textarea(do_QueryInterface(content));
if (textarea) {
textarea->DoneAddingChildren();
}
break;
}
NS_RELEASE(content);
}
break;

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

@ -1880,6 +1880,11 @@ nsXULElement::HandleEvent(nsIDOMEvent *aEvent)
return DispatchEvent(aEvent, &noDefault);
}
NS_IMETHODIMP
nsXULElement::DoneCreatingElement()
{
return NS_OK;
}
//----------------------------------------------------------------------
// nsIScriptEventHandlerOwner interface

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

@ -389,6 +389,7 @@ public:
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus* aEventStatus);
NS_IMETHOD DoneCreatingElement();
NS_IMETHOD GetContentID(PRUint32* aID);
NS_IMETHOD SetContentID(PRUint32 aID);

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

@ -71,6 +71,7 @@
#include "nsIContentList.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsPrintfCString.h"
#ifdef DEBUG
#undef NOISY_DEBUG
@ -366,7 +367,7 @@ public:
nsIStatefulFrame::SpecialStateID aID = nsIStatefulFrame::eNoID);
NS_IMETHOD GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
nsCString& aString);
nsACString& aString);
// Gets and sets properties on a given frame
NS_IMETHOD GetFrameProperty(nsIFrame* aFrame,
@ -2048,14 +2049,14 @@ FrameManager::RestoreFrameState(nsIPresContext* aPresContext, nsIFrame* aFrame,
}
static inline void KeyAppendSep(nsCString& aKey)
static inline void KeyAppendSep(nsACString& aKey)
{
if (!aKey.IsEmpty()) {
aKey.Append(">");
aKey.Append('>');
}
}
static inline void KeyAppendString(const nsAString& aString, nsCString& aKey)
static inline void KeyAppendString(const nsAString& aString, nsACString& aKey)
{
KeyAppendSep(aKey);
@ -2065,14 +2066,14 @@ static inline void KeyAppendString(const nsAString& aString, nsCString& aKey)
aKey.Append(NS_ConvertUCS2toUTF8(aString));
}
static inline void KeyAppendInt(PRInt32 aInt, nsCString& aKey)
static inline void KeyAppendInt(PRInt32 aInt, nsACString& aKey)
{
KeyAppendSep(aKey);
aKey.AppendInt(aInt);
aKey.Append(nsPrintfCString("%d", aInt));
}
static inline void KeyAppendAtom(nsIAtom* aAtom, nsCString& aKey)
static inline void KeyAppendAtom(nsIAtom* aAtom, nsACString& aKey)
{
NS_PRECONDITION(aAtom, "KeyAppendAtom: aAtom can not be null!\n");
@ -2093,7 +2094,7 @@ static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
NS_IMETHODIMP
FrameManager::GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
nsCString& aKey)
nsACString& aKey)
{
aKey.Truncate();

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

@ -202,7 +202,7 @@ public:
nsIStatefulFrame::SpecialStateID aID = nsIStatefulFrame::eNoID) = 0;
NS_IMETHOD GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
nsCString& aString) = 0;
nsACString& aString) = 0;
/**

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

@ -1872,7 +1872,6 @@ nsComboboxControlFrame::GetDropDown(nsIFrame** aDropDownFrame)
NS_IMETHODIMP
nsComboboxControlFrame::ToggleList(nsIPresContext* aPresContext)
{
ShowList(aPresContext, (PR_FALSE == mDroppedDown));
return NS_OK;
@ -1996,7 +1995,7 @@ nsComboboxControlFrame::GetIndexOfDisplayArea(PRInt32* aSelectedIndex)
// nsISelectControlFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsComboboxControlFrame::DoneAddingContent(PRBool aIsDone)
nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
{
nsISelectControlFrame* listFrame = nsnull;
nsresult rv = NS_ERROR_FAILURE;
@ -2004,7 +2003,7 @@ nsComboboxControlFrame::DoneAddingContent(PRBool aIsDone)
rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->DoneAddingContent(aIsDone);
rv = listFrame->DoneAddingChildren(aIsDone);
NS_RELEASE(listFrame);
}
}
@ -2672,6 +2671,7 @@ nsComboboxControlFrame::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
nsCOMPtr<nsIStatefulFrame> stateful(do_QueryInterface(mListControlFrame));
NS_ASSERTION(stateful, "Couldn't cast list frame to stateful frame!!!");
if (stateful) {
return stateful->SaveState(aPresContext, aState);
}
@ -2689,6 +2689,5 @@ nsComboboxControlFrame::RestoreState(nsIPresContext* aPresContext,
nsresult rv = CallQueryInterface(mListControlFrame, &stateful);
NS_ASSERTION(NS_SUCCEEDED(rv), "Must implement nsIStatefulFrame");
rv = stateful->RestoreState(aPresContext, aState);
InitTextStr();
return rv;
}

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

@ -188,7 +188,7 @@ public:
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
NS_IMETHOD DoneAddingChildren(PRBool aIsDone);
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
PRInt32 aIndex,
PRBool aSelected);

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

@ -63,7 +63,6 @@
#include "nsIDOMMouseListener.h"
#include "nsIPresShell.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsIDOMWindowInternal.h"
@ -149,10 +148,16 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(rv)) {
mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE);
if (nsFormFrame::GetDisabled(this)) {
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) {
textControl->SetDisabled(nsFormFrame::GetDisabled(this));
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) {
textControl->SetDisabled(nsFormFrame::GetDisabled(this));
// Initialize value when we create the content in case the value was set
// before we got here
nsCOMPtr<nsIDOMHTMLInputElement> fileContent = do_QueryInterface(mContent);
if (fileContent) {
nsAutoString value;
fileContent->GetValue(value);
textControl->SetValue(value);
}
}
aChildList.AppendElement(mTextContent);
@ -199,9 +204,6 @@ nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
} else if (aIID.Equals(NS_GET_IID(nsIDOMMouseListener))) {
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
return NS_OK;
}
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
}
@ -678,54 +680,6 @@ nsFileControlFrame::Paint(nsIPresContext* aPresContext,
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsFileControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Don't save state before we are initialized
if (!mTextFrame && !mCachedState) {
return NS_OK;
}
// Get the value string
nsAutoString stateString;
nsresult res = GetProperty(nsHTMLAtoms::value, stateString);
NS_ENSURE_SUCCESS(res, res);
// Compare to default value, and only save if needed (Bug 62713)
nsAutoString defaultStateString;
nsCOMPtr<nsIDOMHTMLInputElement> formControl(do_QueryInterface(mContent));
if (formControl) {
formControl->GetDefaultValue(defaultStateString);
}
if (! stateString.Equals(defaultStateString)) {
// Construct a pres state and store value in it.
res = NS_NewPresState(aState);
NS_ENSURE_SUCCESS(res, res);
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
}
return res;
}
NS_IMETHODIMP
nsFileControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
NS_ENSURE_ARG_POINTER(aState);
nsAutoString string;
aState->GetStateProperty(NS_LITERAL_STRING("value"), string);
SetProperty(aPresContext, nsHTMLAtoms::value, string);
return NS_OK;
}
NS_IMETHODIMP
nsFileControlFrame::OnContentReset()
{

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

@ -42,7 +42,6 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIStatefulFrame.h"
#include "nsCOMPtr.h"
#include "nsIHTMLContent.h"
@ -57,9 +56,7 @@ class nsISupportsArray;
class nsFileControlFrame : public nsAreaFrame,
public nsIFormControlFrame,
public nsIDOMMouseListener,
public nsIAnonymousContentCreator,
public nsIStatefulFrame
public nsIAnonymousContentCreator
{
public:
nsFileControlFrame();
@ -183,10 +180,6 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
protected:
virtual PRIntn GetSkipSides() const;

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

@ -892,37 +892,3 @@ nsFormControlHelper::Reset(nsIFrame* aFrame, nsIPresContext* aPresContext)
return NS_ERROR_FAILURE;
}
nsresult
nsFormControlHelper::SaveContentState(nsIFrame* aFrame,
nsIPresContext* aPresContext,
nsIPresState** aState)
{
nsCOMPtr<nsIContent> controlContent;
aFrame->GetContent(getter_AddRefs(controlContent));
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
if (control) {
control->SaveState(aPresContext, aState);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
nsresult
nsFormControlHelper::RestoreContentState(nsIFrame* aFrame,
nsIPresContext* aPresContext,
nsIPresState* aState)
{
nsCOMPtr<nsIContent> controlContent;
aFrame->GetContent(getter_AddRefs(controlContent));
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
if (control) {
control->RestoreState(aPresContext, aState);
return NS_OK;
}
NS_NOTREACHED("no content");
return NS_ERROR_FAILURE;
}

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

@ -160,12 +160,6 @@ public:
static nsresult GetName(nsIContent* aContent, nsAString* aResult);
static nsresult GetInputElementValue(nsIContent* aContent, nsString* aText, PRBool aInitialValue);
static nsresult Reset(nsIFrame* aFrame, nsIPresContext* aPresContext);
static nsresult SaveContentState(nsIFrame* aFrame,
nsIPresContext* aPresContext,
nsIPresState** aState);
static nsresult RestoreContentState(nsIFrame* aFrame,
nsIPresContext* aPresContext,
nsIPresState* aState);
/**
* Utility to convert a string to a PRBool

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

@ -466,8 +466,6 @@ nsGfxButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
*aInstancePtr = NS_STATIC_CAST(nsIAnonymousContentCreator*, this);
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = NS_STATIC_CAST(nsIStatefulFrame*, this);
}
else {
return nsHTMLButtonControlFrame::QueryInterface(aIID, aInstancePtr);
@ -651,48 +649,3 @@ nsGfxButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsGfxButtonControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Get the value string
nsAutoString stateString;
nsresult res = GetProperty(nsHTMLAtoms::value, stateString);
NS_ENSURE_SUCCESS(res, res);
// Compare to default value, and only save if needed (Bug 62713)
NS_ENSURE_TRUE(mContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL),
NS_ERROR_UNEXPECTED);
nsAutoString defaultStateString;
if (!mDefaultValueWasChanged) {
mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, defaultStateString);
}
if (mDefaultValueWasChanged || !stateString.Equals(defaultStateString)) {
// Construct a pres state and store value in it.
res = NS_NewPresState(aState);
NS_ENSURE_SUCCESS(res, res);
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
}
return res;
}
NS_IMETHODIMP
nsGfxButtonControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Set the value to the stored state.
nsAutoString stateString;
nsresult res = aState->GetStateProperty(NS_LITERAL_STRING("value"), stateString);
NS_ENSURE_SUCCESS(res, res);
return SetProperty(aPresContext, nsHTMLAtoms::value, stateString);
}

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

@ -43,7 +43,6 @@
#include "nsCOMPtr.h"
#include "nsIAnonymousContentCreator.h"
#include "nsITextContent.h"
#include "nsIStatefulFrame.h"
#ifdef ACCESSIBILITY
class nsIAccessible;
@ -57,8 +56,7 @@ class nsIAccessible;
class nsIPresState;
class nsGfxButtonControlFrame : public nsHTMLButtonControlFrame,
public nsIAnonymousContentCreator,
public nsIStatefulFrame
public nsIAnonymousContentCreator
{
public:
nsGfxButtonControlFrame();
@ -117,10 +115,6 @@ protected:
virtual PRBool IsSubmit(PRInt32 type);
virtual PRBool IsBrowse(PRInt32 type); // Browse button of file input
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
private:
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }

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

@ -96,10 +96,7 @@ nsGfxCheckboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr
NS_ASSERTION(aInstancePtr, "QueryInterface requires a non-NULL destination!");
if ( !aInstancePtr )
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsICheckboxControlFrame))) {
*aInstancePtr = (void*) ((nsICheckboxControlFrame*) this);
return NS_OK;
@ -275,21 +272,6 @@ nsGfxCheckboxControlFrame::GetCheckboxState ( )
return retval;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP nsGfxCheckboxControlFrame::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
return nsFormControlHelper::SaveContentState(this, aPresContext, aState);
}
NS_IMETHODIMP nsGfxCheckboxControlFrame::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
{
return nsFormControlHelper::RestoreContentState(this, aPresContext, aState);
}
//------------------------------------------------------------
// Extra Debug Methods
//------------------------------------------------------------

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

@ -38,7 +38,6 @@
#define nsGfxCheckboxControlFrame_h___
#include "nsFormControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsICheckboxControlFrame.h"
#ifdef ACCESSIBILITY
@ -50,7 +49,6 @@ class nsIAccessible;
#define NS_GFX_CHECKBOX_CONTROL_FRAME_LAST_CONTEXT_INDEX 0
class nsGfxCheckboxControlFrame : public nsFormControlFrame,
public nsIStatefulFrame,
public nsICheckboxControlFrame//,
//public nsIAccessible
{
@ -90,11 +88,7 @@ public:
// nsIFormControlFrame
NS_IMETHOD OnContentReset();
// nsIStatefulFrame
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
#ifdef DEBUG_rodsXXX
NS_IMETHOD Reflow(nsIPresContext* aCX,

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

@ -94,10 +94,6 @@ nsGfxRadioControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
*aInstancePtr = (void*) ((nsIRadioControlFrame*) this);
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*) ((nsIStatefulFrame*) this);
return NS_OK;
}
return nsFormControlFrame::QueryInterface(aIID, aInstancePtr);
}
@ -257,25 +253,6 @@ nsGfxRadioControlFrame::OnChecked(nsIPresContext* aPresContext,
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsGfxRadioControlFrame::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
return nsFormControlHelper::SaveContentState(this, aPresContext, aState);
}
//----------------------------------------------------------------------
NS_IMETHODIMP
nsGfxRadioControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
return nsFormControlHelper::RestoreContentState(this, aPresContext, aState);
}
//----------------------------------------------------------------------
// Extra Debug Helper Methods

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

@ -39,7 +39,6 @@
#define nsGfxRadioControlFrame_h___
#include "nsFormControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsIRadioControlFrame.h"
#ifdef ACCESSIBILITY
@ -52,7 +51,6 @@ class nsIAccessible;
#define NS_GFX_RADIO_CONTROL_FRAME_LAST_CONTEXT_INDEX 0
class nsGfxRadioControlFrame : public nsFormControlFrame,
public nsIStatefulFrame,
public nsIRadioControlFrame
{
@ -97,10 +95,6 @@ public:
// nsIFormControlFrame
NS_IMETHOD OnContentReset();
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
///XXX: End o the temporary methods
#ifdef DEBUG_rodsXXX
NS_IMETHOD Reflow(nsIPresContext* aCX,

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

@ -74,9 +74,10 @@ public:
NS_IMETHOD GetOptionSelected(PRInt32 index, PRBool* value) = 0;
/**
* Sets the select state of the option at index
* Sets whether the parser is done adding children
* @param aIsDone whether the parser is done adding children
*/
NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0;
NS_IMETHOD DoneAddingChildren(PRBool aIsDone) = 0;
/**
* Notify the frame when an option is selected

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

@ -553,10 +553,6 @@ nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
*aInstancePtr = (void*)(nsIDOMKeyListener*) this;
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
return NS_OK;
}
return nsScrollFrame::QueryInterface(aIID, aInstancePtr);
}
@ -1453,7 +1449,7 @@ nsListControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
// First check to see if all the content has been added
nsCOMPtr<nsISelectElement> element(do_QueryInterface(mContent));
if (element) {
element->IsDoneAddingContent(&mIsAllContentHere);
element->IsDoneAddingChildren(&mIsAllContentHere);
if (!mIsAllContentHere) {
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
@ -1969,7 +1965,7 @@ PRBool nsListControlFrame::CheckIfAllFramesHere()
//-------------------------------------------------------------------
NS_IMETHODIMP
nsListControlFrame::DoneAddingContent(PRBool aIsDone)
nsListControlFrame::DoneAddingChildren(PRBool aIsDone)
{
mIsAllContentHere = aIsDone;
if (mIsAllContentHere) {
@ -2003,7 +1999,7 @@ nsListControlFrame::AddOption(nsIPresContext* aPresContext, PRInt32 aIndex)
if (!mIsAllContentHere) {
nsCOMPtr<nsISelectElement> element(do_QueryInterface(mContent));
if (element) {
element->IsDoneAddingContent(&mIsAllContentHere);
element->IsDoneAddingChildren(&mIsAllContentHere);
if (!mIsAllContentHere) {
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
@ -2775,15 +2771,8 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
if (NS_SUCCEEDED(mPresContext->GetEventStateManager(getter_AddRefs(stateManager)))) {
nsIFrame * frame;
stateManager->GetEventTarget(&frame);
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
if (listFrame) {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
} else {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
// This will consume the focus event we get from the clicking on the dropdown
//stateManager->ConsumeFocusEvents(PR_TRUE);
@ -3575,21 +3564,3 @@ nsListControlFrame::ItemsHaveBeenRemoved(nsIPresContext * aPresContext)
ResetList(aPresContext);
}
}
//--------------------------------------------------------
// nsIStatefulFrame
//--------------------------------------------------------
NS_IMETHODIMP
nsListControlFrame::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
return nsFormControlHelper::SaveContentState(this, aPresContext, aState);
}
NS_IMETHODIMP
nsListControlFrame::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
{
return nsFormControlHelper::RestoreContentState(this, aPresContext, aState);
}

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

@ -58,7 +58,6 @@
#include "nsIPresState.h"
#include "nsCWeakReference.h"
#include "nsIContent.h"
#include "nsIStatefulFrame.h"
class nsIDOMHTMLSelectElement;
class nsIDOMHTMLCollection;
@ -68,7 +67,6 @@ class nsIViewManager;
class nsIPresContext;
class nsVoidArray;
class nsIScrollableView;
class nsIStatefulFrame;
class nsListControlFrame;
class nsSelectUpdateTimer;
@ -283,7 +281,7 @@ public:
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
NS_IMETHOD DoneAddingChildren(PRBool aIsDone);
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
PRInt32 aIndex,
PRBool aSelected);
@ -309,10 +307,6 @@ public:
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) { return NS_OK; }
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
// Static Methods
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
static nsIDOMHTMLCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);

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

@ -71,6 +71,7 @@
#include "nsIContentList.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsPrintfCString.h"
#ifdef DEBUG
#undef NOISY_DEBUG
@ -366,7 +367,7 @@ public:
nsIStatefulFrame::SpecialStateID aID = nsIStatefulFrame::eNoID);
NS_IMETHOD GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
nsCString& aString);
nsACString& aString);
// Gets and sets properties on a given frame
NS_IMETHOD GetFrameProperty(nsIFrame* aFrame,
@ -2048,14 +2049,14 @@ FrameManager::RestoreFrameState(nsIPresContext* aPresContext, nsIFrame* aFrame,
}
static inline void KeyAppendSep(nsCString& aKey)
static inline void KeyAppendSep(nsACString& aKey)
{
if (!aKey.IsEmpty()) {
aKey.Append(">");
aKey.Append('>');
}
}
static inline void KeyAppendString(const nsAString& aString, nsCString& aKey)
static inline void KeyAppendString(const nsAString& aString, nsACString& aKey)
{
KeyAppendSep(aKey);
@ -2065,14 +2066,14 @@ static inline void KeyAppendString(const nsAString& aString, nsCString& aKey)
aKey.Append(NS_ConvertUCS2toUTF8(aString));
}
static inline void KeyAppendInt(PRInt32 aInt, nsCString& aKey)
static inline void KeyAppendInt(PRInt32 aInt, nsACString& aKey)
{
KeyAppendSep(aKey);
aKey.AppendInt(aInt);
aKey.Append(nsPrintfCString("%d", aInt));
}
static inline void KeyAppendAtom(nsIAtom* aAtom, nsCString& aKey)
static inline void KeyAppendAtom(nsIAtom* aAtom, nsACString& aKey)
{
NS_PRECONDITION(aAtom, "KeyAppendAtom: aAtom can not be null!\n");
@ -2093,7 +2094,7 @@ static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
NS_IMETHODIMP
FrameManager::GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
nsCString& aKey)
nsACString& aKey)
{
aKey.Truncate();

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

@ -74,9 +74,10 @@ public:
NS_IMETHOD GetOptionSelected(PRInt32 index, PRBool* value) = 0;
/**
* Sets the select state of the option at index
* Sets whether the parser is done adding children
* @param aIsDone whether the parser is done adding children
*/
NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0;
NS_IMETHOD DoneAddingChildren(PRBool aIsDone) = 0;
/**
* Notify the frame when an option is selected

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

@ -1872,7 +1872,6 @@ nsComboboxControlFrame::GetDropDown(nsIFrame** aDropDownFrame)
NS_IMETHODIMP
nsComboboxControlFrame::ToggleList(nsIPresContext* aPresContext)
{
ShowList(aPresContext, (PR_FALSE == mDroppedDown));
return NS_OK;
@ -1996,7 +1995,7 @@ nsComboboxControlFrame::GetIndexOfDisplayArea(PRInt32* aSelectedIndex)
// nsISelectControlFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsComboboxControlFrame::DoneAddingContent(PRBool aIsDone)
nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
{
nsISelectControlFrame* listFrame = nsnull;
nsresult rv = NS_ERROR_FAILURE;
@ -2004,7 +2003,7 @@ nsComboboxControlFrame::DoneAddingContent(PRBool aIsDone)
rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->DoneAddingContent(aIsDone);
rv = listFrame->DoneAddingChildren(aIsDone);
NS_RELEASE(listFrame);
}
}
@ -2672,6 +2671,7 @@ nsComboboxControlFrame::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
nsCOMPtr<nsIStatefulFrame> stateful(do_QueryInterface(mListControlFrame));
NS_ASSERTION(stateful, "Couldn't cast list frame to stateful frame!!!");
if (stateful) {
return stateful->SaveState(aPresContext, aState);
}
@ -2689,6 +2689,5 @@ nsComboboxControlFrame::RestoreState(nsIPresContext* aPresContext,
nsresult rv = CallQueryInterface(mListControlFrame, &stateful);
NS_ASSERTION(NS_SUCCEEDED(rv), "Must implement nsIStatefulFrame");
rv = stateful->RestoreState(aPresContext, aState);
InitTextStr();
return rv;
}

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

@ -188,7 +188,7 @@ public:
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
NS_IMETHOD DoneAddingChildren(PRBool aIsDone);
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
PRInt32 aIndex,
PRBool aSelected);

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

@ -63,7 +63,6 @@
#include "nsIDOMMouseListener.h"
#include "nsIPresShell.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsIDOMWindowInternal.h"
@ -149,10 +148,16 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(rv)) {
mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE);
if (nsFormFrame::GetDisabled(this)) {
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) {
textControl->SetDisabled(nsFormFrame::GetDisabled(this));
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) {
textControl->SetDisabled(nsFormFrame::GetDisabled(this));
// Initialize value when we create the content in case the value was set
// before we got here
nsCOMPtr<nsIDOMHTMLInputElement> fileContent = do_QueryInterface(mContent);
if (fileContent) {
nsAutoString value;
fileContent->GetValue(value);
textControl->SetValue(value);
}
}
aChildList.AppendElement(mTextContent);
@ -199,9 +204,6 @@ nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
} else if (aIID.Equals(NS_GET_IID(nsIDOMMouseListener))) {
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
return NS_OK;
}
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
}
@ -678,54 +680,6 @@ nsFileControlFrame::Paint(nsIPresContext* aPresContext,
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsFileControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Don't save state before we are initialized
if (!mTextFrame && !mCachedState) {
return NS_OK;
}
// Get the value string
nsAutoString stateString;
nsresult res = GetProperty(nsHTMLAtoms::value, stateString);
NS_ENSURE_SUCCESS(res, res);
// Compare to default value, and only save if needed (Bug 62713)
nsAutoString defaultStateString;
nsCOMPtr<nsIDOMHTMLInputElement> formControl(do_QueryInterface(mContent));
if (formControl) {
formControl->GetDefaultValue(defaultStateString);
}
if (! stateString.Equals(defaultStateString)) {
// Construct a pres state and store value in it.
res = NS_NewPresState(aState);
NS_ENSURE_SUCCESS(res, res);
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
}
return res;
}
NS_IMETHODIMP
nsFileControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
NS_ENSURE_ARG_POINTER(aState);
nsAutoString string;
aState->GetStateProperty(NS_LITERAL_STRING("value"), string);
SetProperty(aPresContext, nsHTMLAtoms::value, string);
return NS_OK;
}
NS_IMETHODIMP
nsFileControlFrame::OnContentReset()
{

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

@ -42,7 +42,6 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIStatefulFrame.h"
#include "nsCOMPtr.h"
#include "nsIHTMLContent.h"
@ -57,9 +56,7 @@ class nsISupportsArray;
class nsFileControlFrame : public nsAreaFrame,
public nsIFormControlFrame,
public nsIDOMMouseListener,
public nsIAnonymousContentCreator,
public nsIStatefulFrame
public nsIAnonymousContentCreator
{
public:
nsFileControlFrame();
@ -183,10 +180,6 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
protected:
virtual PRIntn GetSkipSides() const;

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

@ -892,37 +892,3 @@ nsFormControlHelper::Reset(nsIFrame* aFrame, nsIPresContext* aPresContext)
return NS_ERROR_FAILURE;
}
nsresult
nsFormControlHelper::SaveContentState(nsIFrame* aFrame,
nsIPresContext* aPresContext,
nsIPresState** aState)
{
nsCOMPtr<nsIContent> controlContent;
aFrame->GetContent(getter_AddRefs(controlContent));
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
if (control) {
control->SaveState(aPresContext, aState);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
nsresult
nsFormControlHelper::RestoreContentState(nsIFrame* aFrame,
nsIPresContext* aPresContext,
nsIPresState* aState)
{
nsCOMPtr<nsIContent> controlContent;
aFrame->GetContent(getter_AddRefs(controlContent));
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
if (control) {
control->RestoreState(aPresContext, aState);
return NS_OK;
}
NS_NOTREACHED("no content");
return NS_ERROR_FAILURE;
}

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

@ -160,12 +160,6 @@ public:
static nsresult GetName(nsIContent* aContent, nsAString* aResult);
static nsresult GetInputElementValue(nsIContent* aContent, nsString* aText, PRBool aInitialValue);
static nsresult Reset(nsIFrame* aFrame, nsIPresContext* aPresContext);
static nsresult SaveContentState(nsIFrame* aFrame,
nsIPresContext* aPresContext,
nsIPresState** aState);
static nsresult RestoreContentState(nsIFrame* aFrame,
nsIPresContext* aPresContext,
nsIPresState* aState);
/**
* Utility to convert a string to a PRBool

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

@ -466,8 +466,6 @@ nsGfxButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
*aInstancePtr = NS_STATIC_CAST(nsIAnonymousContentCreator*, this);
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = NS_STATIC_CAST(nsIStatefulFrame*, this);
}
else {
return nsHTMLButtonControlFrame::QueryInterface(aIID, aInstancePtr);
@ -651,48 +649,3 @@ nsGfxButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsGfxButtonControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Get the value string
nsAutoString stateString;
nsresult res = GetProperty(nsHTMLAtoms::value, stateString);
NS_ENSURE_SUCCESS(res, res);
// Compare to default value, and only save if needed (Bug 62713)
NS_ENSURE_TRUE(mContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL),
NS_ERROR_UNEXPECTED);
nsAutoString defaultStateString;
if (!mDefaultValueWasChanged) {
mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, defaultStateString);
}
if (mDefaultValueWasChanged || !stateString.Equals(defaultStateString)) {
// Construct a pres state and store value in it.
res = NS_NewPresState(aState);
NS_ENSURE_SUCCESS(res, res);
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
}
return res;
}
NS_IMETHODIMP
nsGfxButtonControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Set the value to the stored state.
nsAutoString stateString;
nsresult res = aState->GetStateProperty(NS_LITERAL_STRING("value"), stateString);
NS_ENSURE_SUCCESS(res, res);
return SetProperty(aPresContext, nsHTMLAtoms::value, stateString);
}

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

@ -43,7 +43,6 @@
#include "nsCOMPtr.h"
#include "nsIAnonymousContentCreator.h"
#include "nsITextContent.h"
#include "nsIStatefulFrame.h"
#ifdef ACCESSIBILITY
class nsIAccessible;
@ -57,8 +56,7 @@ class nsIAccessible;
class nsIPresState;
class nsGfxButtonControlFrame : public nsHTMLButtonControlFrame,
public nsIAnonymousContentCreator,
public nsIStatefulFrame
public nsIAnonymousContentCreator
{
public:
nsGfxButtonControlFrame();
@ -117,10 +115,6 @@ protected:
virtual PRBool IsSubmit(PRInt32 type);
virtual PRBool IsBrowse(PRInt32 type); // Browse button of file input
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
private:
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }

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

@ -96,10 +96,7 @@ nsGfxCheckboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr
NS_ASSERTION(aInstancePtr, "QueryInterface requires a non-NULL destination!");
if ( !aInstancePtr )
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsICheckboxControlFrame))) {
*aInstancePtr = (void*) ((nsICheckboxControlFrame*) this);
return NS_OK;
@ -275,21 +272,6 @@ nsGfxCheckboxControlFrame::GetCheckboxState ( )
return retval;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP nsGfxCheckboxControlFrame::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
return nsFormControlHelper::SaveContentState(this, aPresContext, aState);
}
NS_IMETHODIMP nsGfxCheckboxControlFrame::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
{
return nsFormControlHelper::RestoreContentState(this, aPresContext, aState);
}
//------------------------------------------------------------
// Extra Debug Methods
//------------------------------------------------------------

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

@ -38,7 +38,6 @@
#define nsGfxCheckboxControlFrame_h___
#include "nsFormControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsICheckboxControlFrame.h"
#ifdef ACCESSIBILITY
@ -50,7 +49,6 @@ class nsIAccessible;
#define NS_GFX_CHECKBOX_CONTROL_FRAME_LAST_CONTEXT_INDEX 0
class nsGfxCheckboxControlFrame : public nsFormControlFrame,
public nsIStatefulFrame,
public nsICheckboxControlFrame//,
//public nsIAccessible
{
@ -90,11 +88,7 @@ public:
// nsIFormControlFrame
NS_IMETHOD OnContentReset();
// nsIStatefulFrame
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
#ifdef DEBUG_rodsXXX
NS_IMETHOD Reflow(nsIPresContext* aCX,

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

@ -94,10 +94,6 @@ nsGfxRadioControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
*aInstancePtr = (void*) ((nsIRadioControlFrame*) this);
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*) ((nsIStatefulFrame*) this);
return NS_OK;
}
return nsFormControlFrame::QueryInterface(aIID, aInstancePtr);
}
@ -257,25 +253,6 @@ nsGfxRadioControlFrame::OnChecked(nsIPresContext* aPresContext,
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsGfxRadioControlFrame::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
return nsFormControlHelper::SaveContentState(this, aPresContext, aState);
}
//----------------------------------------------------------------------
NS_IMETHODIMP
nsGfxRadioControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
return nsFormControlHelper::RestoreContentState(this, aPresContext, aState);
}
//----------------------------------------------------------------------
// Extra Debug Helper Methods

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

@ -39,7 +39,6 @@
#define nsGfxRadioControlFrame_h___
#include "nsFormControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsIRadioControlFrame.h"
#ifdef ACCESSIBILITY
@ -52,7 +51,6 @@ class nsIAccessible;
#define NS_GFX_RADIO_CONTROL_FRAME_LAST_CONTEXT_INDEX 0
class nsGfxRadioControlFrame : public nsFormControlFrame,
public nsIStatefulFrame,
public nsIRadioControlFrame
{
@ -97,10 +95,6 @@ public:
// nsIFormControlFrame
NS_IMETHOD OnContentReset();
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
///XXX: End o the temporary methods
#ifdef DEBUG_rodsXXX
NS_IMETHOD Reflow(nsIPresContext* aCX,

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

@ -1329,10 +1329,6 @@ nsGfxTextControlFrame2::QueryInterface(const nsIID& aIID, void** aInstancePtr)
*aInstancePtr = (void*)(nsIGfxTextControlFrame2*) this;
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIScrollableViewProvider))) {
*aInstancePtr = (void*)(nsIScrollableViewProvider*) this;
return NS_OK;
@ -3405,21 +3401,6 @@ nsGfxTextControlFrame2::GetWidthInCharacters() const
return DEFAULT_COLUMN_WIDTH;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsGfxTextControlFrame2::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
return nsFormControlHelper::SaveContentState(this, aPresContext, aState);
}
NS_IMETHODIMP
nsGfxTextControlFrame2::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
return nsFormControlHelper::RestoreContentState(this, aPresContext, aState);
}
NS_IMETHODIMP
nsGfxTextControlFrame2::GetScrollableView(nsIScrollableView** aView)
{

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

@ -43,7 +43,6 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIStatefulFrame.h"
#include "nsIEditor.h"
#include "nsIGfxTextControlFrame.h"
#include "nsFormControlHelper.h"//for the inputdimensions
@ -70,7 +69,6 @@ class nsIAccessible;
class nsGfxTextControlFrame2 : public nsStackFrame,
public nsIAnonymousContentCreator,
public nsIGfxTextControlFrame2,
public nsIStatefulFrame,
public nsIScrollableViewProvider
{
@ -231,10 +229,6 @@ protected:
PRInt32 GetWidthInCharacters() const;
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
// nsIScrollableViewProvider
NS_IMETHOD GetScrollableView(nsIScrollableView** aView);

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

@ -553,10 +553,6 @@ nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
*aInstancePtr = (void*)(nsIDOMKeyListener*) this;
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
return NS_OK;
}
return nsScrollFrame::QueryInterface(aIID, aInstancePtr);
}
@ -1453,7 +1449,7 @@ nsListControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
// First check to see if all the content has been added
nsCOMPtr<nsISelectElement> element(do_QueryInterface(mContent));
if (element) {
element->IsDoneAddingContent(&mIsAllContentHere);
element->IsDoneAddingChildren(&mIsAllContentHere);
if (!mIsAllContentHere) {
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
@ -1969,7 +1965,7 @@ PRBool nsListControlFrame::CheckIfAllFramesHere()
//-------------------------------------------------------------------
NS_IMETHODIMP
nsListControlFrame::DoneAddingContent(PRBool aIsDone)
nsListControlFrame::DoneAddingChildren(PRBool aIsDone)
{
mIsAllContentHere = aIsDone;
if (mIsAllContentHere) {
@ -2003,7 +1999,7 @@ nsListControlFrame::AddOption(nsIPresContext* aPresContext, PRInt32 aIndex)
if (!mIsAllContentHere) {
nsCOMPtr<nsISelectElement> element(do_QueryInterface(mContent));
if (element) {
element->IsDoneAddingContent(&mIsAllContentHere);
element->IsDoneAddingChildren(&mIsAllContentHere);
if (!mIsAllContentHere) {
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
@ -2775,15 +2771,8 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
if (NS_SUCCEEDED(mPresContext->GetEventStateManager(getter_AddRefs(stateManager)))) {
nsIFrame * frame;
stateManager->GetEventTarget(&frame);
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
if (listFrame) {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
} else {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
// This will consume the focus event we get from the clicking on the dropdown
//stateManager->ConsumeFocusEvents(PR_TRUE);
@ -3575,21 +3564,3 @@ nsListControlFrame::ItemsHaveBeenRemoved(nsIPresContext * aPresContext)
ResetList(aPresContext);
}
}
//--------------------------------------------------------
// nsIStatefulFrame
//--------------------------------------------------------
NS_IMETHODIMP
nsListControlFrame::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
return nsFormControlHelper::SaveContentState(this, aPresContext, aState);
}
NS_IMETHODIMP
nsListControlFrame::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
{
return nsFormControlHelper::RestoreContentState(this, aPresContext, aState);
}

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

@ -58,7 +58,6 @@
#include "nsIPresState.h"
#include "nsCWeakReference.h"
#include "nsIContent.h"
#include "nsIStatefulFrame.h"
class nsIDOMHTMLSelectElement;
class nsIDOMHTMLCollection;
@ -68,7 +67,6 @@ class nsIViewManager;
class nsIPresContext;
class nsVoidArray;
class nsIScrollableView;
class nsIStatefulFrame;
class nsListControlFrame;
class nsSelectUpdateTimer;
@ -283,7 +281,7 @@ public:
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
NS_IMETHOD DoneAddingChildren(PRBool aIsDone);
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
PRInt32 aIndex,
PRBool aSelected);
@ -309,10 +307,6 @@ public:
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) { return NS_OK; }
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
//nsIStatefulFrame
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
// Static Methods
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
static nsIDOMHTMLCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);