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

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

Issue 2614883007: Change computed style enums to be prefixed with 'k'. (Closed)
Patch Set: Rebase on ToT. Created 3 years, 11 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 static bool parentStyleForcesZIndexToCreateStackingContext( 132 static bool parentStyleForcesZIndexToCreateStackingContext(
133 const ComputedStyle& parentStyle) { 133 const ComputedStyle& parentStyle) {
134 return parentStyle.isDisplayFlexibleOrGridBox(); 134 return parentStyle.isDisplayFlexibleOrGridBox();
135 } 135 }
136 136
137 void StyleAdjuster::adjustStyleForEditing(ComputedStyle& style) { 137 void StyleAdjuster::adjustStyleForEditing(ComputedStyle& style) {
138 if (style.userModify() != READ_WRITE_PLAINTEXT_ONLY) 138 if (style.userModify() != READ_WRITE_PLAINTEXT_ONLY)
139 return; 139 return;
140 // Collapsing whitespace is harmful in plain-text editing. 140 // Collapsing whitespace is harmful in plain-text editing.
141 if (style.whiteSpace() == EWhiteSpace::Normal) 141 if (style.whiteSpace() == EWhiteSpace::kNormal)
142 style.setWhiteSpace(EWhiteSpace::PreWrap); 142 style.setWhiteSpace(EWhiteSpace::kPreWrap);
143 else if (style.whiteSpace() == EWhiteSpace::Nowrap) 143 else if (style.whiteSpace() == EWhiteSpace::kNowrap)
144 style.setWhiteSpace(EWhiteSpace::Pre); 144 style.setWhiteSpace(EWhiteSpace::kPre);
145 else if (style.whiteSpace() == EWhiteSpace::PreLine) 145 else if (style.whiteSpace() == EWhiteSpace::kPreLine)
146 style.setWhiteSpace(EWhiteSpace::PreWrap); 146 style.setWhiteSpace(EWhiteSpace::kPreWrap);
147 } 147 }
148 148
149 static void adjustStyleForFirstLetter(ComputedStyle& style) { 149 static void adjustStyleForFirstLetter(ComputedStyle& style) {
150 if (style.styleType() != PseudoIdFirstLetter) 150 if (style.styleType() != PseudoIdFirstLetter)
151 return; 151 return;
152 152
153 // Force inline display (except for floating first-letters). 153 // Force inline display (except for floating first-letters).
154 style.setDisplay(style.isFloating() ? EDisplay::Block : EDisplay::Inline); 154 style.setDisplay(style.isFloating() ? EDisplay::Block : EDisplay::Inline);
155 155
156 // CSS2 says first-letter can't be positioned. 156 // CSS2 says first-letter can't be positioned.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 static void adjustStyleForHTMLElement(ComputedStyle& style, 191 static void adjustStyleForHTMLElement(ComputedStyle& style,
192 HTMLElement& element) { 192 HTMLElement& element) {
193 // <div> and <span> are the most common elements on the web, we skip all the 193 // <div> and <span> are the most common elements on the web, we skip all the
194 // work for them. 194 // work for them.
195 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 195 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
196 return; 196 return;
197 197
198 if (isHTMLTableCellElement(element)) { 198 if (isHTMLTableCellElement(element)) {
199 if (style.whiteSpace() == EWhiteSpace::WebkitNowrap) { 199 if (style.whiteSpace() == EWhiteSpace::kWebkitNowrap) {
200 // Figure out if we are really nowrapping or if we should just 200 // Figure out if we are really nowrapping or if we should just
201 // use normal instead. If the width of the cell is fixed, then 201 // use normal instead. If the width of the cell is fixed, then
202 // we don't actually use NOWRAP. 202 // we don't actually use NOWRAP.
203 if (style.width().isFixed()) 203 if (style.width().isFixed())
204 style.setWhiteSpace(EWhiteSpace::Normal); 204 style.setWhiteSpace(EWhiteSpace::kNormal);
205 else 205 else
206 style.setWhiteSpace(EWhiteSpace::Nowrap); 206 style.setWhiteSpace(EWhiteSpace::kNowrap);
207 } 207 }
208 return; 208 return;
209 } 209 }
210 210
211 if (isHTMLTableElement(element)) { 211 if (isHTMLTableElement(element)) {
212 // Tables never support the -webkit-* values for text-align and will reset 212 // Tables never support the -webkit-* values for text-align and will reset
213 // back to the default. 213 // back to the default.
214 if (style.textAlign() == ETextAlign::WebkitLeft || 214 if (style.textAlign() == ETextAlign::kWebkitLeft ||
215 style.textAlign() == ETextAlign::WebkitCenter || 215 style.textAlign() == ETextAlign::kWebkitCenter ||
216 style.textAlign() == ETextAlign::WebkitRight) 216 style.textAlign() == ETextAlign::kWebkitRight)
217 style.setTextAlign(ETextAlign::Start); 217 style.setTextAlign(ETextAlign::kStart);
218 return; 218 return;
219 } 219 }
220 220
221 if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) { 221 if (isHTMLFrameElement(element) || isHTMLFrameSetElement(element)) {
222 // Frames and framesets never honor position:relative or position:absolute. 222 // Frames and framesets never honor position:relative or position:absolute.
223 // This is necessary to fix a crash where a site tries to position these 223 // This is necessary to fix a crash where a site tries to position these
224 // objects. They also never honor display. 224 // objects. They also never honor display.
225 style.setPosition(StaticPosition); 225 style.setPosition(StaticPosition);
226 style.setDisplay(EDisplay::Block); 226 style.setDisplay(EDisplay::Block);
227 return; 227 return;
228 } 228 }
229 229
230 if (isHTMLFrameElementBase(element)) { 230 if (isHTMLFrameElementBase(element)) {
231 // Frames cannot overflow (they are always the size we ask them to be). 231 // Frames cannot overflow (they are always the size we ask them to be).
232 // Some compositing code paths may try to draw scrollbars anyhow. 232 // Some compositing code paths may try to draw scrollbars anyhow.
233 style.setOverflowX(EOverflow::Visible); 233 style.setOverflowX(EOverflow::Visible);
234 style.setOverflowY(EOverflow::Visible); 234 style.setOverflowY(EOverflow::Visible);
235 return; 235 return;
236 } 236 }
237 237
238 if (isHTMLRTElement(element)) { 238 if (isHTMLRTElement(element)) {
239 // Ruby text does not support float or position. This might change with 239 // Ruby text does not support float or position. This might change with
240 // evolution of the specification. 240 // evolution of the specification.
241 style.setPosition(StaticPosition); 241 style.setPosition(StaticPosition);
242 style.setFloating(EFloat::None); 242 style.setFloating(EFloat::kNone);
243 return; 243 return;
244 } 244 }
245 245
246 if (isHTMLLegendElement(element)) { 246 if (isHTMLLegendElement(element)) {
247 style.setDisplay(EDisplay::Block); 247 style.setDisplay(EDisplay::Block);
248 return; 248 return;
249 } 249 }
250 250
251 if (isHTMLMarqueeElement(element)) { 251 if (isHTMLMarqueeElement(element)) {
252 // For now, <marquee> requires an overflow clip to work properly. 252 // For now, <marquee> requires an overflow clip to work properly.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ||
359 style.display() == EDisplay::TableRowGroup || 359 style.display() == EDisplay::TableRowGroup ||
360 style.display() == EDisplay::TableCell) 360 style.display() == EDisplay::TableCell)
361 style.setWritingMode(parentStyle.getWritingMode()); 361 style.setWritingMode(parentStyle.getWritingMode());
362 362
363 // FIXME: Since we don't support block-flow on flexible boxes yet, disallow 363 // FIXME: Since we don't support block-flow on flexible boxes yet, disallow
364 // setting of block-flow to anything other than TopToBottomWritingMode. 364 // setting of block-flow to anything other than TopToBottomWritingMode.
365 // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support. 365 // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support.
366 if (style.getWritingMode() != WritingMode::HorizontalTb && 366 if (style.getWritingMode() != WritingMode::kHorizontalTb &&
367 (style.display() == EDisplay::WebkitBox || 367 (style.display() == EDisplay::WebkitBox ||
368 style.display() == EDisplay::WebkitInlineBox)) 368 style.display() == EDisplay::WebkitInlineBox))
369 style.setWritingMode(WritingMode::HorizontalTb); 369 style.setWritingMode(WritingMode::kHorizontalTb);
370 370
371 if (parentStyle.isDisplayFlexibleOrGridBox()) { 371 if (parentStyle.isDisplayFlexibleOrGridBox()) {
372 style.setFloating(EFloat::None); 372 style.setFloating(EFloat::kNone);
373 style.setDisplay(equivalentBlockDisplay(style.display())); 373 style.setDisplay(equivalentBlockDisplay(style.display()));
374 374
375 // We want to count vertical percentage paddings/margins on flex items 375 // We want to count vertical percentage paddings/margins on flex items
376 // because our current behavior is different from the spec and we want to 376 // because our current behavior is different from the spec and we want to
377 // gather compatibility data. 377 // gather compatibility data.
378 if (style.paddingBefore().isPercentOrCalc() || 378 if (style.paddingBefore().isPercentOrCalc() ||
379 style.paddingAfter().isPercentOrCalc()) 379 style.paddingAfter().isPercentOrCalc())
380 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVertical); 380 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVertical);
381 if (style.marginBefore().isPercentOrCalc() || 381 if (style.marginBefore().isPercentOrCalc() ||
382 style.marginAfter().isPercentOrCalc()) 382 style.marginAfter().isPercentOrCalc())
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 style.setDisplay(EDisplay::Block); 476 style.setDisplay(EDisplay::Block);
477 477
478 // Columns don't apply to svg text elements. 478 // Columns don't apply to svg text elements.
479 if (isSVGTextElement(*element)) 479 if (isSVGTextElement(*element))
480 style.clearMultiCol(); 480 style.clearMultiCol();
481 } 481 }
482 adjustStyleForAlignment(style, parentStyle); 482 adjustStyleForAlignment(style, parentStyle);
483 } 483 }
484 484
485 } // namespace blink 485 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698