| File: | Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebCore/rendering/PositionedLayoutConstraints.cpp |
| Warning: | line 450, column 23 Local variable 'view' is uncounted and unsafe |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | * Copyright (C) 2025 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "PositionedLayoutConstraints.h" |
| 28 | |
| 29 | #include "AnchorPositionEvaluator.h" |
| 30 | #include "ContainerNodeInlines.h" |
| 31 | #include "InlineIteratorBoxInlines.h" |
| 32 | #include "InlineIteratorInlineBox.h" |
| 33 | #include "RenderGrid.h" |
| 34 | #include "RenderInline.h" |
| 35 | #include "RenderLayer.h" |
| 36 | #include "RenderStyle.h" |
| 37 | #include "RenderTableRow.h" |
| 38 | #include "RenderView.h" |
| 39 | #include "StylePositionArea.h" |
| 40 | |
| 41 | namespace WebCore { |
| 42 | |
| 43 | using namespace CSS::Literals; |
| 44 | |
| 45 | PositionedLayoutConstraints::PositionedLayoutConstraints(const RenderBox& renderer, LogicalBoxAxis selfAxis) |
| 46 | : PositionedLayoutConstraints(renderer, renderer.style(), selfAxis) |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | PositionedLayoutConstraints::PositionedLayoutConstraints(const RenderBox& renderer, const RenderStyle& style, LogicalBoxAxis selfAxis) |
| 51 | : m_renderer(renderer) |
| 52 | , m_container(downcast<RenderBoxModelObject>(*renderer.container())) // Using containingBlock() would be wrong for relpositioned inlines. |
| 53 | , m_containingWritingMode(m_container->writingMode()) |
| 54 | , m_writingMode(style.writingMode()) |
| 55 | , m_selfAxis(selfAxis) |
| 56 | , m_containingAxis(!isOrthogonal() ? selfAxis : oppositeAxis(selfAxis)) |
| 57 | , m_physicalAxis(selfAxis == LogicalBoxAxis::Inline ? m_writingMode.inlineAxis() : m_writingMode.blockAxis()) |
| 58 | , m_style(style) |
| 59 | , m_alignment(m_containingAxis == LogicalBoxAxis::Inline ? style.justifySelf().resolve() : style.alignSelf().resolve()) |
| 60 | , m_defaultAnchorBox(needsAnchor() ? Style::AnchorPositionEvaluator::defaultAnchorForBox(renderer) : nullptr) |
| 61 | , m_marginBefore { 0_css_px } |
| 62 | , m_marginAfter { 0_css_px } |
| 63 | , m_insetBefore { 0_css_px } |
| 64 | , m_insetAfter { 0_css_px } |
| 65 | { |
| 66 | ASSERT(m_container)((void)0); |
| 67 | |
| 68 | // Compute basic containing block info. |
| 69 | m_originalContainingRange = renderer.containingBlockRangeForPositioned(*m_container, m_physicalAxis); |
| 70 | m_containingRange = m_originalContainingRange; |
| 71 | m_containingInlineSize = (LogicalBoxAxis::Inline == m_containingAxis) ? m_containingRange.size() |
| 72 | : renderer.containingBlockRangeForPositioned(*m_container, oppositeAxis(m_physicalAxis)).size(); |
| 73 | |
| 74 | // Adjust for grid-area. |
| 75 | captureGridArea(); |
| 76 | |
| 77 | // Capture the anchor geometry and adjust for position-area. |
| 78 | captureAnchorGeometry(); |
| 79 | } |
| 80 | |
| 81 | void PositionedLayoutConstraints::computeInsets() |
| 82 | { |
| 83 | // Cache insets and margins, etc. |
| 84 | captureInsets(); |
| 85 | |
| 86 | if (m_useStaticPosition) |
| 87 | computeStaticPosition(); |
| 88 | |
| 89 | if (containingCoordsAreFlipped()) { |
| 90 | // Ideally this check is incorporated into captureInsets() but currently it needs to happen after computeStaticPosition() because containingCoordsAreFlipped() depends on m_useStaticPosition. |
| 91 | std::swap(m_marginBefore, m_marginAfter); |
| 92 | std::swap(m_insetBefore, m_insetAfter); |
| 93 | } |
| 94 | |
| 95 | // Compute the inset-modified containing block. |
| 96 | m_insetModifiedContainingRange = m_containingRange; |
| 97 | m_insetModifiedContainingRange.shiftMinEdgeBy(insetBeforeValue()); |
| 98 | m_insetModifiedContainingRange.shiftMaxEdgeBy(-insetAfterValue()); |
| 99 | } |
| 100 | |
| 101 | bool PositionedLayoutConstraints::needsAnchor() const |
| 102 | { |
| 103 | return !m_style.positionArea().isNone() || m_alignment.position() == ItemPosition::AnchorCenter; |
| 104 | } |
| 105 | |
| 106 | bool PositionedLayoutConstraints::containingCoordsAreFlipped() const |
| 107 | { |
| 108 | bool orthogonalOpposing = (m_containingAxis == LogicalBoxAxis::Inline && m_writingMode.isBlockFlipped()) || (m_containingAxis == LogicalBoxAxis::Block && m_containingWritingMode.isBlockFlipped()); |
| 109 | // FIXME: Static position has a confusing implementation. Leaving it alone for now. |
| 110 | return !m_useStaticPosition && ((isBlockOpposing() && m_containingAxis == LogicalBoxAxis::Block) || (isOrthogonal() && orthogonalOpposing)); |
| 111 | } |
| 112 | |
| 113 | void PositionedLayoutConstraints::captureInsets() |
| 114 | { |
| 115 | bool isHorizontal = BoxAxis::Horizontal == m_physicalAxis; |
| 116 | |
| 117 | if (isHorizontal) { |
| 118 | m_bordersPlusPadding = m_renderer->borderLeft() + m_renderer->paddingLeft() + m_renderer->paddingRight() + m_renderer->borderRight(); |
| 119 | m_useStaticPosition = m_style.left().isAuto() && m_style.right().isAuto() && !m_defaultAnchorBox; |
| 120 | } else { |
| 121 | m_bordersPlusPadding = m_renderer->borderTop() + m_renderer->paddingTop() + m_renderer->paddingBottom() + m_renderer->borderBottom(); |
| 122 | m_useStaticPosition = m_style.top().isAuto() && m_style.bottom().isAuto() && !m_defaultAnchorBox; |
| 123 | } |
| 124 | |
| 125 | if (LogicalBoxAxis::Inline == m_selfAxis) { |
| 126 | m_marginBefore = isHorizontal ? m_style.marginLeft() : m_style.marginTop(); |
| 127 | m_marginAfter = isHorizontal ? m_style.marginRight() : m_style.marginBottom(); |
| 128 | m_insetBefore = m_style.logicalLeft(); |
| 129 | m_insetAfter = m_style.logicalRight(); |
| 130 | } else { |
| 131 | m_marginBefore = m_style.marginBefore(); |
| 132 | m_marginAfter = m_style.marginAfter(); |
| 133 | m_insetBefore = m_style.logicalTop(); |
| 134 | m_insetAfter = m_style.logicalBottom(); |
| 135 | } |
| 136 | |
| 137 | if (m_defaultAnchorBox) { |
| 138 | // If the box uses anchor-center or position-area and does have a default anchor box, |
| 139 | // then it doesn't use static positioning. |
| 140 | m_useStaticPosition = false; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // MARK: - Adjustments to the containing block. |
| 145 | |
| 146 | void PositionedLayoutConstraints::expandToScrollableArea(LayoutRange& containingRange, const std::optional<ScrollPosition> fromScrollPosition) const |
| 147 | { |
| 148 | auto containingBlock = dynamicDowncast<RenderBox>(m_container.get()); |
| 149 | if (!containingBlock || !containingBlock->hasRenderOverflow() |
| 150 | || (!containingBlock->isRenderView() && !containingBlock->hasPotentiallyScrollableOverflow())) |
| 151 | return; |
| 152 | |
| 153 | auto scrollableArea = containingBlock->scrollablePaddingAreaOverflowRect(); |
| 154 | auto scrollableRange = BoxAxis::Horizontal == m_physicalAxis ? scrollableArea.xRange() : scrollableArea.yRange(); |
| 155 | containingRange.capMinEdgeTo(scrollableRange.min()); |
| 156 | containingRange.floorMaxEdgeTo(scrollableRange.max()); |
| 157 | |
| 158 | if (fromScrollPosition) { |
| 159 | auto scrollOffset = BoxAxis::Horizontal == m_physicalAxis ? fromScrollPosition->x() : fromScrollPosition->y(); |
| 160 | containingRange.moveBy(-scrollOffset); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | void PositionedLayoutConstraints::captureGridArea() |
| 165 | { |
| 166 | const CheckedPtr gridContainer = dynamicDowncast<RenderGrid>(m_container.get()); |
| 167 | if (!gridContainer) |
| 168 | return; |
| 169 | |
| 170 | if (LogicalBoxAxis::Inline == m_containingAxis) { |
| 171 | m_containingRange = gridContainer->gridAreaRangeForOutOfFlow(m_renderer, Style::GridTrackSizingDirection::Columns); |
| 172 | m_containingInlineSize = m_containingRange.size(); |
| 173 | } else { |
| 174 | m_containingRange = gridContainer->gridAreaRangeForOutOfFlow(m_renderer, Style::GridTrackSizingDirection::Rows); |
| 175 | m_containingInlineSize = gridContainer->gridAreaRangeForOutOfFlow(m_renderer, Style::GridTrackSizingDirection::Columns).size(); |
| 176 | } |
| 177 | |
| 178 | if (!startIsBefore()) { |
| 179 | auto containerSize = BoxAxis::Horizontal == m_physicalAxis |
| 180 | ? gridContainer->width() : gridContainer->height(); |
| 181 | m_containingRange.moveTo(containerSize - m_containingRange.max()); |
| 182 | } |
| 183 | |
| 184 | // FIXME: Get PositionedLayoutConstraints to work in pre-corrected coordinates instead of assuming it's wrong and doing "fixup" afterwards, so we don't have to "unfixup" here. |
| 185 | if (LogicalBoxAxis::Inline == m_containingAxis) { |
| 186 | if (BoxAxis::Horizontal == m_physicalAxis) { |
| 187 | if (gridContainer->shouldPlaceVerticalScrollbarOnLeft()) |
| 188 | m_containingRange.moveBy(-gridContainer->verticalScrollbarWidth()); |
| 189 | } else { |
| 190 | if (!m_containingWritingMode.isInlineTopToBottom()) |
| 191 | m_containingRange.moveBy(-gridContainer->horizontalScrollbarHeight()); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | LayoutRange PositionedLayoutConstraints::extractRange(LayoutRect anchorRect) |
| 197 | { |
| 198 | LayoutRange anchorRange; |
| 199 | if (BoxAxis::Horizontal == m_physicalAxis) |
| 200 | anchorRange.set(anchorRect.x(), anchorRect.width()); |
| 201 | else |
| 202 | anchorRange.set(anchorRect.y(), anchorRect.height()); |
| 203 | |
| 204 | if (m_containingWritingMode.isBlockFlipped() && LogicalBoxAxis::Block == m_containingAxis) { |
| 205 | // Coordinate fixup for flipped blocks. |
| 206 | anchorRange.moveTo(m_containingRange.max() - anchorRange.max() + m_container->borderAfter()); |
| 207 | } |
| 208 | return anchorRange; |
| 209 | } |
| 210 | |
| 211 | void PositionedLayoutConstraints::captureAnchorGeometry() |
| 212 | { |
| 213 | if (!m_defaultAnchorBox) |
| 214 | return; |
| 215 | |
| 216 | // Store the anchor geometry. |
| 217 | LayoutRect anchorRect = Style::AnchorPositionEvaluator::computeAnchorRectRelativeToContainingBlock(*m_defaultAnchorBox, *m_container, m_renderer.get()); |
| 218 | m_anchorArea = extractRange(anchorRect); |
| 219 | |
| 220 | // Adjust containing block for position-area. |
| 221 | if (m_style.positionArea().isNone()) |
| 222 | return; |
| 223 | m_containingRange = adjustForPositionArea(m_containingRange, m_anchorArea, m_physicalAxis); |
| 224 | |
| 225 | // Margin basis is always against the inline axis. |
| 226 | if (LogicalBoxAxis::Inline == m_containingAxis) { |
| 227 | m_containingInlineSize = m_containingRange.size(); |
| 228 | return; |
| 229 | } |
| 230 | // Else we're representing the block axis, but need the inline dimensions. |
| 231 | auto inlineAxis = oppositeAxis(m_physicalAxis); |
| 232 | LayoutRange inlineContainingBlock(m_container->borderLogicalLeft(), m_containingInlineSize); |
| 233 | auto inlineAnchorArea = BoxAxis::Horizontal == inlineAxis |
| 234 | ? LayoutRange { anchorRect.x(), anchorRect.width() } |
| 235 | : LayoutRange { anchorRect.y(), anchorRect.height() }; |
| 236 | m_containingInlineSize = adjustForPositionArea(inlineContainingBlock, inlineAnchorArea, inlineAxis).size(); |
| 237 | } |
| 238 | |
| 239 | LayoutRange PositionedLayoutConstraints::adjustForPositionArea(const LayoutRange rangeToAdjust, const LayoutRange anchorArea, const BoxAxis containerAxis) |
| 240 | { |
| 241 | ASSERT(!m_style.positionArea().isNone())((void)0); |
| 242 | ASSERT(m_defaultAnchorBox)((void)0); |
| 243 | ASSERT(needsAnchor())((void)0); |
| 244 | ASSERT(anchorArea.size() >= 0)((void)0); |
| 245 | |
| 246 | auto adjustedRange = rangeToAdjust; |
| 247 | switch (m_style.positionArea().tryValue()->coordMatchedTrackForAxis(containerAxis, m_containingWritingMode, m_writingMode)) { |
| 248 | case Style::PositionAreaTrack::Start: |
| 249 | adjustedRange.shiftMaxEdgeTo(anchorArea.min()); |
| 250 | adjustedRange.floorSizeFromMaxEdge(); |
| 251 | return adjustedRange; |
| 252 | case Style::PositionAreaTrack::SpanStart: |
| 253 | adjustedRange.shiftMaxEdgeTo(anchorArea.max()); |
| 254 | adjustedRange.capMinEdgeTo(anchorArea.min()); |
| 255 | return adjustedRange; |
| 256 | case Style::PositionAreaTrack::End: |
| 257 | adjustedRange.shiftMinEdgeTo(anchorArea.max()); |
| 258 | adjustedRange.floorSizeFromMinEdge(); |
| 259 | return adjustedRange; |
| 260 | case Style::PositionAreaTrack::SpanEnd: |
| 261 | adjustedRange.shiftMinEdgeTo(anchorArea.min()); |
| 262 | adjustedRange.floorMaxEdgeTo(anchorArea.max()); |
| 263 | return adjustedRange; |
| 264 | case Style::PositionAreaTrack::Center: |
| 265 | adjustedRange = anchorArea; |
| 266 | return adjustedRange; |
| 267 | case Style::PositionAreaTrack::SpanAll: |
| 268 | adjustedRange.capMinEdgeTo(anchorArea.min()); |
| 269 | adjustedRange.floorMaxEdgeTo(anchorArea.max()); |
| 270 | return adjustedRange; |
| 271 | default: |
| 272 | ASSERT_NOT_REACHED()((void)0); |
| 273 | return adjustedRange; |
| 274 | }; |
| 275 | } |
| 276 | |
| 277 | // MARK: - Resolving margins and alignment (after sizing). |
| 278 | |
| 279 | std::optional<LayoutUnit> PositionedLayoutConstraints::remainingSpaceForStaticAlignment(LayoutUnit itemSize) const |
| 280 | { |
| 281 | if (!m_useStaticPosition || m_containingAxis == LogicalBoxAxis::Inline) |
| 282 | return { }; |
| 283 | |
| 284 | if (auto* parent = dynamicDowncast<RenderGrid>(m_renderer->parent())) { |
| 285 | auto& itemStyle = m_renderer->style(); |
| 286 | auto itemResolvedAlignSelf = itemStyle.alignSelf().resolve(&parent->style()); |
| 287 | |
| 288 | switch (itemResolvedAlignSelf.position()) { |
| 289 | case ItemPosition::Center: |
| 290 | case ItemPosition::FlexEnd: |
| 291 | case ItemPosition::SelfEnd: |
| 292 | case ItemPosition::End: { |
| 293 | if (m_container.get() == parent) |
| 294 | return { }; |
| 295 | |
| 296 | // FIXME: This is probably not the correct set of writing mode checks. |
| 297 | |
| 298 | auto& containingBlockStyle = m_container->style(); |
| 299 | if (!containingBlockStyle.writingMode().isHorizontal()) |
| 300 | return { }; |
| 301 | |
| 302 | if (!containingBlockStyle.writingMode().isBidiLTR()) |
| 303 | return { }; |
| 304 | |
| 305 | auto& parentStyle = parent->style(); |
| 306 | if (!parentStyle.writingMode().isHorizontal()) |
| 307 | return { }; |
| 308 | |
| 309 | if (!parentStyle.writingMode().isBidiLTR()) |
| 310 | return { }; |
| 311 | |
| 312 | if (!itemStyle.writingMode().isHorizontal()) |
| 313 | return { }; |
| 314 | |
| 315 | if (!itemStyle.writingMode().isBidiLTR()) |
| 316 | return { }; |
| 317 | |
| 318 | if (itemResolvedAlignSelf.positionType() != ItemPositionType::NonLegacy) |
| 319 | return { }; |
| 320 | |
| 321 | if (itemResolvedAlignSelf.overflow() != OverflowAlignment::Default) |
| 322 | return { }; |
| 323 | |
| 324 | auto remainingSpace = parent->contentBoxLogicalHeight() - itemSize; |
| 325 | #if ASSERT_ENABLED0 |
| 326 | m_isEligibleForStaticRangeAlignment = remainingSpace >= 0_lu; |
| 327 | #endif |
| 328 | if (remainingSpace >= 0_lu) |
| 329 | return remainingSpace; |
| 330 | return { }; |
| 331 | } |
| 332 | default: |
| 333 | return { }; |
| 334 | } |
| 335 | } |
| 336 | return { }; |
| 337 | } |
| 338 | |
| 339 | // See CSS2 § 10.3.7-8 and 10.6.4-5. |
| 340 | void PositionedLayoutConstraints::resolvePosition(RenderBox::LogicalExtentComputedValues& computedValues) const |
| 341 | { |
| 342 | // Static position should have resolved one of our insets by now. |
| 343 | ASSERT(!m_useStaticPosition || !(m_insetBefore.isAuto() && m_insetAfter.isAuto()))((void)0); |
| 344 | |
| 345 | auto usedMarginBefore = marginBeforeValue(); |
| 346 | auto usedMarginAfter = marginAfterValue(); |
| 347 | auto alignmentShift = 0_lu; |
| 348 | |
| 349 | auto outerSize = usedMarginBefore + computedValues.extent + usedMarginAfter; |
| 350 | auto remainingSpace = insetModifiedContainingSize() - outerSize; |
| 351 | |
| 352 | bool honorAutoInsets = !m_defaultAnchorBox || m_alignment.isNormal(); |
| 353 | bool hasAutoBeforeInset = m_insetBefore.isAuto() && honorAutoInsets; |
| 354 | bool hasAutoAfterInset = m_insetAfter.isAuto() && honorAutoInsets; |
| 355 | bool hasAutoBeforeMargin = m_marginBefore.isAuto() && !m_defaultAnchorBox; |
| 356 | bool hasAutoAfterMargin = m_marginAfter.isAuto() && !m_defaultAnchorBox; |
| 357 | |
| 358 | if ((hasAutoBeforeMargin || hasAutoAfterMargin) && !hasAutoBeforeInset && !hasAutoAfterInset) { |
| 359 | // Distribute remainingSpace to auto margins. |
| 360 | if (hasAutoBeforeMargin && hasAutoAfterMargin) { |
| 361 | // Distribute usable space to both margins equally. |
| 362 | auto usableRemainingSpace = (LogicalBoxAxis::Inline == m_containingAxis) |
| 363 | ? std::max(0_lu, remainingSpace) : remainingSpace; |
| 364 | usedMarginBefore = usedMarginAfter = usableRemainingSpace / 2; |
| 365 | |
| 366 | // Distribute unused space to the end side. |
| 367 | auto unusedSpace = remainingSpace - (usedMarginBefore + usedMarginAfter); |
| 368 | if (startIsBefore()) |
| 369 | usedMarginAfter += unusedSpace; |
| 370 | else |
| 371 | usedMarginBefore += unusedSpace; |
| 372 | } else if (hasAutoBeforeMargin) |
| 373 | usedMarginBefore = remainingSpace; |
| 374 | else if (hasAutoAfterMargin) |
| 375 | usedMarginAfter = remainingSpace; |
| 376 | } else { |
| 377 | if (auto staticRemainingSpace = remainingSpaceForStaticAlignment(outerSize)) |
| 378 | alignmentShift = resolveAlignmentShift(*staticRemainingSpace, outerSize); |
| 379 | else if (hasAutoBeforeInset != hasAutoAfterInset) |
| 380 | alignmentShift = hasAutoAfterInset ? 0_lu : remainingSpace; |
| 381 | else // Align into remaining space. |
| 382 | alignmentShift = resolveAlignmentShift(remainingSpace, outerSize); |
| 383 | }; |
| 384 | |
| 385 | auto position = m_insetModifiedContainingRange.min() + usedMarginBefore + alignmentShift; |
| 386 | |
| 387 | computedValues.position = position; |
| 388 | if (LogicalBoxAxis::Inline == m_selfAxis) { |
| 389 | if (m_writingMode.isLogicalLeftInlineStart() == !containingCoordsAreFlipped()) { |
| 390 | computedValues.margins.start = usedMarginBefore; |
| 391 | computedValues.margins.end = usedMarginAfter; |
| 392 | } else { |
| 393 | computedValues.margins.start = usedMarginAfter; |
| 394 | computedValues.margins.end = usedMarginBefore; |
| 395 | } |
| 396 | } else if (containingCoordsAreFlipped()) { |
| 397 | computedValues.margins.before = usedMarginAfter; |
| 398 | computedValues.margins.after = usedMarginBefore; |
| 399 | } else { |
| 400 | computedValues.margins.before = usedMarginBefore; |
| 401 | computedValues.margins.after = usedMarginAfter; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | LayoutUnit PositionedLayoutConstraints::resolveAlignmentShift(LayoutUnit unusedSpace, LayoutUnit itemSize) const |
| 406 | { |
| 407 | bool startIsBefore = this->startIsBefore(); |
| 408 | bool isOverflowing = unusedSpace < 0_lu; |
| 409 | if (isOverflowing && OverflowAlignment::Safe == m_alignment.overflow()) |
| 410 | return startIsBefore ? 0_lu : unusedSpace; |
| 411 | |
| 412 | ItemPosition resolvedAlignment = resolveAlignmentValue(); |
| 413 | ASSERT(ItemPosition::Auto != resolvedAlignment)((void)0); |
| 414 | |
| 415 | LayoutUnit shift; |
| 416 | if (ItemPosition::AnchorCenter == resolvedAlignment) { |
| 417 | auto anchorCenterPosition = m_anchorArea.min() + (m_anchorArea.size() - itemSize) / 2; |
| 418 | shift = anchorCenterPosition - m_insetModifiedContainingRange.min(); |
| 419 | if (m_alignment.overflow() == OverflowAlignment::Safe) { |
| 420 | if (startIsBefore) { |
| 421 | if (shift < 0) |
| 422 | shift = 0; |
| 423 | } else { |
| 424 | if (shift > unusedSpace) |
| 425 | shift = unusedSpace; |
| 426 | } |
| 427 | } |
| 428 | if (!isOverflowing && OverflowAlignment::Default == m_alignment.overflow()) { |
| 429 | // Avoid introducing overflow of the IMCB. |
| 430 | if (shift < 0) |
| 431 | shift = 0; |
| 432 | else if (shift > unusedSpace) |
| 433 | shift = unusedSpace; |
| 434 | } |
| 435 | } else { |
| 436 | auto alignmentSpace = StyleSelfAlignmentData::adjustmentFromStartEdge(unusedSpace, resolvedAlignment, m_containingAxis, m_containingWritingMode, m_writingMode); |
| 437 | shift = startIsBefore ? alignmentSpace : unusedSpace - alignmentSpace; |
| 438 | } |
| 439 | |
| 440 | if (isOverflowing && ItemPosition::Normal != resolvedAlignment |
| 441 | && OverflowAlignment::Default == m_alignment.overflow()) { |
| 442 | // Allow overflow, but try to stay within the containing block. |
| 443 | // See https://www.w3.org/TR/css-align-3/#auto-safety-position |
| 444 | |
| 445 | auto containingRange = m_originalContainingRange; |
| 446 | if (m_defaultAnchorBox && PositionType::Fixed == m_style.position()) { |
| 447 | // We didn't modify the m_containingRange to include scrollable area for positioning, |
| 448 | // but we should allow it for overflow management if we can scroll to reach that overflow. |
| 449 | if (auto renderView = dynamicDowncast<RenderView>(m_container.get())) { |
| 450 | auto& view = renderView->frameView(); |
Local variable 'view' is uncounted and unsafe | |
| 451 | auto scrollPosition = view.constrainedScrollPosition(ScrollPosition(view.scrollPositionRespectingCustomFixedPosition())); |
| 452 | expandToScrollableArea(containingRange, scrollPosition); |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | auto spaceAfter = std::max(0_lu, containingRange.max() - m_insetModifiedContainingRange.max()); |
| 457 | auto spaceBefore = std::max(0_lu, m_insetModifiedContainingRange.min() - containingRange.min()); |
| 458 | |
| 459 | auto [allowsInfiniteOverflowBefore, allowsInfiniteOverflowAfter] = containerAllowsInfiniteOverflow(); |
| 460 | |
| 461 | if (startIsBefore) { |
| 462 | // Avoid overflow on the end side |
| 463 | spaceAfter += (unusedSpace - shift); |
| 464 | if (spaceAfter < 0 && !allowsInfiniteOverflowAfter) |
| 465 | shift += spaceAfter; |
| 466 | // Disallow overflow on the start side. |
| 467 | spaceBefore += shift; |
| 468 | if (spaceBefore < 0 && !allowsInfiniteOverflowBefore) |
| 469 | shift -= spaceBefore; |
| 470 | } else { |
| 471 | // Avoid overflow on the end side |
| 472 | spaceBefore += shift; |
| 473 | if (spaceBefore < 0 && !allowsInfiniteOverflowBefore) |
| 474 | shift -= spaceBefore; |
| 475 | // Disallow overflow on the start side. |
| 476 | spaceAfter += (unusedSpace - shift); |
| 477 | if (spaceAfter < 0 && !allowsInfiniteOverflowAfter) |
| 478 | shift += spaceAfter; |
| 479 | } |
| 480 | |
| 481 | } |
| 482 | return shift; |
| 483 | } |
| 484 | |
| 485 | ItemPosition PositionedLayoutConstraints::resolveAlignmentValue() const |
| 486 | { |
| 487 | if (m_useStaticPosition) { |
| 488 | #if ASSERT_ENABLED0 |
| 489 | ASSERT(m_isEligibleForStaticRangeAlignment)((void)0); |
| 490 | #endif |
| 491 | return m_style.alignSelf().resolve(m_renderer->parentStyle()).position(); |
| 492 | } |
| 493 | |
| 494 | auto alignmentPosition = [&] { |
| 495 | auto itemPosition = m_alignment.position(); |
| 496 | return (ItemPosition::Auto == itemPosition) ? ItemPosition::Normal : itemPosition; |
| 497 | }(); |
| 498 | |
| 499 | if (auto positionAreaValue = m_style.positionArea().tryValue(); positionAreaValue && ItemPosition::Normal == alignmentPosition) |
| 500 | alignmentPosition = positionAreaValue->defaultAlignmentForAxis(m_physicalAxis, m_containingWritingMode, m_writingMode); |
| 501 | |
| 502 | if (!m_defaultAnchorBox && alignmentPosition == ItemPosition::AnchorCenter) |
| 503 | return ItemPosition::Center; |
| 504 | return alignmentPosition; |
| 505 | } |
| 506 | |
| 507 | std::pair<bool, bool> PositionedLayoutConstraints::containerAllowsInfiniteOverflow() const |
| 508 | { |
| 509 | if (!(m_container->hasPotentiallyScrollableOverflow() || (is<RenderView>(m_container) && PositionType::Fixed != m_style.position()))) |
| 510 | return { false, false }; |
| 511 | auto* containerBox = dynamicDowncast<RenderBox>(m_container.get()); |
| 512 | ASSERT(containerBox)((void)0); |
| 513 | if (!containerBox) |
| 514 | return { false, false }; |
| 515 | |
| 516 | auto overflowLimits = containerBox->allowedLayoutOverflow(); // Already in flipped coordinates. |
| 517 | return m_physicalAxis == BoxAxis::Vertical |
| 518 | ? std::pair<bool, bool> { !overflowLimits.top(), !overflowLimits.bottom() } |
| 519 | : std::pair<bool, bool> { !overflowLimits.left(), !overflowLimits.right() }; |
| 520 | } |
| 521 | |
| 522 | bool PositionedLayoutConstraints::alignmentAppliesStretch(ItemPosition normalAlignment) const |
| 523 | { |
| 524 | auto alignmentPosition = m_alignment.position(); |
| 525 | if (m_style.positionArea().isNone() && (ItemPosition::Auto == alignmentPosition || ItemPosition::Normal == alignmentPosition)) |
| 526 | alignmentPosition = normalAlignment; |
| 527 | return ItemPosition::Stretch == alignmentPosition; |
| 528 | } |
| 529 | |
| 530 | bool NODELETE[[clang::annotate_type("webkit.nodelete")]] PositionedLayoutConstraints::insetFitsContent() const |
| 531 | { |
| 532 | return (m_insetBefore.isAuto() || m_insetAfter.isAuto()) |
| 533 | && !m_defaultAnchorBox; // position-area and align-center zero out auto insets. |
| 534 | } |
| 535 | |
| 536 | bool PositionedLayoutConstraints::needsGridAreaAdjustmentBeforeStaticPositioning() const |
| 537 | { |
| 538 | if (m_containingAxis == LogicalBoxAxis::Block) |
| 539 | return true; |
| 540 | |
| 541 | auto* parent = m_renderer->parent(); |
| 542 | // When the grid container is a parent we do not take the normal static positioning path. |
| 543 | if (!m_container->isRenderGrid() || parent == m_container) |
| 544 | return false; |
| 545 | |
| 546 | auto parentWritingMode = parent->writingMode(); |
| 547 | if (parentWritingMode.isLogicalLeftInlineStart() && !parentWritingMode.isOrthogonal(m_writingMode)) |
| 548 | return false; |
| 549 | |
| 550 | return true; |
| 551 | } |
| 552 | |
| 553 | // MARK: - Static Position Computation |
| 554 | |
| 555 | void PositionedLayoutConstraints::computeStaticPosition() |
| 556 | { |
| 557 | ASSERT(m_useStaticPosition)((void)0); |
| 558 | |
| 559 | if (is<RenderGrid>(m_container)) { |
| 560 | // Grid Containers have special behavior, see https://www.w3.org/TR/css-grid/#abspos |
| 561 | if (m_container.get() == m_renderer->parent()) { |
| 562 | // Fake the static layout right here so it integrates with grid-area properly. |
| 563 | m_useStaticPosition = false; // Avoid the static position code path. |
| 564 | m_insetBefore = 0_css_px; |
| 565 | m_insetAfter = 0_css_px; |
| 566 | |
| 567 | if (m_alignment.isNormal()) { |
| 568 | // This very likely was 'auto' before resolution, so re-resolve it against the static position containing block. |
| 569 | if (LogicalBoxAxis::Inline == m_containingAxis) { |
| 570 | m_alignment = m_style.justifySelf().resolve(&m_container->style()); |
| 571 | } else |
| 572 | m_alignment = m_style.alignSelf().resolve(&m_container->style()); |
| 573 | } |
| 574 | if (m_alignment.isNormal()) |
| 575 | m_alignment.setPosition(ItemPosition::Start); |
| 576 | if (OverflowAlignment::Default == m_alignment.overflow()) |
| 577 | m_alignment.setOverflow(OverflowAlignment::Unsafe); |
| 578 | |
| 579 | // Unclear if this is spec-compliant, but it is the current interop behavior. |
| 580 | if (m_marginBefore.isAuto()) |
| 581 | m_marginBefore = 0_css_px; |
| 582 | if (m_marginAfter.isAuto()) |
| 583 | m_marginAfter = 0_css_px; |
| 584 | return; |
| 585 | } |
| 586 | // Rewind grid-area adjustments and fall through to the existing static position code. |
| 587 | if (needsGridAreaAdjustmentBeforeStaticPositioning()) |
| 588 | m_containingRange.moveTo(m_originalContainingRange.min()); |
| 589 | } |
| 590 | |
| 591 | auto staticDistance = m_selfAxis == LogicalBoxAxis::Inline ? computedInlineStaticDistance() : computedBlockStaticDistance(); |
| 592 | auto shouldUseInsetBefore = [&] { |
| 593 | if (m_selfAxis == LogicalBoxAxis::Block) |
| 594 | return true; |
| 595 | auto parentWritingMode = m_renderer->parent()->writingMode(); |
| 596 | auto shouldUseInsetBefore = parentWritingMode.isOrthogonal(selfWritingMode()) || !parentWritingMode.isInlineFlipped(); // This is what trunk has. |
| 597 | if (!shouldUseInsetBefore) { |
| 598 | // FIXME: Figure out why. |
| 599 | shouldUseInsetBefore = m_containingWritingMode.isOrthogonal(parentWritingMode) && m_containingWritingMode.isBlockFlipped(); |
| 600 | } |
| 601 | return shouldUseInsetBefore; |
| 602 | }; |
| 603 | // Since the static position is computed during in flow layout, the computed |
| 604 | // position should already have zoom computed in. We need to divide out the zoom |
| 605 | // so that we get the same position when evaluating the inset. |
| 606 | if (shouldUseInsetBefore()) |
| 607 | m_insetBefore = Style::InsetEdge::Fixed { staticDistance / m_style.usedZoomForLength().value }; |
| 608 | else |
| 609 | m_insetAfter = Style::InsetEdge::Fixed { (containingSize() - staticDistance) / m_style.usedZoomForLength().value }; |
| 610 | } |
| 611 | |
| 612 | static LayoutPoint positionInContainer(const RenderBox& container, const RenderBox& child, LayoutPoint positionInChild) |
| 613 | { |
| 614 | auto containerWritingMode = container.writingMode(); |
| 615 | auto childWritingMode = child.writingMode(); |
| 616 | auto childInFlowOffset = child.writingMode().isHorizontal() ? child.offsetForInFlowPosition() : child.offsetForInFlowPosition().transposedSize(); |
| 617 | auto childLogicalLeft = childInFlowOffset.width() + child.logicalLeft(); |
| 618 | auto childLogicalTop = childInFlowOffset.height() + child.logicalTop(); |
| 619 | |
| 620 | if (containerWritingMode.isOrthogonal(childWritingMode)) { |
| 621 | auto topLeft = LayoutPoint { childLogicalLeft + positionInChild.x(), childLogicalTop + positionInChild.y() }; |
| 622 | if (childWritingMode.isBlockFlipped()) |
| 623 | topLeft.setY(childLogicalTop + child.logicalHeight() - positionInChild.y()); |
| 624 | if (containerWritingMode.isBlockFlipped()) |
| 625 | topLeft.setX(childLogicalLeft + child.logicalWidth() - positionInChild.x()); |
| 626 | return topLeft.transposedPoint(); |
| 627 | } |
| 628 | |
| 629 | if (containerWritingMode.isBlockOpposing(childWritingMode)) |
| 630 | return { childLogicalLeft + positionInChild.x(), childLogicalTop + child.logicalHeight() - positionInChild.y() }; |
| 631 | |
| 632 | return { childLogicalLeft + positionInChild.x(), childLogicalTop + positionInChild.y() }; |
| 633 | } |
| 634 | |
| 635 | static LayoutPoint staticDistance(const RenderBoxModelObject& container, const RenderBox& outOfFlowBox) |
| 636 | { |
| 637 | // Static position is relative to the candidate box's parent (it is computed during normal in-flow layout as if the candidate box was in-flow) |
| 638 | // 1. traverse the ancestor chain and convert static position relative to each container all the way up to the containing block |
| 639 | // 2. adjust the final static position with the containing block's border |
| 640 | // 3. pick x or y depending on what direction we are actually interested in (note that it's always the block directon from the |
| 641 | // candidate box's point of view but it could very well be the inline distance from the containing block's point of view.) |
| 642 | |
| 643 | auto initialStaticPosition = [&] { |
| 644 | // Static position is already in the coordinate system of the container (minus the flip in inline direction). |
| 645 | auto staticPosition = LayoutPoint { outOfFlowBox.layer()->staticInlinePosition(), outOfFlowBox.layer()->staticBlockPosition() }; |
| 646 | // We are relative to a RenderBox ancestor unless the containing block itself is an inline box. |
| 647 | auto* staticPositionContainingBlock = outOfFlowBox.parent(); |
| 648 | for (; staticPositionContainingBlock && !is<RenderBox>(staticPositionContainingBlock) && staticPositionContainingBlock != &container; staticPositionContainingBlock = staticPositionContainingBlock->container()) { } |
| 649 | if (CheckedPtr renderBox = dynamicDowncast<RenderBox>(staticPositionContainingBlock); renderBox && renderBox->writingMode().isInlineFlipped()) |
| 650 | staticPosition.setX(renderBox->logicalWidth() - staticPosition.x()); |
| 651 | return staticPosition; |
| 652 | }; |
| 653 | |
| 654 | auto staticPosition = LayoutPoint { }; |
| 655 | auto* child = &outOfFlowBox; |
| 656 | auto hasSeenNonInlineBoxContainer = false; |
| 657 | for (auto* ancestorContainer = child->parent(); ancestorContainer && ancestorContainer != &container; ancestorContainer = ancestorContainer->container()) { |
| 658 | CheckedPtr containerBox = dynamicDowncast<RenderBox>(*ancestorContainer); |
| 659 | if (!containerBox || is<RenderTableRow>(*containerBox)) |
| 660 | continue; |
| 661 | |
| 662 | staticPosition = child == &outOfFlowBox ? initialStaticPosition() : positionInContainer(*containerBox, *child, staticPosition); |
| 663 | child = containerBox.get(); |
| 664 | hasSeenNonInlineBoxContainer = true; |
| 665 | } |
| 666 | |
| 667 | if (!hasSeenNonInlineBoxContainer && is<RenderInline>(container)) { |
| 668 | // This is a simple case of when the containing block is formed by a positioned inline box with no block boxes in-between (e.g <span style="position: relative">) |
| 669 | return initialStaticPosition(); |
| 670 | } |
| 671 | |
| 672 | auto* containingBlock = dynamicDowncast<RenderBox>(container); |
| 673 | // m_insetBefore is expected to be relative to the padding box (while staticPosition is relative to the border box). |
| 674 | auto containingBlockBorderSize = LayoutSize { }; |
| 675 | if (containingBlock) |
| 676 | containingBlockBorderSize = containingBlock->writingMode().isInlineFlipped() ? LayoutSize(containingBlock->borderEnd(), containingBlock->borderBefore()) : LayoutSize(containingBlock->borderStart(), containingBlock->borderBefore()); |
| 677 | else { |
| 678 | containingBlock = child->containingBlock(); |
| 679 | ASSERT(containingBlock)((void)0); |
| 680 | // Note that we don't take the border here as we passed the real containing block. |
| 681 | } |
| 682 | |
| 683 | staticPosition = child == &outOfFlowBox ? initialStaticPosition() : positionInContainer(*containingBlock, *child, staticPosition); |
| 684 | staticPosition -= containingBlockBorderSize; |
| 685 | return staticPosition; |
| 686 | } |
| 687 | |
| 688 | LayoutUnit PositionedLayoutConstraints::computedInlineStaticDistance() const |
| 689 | { |
| 690 | // Note that at this point staticPosition is relative to the containing block (x is inline direction, y is block direction) which may not match with the box's slef writing mode. |
| 691 | auto staticPosition = staticDistance(*m_container, m_renderer.get()); |
| 692 | auto staticDistance = !isOrthogonal() ? staticPosition.x() : staticPosition.y(); |
| 693 | if (CheckedPtr gridContainer = dynamicDowncast<RenderGrid>(m_container.get())) { |
| 694 | // Special grid handling: move static distance back to relative to border box and adjust with our offset. |
| 695 | auto containingBlockBorderSize = !isOrthogonal() ? (gridContainer->writingMode().isInlineFlipped() ? gridContainer->borderEnd() : gridContainer->borderStart()) : gridContainer->borderBefore(); |
| 696 | staticDistance += containingBlockBorderSize; |
| 697 | staticDistance -= m_containingRange.min(); |
| 698 | } |
| 699 | return staticDistance; |
| 700 | } |
| 701 | |
| 702 | LayoutUnit PositionedLayoutConstraints::computedBlockStaticDistance() const |
| 703 | { |
| 704 | // Note that at this point staticPosition is relative to the containing block (x is inline direction, y is block direction) which may not match with the box's slef writing mode. |
| 705 | auto staticPosition = staticDistance(*m_container, m_renderer.get()); |
| 706 | return !isOrthogonal() ? staticPosition.y() : staticPosition.x(); |
| 707 | } |
| 708 | |
| 709 | static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] shouldInlineStaticDistanceAdjustedWithBoxHeight(WritingMode containinigBlockWritingMode, WritingMode parentWritingMode, WritingMode outOfFlowBoxWritingMode) |
| 710 | { |
| 711 | if (!containinigBlockWritingMode.isOrthogonal(parentWritingMode)) |
| 712 | return false; |
| 713 | |
| 714 | if (parentWritingMode.isOrthogonal(outOfFlowBoxWritingMode)) |
| 715 | return parentWritingMode.isBlockFlipped(); |
| 716 | |
| 717 | return containinigBlockWritingMode.isBlockFlipped() && !parentWritingMode.isInlineFlipped(); |
| 718 | } |
| 719 | |
| 720 | void PositionedLayoutConstraints::fixupLogicalLeftPosition(RenderBox::LogicalExtentComputedValues& computedValues) const |
| 721 | { |
| 722 | if (m_useStaticPosition) { |
| 723 | if (m_container.get() != m_renderer->parent() && shouldInlineStaticDistanceAdjustedWithBoxHeight(m_containingWritingMode, m_renderer->parent()->writingMode(), selfWritingMode())) |
| 724 | computedValues.position -= computedValues.extent; |
| 725 | return; |
| 726 | } |
| 727 | |
| 728 | if (m_writingMode.isHorizontal()) { |
| 729 | CheckedPtr containingBox = dynamicDowncast<RenderBox>(container()); |
| 730 | if (containingBox && containingBox->shouldPlaceVerticalScrollbarOnLeft()) |
| 731 | computedValues.position += containingBox->verticalScrollbarWidth(); |
| 732 | } |
| 733 | |
| 734 | // FIXME: This hack is needed to calculate the logical left position for a 'rtl' relatively |
| 735 | // positioned, inline because right now, it is using the logical left position |
| 736 | // of the first line box when really it should use the last line box. When |
| 737 | // this is fixed elsewhere, this adjustment should be removed. |
| 738 | |
| 739 | CheckedPtr renderInline = dynamicDowncast<RenderInline>(container()); |
| 740 | if (!renderInline || m_containingWritingMode.isLogicalLeftInlineStart()) |
| 741 | return; |
| 742 | |
| 743 | auto firstInlineBox = InlineIterator::lineLeftmostInlineBoxFor(*renderInline); |
| 744 | if (!firstInlineBox) |
| 745 | return; |
| 746 | |
| 747 | auto lastInlineBox = [&] { |
| 748 | auto inlineBox = firstInlineBox; |
| 749 | for (; inlineBox->nextInlineBoxLineRightward(); inlineBox.traverseInlineBoxLineRightward()) { } |
| 750 | return inlineBox; |
| 751 | }(); |
| 752 | if (firstInlineBox == lastInlineBox) |
| 753 | return; |
| 754 | |
| 755 | auto lastInlineBoxPaddingBoxVisualRight = lastInlineBox->logicalLeftIgnoringInlineDirection() + renderInline->borderLogicalLeft(); |
| 756 | // FIXME: This does not work with decoration break clone. |
| 757 | auto firstInlineBoxPaddingBoxVisualRight = firstInlineBox->logicalLeftIgnoringInlineDirection(); |
| 758 | auto adjustment = lastInlineBoxPaddingBoxVisualRight - firstInlineBoxPaddingBoxVisualRight; |
| 759 | computedValues.position += adjustment - m_containingRange.min(); |
| 760 | } |
| 761 | |
| 762 | // FIXME: Let's move this over to RenderBoxModelObject and collapse some of the logic here. |
| 763 | static bool NODELETE[[clang::annotate_type("webkit.nodelete")]] shouldBlockStaticDistanceAdjustedWithBoxHeight(const RenderBoxModelObject& containingBlock, const RenderElement& parent, WritingMode outOfFlowBoxWritingMode) |
| 764 | { |
| 765 | // This is where we check if the final static position needs to be adjusted with the height of the out-of-flow box. |
| 766 | // In ::computeBlockStaticDistance we convert the static position relative to the containing block but in some cases |
| 767 | // this final static position still points to the wrong side of the box (i.e. at computeBlockStaticDistance we don't know yet the height |
| 768 | // which may contribute to the logical top position. see details below.) |
| 769 | |
| 770 | auto parentWritingMode = parent.writingMode(); |
| 771 | auto containinigBlockWritingMode = containingBlock.writingMode(); |
| 772 | |
| 773 | if (containinigBlockWritingMode.blockDirection() == parentWritingMode.blockDirection() && parentWritingMode.blockDirection() == outOfFlowBoxWritingMode.blockDirection()) |
| 774 | return false; |
| 775 | |
| 776 | auto isParentInlineFlipped = parentWritingMode.isInlineFlipped(); |
| 777 | if (containinigBlockWritingMode.isOrthogonal(outOfFlowBoxWritingMode)) { |
| 778 | if (&containingBlock == &parent) { |
| 779 | // <div id=containinigBlock class=rtl> |
| 780 | // <div id=outOfFlowBox class=ltr> |
| 781 | return isParentInlineFlipped; |
| 782 | } |
| 783 | |
| 784 | if (!containinigBlockWritingMode.isOrthogonal(parentWritingMode)) |
| 785 | return isParentInlineFlipped; |
| 786 | |
| 787 | return parentWritingMode.isBlockFlipped(); |
| 788 | } |
| 789 | |
| 790 | ASSERT(containinigBlockWritingMode.blockDirection() == outOfFlowBoxWritingMode.blockDirection() || containinigBlockWritingMode.isBlockOpposing(outOfFlowBoxWritingMode))((void)0); |
| 791 | if (!parentWritingMode.isOrthogonal(containinigBlockWritingMode)) { |
| 792 | // inline direction does not matter as all participants are on the same axis. |
| 793 | if (containinigBlockWritingMode.blockDirection() == outOfFlowBoxWritingMode.blockDirection()) { |
| 794 | // <div id=containinigBlock class=vrl> |
| 795 | // <div id=parent class=vlr> |
| 796 | // <div id=outOfFlowBox class=vrl> |
| 797 | return true; |
| 798 | } |
| 799 | |
| 800 | // <div id=containinigBlock class=vlr> |
| 801 | // <div id=parent class=vrl> |
| 802 | // <div id=outOfFlowBox class=vrl> |
| 803 | return parentWritingMode.isBlockOpposing(containinigBlockWritingMode); |
| 804 | } |
| 805 | |
| 806 | // Orhogonal parent. |
| 807 | // <div id=containinigBlock class=vrl> |
| 808 | // <div id=parent class=htb> |
| 809 | // <div id=outOfFlowBox class=vlr> |
| 810 | return containinigBlockWritingMode.isBlockFlipped() != isParentInlineFlipped; |
| 811 | } |
| 812 | |
| 813 | void PositionedLayoutConstraints::adjustLogicalTopWithLogicalHeightIfNeeded(RenderBox::LogicalExtentComputedValues& computedValues) const |
| 814 | { |
| 815 | if (!m_useStaticPosition || m_selfAxis != LogicalBoxAxis::Block) |
| 816 | return; |
| 817 | if (shouldBlockStaticDistanceAdjustedWithBoxHeight(*m_container, *m_renderer->parent(), m_writingMode)) |
| 818 | computedValues.position -= computedValues.extent; |
| 819 | } |
| 820 | |
| 821 | } |