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

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

Issue 2670643004: Rename EDisplay values with k prefix. (Closed)
Patch Set: Rebase Created 3 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
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. 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "platform/Length.h" 51 #include "platform/Length.h"
52 #include "platform/transforms/TransformOperations.h" 52 #include "platform/transforms/TransformOperations.h"
53 #include "wtf/Assertions.h" 53 #include "wtf/Assertions.h"
54 54
55 namespace blink { 55 namespace blink {
56 56
57 using namespace HTMLNames; 57 using namespace HTMLNames;
58 58
59 static EDisplay equivalentBlockDisplay(EDisplay display) { 59 static EDisplay equivalentBlockDisplay(EDisplay display) {
60 switch (display) { 60 switch (display) {
61 case EDisplay::Block: 61 case EDisplay::kBlock:
62 case EDisplay::Table: 62 case EDisplay::kTable:
63 case EDisplay::WebkitBox: 63 case EDisplay::kWebkitBox:
64 case EDisplay::Flex: 64 case EDisplay::kFlex:
65 case EDisplay::Grid: 65 case EDisplay::kGrid:
66 case EDisplay::ListItem: 66 case EDisplay::kListItem:
67 case EDisplay::FlowRoot: 67 case EDisplay::kFlowRoot:
68 return display; 68 return display;
69 case EDisplay::InlineTable: 69 case EDisplay::kInlineTable:
70 return EDisplay::Table; 70 return EDisplay::kTable;
71 case EDisplay::WebkitInlineBox: 71 case EDisplay::kWebkitInlineBox:
72 return EDisplay::WebkitBox; 72 return EDisplay::kWebkitBox;
73 case EDisplay::InlineFlex: 73 case EDisplay::kInlineFlex:
74 return EDisplay::Flex; 74 return EDisplay::kFlex;
75 case EDisplay::InlineGrid: 75 case EDisplay::kInlineGrid:
76 return EDisplay::Grid; 76 return EDisplay::kGrid;
77 77
78 case EDisplay::Contents: 78 case EDisplay::kContents:
79 case EDisplay::Inline: 79 case EDisplay::kInline:
80 case EDisplay::InlineBlock: 80 case EDisplay::kInlineBlock:
81 case EDisplay::TableRowGroup: 81 case EDisplay::kTableRowGroup:
82 case EDisplay::TableHeaderGroup: 82 case EDisplay::kTableHeaderGroup:
83 case EDisplay::TableFooterGroup: 83 case EDisplay::kTableFooterGroup:
84 case EDisplay::TableRow: 84 case EDisplay::kTableRow:
85 case EDisplay::TableColumnGroup: 85 case EDisplay::kTableColumnGroup:
86 case EDisplay::TableColumn: 86 case EDisplay::kTableColumn:
87 case EDisplay::TableCell: 87 case EDisplay::kTableCell:
88 case EDisplay::TableCaption: 88 case EDisplay::kTableCaption:
89 return EDisplay::Block; 89 return EDisplay::kBlock;
90 case EDisplay::None: 90 case EDisplay::kNone:
91 ASSERT_NOT_REACHED(); 91 ASSERT_NOT_REACHED();
92 return display; 92 return display;
93 } 93 }
94 ASSERT_NOT_REACHED(); 94 ASSERT_NOT_REACHED();
95 return EDisplay::Block; 95 return EDisplay::kBlock;
96 } 96 }
97 97
98 static bool isOutermostSVGElement(const Element* element) { 98 static bool isOutermostSVGElement(const Element* element) {
99 return element && element->isSVGElement() && 99 return element && element->isSVGElement() &&
100 toSVGElement(*element).isOutermostSVGSVGElement(); 100 toSVGElement(*element).isOutermostSVGSVGElement();
101 } 101 }
102 102
103 // CSS requires text-decoration to be reset at each DOM element for 103 // CSS requires text-decoration to be reset at each DOM element for
104 // inline blocks, inline tables, shadow DOM crossings, floating elements, 104 // inline blocks, inline tables, shadow DOM crossings, floating elements,
105 // and absolute or relatively positioned elements. Outermost <svg> roots are 105 // and absolute or relatively positioned elements. Outermost <svg> roots are
106 // considered to be atomic inline-level. 106 // considered to be atomic inline-level.
107 static bool doesNotInheritTextDecoration(const ComputedStyle& style, 107 static bool doesNotInheritTextDecoration(const ComputedStyle& style,
108 const Element* element) { 108 const Element* element) {
109 return style.display() == EDisplay::InlineTable || 109 return style.display() == EDisplay::kInlineTable ||
110 style.display() == EDisplay::InlineBlock || 110 style.display() == EDisplay::kInlineBlock ||
111 style.display() == EDisplay::WebkitInlineBox || 111 style.display() == EDisplay::kWebkitInlineBox ||
112 isAtShadowBoundary(element) || style.isFloating() || 112 isAtShadowBoundary(element) || style.isFloating() ||
113 style.hasOutOfFlowPosition() || isOutermostSVGElement(element) || 113 style.hasOutOfFlowPosition() || isOutermostSVGElement(element) ||
114 isHTMLRTElement(element); 114 isHTMLRTElement(element);
115 } 115 }
116 116
117 // Certain elements (<a>, <font>) override text decoration colors. "The font 117 // Certain elements (<a>, <font>) override text decoration colors. "The font
118 // element is expected to override the color of any text decoration that spans 118 // element is expected to override the color of any text decoration that spans
119 // the text of the element to the used value of the element's 'color' property." 119 // the text of the element to the used value of the element's 'color' property."
120 // (https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3) 120 // (https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3)
121 // The <a> behavior is non-standard. 121 // The <a> behavior is non-standard.
(...skipping 24 matching lines...) Expand all
146 style.setWhiteSpace(EWhiteSpace::kPre); 146 style.setWhiteSpace(EWhiteSpace::kPre);
147 else if (style.whiteSpace() == EWhiteSpace::kPreLine) 147 else if (style.whiteSpace() == EWhiteSpace::kPreLine)
148 style.setWhiteSpace(EWhiteSpace::kPreWrap); 148 style.setWhiteSpace(EWhiteSpace::kPreWrap);
149 } 149 }
150 150
151 static void adjustStyleForFirstLetter(ComputedStyle& style) { 151 static void adjustStyleForFirstLetter(ComputedStyle& style) {
152 if (style.styleType() != PseudoIdFirstLetter) 152 if (style.styleType() != PseudoIdFirstLetter)
153 return; 153 return;
154 154
155 // Force inline display (except for floating first-letters). 155 // Force inline display (except for floating first-letters).
156 style.setDisplay(style.isFloating() ? EDisplay::Block : EDisplay::Inline); 156 style.setDisplay(style.isFloating() ? EDisplay::kBlock : EDisplay::kInline);
157 157
158 // CSS2 says first-letter can't be positioned. 158 // CSS2 says first-letter can't be positioned.
159 style.setPosition(EPosition::kStatic); 159 style.setPosition(EPosition::kStatic);
160 } 160 }
161 161
162 void StyleAdjuster::adjustStyleForAlignment( 162 void StyleAdjuster::adjustStyleForAlignment(
163 ComputedStyle& style, 163 ComputedStyle& style,
164 const ComputedStyle& layoutParentStyle) { 164 const ComputedStyle& layoutParentStyle) {
165 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto' 165 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto'
166 // flag to not just mean 'auto' prior to running the StyleAdjuster but also 166 // flag to not just mean 'auto' prior to running the StyleAdjuster but also
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (style.width().isFixed()) 206 if (style.width().isFixed())
207 style.setWhiteSpace(EWhiteSpace::kNormal); 207 style.setWhiteSpace(EWhiteSpace::kNormal);
208 else 208 else
209 style.setWhiteSpace(EWhiteSpace::kNowrap); 209 style.setWhiteSpace(EWhiteSpace::kNowrap);
210 } 210 }
211 return; 211 return;
212 } 212 }
213 213
214 if (isHTMLImageElement(element)) { 214 if (isHTMLImageElement(element)) {
215 if (toHTMLImageElement(element).isCollapsed()) 215 if (toHTMLImageElement(element).isCollapsed())
216 style.setDisplay(EDisplay::None); 216 style.setDisplay(EDisplay::kNone);
217 return; 217 return;
218 } 218 }
219 219
220 if (isHTMLTableElement(element)) { 220 if (isHTMLTableElement(element)) {
221 // Tables never support the -webkit-* values for text-align and will reset 221 // Tables never support the -webkit-* values for text-align and will reset
222 // back to the default. 222 // back to the default.
223 if (style.textAlign() == ETextAlign::kWebkitLeft || 223 if (style.textAlign() == ETextAlign::kWebkitLeft ||
224 style.textAlign() == ETextAlign::kWebkitCenter || 224 style.textAlign() == ETextAlign::kWebkitCenter ||
225 style.textAlign() == ETextAlign::kWebkitRight) 225 style.textAlign() == ETextAlign::kWebkitRight)
226 style.setTextAlign(ETextAlign::kStart); 226 style.setTextAlign(ETextAlign::kStart);
227 return; 227 return;
228 } 228 }
229 229
230 if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) { 230 if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) {
231 // Frames and framesets never honor position:relative or position:absolute. 231 // Frames and framesets never honor position:relative or position:absolute.
232 // This is necessary to fix a crash where a site tries to position these 232 // This is necessary to fix a crash where a site tries to position these
233 // objects. They also never honor display. 233 // objects. They also never honor display.
234 style.setPosition(EPosition::kStatic); 234 style.setPosition(EPosition::kStatic);
235 style.setDisplay(EDisplay::Block); 235 style.setDisplay(EDisplay::kBlock);
236 return; 236 return;
237 } 237 }
238 238
239 if (isHTMLFrameElementBase(element)) { 239 if (isHTMLFrameElementBase(element)) {
240 // Frames cannot overflow (they are always the size we ask them to be). 240 // Frames cannot overflow (they are always the size we ask them to be).
241 // Some compositing code paths may try to draw scrollbars anyhow. 241 // Some compositing code paths may try to draw scrollbars anyhow.
242 style.setOverflowX(EOverflow::kVisible); 242 style.setOverflowX(EOverflow::kVisible);
243 style.setOverflowY(EOverflow::kVisible); 243 style.setOverflowY(EOverflow::kVisible);
244 return; 244 return;
245 } 245 }
246 246
247 if (isHTMLRTElement(element)) { 247 if (isHTMLRTElement(element)) {
248 // Ruby text does not support float or position. This might change with 248 // Ruby text does not support float or position. This might change with
249 // evolution of the specification. 249 // evolution of the specification.
250 style.setPosition(EPosition::kStatic); 250 style.setPosition(EPosition::kStatic);
251 style.setFloating(EFloat::kNone); 251 style.setFloating(EFloat::kNone);
252 return; 252 return;
253 } 253 }
254 254
255 if (isHTMLLegendElement(element)) { 255 if (isHTMLLegendElement(element)) {
256 style.setDisplay(EDisplay::Block); 256 style.setDisplay(EDisplay::kBlock);
257 return; 257 return;
258 } 258 }
259 259
260 if (isHTMLMarqueeElement(element)) { 260 if (isHTMLMarqueeElement(element)) {
261 // For now, <marquee> requires an overflow clip to work properly. 261 // For now, <marquee> requires an overflow clip to work properly.
262 style.setOverflowX(EOverflow::kHidden); 262 style.setOverflowX(EOverflow::kHidden);
263 style.setOverflowY(EOverflow::kHidden); 263 style.setOverflowY(EOverflow::kHidden);
264 return; 264 return;
265 } 265 }
266 266
(...skipping 12 matching lines...) Expand all
279 style.setRequiresAcceleratedCompositingForExternalReasons( 279 style.setRequiresAcceleratedCompositingForExternalReasons(
280 toHTMLPlugInElement(element).shouldAccelerate()); 280 toHTMLPlugInElement(element).shouldAccelerate());
281 return; 281 return;
282 } 282 }
283 } 283 }
284 284
285 static void adjustOverflow(ComputedStyle& style) { 285 static void adjustOverflow(ComputedStyle& style) {
286 DCHECK(style.overflowX() != EOverflow::kVisible || 286 DCHECK(style.overflowX() != EOverflow::kVisible ||
287 style.overflowY() != EOverflow::kVisible); 287 style.overflowY() != EOverflow::kVisible);
288 288
289 if (style.display() == EDisplay::Table || 289 if (style.display() == EDisplay::kTable ||
290 style.display() == EDisplay::InlineTable) { 290 style.display() == EDisplay::kInlineTable) {
291 // Tables only support overflow:hidden and overflow:visible and ignore 291 // Tables only support overflow:hidden and overflow:visible and ignore
292 // anything else, see http://dev.w3.org/csswg/css2/visufx.html#overflow. As 292 // anything else, see http://dev.w3.org/csswg/css2/visufx.html#overflow. As
293 // a table is not a block container box the rules for resolving conflicting 293 // a table is not a block container box the rules for resolving conflicting
294 // x and y values in CSS Overflow Module Level 3 do not apply. Arguably 294 // x and y values in CSS Overflow Module Level 3 do not apply. Arguably
295 // overflow-x and overflow-y aren't allowed on tables but all UAs allow it. 295 // overflow-x and overflow-y aren't allowed on tables but all UAs allow it.
296 if (style.overflowX() != EOverflow::kHidden) 296 if (style.overflowX() != EOverflow::kHidden)
297 style.setOverflowX(EOverflow::kVisible); 297 style.setOverflowX(EOverflow::kVisible);
298 if (style.overflowY() != EOverflow::kHidden) 298 if (style.overflowY() != EOverflow::kHidden)
299 style.setOverflowY(EOverflow::kVisible); 299 style.setOverflowY(EOverflow::kVisible);
300 // If we are left with conflicting overflow values for the x and y axes on a 300 // If we are left with conflicting overflow values for the x and y axes on a
(...skipping 19 matching lines...) Expand all
320 // Menulists should have visible overflow 320 // Menulists should have visible overflow
321 if (style.appearance() == MenulistPart) { 321 if (style.appearance() == MenulistPart) {
322 style.setOverflowX(EOverflow::kVisible); 322 style.setOverflowX(EOverflow::kVisible);
323 style.setOverflowY(EOverflow::kVisible); 323 style.setOverflowY(EOverflow::kVisible);
324 } 324 }
325 } 325 }
326 326
327 static void adjustStyleForDisplay(ComputedStyle& style, 327 static void adjustStyleForDisplay(ComputedStyle& style,
328 const ComputedStyle& layoutParentStyle, 328 const ComputedStyle& layoutParentStyle,
329 Document* document) { 329 Document* document) {
330 if (style.display() == EDisplay::Block && !style.isFloating()) 330 if (style.display() == EDisplay::kBlock && !style.isFloating())
331 return; 331 return;
332 332
333 if (style.display() == EDisplay::Contents) 333 if (style.display() == EDisplay::kContents)
334 return; 334 return;
335 335
336 // FIXME: Don't support this mutation for pseudo styles like first-letter or 336 // FIXME: Don't support this mutation for pseudo styles like first-letter or
337 // first-line, since it's not completely clear how that should work. 337 // first-line, since it's not completely clear how that should work.
338 if (style.display() == EDisplay::Inline && 338 if (style.display() == EDisplay::kInline &&
339 style.styleType() == PseudoIdNone && 339 style.styleType() == PseudoIdNone &&
340 style.getWritingMode() != layoutParentStyle.getWritingMode()) 340 style.getWritingMode() != layoutParentStyle.getWritingMode())
341 style.setDisplay(EDisplay::InlineBlock); 341 style.setDisplay(EDisplay::kInlineBlock);
342 342
343 // We do not honor position: relative or sticky for table rows, headers, and 343 // We do not honor position: relative or sticky for table rows, headers, and
344 // footers. This is correct for position: relative in CSS2.1 (and caused a 344 // footers. This is correct for position: relative in CSS2.1 (and caused a
345 // crash in containingBlock() on some sites) and position: sticky is defined 345 // crash in containingBlock() on some sites) and position: sticky is defined
346 // as following position: relative behavior for table elements. It is 346 // as following position: relative behavior for table elements. It is
347 // incorrect for CSS3. 347 // incorrect for CSS3.
348 if ((style.display() == EDisplay::TableHeaderGroup || 348 if ((style.display() == EDisplay::kTableHeaderGroup ||
349 style.display() == EDisplay::TableRowGroup || 349 style.display() == EDisplay::kTableRowGroup ||
350 style.display() == EDisplay::TableFooterGroup || 350 style.display() == EDisplay::kTableFooterGroup ||
351 style.display() == EDisplay::TableRow) && 351 style.display() == EDisplay::kTableRow) &&
352 style.hasInFlowPosition()) 352 style.hasInFlowPosition())
353 style.setPosition(EPosition::kStatic); 353 style.setPosition(EPosition::kStatic);
354 354
355 // Cannot support position: sticky for table columns and column groups because 355 // Cannot support position: sticky for table columns and column groups because
356 // current code is only doing background painting through columns / column 356 // current code is only doing background painting through columns / column
357 // groups. 357 // groups.
358 if ((style.display() == EDisplay::TableColumnGroup || 358 if ((style.display() == EDisplay::kTableColumnGroup ||
359 style.display() == EDisplay::TableColumn) && 359 style.display() == EDisplay::kTableColumn) &&
360 style.position() == EPosition::kSticky) 360 style.position() == EPosition::kSticky)
361 style.setPosition(EPosition::kStatic); 361 style.setPosition(EPosition::kStatic);
362 362
363 // writing-mode does not apply to table row groups, table column groups, table 363 // writing-mode does not apply to table row groups, table column groups, table
364 // rows, and table columns. 364 // rows, and table columns.
365 // FIXME: Table cells should be allowed to be perpendicular or flipped with 365 // FIXME: Table cells should be allowed to be perpendicular or flipped with
366 // respect to the table, though. 366 // respect to the table, though.
367 if (style.display() == EDisplay::TableColumn || 367 if (style.display() == EDisplay::kTableColumn ||
368 style.display() == EDisplay::TableColumnGroup || 368 style.display() == EDisplay::kTableColumnGroup ||
369 style.display() == EDisplay::TableFooterGroup || 369 style.display() == EDisplay::kTableFooterGroup ||
370 style.display() == EDisplay::TableHeaderGroup || 370 style.display() == EDisplay::kTableHeaderGroup ||
371 style.display() == EDisplay::TableRow || 371 style.display() == EDisplay::kTableRow ||
372 style.display() == EDisplay::TableRowGroup || 372 style.display() == EDisplay::kTableRowGroup ||
373 style.display() == EDisplay::TableCell) 373 style.display() == EDisplay::kTableCell)
374 style.setWritingMode(layoutParentStyle.getWritingMode()); 374 style.setWritingMode(layoutParentStyle.getWritingMode());
375 375
376 // FIXME: Since we don't support block-flow on flexible boxes yet, disallow 376 // FIXME: Since we don't support block-flow on flexible boxes yet, disallow
377 // setting of block-flow to anything other than TopToBottomWritingMode. 377 // setting of block-flow to anything other than TopToBottomWritingMode.
378 // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support. 378 // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support.
379 if (style.getWritingMode() != WritingMode::kHorizontalTb && 379 if (style.getWritingMode() != WritingMode::kHorizontalTb &&
380 (style.display() == EDisplay::WebkitBox || 380 (style.display() == EDisplay::kWebkitBox ||
381 style.display() == EDisplay::WebkitInlineBox)) 381 style.display() == EDisplay::kWebkitInlineBox))
382 style.setWritingMode(WritingMode::kHorizontalTb); 382 style.setWritingMode(WritingMode::kHorizontalTb);
383 383
384 if (layoutParentStyle.isDisplayFlexibleOrGridBox()) { 384 if (layoutParentStyle.isDisplayFlexibleOrGridBox()) {
385 style.setFloating(EFloat::kNone); 385 style.setFloating(EFloat::kNone);
386 style.setDisplay(equivalentBlockDisplay(style.display())); 386 style.setDisplay(equivalentBlockDisplay(style.display()));
387 387
388 // We want to count vertical percentage paddings/margins on flex items 388 // We want to count vertical percentage paddings/margins on flex items
389 // because our current behavior is different from the spec and we want to 389 // because our current behavior is different from the spec and we want to
390 // gather compatibility data. 390 // gather compatibility data.
391 if (style.paddingBefore().isPercentOrCalc() || 391 if (style.paddingBefore().isPercentOrCalc() ||
392 style.paddingAfter().isPercentOrCalc()) 392 style.paddingAfter().isPercentOrCalc())
393 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVertical); 393 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVertical);
394 if (style.marginBefore().isPercentOrCalc() || 394 if (style.marginBefore().isPercentOrCalc() ||
395 style.marginAfter().isPercentOrCalc()) 395 style.marginAfter().isPercentOrCalc())
396 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVertical); 396 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVertical);
397 } 397 }
398 } 398 }
399 399
400 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, 400 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style,
401 const ComputedStyle& parentStyle, 401 const ComputedStyle& parentStyle,
402 const ComputedStyle& layoutParentStyle, 402 const ComputedStyle& layoutParentStyle,
403 Element* element) { 403 Element* element) {
404 if (style.display() != EDisplay::None) { 404 if (style.display() != EDisplay::kNone) {
405 if (element && element->isHTMLElement()) 405 if (element && element->isHTMLElement())
406 adjustStyleForHTMLElement(style, toHTMLElement(*element)); 406 adjustStyleForHTMLElement(style, toHTMLElement(*element));
407 407
408 // Per the spec, position 'static' and 'relative' in the top layer compute 408 // Per the spec, position 'static' and 'relative' in the top layer compute
409 // to 'absolute'. 409 // to 'absolute'.
410 if (isInTopLayer(element, style) && 410 if (isInTopLayer(element, style) &&
411 (style.position() == EPosition::kStatic || 411 (style.position() == EPosition::kStatic ||
412 style.position() == EPosition::kRelative)) 412 style.position() == EPosition::kRelative))
413 style.setPosition(EPosition::kAbsolute); 413 style.setPosition(EPosition::kAbsolute);
414 414
415 // Absolute/fixed positioned elements, floating elements and the document 415 // Absolute/fixed positioned elements, floating elements and the document
416 // element need block-like outside display. 416 // element need block-like outside display.
417 if (style.display() != EDisplay::Contents && 417 if (style.display() != EDisplay::kContents &&
418 (style.hasOutOfFlowPosition() || style.isFloating())) 418 (style.hasOutOfFlowPosition() || style.isFloating()))
419 style.setDisplay(equivalentBlockDisplay(style.display())); 419 style.setDisplay(equivalentBlockDisplay(style.display()));
420 420
421 if (element && element->document().documentElement() == element) 421 if (element && element->document().documentElement() == element)
422 style.setDisplay(equivalentBlockDisplay(style.display())); 422 style.setDisplay(equivalentBlockDisplay(style.display()));
423 423
424 // We don't adjust the first letter style earlier because we may change the 424 // We don't adjust the first letter style earlier because we may change the
425 // display setting in adjustStyeForTagName() above. 425 // display setting in adjustStyeForTagName() above.
426 adjustStyleForFirstLetter(style); 426 adjustStyleForFirstLetter(style);
427 427
428 adjustStyleForDisplay(style, layoutParentStyle, 428 adjustStyleForDisplay(style, layoutParentStyle,
429 element ? &element->document() : 0); 429 element ? &element->document() : 0);
430 430
431 // Paint containment forces a block formatting context, so we must coerce 431 // Paint containment forces a block formatting context, so we must coerce
432 // from inline. https://drafts.csswg.org/css-containment/#containment-paint 432 // from inline. https://drafts.csswg.org/css-containment/#containment-paint
433 if (style.containsPaint() && style.display() == EDisplay::Inline) 433 if (style.containsPaint() && style.display() == EDisplay::kInline)
434 style.setDisplay(EDisplay::Block); 434 style.setDisplay(EDisplay::kBlock);
435 } else { 435 } else {
436 adjustStyleForFirstLetter(style); 436 adjustStyleForFirstLetter(style);
437 } 437 }
438 438
439 if (element && element->hasCompositorProxy()) 439 if (element && element->hasCompositorProxy())
440 style.setHasCompositorProxy(true); 440 style.setHasCompositorProxy(true);
441 441
442 // Make sure our z-index value is only applied if the object is positioned. 442 // Make sure our z-index value is only applied if the object is positioned.
443 if (style.position() == EPosition::kStatic && 443 if (style.position() == EPosition::kStatic &&
444 !layoutParentStyleForcesZIndexToCreateStackingContext( 444 !layoutParentStyleForcesZIndexToCreateStackingContext(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (isSVGElement) { 484 if (isSVGElement) {
485 // display: contents computes to inline for replaced elements and form 485 // display: contents computes to inline for replaced elements and form
486 // controls, and isn't specified for other kinds of SVG content[1], so let's 486 // controls, and isn't specified for other kinds of SVG content[1], so let's
487 // just do the same here for all other SVG elements. 487 // just do the same here for all other SVG elements.
488 // 488 //
489 // If we wouldn't do this, then we'd need to ensure that display: contents 489 // If we wouldn't do this, then we'd need to ensure that display: contents
490 // doesn't prevent SVG elements from generating a LayoutObject in 490 // doesn't prevent SVG elements from generating a LayoutObject in
491 // SVGElement::layoutObjectIsNeeded. 491 // SVGElement::layoutObjectIsNeeded.
492 // 492 //
493 // [1]: https://www.w3.org/TR/SVG/painting.html#DisplayProperty 493 // [1]: https://www.w3.org/TR/SVG/painting.html#DisplayProperty
494 if (style.display() == EDisplay::Contents) 494 if (style.display() == EDisplay::kContents)
495 style.setDisplay(EDisplay::Inline); 495 style.setDisplay(EDisplay::kInline);
496 496
497 // Only the root <svg> element in an SVG document fragment tree honors css 497 // Only the root <svg> element in an SVG document fragment tree honors css
498 // position. 498 // position.
499 if (!(isSVGSVGElement(*element) && element->parentNode() && 499 if (!(isSVGSVGElement(*element) && element->parentNode() &&
500 !element->parentNode()->isSVGElement())) 500 !element->parentNode()->isSVGElement()))
501 style.setPosition(ComputedStyle::initialPosition()); 501 style.setPosition(ComputedStyle::initialPosition());
502 502
503 // SVG text layout code expects us to be a block-level style element. 503 // SVG text layout code expects us to be a block-level style element.
504 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && 504 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) &&
505 style.isDisplayInlineType()) 505 style.isDisplayInlineType())
506 style.setDisplay(EDisplay::Block); 506 style.setDisplay(EDisplay::kBlock);
507 507
508 // Columns don't apply to svg text elements. 508 // Columns don't apply to svg text elements.
509 if (isSVGTextElement(*element)) 509 if (isSVGTextElement(*element))
510 style.clearMultiCol(); 510 style.clearMultiCol();
511 } 511 }
512 adjustStyleForAlignment(style, layoutParentStyle); 512 adjustStyleForAlignment(style, layoutParentStyle);
513 } 513 }
514 514
515 } // namespace blink 515 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698