void LayoutMenuList::adjustInnerStyle() { ComputedStyle& innerStyle = m_innerBlock->mutableStyleRef(); innerStyle.setFlexGrow(1); innerStyle.setFlexShrink(1); // min-width: 0; is needed for correct shrinking. innerStyle.setMinWidth(Length(0, Fixed)); // Use margin:auto instead of align-items:center to get safe centering, i.e. // when the content overflows, treat it the same as align-items: flex-start. // But we only do that for the cases where html.css would otherwise use // center. if (style()->alignItemsPosition() == ItemPositionCenter) { innerStyle.setMarginTop(Length()); innerStyle.setMarginBottom(Length()); innerStyle.setAlignSelfPosition(ItemPositionFlexStart); } Length paddingStart = Length(LayoutTheme::theme().popupInternalPaddingStart(styleRef()), Fixed); Length paddingEnd = Length(LayoutTheme::theme().popupInternalPaddingEnd( frameView()->getHostWindow(), styleRef()), Fixed); innerStyle.setPaddingLeft(styleRef().direction() == LTR ? paddingStart : paddingEnd); innerStyle.setPaddingRight(styleRef().direction() == LTR ? paddingEnd : paddingStart); innerStyle.setPaddingTop( Length(LayoutTheme::theme().popupInternalPaddingTop(styleRef()), Fixed)); innerStyle.setPaddingBottom(Length( LayoutTheme::theme().popupInternalPaddingBottom(styleRef()), Fixed)); if (m_optionStyle) { if ((m_optionStyle->direction() != innerStyle.direction() || m_optionStyle->unicodeBidi() != innerStyle.unicodeBidi())) m_innerBlock->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( LayoutInvalidationReason::StyleChange); innerStyle.setTextAlign(style()->isLeftToRightDirection() ? ETextAlign::Left : ETextAlign::Right); innerStyle.setDirection(m_optionStyle->direction()); innerStyle.setUnicodeBidi(m_optionStyle->unicodeBidi()); } }
void LayoutMultiColumnSpannerPlaceholder::updateMarginProperties() { RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(styleRef()); copyMarginProperties(*newStyle, m_layoutObjectInFlowThread->styleRef()); setStyle(newStyle); }
float LayoutSVGShape::dashScaleFactor() const { if (!styleRef().svgStyle().strokeDashArray()->size()) return 1; return toSVGGeometryElement(*element()).pathLengthScaleFactor(); }
int LayoutBR::lineHeight(bool firstLine) const { const ComputedStyle& style = styleRef(firstLine && document().styleEngine().usesFirstLineRules()); return style.computedLineHeight(); }
void LayoutSVGRect::updateShapeFromElement() { // Before creating a new object we need to clear the cached bounding box // to avoid using garbage. m_fillBoundingBox = FloatRect(); m_strokeBoundingBox = FloatRect(); m_usePathFallback = false; SVGRectElement* rect = toSVGRectElement(element()); ASSERT(rect); SVGLengthContext lengthContext(rect); FloatSize boundingBoxSize( lengthContext.valueForLength(styleRef().width(), styleRef(), SVGLengthMode::Width), lengthContext.valueForLength(styleRef().height(), styleRef(), SVGLengthMode::Height)); // Spec: "A negative value is an error." if (boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0) return; // Spec: "A value of zero disables rendering of the element." if (!boundingBoxSize.isEmpty()) { // Fallback to LayoutSVGShape and path-based hit detection if the rect // has rounded corners or a non-scaling or non-simple stroke. if (lengthContext.valueForLength(styleRef().svgStyle().rx(), styleRef(), SVGLengthMode::Width) > 0 || lengthContext.valueForLength(styleRef().svgStyle().ry(), styleRef(), SVGLengthMode::Height) > 0 || hasNonScalingStroke() || !definitelyHasSimpleStroke()) { LayoutSVGShape::updateShapeFromElement(); m_usePathFallback = true; return; } } m_fillBoundingBox = FloatRect( FloatPoint( lengthContext.valueForLength(styleRef().svgStyle().x(), styleRef(), SVGLengthMode::Width), lengthContext.valueForLength(styleRef().svgStyle().y(), styleRef(), SVGLengthMode::Height)), boundingBoxSize); m_strokeBoundingBox = m_fillBoundingBox; if (style()->svgStyle().hasStroke()) m_strokeBoundingBox.inflate(strokeWidth() / 2); }
void LayoutSVGRoot::insertedIntoTree() { LayoutReplaced::insertedIntoTree(); SVGResourcesCache::clientWasAddedToTree(this, styleRef()); }