| OLD | NEW |
| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 static bool isInTopLayer(const Element* element, const ComputedStyle& style) | 112 static bool isInTopLayer(const Element* element, const ComputedStyle& style) |
| 113 { | 113 { |
| 114 return (element && element->isInTopLayer()) || style.styleType() == PseudoId
Backdrop; | 114 return (element && element->isInTopLayer()) || style.styleType() == PseudoId
Backdrop; |
| 115 } | 115 } |
| 116 | 116 |
| 117 static bool parentStyleForcesZIndexToCreateStackingContext(const ComputedStyle&
parentStyle) | 117 static bool parentStyleForcesZIndexToCreateStackingContext(const ComputedStyle&
parentStyle) |
| 118 { | 118 { |
| 119 return parentStyle.isDisplayFlexibleOrGridBox(); | 119 return parentStyle.isDisplayFlexibleOrGridBox(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 static bool hasWillChangeThatCreatesStackingContext(const ComputedStyle& style) | |
| 123 { | |
| 124 for (size_t i = 0; i < style.willChangeProperties().size(); ++i) { | |
| 125 switch (style.willChangeProperties()[i]) { | |
| 126 case CSSPropertyOpacity: | |
| 127 case CSSPropertyTransform: | |
| 128 case CSSPropertyAliasWebkitTransform: | |
| 129 case CSSPropertyTransformStyle: | |
| 130 case CSSPropertyAliasWebkitTransformStyle: | |
| 131 case CSSPropertyPerspective: | |
| 132 case CSSPropertyAliasWebkitPerspective: | |
| 133 case CSSPropertyWebkitMask: | |
| 134 case CSSPropertyWebkitMaskBoxImage: | |
| 135 case CSSPropertyWebkitClipPath: | |
| 136 case CSSPropertyWebkitBoxReflect: | |
| 137 case CSSPropertyFilter: | |
| 138 case CSSPropertyAliasWebkitFilter: | |
| 139 case CSSPropertyBackdropFilter: | |
| 140 case CSSPropertyZIndex: | |
| 141 case CSSPropertyPosition: | |
| 142 case CSSPropertyMixBlendMode: | |
| 143 case CSSPropertyIsolation: | |
| 144 return true; | |
| 145 default: | |
| 146 break; | |
| 147 } | |
| 148 } | |
| 149 return false; | |
| 150 } | |
| 151 | |
| 152 void StyleAdjuster::adjustStyleForEditing(ComputedStyle& style) | 122 void StyleAdjuster::adjustStyleForEditing(ComputedStyle& style) |
| 153 { | 123 { |
| 154 if (style.userModify() != READ_WRITE_PLAINTEXT_ONLY) | 124 if (style.userModify() != READ_WRITE_PLAINTEXT_ONLY) |
| 155 return; | 125 return; |
| 156 // Collapsing whitespace is harmful in plain-text editing. | 126 // Collapsing whitespace is harmful in plain-text editing. |
| 157 if (style.whiteSpace() == NORMAL) | 127 if (style.whiteSpace() == NORMAL) |
| 158 style.setWhiteSpace(PRE_WRAP); | 128 style.setWhiteSpace(PRE_WRAP); |
| 159 else if (style.whiteSpace() == NOWRAP) | 129 else if (style.whiteSpace() == NOWRAP) |
| 160 style.setWhiteSpace(PRE); | 130 style.setWhiteSpace(PRE); |
| 161 else if (style.whiteSpace() == PRE_LINE) | 131 else if (style.whiteSpace() == PRE_LINE) |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 if (style.containsPaint() && style.display() == INLINE) | 361 if (style.containsPaint() && style.display() == INLINE) |
| 392 style.setDisplay(BLOCK); | 362 style.setDisplay(BLOCK); |
| 393 } else { | 363 } else { |
| 394 adjustStyleForFirstLetter(style); | 364 adjustStyleForFirstLetter(style); |
| 395 } | 365 } |
| 396 | 366 |
| 397 if (element && element->hasCompositorProxy()) | 367 if (element && element->hasCompositorProxy()) |
| 398 style.setHasCompositorProxy(true); | 368 style.setHasCompositorProxy(true); |
| 399 | 369 |
| 400 // Make sure our z-index value is only applied if the object is positioned. | 370 // Make sure our z-index value is only applied if the object is positioned. |
| 401 if (style.position() == StaticPosition && !parentStyleForcesZIndexToCreateSt
ackingContext(parentStyle)) | 371 if (style.position() == StaticPosition && !parentStyleForcesZIndexToCreateSt
ackingContext(parentStyle)) { |
| 402 style.setHasAutoZIndex(); | 372 style.setIsStackingContext(false); |
| 373 // TODO(alancutter): Avoid altering z-index here. |
| 374 if (!style.hasAutoZIndex()) |
| 375 style.setZIndex(0); |
| 376 } else if (!style.hasAutoZIndex()) { |
| 377 style.setIsStackingContext(true); |
| 378 } |
| 403 | 379 |
| 404 if (style.overflowX() != OverflowVisible || style.overflowY() != OverflowVis
ible) | 380 if (style.overflowX() != OverflowVisible || style.overflowY() != OverflowVis
ible) |
| 405 adjustOverflow(style); | 381 adjustOverflow(style); |
| 406 | 382 |
| 407 // Auto z-index becomes 0 for the root element and transparent objects. This
prevents | |
| 408 // cases where objects that should be blended as a single unit end up with a
non-transparent | |
| 409 // object wedged in between them. Auto z-index also becomes 0 for objects th
at specify transforms/masks/reflections. | |
| 410 if (style.hasAutoZIndex() && ((element && element->document().documentElemen
t() == element) | |
| 411 || style.hasOpacity() | |
| 412 || style.hasTransformRelatedProperty() | |
| 413 || style.hasMask() | |
| 414 || style.clipPath() | |
| 415 || style.boxReflect() | |
| 416 || style.hasFilterInducingProperty() | |
| 417 || style.hasBlendMode() | |
| 418 || style.hasIsolation() | |
| 419 || style.hasViewportConstrainedPosition() | |
| 420 || isInTopLayer(element, style) | |
| 421 || hasWillChangeThatCreatesStackingContext(style) | |
| 422 || style.containsPaint())) | |
| 423 style.setZIndex(0); | |
| 424 | |
| 425 if (doesNotInheritTextDecoration(style, element)) | 383 if (doesNotInheritTextDecoration(style, element)) |
| 426 style.clearAppliedTextDecorations(); | 384 style.clearAppliedTextDecorations(); |
| 427 | 385 |
| 428 style.applyTextDecorations(); | 386 style.applyTextDecorations(); |
| 429 | 387 |
| 430 // Cull out any useless layers and also repeat patterns into additional laye
rs. | 388 // Cull out any useless layers and also repeat patterns into additional laye
rs. |
| 431 style.adjustBackgroundLayers(); | 389 style.adjustBackgroundLayers(); |
| 432 style.adjustMaskLayers(); | 390 style.adjustMaskLayers(); |
| 433 | 391 |
| 434 // Let the theme also have a crack at adjusting the style. | 392 // Let the theme also have a crack at adjusting the style. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 452 style.setDisplay(BLOCK); | 410 style.setDisplay(BLOCK); |
| 453 | 411 |
| 454 // Columns don't apply to svg text elements. | 412 // Columns don't apply to svg text elements. |
| 455 if (isSVGTextElement(*element)) | 413 if (isSVGTextElement(*element)) |
| 456 style.clearMultiCol(); | 414 style.clearMultiCol(); |
| 457 } | 415 } |
| 458 adjustStyleForAlignment(style, parentStyle); | 416 adjustStyleForAlignment(style, parentStyle); |
| 459 } | 417 } |
| 460 | 418 |
| 461 } // namespace blink | 419 } // namespace blink |
| OLD | NEW |