1e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch/* 2e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 6e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 9e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 10e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) Research In Motion Limited 2011. All rights reserved. 11e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Copyright (C) 2013 Google Inc. All rights reserved. 12e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * 13e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * This library is free software; you can redistribute it and/or 14e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * modify it under the terms of the GNU Library General Public 15e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * License as published by the Free Software Foundation; either 16e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * version 2 of the License, or (at your option) any later version. 17e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * 18e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * This library is distributed in the hope that it will be useful, 19e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * but WITHOUT ANY WARRANTY; without even the implied warranty of 20e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Library General Public License for more details. 22e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * 23e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * You should have received a copy of the GNU Library General Public License 24e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * along with this library; see the file COPYING.LIB. If not, write to 25e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 26e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch * Boston, MA 02110-1301, USA. 27e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch */ 28e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 29e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "config.h" 30e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/css/resolver/StyleAdjuster.h" 31e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 325d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#include "core/HTMLNames.h" 335d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#include "core/SVGNames.h" 347757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "core/dom/ContainerNode.h" 357757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "core/dom/Document.h" 367757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "core/dom/Element.h" 37aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch#include "core/dom/NodeRenderStyle.h" 38e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/html/HTMLIFrameElement.h" 39e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/html/HTMLInputElement.h" 405d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#include "core/html/HTMLPlugInElement.h" 41d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/html/HTMLTableCellElement.h" 42e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/html/HTMLTextAreaElement.h" 431e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "core/frame/FrameView.h" 4409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "core/frame/Settings.h" 45e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/rendering/RenderTheme.h" 467757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "core/rendering/style/GridPosition.h" 47e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/rendering/style/RenderStyle.h" 48e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/rendering/style/RenderStyleConstants.h" 49d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/svg/SVGSVGElement.h" 50bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)#include "platform/Length.h" 51d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "platform/transforms/TransformOperations.h" 527757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "wtf/Assertions.h" 53e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 54e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochnamespace WebCore { 55e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 56e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochusing namespace HTMLNames; 57e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 58e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch// FIXME: This is duplicated with StyleResolver.cpp 59e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch// Perhaps this should move onto ElementResolveContext or even Element? 60e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochstatic inline bool isAtShadowBoundary(const Element* element) 61e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch{ 62e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (!element) 63e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return false; 64e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch ContainerNode* parentNode = element->parentNode(); 65e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return parentNode && parentNode->isShadowRoot(); 66e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 67e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 68e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 69e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochstatic void addIntrinsicMargins(RenderStyle* style) 70e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch{ 71e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // Intrinsic margin value. 72e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch const int intrinsicMargin = 2 * style->effectiveZoom(); 73e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 74e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed. 75e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // FIXME: Using "quirk" to decide the margin wasn't set is kind of lame. 76e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->width().isIntrinsicOrAuto()) { 77e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->marginLeft().quirk()) 78e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setMarginLeft(Length(intrinsicMargin, Fixed)); 79e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->marginRight().quirk()) 80e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setMarginRight(Length(intrinsicMargin, Fixed)); 81e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch } 82e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 83e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->height().isAuto()) { 84e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->marginTop().quirk()) 85e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setMarginTop(Length(intrinsicMargin, Fixed)); 86e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->marginBottom().quirk()) 87e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setMarginBottom(Length(intrinsicMargin, Fixed)); 88e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch } 89e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 90e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 91e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochstatic EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool strictParsing) 92e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch{ 93e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch switch (display) { 94e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case BLOCK: 95e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE: 96e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case BOX: 97e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case FLEX: 98e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case GRID: 99e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return display; 100e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 101e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case LIST_ITEM: 102e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // It is a WinIE bug that floated list items lose their bullets, so we'll emulate the quirk, but only in quirks mode. 103e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (!strictParsing && isFloating) 104e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return BLOCK; 105e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return display; 106e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case INLINE_TABLE: 107e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return TABLE; 108e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case INLINE_BOX: 109e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return BOX; 110e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case INLINE_FLEX: 111e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return FLEX; 112e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case INLINE_GRID: 113e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return GRID; 114e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 115e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case INLINE: 116e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case INLINE_BLOCK: 117e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE_ROW_GROUP: 118e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE_HEADER_GROUP: 119e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE_FOOTER_GROUP: 120e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE_ROW: 121e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE_COLUMN_GROUP: 122e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE_COLUMN: 123e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE_CELL: 124e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case TABLE_CAPTION: 125e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return BLOCK; 126e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch case NONE: 127e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch ASSERT_NOT_REACHED(); 128e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return NONE; 129e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch } 130e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch ASSERT_NOT_REACHED(); 131e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return BLOCK; 132e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 133e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 134e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch// CSS requires text-decoration to be reset at each DOM element for tables, 13519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)// inline blocks, inline tables, shadow DOM crossings, floating elements, 136e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch// and absolute or relatively positioned elements. 137e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochstatic bool doesNotInheritTextDecoration(const RenderStyle* style, const Element* e) 138e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch{ 13919cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles) return style->display() == TABLE || style->display() == INLINE_TABLE 140e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->display() == INLINE_BLOCK || style->display() == INLINE_BOX || isAtShadowBoundary(e) 141e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->isFloating() || style->hasOutOfFlowPosition(); 142e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 143e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 144e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch// FIXME: This helper is only needed because pseudoStyleForElement passes a null 145e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch// element to adjustRenderStyle, so we can't just use element->isInTopLayer(). 146e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochstatic bool isInTopLayer(const Element* element, const RenderStyle* style) 147e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch{ 148e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return (element && element->isInTopLayer()) || (style && style->styleType() == BACKDROP); 149e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 150e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 151e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochstatic bool isDisplayFlexibleBox(EDisplay display) 152e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch{ 153e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return display == FLEX || display == INLINE_FLEX; 154e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 155e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 156e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochstatic bool isDisplayGridBox(EDisplay display) 157e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch{ 158e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch return display == GRID || display == INLINE_GRID; 159e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 160e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 1618abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)static bool parentStyleForcesZIndexToCreateStackingContext(const RenderStyle* parentStyle) 1628abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles){ 1638abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) return isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(parentStyle->display()); 1648abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)} 1658abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) 166323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)static bool hasWillChangeThatCreatesStackingContext(const RenderStyle* style) 167d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 168d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) for (size_t i = 0; i < style->willChangeProperties().size(); ++i) { 169d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) switch (style->willChangeProperties()[i]) { 170d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyOpacity: 171aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch case CSSPropertyTransform: 172d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyWebkitTransform: 17307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch case CSSPropertyTransformStyle: 174d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyWebkitTransformStyle: 175aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch case CSSPropertyPerspective: 176d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyWebkitPerspective: 177d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyWebkitMask: 178d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyWebkitMaskBoxImage: 179d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyWebkitClipPath: 180d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyWebkitBoxReflect: 181d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyWebkitFilter: 182d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyZIndex: 183d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyPosition: 184d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return true; 185d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyMixBlendMode: 186d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) case CSSPropertyIsolation: 187d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (RuntimeEnabledFeatures::cssCompositingEnabled()) 188d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return true; 189d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) break; 190d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) default: 191d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) break; 192d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 193d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 194d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return false; 195d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 196d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 1975d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e, const CachedUAStyle* cachedUAStyle) 198e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch{ 199e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch ASSERT(parentStyle); 200e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 201e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->display() != NONE) { 20243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (e) 20343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) adjustStyleForTagName(style, parentStyle, *e); 204e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 205e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // Per the spec, position 'static' and 'relative' in the top layer compute to 'absolute'. 206e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (isInTopLayer(e, style) && (style->position() == StaticPosition || style->position() == RelativePosition)) 207e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setPosition(AbsolutePosition); 208e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 209e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // Absolute/fixed positioned elements, floating elements and the document element need block-like outside display. 2108abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) if (style->hasOutOfFlowPosition() || style->isFloating() || (e && e->document().documentElement() == e)) 211e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), !m_useQuirksModeStyles)); 212e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 21343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) adjustStyleForDisplay(style, parentStyle); 214e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch } 215e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 216e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // Make sure our z-index value is only applied if the object is positioned. 2178abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) if (style->position() == StaticPosition && !parentStyleForcesZIndexToCreateStackingContext(parentStyle)) 218e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setHasAutoZIndex(); 219e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 220e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // Auto z-index becomes 0 for the root element and transparent objects. This prevents 221e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // cases where objects that should be blended as a single unit end up with a non-transparent 222e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms/masks/reflections. 2238abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) if (style->hasAutoZIndex() && ((e && e->document().documentElement() == e) 224e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->opacity() < 1.0f 225e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->hasTransformRelatedProperty() 226e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->hasMask() 227e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->clipPath() 228e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->boxReflect() 229e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->hasFilter() 230e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->hasBlendMode() 23151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) || style->hasIsolation() 232e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->position() == StickyPosition 23307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch || style->position() == FixedPosition 234e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || isInTopLayer(e, style) 235323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) || hasWillChangeThatCreatesStackingContext(style))) 236e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setZIndex(0); 237e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 238d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // will-change:transform should result in the same rendering behavior as having a transform, 239d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // including the creation of a containing block for fixed position descendants. 240aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch if (!style->hasTransform() && (style->willChangeProperties().contains(CSSPropertyWebkitTransform) || style->willChangeProperties().contains(CSSPropertyTransform))) { 241d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool makeIdentity = true; 242d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) style->setTransform(TransformOperations(makeIdentity)); 243d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 244d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 245e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (doesNotInheritTextDecoration(style, e)) 246d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) style->clearAppliedTextDecorations(); 247d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) 248d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) style->applyTextDecorations(); 249e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 25007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (style->overflowX() != OVISIBLE || style->overflowY() != OVISIBLE) 251323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) adjustOverflow(style); 252e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 253e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // Cull out any useless layers and also repeat patterns into additional layers. 254e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->adjustBackgroundLayers(); 255e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->adjustMaskLayers(); 256e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 257e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // Let the theme also have a crack at adjusting the style. 258e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->hasAppearance()) 2595d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) RenderTheme::theme().adjustStyle(style, e, cachedUAStyle); 260e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 26143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // If we have first-letter pseudo style, transitions, or animations, do not share this style. 26243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->hasPseudoStyle(FIRST_LETTER) || style->transitions() || style->animations()) 263e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setUnique(); 264e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 265e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // FIXME: when dropping the -webkit prefix on transform-style, we should also have opacity < 1 cause flattening. 266e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (style->preserves3D() && (style->overflowX() != OVISIBLE 267e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->overflowY() != OVISIBLE 268e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch || style->hasFilter())) 269e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setTransformStyle3D(TransformStyle3DFlat); 270e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 271e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch if (e && e->isSVGElement()) { 272e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch // Only the root <svg> element in an SVG document fragment tree honors css position 273d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (!(isSVGSVGElement(*e) && e->parentNode() && !e->parentNode()->isSVGElement())) 274e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch style->setPosition(RenderStyle::initialPosition()); 275e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 27651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) // SVG text layout code expects us to be a block-level style element. 277d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if ((isSVGForeignObjectElement(*e) || isSVGTextElement(*e)) && style->isDisplayInlineType()) 27851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) style->setDisplay(BLOCK); 279e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch } 280aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch 281aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch if (e && e->renderStyle() && e->renderStyle()->textAutosizingMultiplier() != 1) { 282aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch // Preserve the text autosizing multiplier on style recalc. 283aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch // (The autosizer will update it during layout if it needs to be changed.) 284aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch style->setTextAutosizingMultiplier(e->renderStyle()->textAutosizingMultiplier()); 285aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch style->setUnique(); 286aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch } 287e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 288e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch 28943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)void StyleAdjuster::adjustStyleForTagName(RenderStyle* style, RenderStyle* parentStyle, Element& element) 29043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles){ 29143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // <div> and <span> are the most common elements on the web, we skip all the work for them. 29243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 29343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 29443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 29543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isHTMLTableCellElement(element)) { 29643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // If we have a <td> that specifies a float property, in quirks mode we just drop the float property. 29743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // FIXME: Why is this only <td> and not <th>? 29843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (element.hasTagName(tdTag) && m_useQuirksModeStyles) { 29943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setDisplay(TABLE_CELL); 30043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setFloating(NoFloat); 30143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 30243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // FIXME: We shouldn't be overriding start/-webkit-auto like this. Do it in html.css instead. 30343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Table headers with a text-align of -webkit-auto will change the text-align to center. 30443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (element.hasTagName(thTag) && style->textAlign() == TASTART) 30543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setTextAlign(CENTER); 30643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->whiteSpace() == KHTML_NOWRAP) { 30743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Figure out if we are really nowrapping or if we should just 30843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // use normal instead. If the width of the cell is fixed, then 30943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // we don't actually use NOWRAP. 31043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->width().isFixed()) 31143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setWhiteSpace(NORMAL); 31243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) else 31343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setWhiteSpace(NOWRAP); 31443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 31543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 31643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 31743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 31843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isHTMLTableElement(element)) { 31943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Sites commonly use display:inline/block on <td>s and <table>s. In quirks mode we force 32043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // these tags to retain their display types. 32143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (m_useQuirksModeStyles) 32243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setDisplay(style->isDisplayInlineType() ? INLINE_TABLE : TABLE); 32343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Tables never support the -webkit-* values for text-align and will reset back to the default. 32443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->textAlign() == WEBKIT_LEFT || style->textAlign() == WEBKIT_CENTER || style->textAlign() == WEBKIT_RIGHT) 32543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setTextAlign(TASTART); 32643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 32743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 32843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 32943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) { 33043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Frames and framesets never honor position:relative or position:absolute. This is necessary to 33143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // fix a crash where a site tries to position these objects. They also never honor display. 33243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setPosition(StaticPosition); 33343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setDisplay(BLOCK); 33443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 33543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 33643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 33743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isHTMLRTElement(element)) { 33843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Ruby text does not support float or position. This might change with evolution of the specification. 33943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setPosition(StaticPosition); 34043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setFloating(NoFloat); 34143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 34243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 34343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 34443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isHTMLLegendElement(element)) { 34543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setDisplay(BLOCK); 34643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 34743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 34843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 34943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isHTMLMarqueeElement(element)) { 35043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // For now, <marquee> requires an overflow clip to work properly. 35143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setOverflowX(OHIDDEN); 35243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setOverflowY(OHIDDEN); 35343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 35443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 35543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 35643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (element.isFormControlElement()) { 35743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isHTMLTextAreaElement(element)) { 35843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Textarea considers overflow visible as auto. 35943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->overflowX()); 36043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->overflowY()); 36143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 36243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 36343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Important: Intrinsic margins get added to controls before the theme has adjusted the style, 36443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // since the theme will alter fonts and heights/widths. 36543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // 36643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Don't apply intrinsic margins to image buttons. The designer knows how big the images are, 36743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // so we have to treat all image buttons as though they were explicitly sized. 36843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->fontSize() >= 11 && (!isHTMLInputElement(element) || !toHTMLInputElement(element).isImageButton())) 36943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) addIntrinsicMargins(style); 37043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 37143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 3725d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) 3735d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) if (isHTMLPlugInElement(element)) { 3745d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) style->setRequiresAcceleratedCompositingForExternalReasons(toHTMLPlugInElement(element).shouldAccelerate()); 3755d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) return; 3765d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) } 37743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)} 37843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 379323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)void StyleAdjuster::adjustOverflow(RenderStyle* style) 38007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch{ 38107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch ASSERT(style->overflowX() != OVISIBLE || style->overflowY() != OVISIBLE); 38207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 38307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // If either overflow value is not visible, change to auto. 38407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { 38507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // FIXME: Once we implement pagination controls, overflow-x should default to hidden 38607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, we'll let it 38707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // default to auto so we can at least scroll through the pages. 38807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch style->setOverflowX(OAUTO); 38907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE) { 39007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch style->setOverflowY(OAUTO); 39107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch } 39207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 39307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // Table rows, sections and the table itself will support overflow:hidden and will ignore scroll/auto. 39407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // FIXME: Eventually table sections will support auto and scroll. 39507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (style->display() == TABLE || style->display() == INLINE_TABLE 39607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch || style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW) { 39707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (style->overflowX() != OVISIBLE && style->overflowX() != OHIDDEN) 39807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch style->setOverflowX(OVISIBLE); 39907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (style->overflowY() != OVISIBLE && style->overflowY() != OHIDDEN) 40007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch style->setOverflowY(OVISIBLE); 40107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch } 40207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 40307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // Menulists should have visible overflow 40407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (style->appearance() == MenulistPart) { 40507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch style->setOverflowX(OVISIBLE); 40607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch style->setOverflowY(OVISIBLE); 40707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch } 40807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch} 40907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 41043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* parentStyle) 41143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles){ 41243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->display() == BLOCK && !style->isFloating()) 41343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) return; 41443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 41543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely 41643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // clear how that should work. 41743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->display() == INLINE && style->styleType() == NOPSEUDO && style->writingMode() != parentStyle->writingMode()) 41843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setDisplay(INLINE_BLOCK); 41943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 42043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // After performing the display mutation, check table rows. We do not honor position: relative table rows or cells. 42143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // This has been established for position: relative in CSS2.1 (and caused a crash in containingBlock() 42243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // on some sites). 42343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if ((style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_ROW_GROUP 42443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) || style->display() == TABLE_FOOTER_GROUP || style->display() == TABLE_ROW) 42543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) && style->position() == RelativePosition) 42643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setPosition(StaticPosition); 42743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 42843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // Cannot support position: sticky for table columns and column groups because current code is only doing 42943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // background painting through columns / column groups 43043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if ((style->display() == TABLE_COLUMN_GROUP || style->display() == TABLE_COLUMN) 43143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) && style->position() == StickyPosition) 43243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setPosition(StaticPosition); 43343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 43443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // writing-mode does not apply to table row groups, table column groups, table rows, and table columns. 43543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // FIXME: Table cells should be allowed to be perpendicular or flipped with respect to the table, though. 43643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->display() == TABLE_COLUMN || style->display() == TABLE_COLUMN_GROUP || style->display() == TABLE_FOOTER_GROUP 43743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) || style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_ROW || style->display() == TABLE_ROW_GROUP 43843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) || style->display() == TABLE_CELL) 43943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setWritingMode(parentStyle->writingMode()); 44043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 44143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // FIXME: Since we don't support block-flow on flexible boxes yet, disallow setting 44243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // of block-flow to anything other than TopToBottomWritingMode. 44343e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support. 44443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (style->writingMode() != TopToBottomWritingMode && (style->display() == BOX || style->display() == INLINE_BOX)) 44543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setWritingMode(TopToBottomWritingMode); 44643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 44743e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) if (isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(parentStyle->display())) { 44843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setFloating(NoFloat); 44943e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), !m_useQuirksModeStyles)); 45043e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) } 45143e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)} 45243e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) 453e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch} 454