WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
102975
Node::createRenderer should never return null
https://bugs.webkit.org/show_bug.cgi?id=102975
Summary
Node::createRenderer should never return null
Elliott Sprehn
Reported
2012-11-21 13:18:21 PST
Node::createRenderer should never return null
Attachments
Patch
(2.56 KB, patch)
2012-11-21 13:22 PST
,
Elliott Sprehn
no flags
Details
Formatted Diff
Diff
Patch
(2.58 KB, patch)
2012-11-21 14:01 PST
,
Elliott Sprehn
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Elliott Sprehn
Comment 1
2012-11-21 13:22:24 PST
Created
attachment 175507
[details]
Patch
Ojan Vafai
Comment 2
2012-11-21 13:39:49 PST
Comment on
attachment 175507
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175507&action=review
> Source/WebCore/dom/NodeRenderingContext.cpp:234 > + ASSERT(newRenderer);
There are some codepaths that ASSERT_NOT_REACHED and then return null. If this isn't actually a performance improvement, it might be better to be a bit more defensive here. How about: if (!newRenderer) { ASSERT_NOT_REACHED(); return; }
Elliott Sprehn
Comment 3
2012-11-21 13:47:30 PST
(In reply to
comment #2
)
> (From update of
attachment 175507
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=175507&action=review
> > > Source/WebCore/dom/NodeRenderingContext.cpp:234 > > + ASSERT(newRenderer); > > There are some codepaths that ASSERT_NOT_REACHED and then return null. If this isn't actually a performance improvement, it might be better to be a bit more defensive here. How about: > if (!newRenderer) { > ASSERT_NOT_REACHED(); > return; > }
The return value is required for the code to compile, we could return anything there. If you return true from rendererIsNeeded and then return 0 from createRenderer the program should crash in a release build. I don't think it makes sense to protect against this case. (Similarly returning null from styleForRenderer() is a fatal error and we assert about it right above this, but we don't protect you from developer error of doing that)
Elliott Sprehn
Comment 4
2012-11-21 13:50:27 PST
(In reply to
comment #3
)
> ...
Btw, I don't feel very strongly about this, I can add the protection if you want. :)
Elliott Sprehn
Comment 5
2012-11-21 14:01:38 PST
Created
attachment 175517
[details]
Patch Add return after assert
Ojan Vafai
Comment 6
2012-11-21 14:03:34 PST
Comment on
attachment 175507
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175507&action=review
>>> Source/WebCore/dom/NodeRenderingContext.cpp:234 >>> + ASSERT(newRenderer); >> >> There are some codepaths that ASSERT_NOT_REACHED and then return null. If this isn't actually a performance improvement, it might be better to be a bit more defensive here. How about: >> if (!newRenderer) { >> ASSERT_NOT_REACHED(); >> return; >> } > > The return value is required for the code to compile, we could return anything there. If you return true from rendererIsNeeded and then return 0 from createRenderer the program should crash in a release build. I don't think it makes sense to protect against this case. > > (Similarly returning null from styleForRenderer() is a fatal error and we assert about it right above this, but we don't protect you from developer error of doing that)
Yeah. I'm on the fence.
WebKit Review Bot
Comment 7
2012-11-21 14:36:43 PST
Comment on
attachment 175517
[details]
Patch Clearing flags on attachment: 175517 Committed
r135437
: <
http://trac.webkit.org/changeset/135437
>
WebKit Review Bot
Comment 8
2012-11-21 14:36:47 PST
All reviewed patches have been landed. Closing bug.
WebKit Review Bot
Comment 9
2012-11-21 15:46:37 PST
Re-opened since this is blocked by
bug 102986
Elliott Sprehn
Comment 10
2012-11-23 13:02:07 PST
So it turns out there's a bug my CL uncovered: Node::rendererIsNeeded has: (document()->documentElement() == this) || (context.style()->display() != NONE); Element::createRenderer has a special case for this: // Ignore display: none on root elements. Force a display of block in that case. if (document()->documentElement() == this && style->display() == NONE) { RenderBlock* result = new (arena) RenderBlock(this); ... } but then in HTMLElement::createRenderer we don't call super: return RenderObject::createObject(this, style); so in an HTML document display: none on the root element is NOT ignored! This was introduced way back in
https://trac.webkit.org/changeset/21405
when adding a special case for <wbr> elements in HTMLElement::createRenderer.
Elliott Sprehn
Comment 11
2013-01-15 11:34:59 PST
(In reply to
comment #10
)
> ... > so in an HTML document display: none on the root element is NOT ignored! >
I fixed the bug with the documentElement in
r136331
, but having dug deeper I think it'd be a time consuming task to make createRenderer never return null as in this original bug, and I'm not sure it has a lot of benefits since we'd still need the if statement check in NodeRenderingContext.
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