Commit 85a705e0 authored by ggaren's avatar ggaren

Reviewed by Beth Dakin.

        More clean-up while fixing <rdar://problem/5112273> REGRESSION(TOT): 
        Reproducible crash loading an old version of amazon.com as a web archive
        
        Layout tests pass.
        
        Removed more superfluous document NULL checks. (Node::document() never 
        returns NULL, and it asserts as much.)
        
        Merged some duplicate editing code into a static inline function.
        
        * page/mac/WebCoreFrameBridge.mm:
        (updateRenderingForBindings): Removed superfluous static_cast.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20725 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6a5401aa
2007-04-05 Geoffrey Garen <ggaren@apple.com>
Reviewed by Beth Dakin.
More clean-up while fixing <rdar://problem/5112273> REGRESSION(TOT):
Reproducible crash loading an old version of amazon.com as a web archive
Layout tests pass.
Removed more superfluous document NULL checks. (Node::document() never
returns NULL, and it asserts as much.)
Merged some duplicate editing code into a static inline function.
* page/mac/WebCoreFrameBridge.mm:
(updateRenderingForBindings): Removed superfluous static_cast.
2007-04-05 Adele Peterson <adele@apple.com>
Reviewed by Darin.
......@@ -753,9 +753,7 @@ bool JSHTMLElement::implementsCall() const
{
HTMLElement* element = static_cast<HTMLElement*>(impl());
if (element->hasTagName(embedTag) || element->hasTagName(objectTag) || element->hasTagName(appletTag)) {
Frame* frame = 0;
if (Document* doc = element->document())
frame = doc->frame();
Frame* frame = element->document()->frame();
if (!frame)
return false;
KJSProxy *proxy = frame->scriptProxy();
......
......@@ -1334,13 +1334,8 @@ static IntRect boundingBoxRect(RenderObject* obj)
// try to use the document view from the first position, so that nested WebAreas work,
// but fall back to the top level doc if we do not find it easily
FrameView* frameView = 0;
RenderObject* renderer = startVisiblePosition.deepEquivalent().node()->renderer();
if (renderer) {
Document* doc = renderer->document();
if (doc)
frameView = doc->view();
}
FrameView* frameView = renderer ? renderer->document()->view() : 0;
if (!frameView)
frameView = [self frameView];
NSView* view = frameView->getView();
......
......@@ -1114,48 +1114,33 @@ static bool execUndo(Frame* frame, Event*)
return true;
}
static inline Frame* targetFrame(Frame* frame, Event* evt)
{
Node* node = evt ? evt->target()->toNode() : 0;
if (!node)
return frame;
return node->document()->frame();
}
static bool execInsertTab(Frame* frame, Event* evt)
{
Frame* targetFrame = frame;
if (evt) {
if (Node* node = evt->target()->toNode())
if (Document* doc = node->document())
targetFrame = doc->frame();
}
return targetFrame->eventHandler()->handleTextInputEvent("\t", evt, false, false);
return targetFrame(frame, evt)->eventHandler()->handleTextInputEvent("\t", evt, false, false);
}
static bool execInsertBacktab(Frame* frame, Event* evt)
{
Frame* targetFrame = frame;
if (evt) {
if (Node* node = evt->target()->toNode())
if (Document* doc = node->document())
targetFrame = doc->frame();
}
return targetFrame->eventHandler()->handleTextInputEvent("\t", evt, false, true);
return targetFrame(frame, evt)->eventHandler()->handleTextInputEvent("\t", evt, false, true);
}
static bool execInsertNewline(Frame* frame, Event* evt)
{
Frame* targetFrame = frame;
if (evt) {
if (Node* node = evt->target()->toNode())
if (Document* doc = node->document())
targetFrame = doc->frame();
}
Frame* targetFrame = WebCore::targetFrame(frame, evt);
return targetFrame->eventHandler()->handleTextInputEvent("\n", evt, !targetFrame->editor()->canEditRichly());
}
static bool execInsertLineBreak(Frame* frame, Event* evt)
{
Frame* targetFrame = frame;
if (evt) {
if (Node* node = evt->target()->toNode())
if (Document* doc = node->document())
targetFrame = doc->frame();
}
return targetFrame->eventHandler()->handleTextInputEvent("\n", evt, true);
return targetFrame(frame, evt)->eventHandler()->handleTextInputEvent("\n", evt, true);
}
// Enabled functions
......
......@@ -213,7 +213,7 @@ void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection)
// Restore the cached selection.
setSelectionRange(cachedSelStart, cachedSelEnd);
if (document() && document()->frame()) {
if (document()->frame()) {
document()->frame()->editor()->didBeginEditing();
document()->frame()->revealSelection();
}
......
......@@ -231,7 +231,7 @@ void HTMLTextAreaElement::updateFocusAppearance(bool restorePreviousSelection)
// Restore the cached selection. This matches other browsers' behavior.
setSelectionRange(cachedSelStart, cachedSelEnd);
if (document() && document()->frame())
if (document()->frame())
document()->frame()->revealSelection();
}
......
......@@ -114,7 +114,7 @@ void SVGAElement::defaultEventHandler(Event* evt)
String url = parseURL(href());
if (!evt->defaultPrevented())
if (document() && document()->frame())
if (document()->frame())
document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt);
evt->setDefaultHandled();
......
......@@ -48,8 +48,7 @@ SVGElementInstance::SVGElementInstance(SVGUseElement* useElement, PassRefPtr<SVG
ASSERT(m_element);
// Register as instance for passed element.
if (Document* document = m_element->document())
document->accessSVGExtensions()->mapInstanceToElement(this, m_element.get());
m_element->document()->accessSVGExtensions()->mapInstanceToElement(this, m_element.get());
}
SVGElementInstance::~SVGElementInstance()
......@@ -58,8 +57,7 @@ SVGElementInstance::~SVGElementInstance()
child->setParent(0);
// Deregister as instance for passed element.
if (Document* document = m_element->document())
document->accessSVGExtensions()->removeInstanceMapping(this, m_element.get());
m_element->document()->accessSVGExtensions()->removeInstanceMapping(this, m_element.get());
}
SVGElement* SVGElementInstance::correspondingElement() const
......
......@@ -83,9 +83,8 @@ void ContextMenuController::handleContextMenuEvent(Event* event)
IntPoint point = IntPoint(mouseEvent->pageX(), mouseEvent->pageY());
HitTestResult result(point);
if (Document* document = event->target()->toNode()->document())
if (Frame* frame = document->frame())
result = frame->eventHandler()->hitTestResultAtPoint(point, false);
if (Frame* frame = event->target()->toNode()->document()->frame())
result = frame->eventHandler()->hitTestResultAtPoint(point, false);
if (!result.innerNonSharedNode())
return;
......
......@@ -102,7 +102,7 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
if (dragData->containsURL()) {
String title;
String url = dragData->asURL(&title);
if (document && !url.isEmpty()) {
if (!url.isEmpty()) {
ExceptionCode ec;
RefPtr<HTMLAnchorElement> anchor = static_cast<HTMLAnchorElement*>(document->createElement("a", ec).get());
anchor->setHref(url);
......
......@@ -144,8 +144,7 @@ static void updateRenderingForBindings(ExecState* exec, JSObject* rootObject)
if (!window)
return;
Document* doc = static_cast<Document*>(window->frame()->document());
if (doc)
if (Document* doc = window->frame()->document())
doc->updateRendering();
}
......
......@@ -2488,7 +2488,7 @@ bool RenderObject::documentBeingDestroyed() const
void RenderObject::destroy()
{
// If this renderer is being autoscrolled, stop the autoscroll timer
if (document() && document()->frame() && document()->frame()->eventHandler()->autoscrollRenderer() == this)
if (document()->frame() && document()->frame()->eventHandler()->autoscrollRenderer() == this)
document()->frame()->eventHandler()->stopAutoscrollTimer(true);
if (m_hasCounterNodeMap)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment