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

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: Reduce behavior change 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
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/css/getComputedStyle-svg-text-width-height.html ('k') | no next file » | 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) 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 LayoutBlockFlow).
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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
2535 // According to 2548 if (!widthOrHeightPropertyAppliesToObject(*layoutObject))
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); 2549 return CSSIdentifierValue::create(CSSValueAuto);
2540 return zoomAdjustedPixelValue(sizingBox(layoutObject).height(), style); 2550 return zoomAdjustedPixelValue(sizingBox(layoutObject).height(), style);
2541 } 2551 }
2542 return zoomAdjustedPixelValueForLength(style.height(), style); 2552 return zoomAdjustedPixelValueForLength(style.height(), style);
2543 case CSSPropertyWebkitHighlight: 2553 case CSSPropertyWebkitHighlight:
2544 if (style.highlight() == nullAtom) 2554 if (style.highlight() == nullAtom)
2545 return CSSIdentifierValue::create(CSSValueNone); 2555 return CSSIdentifierValue::create(CSSValueNone);
2546 return CSSStringValue::create(style.highlight()); 2556 return CSSStringValue::create(style.highlight());
2547 case CSSPropertyHyphens: 2557 case CSSPropertyHyphens:
2548 return CSSIdentifierValue::create(style.getHyphens()); 2558 return CSSIdentifierValue::create(style.getHyphens());
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 return nullptr; 2896 return nullptr;
2887 case CSSPropertyVisibility: 2897 case CSSPropertyVisibility:
2888 return CSSIdentifierValue::create(style.visibility()); 2898 return CSSIdentifierValue::create(style.visibility());
2889 case CSSPropertyWhiteSpace: 2899 case CSSPropertyWhiteSpace:
2890 return CSSIdentifierValue::create(style.whiteSpace()); 2900 return CSSIdentifierValue::create(style.whiteSpace());
2891 case CSSPropertyWidows: 2901 case CSSPropertyWidows:
2892 return CSSPrimitiveValue::create(style.widows(), 2902 return CSSPrimitiveValue::create(style.widows(),
2893 CSSPrimitiveValue::UnitType::Number); 2903 CSSPrimitiveValue::UnitType::Number);
2894 case CSSPropertyWidth: 2904 case CSSPropertyWidth:
2895 if (layoutObject) { 2905 if (layoutObject) {
2896 // According to 2906 if (!widthOrHeightPropertyAppliesToObject(*layoutObject))
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); 2907 return CSSIdentifierValue::create(CSSValueAuto);
2901 return zoomAdjustedPixelValue(sizingBox(layoutObject).width(), style); 2908 return zoomAdjustedPixelValue(sizingBox(layoutObject).width(), style);
2902 } 2909 }
2903 return zoomAdjustedPixelValueForLength(style.width(), style); 2910 return zoomAdjustedPixelValueForLength(style.width(), style);
2904 case CSSPropertyWillChange: 2911 case CSSPropertyWillChange:
2905 return valueForWillChange(style.willChangeProperties(), 2912 return valueForWillChange(style.willChangeProperties(),
2906 style.willChangeContents(), 2913 style.willChangeContents(),
2907 style.willChangeScrollPosition()); 2914 style.willChangeScrollPosition());
2908 case CSSPropertyWordBreak: 2915 case CSSPropertyWordBreak:
2909 return CSSIdentifierValue::create(style.wordBreak()); 2916 return CSSIdentifierValue::create(style.wordBreak());
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 case CSSPropertyAll: 3708 case CSSPropertyAll:
3702 return nullptr; 3709 return nullptr;
3703 default: 3710 default:
3704 break; 3711 break;
3705 } 3712 }
3706 NOTREACHED(); 3713 NOTREACHED();
3707 return nullptr; 3714 return nullptr;
3708 } 3715 }
3709 3716
3710 } // namespace blink 3717 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/css/getComputedStyle-svg-text-width-height.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698