2002-07-26 17:17:00 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2002-07-26 17:17:00 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
2002-07-26 17:17:00 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2002-07-26 17:17:00 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of 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"),
|
2002-07-26 17:17:00 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2002-07-26 17:17:00 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2002-07-26 17:17:00 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2002-07-26 20:57:24 +00:00
|
|
|
#ifndef nsTextControlFrame_h___
|
|
|
|
#define nsTextControlFrame_h___
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
#include "nsStackFrame.h"
|
2008-12-29 15:07:38 +00:00
|
|
|
#include "nsBlockFrame.h"
|
2002-07-26 17:17:00 +00:00
|
|
|
#include "nsIFormControlFrame.h"
|
|
|
|
#include "nsIAnonymousContentCreator.h"
|
2002-07-26 20:57:24 +00:00
|
|
|
#include "nsITextControlFrame.h"
|
2006-09-19 04:26:20 +00:00
|
|
|
#include "nsDisplayList.h"
|
2009-09-01 11:22:31 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2010-02-07 19:44:32 +00:00
|
|
|
#include "nsStubMutationObserver.h"
|
2010-04-21 20:17:41 +00:00
|
|
|
#include "nsITextControlElement.h"
|
2011-02-04 23:28:38 +00:00
|
|
|
#include "nsIStatefulFrame.h"
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
class nsIEditor;
|
|
|
|
class nsISelectionController;
|
|
|
|
class nsIDOMCharacterData;
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
class nsIAccessible;
|
|
|
|
#endif
|
2010-02-10 01:29:11 +00:00
|
|
|
class EditorInitializerEntryTracker;
|
2010-04-21 20:17:41 +00:00
|
|
|
class nsTextEditorState;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2002-07-26 20:57:24 +00:00
|
|
|
class nsTextControlFrame : public nsStackFrame,
|
2002-09-16 06:23:52 +00:00
|
|
|
public nsIAnonymousContentCreator,
|
2011-02-04 23:28:38 +00:00
|
|
|
public nsITextControlFrame,
|
|
|
|
public nsIStatefulFrame
|
2002-07-26 17:17:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2011-02-04 23:28:38 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(ContentScrollPos, DestroyPoint)
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsTextControlFrame(nsIPresShell* aShell, nsStyleContext* aContext);
|
2002-07-26 20:57:24 +00:00
|
|
|
virtual ~nsTextControlFrame();
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2009-12-24 05:21:15 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2009-09-01 11:22:31 +00:00
|
|
|
virtual nsIScrollableFrame* GetScrollTargetFrame() {
|
|
|
|
if (!IsScrollable())
|
|
|
|
return nsnull;
|
|
|
|
return do_QueryFrame(GetFirstChild(nsnull));
|
|
|
|
}
|
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext);
|
|
|
|
virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2007-08-22 03:07:25 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
|
|
|
nsSize aPadding, PRBool aShrinkWrap);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
2002-07-26 17:17:00 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState);
|
2007-01-31 16:02:42 +00:00
|
|
|
virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual PRBool IsCollapsed(nsBoxLayoutState& aBoxLayoutState);
|
2005-08-16 22:52:48 +00:00
|
|
|
|
2006-09-19 04:26:20 +00:00
|
|
|
DECL_DO_GLOBAL_REFLOW_COUNT_DSP(nsTextControlFrame, nsStackFrame)
|
|
|
|
|
2005-08-16 22:52:48 +00:00
|
|
|
virtual PRBool IsLeaf() const;
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
virtual already_AddRefed<nsAccessible> CreateAccessible();
|
2002-07-26 17:17:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
2004-06-17 00:13:25 +00:00
|
|
|
aResult.AssignLiteral("nsTextControlFrame");
|
2002-07-26 17:17:00 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-02-24 18:33:33 +00:00
|
|
|
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
|
|
|
|
{
|
|
|
|
// nsStackFrame is already both of these, but that's somewhat bogus,
|
|
|
|
// and we really mean it.
|
|
|
|
return nsStackFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
// nsIAnonymousContentCreator
|
2011-05-06 20:04:44 +00:00
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
|
2010-10-15 15:34:35 +00:00
|
|
|
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
|
|
|
PRUint32 aFilter);
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
// Utility methods to set current widget state
|
2007-03-19 10:23:29 +00:00
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList);
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
//==== BEGIN NSIFORMCONTROLFRAME
|
|
|
|
virtual void SetFocus(PRBool aOn , PRBool aRepaint);
|
2005-12-12 23:53:06 +00:00
|
|
|
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue);
|
|
|
|
virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==== END NSIFORMCONTROLFRAME
|
|
|
|
|
2009-01-29 19:46:17 +00:00
|
|
|
//==== NSITEXTCONTROLFRAME
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
NS_IMETHOD GetEditor(nsIEditor **aEditor);
|
|
|
|
NS_IMETHOD GetTextLength(PRInt32* aTextLength);
|
|
|
|
NS_IMETHOD CheckFireOnChange();
|
|
|
|
NS_IMETHOD SetSelectionStart(PRInt32 aSelectionStart);
|
|
|
|
NS_IMETHOD SetSelectionEnd(PRInt32 aSelectionEnd);
|
|
|
|
NS_IMETHOD SetSelectionRange(PRInt32 aSelectionStart, PRInt32 aSelectionEnd);
|
|
|
|
NS_IMETHOD GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd);
|
2010-04-21 20:17:41 +00:00
|
|
|
NS_IMETHOD GetOwnedSelectionController(nsISelectionController** aSelCon);
|
|
|
|
virtual nsFrameSelection* GetOwnedFrameSelection();
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2008-10-28 00:27:55 +00:00
|
|
|
nsresult GetPhonetic(nsAString& aPhonetic);
|
2002-12-17 23:38:04 +00:00
|
|
|
|
2010-02-02 04:00:06 +00:00
|
|
|
/**
|
|
|
|
* Ensure mEditor is initialized with the proper flags and the default value.
|
|
|
|
* @throws NS_ERROR_NOT_INITIALIZED if mEditor has not been created
|
|
|
|
* @throws various and sundry other things
|
|
|
|
*/
|
|
|
|
virtual nsresult EnsureEditorInitialized();
|
|
|
|
|
2009-01-29 19:46:17 +00:00
|
|
|
//==== END NSITEXTCONTROLFRAME
|
2011-02-04 23:28:38 +00:00
|
|
|
|
|
|
|
//==== NSISTATEFULFRAME
|
|
|
|
|
|
|
|
NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState);
|
|
|
|
NS_IMETHOD RestoreState(nsPresState* aState);
|
|
|
|
|
|
|
|
//=== END NSISTATEFULFRAME
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
//==== OVERLOAD of nsIFrame
|
2003-10-31 20:19:18 +00:00
|
|
|
virtual nsIAtom* GetType() const;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
/** handler for attribute changes to mContent */
|
2005-09-07 16:49:21 +00:00
|
|
|
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
|
2002-07-26 17:17:00 +00:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-11 21:16:12 +00:00
|
|
|
PRInt32 aModType);
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2010-02-07 19:44:32 +00:00
|
|
|
nsresult GetText(nsString& aText);
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2002-07-26 20:57:24 +00:00
|
|
|
public: //for methods who access nsTextControlFrame directly
|
2010-12-07 06:30:05 +00:00
|
|
|
void FireOnInput(PRBool aTrusted);
|
2002-07-26 17:17:00 +00:00
|
|
|
void SetValueChanged(PRBool aValueChanged);
|
|
|
|
/** Called when the frame is focused, to remember the value for onChange. */
|
|
|
|
nsresult InitFocusedValue();
|
|
|
|
|
2007-01-05 16:31:07 +00:00
|
|
|
void SetFireChangeEventState(PRBool aNewState)
|
2006-07-05 22:15:01 +00:00
|
|
|
{
|
2007-01-05 16:31:07 +00:00
|
|
|
mFireChangeEventState = aNewState;
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2006-07-05 22:15:01 +00:00
|
|
|
|
2007-01-05 16:31:07 +00:00
|
|
|
PRBool GetFireChangeEventState() const
|
2006-10-15 15:39:35 +00:00
|
|
|
{
|
2007-01-05 16:31:07 +00:00
|
|
|
return mFireChangeEventState;
|
2006-10-15 15:39:35 +00:00
|
|
|
}
|
|
|
|
|
2007-09-27 16:01:32 +00:00
|
|
|
// called by the focus listener
|
|
|
|
nsresult MaybeBeginSecureKeyboardInput();
|
|
|
|
void MaybeEndSecureKeyboardInput();
|
|
|
|
|
2010-04-21 20:17:41 +00:00
|
|
|
class ValueSetter {
|
|
|
|
public:
|
|
|
|
ValueSetter(nsTextControlFrame* aFrame,
|
|
|
|
PRBool aHasFocusValue)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
// This method isn't used for user-generated changes, except for calls
|
|
|
|
// from nsFileControlFrame which sets mFireChangeEventState==true and
|
|
|
|
// restores it afterwards (ie. we want 'change' events for those changes).
|
|
|
|
// Focused value must be updated to prevent incorrect 'change' events,
|
|
|
|
// but only if user hasn't changed the value.
|
2011-04-14 12:04:12 +00:00
|
|
|
, mFocusValueInit(!mFrame->mFireChangeEventState && aHasFocusValue)
|
|
|
|
, mOuterTransaction(false)
|
|
|
|
, mInited(false)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFrame, "Should pass a valid frame");
|
2010-04-21 20:17:41 +00:00
|
|
|
}
|
|
|
|
void Cancel() {
|
|
|
|
mInited = PR_FALSE;
|
|
|
|
}
|
|
|
|
void Init() {
|
|
|
|
// Since this code does not handle user-generated changes to the text,
|
|
|
|
// make sure we don't fire oninput when the editor notifies us.
|
|
|
|
// (mNotifyOnInput must be reset before we return).
|
|
|
|
|
|
|
|
// To protect against a reentrant call to SetValue, we check whether
|
|
|
|
// another SetValue is already happening for this frame. If it is,
|
|
|
|
// we must wait until we unwind to re-enable oninput events.
|
|
|
|
mOuterTransaction = mFrame->mNotifyOnInput;
|
|
|
|
if (mOuterTransaction)
|
|
|
|
mFrame->mNotifyOnInput = PR_FALSE;
|
|
|
|
|
|
|
|
mInited = PR_TRUE;
|
|
|
|
}
|
|
|
|
~ValueSetter() {
|
|
|
|
if (!mInited)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (mOuterTransaction)
|
|
|
|
mFrame->mNotifyOnInput = PR_TRUE;
|
|
|
|
|
|
|
|
if (mFocusValueInit) {
|
|
|
|
// Reset mFocusedValue so the onchange event doesn't fire incorrectly.
|
|
|
|
mFrame->InitFocusedValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsTextControlFrame* mFrame;
|
|
|
|
PRPackedBool mFocusValueInit;
|
|
|
|
PRPackedBool mOuterTransaction;
|
|
|
|
PRPackedBool mInited;
|
|
|
|
};
|
|
|
|
friend class ValueSetter;
|
|
|
|
|
|
|
|
#define DEFINE_TEXTCTRL_FORWARDER(type, name) \
|
|
|
|
type name() { \
|
|
|
|
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent()); \
|
|
|
|
NS_ASSERTION(txtCtrl, "Content not a text control element"); \
|
|
|
|
return txtCtrl->name(); \
|
|
|
|
}
|
|
|
|
#define DEFINE_TEXTCTRL_CONST_FORWARDER(type, name) \
|
|
|
|
type name() const { \
|
|
|
|
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent()); \
|
|
|
|
NS_ASSERTION(txtCtrl, "Content not a text control element"); \
|
|
|
|
return txtCtrl->name(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(PRBool, IsSingleLineTextControl)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(PRBool, IsTextArea)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(PRBool, IsPlainTextControl)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(PRBool, IsPasswordTextControl)
|
|
|
|
DEFINE_TEXTCTRL_FORWARDER(PRInt32, GetCols)
|
|
|
|
DEFINE_TEXTCTRL_FORWARDER(PRInt32, GetWrapCols)
|
|
|
|
DEFINE_TEXTCTRL_FORWARDER(PRInt32, GetRows)
|
|
|
|
|
|
|
|
#undef DEFINE_TEXTCTRL_CONST_FORWARDER
|
|
|
|
#undef DEFINE_TEXTCTRL_FORWARDER
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
protected:
|
2009-01-29 19:46:17 +00:00
|
|
|
class EditorInitializer;
|
|
|
|
friend class EditorInitializer;
|
2010-04-21 20:17:41 +00:00
|
|
|
friend class nsTextEditorState; // needs access to UpdateValueDisplay
|
2009-01-29 19:46:17 +00:00
|
|
|
|
|
|
|
class EditorInitializer : public nsRunnable {
|
|
|
|
public:
|
|
|
|
EditorInitializer(nsTextControlFrame* aFrame) :
|
|
|
|
mWeakFrame(aFrame),
|
|
|
|
mFrame(aFrame) {}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() {
|
|
|
|
if (mWeakFrame) {
|
2009-04-22 09:35:45 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell =
|
|
|
|
mWeakFrame.GetFrame()->PresContext()->GetPresShell();
|
|
|
|
PRBool observes = shell->ObservesNativeAnonMutationsForPrint();
|
|
|
|
shell->ObserveNativeAnonMutationsForPrint(PR_TRUE);
|
2010-04-21 20:17:41 +00:00
|
|
|
mFrame->EnsureEditorInitialized();
|
2009-04-22 09:35:45 +00:00
|
|
|
shell->ObserveNativeAnonMutationsForPrint(observes);
|
2009-01-29 19:46:17 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsWeakFrame mWeakFrame;
|
|
|
|
nsTextControlFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
2010-05-06 22:12:21 +00:00
|
|
|
class ScrollOnFocusEvent;
|
|
|
|
friend class ScrollOnFocusEvent;
|
|
|
|
|
|
|
|
class ScrollOnFocusEvent : public nsRunnable {
|
|
|
|
public:
|
|
|
|
ScrollOnFocusEvent(nsTextControlFrame* aFrame) :
|
|
|
|
mFrame(aFrame) {}
|
|
|
|
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
|
|
|
void Revoke() {
|
|
|
|
mFrame = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsTextControlFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
2009-01-29 19:46:17 +00:00
|
|
|
nsresult DOMPointToOffset(nsIDOMNode* aNode, PRInt32 aNodeOffset, PRInt32 *aResult);
|
|
|
|
nsresult OffsetToDOMPoint(PRInt32 aOffset, nsIDOMNode** aResult, PRInt32* aPosition);
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
/**
|
|
|
|
* Find out whether this control is scrollable (i.e. if it is not a single
|
|
|
|
* line text control)
|
|
|
|
* @return whether this control is scrollable
|
|
|
|
*/
|
|
|
|
PRBool IsScrollable() const;
|
2010-02-02 15:49:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the textnode under our anonymous div to show the new
|
|
|
|
* value. This should only be called when we have no editor yet.
|
|
|
|
* @throws NS_ERROR_UNEXPECTED if the div has no text content
|
|
|
|
*/
|
|
|
|
nsresult UpdateValueDisplay(PRBool aNotify,
|
|
|
|
PRBool aBeforeEditorInit = PR_FALSE,
|
|
|
|
const nsAString *aValue = nsnull);
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
/**
|
|
|
|
* Get the maxlength attribute
|
|
|
|
* @param aMaxLength the value of the max length attr
|
2005-10-28 11:25:24 +00:00
|
|
|
* @returns PR_FALSE if attr not defined
|
2002-07-26 17:17:00 +00:00
|
|
|
*/
|
2005-10-28 11:25:24 +00:00
|
|
|
PRBool GetMaxLength(PRInt32* aMaxLength);
|
2010-02-02 15:49:55 +00:00
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
/**
|
|
|
|
* Find out whether an attribute exists on the content or not.
|
|
|
|
* @param aAtt the attribute to determine the existence of
|
2005-01-12 19:45:38 +00:00
|
|
|
* @returns PR_FALSE if it does not exist
|
2002-07-26 17:17:00 +00:00
|
|
|
*/
|
2005-01-12 19:45:38 +00:00
|
|
|
PRBool AttributeExists(nsIAtom *aAtt) const
|
|
|
|
{ return mContent && mContent->HasAttr(kNameSpaceID_None, aAtt); }
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
/**
|
|
|
|
* We call this when we are being destroyed or removed from the PFM.
|
|
|
|
* @param aPresContext the current pres context
|
|
|
|
*/
|
2006-04-10 00:16:29 +00:00
|
|
|
void PreDestroy();
|
2002-09-16 06:23:52 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Compute our intrinsic size. This does not include any borders, paddings,
|
|
|
|
// etc. Just the size of our actual area for the text (and the scrollbars,
|
|
|
|
// for <textarea>).
|
2011-04-08 01:04:40 +00:00
|
|
|
nsresult CalcIntrinsicSize(nsRenderingContext* aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize& aIntrinsicSize);
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2011-02-05 00:29:29 +00:00
|
|
|
nsresult ScrollSelectionIntoView();
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
private:
|
|
|
|
//helper methods
|
2003-01-21 15:17:32 +00:00
|
|
|
nsresult SetSelectionInternal(nsIDOMNode *aStartNode, PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode, PRInt32 aEndOffset);
|
2010-02-07 19:44:32 +00:00
|
|
|
nsresult SelectAllOrCollapseToEndOfText(PRBool aSelect);
|
2002-07-26 17:17:00 +00:00
|
|
|
nsresult SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd);
|
2010-02-26 18:47:38 +00:00
|
|
|
|
2010-04-21 20:17:41 +00:00
|
|
|
// accessors for the notify on input flag
|
|
|
|
PRBool GetNotifyOnInput() const { return mNotifyOnInput; }
|
|
|
|
void SetNotifyOnInput(PRBool val) { mNotifyOnInput = val; }
|
2010-02-26 18:47:38 +00:00
|
|
|
|
2010-04-21 20:17:41 +00:00
|
|
|
/**
|
|
|
|
* Return the root DOM element, and implicitly initialize the editor if needed.
|
|
|
|
*/
|
|
|
|
nsresult GetRootNodeAndInitializeEditor(nsIDOMElement **aRootElement);
|
2010-04-06 20:44:46 +00:00
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
private:
|
|
|
|
// these packed bools could instead use the high order bits on mState, saving 4 bytes
|
|
|
|
PRPackedBool mUseEditor;
|
|
|
|
PRPackedBool mIsProcessing;
|
|
|
|
PRPackedBool mNotifyOnInput;//default this to off to stop any notifications until setup is complete
|
2007-01-05 16:31:07 +00:00
|
|
|
// Calls to SetValue will be treated as user values (i.e. trigger onChange
|
|
|
|
// eventually) when mFireChangeEventState==true, this is used by nsFileControlFrame.
|
|
|
|
PRPackedBool mFireChangeEventState;
|
2010-10-19 13:11:07 +00:00
|
|
|
// Keep track if we have asked a placeholder node creation.
|
|
|
|
PRPackedBool mUsePlaceholder;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2010-02-10 01:29:11 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRPackedBool mInEditorInitialization;
|
|
|
|
friend class EditorInitializerEntryTracker;
|
|
|
|
#endif
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
nsString mFocusedValue;
|
2010-05-06 22:12:21 +00:00
|
|
|
nsRevocableEventPtr<ScrollOnFocusEvent> mScrollEvent;
|
2002-07-26 17:17:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|