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(); }
Created attachment 229330 [details] Patch
CC'ing Darin, Darin, if frame()->document() can be null, please let me know.
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.
Comment on attachment 229330 [details] Patch Clearing flags on attachment: 229330 Committed r167308: <http://trac.webkit.org/changeset/167308>
All reviewed patches have been landed. Closing bug.