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

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

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 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 | Annotate | Revision Log
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. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * 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/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 26 matching lines...) Expand all
37 #include "core/frame/FrameView.h" 37 #include "core/frame/FrameView.h"
38 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
39 #include "core/html/HTMLIFrameElement.h" 39 #include "core/html/HTMLIFrameElement.h"
40 #include "core/html/HTMLInputElement.h" 40 #include "core/html/HTMLInputElement.h"
41 #include "core/html/HTMLPlugInElement.h" 41 #include "core/html/HTMLPlugInElement.h"
42 #include "core/html/HTMLTableCellElement.h" 42 #include "core/html/HTMLTableCellElement.h"
43 #include "core/html/HTMLTextAreaElement.h" 43 #include "core/html/HTMLTextAreaElement.h"
44 #include "core/layout/LayoutReplaced.h" 44 #include "core/layout/LayoutReplaced.h"
45 #include "core/layout/LayoutTheme.h" 45 #include "core/layout/LayoutTheme.h"
46 #include "core/layout/style/GridPosition.h" 46 #include "core/layout/style/GridPosition.h"
47 #include "core/layout/style/LayoutStyle.h" 47 #include "core/layout/style/ComputedStyle.h"
48 #include "core/layout/style/LayoutStyleConstants.h" 48 #include "core/layout/style/ComputedStyleConstants.h"
49 #include "core/svg/SVGSVGElement.h" 49 #include "core/svg/SVGSVGElement.h"
50 #include "platform/Length.h" 50 #include "platform/Length.h"
51 #include "platform/transforms/TransformOperations.h" 51 #include "platform/transforms/TransformOperations.h"
52 #include "wtf/Assertions.h" 52 #include "wtf/Assertions.h"
53 53
54 namespace blink { 54 namespace blink {
55 55
56 using namespace HTMLNames; 56 using namespace HTMLNames;
57 57
58 static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s trictParsing) 58 static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s trictParsing)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 ASSERT_NOT_REACHED(); 94 ASSERT_NOT_REACHED();
95 return NONE; 95 return NONE;
96 } 96 }
97 ASSERT_NOT_REACHED(); 97 ASSERT_NOT_REACHED();
98 return BLOCK; 98 return BLOCK;
99 } 99 }
100 100
101 // CSS requires text-decoration to be reset at each DOM element for tables, 101 // CSS requires text-decoration to be reset at each DOM element for tables,
102 // inline blocks, inline tables, shadow DOM crossings, floating elements, 102 // inline blocks, inline tables, shadow DOM crossings, floating elements,
103 // and absolute or relatively positioned elements. 103 // and absolute or relatively positioned elements.
104 static bool doesNotInheritTextDecoration(const LayoutStyle& style, const Element * e) 104 static bool doesNotInheritTextDecoration(const ComputedStyle& style, const Eleme nt* e)
105 { 105 {
106 return style.display() == TABLE || style.display() == INLINE_TABLE 106 return style.display() == TABLE || style.display() == INLINE_TABLE
107 || style.display() == INLINE_BLOCK || style.display() == INLINE_BOX || i sAtShadowBoundary(e) 107 || style.display() == INLINE_BLOCK || style.display() == INLINE_BOX || i sAtShadowBoundary(e)
108 || style.isFloating() || style.hasOutOfFlowPosition(); 108 || style.isFloating() || style.hasOutOfFlowPosition();
109 } 109 }
110 110
111 // FIXME: This helper is only needed because pseudoStyleForElement passes a null 111 // FIXME: This helper is only needed because pseudoStyleForElement passes a null
112 // element to adjustLayoutStyle, so we can't just use element->isInTopLayer(). 112 // element to adjustComputedStyle, so we can't just use element->isInTopLayer().
113 static bool isInTopLayer(const Element* element, const LayoutStyle& style) 113 static bool isInTopLayer(const Element* element, const ComputedStyle& style)
114 { 114 {
115 return (element && element->isInTopLayer()) || style.styleType() == BACKDROP ; 115 return (element && element->isInTopLayer()) || style.styleType() == BACKDROP ;
116 } 116 }
117 117
118 static bool parentStyleForcesZIndexToCreateStackingContext(const LayoutStyle& pa rentStyle) 118 static bool parentStyleForcesZIndexToCreateStackingContext(const ComputedStyle& parentStyle)
119 { 119 {
120 return parentStyle.isDisplayFlexibleOrGridBox(); 120 return parentStyle.isDisplayFlexibleOrGridBox();
121 } 121 }
122 122
123 static bool hasWillChangeThatCreatesStackingContext(const LayoutStyle& style) 123 static bool hasWillChangeThatCreatesStackingContext(const ComputedStyle& style)
124 { 124 {
125 for (size_t i = 0; i < style.willChangeProperties().size(); ++i) { 125 for (size_t i = 0; i < style.willChangeProperties().size(); ++i) {
126 switch (style.willChangeProperties()[i]) { 126 switch (style.willChangeProperties()[i]) {
127 case CSSPropertyOpacity: 127 case CSSPropertyOpacity:
128 case CSSPropertyTransform: 128 case CSSPropertyTransform:
129 case CSSPropertyWebkitTransform: 129 case CSSPropertyWebkitTransform:
130 case CSSPropertyTransformStyle: 130 case CSSPropertyTransformStyle:
131 case CSSPropertyWebkitTransformStyle: 131 case CSSPropertyWebkitTransformStyle:
132 case CSSPropertyPerspective: 132 case CSSPropertyPerspective:
133 case CSSPropertyWebkitPerspective: 133 case CSSPropertyWebkitPerspective:
(...skipping 10 matching lines...) Expand all
144 if (RuntimeEnabledFeatures::cssCompositingEnabled()) 144 if (RuntimeEnabledFeatures::cssCompositingEnabled())
145 return true; 145 return true;
146 break; 146 break;
147 default: 147 default:
148 break; 148 break;
149 } 149 }
150 } 150 }
151 return false; 151 return false;
152 } 152 }
153 153
154 void StyleAdjuster::adjustLayoutStyle(LayoutStyle& style, const LayoutStyle& par entStyle, Element *e, const AuthorStyleInfo& authorStyle) 154 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, const ComputedStyl e& parentStyle, Element *e, const AuthorStyleInfo& authorStyle)
155 { 155 {
156 if (style.display() != NONE) { 156 if (style.display() != NONE) {
157 if (e && e->isHTMLElement()) 157 if (e && e->isHTMLElement())
158 adjustStyleForHTMLElement(style, parentStyle, toHTMLElement(*e)); 158 adjustStyleForHTMLElement(style, parentStyle, toHTMLElement(*e));
159 159
160 // Per the spec, position 'static' and 'relative' in the top layer compu te to 'absolute'. 160 // Per the spec, position 'static' and 'relative' in the top layer compu te to 'absolute'.
161 if (isInTopLayer(e, style) && (style.position() == StaticPosition || sty le.position() == RelativePosition)) 161 if (isInTopLayer(e, style) && (style.position() == StaticPosition || sty le.position() == RelativePosition))
162 style.setPosition(AbsolutePosition); 162 style.setPosition(AbsolutePosition);
163 163
164 // Absolute/fixed positioned elements, floating elements and the documen t element need block-like outside display. 164 // Absolute/fixed positioned elements, floating elements and the documen t element need block-like outside display.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 // FIXME: when dropping the -webkit prefix on transform-style, we should als o have opacity < 1 cause flattening. 225 // FIXME: when dropping the -webkit prefix on transform-style, we should als o have opacity < 1 cause flattening.
226 if (style.preserves3D() && (style.overflowX() != OVISIBLE 226 if (style.preserves3D() && (style.overflowX() != OVISIBLE
227 || style.overflowY() != OVISIBLE 227 || style.overflowY() != OVISIBLE
228 || style.hasFilter())) 228 || style.hasFilter()))
229 style.setTransformStyle3D(TransformStyle3DFlat); 229 style.setTransformStyle3D(TransformStyle3DFlat);
230 230
231 if (e && e->isSVGElement()) { 231 if (e && e->isSVGElement()) {
232 // Only the root <svg> element in an SVG document fragment tree honors c ss position 232 // Only the root <svg> element in an SVG document fragment tree honors c ss position
233 if (!(isSVGSVGElement(*e) && e->parentNode() && !e->parentNode()->isSVGE lement())) 233 if (!(isSVGSVGElement(*e) && e->parentNode() && !e->parentNode()->isSVGE lement()))
234 style.setPosition(LayoutStyle::initialPosition()); 234 style.setPosition(ComputedStyle::initialPosition());
235 235
236 // SVG text layout code expects us to be a block-level style element. 236 // SVG text layout code expects us to be a block-level style element.
237 if ((isSVGForeignObjectElement(*e) || isSVGTextElement(*e)) && style.isD isplayInlineType()) 237 if ((isSVGForeignObjectElement(*e) || isSVGTextElement(*e)) && style.isD isplayInlineType())
238 style.setDisplay(BLOCK); 238 style.setDisplay(BLOCK);
239 239
240 // Columns don't apply to svg text elements. 240 // Columns don't apply to svg text elements.
241 if (isSVGTextElement(*e)) 241 if (isSVGTextElement(*e))
242 style.clearMultiCol(); 242 style.clearMultiCol();
243 } 243 }
244 adjustStyleForAlignment(style, parentStyle); 244 adjustStyleForAlignment(style, parentStyle);
245 } 245 }
246 246
247 void StyleAdjuster::adjustStyleForFirstLetter(LayoutStyle& style) 247 void StyleAdjuster::adjustStyleForFirstLetter(ComputedStyle& style)
248 { 248 {
249 if (style.styleType() != FIRST_LETTER) 249 if (style.styleType() != FIRST_LETTER)
250 return; 250 return;
251 251
252 // Force inline display (except for floating first-letters). 252 // Force inline display (except for floating first-letters).
253 style.setDisplay(style.isFloating() ? BLOCK : INLINE); 253 style.setDisplay(style.isFloating() ? BLOCK : INLINE);
254 254
255 // CSS2 says first-letter can't be positioned. 255 // CSS2 says first-letter can't be positioned.
256 style.setPosition(StaticPosition); 256 style.setPosition(StaticPosition);
257 } 257 }
258 258
259 void StyleAdjuster::adjustStyleForAlignment(LayoutStyle& style, const LayoutStyl e& parentStyle) 259 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle)
260 { 260 {
261 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); 261 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox();
262 bool absolutePositioned = style.position() == AbsolutePosition; 262 bool absolutePositioned = style.position() == AbsolutePosition;
263 263
264 // If the inherited value of justify-items includes the legacy keyword, 'aut o' 264 // If the inherited value of justify-items includes the legacy keyword, 'aut o'
265 // computes to the the inherited value. 265 // computes to the the inherited value.
266 // Otherwise, auto computes to: 266 // Otherwise, auto computes to:
267 // - 'stretch' for flex containers and grid containers. 267 // - 'stretch' for flex containers and grid containers.
268 // - 'start' for everything else. 268 // - 'start' for everything else.
269 if (style.justifyItems() == ItemPositionAuto) { 269 if (style.justifyItems() == ItemPositionAuto) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (style.alignContent() == ContentPositionAuto && style.alignContentDistrib ution() == ContentDistributionDefault) { 327 if (style.alignContent() == ContentPositionAuto && style.alignContentDistrib ution() == ContentDistributionDefault) {
328 if (style.isDisplayFlexibleOrGridBox()) { 328 if (style.isDisplayFlexibleOrGridBox()) {
329 if (style.isDisplayFlexibleBox()) 329 if (style.isDisplayFlexibleBox())
330 style.setAlignContentDistribution(ContentDistributionStretch); 330 style.setAlignContentDistribution(ContentDistributionStretch);
331 else 331 else
332 style.setAlignContent(ContentPositionStart); 332 style.setAlignContent(ContentPositionStart);
333 } 333 }
334 } 334 }
335 } 335 }
336 336
337 void StyleAdjuster::adjustStyleForHTMLElement(LayoutStyle& style, const LayoutSt yle& parentStyle, HTMLElement& element) 337 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element)
338 { 338 {
339 // <div> and <span> are the most common elements on the web, we skip all the work for them. 339 // <div> and <span> are the most common elements on the web, we skip all the work for them.
340 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 340 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
341 return; 341 return;
342 342
343 if (isHTMLTableCellElement(element)) { 343 if (isHTMLTableCellElement(element)) {
344 // If we have a <td> that specifies a float property, in quirks mode we just drop the float property. 344 // If we have a <td> that specifies a float property, in quirks mode we just drop the float property.
345 // FIXME: Why is this only <td> and not <th>? 345 // FIXME: Why is this only <td> and not <th>?
346 if (element.hasTagName(tdTag) && m_useQuirksModeStyles) { 346 if (element.hasTagName(tdTag) && m_useQuirksModeStyles) {
347 style.setDisplay(TABLE_CELL); 347 style.setDisplay(TABLE_CELL);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 if (style.width().isAuto()) 417 if (style.width().isAuto())
418 style.setWidth(Length(LayoutReplaced::defaultWidth, Fixed)); 418 style.setWidth(Length(LayoutReplaced::defaultWidth, Fixed));
419 if (style.height().isAuto()) 419 if (style.height().isAuto())
420 style.setHeight(Length(LayoutReplaced::defaultHeight, Fixed)); 420 style.setHeight(Length(LayoutReplaced::defaultHeight, Fixed));
421 } 421 }
422 422
423 return; 423 return;
424 } 424 }
425 } 425 }
426 426
427 void StyleAdjuster::adjustOverflow(LayoutStyle& style) 427 void StyleAdjuster::adjustOverflow(ComputedStyle& style)
428 { 428 {
429 ASSERT(style.overflowX() != OVISIBLE || style.overflowY() != OVISIBLE); 429 ASSERT(style.overflowX() != OVISIBLE || style.overflowY() != OVISIBLE);
430 430
431 // If either overflow value is not visible, change to auto. 431 // If either overflow value is not visible, change to auto.
432 if (style.overflowX() == OVISIBLE && style.overflowY() != OVISIBLE) { 432 if (style.overflowX() == OVISIBLE && style.overflowY() != OVISIBLE) {
433 // FIXME: Once we implement pagination controls, overflow-x should defau lt to hidden 433 // FIXME: Once we implement pagination controls, overflow-x should defau lt to hidden
434 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w e'll let it 434 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w e'll let it
435 // default to auto so we can at least scroll through the pages. 435 // default to auto so we can at least scroll through the pages.
436 style.setOverflowX(OAUTO); 436 style.setOverflowX(OAUTO);
437 } else if (style.overflowY() == OVISIBLE && style.overflowX() != OVISIBLE) { 437 } else if (style.overflowY() == OVISIBLE && style.overflowX() != OVISIBLE) {
(...skipping 10 matching lines...) Expand all
448 style.setOverflowY(OVISIBLE); 448 style.setOverflowY(OVISIBLE);
449 } 449 }
450 450
451 // Menulists should have visible overflow 451 // Menulists should have visible overflow
452 if (style.appearance() == MenulistPart) { 452 if (style.appearance() == MenulistPart) {
453 style.setOverflowX(OVISIBLE); 453 style.setOverflowX(OVISIBLE);
454 style.setOverflowY(OVISIBLE); 454 style.setOverflowY(OVISIBLE);
455 } 455 }
456 } 456 }
457 457
458 void StyleAdjuster::adjustStyleForDisplay(LayoutStyle& style, const LayoutStyle& parentStyle) 458 void StyleAdjuster::adjustStyleForDisplay(ComputedStyle& style, const ComputedSt yle& parentStyle)
459 { 459 {
460 if (style.display() == BLOCK && !style.isFloating()) 460 if (style.display() == BLOCK && !style.isFloating())
461 return; 461 return;
462 462
463 // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely 463 // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely
464 // clear how that should work. 464 // clear how that should work.
465 if (style.display() == INLINE && style.styleType() == NOPSEUDO && style.writ ingMode() != parentStyle.writingMode()) 465 if (style.display() == INLINE && style.styleType() == NOPSEUDO && style.writ ingMode() != parentStyle.writingMode())
466 style.setDisplay(INLINE_BLOCK); 466 style.setDisplay(INLINE_BLOCK);
467 467
468 // After performing the display mutation, check table rows. We do not honor position: relative table rows or cells. 468 // After performing the display mutation, check table rows. We do not honor position: relative table rows or cells.
(...skipping 17 matching lines...) Expand all
486 if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX)) 486 if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX))
487 style.setWritingMode(TopToBottomWritingMode); 487 style.setWritingMode(TopToBottomWritingMode);
488 488
489 if (parentStyle.isDisplayFlexibleOrGridBox()) { 489 if (parentStyle.isDisplayFlexibleOrGridBox()) {
490 style.setFloating(NoFloat); 490 style.setFloating(NoFloat);
491 style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloatin g(), !m_useQuirksModeStyles)); 491 style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloatin g(), !m_useQuirksModeStyles));
492 } 492 }
493 } 493 }
494 494
495 } 495 }
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleAdjuster.h ('k') | Source/core/css/resolver/StyleBuilderConverter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698