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. |
| 6 * All rights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * 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/) | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 11 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 12 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
11 * Copyright (C) 2013 Google Inc. All rights reserved. | 13 * Copyright (C) 2013 Google Inc. All rights reserved. |
12 * | 14 * |
13 * This library is free software; you can redistribute it and/or | 15 * This library is free software; you can redistribute it and/or |
14 * modify it under the terms of the GNU Library General Public | 16 * modify it under the terms of the GNU Library General Public |
15 * License as published by the Free Software Foundation; either | 17 * License as published by the Free Software Foundation; either |
16 * version 2 of the License, or (at your option) any later version. | 18 * version 2 of the License, or (at your option) any later version. |
17 * | 19 * |
18 * This library is distributed in the hope that it will be useful, | 20 * This library is distributed in the hope that it will be useful, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 140 |
139 // Force inline display (except for floating first-letters). | 141 // Force inline display (except for floating first-letters). |
140 style.setDisplay(style.isFloating() ? EDisplay::Block : EDisplay::Inline); | 142 style.setDisplay(style.isFloating() ? EDisplay::Block : EDisplay::Inline); |
141 | 143 |
142 // CSS2 says first-letter can't be positioned. | 144 // CSS2 says first-letter can't be positioned. |
143 style.setPosition(StaticPosition); | 145 style.setPosition(StaticPosition); |
144 } | 146 } |
145 | 147 |
146 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, | 148 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, |
147 const ComputedStyle& parentStyle) { | 149 const ComputedStyle& parentStyle) { |
148 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto'
flag | 150 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto' |
149 // to not just mean 'auto' prior to running the StyleAdjuster but also mean 'n
ormal' | 151 // flag to not just mean 'auto' prior to running the StyleAdjuster but also |
150 // after running it. | 152 // mean 'normal' after running it. |
151 | 153 |
152 // If the inherited value of justify-items includes the 'legacy' keyword, 'aut
o' | 154 // If the inherited value of justify-items includes the 'legacy' keyword, |
153 // computes to the the inherited value. | 155 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to |
154 // Otherwise, 'auto' computes to 'normal'. | 156 // 'normal'. |
155 if (style.justifyItemsPosition() == ItemPositionAuto) { | 157 if (style.justifyItemsPosition() == ItemPositionAuto) { |
156 if (parentStyle.justifyItemsPositionType() == LegacyPosition) | 158 if (parentStyle.justifyItemsPositionType() == LegacyPosition) |
157 style.setJustifyItems(parentStyle.justifyItems()); | 159 style.setJustifyItems(parentStyle.justifyItems()); |
158 } | 160 } |
159 | 161 |
160 // The 'auto' keyword computes the computed value of justify-items on the pare
nt (minus | 162 // The 'auto' keyword computes the computed value of justify-items on the |
161 // any legacy keywords), or 'normal' if the box has no parent. | 163 // parent (minus any legacy keywords), or 'normal' if the box has no parent. |
162 if (style.justifySelfPosition() == ItemPositionAuto) { | 164 if (style.justifySelfPosition() == ItemPositionAuto) { |
163 if (parentStyle.justifyItemsPositionType() == LegacyPosition) | 165 if (parentStyle.justifyItemsPositionType() == LegacyPosition) |
164 style.setJustifySelfPosition(parentStyle.justifyItemsPosition()); | 166 style.setJustifySelfPosition(parentStyle.justifyItemsPosition()); |
165 else if (parentStyle.justifyItemsPosition() != ItemPositionAuto) | 167 else if (parentStyle.justifyItemsPosition() != ItemPositionAuto) |
166 style.setJustifySelf(parentStyle.justifyItems()); | 168 style.setJustifySelf(parentStyle.justifyItems()); |
167 } | 169 } |
168 | 170 |
169 // The 'auto' keyword computes the computed value of align-items on the parent | 171 // The 'auto' keyword computes the computed value of align-items on the parent |
170 // or 'normal' if the box has no parent. | 172 // or 'normal' if the box has no parent. |
171 if (style.alignSelfPosition() == ItemPositionAuto && | 173 if (style.alignSelfPosition() == ItemPositionAuto && |
172 parentStyle.alignItemsPosition() != | 174 parentStyle.alignItemsPosition() != |
173 ComputedStyle::initialDefaultAlignment().position()) | 175 ComputedStyle::initialDefaultAlignment().position()) |
174 style.setAlignSelf(parentStyle.alignItems()); | 176 style.setAlignSelf(parentStyle.alignItems()); |
175 } | 177 } |
176 | 178 |
177 static void adjustStyleForHTMLElement(ComputedStyle& style, | 179 static void adjustStyleForHTMLElement(ComputedStyle& style, |
178 HTMLElement& element) { | 180 HTMLElement& element) { |
179 // <div> and <span> are the most common elements on the web, we skip all the w
ork for them. | 181 // <div> and <span> are the most common elements on the web, we skip all the |
| 182 // work for them. |
180 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) | 183 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) |
181 return; | 184 return; |
182 | 185 |
183 if (isHTMLTableCellElement(element)) { | 186 if (isHTMLTableCellElement(element)) { |
184 if (style.whiteSpace() == KHTML_NOWRAP) { | 187 if (style.whiteSpace() == KHTML_NOWRAP) { |
185 // Figure out if we are really nowrapping or if we should just | 188 // Figure out if we are really nowrapping or if we should just |
186 // use normal instead. If the width of the cell is fixed, then | 189 // use normal instead. If the width of the cell is fixed, then |
187 // we don't actually use NOWRAP. | 190 // we don't actually use NOWRAP. |
188 if (style.width().isFixed()) | 191 if (style.width().isFixed()) |
189 style.setWhiteSpace(NORMAL); | 192 style.setWhiteSpace(NORMAL); |
190 else | 193 else |
191 style.setWhiteSpace(NOWRAP); | 194 style.setWhiteSpace(NOWRAP); |
192 } | 195 } |
193 return; | 196 return; |
194 } | 197 } |
195 | 198 |
196 if (isHTMLTableElement(element)) { | 199 if (isHTMLTableElement(element)) { |
197 // Tables never support the -webkit-* values for text-align and will reset b
ack to the default. | 200 // Tables never support the -webkit-* values for text-align and will reset |
| 201 // back to the default. |
198 if (style.textAlign() == WEBKIT_LEFT || | 202 if (style.textAlign() == WEBKIT_LEFT || |
199 style.textAlign() == WEBKIT_CENTER || style.textAlign() == WEBKIT_RIGHT) | 203 style.textAlign() == WEBKIT_CENTER || style.textAlign() == WEBKIT_RIGHT) |
200 style.setTextAlign(TASTART); | 204 style.setTextAlign(TASTART); |
201 return; | 205 return; |
202 } | 206 } |
203 | 207 |
204 if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) { | 208 if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) { |
205 // Frames and framesets never honor position:relative or position:absolute.
This is necessary to | 209 // Frames and framesets never honor position:relative or position:absolute. |
206 // fix a crash where a site tries to position these objects. They also never
honor display. | 210 // This is necessary to fix a crash where a site tries to position these |
| 211 // objects. They also never honor display. |
207 style.setPosition(StaticPosition); | 212 style.setPosition(StaticPosition); |
208 style.setDisplay(EDisplay::Block); | 213 style.setDisplay(EDisplay::Block); |
209 return; | 214 return; |
210 } | 215 } |
211 | 216 |
212 if (isHTMLFrameElementBase(element)) { | 217 if (isHTMLFrameElementBase(element)) { |
213 // Frames cannot overflow (they are always the size we ask them to be). | 218 // Frames cannot overflow (they are always the size we ask them to be). |
214 // Some compositing code paths may try to draw scrollbars anyhow. | 219 // Some compositing code paths may try to draw scrollbars anyhow. |
215 style.setOverflowX(OverflowVisible); | 220 style.setOverflowX(OverflowVisible); |
216 style.setOverflowY(OverflowVisible); | 221 style.setOverflowY(OverflowVisible); |
217 return; | 222 return; |
218 } | 223 } |
219 | 224 |
220 if (isHTMLRTElement(element)) { | 225 if (isHTMLRTElement(element)) { |
221 // Ruby text does not support float or position. This might change with evol
ution of the specification. | 226 // Ruby text does not support float or position. This might change with |
| 227 // evolution of the specification. |
222 style.setPosition(StaticPosition); | 228 style.setPosition(StaticPosition); |
223 style.setFloating(EFloat::None); | 229 style.setFloating(EFloat::None); |
224 return; | 230 return; |
225 } | 231 } |
226 | 232 |
227 if (isHTMLMarqueeElement(element)) { | 233 if (isHTMLMarqueeElement(element)) { |
228 // For now, <marquee> requires an overflow clip to work properly. | 234 // For now, <marquee> requires an overflow clip to work properly. |
229 style.setOverflowX(OverflowHidden); | 235 style.setOverflowX(OverflowHidden); |
230 style.setOverflowY(OverflowHidden); | 236 style.setOverflowY(OverflowHidden); |
231 return; | 237 return; |
(...skipping 16 matching lines...) Expand all Loading... |
248 return; | 254 return; |
249 } | 255 } |
250 } | 256 } |
251 | 257 |
252 static void adjustOverflow(ComputedStyle& style) { | 258 static void adjustOverflow(ComputedStyle& style) { |
253 ASSERT(style.overflowX() != OverflowVisible || | 259 ASSERT(style.overflowX() != OverflowVisible || |
254 style.overflowY() != OverflowVisible); | 260 style.overflowY() != OverflowVisible); |
255 | 261 |
256 if (style.display() == EDisplay::Table || | 262 if (style.display() == EDisplay::Table || |
257 style.display() == EDisplay::InlineTable) { | 263 style.display() == EDisplay::InlineTable) { |
258 // Tables only support overflow:hidden and overflow:visible and ignore anyth
ing else, | 264 // Tables only support overflow:hidden and overflow:visible and ignore |
259 // see http://dev.w3.org/csswg/css2/visufx.html#overflow. As a table is not
a block | 265 // anything else, see http://dev.w3.org/csswg/css2/visufx.html#overflow. As |
260 // container box the rules for resolving conflicting x and y values in CSS O
verflow Module | 266 // a table is not a block container box the rules for resolving conflicting |
261 // Level 3 do not apply. Arguably overflow-x and overflow-y aren't allowed o
n tables but | 267 // x and y values in CSS Overflow Module Level 3 do not apply. Arguably |
262 // all UAs allow it. | 268 // overflow-x and overflow-y aren't allowed on tables but all UAs allow it. |
263 if (style.overflowX() != OverflowHidden) | 269 if (style.overflowX() != OverflowHidden) |
264 style.setOverflowX(OverflowVisible); | 270 style.setOverflowX(OverflowVisible); |
265 if (style.overflowY() != OverflowHidden) | 271 if (style.overflowY() != OverflowHidden) |
266 style.setOverflowY(OverflowVisible); | 272 style.setOverflowY(OverflowVisible); |
267 // If we are left with conflicting overflow values for the x and y axes on a
table then resolve | 273 // If we are left with conflicting overflow values for the x and y axes on a |
268 // both to OverflowVisible. This is interoperable behaviour but is not specc
ed anywhere. | 274 // table then resolve both to OverflowVisible. This is interoperable |
| 275 // behaviour but is not specced anywhere. |
269 if (style.overflowX() == OverflowVisible) | 276 if (style.overflowX() == OverflowVisible) |
270 style.setOverflowY(OverflowVisible); | 277 style.setOverflowY(OverflowVisible); |
271 else if (style.overflowY() == OverflowVisible) | 278 else if (style.overflowY() == OverflowVisible) |
272 style.setOverflowX(OverflowVisible); | 279 style.setOverflowX(OverflowVisible); |
273 } else if (style.overflowX() == OverflowVisible && | 280 } else if (style.overflowX() == OverflowVisible && |
274 style.overflowY() != OverflowVisible) { | 281 style.overflowY() != OverflowVisible) { |
275 // If either overflow value is not visible, change to auto. | 282 // If either overflow value is not visible, change to auto. |
276 // FIXME: Once we implement pagination controls, overflow-x should default t
o hidden | 283 // FIXME: Once we implement pagination controls, overflow-x should default |
277 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, we'll
let it | 284 // to hidden if overflow-y is set to -webkit-paged-x or -webkit-page-y. For |
278 // default to auto so we can at least scroll through the pages. | 285 // now, we'll let it default to auto so we can at least scroll through the |
| 286 // pages. |
279 style.setOverflowX(OverflowAuto); | 287 style.setOverflowX(OverflowAuto); |
280 } else if (style.overflowY() == OverflowVisible && | 288 } else if (style.overflowY() == OverflowVisible && |
281 style.overflowX() != OverflowVisible) { | 289 style.overflowX() != OverflowVisible) { |
282 style.setOverflowY(OverflowAuto); | 290 style.setOverflowY(OverflowAuto); |
283 } | 291 } |
284 | 292 |
285 // Menulists should have visible overflow | 293 // Menulists should have visible overflow |
286 if (style.appearance() == MenulistPart) { | 294 if (style.appearance() == MenulistPart) { |
287 style.setOverflowX(OverflowVisible); | 295 style.setOverflowX(OverflowVisible); |
288 style.setOverflowY(OverflowVisible); | 296 style.setOverflowY(OverflowVisible); |
289 } | 297 } |
290 } | 298 } |
291 | 299 |
292 static void adjustStyleForDisplay(ComputedStyle& style, | 300 static void adjustStyleForDisplay(ComputedStyle& style, |
293 const ComputedStyle& parentStyle, | 301 const ComputedStyle& parentStyle, |
294 Document* document) { | 302 Document* document) { |
295 if (style.display() == EDisplay::Block && !style.isFloating()) | 303 if (style.display() == EDisplay::Block && !style.isFloating()) |
296 return; | 304 return; |
297 | 305 |
298 // FIXME: Don't support this mutation for pseudo styles like first-letter or f
irst-line, since it's not completely | 306 // FIXME: Don't support this mutation for pseudo styles like first-letter or |
299 // clear how that should work. | 307 // first-line, since it's not completely clear how that should work. |
300 if (style.display() == EDisplay::Inline && | 308 if (style.display() == EDisplay::Inline && |
301 style.styleType() == PseudoIdNone && | 309 style.styleType() == PseudoIdNone && |
302 style.getWritingMode() != parentStyle.getWritingMode()) | 310 style.getWritingMode() != parentStyle.getWritingMode()) |
303 style.setDisplay(EDisplay::InlineBlock); | 311 style.setDisplay(EDisplay::InlineBlock); |
304 | 312 |
305 // After performing the display mutation, check table rows. We do not honor po
sition: relative table rows or cells. | 313 // After performing the display mutation, check table rows. We do not honor |
306 // This has been established for position: relative in CSS2.1 (and caused a cr
ash in containingBlock() | 314 // position: relative table rows or cells. This has been established for |
307 // on some sites). | 315 // position: relative in CSS2.1 (and caused a crash in containingBlock() on |
| 316 // some sites). |
308 if ((style.display() == EDisplay::TableHeaderGroup || | 317 if ((style.display() == EDisplay::TableHeaderGroup || |
309 style.display() == EDisplay::TableRowGroup || | 318 style.display() == EDisplay::TableRowGroup || |
310 style.display() == EDisplay::TableFooterGroup || | 319 style.display() == EDisplay::TableFooterGroup || |
311 style.display() == EDisplay::TableRow) && | 320 style.display() == EDisplay::TableRow) && |
312 style.position() == RelativePosition) | 321 style.position() == RelativePosition) |
313 style.setPosition(StaticPosition); | 322 style.setPosition(StaticPosition); |
314 | 323 |
315 // Cannot support position: sticky for table columns and column groups because
current code is only doing | 324 // Cannot support position: sticky for table columns and column groups because |
316 // background painting through columns / column groups | 325 // current code is only doing background painting through columns / column |
| 326 // groups. |
317 if ((style.display() == EDisplay::TableColumnGroup || | 327 if ((style.display() == EDisplay::TableColumnGroup || |
318 style.display() == EDisplay::TableColumn) && | 328 style.display() == EDisplay::TableColumn) && |
319 style.position() == StickyPosition) | 329 style.position() == StickyPosition) |
320 style.setPosition(StaticPosition); | 330 style.setPosition(StaticPosition); |
321 | 331 |
322 // writing-mode does not apply to table row groups, table column groups, table
rows, and table columns. | 332 // writing-mode does not apply to table row groups, table column groups, table |
323 // FIXME: Table cells should be allowed to be perpendicular or flipped with re
spect to the table, though. | 333 // rows, and table columns. |
| 334 // FIXME: Table cells should be allowed to be perpendicular or flipped with |
| 335 // respect to the table, though. |
324 if (style.display() == EDisplay::TableColumn || | 336 if (style.display() == EDisplay::TableColumn || |
325 style.display() == EDisplay::TableColumnGroup || | 337 style.display() == EDisplay::TableColumnGroup || |
326 style.display() == EDisplay::TableFooterGroup || | 338 style.display() == EDisplay::TableFooterGroup || |
327 style.display() == EDisplay::TableHeaderGroup || | 339 style.display() == EDisplay::TableHeaderGroup || |
328 style.display() == EDisplay::TableRow || | 340 style.display() == EDisplay::TableRow || |
329 style.display() == EDisplay::TableRowGroup || | 341 style.display() == EDisplay::TableRowGroup || |
330 style.display() == EDisplay::TableCell) | 342 style.display() == EDisplay::TableCell) |
331 style.setWritingMode(parentStyle.getWritingMode()); | 343 style.setWritingMode(parentStyle.getWritingMode()); |
332 | 344 |
333 // FIXME: Since we don't support block-flow on flexible boxes yet, disallow se
tting | 345 // FIXME: Since we don't support block-flow on flexible boxes yet, disallow |
334 // of block-flow to anything other than TopToBottomWritingMode. | 346 // setting of block-flow to anything other than TopToBottomWritingMode. |
335 // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support. | 347 // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support. |
336 if (style.getWritingMode() != TopToBottomWritingMode && | 348 if (style.getWritingMode() != TopToBottomWritingMode && |
337 (style.display() == EDisplay::Box || | 349 (style.display() == EDisplay::Box || |
338 style.display() == EDisplay::InlineBox)) | 350 style.display() == EDisplay::InlineBox)) |
339 style.setWritingMode(TopToBottomWritingMode); | 351 style.setWritingMode(TopToBottomWritingMode); |
340 | 352 |
341 if (parentStyle.isDisplayFlexibleOrGridBox()) { | 353 if (parentStyle.isDisplayFlexibleOrGridBox()) { |
342 style.setFloating(EFloat::None); | 354 style.setFloating(EFloat::None); |
343 style.setDisplay(equivalentBlockDisplay(style.display())); | 355 style.setDisplay(equivalentBlockDisplay(style.display())); |
344 | 356 |
345 // We want to count vertical percentage paddings/margins on flex items becau
se our current | 357 // We want to count vertical percentage paddings/margins on flex items |
346 // behavior is different from the spec and we want to gather compatibility d
ata. | 358 // because our current behavior is different from the spec and we want to |
| 359 // gather compatibility data. |
347 if (style.paddingBefore().isPercentOrCalc() || | 360 if (style.paddingBefore().isPercentOrCalc() || |
348 style.paddingAfter().isPercentOrCalc()) | 361 style.paddingAfter().isPercentOrCalc()) |
349 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVertical); | 362 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVertical); |
350 if (style.marginBefore().isPercentOrCalc() || | 363 if (style.marginBefore().isPercentOrCalc() || |
351 style.marginAfter().isPercentOrCalc()) | 364 style.marginAfter().isPercentOrCalc()) |
352 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVertical); | 365 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVertical); |
353 } | 366 } |
354 } | 367 } |
355 | 368 |
356 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, | 369 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, |
357 const ComputedStyle& parentStyle, | 370 const ComputedStyle& parentStyle, |
358 Element* element) { | 371 Element* element) { |
359 if (style.display() != EDisplay::None) { | 372 if (style.display() != EDisplay::None) { |
360 if (element && element->isHTMLElement()) | 373 if (element && element->isHTMLElement()) |
361 adjustStyleForHTMLElement(style, toHTMLElement(*element)); | 374 adjustStyleForHTMLElement(style, toHTMLElement(*element)); |
362 | 375 |
363 // Per the spec, position 'static' and 'relative' in the top layer compute t
o 'absolute'. | 376 // Per the spec, position 'static' and 'relative' in the top layer compute |
| 377 // to 'absolute'. |
364 if (isInTopLayer(element, style) && (style.position() == StaticPosition || | 378 if (isInTopLayer(element, style) && (style.position() == StaticPosition || |
365 style.position() == RelativePosition)) | 379 style.position() == RelativePosition)) |
366 style.setPosition(AbsolutePosition); | 380 style.setPosition(AbsolutePosition); |
367 | 381 |
368 // Absolute/fixed positioned elements, floating elements and the document el
ement need block-like outside display. | 382 // Absolute/fixed positioned elements, floating elements and the document |
| 383 // element need block-like outside display. |
369 if (style.hasOutOfFlowPosition() || style.isFloating() || | 384 if (style.hasOutOfFlowPosition() || style.isFloating() || |
370 (element && element->document().documentElement() == element)) | 385 (element && element->document().documentElement() == element)) |
371 style.setDisplay(equivalentBlockDisplay(style.display())); | 386 style.setDisplay(equivalentBlockDisplay(style.display())); |
372 | 387 |
373 // We don't adjust the first letter style earlier because we may change the
display setting in | 388 // We don't adjust the first letter style earlier because we may change the |
374 // adjustStyeForTagName() above. | 389 // display setting in adjustStyeForTagName() above. |
375 adjustStyleForFirstLetter(style); | 390 adjustStyleForFirstLetter(style); |
376 | 391 |
377 adjustStyleForDisplay(style, parentStyle, | 392 adjustStyleForDisplay(style, parentStyle, |
378 element ? &element->document() : 0); | 393 element ? &element->document() : 0); |
379 | 394 |
380 // Paint containment forces a block formatting context, so we must coerce fr
om inline. | 395 // Paint containment forces a block formatting context, so we must coerce |
381 // https://drafts.csswg.org/css-containment/#containment-paint | 396 // from inline. https://drafts.csswg.org/css-containment/#containment-paint |
382 if (style.containsPaint() && style.display() == EDisplay::Inline) | 397 if (style.containsPaint() && style.display() == EDisplay::Inline) |
383 style.setDisplay(EDisplay::Block); | 398 style.setDisplay(EDisplay::Block); |
384 } else { | 399 } else { |
385 adjustStyleForFirstLetter(style); | 400 adjustStyleForFirstLetter(style); |
386 } | 401 } |
387 | 402 |
388 if (element && element->hasCompositorProxy()) | 403 if (element && element->hasCompositorProxy()) |
389 style.setHasCompositorProxy(true); | 404 style.setHasCompositorProxy(true); |
390 | 405 |
391 // Make sure our z-index value is only applied if the object is positioned. | 406 // Make sure our z-index value is only applied if the object is positioned. |
(...skipping 10 matching lines...) Expand all Loading... |
402 if (style.overflowX() != OverflowVisible || | 417 if (style.overflowX() != OverflowVisible || |
403 style.overflowY() != OverflowVisible) | 418 style.overflowY() != OverflowVisible) |
404 adjustOverflow(style); | 419 adjustOverflow(style); |
405 | 420 |
406 if (doesNotInheritTextDecoration(style, element)) | 421 if (doesNotInheritTextDecoration(style, element)) |
407 style.clearAppliedTextDecorations(); | 422 style.clearAppliedTextDecorations(); |
408 else | 423 else |
409 style.restoreParentTextDecorations(parentStyle); | 424 style.restoreParentTextDecorations(parentStyle); |
410 style.applyTextDecorations(); | 425 style.applyTextDecorations(); |
411 | 426 |
412 // Cull out any useless layers and also repeat patterns into additional layers
. | 427 // Cull out any useless layers and also repeat patterns into additional |
| 428 // layers. |
413 style.adjustBackgroundLayers(); | 429 style.adjustBackgroundLayers(); |
414 style.adjustMaskLayers(); | 430 style.adjustMaskLayers(); |
415 | 431 |
416 // Let the theme also have a crack at adjusting the style. | 432 // Let the theme also have a crack at adjusting the style. |
417 if (style.hasAppearance()) | 433 if (style.hasAppearance()) |
418 LayoutTheme::theme().adjustStyle(style, element); | 434 LayoutTheme::theme().adjustStyle(style, element); |
419 | 435 |
420 // If we have first-letter pseudo style, transitions, or animations, do not sh
are this style. | 436 // If we have first-letter pseudo style, transitions, or animations, do not |
| 437 // share this style. |
421 if (style.hasPseudoStyle(PseudoIdFirstLetter) || style.transitions() || | 438 if (style.hasPseudoStyle(PseudoIdFirstLetter) || style.transitions() || |
422 style.animations()) | 439 style.animations()) |
423 style.setUnique(); | 440 style.setUnique(); |
424 | 441 |
425 adjustStyleForEditing(style); | 442 adjustStyleForEditing(style); |
426 | 443 |
427 bool isSVGElement = element && element->isSVGElement(); | 444 bool isSVGElement = element && element->isSVGElement(); |
428 if (isSVGElement) { | 445 if (isSVGElement) { |
429 // Only the root <svg> element in an SVG document fragment tree honors css p
osition | 446 // Only the root <svg> element in an SVG document fragment tree honors css |
| 447 // position. |
430 if (!(isSVGSVGElement(*element) && element->parentNode() && | 448 if (!(isSVGSVGElement(*element) && element->parentNode() && |
431 !element->parentNode()->isSVGElement())) | 449 !element->parentNode()->isSVGElement())) |
432 style.setPosition(ComputedStyle::initialPosition()); | 450 style.setPosition(ComputedStyle::initialPosition()); |
433 | 451 |
434 // SVG text layout code expects us to be a block-level style element. | 452 // SVG text layout code expects us to be a block-level style element. |
435 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && | 453 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && |
436 style.isDisplayInlineType()) | 454 style.isDisplayInlineType()) |
437 style.setDisplay(EDisplay::Block); | 455 style.setDisplay(EDisplay::Block); |
438 | 456 |
439 // Columns don't apply to svg text elements. | 457 // Columns don't apply to svg text elements. |
440 if (isSVGTextElement(*element)) | 458 if (isSVGTextElement(*element)) |
441 style.clearMultiCol(); | 459 style.clearMultiCol(); |
442 } | 460 } |
443 adjustStyleForAlignment(style, parentStyle); | 461 adjustStyleForAlignment(style, parentStyle); |
444 } | 462 } |
445 | 463 |
446 } // namespace blink | 464 } // namespace blink |
OLD | NEW |