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

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

Issue 2716153003: Removed FrameHost::chromeClient() (Closed)
Patch Set: Small feedback Created 3 years, 9 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 continue; 530 continue;
531 toLocalFrame(frames[i].get()) 531 toLocalFrame(frames[i].get())
532 ->domWindow() 532 ->domWindow()
533 ->dispatchEvent(Event::create(EventTypeNames::orientationchange)); 533 ->dispatchEvent(Event::create(EventTypeNames::orientationchange));
534 } 534 }
535 } 535 }
536 536
537 int LocalDOMWindow::orientation() const { 537 int LocalDOMWindow::orientation() const {
538 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); 538 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled());
539 539
540 if (!frame() || !frame()->host()) 540 if (!frame() || !frame()->page())
541 return 0; 541 return 0;
542 542
543 int orientation = 543 int orientation =
544 frame()->host()->chromeClient().screenInfo().orientationAngle; 544 frame()->page()->chromeClient().screenInfo().orientationAngle;
545 // For backward compatibility, we want to return a value in the range of 545 // For backward compatibility, we want to return a value in the range of
546 // [-90; 180] instead of [0; 360[ because window.orientation used to behave 546 // [-90; 180] instead of [0; 360[ because window.orientation used to behave
547 // like that in WebKit (this is a WebKit proprietary API). 547 // like that in WebKit (this is a WebKit proprietary API).
548 if (orientation == 270) 548 if (orientation == 270)
549 return -90; 549 return -90;
550 return orientation; 550 return orientation;
551 } 551 }
552 552
553 Screen* LocalDOMWindow::screen() const { 553 Screen* LocalDOMWindow::screen() const {
554 if (!m_screen) 554 if (!m_screen)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 697
698 return toHTMLFrameOwnerElement(frame()->owner()); 698 return toHTMLFrameOwnerElement(frame()->owner());
699 } 699 }
700 700
701 void LocalDOMWindow::blur() {} 701 void LocalDOMWindow::blur() {}
702 702
703 void LocalDOMWindow::print(ScriptState* scriptState) { 703 void LocalDOMWindow::print(ScriptState* scriptState) {
704 if (!frame()) 704 if (!frame())
705 return; 705 return;
706 706
707 FrameHost* host = frame()->host(); 707 Page* page = frame()->page();
708 if (!host) 708 if (!page)
709 return; 709 return;
710 710
711 if (scriptState && 711 if (scriptState &&
712 v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { 712 v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) {
713 UseCounter::count(document(), UseCounter::During_Microtask_Print); 713 UseCounter::count(document(), UseCounter::During_Microtask_Print);
714 } 714 }
715 715
716 if (frame()->isLoading()) { 716 if (frame()->isLoading()) {
717 m_shouldPrintWhenFinishedLoading = true; 717 m_shouldPrintWhenFinishedLoading = true;
718 return; 718 return;
719 } 719 }
720 720
721 UseCounter::countCrossOriginIframe(*document(), 721 UseCounter::countCrossOriginIframe(*document(),
722 UseCounter::CrossOriginWindowPrint); 722 UseCounter::CrossOriginWindowPrint);
723 723
724 m_shouldPrintWhenFinishedLoading = false; 724 m_shouldPrintWhenFinishedLoading = false;
725 host->chromeClient().print(frame()); 725 page->chromeClient().print(frame());
726 } 726 }
727 727
728 void LocalDOMWindow::stop() { 728 void LocalDOMWindow::stop() {
729 if (!frame()) 729 if (!frame())
730 return; 730 return;
731 frame()->loader().stopAllLoaders(); 731 frame()->loader().stopAllLoaders();
732 } 732 }
733 733
734 void LocalDOMWindow::alert(ScriptState* scriptState, const String& message) { 734 void LocalDOMWindow::alert(ScriptState* scriptState, const String& message) {
735 if (!frame()) 735 if (!frame())
(...skipping 28 matching lines...) Expand all
764 UseCounter::count(document(), UseCounter::AlertEngagementMax); 764 UseCounter::count(document(), UseCounter::AlertEngagementMax);
765 break; 765 break;
766 } 766 }
767 767
768 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { 768 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) {
769 UseCounter::count(document(), UseCounter::During_Microtask_Alert); 769 UseCounter::count(document(), UseCounter::During_Microtask_Alert);
770 } 770 }
771 771
772 document()->updateStyleAndLayoutTree(); 772 document()->updateStyleAndLayoutTree();
773 773
774 FrameHost* host = frame()->host(); 774 Page* page = frame()->page();
775 if (!host) 775 if (!page)
776 return; 776 return;
777 777
778 UseCounter::countCrossOriginIframe(*document(), 778 UseCounter::countCrossOriginIframe(*document(),
779 UseCounter::CrossOriginWindowAlert); 779 UseCounter::CrossOriginWindowAlert);
780 780
781 host->chromeClient().openJavaScriptAlert(frame(), message); 781 page->chromeClient().openJavaScriptAlert(frame(), message);
782 } 782 }
783 783
784 bool LocalDOMWindow::confirm(ScriptState* scriptState, const String& message) { 784 bool LocalDOMWindow::confirm(ScriptState* scriptState, const String& message) {
785 if (!frame()) 785 if (!frame())
786 return false; 786 return false;
787 787
788 if (document()->isSandboxed(SandboxModals)) { 788 if (document()->isSandboxed(SandboxModals)) {
789 UseCounter::count(document(), UseCounter::DialogInSandboxedContext); 789 UseCounter::count(document(), UseCounter::DialogInSandboxedContext);
790 frameConsole()->addMessage(ConsoleMessage::create( 790 frameConsole()->addMessage(ConsoleMessage::create(
791 SecurityMessageSource, ErrorMessageLevel, 791 SecurityMessageSource, ErrorMessageLevel,
(...skipping 22 matching lines...) Expand all
814 UseCounter::count(document(), UseCounter::ConfirmEngagementMax); 814 UseCounter::count(document(), UseCounter::ConfirmEngagementMax);
815 break; 815 break;
816 } 816 }
817 817
818 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { 818 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) {
819 UseCounter::count(document(), UseCounter::During_Microtask_Confirm); 819 UseCounter::count(document(), UseCounter::During_Microtask_Confirm);
820 } 820 }
821 821
822 document()->updateStyleAndLayoutTree(); 822 document()->updateStyleAndLayoutTree();
823 823
824 FrameHost* host = frame()->host(); 824 Page* page = frame()->page();
825 if (!host) 825 if (!page)
826 return false; 826 return false;
827 827
828 UseCounter::countCrossOriginIframe(*document(), 828 UseCounter::countCrossOriginIframe(*document(),
829 UseCounter::CrossOriginWindowConfirm); 829 UseCounter::CrossOriginWindowConfirm);
830 830
831 return host->chromeClient().openJavaScriptConfirm(frame(), message); 831 return page->chromeClient().openJavaScriptConfirm(frame(), message);
832 } 832 }
833 833
834 String LocalDOMWindow::prompt(ScriptState* scriptState, 834 String LocalDOMWindow::prompt(ScriptState* scriptState,
835 const String& message, 835 const String& message,
836 const String& defaultValue) { 836 const String& defaultValue) {
837 if (!frame()) 837 if (!frame())
838 return String(); 838 return String();
839 839
840 if (document()->isSandboxed(SandboxModals)) { 840 if (document()->isSandboxed(SandboxModals)) {
841 UseCounter::count(document(), UseCounter::DialogInSandboxedContext); 841 UseCounter::count(document(), UseCounter::DialogInSandboxedContext);
(...skipping 24 matching lines...) Expand all
866 UseCounter::count(document(), UseCounter::PromptEngagementMax); 866 UseCounter::count(document(), UseCounter::PromptEngagementMax);
867 break; 867 break;
868 } 868 }
869 869
870 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { 870 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) {
871 UseCounter::count(document(), UseCounter::During_Microtask_Prompt); 871 UseCounter::count(document(), UseCounter::During_Microtask_Prompt);
872 } 872 }
873 873
874 document()->updateStyleAndLayoutTree(); 874 document()->updateStyleAndLayoutTree();
875 875
876 FrameHost* host = frame()->host(); 876 Page* page = frame()->page();
877 if (!host) 877 if (!page)
878 return String(); 878 return String();
879 879
880 String returnValue; 880 String returnValue;
881 if (host->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue, 881 if (page->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue,
882 returnValue)) 882 returnValue))
883 return returnValue; 883 return returnValue;
884 884
885 UseCounter::countCrossOriginIframe(*document(), 885 UseCounter::countCrossOriginIframe(*document(),
886 UseCounter::CrossOriginWindowPrompt); 886 UseCounter::CrossOriginWindowPrompt);
887 887
888 return String(); 888 return String();
889 } 889 }
890 890
891 bool LocalDOMWindow::find(const String& string, 891 bool LocalDOMWindow::find(const String& string,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 ASSERT(frame()->loader().client()); 1091 ASSERT(frame()->loader().client());
1092 frame()->loader().client()->didChangeName(name, frame()->tree().uniqueName()); 1092 frame()->loader().client()->didChangeName(name, frame()->tree().uniqueName());
1093 } 1093 }
1094 1094
1095 void LocalDOMWindow::setStatus(const String& string) { 1095 void LocalDOMWindow::setStatus(const String& string) {
1096 m_status = string; 1096 m_status = string;
1097 1097
1098 if (!frame()) 1098 if (!frame())
1099 return; 1099 return;
1100 1100
1101 FrameHost* host = frame()->host(); 1101 Page* page = frame()->page();
1102 if (!host) 1102 if (!page)
1103 return; 1103 return;
1104 1104
1105 host->chromeClient().setStatusbarText(m_status); 1105 page->chromeClient().setStatusbarText(m_status);
1106 } 1106 }
1107 1107
1108 void LocalDOMWindow::setDefaultStatus(const String& string) { 1108 void LocalDOMWindow::setDefaultStatus(const String& string) {
1109 m_defaultStatus = string; 1109 m_defaultStatus = string;
1110 1110
1111 if (!frame()) 1111 if (!frame())
1112 return; 1112 return;
1113 1113
1114 FrameHost* host = frame()->host(); 1114 Page* page = frame()->page();
1115 if (!host) 1115 if (!page)
1116 return; 1116 return;
1117 1117
1118 host->chromeClient().setStatusbarText(m_defaultStatus); 1118 page->chromeClient().setStatusbarText(m_defaultStatus);
1119 } 1119 }
1120 1120
1121 Document* LocalDOMWindow::document() const { 1121 Document* LocalDOMWindow::document() const {
1122 return m_document.get(); 1122 return m_document.get();
1123 } 1123 }
1124 1124
1125 StyleMedia* LocalDOMWindow::styleMedia() const { 1125 StyleMedia* LocalDOMWindow::styleMedia() const {
1126 if (!m_media) 1126 if (!m_media)
1127 m_media = StyleMedia::create(frame()); 1127 m_media = StyleMedia::create(frame());
1128 return m_media.get(); 1128 return m_media.get();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 scrollBehavior); 1281 scrollBehavior);
1282 1282
1283 viewport->setScrollOffset(ScrollOffset(scaledX, scaledY), ProgrammaticScroll, 1283 viewport->setScrollOffset(ScrollOffset(scaledX, scaledY), ProgrammaticScroll,
1284 scrollBehavior); 1284 scrollBehavior);
1285 } 1285 }
1286 1286
1287 void LocalDOMWindow::moveBy(int x, int y) const { 1287 void LocalDOMWindow::moveBy(int x, int y) const {
1288 if (!frame() || !frame()->isMainFrame()) 1288 if (!frame() || !frame()->isMainFrame())
1289 return; 1289 return;
1290 1290
1291 FrameHost* host = frame()->host(); 1291 Page* page = frame()->page();
1292 if (!host) 1292 if (!page)
1293 return; 1293 return;
1294 1294
1295 IntRect windowRect = host->chromeClient().rootWindowRect(); 1295 IntRect windowRect = page->chromeClient().rootWindowRect();
1296 windowRect.saturatedMove(x, y); 1296 windowRect.saturatedMove(x, y);
1297 // Security check (the spec talks about UniversalBrowserWrite to disable this 1297 // Security check (the spec talks about UniversalBrowserWrite to disable this
1298 // check...) 1298 // check...)
1299 host->chromeClient().setWindowRectWithAdjustment(windowRect, *frame()); 1299 page->chromeClient().setWindowRectWithAdjustment(windowRect, *frame());
1300 } 1300 }
1301 1301
1302 void LocalDOMWindow::moveTo(int x, int y) const { 1302 void LocalDOMWindow::moveTo(int x, int y) const {
1303 if (!frame() || !frame()->isMainFrame()) 1303 if (!frame() || !frame()->isMainFrame())
1304 return; 1304 return;
1305 1305
1306 FrameHost* host = frame()->host(); 1306 Page* page = frame()->page();
1307 if (!host) 1307 if (!page)
1308 return; 1308 return;
1309 1309
1310 IntRect windowRect = host->chromeClient().rootWindowRect(); 1310 IntRect windowRect = page->chromeClient().rootWindowRect();
1311 windowRect.setLocation(IntPoint(x, y)); 1311 windowRect.setLocation(IntPoint(x, y));
1312 // Security check (the spec talks about UniversalBrowserWrite to disable this 1312 // Security check (the spec talks about UniversalBrowserWrite to disable this
1313 // check...) 1313 // check...)
1314 host->chromeClient().setWindowRectWithAdjustment(windowRect, *frame()); 1314 page->chromeClient().setWindowRectWithAdjustment(windowRect, *frame());
1315 } 1315 }
1316 1316
1317 void LocalDOMWindow::resizeBy(int x, int y) const { 1317 void LocalDOMWindow::resizeBy(int x, int y) const {
1318 if (!frame() || !frame()->isMainFrame()) 1318 if (!frame() || !frame()->isMainFrame())
1319 return; 1319 return;
1320 1320
1321 FrameHost* host = frame()->host(); 1321 Page* page = frame()->page();
1322 if (!host) 1322 if (!page)
1323 return; 1323 return;
1324 1324
1325 IntRect fr = host->chromeClient().rootWindowRect(); 1325 IntRect fr = page->chromeClient().rootWindowRect();
1326 IntSize dest = fr.size() + IntSize(x, y); 1326 IntSize dest = fr.size() + IntSize(x, y);
1327 IntRect update(fr.location(), dest); 1327 IntRect update(fr.location(), dest);
1328 host->chromeClient().setWindowRectWithAdjustment(update, *frame()); 1328 page->chromeClient().setWindowRectWithAdjustment(update, *frame());
1329 } 1329 }
1330 1330
1331 void LocalDOMWindow::resizeTo(int width, int height) const { 1331 void LocalDOMWindow::resizeTo(int width, int height) const {
1332 if (!frame() || !frame()->isMainFrame()) 1332 if (!frame() || !frame()->isMainFrame())
1333 return; 1333 return;
1334 1334
1335 FrameHost* host = frame()->host(); 1335 Page* page = frame()->page();
1336 if (!host) 1336 if (!page)
1337 return; 1337 return;
1338 1338
1339 IntRect fr = host->chromeClient().rootWindowRect(); 1339 IntRect fr = page->chromeClient().rootWindowRect();
1340 IntSize dest = IntSize(width, height); 1340 IntSize dest = IntSize(width, height);
1341 IntRect update(fr.location(), dest); 1341 IntRect update(fr.location(), dest);
1342 host->chromeClient().setWindowRectWithAdjustment(update, *frame()); 1342 page->chromeClient().setWindowRectWithAdjustment(update, *frame());
1343 } 1343 }
1344 1344
1345 int LocalDOMWindow::requestAnimationFrame(FrameRequestCallback* callback) { 1345 int LocalDOMWindow::requestAnimationFrame(FrameRequestCallback* callback) {
1346 callback->m_useLegacyTimeBase = false; 1346 callback->m_useLegacyTimeBase = false;
1347 if (Document* doc = document()) 1347 if (Document* doc = document())
1348 return doc->requestAnimationFrame(callback); 1348 return doc->requestAnimationFrame(callback);
1349 return 0; 1349 return 0;
1350 } 1350 }
1351 1351
1352 int LocalDOMWindow::webkitRequestAnimationFrame( 1352 int LocalDOMWindow::webkitRequestAnimationFrame(
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 DOMWindow::trace(visitor); 1641 DOMWindow::trace(visitor);
1642 Supplementable<LocalDOMWindow>::trace(visitor); 1642 Supplementable<LocalDOMWindow>::trace(visitor);
1643 } 1643 }
1644 1644
1645 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) { 1645 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) {
1646 visitor->traceWrappers(m_customElements); 1646 visitor->traceWrappers(m_customElements);
1647 DOMWindow::traceWrappers(visitor); 1647 DOMWindow::traceWrappers(visitor);
1648 } 1648 }
1649 1649
1650 } // namespace blink 1650 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | third_party/WebKit/Source/core/frame/Navigator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698