Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/layout/forms/nsDateTimeControlFrame.cpp
Warning:line 108, 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-18/lib/clang/18 -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-18/lib/clang/18/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 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -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-07-21-021012-413605-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::GetMinISize(gfxContext* aRenderingContext) {
38 nsIFrame* kid = mFrames.FirstChild();
39 if (!kid) {
40 return 0;
41 }
42 return nsLayoutUtils::IntrinsicForContainer(aRenderingContext, kid,
43 IntrinsicISizeType::MinISize);
44}
45
46nscoord nsDateTimeControlFrame::GetPrefISize(gfxContext* aRenderingContext) {
47 nsIFrame* kid = mFrames.FirstChild();
48 if (!kid) {
49 return 0;
50 }
51 return nsLayoutUtils::IntrinsicForContainer(aRenderingContext, kid,
52 IntrinsicISizeType::PrefISize);
53}
54
55Maybe<nscoord> nsDateTimeControlFrame::GetNaturalBaselineBOffset(
56 WritingMode aWM, BaselineSharingGroup aBaselineGroup,
57 BaselineExportContext) const {
58 return nsTextControlFrame::GetSingleLineTextControlBaseline(
59 this, mFirstBaseline, aWM, aBaselineGroup);
60}
61
62void nsDateTimeControlFrame::Reflow(nsPresContext* aPresContext,
63 ReflowOutput& aDesiredSize,
64 const ReflowInput& aReflowInput,
65 nsReflowStatus& aStatus) {
66 MarkInReflow();
67
68 DO_GLOBAL_REFLOW_COUNT("nsDateTimeControlFrame")aPresContext->CountReflows(("nsDateTimeControlFrame"), (nsIFrame
*)this);
;
69 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"
, 69); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aStatus.IsEmpty()"
") (" "Caller should pass a fresh reflow status!" ")"); do {
*((volatile int*)__null) = 69; __attribute__((nomerge)) ::abort
(); } while (false); } } while (false)
;
70 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)
71 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)
72 ("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)
73 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)
;
74
75 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"
, 76); MOZ_PretendNoReturn(); } } while (0)
76 "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"
, 76); MOZ_PretendNoReturn(); } } while (0)
;
77
78 const WritingMode myWM = aReflowInput.GetWritingMode();
79
80 {
81 auto baseline = nsTextControlFrame::ComputeBaseline(
82 this, aReflowInput, /* aForSingleLineControl = */ true);
83 mFirstBaseline = baseline.valueOr(NS_INTRINSIC_ISIZE_UNKNOWN);
84 if (baseline) {
85 aDesiredSize.SetBlockStartAscent(*baseline);
86 }
87 }
88
89 // The ISize of our content box, which is the available ISize
90 // for our anonymous content:
91 const nscoord contentBoxISize = aReflowInput.ComputedISize();
92 nscoord contentBoxBSize = aReflowInput.ComputedBSize();
93
94 // Figure out our border-box sizes as well (by adding borderPadding to
95 // content-box sizes):
96 const auto borderPadding = aReflowInput.ComputedLogicalBorderPadding(myWM);
97 const nscoord borderBoxISize =
98 contentBoxISize + borderPadding.IStartEnd(myWM);
99
100 nscoord borderBoxBSize;
101 if (contentBoxBSize != NS_UNCONSTRAINEDSIZE) {
102 borderBoxBSize = contentBoxBSize + borderPadding.BStartEnd(myWM);
103 } // else, we'll figure out borderBoxBSize after we resolve contentBoxBSize.
104
105 nsIFrame* inputAreaFrame = mFrames.FirstChild();
106 if (!inputAreaFrame) { // display:none?
107 if (contentBoxBSize == NS_UNCONSTRAINEDSIZE) {
108 contentBoxBSize = 0;
Value stored to 'contentBoxBSize' is never read
109 borderBoxBSize = borderPadding.BStartEnd(myWM);
110 }
111 } else {
112 ReflowOutput childDesiredSize(aReflowInput);
113
114 WritingMode wm = inputAreaFrame->GetWritingMode();
115 LogicalSize availSize = aReflowInput.ComputedSize(wm);
116 availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
117
118 ReflowInput childReflowInput(aPresContext, aReflowInput, inputAreaFrame,
119 availSize);
120
121 // Convert input area margin into my own writing-mode (in case it differs):
122 LogicalMargin childMargin = childReflowInput.ComputedLogicalMargin(myWM);
123
124 // offsets of input area frame within this frame:
125 LogicalPoint childOffset =
126 borderPadding.StartOffset(myWM) + childMargin.StartOffset(myWM);
127
128 nsReflowStatus childStatus;
129 // We initially reflow the child with a dummy containerSize; positioning
130 // will be fixed later.
131 const nsSize dummyContainerSize;
132 ReflowChild(inputAreaFrame, aPresContext, childDesiredSize,
133 childReflowInput, myWM, childOffset, dummyContainerSize,
134 ReflowChildFlags::Default, childStatus);
135 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"
, 137); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { *((volatile int*)__null
) = 137; __attribute__((nomerge)) ::abort(); } while (false);
} } while (false)
136 "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"
, 137); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { *((volatile int*)__null
) = 137; __attribute__((nomerge)) ::abort(); } while (false);
} } while (false)
137 "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"
, 137); AnnotateMozCrashReason("MOZ_ASSERT" "(" "childStatus.IsFullyComplete()"
") (" "We gave our child unconstrained available block-size, "
"so it should be complete" ")"); do { *((volatile int*)__null
) = 137; __attribute__((nomerge)) ::abort(); } while (false);
} } while (false)
;
138
139 nscoord childMarginBoxBSize =
140 childDesiredSize.BSize(myWM) + childMargin.BStartEnd(myWM);
141
142 if (contentBoxBSize == NS_UNCONSTRAINEDSIZE) {
143 // We are intrinsically sized -- we should shrinkwrap the input area's
144 // block-size, or our line-height:
145 contentBoxBSize =
146 std::max(aReflowInput.GetLineHeight(), childMarginBoxBSize);
147
148 // Make sure we obey min/max-bsize in the case when we're doing intrinsic
149 // sizing (we get it for free when we have a non-intrinsic
150 // aReflowInput.ComputedBSize()). Note that we do this before
151 // adjusting for borderpadding, since ComputedMaxBSize and
152 // ComputedMinBSize are content heights.
153 contentBoxBSize = aReflowInput.ApplyMinMaxBSize(contentBoxBSize);
154
155 borderBoxBSize = contentBoxBSize + borderPadding.BStartEnd(myWM);
156 }
157
158 // Center child in block axis
159 nscoord extraSpace = contentBoxBSize - childMarginBoxBSize;
160 childOffset.B(myWM) += std::max(0, extraSpace / 2);
161
162 // Needed in FinishReflowChild, for logical-to-physical conversion:
163 nsSize borderBoxSize =
164 LogicalSize(myWM, borderBoxISize, borderBoxBSize).GetPhysicalSize(myWM);
165
166 // Place the child
167 FinishReflowChild(inputAreaFrame, aPresContext, childDesiredSize,
168 &childReflowInput, myWM, childOffset, borderBoxSize,
169 ReflowChildFlags::Default);
170 }
171
172 LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);
173 aDesiredSize.SetSize(myWM, logicalDesiredSize);
174 aDesiredSize.SetOverflowAreasToDesiredBounds();
175
176 if (inputAreaFrame) {
177 ConsiderChildOverflow(aDesiredSize.mOverflowAreas, inputAreaFrame);
178 }
179
180 FinishAndStoreOverflow(&aDesiredSize);
181
182 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)
183 ("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)
184 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)
;
185}