Bug 71747

Summary: DateMath.cpp should not depend on JavaScriptCore
Product: WebKit Reporter: Mark Rowe (bdash) <mrowe>
Component: Web Template FrameworkAssignee: Adam Barth <abarth>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ggaren, mjs, mrowe, oliver, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Mark Rowe (bdash) 2011-11-07 16:25:31 PST
While working on making WTF build outside of JavaScriptCore I noticed that wtf/DateMath.cpp includes several headers from JavaScriptCore, and makes use of some JavaScriptCore types such as ExecState, JSGlobalData and DSTOffsetCache. This layering violation needs to be addressed before WTF can be correctly split out of JavaScriptCore.
Comment 1 Mark Rowe (bdash) 2011-11-07 16:44:09 PST
It looks like it may be possible to simply move the USE(JSC) parts of DateMath.h / DateMath.cpp in to a more appropriate file inside JavaScriptCore itself.
Comment 2 Adam Barth 2011-11-14 12:50:33 PST
Created attachment 115014 [details]
Patch
Comment 3 WebKit Review Bot 2011-11-14 12:53:41 PST
Attachment 115014 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/CMakeLists.txt', u'S..." exit_code: 1

Source/JavaScriptCore/runtime/JSDateMath.cpp:76:  Alphabetical sorting problem.  [build/include_order] [4]
Source/JavaScriptCore/runtime/JSDateMath.cpp:147:  More than one command on the same line in if  [whitespace/parens] [4]
Source/JavaScriptCore/runtime/JSDateMath.cpp:154:  An else statement can be removed when the prior "if" concludes with a return, break, continue or goto statement.  [readability/control_flow] [4]
Source/JavaScriptCore/runtime/JSDateMath.cpp:244:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 4 in 17 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Darin Adler 2011-11-14 15:12:31 PST
Comment on attachment 115014 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=115014&action=review

>> Source/JavaScriptCore/runtime/JSDateMath.cpp:76
>>  #include "ASCIICType.h"
> 
> Alphabetical sorting problem.  [build/include_order] [4]

It’s true, ASCIICType.h should come before Assertions.h.

> Source/JavaScriptCore/runtime/JSDateMath.cpp:82
>  #include "Assertions.h"
>  #include "ASCIICType.h"
>  #include "CurrentTime.h"
> -#if USE(JSC)
>  #include "JSObject.h"
> -#endif
>  #include "MathExtras.h"
> -#if USE(JSC)
>  #include "ScopeChain.h"
> -#endif
>  #include "StdLibExtras.h"
>  #include "StringExtras.h"

Is there a chance we could cut these includes down a bit more? Guess someone can look into that later.

> Source/JavaScriptCore/wtf/DateMath.h:108
> +using WTF::isLeapYear;
>  using WTF::dateToDaysFrom1970;

Entire "using" list should be sorted alphabetically.
Comment 5 WebKit Review Bot 2011-11-14 16:05:10 PST
Comment on attachment 115014 [details]
Patch

Clearing flags on attachment: 115014

Committed r100205: <http://trac.webkit.org/changeset/100205>
Comment 6 WebKit Review Bot 2011-11-14 16:05:16 PST
All reviewed patches have been landed.  Closing bug.