WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
113473
Rename toScriptElement to differentiate it from other to* functions and better describe its function
https://bugs.webkit.org/show_bug.cgi?id=113473
Summary
Rename toScriptElement to differentiate it from other to* functions and bette...
Philip Rogers
Reported
2013-03-27 20:28:03 PDT
ScriptElement::toScriptElement is different from other to* functions (e.g., Element::toElement, etc) in that it returns 0 if the cast is unsuccessful. These functions have security implications and need to be clear and consistent.
http://trac.webkit.org/browser/trunk/Source/WebCore/dom/ScriptElement.cpp#L417
We should rename toScriptElement to toScriptElementIfPossible (or similar) both to clarify the function behavior and to differentiate it from other to* functions.
Attachments
Patch that just handles the rename
(10.93 KB, patch)
2013-03-27 21:37 PDT
,
Philip Rogers
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Geoffrey Garen
Comment 1
2013-03-27 21:02:48 PDT
In JSC, we use jsCast<T> and jsDynamicCast<T>, to mimic static_cast<T> and dynamic_cast<T>. Ryosuke and I were discussing using domCast<T> or coreCast<T>, along with domDynamicCast<T> or coreDynamicCast<T> for the DOM. This would allow for specialized implementations while keeping the interface consistent at all call sites.
Philip Rogers
Comment 2
2013-03-27 21:27:38 PDT
(In reply to
comment #1
)
> In JSC, we use jsCast<T> and jsDynamicCast<T>, to mimic static_cast<T> and dynamic_cast<T>. > > Ryosuke and I were discussing using domCast<T> or coreCast<T>, along with domDynamicCast<T> or coreDynamicCast<T> for the DOM. This would allow for specialized implementations while keeping the interface consistent at all call sites.
I think Abhishek is working on something similar to domCast<T> to help reduce the security issues involved in our many static_casts. My understanding is that we will only return 0 for null casts, so the toScriptElement function is really an odd one out. I was not aware of jsDynamicCast before, but I like it. Abhishek, is there a bug that's tracking this work?
Philip Rogers
Comment 3
2013-03-27 21:37:51 PDT
Created
attachment 195478
[details]
Patch that just handles the rename
WebKit Review Bot
Comment 4
2013-03-27 22:02:57 PDT
Comment on
attachment 195478
[details]
Patch that just handles the rename Clearing flags on attachment: 195478 Committed
r147057
: <
http://trac.webkit.org/changeset/147057
>
WebKit Review Bot
Comment 5
2013-03-27 22:03:02 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug