Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/layout/forms/nsDateTimeControlFrame.cpp
Warning:line 97, 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 -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=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/layout/forms -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/layout/forms -resource-dir /usr/lib/llvm-19/lib/clang/19 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/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 /var/lib/jenkins/workspace/firefox-scan-build/layout/forms -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/layout/forms -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/chromium/src -I /var/lib/jenkins/workspace/firefox-scan-build/layout/base -I /var/lib/jenkins/workspace/firefox-scan-build/layout/generic -I /var/lib/jenkins/workspace/firefox-scan-build/layout/painting -I /var/lib/jenkins/workspace/firefox-scan-build/layout/style -I /var/lib/jenkins/workspace/firefox-scan-build/layout/xul -I /var/lib/jenkins/workspace/firefox-scan-build/dom/base -I /var/lib/jenkins/workspace/firefox-scan-build/dom/html -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -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-deprecated-this-capture -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 -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 -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-09-22-115206-3586786-1 -x c++ Unified_cpp_layout_forms0.cpp
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3/* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7/**
8 * This frame type is used for input type=date, time, month, week, and
9 * datetime-local.
10 */
11
12#include "nsDateTimeControlFrame.h"
13
14#include "mozilla/PresShell.h"
15#include "nsLayoutUtils.h"
16#include "nsTextControlFrame.h"
17
18using namespace mozilla;
19using namespace mozilla::dom;
20
21nsIFrame* NS_NewDateTimeControlFrame(PresShell* aPresShell,
22 ComputedStyle* aStyle) {
23 return new (aPresShell)
24 nsDateTimeControlFrame(aStyle, aPresShell->GetPresContext());
25}
26
27NS_IMPL_FRAMEARENA_HELPERS(nsDateTimeControlFrame)void* nsDateTimeControlFrame ::operator new(size_t sz, mozilla
::PresShell * aShell) { return aShell->AllocateFrame(nsQueryFrame
::nsDateTimeControlFrame_id, sz); }
28
29NS_QUERYFRAME_HEAD(nsDateTimeControlFrame)void* nsDateTimeControlFrame ::QueryFrame(FrameIID id) const {
switch (id) {
30 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)); }
31NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)default: break; } return nsContainerFrame ::QueryFrame(id); }
32
33nsDateTimeControlFrame::nsDateTimeControlFrame(ComputedStyle* aStyle,
34 nsPresContext* aPresContext)
35 : nsContainerFrame(aStyle, aPresContext, kClassID) {}
36
37nscoord nsDateTimeControlFrame::IntrinsicISize(const IntrinsicSizeInput& aInput,
38 IntrinsicISizeType aType) {
39 return mFrames.IsEmpty() ? 0
40 : nsLayoutUtils::IntrinsicForContainer(
41 aInput.mContext, mFrames.FirstChild(), aType);
42}
43
44Maybe<nscoord> nsDateTimeControlFrame::GetNaturalBaselineBOffset(
45 WritingMode aWM, BaselineSharingGroup aBaselineGroup,
46 BaselineExportContext) const {
47 return nsTextControlFrame::GetSingleLineTextControlBaseline(
48 this, mFirstBaseline, aWM, aBaselineGroup);
49}
50
51void nsDateTimeControlFrame::Reflow(nsPresContext* aPresContext,
52 ReflowOutput& aDesiredSize,
53 const ReflowInput& aReflowInput,
54 nsReflowStatus& aStatus) {
55 MarkInReflow();
56
57 DO_GLOBAL_REFLOW_COUNT("nsDateTimeControlFrame")aPresContext->CountReflows(("nsDateTimeControlFrame"), (nsIFrame
*)this);
;
58 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!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/forms/nsDateTimeControlFrame.cpp"
, 58); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aStatus.IsEmpty()"
") (" "Caller should pass a fresh reflow status!" ")"); do {
*((volatile int*)__null) = 58; __attribute__((nomerge)) ::abort
(); } while (false); } } while (false)
;
59 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)
60 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)
61 ("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)
62 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)
;
63
64 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"
, "/var/lib/jenkins/workspace/firefox-scan-build/layout/forms/nsDateTimeControlFrame.cpp"
, 65); MOZ_PretendNoReturn(); } } while (0)
65 "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"
, "/var/lib/jenkins/workspace/firefox-scan-build/layout/forms/nsDateTimeControlFrame.cpp"
, 65); MOZ_PretendNoReturn(); } } while (0)
;
66
67 const WritingMode myWM = aReflowInput.GetWritingMode();
68
69 {
70 auto baseline = nsTextControlFrame::ComputeBaseline(
71 this, aReflowInput, /* aForSingleLineControl = */ true);
72 mFirstBaseline = baseline.valueOr(NS_INTRINSIC_ISIZE_UNKNOWN);
73 if (baseline) {
74 aDesiredSize.SetBlockStartAscent(*baseline);
75 }
76 }
77
78 // The ISize of our content box, which is the available ISize
79 // for our anonymous content:
80 const nscoord contentBoxISize = aReflowInput.ComputedISize();
81 nscoord contentBoxBSize = aReflowInput.ComputedBSize();
82
83 // Figure out our border-box sizes as well (by adding borderPadding to
84 // content-box sizes):
85 const auto borderPadding = aReflowInput.ComputedLogicalBorderPadding(myWM);
86 const nscoord borderBoxISize =
87 contentBoxISize + borderPadding.IStartEnd(myWM);
88
89 nscoord borderBoxBSize;
90 if (contentBoxBSize != NS_UNCONSTRAINEDSIZE) {
91 borderBoxBSize = contentBoxBSize + borderPadding.BStartEnd(myWM);
92 } // else, we'll figure out borderBoxBSize after we resolve contentBoxBSize.
93
94 nsIFrame* inputAreaFrame = mFrames.FirstChild();
95 if (!inputAreaFrame) { // display:none?
96 if (contentBoxBSize == NS_UNCONSTRAINEDSIZE) {
97 contentBoxBSize = 0;
Value stored to 'contentBoxBSize' is never read
98 borderBoxBSize = borderPadding.BStartEnd(myWM);
99 }
100 } else {
101 ReflowOutput childDesiredSize(aReflowInput);
102
103 WritingMode wm = inputAreaFrame->GetWritingMode();
104 LogicalSize availSize = aReflowInput.ComputedSize(wm);
105 availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
106
107 ReflowInput childReflowInput(aPresContext, aReflowInput, inputAreaFrame,
108 availSize);
109
110 // Convert input area margin into my own writing-mode (in case it differs):
111 LogicalMargin childMargin = childReflowInput.ComputedLogicalMargin(myWM);
112
113 // offsets of input area frame within this frame:
114 LogicalPoint childOffset =
115 borderPadding.StartOffset(myWM) + childMargin.StartOffset(myWM);
116
117 nsReflowStatus childStatus;
118 // We initially reflow the child with a dummy containerSize; positioning
119 // will be fixed later.
120 const nsSize dummyContainerSize;
121 ReflowChild(inputAreaFrame, aPresContext, childDesiredSize,
122 childReflowInput, myWM, childOffset, dummyContainerSize,
123 ReflowChildFlags::Default, childStatus);
124 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" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/forms/nsDateTimeControlFrame.cpp"
, 126); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { *((volatile int*)__null
) = 126; __attribute__((nomerge)) ::abort(); } while (false);
} } while (false)
125 "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" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/forms/nsDateTimeControlFrame.cpp"
, 126); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { *((volatile int*)__null
) = 126; __attribute__((nomerge)) ::abort(); } while (false);
} } while (false)
126 "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" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/forms/nsDateTimeControlFrame.cpp"
, 126); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { *((volatile int*)__null
) = 126; __attribute__((nomerge)) ::abort(); } while (false);
} } while (false)
;
127
128 nscoord childMarginBoxBSize =
129 childDesiredSize.BSize(myWM) + childMargin.BStartEnd(myWM);
130
131 if (contentBoxBSize == NS_UNCONSTRAINEDSIZE) {
132 // We are intrinsically sized -- we should shrinkwrap the input area's
133 // block-size, or our line-height:
134 contentBoxBSize =
135 std::max(aReflowInput.GetLineHeight(), childMarginBoxBSize);
136
137 // Make sure we obey min/max-bsize in the case when we're doing intrinsic
138 // sizing (we get it for free when we have a non-intrinsic
139 // aReflowInput.ComputedBSize()). Note that we do this before
140 // adjusting for borderpadding, since ComputedMaxBSize and
141 // ComputedMinBSize are content heights.
142 contentBoxBSize = aReflowInput.ApplyMinMaxBSize(contentBoxBSize);
143
144 borderBoxBSize = contentBoxBSize + borderPadding.BStartEnd(myWM);
145 }
146
147 // Center child in block axis
148 nscoord extraSpace = contentBoxBSize - childMarginBoxBSize;
149 childOffset.B(myWM) += std::max(0, extraSpace / 2);
150
151 // Needed in FinishReflowChild, for logical-to-physical conversion:
152 nsSize borderBoxSize =
153 LogicalSize(myWM, borderBoxISize, borderBoxBSize).GetPhysicalSize(myWM);
154
155 // Place the child
156 FinishReflowChild(inputAreaFrame, aPresContext, childDesiredSize,
157 &childReflowInput, myWM, childOffset, borderBoxSize,
158 ReflowChildFlags::Default);
159 }
160
161 LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);
162 aDesiredSize.SetSize(myWM, logicalDesiredSize);
163 aDesiredSize.SetOverflowAreasToDesiredBounds();
164
165 if (inputAreaFrame) {
166 ConsiderChildOverflow(aDesiredSize.mOverflowAreas, inputAreaFrame);
167 }
168
169 FinishAndStoreOverflow(&aDesiredSize);
170
171 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)
172 ("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)
173 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)
;
174}