CSSStyleSelector::pseudoStyleForDataGridColumnHeader(DataGridColumn*, RenderStyle*)
{
// FIXME: Implement
return 0;
}
#endif
static void addIntrinsicMargins(RenderStyle* style)
{
// Intrinsic margin value.
const int intrinsicMargin = 2 * style->effectiveZoom();
// FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed.
// FIXME: Using "quirk" to decide the margin wasn't set is kind of lame.
if (style->width().isIntrinsicOrAuto()) {
if (style->marginLeft().quirk())
style->setMarginLeft(Length(intrinsicMargin, Fixed));
if (style->marginRight().quirk())
style->setMarginRight(Length(intrinsicMargin, Fixed));
}
if (style->height().isAuto()) {
if (style->marginTop().quirk())
style->setMarginTop(Length(intrinsicMargin, Fixed));
if (style->marginBottom().quirk())
style->setMarginBottom(Length(intrinsicMargin, Fixed));
}
}
static inline bool isAtShadowBoundary(Element* element)
{
if (!element)
return false;
ContainerNode* parentNode = element->parentNode();
return parentNode && parentNode->isShadowBoundary();
}
void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e)
{
// Cache our original display.
style->setOriginalDisplay(style->display());
if (style->display() != NONE) {
// If we have a that specifies a float property, in quirks mode we just drop the float
// property.
// Sites also commonly use display:inline/block on | s and s. In quirks mode we force
// these tags to retain their display types.
if (!m_checker.m_strictParsing && e) {
if (e->hasTagName(tdTag)) {
style->setDisplay(TABLE_CELL);
style->setFloating(FNONE);
}
else if (e->hasTagName(tableTag))
style->setDisplay(style->isDisplayInlineType() ? INLINE_TABLE : TABLE);
}
if (e && (e->hasTagName(tdTag) || e->hasTagName(thTag))) {
if (style->whiteSpace() == KHTML_NOWRAP) {
// Figure out if we are really nowrapping or if we should just
// use normal instead. If the width of the cell is fixed, then
// we don't actually use NOWRAP.
if (style->width().isFixed())
style->setWhiteSpace(NORMAL);
else
style->setWhiteSpace(NOWRAP);
}
}
// Tables never support the -webkit-* values for text-align and will reset back to the default.
if (e && e->hasTagName(tableTag) && (style->textAlign() == WEBKIT_LEFT || style->textAlign() == WEBKIT_CENTER || style->textAlign() == WEBKIT_RIGHT))
style->setTextAlign(TAAUTO);
// Frames and framesets never honor position:relative or position:absolute. This is necessary to
// fix a crash where a site tries to position these objects. They also never honor display.
if (e && (e->hasTagName(frameTag) || e->hasTagName(framesetTag))) {
style->setPosition(StaticPosition);
style->setDisplay(BLOCK);
}
// Table headers with a text-align of auto will change the text-align to center.
if (e && e->hasTagName(thTag) && style->textAlign() == TAAUTO)
style->setTextAlign(CENTER);
if (e && e->hasTagName(legendTag))
style->setDisplay(BLOCK);
// Mutate the display to BLOCK or TABLE for certain cases, e.g., if someone attempts to
// position or float an inline, compact, or run-in. Cache the original display, since it
// may be needed for positioned elements that have to compute their static normal flow
// positions. We also force inline-level roots to be block-level.
if (style->display() != BLOCK && style->display() != TABLE && style->display() != BOX &&
(style->position() == AbsolutePosition || style->position() == FixedPosition || style->floating() != FNONE ||
(e && e->document()->documentElement() == e))) {
if (style->display() == INLINE_TABLE)
style->setDisplay(TABLE);
else if (style->display() == INLINE_BOX)
style->setDisplay(BOX);
else if (style->display() == LIST_ITEM) {
// It is a WinIE bug that floated list items lose their bullets, so we'll emulate the quirk,
// but only in quirks mode.
if (!m_checker.m_strictParsing && style->floating() != FNONE)
style->setDisplay(BLOCK);
}
else
style->setDisplay(BLOCK);
}
// FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely
// clear how that should work.
if (style->display() == INLINE && style->styleType() == NOPSEUDO && parentStyle && style->writingMode() != parentStyle->writingMode())
style->setDisplay(INLINE_BLOCK);
// After performing the display mutation, check table rows. We do not honor position:relative on
// table rows or cells. This has been established in CSS2.1 (and caused a crash in containingBlock()
// on some sites).
if ((style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_ROW_GROUP
|| style->display() == TABLE_FOOTER_GROUP || style->display() == TABLE_ROW) &&
style->position() == RelativePosition)
style->setPosition(StaticPosition);
// writing-mode does not apply to table row groups, table column groups, table rows, and table columns.
// FIXME: Table cells should be allowed to be perpendicular or flipped with respect to the table, though.
if (style->display() == TABLE_COLUMN || style->display() == TABLE_COLUMN_GROUP || style->display() == TABLE_FOOTER_GROUP
|| style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_ROW || style->display() == TABLE_ROW_GROUP
|| style->display() == TABLE_CELL)
style->setWritingMode(parentStyle->writingMode());
// FIXME: Since we don't support block-flow on flexible boxes yet, disallow setting
// of block-flow to anything other than TopToBottomWritingMode.
// https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support.
if (style->writingMode() != TopToBottomWritingMode && (style->display() == BOX || style->display() == INLINE_BOX))
style->setWritingMode(TopToBottomWritingMode);
}
// Make sure our z-index value is only applied if the object is positioned.
if (style->position() == StaticPosition)
style->setHasAutoZIndex();
// Auto z-index becomes 0 for the root element and transparent objects. This prevents
// cases where objects that should be blended as a single unit end up with a non-transparent
// object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms/masks/reflections.
if (style->hasAutoZIndex() && ((e && e->document()->documentElement() == e) || style->opacity() < 1.0f ||
style->hasTransformRelatedProperty() || style->hasMask() || style->boxReflect()))
style->setZIndex(0);
#if ENABLE(WML)
if (e && (e->hasTagName(WMLNames::insertedLegendTag)
|| e->hasTagName(WMLNames::inputTag))
&& style->width().isAuto())
style->setWidth(Length(Intrinsic));
#endif
// Textarea considers overflow visible as auto.
if (e && e->hasTagName(textareaTag)) {
style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->overflowX());
style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->overflowY());
}
// Finally update our text decorations in effect, but don't allow text-decoration to percolate through
// tables, inline blocks, inline tables, run-ins, or shadow DOM.
if (style->display() == TABLE || style->display() == INLINE_TABLE || style->display() == RUN_IN
|| style->display() == INLINE_BLOCK || style->display() == INLINE_BOX || isAtShadowBoundary(e))
style->setTextDecorationsInEffect(style->textDecoration());
else
style->addToTextDecorationsInEffect(style->textDecoration());
// If either overflow value is not visible, change to auto.
if (style->overflowX() == OMARQUEE && style->overflowY() != OMARQUEE)
style->setOverflowY(OMARQUEE);
else if (style->overflowY() == OMARQUEE && style->overflowX() != OMARQUEE)
style->setOverflowX(OMARQUEE);
else if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE)
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.
style->adjustBackgroundLayers();
style->adjustMaskLayers();
// Do the same for animations and transitions.
style->adjustAnimations();
style->adjustTransitions();
// Important: Intrinsic margins get added to controls before the theme has adjusted the style, since the theme will
// alter fonts and heights/widths.
if (e && e->isFormControlElement() && style->fontSize() >= 11) {
// Don't apply intrinsic margins to image buttons. The designer knows how big the images are,
// so we have to treat all image buttons as though they were explicitly sized.
if (!e->hasTagName(inputTag) || !static_cast(e)->isImageButton())
addIntrinsicMargins(style);
}
// Let the theme also have a crack at adjusting the style.
if (style->hasAppearance())
RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_hasUAAppearance, m_borderData, m_backgroundData, m_backgroundColor);
#if ENABLE(SVG)
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 |