Example #1
0
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();
}
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);
}
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);
}
Example #4
0
LayoutUnit FloatingObjects::getCachedlowestFloatLogicalBottom(
    FloatingObject::Type type) const {
  int floatIndex = static_cast<int>(type) - 1;
  ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) /
                                       sizeof(FloatBottomCachedValue)));
  ASSERT(floatIndex >= 0);
  if (!m_lowestFloatBottomCache[floatIndex].floatingObject)
    return LayoutUnit();
  return m_layoutObject->logicalBottomForFloat(
      *m_lowestFloatBottomCache[floatIndex].floatingObject);
}
Example #5
0
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();
}
Example #6
0
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());
}
Example #7
0
LayoutMenuList::LayoutMenuList(Element* element)
    : LayoutFlexibleBox(element),
      m_buttonText(nullptr),
      m_innerBlock(nullptr),
      m_isEmpty(false),
      m_hasUpdatedActiveOption(false),
      m_innerBlockHeight(LayoutUnit()),
      m_optionsWidth(0),
      m_lastActiveIndex(-1) {
  ASSERT(isHTMLSelectElement(element));
}
Example #8
0
void ColumnBalancer::traverseSubtree(const LayoutBox& box)
{
    if (box.childrenInline() && box.isLayoutBlockFlow()) {
        // Look for breaks between lines.
        for (const RootInlineBox* line = toLayoutBlockFlow(box).firstRootBox(); line; line = line->nextRootBox()) {
            LayoutUnit lineTopInFlowThread = m_flowThreadOffset + line->lineTopWithLeading();
            if (lineTopInFlowThread < group().logicalTopInFlowThread())
                continue;
            if (lineTopInFlowThread >= group().logicalBottomInFlowThread())
                break;
            examineLine(*line);
        }
    }

    const LayoutFlowThread* flowThread = group().columnSet().flowThread();
    bool isHorizontalWritingMode = flowThread->isHorizontalWritingMode();

    // Look for breaks between and inside block-level children. Even if this is a block flow with
    // inline children, there may be interesting floats to examine here.
    for (const LayoutObject* child = box.slowFirstChild(); child; child = child->nextSibling()) {
        if (!child->isBox() || child->isInline())
            continue;
        const LayoutBox& childBox = toLayoutBox(*child);
        LayoutRect overflowRect = childBox.layoutOverflowRect();
        LayoutUnit childLogicalBottomWithOverflow = childBox.logicalTop() + (isHorizontalWritingMode ? overflowRect.maxY() : overflowRect.maxX());
        if (m_flowThreadOffset + childLogicalBottomWithOverflow <= group().logicalTopInFlowThread()) {
            // This child is fully above the fragmentainer group we're examining.
            continue;
        }
        LayoutUnit childLogicalTopWithOverflow = childBox.logicalTop() + (isHorizontalWritingMode ? overflowRect.y() : overflowRect.x());
        if (m_flowThreadOffset + childLogicalTopWithOverflow >= group().logicalBottomInFlowThread()) {
            // This child is fully below the fragmentainer group we're examining. We cannot just
            // stop here, though, thanks to negative margins. So keep looking.
            continue;
        }
        if (childBox.isOutOfFlowPositioned() || childBox.isColumnSpanAll())
            continue;

        // Tables are wicked. Both table rows and table cells are relative to their table section.
        LayoutUnit offsetForThisChild = childBox.isTableRow() ? LayoutUnit() : childBox.logicalTop();
        m_flowThreadOffset += offsetForThisChild;

        examineBoxAfterEntering(childBox);
        // Unless the child is unsplittable, or if the child establishes an inner multicol
        // container, we descend into its subtree for further examination.
        if (childBox.paginationBreakability() != LayoutBox::ForbidBreaks
            && (!childBox.isLayoutBlockFlow() || !toLayoutBlockFlow(childBox).multiColumnFlowThread()))
            traverseSubtree(childBox);
        examineBoxBeforeLeaving(childBox);

        m_flowThreadOffset -= offsetForThisChild;
    }
}
Example #9
0
LayoutUnit ShapeOutsideInfo::logicalTopOffset() const {
  switch (referenceBox(*m_layoutBox.style()->shapeOutside())) {
    case MarginBox:
      return -m_layoutBox.marginBefore(m_layoutBox.containingBlock()->style());
    case BorderBox:
      return LayoutUnit();
    case PaddingBox:
      return borderBeforeInWritingMode(
          m_layoutBox,
          m_layoutBox.containingBlock()->style()->getWritingMode());
    case ContentBox:
      return borderAndPaddingBeforeInWritingMode(
          m_layoutBox,
          m_layoutBox.containingBlock()->style()->getWritingMode());
    case BoxMissing:
      break;
  }

  ASSERT_NOT_REACHED();
  return LayoutUnit();
}
Example #10
0
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();
}
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;
}
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));
}
Example #13
0
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);
}
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();
}
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);
}
Example #16
0
void LayoutMenuList::computeIntrinsicLogicalWidths(
    LayoutUnit& minLogicalWidth,
    LayoutUnit& maxLogicalWidth) const {
  updateOptionsWidth();

  maxLogicalWidth =
      std::max(m_optionsWidth,
               LayoutTheme::theme().minimumMenuListSize(styleRef())) +
      m_innerBlock->paddingLeft() + m_innerBlock->paddingRight();
  if (!style()->width().isPercentOrCalc())
    minLogicalWidth = maxLogicalWidth;
  else
    minLogicalWidth = LayoutUnit();
}
Example #17
0
FloatingObject* FloatingObjects::lowestFloatingObject() const {
  bool isInHorizontalWritingMode = m_horizontalWritingMode;
  if (!hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode,
                                         FloatingObject::FloatLeft) &&
      !hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode,
                                         FloatingObject::FloatRight))
    return nullptr;
  FloatingObject* lowestLeftObject = m_lowestFloatBottomCache[0].floatingObject;
  FloatingObject* lowestRightObject =
      m_lowestFloatBottomCache[1].floatingObject;
  LayoutUnit lowestFloatBottomLeft =
      lowestLeftObject
          ? m_layoutObject->logicalBottomForFloat(*lowestLeftObject)
          : LayoutUnit();
  LayoutUnit lowestFloatBottomRight =
      lowestRightObject
          ? m_layoutObject->logicalBottomForFloat(*lowestRightObject)
          : LayoutUnit();

  if (lowestFloatBottomLeft > lowestFloatBottomRight)
    return lowestLeftObject;
  return lowestRightObject;
}
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;
}
Example #19
0
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));
}
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());
}
Example #21
0
// 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);
}
Example #22
0
LayoutUnit RenderMultiColumnSet::heightAdjustedForSetOffset(LayoutUnit height) const
{
    // Adjust for the top offset within the content box of the multicol container (containing
    // block), unless this is the first set. We know that the top offset for the first set will be
    // zero, but if the multicol container has non-zero top border or padding, the set's top offset
    // (initially being 0 and relative to the border box) will be negative until it has been laid
    // out. Had we used this bogus offset, we would calculate the wrong height, and risk performing
    // a wasted layout iteration. Of course all other sets (if any) have this problem in the first
    // layout pass too, but there's really nothing we can do there until the flow thread has been
    // laid out anyway.
    if (previousSiblingMultiColumnSet()) {
        RenderBlockFlow* multicolBlock = multiColumnBlockFlow();
        LayoutUnit contentLogicalTop = logicalTop() - multicolBlock->borderAndPaddingBefore();
        height -= contentLogicalTop;
    }
    return max(height, LayoutUnit(1)); // Let's avoid zero height, as that would probably cause an infinite amount of columns to be created.
}
void LayoutRubyRun::layout()
{
    LayoutBlockFlow::layout();

    LayoutRubyText* rt = rubyText();
    if (!rt)
        return;

    rt->setLogicalLeft(LayoutUnit());

    // Place the LayoutRubyText such that its bottom is flush with the lineTop of the first line of the LayoutRubyBase.
    LayoutUnit lastLineRubyTextBottom = rt->logicalHeight();
    LayoutUnit firstLineRubyTextTop;
    RootInlineBox* rootBox = rt->lastRootBox();
    if (rootBox) {
        // In order to align, we have to ignore negative leading.
        firstLineRubyTextTop = rt->firstRootBox()->logicalTopLayoutOverflow();
        lastLineRubyTextBottom = rootBox->logicalBottomLayoutOverflow();
    }

    if (style()->isFlippedLinesWritingMode() == (style()->rubyPosition() == RubyPositionAfter)) {
        LayoutUnit firstLineTop;
        if (LayoutRubyBase* rb = rubyBase()) {
            RootInlineBox* rootBox = rb->firstRootBox();
            if (rootBox)
                firstLineTop = rootBox->logicalTopLayoutOverflow();
            firstLineTop += rb->logicalTop();
        }

        rt->setLogicalTop(-lastLineRubyTextBottom + firstLineTop);
    } else {
        LayoutUnit lastLineBottom = logicalHeight();
        if (LayoutRubyBase* rb = rubyBase()) {
            RootInlineBox* rootBox = rb->lastRootBox();
            if (rootBox)
                lastLineBottom = rootBox->logicalBottomLayoutOverflow();
            lastLineBottom += rb->logicalTop();
        }

        rt->setLogicalTop(-firstLineRubyTextTop + lastLineBottom);
    }

    // Update our overflow to account for the new LayoutRubyText position.
    computeOverflow(clientLogicalBottom());
}
Example #24
0
void LayoutReplaced::computePreferredLogicalWidths() {
    ASSERT(preferredLogicalWidthsDirty());

    // We cannot resolve some logical width here (i.e. percent, fill-available or
    // fit-content) as the available logical width may not be set on our
    // containing block.
    const Length& logicalWidth = style()->logicalWidth();
    if (logicalWidth.isPercentOrCalc() || logicalWidth.isFillAvailable() ||
            logicalWidth.isFitContent())
        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth,
                                      m_maxPreferredLogicalWidth);
    else
        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth =
                                         computeReplacedLogicalWidth(ComputePreferred);

    const ComputedStyle& styleToUse = styleRef();
    if (styleToUse.logicalWidth().isPercentOrCalc() ||
            styleToUse.logicalMaxWidth().isPercentOrCalc())
        m_minPreferredLogicalWidth = LayoutUnit();

    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 borderAndPadding = borderAndPaddingLogicalWidth();
    m_minPreferredLogicalWidth += borderAndPadding;
    m_maxPreferredLogicalWidth += borderAndPadding;

    clearPreferredLogicalWidthsDirty();
}
Example #25
0
LayoutSet X11Helper::getCurrentLayouts()
{
	LayoutSet layoutSet;

	QList<LayoutUnit> currentLayouts = getLayoutsList();
	layoutSet.layouts = currentLayouts;

	unsigned int group = X11Helper::getGroup();
	if( group < (unsigned int)currentLayouts.size() ) {
		layoutSet.currentLayout = currentLayouts[group];
	}
	else {
		qCWarning(KCM_KEYBOARD) << "Current group number" << group << "is outside of current layout list" << getLayoutsListAsString(currentLayouts);
		layoutSet.currentLayout = LayoutUnit();
	}

	return layoutSet;
}
LayoutUnit InlineBox::logicalHeight() const
{
    if (hasVirtualLogicalHeight())
        return virtualLogicalHeight();

    if (lineLayoutItem().isText())
        return m_bitfields.isText() ? LayoutUnit(lineLayoutItem().style(isFirstLineStyle())->fontMetrics().height()) : LayoutUnit();
    if (lineLayoutItem().isBox() && parent())
        return isHorizontal() ? toLayoutBox(layoutObject()).size().height() : toLayoutBox(layoutObject()).size().width();

    ASSERT(isInlineFlowBox());
    LineLayoutBoxModel flowObject = boxModelObject();
    const FontMetrics& fontMetrics = lineLayoutItem().style(isFirstLineStyle())->fontMetrics();
    LayoutUnit result = fontMetrics.height();
    if (parent())
        result += flowObject.borderAndPaddingLogicalHeight();
    return result;
}
void MultiColumnFragmentainerGroup::resetColumnHeight()
{
    m_maxColumnHeight = calculateMaxColumnHeight();

    LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread();
    if (m_columnSet.heightIsAuto()) {
        FragmentationContext* enclosingFragmentationContext = flowThread->enclosingFragmentationContext();
        if (enclosingFragmentationContext && enclosingFragmentationContext->isFragmentainerLogicalHeightKnown()) {
            // Even if height is auto, we set an initial height, in order to tell how much content
            // this MultiColumnFragmentainerGroup can hold, and when we need to append a new one.
            m_columnHeight = m_maxColumnHeight;
        } else {
            m_columnHeight = LayoutUnit();
        }
    } else {
        setAndConstrainColumnHeight(heightAdjustedForRowOffset(flowThread->columnHeightAvailable()));
    }
}
Example #28
0
TEST(LayoutUnitTest, UnaryMinus) {
  EXPECT_EQ(LayoutUnit(), -LayoutUnit());
  EXPECT_EQ(LayoutUnit(999), -LayoutUnit(-999));
  EXPECT_EQ(LayoutUnit(-999), -LayoutUnit(999));

  LayoutUnit negativeMax;
  negativeMax.setRawValue(LayoutUnit::min().rawValue() + 1);
  EXPECT_EQ(negativeMax, -LayoutUnit::max());
  EXPECT_EQ(LayoutUnit::max(), -negativeMax);

  // -LayoutUnit::min() is saturated to LayoutUnit::max()
  EXPECT_EQ(LayoutUnit::max(), -LayoutUnit::min());
}
Example #29
0
void KeyboardConfig::load()
{
    KConfigGroup config(KSharedConfig::openConfig( CONFIG_FILENAME, KConfig::NoGlobals ), CONFIG_GROUPNAME);

    keyboardModel = config.readEntry("Model", "");

    resetOldXkbOptions = config.readEntry("ResetOldOptions", false);
    QString options = config.readEntry("Options", "");
    xkbOptions = options.split(LIST_SEPARATOR, QString::SkipEmptyParts);

    configureLayouts = config.readEntry("Use", false);
    QString layoutsString = config.readEntry("LayoutList", "");
    QStringList layoutStrings = layoutsString.split(LIST_SEPARATOR, QString::SkipEmptyParts);
//    if( layoutStrings.isEmpty() ) {
//    	layoutStrings.append(DEFAULT_LAYOUT);
//    }
    layouts.clear();
    foreach(const QString& layoutString, layoutStrings) {
    	layouts.append(LayoutUnit(layoutString));
    }
Example #30
0
void RenderFlowThread::updateLogicalWidth()
{
    LayoutUnit logicalWidth = 0;
    for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
        RenderRegion* region = *iter;
        ASSERT(!region->needsLayout());
        logicalWidth = max(region->pageLogicalWidth(), logicalWidth);
    }
    setLogicalWidth(logicalWidth);

    // If the regions have non-uniform logical widths, then insert inset information for the RenderFlowThread.
    for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
        RenderRegion* region = *iter;
        LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
        if (regionLogicalWidth != logicalWidth) {
            LayoutUnit logicalLeft = style()->direction() == LTR ? LayoutUnit() : logicalWidth - regionLogicalWidth;
            region->setRenderBoxRegionInfo(this, logicalLeft, regionLogicalWidth, false);
        }
    }
}