RESOLVED FIXED Bug 131652
Remove unnecessary null checking in NavigatorContentUtils
https://bugs.webkit.org/show_bug.cgi?id=131652
Summary Remove unnecessary null checking in NavigatorContentUtils
Gyuyoung Kim
Reported 2014-04-14 17:38:38 PDT
According to my investigation, it looks there is no change that document can be null.So, it seems to me that we don't need to check if document is null when frame is existed. In Frame.cpp, m_doc is set in Frame::setDocument(). I think m_doc can't be null. Even when I try to find same null check, I couldn't find it in WebKit. void Frame::setDocument(PassRefPtr<Document> newDocument) { ASSERT(!newDocument || newDocument->frame() == this); if (m_doc && m_doc->hasLivingRenderTree() && !m_doc->inPageCache()) m_doc->prepareForDestruction(); m_doc = newDocument.get(); ASSERT(!m_doc || m_doc->domWindow()); ASSERT(!m_doc || m_doc->domWindow()->frame() == this); // Don't use m_doc because it can be overwritten and we want to guarantee // that the document is not destroyed during this function call. if (newDocument) newDocument->didBecomeCurrentDocumentInFrame(); }
Attachments
Patch (2.69 KB, patch)
2014-04-14 17:39 PDT, Gyuyoung Kim
no flags
Gyuyoung Kim
Comment 1 2014-04-14 17:39:44 PDT
Gyuyoung Kim
Comment 2 2014-04-14 17:40:34 PDT
CC'ing Darin, Darin, if frame()->document() can be null, please let me know.
Darin Adler
Comment 3 2014-04-15 07:37:15 PDT
Comment on attachment 229330 [details] Patch Frame::document is mostly non-null. If it was truly always non-null then we (Kling) would have changed it to a Document& instead of a Document* and it would be clear it doesn’t need null checks. I think the only times it can be null are very early in the frame lifetime, so this patch is OK. But really our goal for the project is to use references for things that can’t be null so that such things aren’t a matter of style, instead just making it impossible to include extra null checks.
WebKit Commit Bot
Comment 4 2014-04-15 09:19:35 PDT
Comment on attachment 229330 [details] Patch Clearing flags on attachment: 229330 Committed r167308: <http://trac.webkit.org/changeset/167308>
WebKit Commit Bot
Comment 5 2014-04-15 09:19:41 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.