2002-07-26 17:17:00 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2002-07-26 20:57:24 +00:00
|
|
|
#ifndef nsTextControlFrame_h___
|
|
|
|
#define nsTextControlFrame_h___
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-06-23 11:11:00 +00:00
|
|
|
#include "nsContainerFrame.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"
|
2011-08-11 13:29:50 +00:00
|
|
|
#include "nsContentUtils.h" // nsAutoScriptBlocker
|
2012-03-27 01:36:44 +00:00
|
|
|
#include "nsIEditor.h"
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
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;
|
2012-06-10 23:44:50 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
}
|
|
|
|
}
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2012-06-23 11:11:00 +00:00
|
|
|
class nsTextControlFrame : public nsContainerFrame,
|
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
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2009-09-01 11:22:31 +00:00
|
|
|
virtual nsIScrollableFrame* GetScrollTargetFrame() {
|
|
|
|
if (!IsScrollable())
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-08-24 20:54:30 +00:00
|
|
|
return do_QueryFrame(GetFirstPrincipalChild());
|
2009-09-01 11:22:31 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext);
|
2012-06-23 11:11:00 +00:00
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext);
|
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2007-08-22 03:07:25 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
|
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 GetMinSize(nsBoxLayoutState& aBoxLayoutState);
|
2011-06-15 21:03:49 +00:00
|
|
|
virtual bool IsCollapsed();
|
2005-08-16 22:52:48 +00:00
|
|
|
|
2012-06-23 11:11:00 +00:00
|
|
|
DECL_DO_GLOBAL_REFLOW_COUNT_DSP(nsTextControlFrame, nsContainerFrame)
|
2006-09-19 04:26:20 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool IsLeaf() const;
|
2005-08-16 22:52:48 +00:00
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-05-29 01:18:45 +00:00
|
|
|
virtual already_AddRefed<Accessible> CreateAccessible();
|
2002-07-26 17:17:00 +00:00
|
|
|
#endif
|
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2002-07-26 17:17:00 +00:00
|
|
|
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
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const
|
2007-02-24 18:33:33 +00:00
|
|
|
{
|
|
|
|
// nsStackFrame is already both of these, but that's somewhat bogus,
|
|
|
|
// and we really mean it.
|
2012-06-23 11:11:00 +00:00
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
2007-02-24 18:33:33 +00:00
|
|
|
~(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
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
|
2010-10-15 15:34:35 +00:00
|
|
|
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-09-14 16:10:08 +00:00
|
|
|
uint32_t aFilter) MOZ_OVERRIDE;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
// Utility methods to set current widget state
|
2007-03-19 10:23:29 +00:00
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD SetInitialChildList(ChildListID aListID,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsFrameList& aChildList) MOZ_OVERRIDE;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
|
|
|
//==== BEGIN NSIFORMCONTROLFRAME
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual void SetFocus(bool aOn , bool 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
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
NS_IMETHOD GetEditor(nsIEditor **aEditor) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetTextLength(int32_t* aTextLength) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetSelectionStart(int32_t aSelectionStart) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetSelectionEnd(int32_t aSelectionEnd) MOZ_OVERRIDE;
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD SetSelectionRange(int32_t aSelectionStart,
|
|
|
|
int32_t aSelectionEnd,
|
2012-09-14 16:10:08 +00:00
|
|
|
SelectionDirection aDirection = eNone) MOZ_OVERRIDE;
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetSelectionRange(int32_t* aSelectionStart,
|
|
|
|
int32_t* aSelectionEnd,
|
2012-09-14 16:10:08 +00:00
|
|
|
SelectionDirection* aDirection = nullptr) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetOwnedSelectionController(nsISelectionController** aSelCon) MOZ_OVERRIDE;
|
|
|
|
virtual nsFrameSelection* GetOwnedFrameSelection() MOZ_OVERRIDE;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
nsresult GetPhonetic(nsAString& aPhonetic) MOZ_OVERRIDE;
|
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
|
|
|
|
*/
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual nsresult EnsureEditorInitialized() MOZ_OVERRIDE;
|
2010-02-02 04:00:06 +00:00
|
|
|
|
2009-01-29 19:46:17 +00:00
|
|
|
//==== END NSITEXTCONTROLFRAME
|
2011-02-04 23:28:38 +00:00
|
|
|
|
|
|
|
//==== NSISTATEFULFRAME
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD RestoreState(nsPresState* aState) MOZ_OVERRIDE;
|
2011-02-04 23:28:38 +00:00
|
|
|
|
|
|
|
//=== 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 */
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2002-07-26 17:17:00 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t 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
|
|
|
|
2012-06-19 23:31:03 +00:00
|
|
|
NS_IMETHOD PeekOffset(nsPeekOffsetStruct *aPos);
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2011-05-21 08:25:27 +00:00
|
|
|
// Temp reference to scriptrunner
|
|
|
|
// We could make these auto-Revoking via the "delete" entry for safety
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(TextControlInitializer, nullptr)
|
2011-05-21 08:25:27 +00:00
|
|
|
|
2012-06-23 11:11:00 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Launch the reflow on the child frames - see nsTextControlFrame::Reflow()
|
|
|
|
*/
|
|
|
|
void ReflowTextControlChild(nsIFrame* aFrame,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsHTMLReflowMetrics& aParentDesiredSize);
|
2011-05-21 08:25:27 +00:00
|
|
|
|
2002-07-26 20:57:24 +00:00
|
|
|
public: //for methods who access nsTextControlFrame directly
|
2011-09-29 06:19:26 +00:00
|
|
|
void SetValueChanged(bool aValueChanged);
|
2012-05-07 16:27:24 +00:00
|
|
|
|
2007-09-27 16:01:32 +00:00
|
|
|
// called by the focus listener
|
|
|
|
nsresult MaybeBeginSecureKeyboardInput();
|
|
|
|
void MaybeEndSecureKeyboardInput();
|
|
|
|
|
2012-03-27 01:36:44 +00:00
|
|
|
NS_STACK_CLASS class ValueSetter {
|
2010-04-21 20:17:41 +00:00
|
|
|
public:
|
2012-07-15 04:18:01 +00:00
|
|
|
ValueSetter(nsIEditor* aEditor)
|
|
|
|
: mEditor(aEditor)
|
2012-03-27 01:36:44 +00:00
|
|
|
, mCanceled(false)
|
2011-04-14 12:04:12 +00:00
|
|
|
{
|
2012-03-27 01:36:44 +00:00
|
|
|
MOZ_ASSERT(aEditor);
|
2010-04-21 20:17:41 +00:00
|
|
|
|
|
|
|
// 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.
|
2012-03-27 01:36:44 +00:00
|
|
|
mEditor->GetSuppressDispatchingInputEvent(&mOuterTransaction);
|
|
|
|
}
|
|
|
|
void Cancel() {
|
|
|
|
mCanceled = true;
|
|
|
|
}
|
|
|
|
void Init() {
|
|
|
|
mEditor->SetSuppressDispatchingInputEvent(true);
|
2010-04-21 20:17:41 +00:00
|
|
|
}
|
|
|
|
~ValueSetter() {
|
2012-03-27 01:36:44 +00:00
|
|
|
mEditor->SetSuppressDispatchingInputEvent(mOuterTransaction);
|
2010-04-21 20:17:41 +00:00
|
|
|
|
2012-03-27 01:36:44 +00:00
|
|
|
if (mCanceled) {
|
|
|
|
return;
|
|
|
|
}
|
2010-04-21 20:17:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-03-27 01:36:44 +00:00
|
|
|
nsCOMPtr<nsIEditor> mEditor;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mOuterTransaction;
|
2012-03-27 01:36:44 +00:00
|
|
|
bool mCanceled;
|
2010-04-21 20:17:41 +00:00
|
|
|
};
|
|
|
|
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(); \
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsSingleLineTextControl)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsTextArea)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsPlainTextControl)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsPasswordTextControl)
|
2012-08-22 15:56:38 +00:00
|
|
|
DEFINE_TEXTCTRL_FORWARDER(int32_t, GetCols)
|
|
|
|
DEFINE_TEXTCTRL_FORWARDER(int32_t, GetWrapCols)
|
|
|
|
DEFINE_TEXTCTRL_FORWARDER(int32_t, GetRows)
|
2010-04-21 20:17:41 +00:00
|
|
|
|
|
|
|
#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) :
|
|
|
|
mFrame(aFrame) {}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() {
|
2011-05-21 08:25:27 +00:00
|
|
|
if (mFrame) {
|
2011-07-13 20:57:41 +00:00
|
|
|
// need to block script to avoid bug 669767
|
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
|
|
|
|
2009-04-22 09:35:45 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell =
|
2011-05-21 08:25:27 +00:00
|
|
|
mFrame->PresContext()->GetPresShell();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool observes = shell->ObservesNativeAnonMutationsForPrint();
|
2011-10-17 14:59:28 +00:00
|
|
|
shell->ObserveNativeAnonMutationsForPrint(true);
|
2011-09-20 03:14:47 +00:00
|
|
|
// This can cause the frame to be destroyed (and call Revoke())
|
2010-04-21 20:17:41 +00:00
|
|
|
mFrame->EnsureEditorInitialized();
|
2009-04-22 09:35:45 +00:00
|
|
|
shell->ObserveNativeAnonMutationsForPrint(observes);
|
2011-07-13 20:57:41 +00:00
|
|
|
|
2011-09-20 03:14:47 +00:00
|
|
|
// The frame can *still* be destroyed even though we have a scriptblocker
|
|
|
|
// Bug 682684
|
|
|
|
if (!mFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-05-21 08:25:27 +00:00
|
|
|
mFrame->FinishedInitializer();
|
2009-01-29 19:46:17 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-21 08:25:27 +00:00
|
|
|
// avoids use of nsWeakFrame
|
|
|
|
void Revoke() {
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrame = nullptr;
|
2011-05-21 08:25:27 +00:00
|
|
|
}
|
|
|
|
|
2009-01-29 19:46:17 +00:00
|
|
|
private:
|
|
|
|
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() {
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrame = nullptr;
|
2010-05-06 22:12:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsTextControlFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult OffsetToDOMPoint(int32_t aOffset, nsIDOMNode** aResult, int32_t* aPosition);
|
2009-01-29 19:46:17 +00:00
|
|
|
|
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
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool 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
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult UpdateValueDisplay(bool aNotify,
|
|
|
|
bool aBeforeEditorInit = false,
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsAString *aValue = nullptr);
|
2010-02-02 15:49:55 +00:00
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
/**
|
|
|
|
* Get the maxlength attribute
|
|
|
|
* @param aMaxLength the value of the max length attr
|
2011-10-17 14:59:28 +00:00
|
|
|
* @returns false if attr not defined
|
2002-07-26 17:17:00 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
bool GetMaxLength(int32_t* 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
|
2011-10-17 14:59:28 +00:00
|
|
|
* @returns false if it does not exist
|
2002-07-26 17:17:00 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool AttributeExists(nsIAtom *aAtt) const
|
2005-01-12 19:45:38 +00:00
|
|
|
{ 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,
|
2011-11-24 02:48:23 +00:00
|
|
|
nsSize& aIntrinsicSize,
|
|
|
|
float aFontSizeInflation);
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
nsresult ScrollSelectionIntoView() MOZ_OVERRIDE;
|
2011-02-05 00:29:29 +00:00
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
private:
|
|
|
|
//helper methods
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult SetSelectionInternal(nsIDOMNode *aStartNode, int32_t aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode, int32_t aEndOffset,
|
2011-07-28 17:51:22 +00:00
|
|
|
SelectionDirection aDirection = eNone);
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult SelectAllOrCollapseToEndOfText(bool aSelect);
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult SetSelectionEndPoints(int32_t aSelStart, int32_t aSelEnd,
|
2011-07-28 17:51:22 +00:00
|
|
|
SelectionDirection aDirection = eNone);
|
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.
|
|
|
|
*/
|
2012-06-10 23:44:50 +00:00
|
|
|
mozilla::dom::Element* GetRootNodeAndInitializeEditor();
|
2010-04-21 20:17:41 +00:00
|
|
|
nsresult GetRootNodeAndInitializeEditor(nsIDOMElement **aRootElement);
|
2010-04-06 20:44:46 +00:00
|
|
|
|
2011-05-21 08:25:27 +00:00
|
|
|
void FinishedInitializer() {
|
|
|
|
Properties().Delete(TextControlInitializer());
|
|
|
|
}
|
|
|
|
|
2002-07-26 17:17:00 +00:00
|
|
|
private:
|
|
|
|
// these packed bools could instead use the high order bits on mState, saving 4 bytes
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mUseEditor;
|
|
|
|
bool mIsProcessing;
|
2010-10-19 13:11:07 +00:00
|
|
|
// Keep track if we have asked a placeholder node creation.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mUsePlaceholder;
|
2002-07-26 17:17:00 +00:00
|
|
|
|
2010-02-10 01:29:11 +00:00
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInEditorInitialization;
|
2010-02-10 01:29:11 +00:00
|
|
|
friend class EditorInitializerEntryTracker;
|
|
|
|
#endif
|
|
|
|
|
2010-05-06 22:12:21 +00:00
|
|
|
nsRevocableEventPtr<ScrollOnFocusEvent> mScrollEvent;
|
2002-07-26 17:17:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|