New issue
Advanced search Search tips

Issue 708687 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

getComputedStyle(svgText).width|height returns internal used value of 'width'/'height'

Project Member Reported by wangxianzhu@chromium.org, Apr 5 2017

Issue description

CSS properties 'width' and 'height' don't apply to svg <text>, so according to the spec (https://drafts.csswg.org/cssom/#resolved-value), we should return the computed values of the properties for getComputedStyle(svgText).width|height. For now Chrome returns the internal used value in 'px' unit.

http://jsbin.com/sekeli

<svg>
  <text id="text1">Text</text>
  <text id="text2" style="width: 200px; height: 30%">Text</text>
</svg>

Chrome (incorrect):
text1.width = "28.2031px"
text1.height = "0px"
text2.width = "28.2031px"
text2.height = "0px"
(0px values are because of  bug 708101 .)

FireFox (correct):
text1.width = "auto"
text1.height = "auto"
text2.width = "200px"
text2.height = "30%"

IE11 (incorrect):
text1.width = "0px"
text1.height = "0px"
text2.width = "0px"
text2.height = "0px"

 
Labels: PaintTeamTriaged-20170405 BugSource-Team
Description: Show this description
Owner: wangxianzhu@chromium.org
Status: Assigned (was: Available)
Labels: Update-Quarterly
Project Member

Comment 5 by bugdroid1@chromium.org, Apr 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e60f30d448ad169ebc5c7f1cf45e83da2af33959

commit e60f30d448ad169ebc5c7f1cf45e83da2af33959
Author: wangxianzhu <wangxianzhu@chromium.org>
Date: Thu Apr 06 16:46:42 2017

Return 'auto' for width/height for non-root SVG

According to the specs:
- https://www.w3.org/TR/CSS2/visudet.html#the-height-property:
  The 'height' property doesn't apply to non-atomic inline elements.
- https://drafts.csswg.org/cssom/#resolved-value:
  getComputeStyle() returns resolved values. For a property that
  doesn't apply, the resolved value is the computed value.

Actually because of  crbug.com/708888  'auto' is not the computed value
when width/height is specified, but this keeps the current behavior.

I didn't find spec about whether a non-root SVG is inline or not,
but SVG's display's initial value is 'inline', and we treat most of
the SVG elements always as inline. We treat SVG text as block internally
just because we implement SVG text based on LayoutBlockFlow, which is
an implementation detail and should not affect cssom.

BUG= 708687 

Review-Url: https://codereview.chromium.org/2798903005
Cr-Commit-Position: refs/heads/master@{#462508}

[add] https://crrev.com/e60f30d448ad169ebc5c7f1cf45e83da2af33959/third_party/WebKit/LayoutTests/svg/css/getComputedStyle-svg-text-width-height.html
[modify] https://crrev.com/e60f30d448ad169ebc5c7f1cf45e83da2af33959/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Status: Fixed (was: Assigned)

Sign in to add a comment