inline LayoutUnit borderAndPaddingBeforeInWritingMode(const LayoutBox& layoutBox, WritingMode writingMode) { switch (writingMode) { case TopToBottomWritingMode: return layoutBox.borderTop() + layoutBox.paddingTop(); case LeftToRightWritingMode: return layoutBox.borderLeft() + layoutBox.paddingLeft(); case RightToLeftWritingMode: return layoutBox.borderRight() + layoutBox.paddingRight(); } ASSERT_NOT_REACHED(); return layoutBox.borderAndPaddingBefore(); }
inline LayoutUnit borderAndPaddingStartWithStyleForWritingMode(const LayoutBox& layoutBox, const ComputedStyle* style) { if (style->isHorizontalWritingMode()) { if (style->isLeftToRightDirection()) return layoutBox.borderLeft() + layoutBox.paddingLeft(); return layoutBox.borderRight() + layoutBox.paddingRight(); } if (style->isLeftToRightDirection()) return layoutBox.borderTop() + layoutBox.paddingTop(); return layoutBox.borderBottom() + layoutBox.paddingBottom(); }
void ThemePainterDefault::setupMenuListArrow( const LayoutBox& box, const IntRect& rect, WebThemeEngine::ExtraParams& extraParams) { const int left = rect.x() + box.borderLeft(); const int right = rect.x() + rect.width() - box.borderRight(); const int middle = rect.y() + rect.height() / 2; extraParams.menuList.arrowY = middle; float arrowBoxWidth = m_theme.clampedMenuListArrowPaddingSize( box.frameView()->getHostWindow(), box.styleRef()); float arrowScaleFactor = arrowBoxWidth / m_theme.scrollbarThicknessInDIP(); if (useMockTheme()) { // The size and position of the drop-down button is different between // the mock theme and the regular aura theme. // Padding inside the arrowBox. float extraPadding = 2 * arrowScaleFactor; float arrowSize = std::min(arrowBoxWidth, static_cast<float>(rect.height() - box.borderTop() - box.borderBottom())) - 2 * extraPadding; // |arrowX| is the middle position for mock theme engine. extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) ? rect.x() + extraPadding + (arrowSize / 2) : right - (arrowSize / 2) - extraPadding; extraParams.menuList.arrowSize = arrowSize; } else { // TODO(tkent): This should be 7.0 to match scroll bar buttons. float arrowSize = 6.0 * arrowScaleFactor; // Put the 6px arrow at the center of paddingForArrow area. // |arrowX| is the left position for Aura theme engine. extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) ? left + (arrowBoxWidth - arrowSize) / 2 : right - (arrowBoxWidth + arrowSize) / 2; extraParams.menuList.arrowSize = arrowSize; } extraParams.menuList.arrowColor = box.resolveColor(CSSPropertyColor).rgb(); }
LayoutState::LayoutState(LayoutBox& layoutObject, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, bool containingBlockLogicalWidthChanged) : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged) , m_next(layoutObject.view()->layoutState()) , m_layoutObject(layoutObject) { if (layoutObject.isLayoutFlowThread()) m_flowThread = toLayoutFlowThread(&layoutObject); else if (!layoutObject.isOutOfFlowPositioned() && !layoutObject.isColumnSpanAll()) m_flowThread = m_next->flowThread(); else m_flowThread = nullptr; layoutObject.view()->pushLayoutState(*this); bool fixed = layoutObject.isOutOfFlowPositioned() && layoutObject.style()->position() == FixedPosition; if (fixed) { // FIXME: This doesn't work correctly with transforms. FloatPoint fixedOffset = layoutObject.view()->localToAbsolute(FloatPoint(), IsFixed); m_layoutOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset; } else { m_layoutOffset = m_next->m_layoutOffset + offset; } if (layoutObject.isOutOfFlowPositioned() && !fixed) { if (LayoutObject* container = layoutObject.container()) { if (container->style()->hasInFlowPosition() && container->isLayoutInline()) m_layoutOffset += toLayoutInline(container)->offsetForInFlowPositionedInline(layoutObject); } } // If we establish a new page height, then cache the offset to the top of the first page. // We can compare this later on to figure out what part of the page we're actually on, if (pageLogicalHeight || layoutObject.isLayoutFlowThread()) { m_pageLogicalHeight = pageLogicalHeight; bool isFlipped = layoutObject.style()->isFlippedBlocksWritingMode(); m_pageOffset = LayoutSize(m_layoutOffset.width() + (!isFlipped ? layoutObject.borderLeft() + layoutObject.paddingLeft() : layoutObject.borderRight() + layoutObject.paddingRight()), m_layoutOffset.height() + (!isFlipped ? layoutObject.borderTop() + layoutObject.paddingTop() : layoutObject.borderBottom() + layoutObject.paddingBottom())); m_pageLogicalHeightChanged = pageLogicalHeightChanged; m_isPaginated = true; } else if (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot()) { // Pagination inside SVG is not allowed. m_flowThread = nullptr; m_pageLogicalHeightChanged = false; m_isPaginated = false; } else { // If we don't establish a new page height, then propagate the old page height and offset down. m_pageLogicalHeight = m_next->m_pageLogicalHeight; m_pageLogicalHeightChanged = m_next->m_pageLogicalHeightChanged; m_pageOffset = m_next->m_pageOffset; // Disable pagination for objects we don't support. For now this includes overflow:scroll/auto, inline blocks and // writing mode roots. if (layoutObject.isUnsplittableForPagination()) { m_pageLogicalHeight = 0; m_isPaginated = false; } else { m_isPaginated = m_pageLogicalHeight || layoutObject.flowThreadContainingBlock(); } } // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. }