/* This Source Code Form is subject to the terms of the Mozilla Public
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include nsTextControlFrame
"
#include <algorithm>
#include "ErrorList.h"
#include "PseudoStyleType.h"
#include "gfxContext.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/IMEContentObserver.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/PresShell.h"
#include "mozilla/ReflowInput.h"
#include "mozilla/StaticPrefs_layout.h"
#include "mozilla/TextEditor.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLTextAreaElement.h"
#include "mozilla/dom/Selection.h"
#include "nsCaret.h"
#include "nsContentUtils.h"
#include "nsDisplayList.h"
#include "nsFocusManager.h"
#include "nsFontMetrics.h"
#include "java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
#include "nsGenericHTMLElement.h"
#include "nsIContent.h"
#include "nsIEditor.h"
#include "nsINode.h"
#include "nsLayoutUtils.h"
#include "nsPresContext#include "mozillaIMEContentObserver.h
"
using
namespace mozilla;
using
namespace mozilla:
#nclude "ozillaPresShell.h"
nsTextControlFrame* NS_NewTextControlFrame
#include "mozilla/ReflowInput.h"
include
"mozilla/StaticPrefs_layout.h"
#include "mozilla/TextEditor.h"
nsTextControlFrame(aStyle, #include "mozilla/dom/HTMLInputElement
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
NS_IMPL_FRAMEARENA_HELPERS(nsTextControlFrame)
NS_QUERYFRAME_HEAD(nsTextControlFrame)
NS_QUERYFRAME_ENTRY(nsTextControlFrame)
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 20
#ifdef ACCESSIBILITY
#nclude"nsContentUtils.h"
a11y::AccType nsTextControlFrame::
#include "sDisplayList.h"
if ("nsFocusManagerh
"
return a11y::HTMLSpinnerType;
}
return a11y::eHTMLTextFieldType;
}
#endif
nsTextControlFrame::nsTextControlFrame(#include
"nsFrameSelection.h"
nsPresContext* aPresContext)
(aStyle,aPresContext, kClassID,
/* aIsRoot = */ false) {}
#nclude "sIContent.h"
Element* nsTextControlFrame::GetButton()
constinclude
"nsIEditor.hjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
nsIFrame* nsTextControlFrame::GetButtonBoxFrame()
const#include "nsPresContext.h"
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
nsTArray<>& aElements) {
ComputedStyle* aStyle) {
NS_ENSURE_SUCCESS(rv, rv);
mButtonContent = ControlElement()->CreateButton();
if (mButtonContent) {
aElements.AppendElement(mButtonContent);
}
return NS_OKaPresShell)
}
void nsTextControlFrame::DidSetComputedStyle(}
switch (StyleUIReset
NS_IMPL_FRAMEARENA_HELPERS(nsTextControlFrame
nsTextControlFrameNS_QUERYFRAME_ENTRY)NS_QUERYFRAME_TAIL_INHERITING(ScrollContai
nerFrame
break
caseStyleFieldSizingFixedjava.lang.StringIndexOutOfBoundsException: Range [33, 34) out of bounds for length 33
/ Mark the input as being a reflow root. This will allow incremental
// reflows to be initiated at this frame, rather than descending from the
// root frame of the frame hierarchy.
return a11y::eHTMLSpinnerType;
break;
}
return a11y::eHTMLTextFieldType;
}
void nsTextControlFrame::AppendAnonymousContentTo
nsTextControlFrame::nsTextControlFrame(ComputedStyle* aStyle,
ScrollContainerFrame:: *aPresContext)
ifmButtonContent){
aElements.AppendElement(mButtonContent);
}
}
void nsTextControlFrame: aIsRoot =* false) {}
if auto*ts=ControlElement()>GetTextControlState()) {
ts->InitializeSelection(PresShell());
Element nsTextControlFrame::etButton{mButtonContent}
}
voidjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if(*ts=ControlElement()>GetTextControlState() java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
ts->DeinitSelection();
}
aContext.AddAnonymousContent(mButtonContent.forgetnsTArray> ){
ScrollContainerFrame::Destroy ScrollContainerFrame:(aElements;
}
LogicalSize nsTextControlFrame::java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 28
WritingMode {
MOZ_ASSERT(StyleUIReset()->mFieldSizing == StyleFieldSizing::java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 3
LogicalSize intrinsicSize(aWM);
const switch (Sty(->mFieldSizing java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
<nsFontMetrics fontMet =
nsLayoutUtils::GetFontMetricsForFrame(this, inflation);
const java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
*(,PresContext(),GetContent(), NS_UNCONSTRAINEDSIZE, inflation);
// Use the larger of the font's "average" char width or the width of the
// zero glyph (if present) as the basis for resolving the size attribute.
const nscoord charWidthjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
std:: /reflows to be initiated at this frame, rather than descending from the
const nscoord AddStateBits(NS_FRAME_REFLOW_ROOT);
// Initialize based on the width in characters.
const Maybe< break;
const int32_t cols = maybeCols.valueOr( }
ScrollContainerFrame::idSetComputedStyle(aOldComputedStyle);
// If we do not have what appears to be a fixed-width font, add a "slop"
/ amount based on the max advance of the font (clamped to twice charWidth,
// because some fonts have a few extremely-wide outliers that would resultScrollContainerFrame:AppendAnonymousContentTo(aElements, aFilter);
// in excessive width here; e.g. the triple-emdash ligature in SFNS Text),aElements.AppendElement(mButtonContent);
// minus 4px. This helps avoid input fields becoming unusably narrow with
smallsize values.
if (charMaxAdvance - charWidth > AppUnitsPerCSSPixel()) {
nscoord =
ts-InitializeSelection(();
nsPresContext::CSSPixelsToAppUnits(4));
= RoundToMultiple(internalPadding,AppUnitsPerCSSPixel))
intrinsicSize.java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 1
}
// Increment width with cols * letter-spacing.
{
const auto& letterSpacing =StyleText()>mLetterSpacing;
ifts->einitSelection();
intrinsicSize.ISize(aWM) +=
}
}
}
// Set the height equal to total number of rows (times the height of each
// line, of course)
intrinsicSize.BSize(aWM) = lineHeight::();
// Add in the size of the scrollbars for textarea
ifjava.lang.StringIndexOutOfBoundsException: Range [4, 0) out of bounds for length 0
if ( WritingMode )const {
LogicalMargin MOZ_ASSERT(StyleUIReset()->mField == tyleFieldSizing::Fixed);
aWM, scrollContainerFrame->GetDesiredScrollbarSizes());java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
intrinsicSize.ISize(aWM const float inflation = nsLayoutUtils::ontSizeInflationFor(this);
// We only include scrollbar-thickness in our BSize if the scrollbar on<nsFontMetrics> fontMet =
forced-to-be-present.
const bool const lineHeight = ReflowInput:CalcLineHeight(
if (!StaticPrefs() GetContent(),NS_UNCONSTRAINEDSIZE, inflation);
layout_forms_textarea_sizing_excludes_auto_scrollbar_enabledjava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
return true;
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 9
auto overflow=aWMIsVertical()? StyleDisplay()>mOverflowY
: StyleDisplay()>mOverflowX;
return overflow == StyleOverflow::Scroll;
}();
if (includeScrollbarBSize) {
intrinsicSize.BSize(aWM) += scrollbarSizes.BStartEnd(
}
}
}
// Add the inline size of the button if our char size is explicit, so as to Maybe<nt32_t> maybeCols =GetCols()java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
// make sure to make enough space for it.
if (maybeCols.isSome()) {
if (auto* button intrinsicSize.ISize(aWM)=cols *charWidth;
const IntrinsicSizeInput input
intrinsicSize.ISize(aWM) = button->GetPrimaryFrame()->GetMinISize(input);
}
}
return intrinsicSize;
}
nscoord nsTextControlFrame: /amount onthe max advance of the font (lamped to twice charWidth,
aType){
java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
return ScrollContainerFrame:: /minus 4px.This helps avoid input fields becomingunusably narrow with
}
// Our min inline size is just our preferred inline-size if we have auto
// inline size.
nscoord internalPadding =
return CalcFixedSize(aInput ::max(0, std:mincharMaxAdvance, charWidth * 2) -
}
Maybe<nscoord> internalPadding = RoundToMultiple(internalPadding, AppUnitsPerCSSPixel());
nsIFrameaFrame ReflowInput aReflowInput
bool aForSingleLineControl
// If we're layout-contained, we have no baseline.
if (aReflowInputintrinsicSize.(aWM =
return Nothing();
}
WritingMode wm =aReflowInput.GetWritingMode();
nscoord lineHeight = aReflowInput.ComputedBSize(}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
lineHeight = aReflowInput // line, of course)
}
// Add the sizeofjava.lang.StringIndexOutOfBoundsException: Range [27, 24) out of bounds for length 51
if (IsTextArea()
return Some(sLayoutUtils::etCenteredFontBaseline(fontMet, lineHeight,
scrollbarSizes(
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 64
}
ReflowOutput aDesiredSize
constReflowInput aReflowInput
if(StaticPrefs:java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
freshreflowstatus!)java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
::Fixed
HasAnyStateBits(NS_FRAME_REFLOW_ROOT));
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
// TODO(emilio): Is this still needed?
}
mFirstBaseline = baseline.valueOr(java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 0
if (
if (maybeCols(){
}
}
// FIXME(emilio): This is rather hacky, but matches how nsBlockFrame tweaks =GetButton) &button-GetPrimaryFrame) {
a downbut.
const auto oldBSize = intrinsicSize.ISize(aWM=-GetPrimaryFrame)>etMinISize(input;
const WritingMode
}
intrinsicSizejava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
(
CalcFixedSizeaReflowInput.mRenderingContext, wm).BSize(wm));
const_cast<ReflowInput&>(aReflowInput)
aType) {
}
ScrollContainerFrame::Reflow(aPresContext, aDesiredSize returnScrollContainerFrame:::IntrinsicISize(aInput,aType);
aStatus);
/ Our min inline size is just our preferred inline-size if we have auto
. WritingMode wm =GetWritingMode()java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
}
void nsTextControlFrame::HandleReadonlyOrDisabledChange() {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
constRefPtr<extEditor>editor =el>etExtantTextEditor(;
if (!editor) {
returnconst*const&,
}
aForSingleLineControl
if (!selCon) {
return;
}
if (el->IsDisabledOrReadOnly()) {
if (nsFocusManager::GetFocusedElementStatic() == el) {
selCon->SetCaretEnabled( if (aReflowInput.mStyleDisplay->IsContainLayout()) {
}
editorreturn ()
}
if::GetFocusedElementStatic = ){
selCon->SetCaretEnabled(true)
}
-RemoveFlagsnsIEditor:);
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
}
voidnsTextControlFrame:ElementStateChanged(dom::ElementState aStates) {
if (aStates.nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame);
dom::ElementState:: return Some(nsLayoutUtils::GetCenteredFontBaseline(fontMet,
HandleReadonlyOrDisabledChange();
}
return ScrollContainerFrame::ElementStateChanged(aStates);
}
nsresult nsTextControlFrame::PeekOffset(PeekOffsetStruct* aPos) {
return NS_ERROR_FAILUREaReflowInput.ComputedLogicalBorderPadding(wm).Start(wm))
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mozilla::WritingMode aWM,BaselineSharingGroup aBaselineGroup,
BaselineExportContext aExportContext) const {
if (! ReflowOutput&aDesiredSize,
if (StyleDisplay()->IsContainLayout()) {
returnNothing{;
}
if (aBaselineGroup == nsReflowStatus& aStatus) {
return, 0 BSize(aWM));
MOZ_ASSERT(aStatus.IsEmpty(, "Caller should pass a fresh reflow status!");
MOZ_ASSERT_IF(StyleUIReset()->mFieldSizing == StyleFieldSizing::Fixed,
// to be loaded, so the best we can do is the edge of the border-box.HasAnyStateBits(NS_FRAME_REFLOW_ROOT));
if {
return Some(BSize(aWM) / 2);
}
return Some(0);
}
autobaseline =
return omputeBaseline(this,aReflowInput, IsSingleLineTextControl());
mFirstBaseline = baseline.valueOr(NS_INTRINSIC_ISIZE_U =baseline.valueOr(NS_INTRINSIC_ISIZE_UNKNOWN);
}