void RenderTextTrackCue::repositionCueSnapToLinesSet() { InlineFlowBox* firstLineBox; LayoutUnit step; LayoutUnit position; if (!initializeLayoutParameters(firstLineBox, step, position)) return; bool switched; placeBoxInDefaultPosition(position, switched); // 11. Step loop: If none of the boxes in boxes would overlap any of the boxes // in output and all the boxes in output are within the video's rendering area // then jump to the step labeled done positioning. while (isOutside() || isOverlapping()) { if (!shouldSwitchDirection(firstLineBox, step)) // 13. Move all the boxes in boxes ... // 14. Jump back to the step labeled step loop. moveBoxesByStep(step); else if (!switchDirection(switched, step)) break; // 19. Jump back to the step labeled step loop. } // Acommodate extra top and bottom padding, border or margin. // Note: this is supported only for internal UA styling, not through the cue selector. if (hasInlineDirectionBordersPaddingOrMargin()) moveIfNecessaryToKeepWithinContainer(); }
void RenderVTTCue::repositionCueSnapToLinesSet() { InlineFlowBox* firstLineBox; LayoutUnit step; LayoutUnit position; if (!findFirstLineBox(firstLineBox)) return; if (!initializeLayoutParameters(firstLineBox, step, position)) return; bool switched; placeBoxInDefaultPosition(position, switched); // 11. Step loop: If none of the boxes in boxes would overlap any of the boxes // in output and all the boxes in output are within the video's rendering area // then jump to the step labeled done positioning. while (isOutside() || isOverlapping()) { if (!shouldSwitchDirection(firstLineBox, step)) { // 13. Move all the boxes in boxes ... // 14. Jump back to the step labeled step loop. moveBoxesByStep(step); } else if (!switchDirection(switched, step)) { break; } // 19. Jump back to the step labeled step loop. } // Acommodate extra top and bottom padding, border or margin. // Note: this is supported only for internal UA styling, not through the cue selector. if (hasInlineDirectionBordersPaddingOrMargin()) { IntRect containerRect = containingBlock()->absoluteBoundingBoxRect(); IntRect cueRect = absoluteBoundingBoxRect(); int topOverflow = cueRect.y() - containerRect.y(); int bottomOverflow = containerRect.y() + containerRect.height() - cueRect.y() - cueRect.height(); int adjustment = 0; if (topOverflow < 0) adjustment = -topOverflow; else if (bottomOverflow < 0) adjustment = bottomOverflow; if (adjustment) setY(y() + adjustment); } }