Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: Source/core/css/resolver/StyleAdjuster.cpp

Issue 214413011: Skip overflow adjustment checks when possible in StyleAdjuster (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/resolver/StyleAdjuster.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 || style->hasTransformRelatedProperty() 224 || style->hasTransformRelatedProperty()
225 || style->hasMask() 225 || style->hasMask()
226 || style->clipPath() 226 || style->clipPath()
227 || style->boxReflect() 227 || style->boxReflect()
228 || style->hasFilter() 228 || style->hasFilter()
229 || style->hasBlendMode() 229 || style->hasBlendMode()
230 || style->hasIsolation() 230 || style->hasIsolation()
231 || style->position() == StickyPosition 231 || style->position() == StickyPosition
232 || style->position() == FixedPosition 232 || style->position() == FixedPosition
233 || isInTopLayer(e, style) 233 || isInTopLayer(e, style)
234 || hasWillChangeThatCreatesStackingContext(style, e) 234 || hasWillChangeThatCreatesStackingContext(style, e)))
235 ))
236 style->setZIndex(0); 235 style->setZIndex(0);
237 236
238 // will-change:transform should result in the same rendering behavior as hav ing a transform, 237 // will-change:transform should result in the same rendering behavior as hav ing a transform,
239 // including the creation of a containing block for fixed position descendan ts. 238 // including the creation of a containing block for fixed position descendan ts.
240 if (!style->hasTransform() && style->willChangeProperties().contains(CSSProp ertyWebkitTransform)) { 239 if (!style->hasTransform() && style->willChangeProperties().contains(CSSProp ertyWebkitTransform)) {
241 bool makeIdentity = true; 240 bool makeIdentity = true;
242 style->setTransform(TransformOperations(makeIdentity)); 241 style->setTransform(TransformOperations(makeIdentity));
243 } 242 }
244 243
245 if (doesNotInheritTextDecoration(style, e)) 244 if (doesNotInheritTextDecoration(style, e))
246 style->setTextDecorationsInEffect(style->textDecoration()); 245 style->setTextDecorationsInEffect(style->textDecoration());
247 else 246 else
248 style->addToTextDecorationsInEffect(style->textDecoration()); 247 style->addToTextDecorationsInEffect(style->textDecoration());
249 248
250 // If either overflow value is not visible, change to auto. 249 if (style->overflowX() != OVISIBLE || style->overflowY() != OVISIBLE)
251 if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { 250 adjustOverflow(style, e);
252 // FIXME: Once we implement pagination controls, overflow-x should defau lt to hidden
253 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w e'll let it
254 // default to auto so we can at least scroll through the pages.
255 style->setOverflowX(OAUTO);
256 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE) {
257 style->setOverflowY(OAUTO);
258 }
259
260 // Table rows, sections and the table itself will support overflow:hidden an d will ignore scroll/auto.
261 // FIXME: Eventually table sections will support auto and scroll.
262 if (style->display() == TABLE || style->display() == INLINE_TABLE
263 || style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW) {
264 if (style->overflowX() != OVISIBLE && style->overflowX() != OHIDDEN)
265 style->setOverflowX(OVISIBLE);
266 if (style->overflowY() != OVISIBLE && style->overflowY() != OHIDDEN)
267 style->setOverflowY(OVISIBLE);
268 }
269
270 // Menulists should have visible overflow
271 if (style->appearance() == MenulistPart) {
272 style->setOverflowX(OVISIBLE);
273 style->setOverflowY(OVISIBLE);
274 }
275 251
276 // Cull out any useless layers and also repeat patterns into additional laye rs. 252 // Cull out any useless layers and also repeat patterns into additional laye rs.
277 style->adjustBackgroundLayers(); 253 style->adjustBackgroundLayers();
278 style->adjustMaskLayers(); 254 style->adjustMaskLayers();
279 255
280 // Let the theme also have a crack at adjusting the style. 256 // Let the theme also have a crack at adjusting the style.
281 if (style->hasAppearance()) 257 if (style->hasAppearance())
282 RenderTheme::theme().adjustStyle(style, e, m_cachedUAStyle); 258 RenderTheme::theme().adjustStyle(style, e, m_cachedUAStyle);
283 259
284 // If we have first-letter pseudo style, transitions, or animations, do not share this style. 260 // If we have first-letter pseudo style, transitions, or animations, do not share this style.
285 if (style->hasPseudoStyle(FIRST_LETTER) || style->transitions() || style->an imations()) 261 if (style->hasPseudoStyle(FIRST_LETTER) || style->transitions() || style->an imations())
286 style->setUnique(); 262 style->setUnique();
287 263
288 // FIXME: when dropping the -webkit prefix on transform-style, we should als o have opacity < 1 cause flattening. 264 // FIXME: when dropping the -webkit prefix on transform-style, we should als o have opacity < 1 cause flattening.
289 if (style->preserves3D() && (style->overflowX() != OVISIBLE 265 if (style->preserves3D() && (style->overflowX() != OVISIBLE
290 || style->overflowY() != OVISIBLE 266 || style->overflowY() != OVISIBLE
291 || style->hasFilter())) 267 || style->hasFilter()))
292 style->setTransformStyle3D(TransformStyle3DFlat); 268 style->setTransformStyle3D(TransformStyle3DFlat);
293 269
294 if (e && e->isSVGElement()) { 270 if (e && e->isSVGElement()) {
295 // Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
296 if (style->overflowY() == OSCROLL)
297 style->setOverflowY(OHIDDEN);
298 else if (style->overflowY() == OAUTO)
299 style->setOverflowY(OVISIBLE);
300
301 if (style->overflowX() == OSCROLL)
302 style->setOverflowX(OHIDDEN);
303 else if (style->overflowX() == OAUTO)
304 style->setOverflowX(OVISIBLE);
305
306 // Only the root <svg> element in an SVG document fragment tree honors c ss position 271 // Only the root <svg> element in an SVG document fragment tree honors c ss position
307 if (!(isSVGSVGElement(*e) && e->parentNode() && !e->parentNode()->isSVGE lement())) 272 if (!(isSVGSVGElement(*e) && e->parentNode() && !e->parentNode()->isSVGE lement()))
308 style->setPosition(RenderStyle::initialPosition()); 273 style->setPosition(RenderStyle::initialPosition());
309 274
310 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should 275 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should
311 // not be scaled again. 276 // not be scaled again.
312 if (isSVGForeignObjectElement(*e)) 277 if (isSVGForeignObjectElement(*e))
313 style->setEffectiveZoom(RenderStyle::initialZoom()); 278 style->setEffectiveZoom(RenderStyle::initialZoom());
314 279
315 // SVG text layout code expects us to be a block-level style element. 280 // SVG text layout code expects us to be a block-level style element.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // since the theme will alter fonts and heights/widths. 361 // since the theme will alter fonts and heights/widths.
397 // 362 //
398 // Don't apply intrinsic margins to image buttons. The designer knows ho w big the images are, 363 // Don't apply intrinsic margins to image buttons. The designer knows ho w big the images are,
399 // so we have to treat all image buttons as though they were explicitly sized. 364 // so we have to treat all image buttons as though they were explicitly sized.
400 if (style->fontSize() >= 11 && (!isHTMLInputElement(element) || !toHTMLI nputElement(element).isImageButton())) 365 if (style->fontSize() >= 11 && (!isHTMLInputElement(element) || !toHTMLI nputElement(element).isImageButton()))
401 addIntrinsicMargins(style); 366 addIntrinsicMargins(style);
402 return; 367 return;
403 } 368 }
404 } 369 }
405 370
371 void StyleAdjuster::adjustOverflow(RenderStyle* style, Element* element)
372 {
373 ASSERT(style->overflowX() != OVISIBLE || style->overflowY() != OVISIBLE);
374
375 // If either overflow value is not visible, change to auto.
376 if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) {
377 // FIXME: Once we implement pagination controls, overflow-x should defau lt to hidden
378 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w e'll let it
379 // default to auto so we can at least scroll through the pages.
380 style->setOverflowX(OAUTO);
381 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE) {
382 style->setOverflowY(OAUTO);
383 }
384
385 // Table rows, sections and the table itself will support overflow:hidden an d will ignore scroll/auto.
386 // FIXME: Eventually table sections will support auto and scroll.
387 if (style->display() == TABLE || style->display() == INLINE_TABLE
388 || style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW) {
389 if (style->overflowX() != OVISIBLE && style->overflowX() != OHIDDEN)
390 style->setOverflowX(OVISIBLE);
391 if (style->overflowY() != OVISIBLE && style->overflowY() != OHIDDEN)
392 style->setOverflowY(OVISIBLE);
393 }
394
395 // Menulists should have visible overflow
396 if (style->appearance() == MenulistPart) {
397 style->setOverflowX(OVISIBLE);
398 style->setOverflowY(OVISIBLE);
399 }
400
401 // Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
402 if (element && element->isSVGElement()) {
403 if (style->overflowY() == OSCROLL)
404 style->setOverflowY(OHIDDEN);
405 else if (style->overflowY() == OAUTO)
406 style->setOverflowY(OVISIBLE);
407
408 if (style->overflowX() == OSCROLL)
409 style->setOverflowX(OHIDDEN);
410 else if (style->overflowX() == OAUTO)
411 style->setOverflowX(OVISIBLE);
412 }
413 }
414
406 void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* paren tStyle) 415 void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* paren tStyle)
407 { 416 {
408 if (style->display() == BLOCK && !style->isFloating()) 417 if (style->display() == BLOCK && !style->isFloating())
409 return; 418 return;
410 419
411 // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely 420 // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely
412 // clear how that should work. 421 // clear how that should work.
413 if (style->display() == INLINE && style->styleType() == NOPSEUDO && style->w ritingMode() != parentStyle->writingMode()) 422 if (style->display() == INLINE && style->styleType() == NOPSEUDO && style->w ritingMode() != parentStyle->writingMode())
414 style->setDisplay(INLINE_BLOCK); 423 style->setDisplay(INLINE_BLOCK);
415 424
(...skipping 24 matching lines...) Expand all
440 if (style->writingMode() != TopToBottomWritingMode && (style->display() == B OX || style->display() == INLINE_BOX)) 449 if (style->writingMode() != TopToBottomWritingMode && (style->display() == B OX || style->display() == INLINE_BOX))
441 style->setWritingMode(TopToBottomWritingMode); 450 style->setWritingMode(TopToBottomWritingMode);
442 451
443 if (isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(parentS tyle->display())) { 452 if (isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(parentS tyle->display())) {
444 style->setFloating(NoFloat); 453 style->setFloating(NoFloat);
445 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloa ting(), !m_useQuirksModeStyles)); 454 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloa ting(), !m_useQuirksModeStyles));
446 } 455 }
447 } 456 }
448 457
449 } 458 }
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleAdjuster.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698