Bug 42098 - The WebCore::Document::head() method should be const.
Summary: The WebCore::Document::head() method should be const.
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-12 11:50 PDT by Jay Civelli
Modified: 2010-07-12 16:39 PDT (History)
0 users

See Also:


Attachments
Initial patch (1.50 KB, patch)
2010-07-12 11:52 PDT, Jay Civelli
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jay Civelli 2010-07-12 11:50:53 PDT
The WebCore::Document::head() method is not const, it should.
Comment 1 Jay Civelli 2010-07-12 11:52:29 PDT
Created attachment 61251 [details]
Initial patch
Comment 2 Darin Adler 2010-07-12 12:38:23 PDT
Comment on attachment 61251 [details]
Initial patch

Why should this be const? You have a const pointer to a document and you get a non-const pointer to one of the elements of that document? I think we should not use const so much on classes like Document* that are part of a tree. It doesn't make sense to have a const pointer to something but then call firstChild()->parent() and get back a non-const pointer to the same thing. I suggest going the opposite direction and phasing out use of const Document*.
Comment 3 Jay Civelli 2010-07-12 13:36:56 PDT
I came up across this using the Chromium WebKit API (trying to pass a WebDocument as a const& and then call head() on it which ends up calling Document::head()) and thought the const had somehow been forgotten since body() was const.
You are right, it does not make sense if the constness can be circumvented.
Closing the bug.