Bug Summary

File:Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebCore/rendering/RenderMultiColumnFlow.cpp
Warning:line 433, column 12
Call argument for 'this' parameter is uncounted and unsafe

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple arm64-apple-ios26.2.0-simulator -O3 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name UnifiedSource415.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=osx -analyzer-checker=security.insecureAPI.decodeValueOfObjCType -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 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -target-sdk-version=26.2 -fdepfile-entry=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/SDKSettings.json -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fno-modulemap-allow-subdirectory-search -fdefine-target-os-macros -enable-tlsdesc -target-cpu apple-m1 -target-feature +v8.4a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +ccpp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +flagm -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -target-abi darwinpcs -dwarf-ext-refs -fmodule-format=obj -debug-info-kind=standalone -dwarf-version=5 -debugger-tuning=lldb -fdebug-compilation-dir=/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebCore -target-linker-version 1230.1 -fcoverage-compilation-dir=/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebCore -resource-dir /Users/buildbot/Library/Developer/Toolchains/swift-webkit.xctoolchain/usr/lib/clang/21 -dependency-file /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/WebCore/WebCore/normal/arm64/UnifiedSource415.d -skip-unused-modulemap-deps -MT dependencies -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk -iquote /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/WebCore-generated-files.hmap -iquote /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/WebCore-project-headers.hmap -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebCore/PAL/ThirdParty/dav1d/include -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/SDKAdditions/usr/include -iframework /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/SDKAdditions/System/Library/Frameworks -iframework /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/System/Library/PrivateFrameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/Frameworks -include-pch /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/PrecompiledHeaders/SharedPrecompiledHeaders/11721353671419897710/WebCorePrefix.h.gch -D _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D NDEBUG -D BUILDING_WEBKIT -D GL_SILENCE_DEPRECATION=1 -D GLES_SILENCE_DEPRECATION=1 -D __clang_analyzer__ -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/WebCore-own-target-headers.hmap -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/WebCore-all-target-headers.hmap -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/include -I PAL -I ForwardingHeaders -I /usr/include/libxslt -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include/libxml2 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/WebCore -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/WebKitAdditions -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/WebKitAdditions -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/usr/local/include -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/webrtc -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/webrtc -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/webm -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/webm -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/PAL.build/PAL.build/DerivedSources -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/PAL.build/Release-iphonesimulator/PAL.build/DerivedSources -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebCore -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/DerivedSources-normal/arm64 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/DerivedSources/arm64 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/DerivedSources -F/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator -F/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include -internal-isystem /Users/buildbot/Library/Developer/Toolchains/swift-webkit.xctoolchain/usr/lib/clang/21/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/Frameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/SubFrameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/Library/Frameworks -Wno-trigraphs -Werror -Wno-missing-field-initializers -Wmissing-prototypes -Wunreachable-code -Wnon-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wsign-compare -Wno-shorten-64-to-32 -Wnewline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wall -Wc99-designator -Wconditional-uninitialized -Wextra -Wdeprecated-enum-enum-conversion -Wdeprecated-enum-float-conversion -Wenum-float-conversion -Wfinal-dtor-non-final-class -Wformat=2 -Wmisleading-indentation -Wpointer-to-int-cast -Wreorder-init-list -Wundef -Wunused-but-set-variable -Wvla -Werror=unguarded-availability -Wno-elaborated-enum-base -Wcast-qual -Wchar-subscripts -Wextra-tokens -Winit-self -Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough -Wvla -Wno-unknown-warning-option -Wliteral-conversion -Wthread-safety -Wno-profile-instr-out-of-date -Wno-profile-instr-unprofiled -Wno-backend-plugin -Wunsafe-buffer-usage -std=c++2b -fdeprecated-macro -ferror-limit 19 -fmacro-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden -stack-protector 1 -fblocks -fencode-extended-block-signature -fno-rtti -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fno-implicit-modules -fskip-odr-check-in-gmf -fpascal-strings -fmax-type-align=16 -fdiagnostics-show-note-include-stack -vectorize-loops -vectorize-slp -fsafe-buffer-usage-suggestions -analyzer-output=html -analyzer-config report-in-main-source-file=true -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -analyzer-checker optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker security.insecureAPI.UncheckedReturn -analyzer-checker security.insecureAPI.getpw -analyzer-checker security.insecureAPI.gets -analyzer-checker security.insecureAPI.mkstemp -analyzer-checker security.insecureAPI.mktemp -analyzer-disable-checker security.insecureAPI.rand -analyzer-disable-checker security.insecureAPI.strcpy -analyzer-checker security.insecureAPI.vfork -analyzer-disable-checker alpha,apiModeling,core,cplusplus,deadcode,debug,fuchsia,nullability,optin,osx,security,unix,webkit -analyzer-checker alpha.webkit.ForwardDeclChecker,alpha.webkit.MemoryUnsafeCastChecker,alpha.webkit.NoDeleteChecker,alpha.webkit.NoUncheckedPtrMemberChecker,alpha.webkit.NoUnretainedMemberChecker,alpha.webkit.RetainPtrCtorAdoptChecker,alpha.webkit.UncheckedCallArgsChecker,alpha.webkit.UncheckedLocalVarsChecker,alpha.webkit.UncountedCallArgsChecker,alpha.webkit.UncountedLocalVarsChecker,alpha.webkit.UnretainedCallArgsChecker,alpha.webkit.UnretainedLambdaCapturesChecker,alpha.webkit.UnretainedLocalVarsChecker,webkit.NoUncountedMemberChecker,webkit.RefCntblBaseVirtualDtor,webkit.UncountedLambdaCapturesChecker -analyzer-config max-nodes=10000000 -analyzer-config verbose-report-filename=true -fdwarf2-cfi-asm -o /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/WebCore/WebCore/normal/arm64/UnifiedSource415.plist -x c++ /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/WebCore/unified-sources/UnifiedSource415.cpp
1/*
2 * Copyright (C) 2012-2023 Apple Inc. All rights reserved.
3 * Copyright (C) 2014 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS IN..0TERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "config.h"
28#include "RenderMultiColumnFlow.h"
29
30#include "HitTestResult.h"
31#include "RenderBoxInlines.h"
32#include "RenderBoxModelObjectInlines.h"
33#include "RenderIterator.h"
34#include "RenderLayoutState.h"
35#include "RenderMultiColumnSet.h"
36#include "RenderMultiColumnSpannerPlaceholder.h"
37#include "RenderStyle+GettersInlines.h"
38#include "RenderTreeBuilder.h"
39#include "RenderView.h"
40#include "TransformState.h"
41#include <wtf/TZoneMallocInlines.h>
42
43namespace WebCore {
44
45WTF_MAKE_TZONE_ALLOCATED_IMPL(RenderMultiColumnFlow)::bmalloc::api::HeapRef RenderMultiColumnFlow::s_heapRef; const
TZoneSpecification RenderMultiColumnFlow::s_heapSpec = { &
RenderMultiColumnFlow::s_heapRef, TZoneSpecification::encodeSize
<RenderMultiColumnFlow>(), TZoneSpecification::encodeAlignment
<RenderMultiColumnFlow>(), TZoneSpecification::encodeCategory
<RenderMultiColumnFlow>(), ::bmalloc::api::compactAllocationMode
<RenderMultiColumnFlow>(), TZoneSpecification::encodeDescriptor
<RenderMultiColumnFlow>(), }; void* RenderMultiColumnFlow
::operatorNewSlow(size_t size) { if constexpr (::bmalloc::api
::compactAllocationMode<RenderMultiColumnFlow>() == CompactAllocationMode
::Compact) return ::bmalloc::api::tzoneAllocateCompactSlow(size
, s_heapSpec); return ::bmalloc::api::tzoneAllocateNonCompactSlow
(size, s_heapSpec); } using __makeBtzoneMallocedInlineMacroSemicolonifier
__attribute__((unused)) = int
;
46
47RenderMultiColumnFlow::RenderMultiColumnFlow(Document& document, RenderStyle&& style)
48 : RenderFragmentedFlow(Type::MultiColumnFlow, document, WTF::move(style))
49{
50 setFragmentedFlowState(FragmentedFlowState::InsideFlow);
51 ASSERT(isRenderMultiColumnFlow())((void)0);
52}
53
54RenderMultiColumnFlow::~RenderMultiColumnFlow() = default;
55
56ASCIILiteral RenderMultiColumnFlow::renderName() const
57{
58 return "RenderMultiColumnFlowThread"_s;
59}
60
61RenderMultiColumnSet* RenderMultiColumnFlow::firstMultiColumnSet() const
62{
63 for (RenderObject* sibling = nextSibling(); sibling; sibling = sibling->nextSibling()) {
64 if (auto* multiColumnSet = dynamicDowncast<RenderMultiColumnSet>(*sibling))
65 return multiColumnSet;
66 }
67 return nullptr;
68}
69
70RenderMultiColumnSet* RenderMultiColumnFlow::lastMultiColumnSet() const
71{
72 ASSERT(multiColumnBlockFlow())((void)0);
73
74 for (RenderObject* sibling = multiColumnBlockFlow()->lastChild(); sibling; sibling = sibling->previousSibling()) {
75 if (auto* multiColumnSet = dynamicDowncast<RenderMultiColumnSet>(*sibling))
76 return multiColumnSet;
77 }
78 return nullptr;
79}
80
81RenderBox* RenderMultiColumnFlow::firstColumnSetOrSpanner() const
82{
83 if (RenderObject* sibling = nextSibling()) {
84 ASSERT(is<RenderBox>(*sibling))((void)0);
85 ASSERT(is<RenderMultiColumnSet>(*sibling) || findColumnSpannerPlaceholder(downcast<RenderBox>(*sibling)))((void)0);
86 return downcast<RenderBox>(sibling);
87 }
88 return nullptr;
89}
90
91RenderBox* RenderMultiColumnFlow::nextColumnSetOrSpannerSiblingOf(const RenderBox* child)
92{
93 return child ? child->nextSiblingBox() : nullptr;
94}
95
96RenderBox* RenderMultiColumnFlow::previousColumnSetOrSpannerSiblingOf(const RenderBox* child)
97{
98 if (!child)
99 return nullptr;
100 if (auto* sibling = child->previousSiblingBox()) {
101 if (!is<RenderFragmentedFlow>(*sibling))
102 return sibling;
103 }
104 return nullptr;
105}
106
107RenderMultiColumnSpannerPlaceholder* RenderMultiColumnFlow::findColumnSpannerPlaceholder(const RenderBox& spanner) const
108{
109 return m_spannerMap.get(spanner);
110}
111
112void RenderMultiColumnFlow::layout()
113{
114 ASSERT(!m_inLayout)((void)0);
115 m_inLayout = true;
116 m_lastSetWorkedOn = nullptr;
117 if (RenderBox* first = firstColumnSetOrSpanner()) {
118 if (CheckedPtr multiColumnSet = dynamicDowncast<RenderMultiColumnSet>(*first)) {
119 m_lastSetWorkedOn = multiColumnSet.get();
120 multiColumnSet->beginFlow(this);
121 }
122 }
123 RenderFragmentedFlow::layout();
124 if (RenderMultiColumnSet* lastSet = lastMultiColumnSet()) {
125 if (!nextColumnSetOrSpannerSiblingOf(lastSet))
126 lastSet->endFlow(this, logicalHeight());
127 lastSet->expandToEncompassFragmentedFlowContentsIfNeeded();
128 }
129 m_inLayout = false;
130 m_lastSetWorkedOn = nullptr;
131}
132
133void RenderMultiColumnFlow::addFragmentToThread(RenderFragmentContainer* fragmentContainer)
134{
135 auto* columnSet = downcast<RenderMultiColumnSet>(fragmentContainer);
136 if (RenderMultiColumnSet* nextSet = columnSet->nextSiblingMultiColumnSet()) {
137 auto it = m_fragmentList.find(*nextSet);
138 ASSERT(it != m_fragmentList.end())((void)0);
139 m_fragmentList.insertBefore(it, *columnSet);
140 } else
141 m_fragmentList.add(*columnSet);
142 fragmentContainer->setIsValid(true);
143}
144
145void RenderMultiColumnFlow::willBeRemovedFromTree()
146{
147 // Detach all column sets from the flow thread. Cannot destroy them at this point, since they
148 // are siblings of this object, and there may be pointers to this object's sibling somewhere
149 // further up on the call stack.
150 for (RenderMultiColumnSet* columnSet = firstMultiColumnSet(); columnSet; columnSet = columnSet->nextSiblingMultiColumnSet())
151 columnSet->detachFragment();
152 RenderFragmentedFlow::willBeRemovedFromTree();
153}
154
155void RenderMultiColumnFlow::fragmentedFlowDescendantBoxLaidOut(RenderBox* descendant)
156{
157 CheckedPtr placeholder = dynamicDowncast<RenderMultiColumnSpannerPlaceholder>(*descendant);
158 if (!placeholder)
159 return;
160
161 CheckedPtr container = placeholder->containingBlock();
162
163 for (RenderBox* prev = previousColumnSetOrSpannerSiblingOf(placeholder->spanner()); prev; prev = previousColumnSetOrSpannerSiblingOf(prev)) {
164 if (CheckedPtr multiColumnSet = dynamicDowncast<RenderMultiColumnSet>(*prev)) {
165 multiColumnSet->endFlow(container.get(), placeholder->logicalTop());
166 break;
167 }
168 }
169
170 for (RenderBox* next = nextColumnSetOrSpannerSiblingOf(placeholder->spanner()); next; next = nextColumnSetOrSpannerSiblingOf(next)) {
171 if (CheckedPtr multiColumnSet = dynamicDowncast<RenderMultiColumnSet>(*next)) {
172 m_lastSetWorkedOn = multiColumnSet.get();
173 multiColumnSet->beginFlow(container.get());
174 break;
175 }
176 }
177}
178
179RenderBox::LogicalExtentComputedValues RenderMultiColumnFlow::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const
180{
181 // We simply remain at our intrinsic height.
182 return { logicalHeight, logicalTop, ComputedMarginValues() };
183}
184
185LayoutUnit RenderMultiColumnFlow::initialLogicalWidth() const
186{
187 return columnWidth();
188}
189
190void RenderMultiColumnFlow::setPageBreak(const RenderBlock* block, LayoutUnit offset, LayoutUnit spaceShortage)
191{
192 // Only positive values are interesting (and allowed) here. Zero space shortage may be reported
193 // when we're at the top of a column and the element has zero height. Ignore this, and also
194 // ignore any negative values, which may occur when we set an early break in order to honor
195 // widows in the next column.
196 if (spaceShortage <= 0)
197 return;
198
199 if (auto* multicolSet = downcast<RenderMultiColumnSet>(fragmentAtBlockOffset(block, offset)))
200 multicolSet->recordSpaceShortage(spaceShortage);
201}
202
203void RenderMultiColumnFlow::updateMinimumPageHeight(const RenderBlock* block, LayoutUnit offset, LayoutUnit minHeight)
204{
205 if (!hasValidFragmentInfo())
206 return;
207
208 if (auto* multicolSet = downcast<RenderMultiColumnSet>(fragmentAtBlockOffset(block, offset)))
209 multicolSet->updateMinimumColumnHeight(minHeight);
210}
211
212void RenderMultiColumnFlow::updateSpaceShortageForSizeContainment(const RenderBlock* block, LayoutUnit offset, LayoutUnit shortage)
213{
214 if (auto* multicolSet = downcast<RenderMultiColumnSet>(fragmentAtBlockOffset(block, offset)))
215 multicolSet->updateSpaceShortageForSizeContainment(shortage);
216}
217
218RenderFragmentContainer* RenderMultiColumnFlow::fragmentAtBlockOffset(const RenderBox* box, LayoutUnit offset, bool extendLastFragment) const
219{
220 if (!m_inLayout)
221 return RenderFragmentedFlow::fragmentAtBlockOffset(box, offset, extendLastFragment);
222
223 // Layout in progress. We are calculating the set heights as we speak, so the fragment range
224 // information is not up-to-date.
225
226 if (m_lastSetWorkedOn && m_lastSetWorkedOn->fragmentedFlow() != this)
227 m_lastSetWorkedOn = nullptr;
228
229 RenderMultiColumnSet* columnSet = m_lastSetWorkedOn ? m_lastSetWorkedOn.get() : firstMultiColumnSet();
230 if (!columnSet) {
231 // If there's no set, bail. This multicol is empty or only consists of spanners. There
232 // are no fragments.
233 return nullptr;
234 }
235 // The last set worked on is a good guess. But if we're not within the bounds, search for the
236 // right one.
237 if (offset < columnSet->logicalTopInFragmentedFlow()) {
238 do {
239 if (RenderMultiColumnSet* prev = columnSet->previousSiblingMultiColumnSet())
240 columnSet = prev;
241 else
242 break;
243 } while (offset < columnSet->logicalTopInFragmentedFlow());
244 } else {
245 while (offset >= columnSet->logicalBottomInFragmentedFlow()) {
246 RenderMultiColumnSet* next = columnSet->nextSiblingMultiColumnSet();
247 if (!next || !next->hasBeenFlowed())
248 break;
249 columnSet = next;
250 }
251 }
252 return columnSet;
253}
254
255void RenderMultiColumnFlow::setFragmentRangeForBox(const RenderBox& box, RenderFragmentContainer* startFragment, RenderFragmentContainer* endFragment)
256{
257 // Some column sets may have zero height, which means that two or more sets may start at the
258 // exact same flow thread position, which means that some parts of the code may believe that a
259 // given box lives in sets that it doesn't really live in. Make some adjustments here and
260 // include such sets if they are adjacent to the start and/or end fragments.
261 for (RenderMultiColumnSet* columnSet = downcast<RenderMultiColumnSet>(*startFragment).previousSiblingMultiColumnSet(); columnSet; columnSet = columnSet->previousSiblingMultiColumnSet()) {
262 if (columnSet->logicalHeightInFragmentedFlow())
263 break;
264 startFragment = columnSet;
265 }
266 for (RenderMultiColumnSet* columnSet = downcast<RenderMultiColumnSet>(*startFragment).nextSiblingMultiColumnSet(); columnSet; columnSet = columnSet->nextSiblingMultiColumnSet()) {
267 if (columnSet->logicalHeightInFragmentedFlow())
268 break;
269 endFragment = columnSet;
270 }
271
272 RenderFragmentedFlow::setFragmentRangeForBox(box, startFragment, endFragment);
273}
274
275bool RenderMultiColumnFlow::addForcedFragmentBreak(const RenderBlock* block, LayoutUnit offset, RenderBox* /*breakChild*/, bool /*isBefore*/, LayoutUnit* offsetBreakAdjustment)
276{
277 if (auto* multicolSet = downcast<RenderMultiColumnSet>(fragmentAtBlockOffset(block, offset))) {
278 multicolSet->addForcedBreak(offset);
279 if (offsetBreakAdjustment)
280 *offsetBreakAdjustment = pageLogicalHeightForOffset(offset) ? pageRemainingLogicalHeightForOffset(offset, IncludePageBoundary) : 0_lu;
281 return true;
282 }
283 return false;
284}
285
286LayoutSize RenderMultiColumnFlow::offsetFromContainer(const RenderElement& enclosingContainer, const LayoutPoint& physicalPoint, bool* offsetDependsOnPoint) const
287{
288 ASSERT(&enclosingContainer == container())((void)0);
289
290 if (offsetDependsOnPoint)
291 *offsetDependsOnPoint = true;
292
293 LayoutPoint translatedPhysicalPoint(physicalPoint);
294 if (RenderFragmentContainer* fragment = physicalTranslationFromFlowToFragment(translatedPhysicalPoint))
295 translatedPhysicalPoint.moveBy(fragment->topLeftLocation());
296
297 LayoutSize offset(translatedPhysicalPoint.x(), translatedPhysicalPoint.y());
298 if (auto* enclosingBox = dynamicDowncast<RenderBox>(enclosingContainer))
299 offset -= toLayoutSize(enclosingBox->scrollPosition());
300 return offset;
301}
302
303void RenderMultiColumnFlow::mapAbsoluteToLocalPoint(OptionSet<MapCoordinatesMode> mode, TransformState& transformState) const
304{
305 // First get the transform state's point into the block flow thread's physical coordinate space.
306 parent()->mapAbsoluteToLocalPoint(mode, transformState);
307 LayoutPoint transformPoint(transformState.mappedPoint());
308
309 // Now walk through each fragment.
310 const RenderMultiColumnSet* candidateColumnSet = nullptr;
311 LayoutPoint candidatePoint;
312 LayoutSize candidateContainerOffset;
313
314 for (const auto& columnSet : childrenOfType<RenderMultiColumnSet>(*parent())) {
315 candidateContainerOffset = columnSet.offsetFromContainer(*parent(), LayoutPoint());
316
317 candidatePoint = transformPoint - candidateContainerOffset;
318 candidateColumnSet = &columnSet;
319
320 // We really have no clue what to do with overflow. We'll just use the closest fragment to the point in that case.
321 LayoutUnit pointOffset = isHorizontalWritingMode() ? candidatePoint.y() : candidatePoint.x();
322 LayoutUnit fragmentOffset = isHorizontalWritingMode() ? columnSet.topLeftLocation().y() : columnSet.topLeftLocation().x();
323 if (pointOffset < fragmentOffset + columnSet.logicalHeight())
324 break;
325 }
326
327 // Once we have a good guess as to which fragment we hit tested through (and yes, this was just a heuristic, but it's
328 // the best we could do), then we can map from the fragment into the flow thread.
329 LayoutSize translationOffset = physicalTranslationFromFragmentToFlow(candidateColumnSet, candidatePoint) + candidateContainerOffset;
330 pushOntoTransformState(transformState, mode, nullptr, parent(), translationOffset, false);
331}
332
333LayoutSize RenderMultiColumnFlow::physicalTranslationFromFragmentToFlow(const RenderMultiColumnSet* columnSet, const LayoutPoint& physicalPoint) const
334{
335 LayoutPoint logicalPoint = columnSet->flipForWritingMode(physicalPoint);
336 LayoutPoint translatedPoint = columnSet->translateFragmentPointToFragmentedFlow(logicalPoint);
337 LayoutPoint physicalTranslatedPoint = columnSet->flipForWritingMode(translatedPoint);
338 return physicalPoint - physicalTranslatedPoint;
339}
340
341RenderFragmentContainer* RenderMultiColumnFlow::mapFromFlowToFragment(TransformState& transformState) const
342{
343 if (!hasValidFragmentInfo())
344 return nullptr;
345
346 // Get back into our local flow thread space.
347 LayoutRect boxRect = transformState.mappedQuad().enclosingBoundingBox();
348 flipForWritingMode(boxRect);
349
350 // FIXME: We need to refactor RenderObject::absoluteQuads to be able to split the quads across fragments,
351 // for now we just take the center of the mapped enclosing box and map it to a column.
352 LayoutPoint centerPoint = boxRect.center();
353 LayoutUnit centerLogicalOffset = isHorizontalWritingMode() ? centerPoint.y() : centerPoint.x();
354 auto* fragmentContainer = fragmentAtBlockOffset(this, centerLogicalOffset, true);
355 if (!fragmentContainer)
356 return nullptr;
357 transformState.move(physicalTranslationOffsetFromFlowToFragment(fragmentContainer, centerLogicalOffset));
358 return fragmentContainer;
359}
360
361LayoutSize RenderMultiColumnFlow::physicalTranslationOffsetFromFlowToFragment(const RenderFragmentContainer* fragmentContainer, const LayoutUnit logicalOffset) const
362{
363 // Now that we know which multicolumn set we hit, we need to get the appropriate translation offset for the column.
364 const auto* columnSet = downcast<RenderMultiColumnSet>(fragmentContainer);
365 LayoutPoint translationOffset = columnSet->columnTranslationForOffset(logicalOffset);
366
367 // Now we know how we want the rect to be translated into the fragment. At this point we're converting
368 // back to physical coordinates.
369 if (writingMode().isBlockFlipped()) {
370 LayoutRect portionRect(columnSet->fragmentedFlowPortionRect());
371 LayoutRect columnRect = columnSet->columnRectAt(0);
372 LayoutUnit physicalDeltaFromPortionBottom = logicalHeight() - columnSet->logicalBottomInFragmentedFlow();
373 if (isHorizontalWritingMode())
374 columnRect.setHeight(portionRect.height());
375 else
376 columnRect.setWidth(portionRect.width());
377 columnSet->flipForWritingMode(columnRect);
378 if (isHorizontalWritingMode())
379 translationOffset.move(0_lu, columnRect.y() - portionRect.y() - physicalDeltaFromPortionBottom);
380 else
381 translationOffset.move(columnRect.x() - portionRect.x() - physicalDeltaFromPortionBottom, 0_lu);
382 }
383
384 return LayoutSize(translationOffset.x(), translationOffset.y());
385}
386
387RenderFragmentContainer* RenderMultiColumnFlow::physicalTranslationFromFlowToFragment(LayoutPoint& physicalPoint) const
388{
389 if (!hasValidFragmentInfo())
390 return nullptr;
391
392 // Put the physical point into the flow thread's coordinate space.
393 LayoutPoint logicalPoint = flipForWritingMode(physicalPoint);
394
395 // Now get the fragment that we are in.
396 LayoutUnit logicalOffset = isHorizontalWritingMode() ? logicalPoint.y() : logicalPoint.x();
397 RenderFragmentContainer* fragmentContainer = fragmentAtBlockOffset(this, logicalOffset, true);
398 if (!fragmentContainer)
399 return nullptr;
400
401 // Translate to the coordinate space of the fragment.
402 LayoutSize translationOffset = physicalTranslationOffsetFromFlowToFragment(fragmentContainer, logicalOffset);
403
404 // Now shift the physical point into the fragment's coordinate space.
405 physicalPoint += translationOffset;
406
407 return fragmentContainer;
408}
409
410bool RenderMultiColumnFlow::isPageLogicalHeightKnown() const
411{
412 if (RenderMultiColumnSet* columnSet = lastMultiColumnSet())
413 return columnSet->columnHeightComputed();
414 return false;
415}
416
417bool RenderMultiColumnFlow::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
418{
419 // You cannot be inside an in-flow RenderFragmentedFlow without a corresponding DOM node. It's better to
420 // just let the ancestor figure out where we are instead.
421 if (hitTestAction == HitTestBlockBackground)
422 return false;
423 bool inside = RenderFragmentedFlow::nodeAtPoint(request, result, locationInContainer, accumulatedOffset, hitTestAction);
424 if (inside && !result.innerNode())
425 return false;
426 return inside;
427}
428
429bool RenderMultiColumnFlow::shouldCheckColumnBreaks() const
430{
431 if (!parent()->isRenderView())
432 return true;
433 return view().frameView().pagination().behavesLikeColumns;
Call argument for 'this' parameter is uncounted and unsafe
434}
435
436}