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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 2858963002: Replace ASSERT with DCHECK in core/ (Closed)
Patch Set: WorkerBackingThread Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &frame), 288 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &frame),
289 this, 289 this,
290 &LocalDOMWindow::WarnUnusedPreloads), 290 &LocalDOMWindow::WarnUnusedPreloads),
291 should_print_when_finished_loading_(false), 291 should_print_when_finished_loading_(false),
292 custom_elements_(this, nullptr) {} 292 custom_elements_(this, nullptr) {}
293 293
294 void LocalDOMWindow::ClearDocument() { 294 void LocalDOMWindow::ClearDocument() {
295 if (!document_) 295 if (!document_)
296 return; 296 return;
297 297
298 ASSERT(!document_->IsActive()); 298 DCHECK(!document_->IsActive());
299 299
300 // FIXME: This should be part of SuspendableObject shutdown 300 // FIXME: This should be part of SuspendableObject shutdown
301 ClearEventQueue(); 301 ClearEventQueue();
302 302
303 unused_preloads_timer_.Stop(); 303 unused_preloads_timer_.Stop();
304 document_->ClearDOMWindow(); 304 document_->ClearDOMWindow();
305 document_ = nullptr; 305 document_ = nullptr;
306 } 306 }
307 307
308 void LocalDOMWindow::ClearEventQueue() { 308 void LocalDOMWindow::ClearEventQueue() {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we 457 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we
458 // defer firing of popstate until we're in the complete state. 458 // defer firing of popstate until we're in the complete state.
459 if (document()->IsLoadCompleted()) 459 if (document()->IsLoadCompleted())
460 EnqueuePopstateEvent(std::move(state_object)); 460 EnqueuePopstateEvent(std::move(state_object));
461 else 461 else
462 pending_state_object_ = std::move(state_object); 462 pending_state_object_ = std::move(state_object);
463 } 463 }
464 464
465 LocalDOMWindow::~LocalDOMWindow() { 465 LocalDOMWindow::~LocalDOMWindow() {
466 // Cleared when detaching document. 466 // Cleared when detaching document.
467 ASSERT(!event_queue_); 467 DCHECK(!event_queue_);
468 } 468 }
469 469
470 void LocalDOMWindow::Dispose() { 470 void LocalDOMWindow::Dispose() {
471 // Oilpan: should the LocalDOMWindow be GCed along with its LocalFrame without 471 // Oilpan: should the LocalDOMWindow be GCed along with its LocalFrame without
472 // the frame having first notified its observers of imminent destruction, the 472 // the frame having first notified its observers of imminent destruction, the
473 // LocalDOMWindow will not have had an opportunity to remove event listeners. 473 // LocalDOMWindow will not have had an opportunity to remove event listeners.
474 // 474 //
475 // Arrange for that removal to happen using a prefinalizer action. Making 475 // Arrange for that removal to happen using a prefinalizer action. Making
476 // LocalDOMWindow eager finalizable is problematic as other eagerly finalized 476 // LocalDOMWindow eager finalizable is problematic as other eagerly finalized
477 // objects may well want to access their associated LocalDOMWindow from their 477 // objects may well want to access their associated LocalDOMWindow from their
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 scrollbars_ = nullptr; 522 scrollbars_ = nullptr;
523 statusbar_ = nullptr; 523 statusbar_ = nullptr;
524 toolbar_ = nullptr; 524 toolbar_ = nullptr;
525 navigator_ = nullptr; 525 navigator_ = nullptr;
526 media_ = nullptr; 526 media_ = nullptr;
527 custom_elements_ = nullptr; 527 custom_elements_ = nullptr;
528 application_cache_ = nullptr; 528 application_cache_ = nullptr;
529 } 529 }
530 530
531 void LocalDOMWindow::SendOrientationChangeEvent() { 531 void LocalDOMWindow::SendOrientationChangeEvent() {
532 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); 532 DCHECK(RuntimeEnabledFeatures::orientationEventEnabled());
533 DCHECK(GetFrame()->IsLocalRoot()); 533 DCHECK(GetFrame()->IsLocalRoot());
534 534
535 // Before dispatching the event, build a list of all frames in the page 535 // Before dispatching the event, build a list of all frames in the page
536 // to send the event to, to mitigate side effects from event handlers 536 // to send the event to, to mitigate side effects from event handlers
537 // potentially interfering with others. 537 // potentially interfering with others.
538 HeapVector<Member<LocalFrame>> frames; 538 HeapVector<Member<LocalFrame>> frames;
539 frames.push_back(GetFrame()); 539 frames.push_back(GetFrame());
540 for (size_t i = 0; i < frames.size(); i++) { 540 for (size_t i = 0; i < frames.size(); i++) {
541 for (Frame* child = frames[i]->Tree().FirstChild(); child; 541 for (Frame* child = frames[i]->Tree().FirstChild(); child;
542 child = child->Tree().NextSibling()) { 542 child = child->Tree().NextSibling()) {
543 if (child->IsLocalFrame()) 543 if (child->IsLocalFrame())
544 frames.push_back(ToLocalFrame(child)); 544 frames.push_back(ToLocalFrame(child));
545 } 545 }
546 } 546 }
547 547
548 for (LocalFrame* frame : frames) { 548 for (LocalFrame* frame : frames) {
549 frame->DomWindow()->DispatchEvent( 549 frame->DomWindow()->DispatchEvent(
550 Event::Create(EventTypeNames::orientationchange)); 550 Event::Create(EventTypeNames::orientationchange));
551 } 551 }
552 } 552 }
553 553
554 int LocalDOMWindow::orientation() const { 554 int LocalDOMWindow::orientation() const {
555 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); 555 DCHECK(RuntimeEnabledFeatures::orientationEventEnabled());
556 556
557 if (!GetFrame() || !GetFrame()->GetPage()) 557 if (!GetFrame() || !GetFrame()->GetPage())
558 return 0; 558 return 0;
559 559
560 int orientation = GetFrame() 560 int orientation = GetFrame()
561 ->GetPage() 561 ->GetPage()
562 ->GetChromeClient() 562 ->GetChromeClient()
563 .GetScreenInfo() 563 .GetScreenInfo()
564 .orientation_angle; 564 .orientation_angle;
565 // For backward compatibility, we want to return a value in the range of 565 // For backward compatibility, we want to return a value in the range of
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 // didn't change. This is important to avoid violating the browser assumption 1113 // didn't change. This is important to avoid violating the browser assumption
1114 // that the unique name doesn't change if the browsing context name doesn't 1114 // that the unique name doesn't change if the browsing context name doesn't
1115 // change. 1115 // change.
1116 // TODO(dcheng): This comment is indicative of a problematic layering 1116 // TODO(dcheng): This comment is indicative of a problematic layering
1117 // violation. The browser should not be relying on the renderer to get this 1117 // violation. The browser should not be relying on the renderer to get this
1118 // correct; unique name calculation should be moved up into the browser. 1118 // correct; unique name calculation should be moved up into the browser.
1119 if (name == GetFrame()->Tree().GetName()) 1119 if (name == GetFrame()->Tree().GetName())
1120 return; 1120 return;
1121 1121
1122 GetFrame()->Tree().SetName(name); 1122 GetFrame()->Tree().SetName(name);
1123 ASSERT(GetFrame()->Loader().Client()); 1123 DCHECK(GetFrame()->Loader().Client());
1124 GetFrame()->Loader().Client()->DidChangeName(name); 1124 GetFrame()->Loader().Client()->DidChangeName(name);
1125 } 1125 }
1126 1126
1127 void LocalDOMWindow::setStatus(const String& string) { 1127 void LocalDOMWindow::setStatus(const String& string) {
1128 status_ = string; 1128 status_ = string;
1129 1129
1130 if (!GetFrame()) 1130 if (!GetFrame())
1131 return; 1131 return;
1132 1132
1133 Page* page = GetFrame()->GetPage(); 1133 Page* page = GetFrame()->GetPage();
(...skipping 26 matching lines...) Expand all
1160 1160
1161 StyleMedia* LocalDOMWindow::styleMedia() const { 1161 StyleMedia* LocalDOMWindow::styleMedia() const {
1162 if (!media_) 1162 if (!media_)
1163 media_ = StyleMedia::Create(GetFrame()); 1163 media_ = StyleMedia::Create(GetFrame());
1164 return media_.Get(); 1164 return media_.Get();
1165 } 1165 }
1166 1166
1167 CSSStyleDeclaration* LocalDOMWindow::getComputedStyle( 1167 CSSStyleDeclaration* LocalDOMWindow::getComputedStyle(
1168 Element* elt, 1168 Element* elt,
1169 const String& pseudo_elt) const { 1169 const String& pseudo_elt) const {
1170 ASSERT(elt); 1170 DCHECK(elt);
1171 return CSSComputedStyleDeclaration::Create(elt, false, pseudo_elt); 1171 return CSSComputedStyleDeclaration::Create(elt, false, pseudo_elt);
1172 } 1172 }
1173 1173
1174 CSSRuleList* LocalDOMWindow::getMatchedCSSRules( 1174 CSSRuleList* LocalDOMWindow::getMatchedCSSRules(
1175 Element* element, 1175 Element* element,
1176 const String& pseudo_element) const { 1176 const String& pseudo_element) const {
1177 if (!element) 1177 if (!element)
1178 return nullptr; 1178 return nullptr;
1179 1179
1180 if (!IsCurrentlyDisplayedInFrame()) 1180 if (!IsCurrentlyDisplayedInFrame())
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 DOMWindow::Trace(visitor); 1695 DOMWindow::Trace(visitor);
1696 Supplementable<LocalDOMWindow>::Trace(visitor); 1696 Supplementable<LocalDOMWindow>::Trace(visitor);
1697 } 1697 }
1698 1698
1699 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) { 1699 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) {
1700 visitor->TraceWrappers(custom_elements_); 1700 visitor->TraceWrappers(custom_elements_);
1701 DOMWindow::TraceWrappers(visitor); 1701 DOMWindow::TraceWrappers(visitor);
1702 } 1702 }
1703 1703
1704 } // namespace blink 1704 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LayoutSubtreeRootList.cpp ('k') | third_party/WebKit/Source/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698