2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 21:17:00 +04:00
|
|
|
|
2002-07-27 00:57:24 +04:00
|
|
|
#ifndef nsTextControlFrame_h___
|
|
|
|
#define nsTextControlFrame_h___
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-11-25 09:35:15 +03:00
|
|
|
#include "mozilla/TextControlElement.h"
|
2017-12-07 21:13:50 +03:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-06-23 15:11:00 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2002-07-26 21:17:00 +04:00
|
|
|
#include "nsIAnonymousContentCreator.h"
|
2014-08-18 18:44:50 +04:00
|
|
|
#include "nsIContent.h"
|
2002-07-27 00:57:24 +04:00
|
|
|
#include "nsITextControlFrame.h"
|
2011-02-05 02:28:38 +03:00
|
|
|
#include "nsIStatefulFrame.h"
|
2002-07-26 21:17:00 +04:00
|
|
|
|
|
|
|
class nsISelectionController;
|
2010-02-10 04:29:11 +03:00
|
|
|
class EditorInitializerEntryTracker;
|
2012-06-11 03:44:50 +04:00
|
|
|
namespace mozilla {
|
2019-11-03 05:50:00 +03:00
|
|
|
class AutoTextControlHandlingState;
|
2017-06-19 17:47:02 +03:00
|
|
|
class TextEditor;
|
2019-11-01 23:43:11 +03:00
|
|
|
class TextControlState;
|
2019-02-19 16:44:33 +03:00
|
|
|
enum class PseudoStyleType : uint8_t;
|
2012-06-11 03:44:50 +04:00
|
|
|
namespace dom {
|
|
|
|
class Element;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
class nsTextControlFrame : public nsContainerFrame,
|
|
|
|
public nsIAnonymousContentCreator,
|
|
|
|
public nsITextControlFrame,
|
|
|
|
public nsIStatefulFrame {
|
2002-07-26 21:17:00 +04:00
|
|
|
public:
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsTextControlFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2016-01-28 06:23:59 +03:00
|
|
|
NS_DECLARE_FRAME_PROPERTY_DELETABLE(ContentScrollPos, nsPoint)
|
2011-02-05 02:28:38 +03:00
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
protected:
|
|
|
|
nsTextControlFrame(ComputedStyle*, nsPresContext*, nsIFrame::ClassID);
|
|
|
|
|
|
|
|
public:
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsTextControlFrame(ComputedStyle* aStyle,
|
2020-01-14 18:05:22 +03:00
|
|
|
nsPresContext* aPresContext)
|
|
|
|
: nsTextControlFrame(aStyle, aPresContext, kClassID) {}
|
|
|
|
|
2002-07-27 00:57:24 +04:00
|
|
|
virtual ~nsTextControlFrame();
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2019-12-11 06:04:20 +03:00
|
|
|
/**
|
|
|
|
* DestroyFrom() causes preparing to destroy editor and that may cause
|
|
|
|
* running selection listeners of specllchecker selection and document
|
|
|
|
* state listeners. Not sure whether the former does something or not,
|
|
|
|
* but nobody should run content script. The latter is currently only
|
|
|
|
* FinderHighlighter to clean up its fields at destruction. Thus, the
|
|
|
|
* latter won't run content script too. Therefore, this won't run
|
|
|
|
* unsafe script.
|
|
|
|
*/
|
2020-01-14 18:05:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData&) override;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
nsIScrollableFrame* GetScrollTargetFrame() override;
|
|
|
|
nsIScrollableFrame* GetScrollTargetFrame() const {
|
|
|
|
return const_cast<nsTextControlFrame*>(this)->GetScrollTargetFrame();
|
2009-09-01 15:22:31 +04:00
|
|
|
}
|
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
|
|
|
nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
2012-06-23 15:11:00 +04:00
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
mozilla::LogicalSize ComputeAutoSize(
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aRenderingContext, mozilla::WritingMode aWM,
|
2014-08-24 18:34:51 +04:00
|
|
|
const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
|
|
|
|
const mozilla::LogicalSize& aMargin, const mozilla::LogicalSize& aBorder,
|
|
|
|
const mozilla::LogicalSize& aPadding, ComputeSizeFlags aFlags) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
|
|
|
const ReflowInput& aReflowInput,
|
|
|
|
nsReflowStatus& aStatus) override;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2017-01-28 04:34:13 +03:00
|
|
|
bool GetVerticalAlignBaseline(mozilla::WritingMode aWM,
|
|
|
|
nscoord* aBaseline) const override {
|
2019-04-26 02:03:04 +03:00
|
|
|
return GetNaturalBaselineBOffset(aWM, BaselineSharingGroup::First,
|
2017-01-28 04:34:13 +03:00
|
|
|
aBaseline);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM,
|
|
|
|
BaselineSharingGroup aBaselineGroup,
|
|
|
|
nscoord* aBaseline) const override {
|
2019-05-24 07:46:17 +03:00
|
|
|
if (StyleDisplay()->IsContainLayout() || !IsSingleLineTextControl()) {
|
2017-01-28 04:34:13 +03:00
|
|
|
return false;
|
|
|
|
}
|
2019-05-03 20:34:36 +03:00
|
|
|
NS_ASSERTION(mFirstBaseline != NS_INTRINSIC_ISIZE_UNKNOWN,
|
2017-01-28 04:34:13 +03:00
|
|
|
"please call Reflow before asking for the baseline");
|
2019-04-26 02:03:04 +03:00
|
|
|
if (aBaselineGroup == BaselineSharingGroup::First) {
|
2017-01-28 04:34:13 +03:00
|
|
|
*aBaseline = mFirstBaseline;
|
|
|
|
} else {
|
|
|
|
*aBaseline = BSize(aWM) - mFirstBaseline;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
nsSize GetXULMinSize(nsBoxLayoutState&) override;
|
|
|
|
bool IsXULCollapsed() override;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2002-07-26 21:17:00 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2020-01-14 18:05:22 +03:00
|
|
|
mozilla::a11y::AccType AccessibleType() override;
|
2002-07-26 21:17:00 +04:00
|
|
|
#endif
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2020-01-14 18:05:22 +03:00
|
|
|
nsresult GetFrameName(nsAString& aResult) const override {
|
2004-06-17 04:13:25 +04:00
|
|
|
aResult.AssignLiteral("nsTextControlFrame");
|
2002-07-26 21:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
bool IsFrameOfType(uint32_t aFlags) const override {
|
2012-06-23 15:11:00 +04:00
|
|
|
return nsContainerFrame::IsFrameOfType(
|
2007-02-24 21:33:33 +03:00
|
|
|
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 08:38:33 +03:00
|
|
|
|
2017-01-28 04:34:13 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
void MarkIntrinsicISizesDirty() override {
|
|
|
|
// Need another Reflow to have a correct baseline value again.
|
2019-05-03 20:34:36 +03:00
|
|
|
mFirstBaseline = NS_INTRINSIC_ISIZE_UNKNOWN;
|
2017-01-28 04:34:13 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
// nsIAnonymousContentCreator
|
2020-01-14 18:05:22 +03:00
|
|
|
nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
|
|
|
|
void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
|
|
|
uint32_t aFilter) override;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
void SetInitialChildList(ChildListID, nsFrameList&) override;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) override;
|
2012-11-09 14:22:29 +04:00
|
|
|
|
2002-07-26 21:17:00 +04:00
|
|
|
//==== BEGIN NSIFORMCONTROLFRAME
|
2020-01-14 18:05:22 +03:00
|
|
|
void SetFocus(bool aOn, bool aRepaint) override;
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
|
|
|
|
SetFormProperty(nsAtom* aName, const nsAString& aValue) override;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
|
|
|
//==== END NSIFORMCONTROLFRAME
|
|
|
|
|
2009-01-29 22:46:17 +03:00
|
|
|
//==== NSITEXTCONTROLFRAME
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD_(already_AddRefed<mozilla::TextEditor>)
|
|
|
|
GetTextEditor() override;
|
2019-12-11 06:02:53 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT NS_IMETHOD
|
|
|
|
SetSelectionRange(uint32_t aSelectionStart, uint32_t aSelectionEnd,
|
|
|
|
SelectionDirection aDirection = eNone) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetOwnedSelectionController(
|
|
|
|
nsISelectionController** aSelCon) override;
|
2020-01-14 18:05:22 +03:00
|
|
|
nsFrameSelection* GetOwnedFrameSelection() override;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2010-02-02 07:00:06 +03: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
|
|
|
|
*/
|
2020-01-14 18:05:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult EnsureEditorInitialized() override;
|
2010-02-02 07:00:06 +03:00
|
|
|
|
2009-01-29 22:46:17 +03:00
|
|
|
//==== END NSITEXTCONTROLFRAME
|
2011-02-05 02:28:38 +03:00
|
|
|
|
|
|
|
//==== NSISTATEFULFRAME
|
|
|
|
|
2018-06-15 19:14:29 +03:00
|
|
|
mozilla::UniquePtr<mozilla::PresState> SaveState() override;
|
|
|
|
NS_IMETHOD RestoreState(mozilla::PresState* aState) override;
|
2011-02-05 02:28:38 +03:00
|
|
|
|
|
|
|
//=== END NSISTATEFULFRAME
|
|
|
|
|
2002-07-26 21:17:00 +04:00
|
|
|
//==== OVERLOAD of nsIFrame
|
|
|
|
|
|
|
|
/** handler for attribute changes to mContent */
|
2020-01-14 18:05:22 +03:00
|
|
|
nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
|
|
|
int32_t aModType) override;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
void GetText(nsString& aText);
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2019-11-25 09:35:17 +03:00
|
|
|
/**
|
|
|
|
* TextEquals() is designed for internal use so that aValue shouldn't
|
|
|
|
* include \r character. It should be handled before calling this with
|
|
|
|
* nsContentUtils::PlatformToDOMLineBreaks().
|
|
|
|
*/
|
|
|
|
bool TextEquals(const nsAString& aText) const;
|
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
nsresult PeekOffset(nsPeekOffsetStruct* aPos) override;
|
2012-06-20 03:31:03 +04:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2012-06-23 15:11:00 +04:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Launch the reflow on the child frames - see nsTextControlFrame::Reflow()
|
|
|
|
*/
|
|
|
|
void ReflowTextControlChild(nsIFrame* aFrame, nsPresContext* aPresContext,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2012-06-23 15:11:00 +04:00
|
|
|
nsReflowStatus& aStatus,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aParentDesiredSize);
|
2011-05-21 12:25:27 +04:00
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
void ComputeBaseline(const ReflowInput&, ReflowOutput&);
|
|
|
|
|
2002-07-27 00:57:24 +04:00
|
|
|
public: // for methods who access nsTextControlFrame directly
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetValueChanged(bool aValueChanged);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2017-09-22 03:18:30 +03:00
|
|
|
mozilla::dom::Element* GetRootNode() const { return mRootNode; }
|
|
|
|
|
|
|
|
mozilla::dom::Element* GetPreviewNode() const { return mPreviewDiv; }
|
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
mozilla::dom::Element* GetPlaceholderNode() const { return mPlaceholderDiv; }
|
|
|
|
|
2007-09-27 20:01:32 +04:00
|
|
|
// called by the focus listener
|
|
|
|
nsresult MaybeBeginSecureKeyboardInput();
|
|
|
|
void MaybeEndSecureKeyboardInput();
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
#define DEFINE_TEXTCTRL_CONST_FORWARDER(type, name) \
|
|
|
|
type name() const { \
|
|
|
|
mozilla::TextControlElement* textControlElement = \
|
|
|
|
mozilla::TextControlElement::FromNode(GetContent()); \
|
|
|
|
return textControlElement->name(); \
|
2010-04-22 00:17:41 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsSingleLineTextControl)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsTextArea)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsPasswordTextControl)
|
2016-11-18 21:08:32 +03:00
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(int32_t, GetCols)
|
|
|
|
DEFINE_TEXTCTRL_CONST_FORWARDER(int32_t, GetRows)
|
2010-04-22 00:17:41 +04:00
|
|
|
|
|
|
|
#undef DEFINE_TEXTCTRL_CONST_FORWARDER
|
|
|
|
|
2002-07-26 21:17:00 +04:00
|
|
|
protected:
|
2009-01-29 22:46:17 +03:00
|
|
|
class EditorInitializer;
|
|
|
|
friend class EditorInitializer;
|
2019-11-03 05:50:00 +03:00
|
|
|
friend class mozilla::AutoTextControlHandlingState; // needs access to
|
|
|
|
// CacheValue
|
2019-11-01 23:43:11 +03:00
|
|
|
friend class mozilla::TextControlState; // needs access to UpdateValueDisplay
|
2009-01-29 22:46:17 +03:00
|
|
|
|
2016-01-28 06:23:59 +03:00
|
|
|
// Temp reference to scriptrunner
|
2017-05-28 13:22:29 +03:00
|
|
|
NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(TextControlInitializer, EditorInitializer,
|
|
|
|
nsTextControlFrame::RevokeInitializer)
|
|
|
|
|
|
|
|
static void RevokeInitializer(EditorInitializer* aInitializer) {
|
|
|
|
aInitializer->Revoke();
|
|
|
|
};
|
2016-01-28 06:23:59 +03:00
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class EditorInitializer : public mozilla::Runnable {
|
2009-01-29 22:46:17 +03:00
|
|
|
public:
|
2017-06-12 22:34:10 +03:00
|
|
|
explicit EditorInitializer(nsTextControlFrame* aFrame)
|
|
|
|
: mozilla::Runnable("nsTextControlFrame::EditorInitializer"),
|
|
|
|
mFrame(aFrame) {}
|
2009-01-29 22:46:17 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Run() override;
|
2009-01-29 22:46:17 +03:00
|
|
|
|
2017-03-01 20:03:14 +03:00
|
|
|
// avoids use of AutoWeakFrame
|
2012-07-30 18:20:58 +04:00
|
|
|
void Revoke() { mFrame = nullptr; }
|
2011-05-21 12:25:27 +04:00
|
|
|
|
2009-01-29 22:46:17 +03:00
|
|
|
private:
|
|
|
|
nsTextControlFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
2010-05-07 02:12:21 +04:00
|
|
|
class ScrollOnFocusEvent;
|
|
|
|
friend class ScrollOnFocusEvent;
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class ScrollOnFocusEvent : public mozilla::Runnable {
|
2010-05-07 02:12:21 +04:00
|
|
|
public:
|
2017-06-12 22:34:10 +03:00
|
|
|
explicit ScrollOnFocusEvent(nsTextControlFrame* aFrame)
|
|
|
|
: mozilla::Runnable("nsTextControlFrame::ScrollOnFocusEvent"),
|
|
|
|
mFrame(aFrame) {}
|
2010-05-07 02:12:21 +04:00
|
|
|
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
void Revoke() { mFrame = nullptr; }
|
2010-05-07 02:12:21 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsTextControlFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
2018-01-30 07:10:51 +03:00
|
|
|
nsresult OffsetToDOMPoint(uint32_t aOffset, nsINode** aResult,
|
|
|
|
uint32_t* aPosition);
|
2009-01-29 22:46:17 +03:00
|
|
|
|
2010-02-02 18:49:55 +03: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 10:19:26 +04:00
|
|
|
nsresult UpdateValueDisplay(bool aNotify, bool aBeforeEditorInit = false,
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsAString* aValue = nullptr);
|
2010-02-02 18:49:55 +03:00
|
|
|
|
2002-07-26 21:17:00 +04:00
|
|
|
/**
|
|
|
|
* Get the maxlength attribute
|
|
|
|
* @param aMaxLength the value of the max length attr
|
2011-10-17 18:59:28 +04:00
|
|
|
* @returns false if attr not defined
|
2002-07-26 21:17:00 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
bool GetMaxLength(int32_t* aMaxLength);
|
2010-02-02 18:49:55 +03:00
|
|
|
|
2002-07-26 21:17:00 +04:00
|
|
|
/**
|
|
|
|
* Find out whether an attribute exists on the content or not.
|
|
|
|
* @param aAtt the attribute to determine the existence of
|
2011-10-17 18:59:28 +04:00
|
|
|
* @returns false if it does not exist
|
2002-07-26 21:17:00 +04:00
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
bool AttributeExists(nsAtom* aAtt) const {
|
2017-12-07 21:13:50 +03:00
|
|
|
return mContent && mContent->AsElement()->HasAttr(kNameSpaceID_None, aAtt);
|
|
|
|
}
|
2005-01-12 22:45:38 +03:00
|
|
|
|
2002-07-26 21:17:00 +04:00
|
|
|
/**
|
|
|
|
* We call this when we are being destroyed or removed from the PFM.
|
|
|
|
* @param aPresContext the current pres context
|
|
|
|
*/
|
2006-04-10 04:16:29 +04:00
|
|
|
void PreDestroy();
|
2002-09-16 10:23:52 +04: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 08:38:33 +03: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>).
|
2017-06-09 22:14:53 +03:00
|
|
|
mozilla::LogicalSize CalcIntrinsicSize(gfxContext* aRenderingContext,
|
2016-11-18 21:08:32 +03:00
|
|
|
mozilla::WritingMode aWM,
|
|
|
|
float aFontSizeInflation) const;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult ScrollSelectionIntoView() override;
|
2011-02-05 03:29:29 +03:00
|
|
|
|
2002-07-26 21:17:00 +04:00
|
|
|
private:
|
|
|
|
// helper methods
|
2019-12-11 06:02:53 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetSelectionInternal(
|
|
|
|
nsINode* aStartNode, uint32_t aStartOffset, nsINode* aEndNode,
|
|
|
|
uint32_t aEndOffset, SelectionDirection aDirection = eNone);
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SelectAllOrCollapseToEndOfText(bool aSelect);
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
SetSelectionEndPoints(uint32_t aSelStart, uint32_t aSelEnd,
|
|
|
|
SelectionDirection aDirection = eNone);
|
2010-02-26 21:47:38 +03:00
|
|
|
|
2017-05-27 14:36:00 +03:00
|
|
|
void FinishedInitializer() { DeleteProperty(TextControlInitializer()); }
|
2011-05-21 12:25:27 +04:00
|
|
|
|
2017-09-22 03:18:30 +03:00
|
|
|
const nsAString& CachedValue() const { return mCachedValue; }
|
|
|
|
|
|
|
|
void ClearCachedValue() { mCachedValue.SetIsVoid(true); }
|
|
|
|
|
|
|
|
void CacheValue(const nsAString& aValue) { mCachedValue.Assign(aValue); }
|
|
|
|
|
|
|
|
MOZ_MUST_USE bool CacheValue(const nsAString& aValue,
|
|
|
|
const mozilla::fallible_t& aFallible) {
|
|
|
|
if (!mCachedValue.Assign(aValue, aFallible)) {
|
|
|
|
ClearCachedValue();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-01-14 18:05:22 +03:00
|
|
|
protected:
|
2017-09-22 03:18:30 +03:00
|
|
|
class nsAnonDivObserver;
|
|
|
|
|
|
|
|
nsresult CreateRootNode();
|
|
|
|
void CreatePlaceholderIfNeeded();
|
|
|
|
void CreatePreviewIfNeeded();
|
2019-07-22 06:54:16 +03:00
|
|
|
enum class AnonymousDivType {
|
|
|
|
Root,
|
|
|
|
Placeholder,
|
|
|
|
Preview,
|
|
|
|
};
|
2019-11-29 23:39:36 +03:00
|
|
|
already_AddRefed<mozilla::dom::Element> CreateEmptyAnonymousDiv(
|
|
|
|
AnonymousDivType) const;
|
|
|
|
already_AddRefed<mozilla::dom::Element> CreateEmptyAnonymousDivWithTextNode(
|
|
|
|
AnonymousDivType) const;
|
2019-07-22 06:54:16 +03:00
|
|
|
|
2017-09-22 03:18:30 +03:00
|
|
|
bool ShouldInitializeEagerly() const;
|
|
|
|
void InitializeEagerlyIfNeeded();
|
|
|
|
|
|
|
|
RefPtr<mozilla::dom::Element> mRootNode;
|
|
|
|
RefPtr<mozilla::dom::Element> mPlaceholderDiv;
|
|
|
|
RefPtr<mozilla::dom::Element> mPreviewDiv;
|
|
|
|
RefPtr<nsAnonDivObserver> mMutationObserver;
|
|
|
|
// Cache of the |.value| of <input> or <textarea> element without hard-wrap.
|
|
|
|
// If its IsVoid() returns true, it doesn't cache |.value|.
|
|
|
|
// Otherwise, it's cached when setting specific value or getting value from
|
|
|
|
// TextEditor. Additionally, when contents in the anonymous <div> element
|
|
|
|
// is modified, this is cleared.
|
|
|
|
//
|
|
|
|
// FIXME(bug 1402545): Consider using an nsAutoString here.
|
|
|
|
nsString mCachedValue;
|
|
|
|
|
2019-05-03 20:34:36 +03:00
|
|
|
// Our first baseline, or NS_INTRINSIC_ISIZE_UNKNOWN if we have a pending
|
2019-05-24 07:46:17 +03:00
|
|
|
// Reflow (or if we're contain:layout, which means we have no baseline).
|
2017-01-28 04:34:13 +03:00
|
|
|
nscoord mFirstBaseline;
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
// these packed bools could instead use the high order bits on mState, saving
|
|
|
|
// 4 bytes
|
2013-10-16 17:43:03 +04:00
|
|
|
bool mEditorHasBeenInitialized;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsProcessing;
|
2002-07-26 21:17:00 +04:00
|
|
|
|
2010-02-10 04:29:11 +03:00
|
|
|
#ifdef DEBUG
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInEditorInitialization;
|
2010-02-10 04:29:11 +03:00
|
|
|
friend class EditorInitializerEntryTracker;
|
|
|
|
#endif
|
|
|
|
|
2010-05-07 02:12:21 +04:00
|
|
|
nsRevocableEventPtr<ScrollOnFocusEvent> mScrollEvent;
|
2002-07-26 21:17:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|