Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 1175173002: Simplify inDetach() assert and make it stronger. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/DocumentLifecycle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after
3418 } 3418 }
3419 3419
3420 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions) 3420 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions)
3421 { 3421 {
3422 m_annotatedRegions = regions; 3422 m_annotatedRegions = regions;
3423 setAnnotatedRegionsDirty(false); 3423 setAnnotatedRegionsDirty(false);
3424 } 3424 }
3425 3425
3426 bool Document::setFocusedElement(PassRefPtrWillBeRawPtr<Element> prpNewFocusedEl ement, WebFocusType type) 3426 bool Document::setFocusedElement(PassRefPtrWillBeRawPtr<Element> prpNewFocusedEl ement, WebFocusType type)
3427 { 3427 {
3428 ASSERT(!m_lifecycle.inDetach());
3429
3428 m_clearFocusedElementTimer.stop(); 3430 m_clearFocusedElementTimer.stop();
3429 3431
3430 RefPtrWillBeRawPtr<Element> newFocusedElement = prpNewFocusedElement; 3432 RefPtrWillBeRawPtr<Element> newFocusedElement = prpNewFocusedElement;
3431 3433
3432 // Make sure newFocusedNode is actually in this document 3434 // Make sure newFocusedNode is actually in this document
3433 if (newFocusedElement && (newFocusedElement->document() != this)) 3435 if (newFocusedElement && (newFocusedElement->document() != this))
3434 return true; 3436 return true;
3435 3437
3436 if (NodeChildRemovalTracker::isBeingRemoved(newFocusedElement.get())) 3438 if (NodeChildRemovalTracker::isBeingRemoved(newFocusedElement.get()))
3437 return true; 3439 return true;
3438 3440
3439 if (m_focusedElement == newFocusedElement) 3441 if (m_focusedElement == newFocusedElement)
3440 return true; 3442 return true;
3441 3443
3442 bool focusChangeBlocked = false; 3444 bool focusChangeBlocked = false;
3443 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; 3445 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement;
3444 m_focusedElement = nullptr; 3446 m_focusedElement = nullptr;
3445 3447
3446 // Remove focus from the existing focus node (if any) 3448 // Remove focus from the existing focus node (if any)
3447 if (oldFocusedElement) { 3449 if (oldFocusedElement) {
3448 ASSERT(!oldFocusedElement->inDetach());
3449
3450 if (oldFocusedElement->active()) 3450 if (oldFocusedElement->active())
3451 oldFocusedElement->setActive(false); 3451 oldFocusedElement->setActive(false);
3452 3452
3453 oldFocusedElement->setFocus(false); 3453 oldFocusedElement->setFocus(false);
3454 3454
3455 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields) 3455 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields)
3456 // If page lost focus, blur event will have already been dispatched 3456 // If page lost focus, blur event will have already been dispatched
3457 if (page() && (page()->focusController().isFocused())) { 3457 if (page() && (page()->focusController().isFocused())) {
3458 oldFocusedElement->dispatchBlurEvent(newFocusedElement.get(), type); 3458 oldFocusedElement->dispatchBlurEvent(newFocusedElement.get(), type);
3459 3459
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
5738 #ifndef NDEBUG 5738 #ifndef NDEBUG
5739 using namespace blink; 5739 using namespace blink;
5740 void showLiveDocumentInstances() 5740 void showLiveDocumentInstances()
5741 { 5741 {
5742 WeakDocumentSet& set = liveDocumentSet(); 5742 WeakDocumentSet& set = liveDocumentSet();
5743 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5743 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5744 for (Document* document : set) 5744 for (Document* document : set)
5745 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5745 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5746 } 5746 }
5747 #endif 5747 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/DocumentLifecycle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698