Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/layout/forms/./../../../layout/forms/nsDateTimeControlFrame.cpp
Warning:line 96, column 7
Value stored to 'contentBoxBSize' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_layout_forms0.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/layout/forms -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/layout/forms -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/layout/forms -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/layout/forms -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/toolkit/components/telemetry -I /root/firefox-clang/xpcom/base -I /root/firefox-clang/layout/base -I /root/firefox-clang/layout/generic -I /root/firefox-clang/layout/painting -I /root/firefox-clang/layout/style -I /root/firefox-clang/layout/xul -I /root/firefox-clang/dom/base -I /root/firefox-clang/dom/html -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-09-01-224014-2642839-1 -x c++ Unified_cpp_layout_forms0.cpp
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5/**
6 * This frame type is used for input type=date, time, month, week, and
7 * datetime-local.
8 */
9
10#include "nsDateTimeControlFrame.h"
11
12#include "mozilla/PresShell.h"
13#include "mozilla/ReflowInput.h"
14#include "nsLayoutUtils.h"
15#include "nsTextControlFrame.h"
16
17using namespace mozilla;
18using namespace mozilla::dom;
19
20nsIFrame* NS_NewDateTimeControlFrame(PresShell* aPresShell,
21 ComputedStyle* aStyle) {
22 return new (aPresShell)
23 nsDateTimeControlFrame(aStyle, aPresShell->GetPresContext());
24}
25
26NS_IMPL_FRAMEARENA_HELPERS(nsDateTimeControlFrame)void* nsDateTimeControlFrame ::operator new(size_t sz, mozilla
::PresShell * aShell) { return aShell->AllocateFrame(nsQueryFrame
::nsDateTimeControlFrame_id, sz); }
27
28NS_QUERYFRAME_HEAD(nsDateTimeControlFrame)void* nsDateTimeControlFrame ::QueryFrame(FrameIID id) const {
switch (id) {
29 NS_QUERYFRAME_ENTRY(nsDateTimeControlFrame)case nsDateTimeControlFrame ::kFrameIID: { static_assert( std
::is_same_v<nsDateTimeControlFrame, nsDateTimeControlFrame
::Has_NS_DECL_QUERYFRAME_TARGET>, "nsDateTimeControlFrame"
" must declare itself as a queryframe target"); return const_cast
<nsDateTimeControlFrame*>(static_cast<const nsDateTimeControlFrame
*>(this)); }
30NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)default: break; } return nsContainerFrame ::QueryFrame(id); }
31
32nsDateTimeControlFrame::nsDateTimeControlFrame(ComputedStyle* aStyle,
33 nsPresContext* aPresContext)
34 : nsContainerFrame(aStyle, aPresContext, kClassID) {}
35
36nscoord nsDateTimeControlFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
37 IntrinsicISizeType aType) {
38 return mFrames.IsEmpty() ? 0
39 : nsLayoutUtils::IntrinsicForContainer(
40 aInput.mContext, mFrames.FirstChild(), aType);
41}
42
43Maybe<nscoord> nsDateTimeControlFrame::GetNaturalBaselineBOffset(
44 WritingMode aWM, BaselineSharingGroup aBaselineGroup,
45 BaselineExportContext) const {
46 return nsTextControlFrame::GetSingleLineTextControlBaseline(
47 this, mFirstBaseline, aWM, aBaselineGroup);
48}
49
50void nsDateTimeControlFrame::Reflow(nsPresContext* aPresContext,
51 ReflowOutput& aDesiredSize,
52 const ReflowInput& aReflowInput,
53 nsReflowStatus& aStatus) {
54 MarkInReflow();
55
56 DO_GLOBAL_REFLOW_COUNT("nsDateTimeControlFrame")aPresContext->CountReflows(("nsDateTimeControlFrame"), (nsIFrame
*)this);
;
57 MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aStatus.IsEmpty())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aStatus.IsEmpty()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("aStatus.IsEmpty()"
" (" "Caller should pass a fresh reflow status!" ")", "./../../../layout/forms/nsDateTimeControlFrame.cpp"
, 57); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aStatus.IsEmpty()"
") (" "Caller should pass a fresh reflow status!" ")"); do {
MOZ_CrashSequence(__null, 57); __attribute__((nomerge)) ::abort
(); } while (false); } } while (false)
;
58 NS_FRAME_TRACE(do { if ((int(((mozilla::LogModule*)(nsIFrame::sFrameLogModule
))->Level()) & (0x1))) { TraceMsg ("enter nsDateTimeControlFrame::Reflow: availSize=%d,%d"
, aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight
()); } } while (0)
59 NS_FRAME_TRACE_CALLS,do { if ((int(((mozilla::LogModule*)(nsIFrame::sFrameLogModule
))->Level()) & (0x1))) { TraceMsg ("enter nsDateTimeControlFrame::Reflow: availSize=%d,%d"
, aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight
()); } } while (0)
60 ("enter nsDateTimeControlFrame::Reflow: availSize=%d,%d",do { if ((int(((mozilla::LogModule*)(nsIFrame::sFrameLogModule
))->Level()) & (0x1))) { TraceMsg ("enter nsDateTimeControlFrame::Reflow: availSize=%d,%d"
, aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight
()); } } while (0)
61 aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()))do { if ((int(((mozilla::LogModule*)(nsIFrame::sFrameLogModule
))->Level()) & (0x1))) { TraceMsg ("enter nsDateTimeControlFrame::Reflow: availSize=%d,%d"
, aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight
()); } } while (0)
;
62
63 NS_ASSERTION(mFrames.GetLength() <= 1,do { if (!(mFrames.GetLength() <= 1)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "There should be no more than 1 frames", "mFrames.GetLength() <= 1"
, "./../../../layout/forms/nsDateTimeControlFrame.cpp", 64); MOZ_PretendNoReturn
(); } } while (0)
64 "There should be no more than 1 frames")do { if (!(mFrames.GetLength() <= 1)) { NS_DebugBreak(NS_DEBUG_ASSERTION
, "There should be no more than 1 frames", "mFrames.GetLength() <= 1"
, "./../../../layout/forms/nsDateTimeControlFrame.cpp", 64); MOZ_PretendNoReturn
(); } } while (0)
;
65
66 const WritingMode myWM = aReflowInput.GetWritingMode();
67
68 {
69 auto baseline = nsTextControlFrame::ComputeBaseline(
70 this, aReflowInput, /* aForSingleLineControl = */ true);
71 mFirstBaseline = baseline.valueOr(NS_INTRINSIC_ISIZE_UNKNOWN);
72 if (baseline) {
73 aDesiredSize.SetBlockStartAscent(*baseline);
74 }
75 }
76
77 // The ISize of our content box, which is the available ISize
78 // for our anonymous content:
79 const nscoord contentBoxISize = aReflowInput.ComputedISize();
80 nscoord contentBoxBSize = aReflowInput.ComputedBSize();
81
82 // Figure out our border-box sizes as well (by adding borderPadding to
83 // content-box sizes):
84 const auto borderPadding = aReflowInput.ComputedLogicalBorderPadding(myWM);
85 const nscoord borderBoxISize =
86 contentBoxISize + borderPadding.IStartEnd(myWM);
87
88 nscoord borderBoxBSize;
89 if (contentBoxBSize != NS_UNCONSTRAINEDSIZE) {
90 borderBoxBSize = contentBoxBSize + borderPadding.BStartEnd(myWM);
91 } // else, we'll figure out borderBoxBSize after we resolve contentBoxBSize.
92
93 nsIFrame* inputAreaFrame = mFrames.FirstChild();
94 if (!inputAreaFrame) { // display:none?
95 if (contentBoxBSize == NS_UNCONSTRAINEDSIZE) {
96 contentBoxBSize = 0;
Value stored to 'contentBoxBSize' is never read
97 borderBoxBSize = borderPadding.BStartEnd(myWM);
98 }
99 } else {
100 ReflowOutput childDesiredSize(aReflowInput);
101
102 WritingMode wm = inputAreaFrame->GetWritingMode();
103 LogicalSize availSize = aReflowInput.ComputedSize(wm);
104 availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
105
106 ReflowInput childReflowInput(aPresContext, aReflowInput, inputAreaFrame,
107 availSize);
108
109 // Convert input area margin into my own writing-mode (in case it differs):
110 LogicalMargin childMargin = childReflowInput.ComputedLogicalMargin(myWM);
111
112 // offsets of input area frame within this frame:
113 LogicalPoint childOffset =
114 borderPadding.StartOffset(myWM) + childMargin.StartOffset(myWM);
115
116 nsReflowStatus childStatus;
117 // We initially reflow the child with a dummy containerSize; positioning
118 // will be fixed later.
119 const nsSize dummyContainerSize;
120 ReflowChild(inputAreaFrame, aPresContext, childDesiredSize,
121 childReflowInput, myWM, childOffset, dummyContainerSize,
122 ReflowChildFlags::Default, childStatus);
123 MOZ_ASSERT(childStatus.IsFullyComplete(),do { static_assert( mozilla::detail::AssertionConditionType<
decltype(childStatus.IsFullyComplete())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(childStatus.IsFullyComplete(
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("childStatus.IsFullyComplete()" " (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")", "./../../../layout/forms/nsDateTimeControlFrame.cpp"
, 125); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { MOZ_CrashSequence(__null
, 125); __attribute__((nomerge)) ::abort(); } while (false); }
} while (false)
124 "We gave our child unconstrained available block-size, "do { static_assert( mozilla::detail::AssertionConditionType<
decltype(childStatus.IsFullyComplete())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(childStatus.IsFullyComplete(
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("childStatus.IsFullyComplete()" " (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")", "./../../../layout/forms/nsDateTimeControlFrame.cpp"
, 125); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { MOZ_CrashSequence(__null
, 125); __attribute__((nomerge)) ::abort(); } while (false); }
} while (false)
125 "so it should be complete")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(childStatus.IsFullyComplete())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(childStatus.IsFullyComplete(
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("childStatus.IsFullyComplete()" " (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")", "./../../../layout/forms/nsDateTimeControlFrame.cpp"
, 125); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { MOZ_CrashSequence(__null
, 125); __attribute__((nomerge)) ::abort(); } while (false); }
} while (false)
;
126
127 nscoord childMarginBoxBSize =
128 childDesiredSize.BSize(myWM) + childMargin.BStartEnd(myWM);
129
130 if (contentBoxBSize == NS_UNCONSTRAINEDSIZE) {
131 // We are intrinsically sized -- we should shrinkwrap the input area's
132 // block-size, or our line-height:
133 contentBoxBSize =
134 std::max(aReflowInput.GetLineHeight(), childMarginBoxBSize);
135
136 // Make sure we obey min/max-bsize in the case when we're doing intrinsic
137 // sizing (we get it for free when we have a non-intrinsic
138 // aReflowInput.ComputedBSize()). Note that we do this before
139 // adjusting for borderpadding, since ComputedMaxBSize and
140 // ComputedMinBSize are content heights.
141 contentBoxBSize = aReflowInput.ApplyMinMaxBSize(contentBoxBSize);
142
143 borderBoxBSize = contentBoxBSize + borderPadding.BStartEnd(myWM);
144 }
145
146 // Center child in block axis
147 nscoord extraSpace = contentBoxBSize - childMarginBoxBSize;
148 childOffset.B(myWM) += std::max(0, extraSpace / 2);
149
150 // Needed in FinishReflowChild, for logical-to-physical conversion:
151 nsSize borderBoxSize =
152 LogicalSize(myWM, borderBoxISize, borderBoxBSize).GetPhysicalSize(myWM);
153
154 // Place the child
155 FinishReflowChild(inputAreaFrame, aPresContext, childDesiredSize,
156 &childReflowInput, myWM, childOffset, borderBoxSize,
157 ReflowChildFlags::Default);
158 }
159
160 LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);
161 aDesiredSize.SetSize(myWM, logicalDesiredSize);
162 aDesiredSize.SetOverflowAreasToDesiredBounds();
163
164 if (inputAreaFrame) {
165 ConsiderChildOverflow(aDesiredSize.mOverflowAreas, inputAreaFrame);
166 }
167
168 FinishAndStoreOverflow(&aDesiredSize);
169
170 NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,do { if ((int(((mozilla::LogModule*)(nsIFrame::sFrameLogModule
))->Level()) & (0x1))) { TraceMsg ("exit nsDateTimeControlFrame::Reflow: size=%d,%d"
, aDesiredSize.Width(), aDesiredSize.Height()); } } while (0)
171 ("exit nsDateTimeControlFrame::Reflow: size=%d,%d",do { if ((int(((mozilla::LogModule*)(nsIFrame::sFrameLogModule
))->Level()) & (0x1))) { TraceMsg ("exit nsDateTimeControlFrame::Reflow: size=%d,%d"
, aDesiredSize.Width(), aDesiredSize.Height()); } } while (0)
172 aDesiredSize.Width(), aDesiredSize.Height()))do { if ((int(((mozilla::LogModule*)(nsIFrame::sFrameLogModule
))->Level()) & (0x1))) { TraceMsg ("exit nsDateTimeControlFrame::Reflow: size=%d,%d"
, aDesiredSize.Width(), aDesiredSize.Height()); } } while (0)
;
173}