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...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::Block : EDisplay::Inline); |
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(ComputedStyle& style, | 162 void StyleAdjuster::adjustStyleForAlignment( |
163 const ComputedStyle& parentStyle) { | 163 ComputedStyle& style, |
| 164 const ComputedStyle& layoutParentStyle) { |
164 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto' | 165 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto' |
165 // 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 |
166 // mean 'normal' after running it. | 167 // mean 'normal' after running it. |
167 | 168 |
168 // If the inherited value of justify-items includes the 'legacy' keyword, | 169 // If the inherited value of justify-items includes the 'legacy' keyword, |
169 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to | 170 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to |
170 // 'normal'. | 171 // 'normal'. |
171 if (style.justifyItemsPosition() == ItemPositionAuto) { | 172 if (style.justifyItemsPosition() == ItemPositionAuto) { |
172 if (parentStyle.justifyItemsPositionType() == LegacyPosition) | 173 if (layoutParentStyle.justifyItemsPositionType() == LegacyPosition) |
173 style.setJustifyItems(parentStyle.justifyItems()); | 174 style.setJustifyItems(layoutParentStyle.justifyItems()); |
174 } | 175 } |
175 | 176 |
176 // The 'auto' keyword computes the computed value of justify-items on the | 177 // The 'auto' keyword computes the computed value of justify-items on the |
177 // parent (minus any legacy keywords), or 'normal' if the box has no parent. | 178 // parent (minus any legacy keywords), or 'normal' if the box has no parent. |
178 if (style.justifySelfPosition() == ItemPositionAuto) { | 179 if (style.justifySelfPosition() == ItemPositionAuto) { |
179 if (parentStyle.justifyItemsPositionType() == LegacyPosition) | 180 if (layoutParentStyle.justifyItemsPositionType() == LegacyPosition) |
180 style.setJustifySelfPosition(parentStyle.justifyItemsPosition()); | 181 style.setJustifySelfPosition(layoutParentStyle.justifyItemsPosition()); |
181 else if (parentStyle.justifyItemsPosition() != ItemPositionAuto) | 182 else if (layoutParentStyle.justifyItemsPosition() != ItemPositionAuto) |
182 style.setJustifySelf(parentStyle.justifyItems()); | 183 style.setJustifySelf(layoutParentStyle.justifyItems()); |
183 } | 184 } |
184 | 185 |
185 // The 'auto' keyword computes the computed value of align-items on the parent | 186 // The 'auto' keyword computes the computed value of align-items on the parent |
186 // or 'normal' if the box has no parent. | 187 // or 'normal' if the box has no parent. |
187 if (style.alignSelfPosition() == ItemPositionAuto && | 188 if (style.alignSelfPosition() == ItemPositionAuto && |
188 parentStyle.alignItemsPosition() != | 189 layoutParentStyle.alignItemsPosition() != |
189 ComputedStyle::initialDefaultAlignment().position()) | 190 ComputedStyle::initialDefaultAlignment().position()) |
190 style.setAlignSelf(parentStyle.alignItems()); | 191 style.setAlignSelf(layoutParentStyle.alignItems()); |
191 } | 192 } |
192 | 193 |
193 static void adjustStyleForHTMLElement(ComputedStyle& style, | 194 static void adjustStyleForHTMLElement(ComputedStyle& style, |
194 HTMLElement& element) { | 195 HTMLElement& element) { |
195 // <div> and <span> are the most common elements on the web, we skip all the | 196 // <div> and <span> are the most common elements on the web, we skip all the |
196 // work for them. | 197 // work for them. |
197 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) | 198 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) |
198 return; | 199 return; |
199 | 200 |
200 if (isHTMLTableCellElement(element)) { | 201 if (isHTMLTableCellElement(element)) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 500 |
500 // SVG text layout code expects us to be a block-level style element. | 501 // SVG text layout code expects us to be a block-level style element. |
501 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && | 502 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && |
502 style.isDisplayInlineType()) | 503 style.isDisplayInlineType()) |
503 style.setDisplay(EDisplay::Block); | 504 style.setDisplay(EDisplay::Block); |
504 | 505 |
505 // Columns don't apply to svg text elements. | 506 // Columns don't apply to svg text elements. |
506 if (isSVGTextElement(*element)) | 507 if (isSVGTextElement(*element)) |
507 style.clearMultiCol(); | 508 style.clearMultiCol(); |
508 } | 509 } |
509 adjustStyleForAlignment(style, parentStyle); | 510 adjustStyleForAlignment(style, layoutParentStyle); |
510 } | 511 } |
511 | 512 |
512 } // namespace blink | 513 } // namespace blink |
OLD | NEW |