Changeset 20452 for S60/trunk/WebCore

Show
Ignore:
Timestamp:
03/23/07 13:53:05 (22 months ago)
Author:
brmorris
Message:

rathnasa, reviewed by zalan

DESC: [S60] ESMS-6YDMWP: TRUE - GSM - broswer crashes on certain web pages
Quick fix to validate null pointers
http://bugs.webkit.org/show_bug.cgi?id=13074

Location:
S60/trunk/WebCore
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • S60/trunk/WebCore/ChangeLog

    r20451 r20452  
     1rathnasa, reviewed by zalan 
     2 DESC: [S60] ESMS-6YDMWP: TRUE - GSM - broswer crashes on certain web pages 
     3 Quick fix to validate null pointers 
     4 http://bugs.webkit.org/show_bug.cgi?id=13074 
     5 
     6        WARNING: NO TEST CASES ADDED OR CHANGED 
     7         
     8        * khtml/xml/dom_elementimpl.cpp: 
     9        (AttrImpl::nodeName): 
     10        (ElementImpl::blur): 
     11        (ElementImpl::getAttributeNS): 
     12        (ElementImpl::tagName): 
     13        (ElementImpl::styleForRenderer): 
     14        (ElementImpl::createRenderer): 
     15        (ElementImpl::childAllowed): 
     16        (ElementImpl::dispatchAttrRemovalEvent): 
     17        (ElementImpl::dispatchAttrAdditionEvent): 
     18        (ElementImpl::updateId): 
     19        (XMLElementImpl::localName): 
     20        (XMLElementImpl::namespaceURI): 
     21        (XMLElementImpl::cloneNode): 
     22        (NamedAttrMapImpl::mapId): 
     23 
    1242007-03-23  bujtas  <zbujtas@gmail.com> 
    225 
  • S60/trunk/WebCore/khtml/xml/dom_elementimpl.cpp

    r16165 r20452  
    8282DOMString AttrImpl::nodeName() const 
    8383{ 
    84     return getDocument()->attrName(m_attribute->id()); 
     84    DocumentImpl *doc = getDocument(); 
     85    if (doc) { 
     86        return doc->attrName(m_attribute->id()); 
     87    } 
     88    else { 
     89        return DOMString(); 
     90    } 
    8591} 
    8692 
     
    287293    DocumentImpl* doc = getDocument(); 
    288294    if (doc && doc->focusNode() == this) 
    289     doc->setFocusNode(0); 
     295        doc->setFocusNode(0); 
    290296} 
    291297 
     
    293299                                                const DOMString &localName) const 
    294300{ 
    295     NodeImpl::Id id = getDocument()->attrId(namespaceURI.implementation(), 
     301    DocumentImpl *doc = getDocument(); 
     302    if (doc) { 
     303        NodeImpl::Id id = doc->attrId(namespaceURI.implementation(), 
    296304                                            localName.implementation(), true); 
    297     if (!id) return nullAtom; 
    298     return getAttribute(id); 
     305        if (!id) return nullAtom; 
     306        return getAttribute(id); 
     307    } 
     308    else { 
     309        return nullAtom; 
     310    } 
    299311} 
    300312 
     
    375387DOMString ElementImpl::tagName() const 
    376388{ 
    377     DOMString tn = getDocument()->tagName(id()); 
    378  
    379     if (m_prefix) 
    380         return DOMString(m_prefix) + ":" + tn; 
    381  
    382     return tn; 
     389    DocumentImpl *doc = getDocument(); 
     390    if (doc) { 
     391        DOMString tn = doc->tagName(id()); 
     392 
     393        if (m_prefix) 
     394            return DOMString(m_prefix) + ":" + tn; 
     395 
     396        return tn; 
     397    } 
     398    else { 
     399        return DOMString(); 
     400    } 
    383401} 
    384402 
     
    410428RenderStyle *ElementImpl::styleForRenderer(RenderObject *parentRenderer) 
    411429{ 
    412     return getDocument()->styleSelector()->styleForElement(this); 
     430    DocumentImpl *doc = getDocument(); 
     431    if (doc) { 
     432        return doc->styleSelector()->styleForElement(this); 
     433    } 
     434    else { 
     435        return 0; 
     436    } 
    413437} 
    414438 
    415439RenderObject *ElementImpl::createRenderer(RenderArena *arena, RenderStyle *style) 
    416440{ 
    417     if (getDocument()->documentElement() == this && style->display() == NONE) { 
     441    DocumentImpl *doc = getDocument(); 
     442    if (doc && doc->documentElement() == this && style->display() == NONE) { 
    418443        // Ignore display: none on root elements.  Force a display of block in that case. 
    419444        RenderBlock* result = new (arena) RenderBlock(this); 
     
    542567 
    543568    // For XML documents, we are non-validating and do not check against a DTD, even for HTML elements. 
    544     if (getDocument()->isHTMLDocument()) 
    545         return checkChild(id(), newChild->id(), !getDocument()->inCompatMode()); 
     569    DocumentImpl *doc = getDocument(); 
     570    if (doc && doc->isHTMLDocument()) { 
     571        return checkChild(id(), newChild->id(), !doc->inCompatMode()); 
     572    } 
    546573    return true; 
    547574} 
     
    565592void ElementImpl::dispatchAttrRemovalEvent(AttributeImpl *attr) 
    566593{ 
    567     if (!getDocument()->hasListenerType(DocumentImpl::DOMATTRMODIFIED_LISTENER)) 
    568     return; 
     594    DocumentImpl *doc = getDocument(); 
     595    if (doc && !doc->hasListenerType(DocumentImpl::DOMATTRMODIFIED_LISTENER)) { 
     596        return; 
     597    } 
    569598    //int exceptioncode = 0; 
    570599//     dispatchEvent(new MutationEventImpl(EventImpl::DOMATTRMODIFIED_EVENT,true,false,attr,attr->value(), 
     
    574603void ElementImpl::dispatchAttrAdditionEvent(AttributeImpl *attr) 
    575604{ 
    576     if (!getDocument()->hasListenerType(DocumentImpl::DOMATTRMODIFIED_LISTENER)) 
    577     return; 
     605    DocumentImpl *doc = getDocument(); 
     606    if (doc && !doc->hasListenerType(DocumentImpl::DOMATTRMODIFIED_LISTENER)) { 
     607        return; 
     608    } 
    578609   // int exceptioncode = 0; 
    579610//     dispatchEvent(new MutationEventImpl(EventImpl::DOMATTRMODIFIED_EVENT,true,false,attr,attr->value(), 
     
    642673 
    643674    DocumentImpl* doc = getDocument(); 
    644     if (!oldId.isEmpty()) 
    645     doc->removeElementById(oldId, this); 
    646     if (!newId.isEmpty()) 
    647     doc->addElementById(newId, this); 
     675    if (!oldId.isEmpty() && doc) { 
     676        doc->removeElementById(oldId, this); 
     677    } 
     678    if (!newId.isEmpty() && doc) { 
     679        doc->addElementById(newId, this); 
     680    } 
    648681} 
    649682 
     
    737770DOMString XMLElementImpl::localName() const 
    738771{ 
    739     return getDocument()->tagName(m_id); 
     772    DocumentImpl *doc = getDocument(); 
     773    if (doc) { 
     774        return doc->tagName(m_id); 
     775    } 
     776    else { 
     777        return DOMString(); 
     778    } 
    740779} 
    741780 
    742781DOMString XMLElementImpl::namespaceURI() const 
    743782{ 
    744     return getDocument()->namespaceURI(m_id); 
     783    DocumentImpl *doc = getDocument(); 
     784    if (doc) { 
     785        return doc->namespaceURI(m_id); 
     786    } 
     787    else { 
     788        return DOMString(); 
     789    } 
    745790} 
    746791 
     
    749794    // ### we loose namespace here FIXME 
    750795    // should pass id around 
    751     XMLElementImpl *clone = new XMLElementImpl(docPtr(), getDocument()->tagName(m_id).implementation()); 
     796    DocumentImpl *doc = getDocument(); 
     797    if (!doc) { 
     798        return 0; 
     799        } 
     800 
     801    XMLElementImpl *clone = new XMLElementImpl(docPtr(), doc->tagName(m_id).implementation()); 
    752802    clone->m_id = m_id; 
    753803 
     
    905955    assert(element); 
    906956    if (!element) return 0; 
    907     return element->getDocument()->attrId(namespaceURI.implementation(), 
     957    DocumentImpl *doc = element->getDocument(); 
     958    if (!doc) return 0; 
     959    return doc->attrId(namespaceURI.implementation(), 
    908960                                            localName.implementation(), readonly); 
    909961}