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

Side by Side Diff: Source/core/css/StyleResolver.cpp

Issue 13992003: Add support for parsing <grid-line> that includes a 'span' (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed the change to match the specification Created 7 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
« no previous file with comments | « Source/core/css/StyleResolver.h ('k') | Source/core/rendering/RenderGrid.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 // FIXME: when dropping the -webkit prefix on transform-style, we should als o have opacity < 1 cause flattening. 1526 // FIXME: when dropping the -webkit prefix on transform-style, we should als o have opacity < 1 cause flattening.
1527 if (style->preserves3D() && (style->overflowX() != OVISIBLE 1527 if (style->preserves3D() && (style->overflowX() != OVISIBLE
1528 || style->overflowY() != OVISIBLE 1528 || style->overflowY() != OVISIBLE
1529 || style->hasFilter())) 1529 || style->hasFilter()))
1530 style->setTransformStyle3D(TransformStyle3DFlat); 1530 style->setTransformStyle3D(TransformStyle3DFlat);
1531 1531
1532 // Seamless iframes behave like blocks. Map their display to inline-block wh en marked inline. 1532 // Seamless iframes behave like blocks. Map their display to inline-block wh en marked inline.
1533 if (e && e->hasTagName(iframeTag) && style->display() == INLINE && static_ca st<HTMLIFrameElement*>(e)->shouldDisplaySeamlessly()) 1533 if (e && e->hasTagName(iframeTag) && style->display() == INLINE && static_ca st<HTMLIFrameElement*>(e)->shouldDisplaySeamlessly())
1534 style->setDisplay(INLINE_BLOCK); 1534 style->setDisplay(INLINE_BLOCK);
1535 1535
1536 adjustGridItemPosition(style);
1537
1536 #if ENABLE(SVG) 1538 #if ENABLE(SVG)
1537 if (e && e->isSVGElement()) { 1539 if (e && e->isSVGElement()) {
1538 // Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty 1540 // Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
1539 if (style->overflowY() == OSCROLL) 1541 if (style->overflowY() == OSCROLL)
1540 style->setOverflowY(OHIDDEN); 1542 style->setOverflowY(OHIDDEN);
1541 else if (style->overflowY() == OAUTO) 1543 else if (style->overflowY() == OAUTO)
1542 style->setOverflowY(OVISIBLE); 1544 style->setOverflowY(OVISIBLE);
1543 1545
1544 if (style->overflowX() == OSCROLL) 1546 if (style->overflowX() == OSCROLL)
1545 style->setOverflowX(OHIDDEN); 1547 style->setOverflowX(OHIDDEN);
1546 else if (style->overflowX() == OAUTO) 1548 else if (style->overflowX() == OAUTO)
1547 style->setOverflowX(OVISIBLE); 1549 style->setOverflowX(OVISIBLE);
1548 1550
1549 // Only the root <svg> element in an SVG document fragment tree honors c ss position 1551 // Only the root <svg> element in an SVG document fragment tree honors c ss position
1550 if (!(e->hasTagName(SVGNames::svgTag) && e->parentNode() && !e->parentNo de()->isSVGElement())) 1552 if (!(e->hasTagName(SVGNames::svgTag) && e->parentNode() && !e->parentNo de()->isSVGElement()))
1551 style->setPosition(RenderStyle::initialPosition()); 1553 style->setPosition(RenderStyle::initialPosition());
1552 1554
1553 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should 1555 // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignOb ject content should
1554 // not be scaled again. 1556 // not be scaled again.
1555 if (e->hasTagName(SVGNames::foreignObjectTag)) 1557 if (e->hasTagName(SVGNames::foreignObjectTag))
1556 style->setEffectiveZoom(RenderStyle::initialZoom()); 1558 style->setEffectiveZoom(RenderStyle::initialZoom());
1557 } 1559 }
1558 #endif 1560 #endif
1559 } 1561 }
1560 1562
1563 void StyleResolver::adjustGridItemPosition(RenderStyle* style) const
1564 {
1565 // If opposing grid-placement properties both specify a grid span, they both compute to ‘auto’.
1566 if (style->gridItemStart().isSpan() && style->gridItemEnd().isSpan()) {
1567 style->setGridItemStart(GridPosition());
1568 style->setGridItemEnd(GridPosition());
1569 }
1570
1571 if (style->gridItemBefore().isSpan() && style->gridItemAfter().isSpan()) {
1572 style->setGridItemBefore(GridPosition());
1573 style->setGridItemAfter(GridPosition());
1574 }
1575 }
1576
1561 bool StyleResolver::checkRegionStyle(Element* regionElement) 1577 bool StyleResolver::checkRegionStyle(Element* regionElement)
1562 { 1578 {
1563 // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style she ets for the moment, 1579 // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style she ets for the moment,
1564 // so all region rules are global by default. Verify whether that can stand or needs changing. 1580 // so all region rules are global by default. Verify whether that can stand or needs changing.
1565 1581
1566 unsigned rulesSize = m_ruleSets.authorStyle()->m_regionSelectorsAndRuleSets. size(); 1582 unsigned rulesSize = m_ruleSets.authorStyle()->m_regionSelectorsAndRuleSets. size();
1567 for (unsigned i = 0; i < rulesSize; ++i) { 1583 for (unsigned i = 0; i < rulesSize; ++i) {
1568 ASSERT(m_ruleSets.authorStyle()->m_regionSelectorsAndRuleSets.at(i).rule Set.get()); 1584 ASSERT(m_ruleSets.authorStyle()->m_regionSelectorsAndRuleSets.at(i).rule Set.get());
1569 if (checkRegionSelector(m_ruleSets.authorStyle()->m_regionSelectorsAndRu leSets.at(i).selector, regionElement)) 1585 if (checkRegionSelector(m_ruleSets.authorStyle()->m_regionSelectorsAndRu leSets.at(i).selector, regionElement))
1570 return true; 1586 return true;
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 return false; 2111 return false;
2096 2112
2097 trackSizes.append(trackSize); 2113 trackSizes.append(trackSize);
2098 } 2114 }
2099 return true; 2115 return true;
2100 } 2116 }
2101 2117
2102 2118
2103 static bool createGridPosition(CSSValue* value, GridPosition& position) 2119 static bool createGridPosition(CSSValue* value, GridPosition& position)
2104 { 2120 {
2105 // For now, we only accept: <integer> | 'auto' 2121 // For now, we only accept: 'auto' | <integer> | span && <integer>?
2106 if (!value->isPrimitiveValue()) 2122 if (value->isPrimitiveValue()) {
2107 return false; 2123 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(valu e);
2124 if (primitiveValue->getIdent() == CSSValueAuto)
2125 return true;
2108 2126
2109 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 2127 if (primitiveValue->getIdent() == CSSValueSpan) {
2110 if (primitiveValue->getIdent() == CSSValueAuto) 2128 // If the <integer> is omitted, it defaults to '1'.
2129 position.setSpanPosition(1);
2130 return true;
2131 }
2132
2133 ASSERT(primitiveValue->isNumber());
2134 position.setIntegerPosition(primitiveValue->getIntValue());
2111 return true; 2135 return true;
2136 }
2112 2137
2113 ASSERT_WITH_SECURITY_IMPLICATION(primitiveValue->isNumber()); 2138 ASSERT_WITH_SECURITY_IMPLICATION(value->isValueList());
2114 position.setIntegerPosition(primitiveValue->getIntValue()); 2139 CSSValueList* values = static_cast<CSSValueList*>(value);
2140 ASSERT(values->length() == 2);
2141 ASSERT_WITH_SECURITY_IMPLICATION(values->itemWithoutBoundsCheck(1)->isPrimit iveValue());
2142 CSSPrimitiveValue* numericValue = static_cast<CSSPrimitiveValue*>(values->it emWithoutBoundsCheck(1));
2143 ASSERT(numericValue->isNumber());
2144 position.setSpanPosition(numericValue->getIntValue());
2115 return true; 2145 return true;
2116 } 2146 }
2117 2147
2118 static bool hasVariableReference(CSSValue* value) 2148 static bool hasVariableReference(CSSValue* value)
2119 { 2149 {
2120 if (value->isPrimitiveValue()) { 2150 if (value->isPrimitiveValue()) {
2121 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(valu e); 2151 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(valu e);
2122 return primitiveValue->hasVariableReference(); 2152 return primitiveValue->hasVariableReference();
2123 } 2153 }
2124 2154
(...skipping 2293 matching lines...) Expand 10 before | Expand all | Expand 10 after
4418 info.addMember(m_state, "state"); 4448 info.addMember(m_state, "state");
4419 4449
4420 // FIXME: move this to a place where it would be called only once? 4450 // FIXME: move this to a place where it would be called only once?
4421 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle"); 4451 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle");
4422 info.addMember(CSSDefaultStyleSheets::defaultQuirksStyle, "defaultQuirksStyl e"); 4452 info.addMember(CSSDefaultStyleSheets::defaultQuirksStyle, "defaultQuirksStyl e");
4423 info.addMember(CSSDefaultStyleSheets::defaultPrintStyle,"defaultPrintStyle") ; 4453 info.addMember(CSSDefaultStyleSheets::defaultPrintStyle,"defaultPrintStyle") ;
4424 info.addMember(CSSDefaultStyleSheets::defaultViewSourceStyle, "defaultViewSo urceStyle"); 4454 info.addMember(CSSDefaultStyleSheets::defaultViewSourceStyle, "defaultViewSo urceStyle");
4425 } 4455 }
4426 4456
4427 } // namespace WebCore 4457 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/StyleResolver.h ('k') | Source/core/rendering/RenderGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698