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


C++ LayoutUnit函数代码示例

本文整理汇总了C++中LayoutUnit函数的典型用法代码示例。如果您正苦于以下问题:C++ LayoutUnit函数的具体用法?C++ LayoutUnit怎么用?C++ LayoutUnit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: ASSERT

void LayoutTextControl::computePreferredLogicalWidths() {
  ASSERT(preferredLogicalWidthsDirty());

  m_minPreferredLogicalWidth = LayoutUnit();
  m_maxPreferredLogicalWidth = LayoutUnit();
  const ComputedStyle& styleToUse = styleRef();

  if (styleToUse.logicalWidth().isFixed() &&
      styleToUse.logicalWidth().value() >= 0)
    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth =
        adjustContentBoxLogicalWidthForBoxSizing(
            styleToUse.logicalWidth().value());
  else
    computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth,
                                  m_maxPreferredLogicalWidth);

  if (styleToUse.logicalMinWidth().isFixed() &&
      styleToUse.logicalMinWidth().value() > 0) {
    m_maxPreferredLogicalWidth = std::max(
        m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                        styleToUse.logicalMinWidth().value()));
    m_minPreferredLogicalWidth = std::max(
        m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                        styleToUse.logicalMinWidth().value()));
  }

  if (styleToUse.logicalMaxWidth().isFixed()) {
    m_maxPreferredLogicalWidth = std::min(
        m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                        styleToUse.logicalMaxWidth().value()));
    m_minPreferredLogicalWidth = std::min(
        m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                        styleToUse.logicalMaxWidth().value()));
  }

  LayoutUnit toAdd = borderAndPaddingLogicalWidth();

  m_minPreferredLogicalWidth += toAdd;
  m_maxPreferredLogicalWidth += toAdd;

  clearPreferredLogicalWidthsDirty();
}
开发者ID:ollie314,项目名称:chromium,代码行数:42,代码来源:LayoutTextControl.cpp

示例2: TEST_F

TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowHidden) {
  setBodyInnerHTML(
      "<div id='container' style='writing-mode: vertical-rl; position: "
      "absolute; top: 111px; left: 222px;"
      "    border: solid red; border-width: 10px 20px 30px 40px;"
      "    overflow: hidden; width: 50px; height: 80px'>"
      "    <div id='target' style='box-shadow: 40px 20px black; width: 100px; "
      "height: 90px'></div>"
      "    <div style='width: 100px; height: 100px'></div>"
      "</div>");

  LayoutBlock* container =
      toLayoutBlock(getLayoutObjectByElementId("container"));
  EXPECT_EQ(LayoutUnit(), container->scrollTop());
  // The initial scroll offset is to the left-most because of flipped blocks
  // writing mode.
  // 150 = total_layout_overflow(100 + 100) - width(50)
  EXPECT_EQ(LayoutUnit(150), container->scrollLeft());
  container->setScrollTop(LayoutUnit(7));
  container->setScrollLeft(LayoutUnit(82));  // Scroll to the right by 8 pixels.
  document().view()->updateAllLifecyclePhases();

  LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
  LayoutRect targetVisualRect = target->localVisualRect();
  // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the
  // origin)
  // 140 = width(100) + box_shadow_offset_x(40)
  // 110 = height(90) + box_shadow_offset_y(20)
  EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetVisualRect);

  LayoutRect rect = targetVisualRect;
  target->flipForWritingMode(rect);
  EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect));
  // This rect is in physical coordinates of target.
  EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect);

  rect = targetVisualRect;
  target->flipForWritingMode(rect);
  EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect));
  // 58 = target_physical_x(100) + container_border_left(40) - scroll_left(58)
  EXPECT_EQ(LayoutRect(-10, 10, 140, 110), rect);
}
开发者ID:mirror,项目名称:chromium,代码行数:42,代码来源:VisualRectMappingTest.cpp

示例3: ASSERT

