| 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. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 148 } |
| 149 | 149 |
| 150 static void adjustStyleForFirstLetter(ComputedStyle& style) { | 150 static void adjustStyleForFirstLetter(ComputedStyle& style) { |
| 151 if (style.styleType() != PseudoIdFirstLetter) | 151 if (style.styleType() != PseudoIdFirstLetter) |
| 152 return; | 152 return; |
| 153 | 153 |
| 154 // Force inline display (except for floating first-letters). | 154 // Force inline display (except for floating first-letters). |
| 155 style.setDisplay(style.isFloating() ? EDisplay::Block : EDisplay::Inline); | 155 style.setDisplay(style.isFloating() ? EDisplay::Block : EDisplay::Inline); |
| 156 | 156 |
| 157 // CSS2 says first-letter can't be positioned. | 157 // CSS2 says first-letter can't be positioned. |
| 158 style.setPosition(StaticPosition); | 158 style.setPosition(EPosition::kStatic); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, | 161 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, |
| 162 const ComputedStyle& parentStyle) { | 162 const ComputedStyle& parentStyle) { |
| 163 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto' | 163 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto' |
| 164 // flag to not just mean 'auto' prior to running the StyleAdjuster but also | 164 // flag to not just mean 'auto' prior to running the StyleAdjuster but also |
| 165 // mean 'normal' after running it. | 165 // mean 'normal' after running it. |
| 166 | 166 |
| 167 // If the inherited value of justify-items includes the 'legacy' keyword, | 167 // If the inherited value of justify-items includes the 'legacy' keyword, |
| 168 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to | 168 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 style.textAlign() == ETextAlign::kWebkitCenter || | 216 style.textAlign() == ETextAlign::kWebkitCenter || |
| 217 style.textAlign() == ETextAlign::kWebkitRight) | 217 style.textAlign() == ETextAlign::kWebkitRight) |
| 218 style.setTextAlign(ETextAlign::kStart); | 218 style.setTextAlign(ETextAlign::kStart); |
| 219 return; | 219 return; |
| 220 } | 220 } |
| 221 | 221 |
| 222 if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) { | 222 if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) { |
| 223 // Frames and framesets never honor position:relative or position:absolute. | 223 // Frames and framesets never honor position:relative or position:absolute. |
| 224 // This is necessary to fix a crash where a site tries to position these | 224 // This is necessary to fix a crash where a site tries to position these |
| 225 // objects. They also never honor display. | 225 // objects. They also never honor display. |
| 226 style.setPosition(StaticPosition); | 226 style.setPosition(EPosition::kStatic); |
| 227 style.setDisplay(EDisplay::Block); | 227 style.setDisplay(EDisplay::Block); |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 | 230 |
| 231 if (isHTMLFrameElementBase(element)) { | 231 if (isHTMLFrameElementBase(element)) { |
| 232 // Frames cannot overflow (they are always the size we ask them to be). | 232 // Frames cannot overflow (they are always the size we ask them to be). |
| 233 // Some compositing code paths may try to draw scrollbars anyhow. | 233 // Some compositing code paths may try to draw scrollbars anyhow. |
| 234 style.setOverflowX(EOverflow::kVisible); | 234 style.setOverflowX(EOverflow::kVisible); |
| 235 style.setOverflowY(EOverflow::kVisible); | 235 style.setOverflowY(EOverflow::kVisible); |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 | 238 |
| 239 if (isHTMLRTElement(element)) { | 239 if (isHTMLRTElement(element)) { |
| 240 // Ruby text does not support float or position. This might change with | 240 // Ruby text does not support float or position. This might change with |
| 241 // evolution of the specification. | 241 // evolution of the specification. |
| 242 style.setPosition(StaticPosition); | 242 style.setPosition(EPosition::kStatic); |
| 243 style.setFloating(EFloat::kNone); | 243 style.setFloating(EFloat::kNone); |
| 244 return; | 244 return; |
| 245 } | 245 } |
| 246 | 246 |
| 247 if (isHTMLLegendElement(element)) { | 247 if (isHTMLLegendElement(element)) { |
| 248 style.setDisplay(EDisplay::Block); | 248 style.setDisplay(EDisplay::Block); |
| 249 return; | 249 return; |
| 250 } | 250 } |
| 251 | 251 |
| 252 if (isHTMLMarqueeElement(element)) { | 252 if (isHTMLMarqueeElement(element)) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 style.getWritingMode() != parentStyle.getWritingMode()) | 329 style.getWritingMode() != parentStyle.getWritingMode()) |
| 330 style.setDisplay(EDisplay::InlineBlock); | 330 style.setDisplay(EDisplay::InlineBlock); |
| 331 | 331 |
| 332 // After performing the display mutation, check table rows. We do not honor | 332 // After performing the display mutation, check table rows. We do not honor |
| 333 // position: relative table rows. This has been established for position: | 333 // position: relative table rows. This has been established for position: |
| 334 // relative in CSS2.1 (and caused a crash in containingBlock() on some sites). | 334 // relative in CSS2.1 (and caused a crash in containingBlock() on some sites). |
| 335 if ((style.display() == EDisplay::TableHeaderGroup || | 335 if ((style.display() == EDisplay::TableHeaderGroup || |
| 336 style.display() == EDisplay::TableRowGroup || | 336 style.display() == EDisplay::TableRowGroup || |
| 337 style.display() == EDisplay::TableFooterGroup || | 337 style.display() == EDisplay::TableFooterGroup || |
| 338 style.display() == EDisplay::TableRow) && | 338 style.display() == EDisplay::TableRow) && |
| 339 style.position() == RelativePosition) | 339 style.position() == EPosition::kRelative) |
| 340 style.setPosition(StaticPosition); | 340 style.setPosition(EPosition::kStatic); |
| 341 | 341 |
| 342 // Cannot support position: sticky for table columns and column groups because | 342 // Cannot support position: sticky for table columns and column groups because |
| 343 // current code is only doing background painting through columns / column | 343 // current code is only doing background painting through columns / column |
| 344 // groups. | 344 // groups. |
| 345 if ((style.display() == EDisplay::TableColumnGroup || | 345 if ((style.display() == EDisplay::TableColumnGroup || |
| 346 style.display() == EDisplay::TableColumn) && | 346 style.display() == EDisplay::TableColumn) && |
| 347 style.position() == StickyPosition) | 347 style.position() == EPosition::kSticky) |
| 348 style.setPosition(StaticPosition); | 348 style.setPosition(EPosition::kStatic); |
| 349 | 349 |
| 350 // writing-mode does not apply to table row groups, table column groups, table | 350 // writing-mode does not apply to table row groups, table column groups, table |
| 351 // rows, and table columns. | 351 // rows, and table columns. |
| 352 // FIXME: Table cells should be allowed to be perpendicular or flipped with | 352 // FIXME: Table cells should be allowed to be perpendicular or flipped with |
| 353 // respect to the table, though. | 353 // respect to the table, though. |
| 354 if (style.display() == EDisplay::TableColumn || | 354 if (style.display() == EDisplay::TableColumn || |
| 355 style.display() == EDisplay::TableColumnGroup || | 355 style.display() == EDisplay::TableColumnGroup || |
| 356 style.display() == EDisplay::TableFooterGroup || | 356 style.display() == EDisplay::TableFooterGroup || |
| 357 style.display() == EDisplay::TableHeaderGroup || | 357 style.display() == EDisplay::TableHeaderGroup || |
| 358 style.display() == EDisplay::TableRow || | 358 style.display() == EDisplay::TableRow || |
| (...skipping 28 matching lines...) Expand all Loading... |
| 387 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, | 387 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, |
| 388 const ComputedStyle& parentStyle, | 388 const ComputedStyle& parentStyle, |
| 389 Element* element) { | 389 Element* element) { |
| 390 if (style.display() != EDisplay::None && | 390 if (style.display() != EDisplay::None && |
| 391 style.display() != EDisplay::Contents) { | 391 style.display() != EDisplay::Contents) { |
| 392 if (element && element->isHTMLElement()) | 392 if (element && element->isHTMLElement()) |
| 393 adjustStyleForHTMLElement(style, toHTMLElement(*element)); | 393 adjustStyleForHTMLElement(style, toHTMLElement(*element)); |
| 394 | 394 |
| 395 // Per the spec, position 'static' and 'relative' in the top layer compute | 395 // Per the spec, position 'static' and 'relative' in the top layer compute |
| 396 // to 'absolute'. | 396 // to 'absolute'. |
| 397 if (isInTopLayer(element, style) && (style.position() == StaticPosition || | 397 if (isInTopLayer(element, style) && |
| 398 style.position() == RelativePosition)) | 398 (style.position() == EPosition::kStatic || |
| 399 style.setPosition(AbsolutePosition); | 399 style.position() == EPosition::kRelative)) |
| 400 style.setPosition(EPosition::kAbsolute); |
| 400 | 401 |
| 401 // Absolute/fixed positioned elements, floating elements and the document | 402 // Absolute/fixed positioned elements, floating elements and the document |
| 402 // element need block-like outside display. | 403 // element need block-like outside display. |
| 403 if (style.hasOutOfFlowPosition() || style.isFloating() || | 404 if (style.hasOutOfFlowPosition() || style.isFloating() || |
| 404 (element && element->document().documentElement() == element)) | 405 (element && element->document().documentElement() == element)) |
| 405 style.setDisplay(equivalentBlockDisplay(style.display())); | 406 style.setDisplay(equivalentBlockDisplay(style.display())); |
| 406 | 407 |
| 407 // We don't adjust the first letter style earlier because we may change the | 408 // We don't adjust the first letter style earlier because we may change the |
| 408 // display setting in adjustStyeForTagName() above. | 409 // display setting in adjustStyeForTagName() above. |
| 409 adjustStyleForFirstLetter(style); | 410 adjustStyleForFirstLetter(style); |
| 410 | 411 |
| 411 adjustStyleForDisplay(style, parentStyle, | 412 adjustStyleForDisplay(style, parentStyle, |
| 412 element ? &element->document() : 0); | 413 element ? &element->document() : 0); |
| 413 | 414 |
| 414 // Paint containment forces a block formatting context, so we must coerce | 415 // Paint containment forces a block formatting context, so we must coerce |
| 415 // from inline. https://drafts.csswg.org/css-containment/#containment-paint | 416 // from inline. https://drafts.csswg.org/css-containment/#containment-paint |
| 416 if (style.containsPaint() && style.display() == EDisplay::Inline) | 417 if (style.containsPaint() && style.display() == EDisplay::Inline) |
| 417 style.setDisplay(EDisplay::Block); | 418 style.setDisplay(EDisplay::Block); |
| 418 } else { | 419 } else { |
| 419 adjustStyleForFirstLetter(style); | 420 adjustStyleForFirstLetter(style); |
| 420 } | 421 } |
| 421 | 422 |
| 422 if (element && element->hasCompositorProxy()) | 423 if (element && element->hasCompositorProxy()) |
| 423 style.setHasCompositorProxy(true); | 424 style.setHasCompositorProxy(true); |
| 424 | 425 |
| 425 // Make sure our z-index value is only applied if the object is positioned. | 426 // Make sure our z-index value is only applied if the object is positioned. |
| 426 if (style.position() == StaticPosition && | 427 if (style.position() == EPosition::kStatic && |
| 427 !parentStyleForcesZIndexToCreateStackingContext(parentStyle)) { | 428 !parentStyleForcesZIndexToCreateStackingContext(parentStyle)) { |
| 428 style.setIsStackingContext(false); | 429 style.setIsStackingContext(false); |
| 429 // TODO(alancutter): Avoid altering z-index here. | 430 // TODO(alancutter): Avoid altering z-index here. |
| 430 if (!style.hasAutoZIndex()) | 431 if (!style.hasAutoZIndex()) |
| 431 style.setZIndex(0); | 432 style.setZIndex(0); |
| 432 } else if (!style.hasAutoZIndex()) { | 433 } else if (!style.hasAutoZIndex()) { |
| 433 style.setIsStackingContext(true); | 434 style.setIsStackingContext(true); |
| 434 } | 435 } |
| 435 | 436 |
| 436 if (style.overflowX() != EOverflow::kVisible || | 437 if (style.overflowX() != EOverflow::kVisible || |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 style.setDisplay(EDisplay::Block); | 489 style.setDisplay(EDisplay::Block); |
| 489 | 490 |
| 490 // Columns don't apply to svg text elements. | 491 // Columns don't apply to svg text elements. |
| 491 if (isSVGTextElement(*element)) | 492 if (isSVGTextElement(*element)) |
| 492 style.clearMultiCol(); | 493 style.clearMultiCol(); |
| 493 } | 494 } |
| 494 adjustStyleForAlignment(style, parentStyle); | 495 adjustStyleForAlignment(style, parentStyle); |
| 495 } | 496 } |
| 496 | 497 |
| 497 } // namespace blink | 498 } // namespace blink |
| OLD | NEW |