当前位置: 首页>>代码示例>>C++>>正文


C++ WritingMode::ParallelAxisStartsOnSameSide方法代码示例

本文整理汇总了C++中WritingMode::ParallelAxisStartsOnSameSide方法的典型用法代码示例。如果您正苦于以下问题:C++ WritingMode::ParallelAxisStartsOnSameSide方法的具体用法?C++ WritingMode::ParallelAxisStartsOnSameSide怎么用?C++ WritingMode::ParallelAxisStartsOnSameSide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WritingMode的用法示例。


在下文中一共展示了WritingMode::ParallelAxisStartsOnSameSide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: alignAreaSize

/**
 * This function returns the offset of an abs/fixed-pos child's static
 * position, with respect to the "start" corner of its alignment container,
 * according to CSS Box Alignment.  This function only operates in a single
 * axis at a time -- callers can choose which axis via the |aAbsPosCBAxis|
 * parameter.
 *
 * @param aKidReflowInput The ReflowInput for the to-be-aligned abspos child.
 * @param aKidSizeInAbsPosCBWM The child frame's size (after it's been given
 *                             the opportunity to reflow), in terms of the
 *                             containing block's WritingMode.
 * @param aPlaceholderContainer The parent of the child frame's corresponding
 *                              placeholder frame, cast to a nsContainerFrame.
 *                              (This will help us choose which alignment enum
 *                              we should use for the child.)
 * @param aAbsPosCBWM The child frame's containing block's WritingMode.
 * @param aAbsPosCBAxis The axis (of the containing block) that we should
 *                      be doing this computation for.
 */
static nscoord
OffsetToAlignedStaticPos(const ReflowInput& aKidReflowInput,
                         const LogicalSize& aKidSizeInAbsPosCBWM,
                         nsContainerFrame* aPlaceholderContainer,
                         WritingMode aAbsPosCBWM,
                         LogicalAxis aAbsPosCBAxis)
{
  if (!aPlaceholderContainer) {
    // (The placeholder container should be the thing that kicks this whole
    // process off, by setting PLACEHOLDER_STATICPOS_NEEDS_CSSALIGN.  So it
    // should exist... but bail gracefully if it doesn't.)
    NS_ERROR("Missing placeholder-container when computing a "
             "CSS Box Alignment static position");
    return 0;
  }

  // (Most of this function is simply preparing args that we'll pass to
  // AlignJustifySelf at the end.)

  // NOTE: Our alignment container is aPlaceholderContainer's content-box
  // (or an area within it, if aPlaceholderContainer is a grid). So, we'll
  // perform most of our arithmetic/alignment in aPlaceholderContainer's
  // WritingMode. For brevity, we use the abbreviation "pc" for "placeholder
  // container" in variables below.
  WritingMode pcWM = aPlaceholderContainer->GetWritingMode();

  // Find what axis aAbsPosCBAxis corresponds to, in placeholder's parent's
  // writing-mode.
  LogicalAxis pcAxis = (pcWM.IsOrthogonalTo(aAbsPosCBWM)
                        ? GetOrthogonalAxis(aAbsPosCBAxis)
                        : aAbsPosCBAxis);

  nsIAtom* parentType = aPlaceholderContainer->GetType();
  LogicalSize alignAreaSize(pcWM);
  if (parentType == nsGkAtoms::flexContainerFrame) {
    alignAreaSize = aPlaceholderContainer->GetLogicalSize(pcWM);
    LogicalMargin pcBorderPadding =
      aPlaceholderContainer->GetLogicalUsedBorderAndPadding(pcWM);
    alignAreaSize -= pcBorderPadding.Size(pcWM);
  } else {
    NS_ERROR("Unsupported container for abpsos CSS Box Alignment");
    return 0; // (leave the child at the start of its alignment container)
  }

  nscoord alignAreaSizeInAxis = (pcAxis == eLogicalAxisInline)
    ? alignAreaSize.ISize(pcWM)
    : alignAreaSize.BSize(pcWM);

  AlignJustifyFlags flags = AlignJustifyFlags::eIgnoreAutoMargins;
  uint16_t alignConst =
    aPlaceholderContainer->CSSAlignmentForAbsPosChild(aKidReflowInput, pcAxis);
  // XXXdholbert: Handle <overflow-position> in bug 1311892 (by conditionally
  // setting AlignJustifyFlags::eOverflowSafe in |flags|.)  For now, we behave
  // as if "unsafe" was the specified value (which is basically equivalent to
  // the default behavior, when no value is specified -- though the default
  // behavior also has some [at-risk] extra nuance about scroll containers...)
  // For now we ignore & strip off <overflow-position> bits, until bug 1311892.
  alignConst &= ~NS_STYLE_ALIGN_FLAG_BITS;

  // Find out if placeholder-container & the OOF child have the same start-sides
  // in the placeholder-container's pcAxis.
  WritingMode kidWM = aKidReflowInput.GetWritingMode();
  if (pcWM.ParallelAxisStartsOnSameSide(pcAxis, kidWM)) {
    flags |= AlignJustifyFlags::eSameSide;
  }

  // (baselineAdjust is unused. CSSAlignmentForAbsPosChild() should've
  // converted 'baseline'/'last baseline' enums to their fallback values.)
  const nscoord baselineAdjust = nscoord(0);

  // AlignJustifySelf operates in the kid's writing mode, so we need to
  // represent the child's size and the desired axis in that writing mode:
  LogicalSize kidSizeInOwnWM = aKidSizeInAbsPosCBWM.ConvertTo(kidWM,
                                                              aAbsPosCBWM);
  LogicalAxis kidAxis = (kidWM.IsOrthogonalTo(aAbsPosCBWM)
                         ? GetOrthogonalAxis(aAbsPosCBAxis)
                         : aAbsPosCBAxis);

  nscoord offset =
    CSSAlignUtils::AlignJustifySelf(alignConst, kidAxis, flags,
                                    baselineAdjust, alignAreaSizeInAxis,
//.........这里部分代码省略.........
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:101,代码来源:nsAbsoluteContainingBlock.cpp


注:本文中的WritingMode::ParallelAxisStartsOnSameSide方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。