Backing out 108308 due to pageload spike

This commit is contained in:
jkeiser%netscape.com 2002-03-29 07:35:09 +00:00
Родитель eebcbb8f9d
Коммит 24891ed355
56 изменённых файлов: 752 добавлений и 557 удалений

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

@ -309,34 +309,6 @@ 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,11 +641,6 @@ nsGenericDOMDataNode::GetListenerManager(nsIEventListenerManager** aResult)
return NS_OK;
}
NS_IMETHODIMP
nsGenericDOMDataNode::DoneCreatingElement()
{
return NS_OK;
}
//----------------------------------------------------------------------
// Implementation of nsIContent

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

@ -210,7 +210,6 @@ 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,12 +2040,6 @@ nsGenericElement::GetListenerManager(nsIEventListenerManager** aResult)
return rv;
}
NS_IMETHODIMP
nsGenericElement::DoneCreatingElement()
{
return NS_OK;
}
//----------------------------------------------------------------------
// Generic DOMNode implementations

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,54 +0,0 @@
/* -*- 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,10 +139,6 @@ 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,98 +2951,44 @@ nsGenericHTMLElement::GetPrimaryPresState(nsIHTMLContent* aContent,
nsresult result = NS_OK;
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
//
// Generate the state key
nsCOMPtr<nsIDocument> doc;
nsresult rv = aContent->GetDocument(*getter_AddRefs(doc));
result = aContent->GetDocument(*getter_AddRefs(doc));
if (!doc) {
return rv;
return result;
}
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);
rv = frameManager->GenerateStateKey(aContent, nsIStatefulFrame::eNoID, aKey);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString stateKey;
result = frameManager->GenerateStateKey(aContent, nsIStatefulFrame::eNoID, stateKey);
NS_ENSURE_TRUE((NS_SUCCEEDED(result) && !stateKey.IsEmpty()), result);
// 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;
}
// Add something unique to content so layout doesn't muck us up
aKey += "-C";
return rv;
}
PRBool
nsGenericHTMLElement::RestoreFormControlState(nsIHTMLContent* aContent,
nsIFormControl* aControl)
{
// 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;
nsCAutoString key;
nsresult rv = GetLayoutHistoryAndKey(aContent, getter_AddRefs(history), key);
if (!history) {
return PR_FALSE;
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);
}
}
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;
return result;
}
// XXX This creates a dependency between content and frames
@ -4254,11 +4200,6 @@ 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) {
@ -4285,7 +4226,6 @@ nsGenericHTMLContainerFormElement::SetDocument(nsIDocument* aDocument,
return rv;
}
nsresult
nsGenericHTMLElement::SetFormControlAttribute(nsIForm* aForm,
PRInt32 aNameSpaceID,
@ -4504,11 +4444,6 @@ 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) {
@ -4535,13 +4470,6 @@ 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,6 +53,7 @@
class nsIDOMAttr;
class nsIDOMEventListener;
class nsIDOMNodeList;
class nsIEventListenerManager;
class nsIFrame;
class nsHTMLAttributes;
class nsIHTMLMappedAttributes;
@ -67,7 +68,6 @@ class nsIFormControlFrame;
class nsIForm;
class nsIPresState;
class nsIScrollableView;
class nsILayoutHistoryState;
struct nsRect;
@ -357,38 +357,8 @@ 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);
@ -619,8 +589,14 @@ public:
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm,
PRBool aRemoveFromForm = PR_TRUE);
NS_IMETHOD SaveState() { return NS_OK; }
NS_IMETHOD RestoreState(nsIPresState* aState) { return NS_OK; }
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
return NS_OK;
}
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
return NS_OK;
}
// nsIContent
NS_IMETHOD SetParent(nsIContent *aParent);
@ -662,8 +638,14 @@ public:
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm,
PRBool aRemoveFromForm = PR_TRUE);
NS_IMETHOD SaveState() { return NS_OK; }
NS_IMETHOD RestoreState(nsIPresState* aState) { return NS_OK; }
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
return NS_OK;
}
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
return NS_OK;
}
// nsIContent
NS_IMETHOD SetParent(nsIContent *aParent);
@ -676,7 +658,7 @@ public:
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
const nsAString& aValue,
PRBool aNotify);
NS_IMETHOD DoneCreatingElement();
NS_METHOD SetAttribute(const nsAString& aName,
const nsAString& aValue)
@ -967,8 +949,7 @@ nsresult
NS_NewHTMLImageElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
nsresult
NS_NewHTMLInputElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
PRBool aFromParser);
NS_NewHTMLInputElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
nsresult
NS_NewHTMLInsElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
@ -1034,8 +1015,7 @@ nsresult
NS_NewHTMLScriptElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
nsresult
NS_NewHTMLSelectElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
PRBool aFromParser);
NS_NewHTMLSelectElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo);
inline nsresult
NS_NewHTMLSpacerElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo)

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

@ -1,3 +1,4 @@
/* -*- 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
*
@ -118,8 +119,6 @@ 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)
@ -134,7 +133,7 @@ class nsHTMLInputElement : public nsGenericHTMLLeafFormElement,
public nsIRadioControlElement
{
public:
nsHTMLInputElement(PRBool aFromParser);
nsHTMLInputElement();
virtual ~nsHTMLInputElement();
// nsISupports
@ -162,8 +161,8 @@ public:
NS_IMETHOD Reset();
NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,
nsIContent* aSubmitElement);
NS_IMETHOD SaveState();
NS_IMETHOD RestoreState(nsIPresState* aState);
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
// nsIContent
NS_IMETHOD SetFocus(nsIPresContext* aPresContext);
@ -213,8 +212,6 @@ public:
return rv;
}
NS_IMETHOD DoneCreatingElement();
// nsITextControlElement
NS_IMETHOD SetValueGuaranteed(const nsAString& aValue, nsIGfxTextControlFrame2* aFrame);
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
@ -229,6 +226,7 @@ public:
protected:
// Helper method
void SetPresStateChecked(nsIHTMLContent * aHTMLContent, PRBool aValue);
NS_IMETHOD SetValueSecure(const nsAString& aValue,
nsIGfxTextControlFrame2* aFrame,
PRBool aCheckSecurity);
@ -312,12 +310,11 @@ NS_METHOD NS_GetRadioGetCheckedChangedVisitor(PRBool* aCheckedChanged,
nsresult
NS_NewHTMLInputElement(nsIHTMLContent** aInstancePtrResult,
nsINodeInfo *aNodeInfo,
PRBool aFromParser)
nsINodeInfo *aNodeInfo)
{
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
nsHTMLInputElement* it = new nsHTMLInputElement(aFromParser);
nsHTMLInputElement* it = new nsHTMLInputElement();
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
@ -338,11 +335,10 @@ NS_NewHTMLInputElement(nsIHTMLContent** aInstancePtrResult,
}
nsHTMLInputElement::nsHTMLInputElement(PRBool aFromParser)
nsHTMLInputElement::nsHTMLInputElement()
{
mType = NS_FORM_INPUT_TEXT; // default value
mBitField = 0;
SET_BOOLBIT(mBitField, BF_PARSER_CREATING, aFromParser);
mValue = nsnull;
}
@ -382,7 +378,7 @@ nsHTMLInputElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
nsHTMLInputElement* it = new nsHTMLInputElement(PR_FALSE);
nsHTMLInputElement* it = new nsHTMLInputElement();
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
@ -456,16 +452,10 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
//
if (aName == nsHTMLAtoms::checked &&
!GET_BOOLBIT(mBitField, BF_CHECKED_CHANGED)) {
// 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);
}
PRBool resetVal;
GetDefaultChecked(&resetVal);
SetChecked(resetVal);
SetCheckedChanged(PR_FALSE);
}
}
@ -626,7 +616,6 @@ 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 =
@ -648,6 +637,7 @@ nsHTMLInputElement::SetValueSecure(const nsAString& aValue,
}
}
nsIGfxTextControlFrame2* textControlFrame = aFrame;
nsIFormControlFrame* formControlFrame = textControlFrame;
if (!textControlFrame) {
@ -661,12 +651,7 @@ 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);
}
@ -714,6 +699,20 @@ 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)
{
@ -1598,9 +1597,8 @@ 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;
@ -2011,7 +2009,7 @@ nsHTMLInputElement::Reset()
case NS_FORM_INPUT_FILE:
{
// Resetting it to blank should not perform security check
rv = SetValueGuaranteed(NS_LITERAL_STRING(""), nsnull);
rv = SetValueSecure(NS_LITERAL_STRING(""), nsnull, PR_FALSE);
break;
}
default:
@ -2236,37 +2234,30 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
NS_IMETHODIMP
nsHTMLInputElement::SaveState()
nsHTMLInputElement::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
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);
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!");
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"));
}
NS_ASSERTION(NS_SUCCEEDED(rv), "checked save failed!");
}
break;
}
@ -2277,19 +2268,19 @@ nsHTMLInputElement::SaveState()
case NS_FORM_INPUT_TEXT:
case NS_FORM_INPUT_FILE:
{
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!");
}
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!");
}
break;
}
@ -2299,41 +2290,8 @@ nsHTMLInputElement::SaveState()
}
NS_IMETHODIMP
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)
nsHTMLInputElement::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
{
nsresult rv = NS_OK;
@ -2348,18 +2306,25 @@ nsHTMLInputElement::RestoreState(nsIPresState* aState)
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.
SetChecked(checked.Equals(NS_LITERAL_STRING("t")));
if (checked.Equals(NS_LITERAL_STRING("t"))) {
SetChecked(PR_TRUE);
} else {
SetChecked(PR_FALSE);
}
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("v"), value);
rv = aState->GetStateProperty(NS_LITERAL_STRING("value"), value);
NS_ASSERTION(NS_SUCCEEDED(rv), "value restore failed!");
SetValueGuaranteed(value, nsnull);
SetValue(value);
break;
}
}

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

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

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

@ -73,7 +73,6 @@
#include "nsIDOMText.h"
#include "nsReadableUtils.h"
#include "nsITextContent.h"
#include "nsITextAreaElement.h"
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
@ -81,8 +80,7 @@ static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
class nsHTMLTextAreaElement : public nsGenericHTMLContainerFormElement,
public nsIDOMHTMLTextAreaElement,
public nsIDOMNSHTMLTextAreaElement,
public nsITextControlElement,
public nsITextAreaElement
public nsITextControlElement
{
public:
nsHTMLTextAreaElement();
@ -106,16 +104,13 @@ 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();
NS_IMETHOD RestoreState(nsIPresState* aState);
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
// nsITextControlElement
NS_IMETHOD SetValueGuaranteed(const nsAString& aValue, nsIGfxTextControlFrame2* aFrame);
@ -202,7 +197,6 @@ 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
@ -795,14 +789,6 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
return rv;
}
// nsITextAreaElement
NS_IMETHODIMP
nsHTMLTextAreaElement::DoneAddingChildren()
{
RestoreFormControlState(this, this);
return NS_OK;
}
// nsIFormControl
NS_IMETHODIMP
@ -928,33 +914,30 @@ nsHTMLTextAreaElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
NS_IMETHODIMP
nsHTMLTextAreaElement::SaveState()
nsHTMLTextAreaElement::SaveState(nsIPresContext* aPresContext,
nsIPresState** aState)
{
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!");
}
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!");
}
return rv;
}
NS_IMETHODIMP
nsHTMLTextAreaElement::RestoreState(nsIPresState* aState)
nsHTMLTextAreaElement::RestoreState(nsIPresContext* aPresContext,
nsIPresState* aState)
{
nsresult rv = NS_OK;

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

@ -123,7 +123,6 @@
#include "nsIParserService.h"
#include "nsParserCIID.h"
#include "nsISelectElement.h"
#include "nsITextAreaElement.h"
#include "nsIPref.h"
@ -811,9 +810,8 @@ MakeContentObject(nsHTMLTag aNodeType,
nsIDOMHTMLFormElement* aForm,
nsIWebShell* aWebShell,
nsIHTMLContent** aResult,
const nsAString* aSkippedContent,
PRBool aInsideNoXXXTag,
PRBool aFromParser);
const nsAString* aSkippedContent = nsnull,
PRBool aInsideNoXXXTag = PR_FALSE);
/**
@ -860,8 +858,7 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
}
// Make the content object
rv = MakeContentObject(aNodeType, nodeInfo, aForm, aWebShell,
aResult, skippedContent, !!mInsideNoXXXTag,
PR_TRUE);
aResult, skippedContent, !!mInsideNoXXXTag);
PRInt32 id;
mDocument->GetAndIncrementContentID(&id);
@ -898,7 +895,7 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
if (aCaseSensitive) {
rv = MakeContentObject(nsHTMLTag(id), aNodeInfo, nsnull, nsnull,
aResult, nsnull, PR_FALSE, PR_FALSE);
aResult);
} else {
// Revese map id to name to get the correct character case in
// the tag name.
@ -925,8 +922,7 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
}
}
rv = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull, nsnull, aResult,
nsnull, PR_FALSE, PR_FALSE);
rv = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull, nsnull, aResult);
}
}
@ -998,8 +994,7 @@ MakeContentObject(nsHTMLTag aNodeType,
nsIWebShell* aWebShell,
nsIHTMLContent** aResult,
const nsAString* aSkippedContent,
PRBool aInsideNoXXXTag,
PRBool aFromParser)
PRBool aInsideNoXXXTag)
{
nsresult rv = NS_OK;
switch (aNodeType) {
@ -1110,7 +1105,7 @@ MakeContentObject(nsHTMLTag aNodeType,
rv = NS_NewHTMLImageElement(aResult, aNodeInfo);
break;
case eHTMLTag_input:
rv = NS_NewHTMLInputElement(aResult, aNodeInfo, aFromParser);
rv = NS_NewHTMLInputElement(aResult, aNodeInfo);
if (!aInsideNoXXXTag)
SetForm(*aResult, aForm);
break;
@ -1175,7 +1170,7 @@ MakeContentObject(nsHTMLTag aNodeType,
rv = NS_NewHTMLScriptElement(aResult, aNodeInfo);
break;
case eHTMLTag_select:
rv = NS_NewHTMLSelectElement(aResult, aNodeInfo, aFromParser);
rv = NS_NewHTMLSelectElement(aResult, aNodeInfo);
if (!aInsideNoXXXTag) {
SetForm(*aResult, aForm);
}
@ -1426,6 +1421,13 @@ 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;
@ -1605,8 +1607,9 @@ SinkContext::CloseContainer(const nsIParserNode& aNode)
case eHTMLTag_select:
{
nsCOMPtr<nsISelectElement> select = do_QueryInterface(content, &result);
if (select) {
result = select->DoneAddingChildren();
if (NS_SUCCEEDED(result)) {
result = select->DoneAddingContent(PR_TRUE);
}
}
break;
@ -1881,22 +1884,6 @@ 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;

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

@ -869,13 +869,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITextAreaElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIWyciwygChannel.idl</PATH>
@ -984,11 +977,6 @@
<PATH>nsISelectElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITextAreaElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIWyciwygChannel.idl</PATH>
@ -1822,13 +1810,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITextAreaElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIWyciwygChannel.idl</PATH>
@ -1937,11 +1918,6 @@
<PATH>nsISelectElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITextAreaElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIWyciwygChannel.idl</PATH>
@ -2069,12 +2045,6 @@
<PATH>nsISelectElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsITextAreaElement.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

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

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

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

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

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

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

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

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

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

@ -1872,6 +1872,7 @@ nsComboboxControlFrame::GetDropDown(nsIFrame** aDropDownFrame)
NS_IMETHODIMP
nsComboboxControlFrame::ToggleList(nsIPresContext* aPresContext)
{
ShowList(aPresContext, (PR_FALSE == mDroppedDown));
return NS_OK;
@ -1995,7 +1996,7 @@ nsComboboxControlFrame::GetIndexOfDisplayArea(PRInt32* aSelectedIndex)
// nsISelectControlFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
nsComboboxControlFrame::DoneAddingContent(PRBool aIsDone)
{
nsISelectControlFrame* listFrame = nsnull;
nsresult rv = NS_ERROR_FAILURE;
@ -2003,7 +2004,7 @@ nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->DoneAddingChildren(aIsDone);
rv = listFrame->DoneAddingContent(aIsDone);
NS_RELEASE(listFrame);
}
}
@ -2671,7 +2672,6 @@ 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,5 +2689,6 @@ 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 DoneAddingChildren(PRBool aIsDone);
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
PRInt32 aIndex,
PRBool aSelected);

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

@ -63,6 +63,7 @@
#include "nsIDOMMouseListener.h"
#include "nsIPresShell.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsIDOMWindowInternal.h"
@ -148,16 +149,10 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(rv)) {
mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE);
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);
if (nsFormFrame::GetDisabled(this)) {
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) {
textControl->SetDisabled(nsFormFrame::GetDisabled(this));
}
}
aChildList.AppendElement(mTextContent);
@ -204,6 +199,9 @@ 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);
}
@ -680,6 +678,54 @@ 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,6 +42,7 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIStatefulFrame.h"
#include "nsCOMPtr.h"
#include "nsIHTMLContent.h"
@ -56,7 +57,9 @@ class nsISupportsArray;
class nsFileControlFrame : public nsAreaFrame,
public nsIFormControlFrame,
public nsIDOMMouseListener,
public nsIAnonymousContentCreator
public nsIAnonymousContentCreator,
public nsIStatefulFrame
{
public:
nsFileControlFrame();
@ -180,6 +183,10 @@ 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,3 +892,37 @@ 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,6 +160,12 @@ 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,6 +466,8 @@ 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);
@ -649,3 +651,48 @@ 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,6 +43,7 @@
#include "nsCOMPtr.h"
#include "nsIAnonymousContentCreator.h"
#include "nsITextContent.h"
#include "nsIStatefulFrame.h"
#ifdef ACCESSIBILITY
class nsIAccessible;
@ -56,7 +57,8 @@ class nsIAccessible;
class nsIPresState;
class nsGfxButtonControlFrame : public nsHTMLButtonControlFrame,
public nsIAnonymousContentCreator
public nsIAnonymousContentCreator,
public nsIStatefulFrame
{
public:
nsGfxButtonControlFrame();
@ -115,6 +117,10 @@ 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,7 +96,10 @@ 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;
@ -272,6 +275,21 @@ 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,6 +38,7 @@
#define nsGfxCheckboxControlFrame_h___
#include "nsFormControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsICheckboxControlFrame.h"
#ifdef ACCESSIBILITY
@ -49,6 +50,7 @@ class nsIAccessible;
#define NS_GFX_CHECKBOX_CONTROL_FRAME_LAST_CONTEXT_INDEX 0
class nsGfxCheckboxControlFrame : public nsFormControlFrame,
public nsIStatefulFrame,
public nsICheckboxControlFrame//,
//public nsIAccessible
{
@ -88,7 +90,11 @@ 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,6 +94,10 @@ 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);
}
@ -253,6 +257,25 @@ 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,6 +39,7 @@
#define nsGfxRadioControlFrame_h___
#include "nsFormControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsIRadioControlFrame.h"
#ifdef ACCESSIBILITY
@ -51,6 +52,7 @@ class nsIAccessible;
#define NS_GFX_RADIO_CONTROL_FRAME_LAST_CONTEXT_INDEX 0
class nsGfxRadioControlFrame : public nsFormControlFrame,
public nsIStatefulFrame,
public nsIRadioControlFrame
{
@ -95,6 +97,10 @@ 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,10 +74,9 @@ public:
NS_IMETHOD GetOptionSelected(PRInt32 index, PRBool* value) = 0;
/**
* Sets whether the parser is done adding children
* @param aIsDone whether the parser is done adding children
* Sets the select state of the option at index
*/
NS_IMETHOD DoneAddingChildren(PRBool aIsDone) = 0;
NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0;
/**
* Notify the frame when an option is selected

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

@ -553,6 +553,10 @@ 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);
}
@ -1449,7 +1453,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->IsDoneAddingChildren(&mIsAllContentHere);
element->IsDoneAddingContent(&mIsAllContentHere);
if (!mIsAllContentHere) {
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
@ -1965,7 +1969,7 @@ PRBool nsListControlFrame::CheckIfAllFramesHere()
//-------------------------------------------------------------------
NS_IMETHODIMP
nsListControlFrame::DoneAddingChildren(PRBool aIsDone)
nsListControlFrame::DoneAddingContent(PRBool aIsDone)
{
mIsAllContentHere = aIsDone;
if (mIsAllContentHere) {
@ -1999,7 +2003,7 @@ nsListControlFrame::AddOption(nsIPresContext* aPresContext, PRInt32 aIndex)
if (!mIsAllContentHere) {
nsCOMPtr<nsISelectElement> element(do_QueryInterface(mContent));
if (element) {
element->IsDoneAddingChildren(&mIsAllContentHere);
element->IsDoneAddingContent(&mIsAllContentHere);
if (!mIsAllContentHere) {
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
@ -2771,8 +2775,15 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
if (NS_SUCCEEDED(mPresContext->GetEventStateManager(getter_AddRefs(stateManager)))) {
nsIFrame * frame;
stateManager->GetEventTarget(&frame);
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
if (listFrame) {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
} else {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
}
// This will consume the focus event we get from the clicking on the dropdown
//stateManager->ConsumeFocusEvents(PR_TRUE);
@ -3564,3 +3575,21 @@ 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,6 +58,7 @@
#include "nsIPresState.h"
#include "nsCWeakReference.h"
#include "nsIContent.h"
#include "nsIStatefulFrame.h"
class nsIDOMHTMLSelectElement;
class nsIDOMHTMLCollection;
@ -67,6 +68,7 @@ class nsIViewManager;
class nsIPresContext;
class nsVoidArray;
class nsIScrollableView;
class nsIStatefulFrame;
class nsListControlFrame;
class nsSelectUpdateTimer;
@ -281,7 +283,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 DoneAddingChildren(PRBool aIsDone);
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
PRInt32 aIndex,
PRBool aSelected);
@ -307,6 +309,10 @@ 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,7 +71,6 @@
#include "nsIContentList.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsPrintfCString.h"
#ifdef DEBUG
#undef NOISY_DEBUG
@ -367,7 +366,7 @@ public:
nsIStatefulFrame::SpecialStateID aID = nsIStatefulFrame::eNoID);
NS_IMETHOD GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
nsACString& aString);
nsCString& aString);
// Gets and sets properties on a given frame
NS_IMETHOD GetFrameProperty(nsIFrame* aFrame,
@ -2049,14 +2048,14 @@ FrameManager::RestoreFrameState(nsIPresContext* aPresContext, nsIFrame* aFrame,
}
static inline void KeyAppendSep(nsACString& aKey)
static inline void KeyAppendSep(nsCString& aKey)
{
if (!aKey.IsEmpty()) {
aKey.Append('>');
aKey.Append(">");
}
}
static inline void KeyAppendString(const nsAString& aString, nsACString& aKey)
static inline void KeyAppendString(const nsAString& aString, nsCString& aKey)
{
KeyAppendSep(aKey);
@ -2066,14 +2065,14 @@ static inline void KeyAppendString(const nsAString& aString, nsACString& aKey)
aKey.Append(NS_ConvertUCS2toUTF8(aString));
}
static inline void KeyAppendInt(PRInt32 aInt, nsACString& aKey)
static inline void KeyAppendInt(PRInt32 aInt, nsCString& aKey)
{
KeyAppendSep(aKey);
aKey.Append(nsPrintfCString("%d", aInt));
aKey.AppendInt(aInt);
}
static inline void KeyAppendAtom(nsIAtom* aAtom, nsACString& aKey)
static inline void KeyAppendAtom(nsIAtom* aAtom, nsCString& aKey)
{
NS_PRECONDITION(aAtom, "KeyAppendAtom: aAtom can not be null!\n");
@ -2094,7 +2093,7 @@ static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
NS_IMETHODIMP
FrameManager::GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
nsACString& aKey)
nsCString& aKey)
{
aKey.Truncate();

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

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

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

@ -1872,6 +1872,7 @@ nsComboboxControlFrame::GetDropDown(nsIFrame** aDropDownFrame)
NS_IMETHODIMP
nsComboboxControlFrame::ToggleList(nsIPresContext* aPresContext)
{
ShowList(aPresContext, (PR_FALSE == mDroppedDown));
return NS_OK;
@ -1995,7 +1996,7 @@ nsComboboxControlFrame::GetIndexOfDisplayArea(PRInt32* aSelectedIndex)
// nsISelectControlFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
nsComboboxControlFrame::DoneAddingContent(PRBool aIsDone)
{
nsISelectControlFrame* listFrame = nsnull;
nsresult rv = NS_ERROR_FAILURE;
@ -2003,7 +2004,7 @@ nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone)
rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->DoneAddingChildren(aIsDone);
rv = listFrame->DoneAddingContent(aIsDone);
NS_RELEASE(listFrame);
}
}
@ -2671,7 +2672,6 @@ 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,5 +2689,6 @@ 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 DoneAddingChildren(PRBool aIsDone);
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
PRInt32 aIndex,
PRBool aSelected);

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

@ -63,6 +63,7 @@
#include "nsIDOMMouseListener.h"
#include "nsIPresShell.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsIDOMWindowInternal.h"
@ -148,16 +149,10 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(rv)) {
mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE);
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);
if (nsFormFrame::GetDisabled(this)) {
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) {
textControl->SetDisabled(nsFormFrame::GetDisabled(this));
}
}
aChildList.AppendElement(mTextContent);
@ -204,6 +199,9 @@ 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);
}
@ -680,6 +678,54 @@ 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,6 +42,7 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIStatefulFrame.h"
#include "nsCOMPtr.h"
#include "nsIHTMLContent.h"
@ -56,7 +57,9 @@ class nsISupportsArray;
class nsFileControlFrame : public nsAreaFrame,
public nsIFormControlFrame,
public nsIDOMMouseListener,
public nsIAnonymousContentCreator
public nsIAnonymousContentCreator,
public nsIStatefulFrame
{
public:
nsFileControlFrame();
@ -180,6 +183,10 @@ 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,3 +892,37 @@ 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,6 +160,12 @@ 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,6 +466,8 @@ 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);
@ -649,3 +651,48 @@ 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,6 +43,7 @@
#include "nsCOMPtr.h"
#include "nsIAnonymousContentCreator.h"
#include "nsITextContent.h"
#include "nsIStatefulFrame.h"
#ifdef ACCESSIBILITY
class nsIAccessible;
@ -56,7 +57,8 @@ class nsIAccessible;
class nsIPresState;
class nsGfxButtonControlFrame : public nsHTMLButtonControlFrame,
public nsIAnonymousContentCreator
public nsIAnonymousContentCreator,
public nsIStatefulFrame
{
public:
nsGfxButtonControlFrame();
@ -115,6 +117,10 @@ 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,7 +96,10 @@ 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;
@ -272,6 +275,21 @@ 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,6 +38,7 @@
#define nsGfxCheckboxControlFrame_h___
#include "nsFormControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsICheckboxControlFrame.h"
#ifdef ACCESSIBILITY
@ -49,6 +50,7 @@ class nsIAccessible;
#define NS_GFX_CHECKBOX_CONTROL_FRAME_LAST_CONTEXT_INDEX 0
class nsGfxCheckboxControlFrame : public nsFormControlFrame,
public nsIStatefulFrame,
public nsICheckboxControlFrame//,
//public nsIAccessible
{
@ -88,7 +90,11 @@ 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,6 +94,10 @@ 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);
}
@ -253,6 +257,25 @@ 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,6 +39,7 @@
#define nsGfxRadioControlFrame_h___
#include "nsFormControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsIRadioControlFrame.h"
#ifdef ACCESSIBILITY
@ -51,6 +52,7 @@ class nsIAccessible;
#define NS_GFX_RADIO_CONTROL_FRAME_LAST_CONTEXT_INDEX 0
class nsGfxRadioControlFrame : public nsFormControlFrame,
public nsIStatefulFrame,
public nsIRadioControlFrame
{
@ -95,6 +97,10 @@ 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,6 +1329,10 @@ 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;
@ -3401,6 +3405,21 @@ 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,6 +43,7 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIStatefulFrame.h"
#include "nsIEditor.h"
#include "nsIGfxTextControlFrame.h"
#include "nsFormControlHelper.h"//for the inputdimensions
@ -69,6 +70,7 @@ class nsIAccessible;
class nsGfxTextControlFrame2 : public nsStackFrame,
public nsIAnonymousContentCreator,
public nsIGfxTextControlFrame2,
public nsIStatefulFrame,
public nsIScrollableViewProvider
{
@ -229,6 +231,10 @@ 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,6 +553,10 @@ 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);
}
@ -1449,7 +1453,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->IsDoneAddingChildren(&mIsAllContentHere);
element->IsDoneAddingContent(&mIsAllContentHere);
if (!mIsAllContentHere) {
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
@ -1965,7 +1969,7 @@ PRBool nsListControlFrame::CheckIfAllFramesHere()
//-------------------------------------------------------------------
NS_IMETHODIMP
nsListControlFrame::DoneAddingChildren(PRBool aIsDone)
nsListControlFrame::DoneAddingContent(PRBool aIsDone)
{
mIsAllContentHere = aIsDone;
if (mIsAllContentHere) {
@ -1999,7 +2003,7 @@ nsListControlFrame::AddOption(nsIPresContext* aPresContext, PRInt32 aIndex)
if (!mIsAllContentHere) {
nsCOMPtr<nsISelectElement> element(do_QueryInterface(mContent));
if (element) {
element->IsDoneAddingChildren(&mIsAllContentHere);
element->IsDoneAddingContent(&mIsAllContentHere);
if (!mIsAllContentHere) {
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
@ -2771,8 +2775,15 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
if (NS_SUCCEEDED(mPresContext->GetEventStateManager(getter_AddRefs(stateManager)))) {
nsIFrame * frame;
stateManager->GetEventTarget(&frame);
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
if (listFrame) {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
} else {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
}
// This will consume the focus event we get from the clicking on the dropdown
//stateManager->ConsumeFocusEvents(PR_TRUE);
@ -3564,3 +3575,21 @@ 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,6 +58,7 @@
#include "nsIPresState.h"
#include "nsCWeakReference.h"
#include "nsIContent.h"
#include "nsIStatefulFrame.h"
class nsIDOMHTMLSelectElement;
class nsIDOMHTMLCollection;
@ -67,6 +68,7 @@ class nsIViewManager;
class nsIPresContext;
class nsVoidArray;
class nsIScrollableView;
class nsIStatefulFrame;
class nsListControlFrame;
class nsSelectUpdateTimer;
@ -281,7 +283,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 DoneAddingChildren(PRBool aIsDone);
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
PRInt32 aIndex,
PRBool aSelected);
@ -307,6 +309,10 @@ 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);