Commit 55cde01f authored by akling@apple.com's avatar akling@apple.com

Ref-ify more stack guards.

<https://webkit.org/b/122360>

Reviewed by Anders Carlsson.

Make another pass turning RefPtr<T> into Ref<T> where possible.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156932 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f9d0842b
2013-10-04 Andreas Kling <akling@apple.com>
Ref-ify more stack guards.
<https://webkit.org/b/122360>
Reviewed by Anders Carlsson.
Make another pass turning RefPtr<T> into Ref<T> where possible.
2013-10-04 Ojan Vafai <ojan@chromium.org> and Martin Robinson <mrobinson@igalia.com>
[MathML] Remove RenderTree modification during layout and refactor the StretchyOp code
......@@ -105,7 +105,7 @@ bool AccessibilityMenuList::canSetFocusAttribute() const
void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
{
RefPtr<Document> document = &m_renderer->document();
Ref<Document> document(m_renderer->document());
AXObjectCache* cache = document->axObjectCache();
const AccessibilityChildrenVector& childObjects = children();
......@@ -119,7 +119,7 @@ void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
}
}
cache->postNotification(this, document.get(), AXObjectCache::AXMenuListValueChanged, TargetElement, PostSynchronously);
cache->postNotification(this, &document.get(), AXObjectCache::AXMenuListValueChanged, TargetElement, PostSynchronously);
}
} // namespace WebCore
......@@ -251,10 +251,10 @@ bool ScriptElement::prepareScript(const TextPosition& scriptStartPosition, Legac
bool ScriptElement::requestScript(const String& sourceUrl)
{
RefPtr<Document> originalDocument = &m_element->document();
Ref<Document> originalDocument(m_element->document());
if (!m_element->dispatchBeforeLoadEvent(sourceUrl))
return false;
if (!m_element->inDocument() || &m_element->document() != originalDocument)
if (!m_element->inDocument() || &m_element->document() != &originalDocument.get())
return false;
if (!m_element->document().contentSecurityPolicy()->allowScriptNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr), m_element->document().url(), m_startLineNumber, m_element->document().completeURL(sourceUrl)))
return false;
......@@ -304,10 +304,10 @@ void ScriptElement::executeScript(const ScriptSourceCode& sourceCode)
}
#endif
RefPtr<Document> document = &m_element->document();
Ref<Document> document(m_element->document());
if (Frame* frame = document->frame()) {
IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_isExternalScript ? document.get() : 0);
CurrentScriptIncrementer currentScriptIncrementer(document.get(), m_element);
IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_isExternalScript ? &document.get() : 0);
CurrentScriptIncrementer currentScriptIncrementer(&document.get(), m_element);
// Create a script from the script element node, using the script
// block's source and the script block's type.
......
......@@ -982,18 +982,18 @@ bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectIn
selection = selectionForCommand(triggeringEvent);
if (selection.isContentEditable()) {
if (Node* selectionStart = selection.start().deprecatedNode()) {
RefPtr<Document> document = &selectionStart->document();
Ref<Document> document(selectionStart->document());
// Insert the text
if (triggeringEvent && triggeringEvent->isDictation())
DictationCommand::insertText(document.get(), text, triggeringEvent->dictationAlternatives(), selection);
DictationCommand::insertText(&document.get(), text, triggeringEvent->dictationAlternatives(), selection);
else {
TypingCommand::Options options = 0;
if (selectInsertedText)
options |= TypingCommand::SelectInsertedText;
if (autocorrectionWasApplied)
options |= TypingCommand::RetainAutocorrectionIndicator;
TypingCommand::insertText(document.get(), text, selection, options, triggeringEvent && triggeringEvent->isComposition() ? TypingCommand::TextCompositionConfirm : TypingCommand::TextCompositionNone);
TypingCommand::insertText(&document.get(), text, selection, options, triggeringEvent && triggeringEvent->isComposition() ? TypingCommand::TextCompositionConfirm : TypingCommand::TextCompositionNone);
}
// Reveal the current selection
......
......@@ -355,7 +355,7 @@ static bool removingNodeRemovesPosition(Node* node, const Position& position)
static void clearRenderViewSelection(const Position& position)
{
RefPtr<Document> document = &position.anchorNode()->document();
Ref<Document> document(position.anchorNode()->document());
document->updateStyleIfNeeded();
if (RenderView* view = document->renderView())
view->clearSelection();
......
......@@ -362,7 +362,7 @@ void FileInputType::setFiles(PassRefPtr<FileList> files)
if (!files)
return;
RefPtr<HTMLInputElement> input = &element();
Ref<HTMLInputElement> input(element());
bool pathsChanged = false;
if (files->length() != m_fileList->length())
......
......@@ -162,11 +162,11 @@ void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
bool HTMLLinkElement::shouldLoadLink()
{
RefPtr<Document> originalDocument = &document();
Ref<Document> originalDocument(document());
if (!dispatchBeforeLoadEvent(getNonEmptyURLAttribute(hrefAttr)))
return false;
// A beforeload handler might have removed us from the document or changed the document.
if (!inDocument() || &document() != originalDocument)
if (!inDocument() || &document() != &originalDocument.get())
return false;
return true;
}
......
......@@ -87,7 +87,7 @@ bool ImageInputType::supportsValidation() const
void ImageInputType::handleDOMActivateEvent(Event* event)
{
RefPtr<HTMLInputElement> element = &this->element();
Ref<HTMLInputElement> element(this->element());
if (element->isDisabledFormControl() || !element->form())
return;
element->setActivatedSubmit(true);
......@@ -173,7 +173,7 @@ bool ImageInputType::shouldRespectHeightAndWidthAttributes()
unsigned ImageInputType::height() const
{
RefPtr<HTMLInputElement> element = &this->element();
Ref<HTMLInputElement> element(this->element());
if (!element->renderer()) {
// Check the attribute first for an explicit pixel value.
......@@ -197,7 +197,7 @@ unsigned ImageInputType::height() const
unsigned ImageInputType::width() const
{
RefPtr<HTMLInputElement> element = &this->element();
Ref<HTMLInputElement> element(this->element());
if (!element->renderer()) {
// Check the attribute first for an explicit pixel value.
......
......@@ -133,7 +133,7 @@ void SearchInputType::handleKeydownEvent(KeyboardEvent* event)
const String& key = event->keyIdentifier();
if (key == "U+001B") {
RefPtr<HTMLInputElement> input = &element();
Ref<HTMLInputElement> input(this->element());
input->setValueForUser("");
input->onSearch();
event->setDefaultHandled();
......
......@@ -67,7 +67,7 @@ bool SubmitInputType::supportsRequired() const
void SubmitInputType::handleDOMActivateEvent(Event* event)
{
RefPtr<HTMLInputElement> element = &this->element();
Ref<HTMLInputElement> element(this->element());
if (element->isDisabledFormControl() || !element->form())
return;
element->setActivatedSubmit(true);
......
......@@ -97,7 +97,7 @@ void TextFieldInputType::setValue(const String& sanitizedValue, bool valueChange
{
// Grab this input element to keep reference even if JS event handler
// changes input type.
RefPtr<HTMLInputElement> input = &element();
Ref<HTMLInputElement> input(element());
// We don't ask InputType::setValue to dispatch events because
// TextFieldInputType dispatches events different way from InputType.
......@@ -492,7 +492,7 @@ void TextFieldInputType::updateInnerTextValue()
void TextFieldInputType::focusAndSelectSpinButtonOwner()
{
RefPtr<HTMLInputElement> input = &element();
Ref<HTMLInputElement> input(element());
input->focus();
input->select();
}
......
......@@ -2888,7 +2888,7 @@ void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& reques
if (!shouldContinue)
return;
RefPtr<Frame> frame = &m_frame;
Ref<Frame> frame(m_frame);
RefPtr<Frame> mainFrame = m_client.dispatchCreatePage(action);
if (!mainFrame)
return;
......@@ -2899,7 +2899,7 @@ void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& reques
mainFrame->page()->setOpenedByDOM();
mainFrame->loader().m_client.dispatchShow();
if (!m_suppressOpenerInNewFrame) {
mainFrame->loader().setOpener(frame.get());
mainFrame->loader().setOpener(&frame.get());
mainFrame->document()->setReferrerPolicy(frame->document()->referrerPolicy());
}
mainFrame->loader().loadWithNavigationAction(request, NavigationAction(request), false, FrameLoadTypeStandard, formState);
......
......@@ -209,7 +209,7 @@ bool DragController::performDrag(DragData* dragData)
m_documentUnderMouse = m_page.mainFrame().documentAtPoint(dragData->clientPosition());
if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHandlingDrag) {
m_client.willPerformDragDestinationAction(DragDestinationActionDHTML, dragData);
RefPtr<Frame> mainFrame = &m_page.mainFrame();
Ref<MainFrame> mainFrame(m_page.mainFrame());
bool preventedDefault = false;
if (mainFrame->view()) {
// Sending an event can result in the destruction of the view and part.
......@@ -598,7 +598,7 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
{
ASSERT(dragData);
ASSERT(m_documentUnderMouse);
RefPtr<Frame> mainFrame = &m_page.mainFrame();
Ref<MainFrame> mainFrame(m_page.mainFrame());
RefPtr<FrameView> viewProtector = mainFrame->view();
if (!viewProtector)
return false;
......@@ -908,10 +908,10 @@ void DragController::doSystemDrag(DragImageRef image, const IntPoint& dragLoc, c
m_didInitiateDrag = true;
m_dragInitiator = frame->document();
// Protect this frame and view, as a load may occur mid drag and attempt to unload this frame
RefPtr<Frame> frameProtector = &m_page.mainFrame();
Ref<MainFrame> frameProtector(m_page.mainFrame());
RefPtr<FrameView> viewProtector = frameProtector->view();
m_client.startDrag(image, viewProtector->rootViewToContents(frame->view()->contentsToRootView(dragLoc)),
viewProtector->rootViewToContents(frame->view()->contentsToRootView(eventPos)), clipboard, frameProtector.get(), forLink);
viewProtector->rootViewToContents(frame->view()->contentsToRootView(eventPos)), clipboard, &frameProtector.get(), forLink);
// DragClient::startDrag can cause our Page to dispear, deallocating |this|.
if (!frameProtector->page())
return;
......
......@@ -610,14 +610,14 @@ bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
return true;
}
RefPtr<Document> newDocument = &element->document();
Ref<Document> newDocument(element->document());
if (newDocument->focusedElement() == element) {
m_page.editorClient()->setInputMethodState(element->shouldUseInputMethod());
return true;
}
if (oldDocument && oldDocument != newDocument)
if (oldDocument && oldDocument != &newDocument.get())
oldDocument->setFocusedElement(0);
if (newFocusedFrame && !newFocusedFrame->page()) {
......@@ -627,11 +627,10 @@ bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
setFocusedFrame(newFocusedFrame);
Ref<Element> protect(*element);
if (newDocument) {
bool successfullyFocused = newDocument->setFocusedElement(element, direction);
if (!successfullyFocused)
return false;
}
bool successfullyFocused = newDocument->setFocusedElement(element, direction);
if (!successfullyFocused)
return false;
if (newDocument->focusedElement() == element)
m_page.editorClient()->setInputMethodState(element->shouldUseInputMethod());
......
......@@ -1075,7 +1075,7 @@ inline void FrameView::forceLayoutParentViewIfNeeded()
// FrameView for a layout. After that the RenderEmbeddedObject (ownerRenderer) carries the
// correct size, which RenderSVGRoot::computeReplacedLogicalWidth/Height rely on, when laying
// out for the first time, or when the RenderSVGRoot size has changed dynamically (eg. via <script>).
RefPtr<FrameView> frameView = &ownerRenderer->view().frameView();
Ref<FrameView> frameView(ownerRenderer->view().frameView());
// Mark the owner renderer as needing layout.
ownerRenderer->setNeedsLayoutAndPrefWidthsRecalc();
......
......@@ -70,8 +70,8 @@ XSLTProcessor::~XSLTProcessor()
PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame)
{
RefPtr<Document> ownerDocument = &sourceNode->document();
bool sourceIsDocument = (sourceNode == ownerDocument.get());
Ref<Document> ownerDocument(sourceNode->document());
bool sourceIsDocument = (sourceNode == &ownerDocument.get());
String documentSource = sourceString;
RefPtr<Document> result;
......
......@@ -267,8 +267,8 @@ static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheet>& cachedStyl
static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete)
{
RefPtr<Document> ownerDocument = &sourceNode->document();
bool sourceIsDocument = (sourceNode == ownerDocument.get());
Ref<Document> ownerDocument(sourceNode->document());
bool sourceIsDocument = (sourceNode == &ownerDocument.get());
xmlDocPtr sourceDoc = 0;
if (sourceIsDocument && ownerDocument->transformSource())
......@@ -302,7 +302,7 @@ static inline String resultMIMEType(xmlDocPtr resultDoc, xsltStylesheetPtr sheet
bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String& resultString, String& resultEncoding)
{
RefPtr<Document> ownerDocument = &sourceNode->document();
Ref<Document> ownerDocument(sourceNode->document());
setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->cachedResourceLoader());
xsltStylesheetPtr sheet = xsltStylesheetPointer(m_stylesheet, m_stylesheetRootNode.get());
......
......@@ -172,7 +172,7 @@ void PopupMenuMac::show(const IntRect& r, FrameView* v, int index)
// Save the current event that triggered the popup, so we can clean up our event
// state after the NSMenu goes away.
RefPtr<Frame> frame = &v->frame();
Ref<Frame> frame(v->frame());
RetainPtr<NSEvent> event = frame->eventHandler().currentNSEvent();
Ref<PopupMenuMac> protector(*this);
......
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