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

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

Issue 2798903005: Return computed style for width/height for non-root SVG (Closed)
Patch Set: - Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 5 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
7 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 7 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
8 * Copyright (C) 2015 Google Inc. All rights reserved. 8 * Copyright (C) 2015 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 2030
2031 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> 2031 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>>
2032 ComputedStyleCSSValueMapping::getVariables(const ComputedStyle& style) { 2032 ComputedStyleCSSValueMapping::getVariables(const ComputedStyle& style) {
2033 // TODO(timloh): Also return non-inherited variables 2033 // TODO(timloh): Also return non-inherited variables
2034 StyleInheritedVariables* variables = style.inheritedVariables(); 2034 StyleInheritedVariables* variables = style.inheritedVariables();
2035 if (variables) 2035 if (variables)
2036 return variables->getVariables(); 2036 return variables->getVariables();
2037 return nullptr; 2037 return nullptr;
2038 } 2038 }
2039 2039
2040 static bool widthOrHeightPropertyAppliesToObject(const LayoutObject& object) {
2041 // According to
2042 // http://www.w3.org/TR/CSS2/visudet.html#the-width-property and
2043 // http://www.w3.org/TR/CSS2/visudet.html#the-height-property, the "width" or
2044 // "height" property does not apply to non-atomic inline elements.
2045 if (!object.isAtomicInlineLevel() && object.isInline())
2046 return false;
2047
2048 // Non-root SVG should be treated as non-atomic inline no matter how we
2049 // implement it internally (e.g. LayoutSVGBlock is based on LayoutBlock).
2050 return !object.isSVGChild();
2051 }
2052
2040 const CSSValue* ComputedStyleCSSValueMapping::get( 2053 const CSSValue* ComputedStyleCSSValueMapping::get(
2041 CSSPropertyID propertyID, 2054 CSSPropertyID propertyID,
2042 const ComputedStyle& style, 2055 const ComputedStyle& style,
2043 const LayoutObject* layoutObject, 2056 const LayoutObject* layoutObject,
2044 Node* styledNode, 2057 Node* styledNode,
2045 bool allowVisitedStyle) { 2058 bool allowVisitedStyle) {
2046 const SVGComputedStyle& svgStyle = style.svgStyle(); 2059 const SVGComputedStyle& svgStyle = style.svgStyle();
2047 propertyID = CSSProperty::resolveDirectionAwareProperty( 2060 propertyID = CSSProperty::resolveDirectionAwareProperty(
2048 propertyID, style.direction(), style.getWritingMode()); 2061 propertyID, style.direction(), style.getWritingMode());
2049 switch (propertyID) { 2062 switch (propertyID) {
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2524 style.namedGridAreaColumnCount()); 2537 style.namedGridAreaColumnCount());
2525 case CSSPropertyGridColumnGap: 2538 case CSSPropertyGridColumnGap:
2526 return zoomAdjustedPixelValueForLength(style.gridColumnGap(), style); 2539 return zoomAdjustedPixelValueForLength(style.gridColumnGap(), style);
2527 case CSSPropertyGridRowGap: 2540 case CSSPropertyGridRowGap:
2528 return zoomAdjustedPixelValueForLength(style.gridRowGap(), style); 2541 return zoomAdjustedPixelValueForLength(style.gridRowGap(), style);
2529 case CSSPropertyGridGap: 2542 case CSSPropertyGridGap:
2530 return valuesForShorthandProperty(gridGapShorthand(), style, layoutObject, 2543 return valuesForShorthandProperty(gridGapShorthand(), style, layoutObject,
2531 styledNode, allowVisitedStyle); 2544 styledNode, allowVisitedStyle);
2532 2545
2533 case CSSPropertyHeight: 2546 case CSSPropertyHeight:
2534 if (layoutObject) { 2547 if (layoutObject && widthOrHeightPropertyAppliesToObject(*layoutObject))
2535 // According to
2536 // http://www.w3.org/TR/CSS2/visudet.html#the-height-property, the
2537 // "height" property does not apply for non-atomic inline elements.
2538 if (!layoutObject->isAtomicInlineLevel() && layoutObject->isInline())
2539 return CSSIdentifierValue::create(CSSValueAuto);
2540 return zoomAdjustedPixelValue(sizingBox(layoutObject).height(), style); 2548 return zoomAdjustedPixelValue(sizingBox(layoutObject).height(), style);
2541 }
2542 return zoomAdjustedPixelValueForLength(style.height(), style); 2549 return zoomAdjustedPixelValueForLength(style.height(), style);
2543 case CSSPropertyWebkitHighlight: 2550 case CSSPropertyWebkitHighlight:
2544 if (style.highlight() == nullAtom) 2551 if (style.highlight() == nullAtom)
2545 return CSSIdentifierValue::create(CSSValueNone); 2552 return CSSIdentifierValue::create(CSSValueNone);
2546 return CSSStringValue::create(style.highlight()); 2553 return CSSStringValue::create(style.highlight());
2547 case CSSPropertyHyphens: 2554 case CSSPropertyHyphens:
2548 return CSSIdentifierValue::create(style.getHyphens()); 2555 return CSSIdentifierValue::create(style.getHyphens());
2549 case CSSPropertyWebkitHyphenateCharacter: 2556 case CSSPropertyWebkitHyphenateCharacter:
2550 if (style.hyphenationString().isNull()) 2557 if (style.hyphenationString().isNull())
2551 return CSSIdentifierValue::create(CSSValueAuto); 2558 return CSSIdentifierValue::create(CSSValueAuto);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 NOTREACHED(); 2892 NOTREACHED();
2886 return nullptr; 2893 return nullptr;
2887 case CSSPropertyVisibility: 2894 case CSSPropertyVisibility:
2888 return CSSIdentifierValue::create(style.visibility()); 2895 return CSSIdentifierValue::create(style.visibility());
2889 case CSSPropertyWhiteSpace: 2896 case CSSPropertyWhiteSpace:
2890 return CSSIdentifierValue::create(style.whiteSpace()); 2897 return CSSIdentifierValue::create(style.whiteSpace());
2891 case CSSPropertyWidows: 2898 case CSSPropertyWidows:
2892 return CSSPrimitiveValue::create(style.widows(), 2899 return CSSPrimitiveValue::create(style.widows(),
2893 CSSPrimitiveValue::UnitType::Number); 2900 CSSPrimitiveValue::UnitType::Number);
2894 case CSSPropertyWidth: 2901 case CSSPropertyWidth:
2895 if (layoutObject) { 2902 if (layoutObject && widthOrHeightPropertyAppliesToObject(*layoutObject))
2896 // According to
2897 // http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
2898 // the "width" property does not apply for non-atomic inline elements.
2899 if (!layoutObject->isAtomicInlineLevel() && layoutObject->isInline())
2900 return CSSIdentifierValue::create(CSSValueAuto);
2901 return zoomAdjustedPixelValue(sizingBox(layoutObject).width(), style); 2903 return zoomAdjustedPixelValue(sizingBox(layoutObject).width(), style);
2902 }
2903 return zoomAdjustedPixelValueForLength(style.width(), style); 2904 return zoomAdjustedPixelValueForLength(style.width(), style);
2904 case CSSPropertyWillChange: 2905 case CSSPropertyWillChange:
2905 return valueForWillChange(style.willChangeProperties(), 2906 return valueForWillChange(style.willChangeProperties(),
2906 style.willChangeContents(), 2907 style.willChangeContents(),
2907 style.willChangeScrollPosition()); 2908 style.willChangeScrollPosition());
2908 case CSSPropertyWordBreak: 2909 case CSSPropertyWordBreak:
2909 return CSSIdentifierValue::create(style.wordBreak()); 2910 return CSSIdentifierValue::create(style.wordBreak());
2910 case CSSPropertyWordSpacing: 2911 case CSSPropertyWordSpacing:
2911 return zoomAdjustedPixelValue(style.wordSpacing(), style); 2912 return zoomAdjustedPixelValue(style.wordSpacing(), style);
2912 case CSSPropertyWordWrap: 2913 case CSSPropertyWordWrap:
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 case CSSPropertyAll: 3702 case CSSPropertyAll:
3702 return nullptr; 3703 return nullptr;
3703 default: 3704 default:
3704 break; 3705 break;
3705 } 3706 }
3706 NOTREACHED(); 3707 NOTREACHED();
3707 return nullptr; 3708 return nullptr;
3708 } 3709 }
3709 3710
3710 } // namespace blink 3711 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698