Bug 143000 - Empty or all-space inline element with spaces around it, and has white-space:pre, word-spacing on its parent, causes wrong rendered width
Summary: Empty or all-space inline element with spaces around it, and has white-space:...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-24 01:20 PDT by Duan Yao
Modified: 2015-03-27 09:38 PDT (History)
3 users (show)

See Also:


Attachments
test cases (937 bytes, text/html)
2015-03-24 01:20 PDT, Duan Yao
no flags Details
Test case2 (891 bytes, text/html)
2015-03-27 09:38 PDT, zalan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duan Yao 2015-03-24 01:20:15 PDT
Created attachment 249321 [details]
test cases

In webkit, if an empty or all-space inline element has space(s) before or after it, and has white-space:pre, word-spacing on its parent, the width of the line will be wrong.

In following lines, widths between two "M"s should be the same. But in Webkit, widths in the third and following lines are narrower than the first 2 lines:

<div style="white-space:pre; word-spacing:1em;">
  <div>M    M (4 spaces in text)</div>
  <div>M<span style="background-color:red;">    </span>M (4 space in a inline)</div>
  <div>M  <span style="background-color:red;"></span>  M (2 space before, 2 space after, 0 space in the inline)</div>
  <div>M <span style="background-color:red;">  </span> M (1 space before and after, 2 space in the inline)</div>
  <div>M<span style="background-color:red;">  </span>  M (0 space before, 2 space after, 2 space in the inline)</div>
  <div>M  <span style="background-color:red;">  </span>M (2 space before, 0 space after, 2 space in the inline)</div>
</div>

You can also reproduce this issue by opening the attachment.
Comment 1 zalan 2015-03-27 09:38:10 PDT
Created attachment 249574 [details]
Test case2