LayoutSize LayoutListMarker::imageBulletSize() const
{
    ASSERT(isImage());

    // FIXME: This is a somewhat arbitrary default width. Generated images for markers really won't
    // become particularly useful until we support the CSS3 marker pseudoclass to allow control over
    // the width and height of the marker box.
    LayoutUnit bulletWidth = style()->fontMetrics().ascent() / LayoutUnit(2);
    LayoutSize defaultBulletSize(bulletWidth, bulletWidth);
    return calculateImageIntrinsicDimensions(m_image.get(), defaultBulletSize, DoNotScaleByEffectiveZoom);
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:11,代码来源:LayoutListMarker.cpp

示例4: getLayoutsList

LayoutUnit X11Helper::getCurrentLayout()
{
	QList<LayoutUnit> currentLayouts = getLayoutsList();
	unsigned int group = X11Helper::getGroup();
	if( group < (unsigned int)currentLayouts.size() )
		return currentLayouts[group];

	kWarning() << "Current group number" << group << "is outside of current layout list" <<
						getLayoutsListAsString(currentLayouts);
	return LayoutUnit();
}
开发者ID:ypid,项目名称:ktouch,代码行数:11,代码来源:x11_helper.cpp

示例5: LayoutRect

LayoutRect LayoutReplaced::localSelectionRect() const {
    if (getSelectionState() == SelectionNone)
        return LayoutRect();

    if (!inlineBoxWrapper()) {
        // We're a block-level replaced element.  Just return our own dimensions.
        return LayoutRect(LayoutPoint(), size());
    }

    RootInlineBox& root = inlineBoxWrapper()->root();
    LayoutUnit newLogicalTop =
        root.block().style()->isFlippedBlocksWritingMode()
        ? inlineBoxWrapper()->logicalBottom() - root.selectionBottom()
        : root.selectionTop() - inlineBoxWrapper()->logicalTop();
    if (root.block().style()->isHorizontalWritingMode())
        return LayoutRect(LayoutUnit(), newLogicalTop, size().width(),
                          root.selectionHeight());
    return LayoutRect(newLogicalTop, LayoutUnit(), root.selectionHeight(),
                      size().height());
}
开发者ID:mirror,项目名称:chromium,代码行数:20,代码来源:LayoutReplaced.cpp

示例6: availableWidthAtOffset

inline static LayoutUnit availableWidthAtOffset(
    LineLayoutBlockFlow block,
    const LayoutUnit& offset,
    IndentTextOrNot indentText,
    LayoutUnit& newLineLeft,
    LayoutUnit& newLineRight,
    const LayoutUnit& lineHeight = LayoutUnit()) {
  newLineLeft = block.logicalLeftOffsetForLine(offset, indentText, lineHeight);
  newLineRight =
      block.logicalRightOffsetForLine(offset, indentText, lineHeight);
  return (newLineRight - newLineLeft).clampNegativeToZero();
}
开发者ID:mirror,项目名称:chromium,代码行数:12,代码来源:LineWidth.cpp

示例7: LayoutUnit

void LayoutSVGForeignObject::computeLogicalHeight(
    LayoutUnit,
    LayoutUnit logicalTop,
    LogicalExtentComputedValues& computedValues) const {
  // FIXME: Investigate in size rounding issues
  // FIXME: Remove unnecessary rounding when layout is off ints:
  // webkit.org/b/63656
  // FIXME: Is this correct for vertical writing mode?
  computedValues.m_extent =
      LayoutUnit(static_cast<int>(roundf(m_viewport.height())));
  computedValues.m_position = logicalTop;
}
开发者ID:mirror,项目名称:chromium,代码行数:12,代码来源:LayoutSVGForeignObject.cpp

示例8: style

void LayoutListMarker::updateMargins()
{
    const FontMetrics& fontMetrics = style()->fontMetrics();

    LayoutUnit marginStart;
    LayoutUnit marginEnd;

    if (isInside()) {
        if (isImage()) {
            marginEnd = LayoutUnit(cMarkerPaddingPx);
        } else {
            switch (listStyleCategory()) {
            case ListStyleCategory::Symbol:
                marginStart = LayoutUnit(-1);
                marginEnd = fontMetrics.ascent() - minPreferredLogicalWidth() + 1;
                break;
            default:
                break;
            }
        }
    } else {
        if (style()->isLeftToRightDirection()) {
            if (isImage()) {
                marginStart = -minPreferredLogicalWidth() - cMarkerPaddingPx;
            } else {
                int offset = fontMetrics.ascent() * 2 / 3;
                switch (listStyleCategory()) {
                case ListStyleCategory::None:
                    break;
                case ListStyleCategory::Symbol:
                    marginStart = LayoutUnit(-offset - cMarkerPaddingPx - 1);
                    break;
                default:
                    marginStart = m_text.isEmpty() ? LayoutUnit() : -minPreferredLogicalWidth();
                }
            }
            marginEnd = -marginStart - minPreferredLogicalWidth();
        } else {
            if (isImage()) {
                marginEnd = LayoutUnit(cMarkerPaddingPx);
            } else {
                int offset = fontMetrics.ascent() * 2 / 3;
                switch (listStyleCategory()) {
                case ListStyleCategory::None:
                    break;
                case ListStyleCategory::Symbol:
                    marginEnd = offset + cMarkerPaddingPx + 1 - minPreferredLogicalWidth();
                    break;
                default:
                    marginEnd = LayoutUnit();
                }
            }
            marginStart = -marginEnd - minPreferredLogicalWidth();
        }

    }

    mutableStyleRef().setMarginStart(Length(marginStart, Fixed));
    mutableStyleRef().setMarginEnd(Length(marginEnd, Fixed));
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:60,代码来源:LayoutListMarker.cpp

示例9: lookupLocalized

void LayoutConfig::updateLayoutCommand()
{
    QString setxkbmap;
    QString layoutDisplayName;
    QListViewItem *sel = widget->listLayoutsDst->selectedItem();

    if(sel != NULL)
    {
        QString kbdLayout = sel->text(LAYOUT_COLUMN_MAP);
        QString variant = widget->comboVariant->currentText();
        if(variant == DEFAULT_VARIANT_NAME)
            variant = "";

        setxkbmap = "setxkbmap"; //-rules " + m_rule
        setxkbmap += " -model " + lookupLocalized(m_rules->models(), widget->comboModel->currentText()) + " -layout ";
        setxkbmap += kbdLayout;
        if(widget->chkLatin->isChecked())
            setxkbmap += ",us";

        /*	LayoutUnit layoutUnitKey = getLayoutUnitKey(sel);
            layoutDisplayName = m_kxkbConfig.getLayoutDisplayName( *m_kxkbConfig.m_layouts.find(layoutUnitKey) );*/
        layoutDisplayName = sel->text(LAYOUT_COLUMN_DISPLAY_NAME);
        if(layoutDisplayName.isEmpty())
        {
            int count = 0;
            QListViewItem *item = widget->listLayoutsDst->firstChild();
            while(item)
            {
                QString layout_ = item->text(LAYOUT_COLUMN_MAP);
                if(layout_ == kbdLayout)
                    ++count;
                item = item->nextSibling();
            }
            bool single = count < 2;
            layoutDisplayName = m_kxkbConfig.getDefaultDisplayName(LayoutUnit(kbdLayout, variant), single);
        }
        kdDebug() << "disp: '" << layoutDisplayName << "'" << endl;

        if(!variant.isEmpty())
        {
            setxkbmap += " -variant ";
            if(widget->chkLatin->isChecked())
                setxkbmap += ",";
            setxkbmap += variant;
        }
    }

    widget->editCmdLine->setText(setxkbmap);

    widget->editDisplayName->setEnabled(sel != NULL);
    widget->editDisplayName->setText(layoutDisplayName);
}
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:52,代码来源:kcmlayout.cpp

示例10: fixedSize

LayoutSize StyleGeneratedImage::imageSize(const LayoutObject* layoutObject, float multiplier) const
{
    if (m_fixedSize) {
        LayoutSize fixedSize(m_imageGeneratorValue->fixedSize(layoutObject));
        if (multiplier == 1.0f)
            return fixedSize;

        LayoutUnit width(fixedSize.width() * multiplier);
        LayoutUnit height(fixedSize.height() * multiplier);

        // Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
        if (fixedSize.width() > LayoutUnit())
            width = max(LayoutUnit(1), width);

        if (fixedSize.height() > LayoutUnit())
            height = max(LayoutUnit(1), height);

        return LayoutSize(width, height);
    }

    return LayoutSize();
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:22,代码来源:StyleGeneratedImage.cpp

示例11: LayoutUnit

void TableLayoutAlgorithmFixed::applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const
{
    Length tableLogicalWidth = m_table->style()->logicalWidth();
    if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) {
        minWidth = maxWidth = LayoutUnit(max(minWidth, LayoutUnit(tableLogicalWidth.value() - m_table->bordersPaddingAndSpacingInRowDirection())).floor());
    }

    /*
        <table style="width:100%; background-color:red"><tr><td>
            <table style="background-color:blue"><tr><td>
                <table style="width:100%; background-color:green; table-layout:fixed"><tr><td>
                    Content
                </td></tr></table>
            </td></tr></table>
        </td></tr></table>
    */
    // In this example, the two inner tables should be as large as the outer table.
    // We can achieve this effect by making the maxwidth of fixed tables with percentage
    // widths be infinite.
    if (m_table->style()->logicalWidth().hasPercent() && maxWidth < tableMaxWidth)
        maxWidth = LayoutUnit(tableMaxWidth);
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:22,代码来源:TableLayoutAlgorithmFixed.cpp

示例12: ASSERT

LayoutRect LayoutListMarker::selectionRectForPaintInvalidation(const LayoutBoxModelObject* paintInvalidationContainer) const
{
    ASSERT(!needsLayout());

    if (getSelectionState() == SelectionNone || !inlineBoxWrapper())
        return LayoutRect();

    RootInlineBox& root = inlineBoxWrapper()->root();
    LayoutRect rect(LayoutUnit(), root.selectionTop() - location().y(), size().width(), root.selectionHeight());
    mapToVisibleRectInAncestorSpace(paintInvalidationContainer, rect, nullptr);
    // FIXME: groupedMapping() leaks the squashing abstraction.
    if (paintInvalidationContainer->layer()->groupedMapping())
        PaintLayer::mapRectToPaintBackingCoordinates(paintInvalidationContainer, rect);
    return rect;
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:15,代码来源:LayoutListMarker.cpp

示例13: ASSERT

LayoutSize LayoutListMarker::imageBulletSize() const {
  ASSERT(isImage());
  const SimpleFontData* fontData = style()->font().primaryFont();
  DCHECK(fontData);
  if (!fontData)
    return LayoutSize();

  // FIXME: This is a somewhat arbitrary default width. Generated images for
  // markers really won't become particularly useful until we support the CSS3
  // marker pseudoclass to allow control over the width and height of the
  // marker box.
  LayoutUnit bulletWidth = fontData->getFontMetrics().ascent() / LayoutUnit(2);
  return m_image->imageSize(*this, style()->effectiveZoom(),
                            LayoutSize(bulletWidth, bulletWidth));
}
开发者ID:mirror,项目名称:chromium,代码行数:15,代码来源:LayoutListMarker.cpp

示例14: ASSERT

LayoutUnit InlineTextBox::positionForOffset(int offset) const
{
    ASSERT(offset >= m_start);
    ASSERT(offset <= m_start + m_len);

    if (isLineBreak())
        return logicalLeft();

    LineLayoutText text = getLineLayoutItem();
    const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle());
    const Font& font = styleToUse.font();
    int from = !isLeftToRightDirection() ? offset - m_start : 0;
    int to = !isLeftToRightDirection() ? m_len : offset - m_start;
    // FIXME: Do we need to add rightBearing here?
    return LayoutUnit(font.selectionRectForText(constructTextRun(styleToUse, font), IntPoint(logicalLeft(), 0), 0, from, to).maxX());
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:16,代码来源:InlineTextBox.cpp

示例15: caretLayoutObject

// TODO(yoichio): |node| is FrameSelection::m_previousCaretNode and this is bad
// design. We should use only previous layoutObject or Rectangle to invalidate
// old caret.
void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) {
    LayoutBlock* caretLayoutBlock = caretLayoutObject(node);
    if (!caretLayoutBlock)
        return;

    // FIXME: Need to over-paint 1 pixel to workaround some rounding problems.
    // https://bugs.webkit.org/show_bug.cgi?id=108283
    LayoutRect inflatedRect = rect;
    inflatedRect.inflate(LayoutUnit(1));

    // FIXME: We should not allow paint invalidation out of paint invalidation
    // state. crbug.com/457415
    DisablePaintInvalidationStateAsserts disabler;

    m_visualRect =
        node->layoutObject()->invalidatePaintRectangle(inflatedRect, this);
}
开发者ID:mirror,项目名称:chromium,代码行数:20,代码来源:CaretBase.cpp


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