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 141 matching lines...) Loading... |
152 if (style.StyleType() != kPseudoIdFirstLetter) | 152 if (style.StyleType() != kPseudoIdFirstLetter) |
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::kBlock : EDisplay::kInline); | 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( | |
163 ComputedStyle& style, | |
164 const ComputedStyle& layout_parent_style) { | |
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 | |
167 // mean 'normal' after running it. | |
168 | |
169 // If the inherited value of justify-items includes the 'legacy' keyword, | |
170 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to | |
171 // 'normal'. | |
172 if (style.JustifyItemsPosition() == kItemPositionAuto) { | |
173 if (layout_parent_style.JustifyItemsPositionType() == kLegacyPosition) | |
174 style.SetJustifyItems(layout_parent_style.JustifyItems()); | |
175 } | |
176 | |
177 // The 'auto' keyword computes the computed value of justify-items on the | |
178 // parent (minus any legacy keywords), or 'normal' if the box has no parent. | |
179 if (style.JustifySelfPosition() == kItemPositionAuto) { | |
180 if (layout_parent_style.JustifyItemsPositionType() == kLegacyPosition) | |
181 style.SetJustifySelfPosition(layout_parent_style.JustifyItemsPosition()); | |
182 else if (layout_parent_style.JustifyItemsPosition() != kItemPositionAuto) | |
183 style.SetJustifySelf(layout_parent_style.JustifyItems()); | |
184 } | |
185 | |
186 // The 'auto' keyword computes the computed value of align-items on the parent | |
187 // or 'normal' if the box has no parent. | |
188 if (style.AlignSelfPosition() == kItemPositionAuto && | |
189 layout_parent_style.AlignItemsPosition() != | |
190 ComputedStyle::InitialDefaultAlignment().GetPosition()) | |
191 style.SetAlignSelf(layout_parent_style.AlignItems()); | |
192 } | |
193 | |
194 static void AdjustStyleForHTMLElement(ComputedStyle& style, | 162 static void AdjustStyleForHTMLElement(ComputedStyle& style, |
195 HTMLElement& element) { | 163 HTMLElement& element) { |
196 // <div> and <span> are the most common elements on the web, we skip all the | 164 // <div> and <span> are the most common elements on the web, we skip all the |
197 // work for them. | 165 // work for them. |
198 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) | 166 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) |
199 return; | 167 return; |
200 | 168 |
201 if (IsHTMLTableCellElement(element)) { | 169 if (IsHTMLTableCellElement(element)) { |
202 if (style.WhiteSpace() == EWhiteSpace::kWebkitNowrap) { | 170 if (style.WhiteSpace() == EWhiteSpace::kWebkitNowrap) { |
203 // Figure out if we are really nowrapping or if we should just | 171 // Figure out if we are really nowrapping or if we should just |
(...skipping 300 matching lines...) Loading... |
504 | 472 |
505 // SVG text layout code expects us to be a block-level style element. | 473 // SVG text layout code expects us to be a block-level style element. |
506 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && | 474 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && |
507 style.IsDisplayInlineType()) | 475 style.IsDisplayInlineType()) |
508 style.SetDisplay(EDisplay::kBlock); | 476 style.SetDisplay(EDisplay::kBlock); |
509 | 477 |
510 // Columns don't apply to svg text elements. | 478 // Columns don't apply to svg text elements. |
511 if (isSVGTextElement(*element)) | 479 if (isSVGTextElement(*element)) |
512 style.ClearMultiCol(); | 480 style.ClearMultiCol(); |
513 } | 481 } |
514 AdjustStyleForAlignment(style, layout_parent_style); | |
515 | 482 |
516 // If this node is sticky it marks the creation of a sticky subtree, which we | 483 // If this node is sticky it marks the creation of a sticky subtree, which we |
517 // must track to properly handle document lifecycle in some cases. | 484 // must track to properly handle document lifecycle in some cases. |
518 // | 485 // |
519 // It is possible that this node is already in a sticky subtree (i.e. we have | 486 // It is possible that this node is already in a sticky subtree (i.e. we have |
520 // nested sticky nodes) - in that case the bit will already be set via | 487 // nested sticky nodes) - in that case the bit will already be set via |
521 // inheritance from the ancestor and there is no harm to setting it again. | 488 // inheritance from the ancestor and there is no harm to setting it again. |
522 if (style.GetPosition() == EPosition::kSticky) | 489 if (style.GetPosition() == EPosition::kSticky) |
523 style.SetSubtreeIsSticky(true); | 490 style.SetSubtreeIsSticky(true); |
| 491 |
| 492 // If the inherited value of justify-items includes the 'legacy' keyword, |
| 493 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to |
| 494 // 'normal'. |
| 495 if (style.JustifyItemsPosition() == kItemPositionAuto) { |
| 496 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) |
| 497 style.SetJustifyItems(parent_style.JustifyItems()); |
| 498 } |
524 } | 499 } |
525 | 500 |
526 } // namespace blink | 501 } // namespace blink |
OLD | NEW |