New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 629236 link

Starred by 8 users

Issue metadata

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



Sign in to add a comment

failed import interfere with getBoundingClientRect

Project Member Reported by valdrin@google.com, Jul 18 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Steps to reproduce the problem:
1. Have a div in the document
2. Synchronously import of a non-existing resource with <link rel="import">
3. Compute the div's getBoundingClientRect()

https://jsbin.com/necapa/2/edit?html,console,output

<div>hello</div>
<script>
  var link = document.createElement('link');
  link.rel = 'import';
  link.href = 'bad/import.html';
  document.head.appendChild(link);    
  var div = document.querySelector('div');
  console.log(div.getBoundingClientRect());
</script>

What is the expected behavior?
The rect should be a non-zero rect.

What went wrong?
The rect is a zero-rect.

Did this work before? N/A 

Chrome version: 51.0.2704.103  Channel: n/a
OS Version: OS X 10.11.5
Flash Version: Shockwave Flash 22.0 r0

Works correctly in Safari & Firefox
 
Components: Blink
Components: -Blink Blink>Layout
Project Member

Comment 3 by sheriffbot@chromium.org, Jul 19 2016

Labels: Hotlist-Google

Comment 4 by e...@chromium.org, Jul 19 2016

Cc: atotic@chromium.org glebl@chromium.org dgro...@chromium.org
Components: Blink>Loader
Labels: -Pri-2 -OS-Mac Hotlist-GoodFirstBug OS-All Pri-3
Status: Available (was: Unconfirmed)
Looks like it's waiting for the import to fail before reporting the correct size even though content has been rendered. This is clearly incorrect.
Hi Guys,

I just looked at this bug hoping to fix but I noticed something a bit strange.
I can replicated problem using the the above mentioned snippet. But when I add a log before and after trying to load  the link everything looks fine (I get a non zero rectangle)

<div>hello</div>
<script>
  var link = document.createElement('link');
  link.rel = 'import';
  link.href = 'bad/import.html';

  var div = document.querySelector('div');
  console.log(div.getBoundingClientRect());
  document.head.appendChild(link);
  var div2 = document.querySelector('div');
  console.log(div2.getBoundingClientRect());   
</script>

test.html:8 ClientRect {top: 8, right: 1912, bottom: 26, left: 8, width: 1904…}bottom: 26height: 18left: 8right: 1912top: 8width: 1904__proto__: ClientRect
test.html:11 ClientRect {top: 8, right: 1912, bottom: 26, left: 8, width: 1904…}
test.html:9 GET file:///C:/Users/ramzi.rhahlia/Desktop/bad/import.html net::ERR_FILE_NOT_FOUND(anonymous function) @ test.html:9

This made me a bit confused. Do you think of any explanation to this from the top of you head.
Do you have an idea where about in the code to look?

Sorry if may question is so simple I am still new to this and still finding my way.
Hey guys,

I also looked into this issue recently:)

Reason:
'import' will block rendering process when it is not loaded yet.
In this case, 'import' is created dynamicly by js, so script won't be blocked by 'import'.
After append 'import' into document, the rest of js will be excuted.
When come to 'div.getBoundingClientRect()', we need 'Document::updateStyleAndLayoutIgnorePendingStylesheets()'. 
We plan to calculate style, build layout tree, and layout.
But at the calculate-style point, it'll be blocked by 'Document::isRenderingReady()' at 'StyleResolver::styleForElement'. More specific, it'll block by 'Document::haveImportsLoaded()'.
So 's_styleNotYetAvailable' will be used as the tyle of document, and 'div.getBoundingClientRect()' will get an empty rect.

Approach:
I think if IgnorePendingStylesheets is true, ImportsLoader need to be ignored too.

codereview:
https://codereview.chromium.org/2729493002/

Guys, if I misunderstood about anything, just point it out. Thanks:)
Components: -Blink>Layout -Blink>Loader Blink>CSS

Comment 9 by shans@chromium.org, Mar 6 2017

Labels: Update-Quartlerly

Comment 10 by suzyh@chromium.org, Mar 27 2017

Labels: -Update-Quartlerly Update-Quarterly

Comment 11 by r...@opera.com, Jun 1 2017

Cc: pmeenan@chromium.org kavvaru@chromium.org jmukthavaram@chromium.org sorvell@chromium.org r...@opera.com
Issue 719078 has been merged into this issue.

Comment 12 by r...@opera.com, Jun 1 2017

Status: Fixed (was: Available)

Sign in to add a comment