Bug 12687 - REGRESSION: Google Calendar cell highlight misplaced
Summary: REGRESSION: Google Calendar cell highlight misplaced
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Nobody
URL: http://www.google.com/calendar/render...
Keywords: GoogleBug, NeedsReduction, Regression
Depends on:
Blocks:
 
Reported: 2007-02-07 16:52 PST by Antti Koivisto
Modified: 2007-02-11 16:31 PST (History)
3 users (show)

See Also:


Attachments
test case showing different offset behavior compared to ie/ff (449 bytes, text/html)
2007-02-09 09:36 PST, Antti Koivisto
no flags Details
proposed patch (1.72 KB, patch)
2007-02-09 13:26 PST, Antti Koivisto
koivisto: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2007-02-07 16:52:13 PST
1. login to Google Calendar
2. click somewhere on main calendar area to select a time

The grey transparent highlight is drawn shifted several pixels right/down from cell area where it should be. Works fine in shipping Safari.
Comment 1 mitz 2007-02-07 22:27:37 PST
Could be a result of changing offsetTop/offsetLeft behavior to match Firefox recently.
Comment 2 mitz 2007-02-07 23:49:49 PST
(In reply to comment #1)
> Could be a result of changing offsetTop/offsetLeft behavior to match Firefox
> recently.
> 

Wrong. Based on nightly builds, the regression happened sometime between 2005-12-01 and 2005-12-16.
Comment 3 mitz 2007-02-08 00:02:16 PST
Perhaps this: <http://trac.webkit.org/projects/webkit/changeset/11484>.
Comment 4 Antti Koivisto 2007-02-08 01:36:25 PST
No, wasn't that one. Something else...(In reply to comment #3)
> Perhaps this: <http://trac.webkit.org/projects/webkit/changeset/11484>.
> 

No, doesn't seem to be that one. 
Comment 5 mitz 2007-02-08 04:20:24 PST
WebKit-CVS-2005-12-07 10-27-14 GMT.dmg works
WebKit-CVS-2005-12-08 23-04-18 GMT.dmg broken
Comment 6 Antti Koivisto 2007-02-09 08:18:28 PST
If you revert both Bug 11109 and http://trac.webkit.org/projects/webkit/changeset/11484 then you get correct positioning. This is because Calendar works around offsetLeft/offsetTop/offsetParent bug in tiger webkit. Specifically tiger webkit would not include body margins to offsets of relative positioned elements.

This code in function qC(a, b, c, d) in the obfuscated calendar script

      if (T)
        i.x += 3;
      else
        if ($)
          {
            i.x += fb() ? 6 : 8;
            i.y += 6;
          }

adds some magic offsets to fix positioning issues. For safari $=1, for MSIE T=1.

Safari offsetLeft behavior is still not exactly the same as Firefox. For some reason, like MSIE, ToT Safari needs that i.x += 3; to get pixel-correct horizontal position. Is the idea here to try to replicate MSIE or Firefox behavior for offset functions? If target is MSIE then I don't think there is any bug here.
Comment 7 mitz 2007-02-09 08:27:03 PST
(In reply to comment #6)
> Safari offsetLeft behavior is still not exactly the same as Firefox.

> Is the idea here to try to replicate MSIE or Firefox
> behavior for offset functions?

My intention with the patch for bug 11109 was to replicate Firefox (WinIE behavior is described in one of my comments on that bug). Do you know what the remaining discrepancy is?
Comment 8 Antti Koivisto 2007-02-09 09:36:19 PST
Created attachment 13086 [details]
test case showing different offset behavior compared to ie/ff

Both FF and IE agree that offsetLeft/Top should be measured from inner border edge of the offsetParent. WebKit measures it from outer border edge of the parent. 

In this case first offsetLeft is zero in FF/IE and non-zero in Safari
Comment 9 Antti Koivisto 2007-02-09 11:02:38 PST
Here is a nice test suite for offset properties by Anne van Kesteren: 

http://dump.testsuite.org/2006/dom/style/offset/

We get quite a few wrong and more importantly we get quite a few different from FF. Especially offsetParent seems to be often wrong.

Comment 10 David Kilzer (:ddkilzer) 2007-02-09 11:19:24 PST
Per Comment #6, it sounds like both Safari and Google Calendar will need fixes to resolve this bug.

Comment 11 David Kilzer (:ddkilzer) 2007-02-09 11:25:12 PST
(In reply to comment #9)
> Here is a nice test suite for offset properties by Anne van Kesteren: 
> 
> http://dump.testsuite.org/2006/dom/style/offset/
> 
> We get quite a few wrong and more importantly we get quite a few different from
> FF. Especially offsetParent seems to be often wrong.

Filed Bug 12713 to import this test suite.
Comment 12 Antti Koivisto 2007-02-09 13:26:37 PST
Created attachment 13091 [details]
proposed patch

Ok, so here is proposed patch. It does three things
1) calculate offsets from padding edge (inner edge of border), not from border edge
2) revert this 

!(!style()->htmlHacks() && skipTables ? curr->isRoot() : curr->isBody())

in http://trac.webkit.org/projects/webkit/changeset/11484 back to this

!curr->isBody()

which seems to match FF behavior in both strict and compat modes. Why was this change done? Hard to say since there was no test case nor explanation.

3) Check for tableness from dom tree instead of rendering tree. That's just what other browser seem to do based on Anne's tests.

These changes make all Anne's tests pass except for 3,8,12,29,43,45,49,50. In all those cases we match FF behavior (except 12, where we fail a bit less). Failures are of course all debatable since there is no authorative spec about offset behaviors. No layout test failures either.

(some of Anne's test cases may randomly produce wrong offsetTop results when reloaded. that is some layout timing problem not directly related to offset calculations)

None of this actually fixes Google Calendar, it needs ToT fixes in the other end. Best we can do is to make this stuff consistent.
Comment 13 Bob Austin 2007-02-09 14:12:33 PST
This problem has been written to the Google bug tracking system.
631734
Comment 14 Maciej Stachowiak 2007-02-10 16:21:36 PST
Comment on attachment 13091 [details]
proposed patch

Fix looks good (Mitz agrees) but needs ChangeLog entry and test case. Feel free to convert this to an r+ if you add a ChangeLog and land the attached test case w/ this.

Also, this won't really make the bug on Google go away, but being more like FF will allow us to turn this into strictly an evangelism bug.
Comment 15 Maciej Stachowiak 2007-02-10 16:27:40 PST
Comment on attachment 13091 [details]
proposed patch

r- per above comments
Comment 16 Antti Koivisto 2007-02-11 16:29:17 PST
Commited as r19567 with attached layout test based on comment  #14 above.
Comment 17 Antti Koivisto 2007-02-11 16:31:29 PST
Comment on attachment 13091 [details]
proposed patch

see comment 14