Commit 2a1952d8 authored by esprehn@chromium.org's avatar esprehn@chromium.org

Skip overflow adjustment checks when possible in StyleAdjuster

Continuing the work to make StyleAdjuster cheaper we can skip all the work
related to overflow adjustment in the common case when overflow is visible.

Review URL: https://codereview.chromium.org/214413011

git-svn-id: svn://svn.chromium.org/blink/trunk@170306 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5a84960a
...@@ -231,8 +231,7 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty ...@@ -231,8 +231,7 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
|| style->position() == StickyPosition || style->position() == StickyPosition
|| style->position() == FixedPosition || style->position() == FixedPosition
|| isInTopLayer(e, style) || isInTopLayer(e, style)
|| hasWillChangeThatCreatesStackingContext(style, e) || hasWillChangeThatCreatesStackingContext(style, e)))
))
style->setZIndex(0); style->setZIndex(0);
// will-change:transform should result in the same rendering behavior as having a transform, // will-change:transform should result in the same rendering behavior as having a transform,
...@@ -247,31 +246,8 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty ...@@ -247,31 +246,8 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
else else
style->addToTextDecorationsInEffect(style->textDecoration()); style->addToTextDecorationsInEffect(style->textDecoration());
// If either overflow value is not visible, change to auto. if (style->overflowX() != OVISIBLE || style->overflowY() != OVISIBLE)
if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { adjustOverflow(style, e);
// FIXME: Once we implement pagination controls, overflow-x should default to hidden
// if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, we'll let it
// default to auto so we can at least scroll through the pages.
style->setOverflowX(OAUTO);
} else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE) {
style->setOverflowY(OAUTO);
}
// Table rows, sections and the table itself will support overflow:hidden and will ignore scroll/auto.
// FIXME: Eventually table sections will support auto and scroll.
if (style->display() == TABLE || style->display() == INLINE_TABLE
|| style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW) {
if (style->overflowX() != OVISIBLE && style->overflowX() != OHIDDEN)
style->setOverflowX(OVISIBLE);
if (style->overflowY() != OVISIBLE && style->overflowY() != OHIDDEN)
style->setOverflowY(OVISIBLE);
}
// Menulists should have visible overflow
if (style->appearance() == MenulistPart) {
style->setOverflowX(OVISIBLE);
style->setOverflowY(OVISIBLE);
}
// Cull out any useless layers and also repeat patterns into additional layers. // Cull out any useless layers and also repeat patterns into additional layers.
style->adjustBackgroundLayers(); style->adjustBackgroundLayers();
...@@ -292,17 +268,6 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty ...@@ -292,17 +268,6 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
style->setTransformStyle3D(TransformStyle3DFlat); style->setTransformStyle3D(TransformStyle3DFlat);
if (e && e->isSVGElement()) { if (e && e->isSVGElement()) {
// Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
if (style->overflowY() == OSCROLL)
style->setOverflowY(OHIDDEN);
else if (style->overflowY() == OAUTO)
style->setOverflowY(OVISIBLE);
if (style->overflowX() == OSCROLL)
style->setOverflowX(OHIDDEN);
else if (style->overflowX() == OAUTO)
style->setOverflowX(OVISIBLE);
// Only the root <svg> element in an SVG document fragment tree honors css position // Only the root <svg> element in an SVG document fragment tree honors css position
if (!(isSVGSVGElement(*e) && e->parentNode() && !e->parentNode()->isSVGElement())) if (!(isSVGSVGElement(*e) && e->parentNode() && !e->parentNode()->isSVGElement()))
style->setPosition(RenderStyle::initialPosition()); style->setPosition(RenderStyle::initialPosition());
...@@ -403,6 +368,50 @@ void StyleAdjuster::adjustStyleForTagName(RenderStyle* style, RenderStyle* paren ...@@ -403,6 +368,50 @@ void StyleAdjuster::adjustStyleForTagName(RenderStyle* style, RenderStyle* paren
} }
} }
void StyleAdjuster::adjustOverflow(RenderStyle* style, Element* element)
{
ASSERT(style->overflowX() != OVISIBLE || style->overflowY() != OVISIBLE);
// If either overflow value is not visible, change to auto.
if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) {
// FIXME: Once we implement pagination controls, overflow-x should default to hidden
// if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, we'll let it
// default to auto so we can at least scroll through the pages.
style->setOverflowX(OAUTO);
} else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE) {
style->setOverflowY(OAUTO);
}
// Table rows, sections and the table itself will support overflow:hidden and will ignore scroll/auto.
// FIXME: Eventually table sections will support auto and scroll.
if (style->display() == TABLE || style->display() == INLINE_TABLE
|| style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW) {
if (style->overflowX() != OVISIBLE && style->overflowX() != OHIDDEN)
style->setOverflowX(OVISIBLE);
if (style->overflowY() != OVISIBLE && style->overflowY() != OHIDDEN)
style->setOverflowY(OVISIBLE);
}
// Menulists should have visible overflow
if (style->appearance() == MenulistPart) {
style->setOverflowX(OVISIBLE);
style->setOverflowY(OVISIBLE);
}
// Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
if (element && element->isSVGElement()) {
if (style->overflowY() == OSCROLL)
style->setOverflowY(OHIDDEN);
else if (style->overflowY() == OAUTO)
style->setOverflowY(OVISIBLE);
if (style->overflowX() == OSCROLL)
style->setOverflowX(OHIDDEN);
else if (style->overflowX() == OAUTO)
style->setOverflowX(OVISIBLE);
}
}
void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* parentStyle) void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* parentStyle)
{ {
if (style->display() == BLOCK && !style->isFloating()) if (style->display() == BLOCK && !style->isFloating())
......
...@@ -43,6 +43,7 @@ public: ...@@ -43,6 +43,7 @@ public:
private: private:
void adjustStyleForDisplay(RenderStyle* styleToAdjust, RenderStyle* parentStyle); void adjustStyleForDisplay(RenderStyle* styleToAdjust, RenderStyle* parentStyle);
void adjustStyleForTagName(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element&); void adjustStyleForTagName(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element&);
void adjustOverflow(RenderStyle* styleToAdjust, Element*);
const CachedUAStyle& m_cachedUAStyle; const CachedUAStyle& m_cachedUAStyle;
bool m_useQuirksModeStyles; bool m_useQuirksModeStyles;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment