| OLD | NEW |
| 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 continue; | 524 continue; |
| 525 toLocalFrame(frames[i].get()) | 525 toLocalFrame(frames[i].get()) |
| 526 ->domWindow() | 526 ->domWindow() |
| 527 ->dispatchEvent(Event::create(EventTypeNames::orientationchange)); | 527 ->dispatchEvent(Event::create(EventTypeNames::orientationchange)); |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 | 530 |
| 531 int LocalDOMWindow::orientation() const { | 531 int LocalDOMWindow::orientation() const { |
| 532 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); | 532 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); |
| 533 | 533 |
| 534 if (!frame() || !frame()->host()) | 534 if (!frame() || !frame()->page()) |
| 535 return 0; | 535 return 0; |
| 536 | 536 |
| 537 int orientation = | 537 int orientation = |
| 538 frame()->host()->chromeClient().screenInfo().orientationAngle; | 538 frame()->page()->chromeClient().screenInfo().orientationAngle; |
| 539 // For backward compatibility, we want to return a value in the range of | 539 // For backward compatibility, we want to return a value in the range of |
| 540 // [-90; 180] instead of [0; 360[ because window.orientation used to behave | 540 // [-90; 180] instead of [0; 360[ because window.orientation used to behave |
| 541 // like that in WebKit (this is a WebKit proprietary API). | 541 // like that in WebKit (this is a WebKit proprietary API). |
| 542 if (orientation == 270) | 542 if (orientation == 270) |
| 543 return -90; | 543 return -90; |
| 544 return orientation; | 544 return orientation; |
| 545 } | 545 } |
| 546 | 546 |
| 547 Screen* LocalDOMWindow::screen() const { | 547 Screen* LocalDOMWindow::screen() const { |
| 548 if (!m_screen) | 548 if (!m_screen) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 691 |
| 692 return toHTMLFrameOwnerElement(frame()->owner()); | 692 return toHTMLFrameOwnerElement(frame()->owner()); |
| 693 } | 693 } |
| 694 | 694 |
| 695 void LocalDOMWindow::blur() {} | 695 void LocalDOMWindow::blur() {} |
| 696 | 696 |
| 697 void LocalDOMWindow::print(ScriptState* scriptState) { | 697 void LocalDOMWindow::print(ScriptState* scriptState) { |
| 698 if (!frame()) | 698 if (!frame()) |
| 699 return; | 699 return; |
| 700 | 700 |
| 701 FrameHost* host = frame()->host(); | 701 Page* page = frame()->page(); |
| 702 if (!host) | 702 if (!page) |
| 703 return; | 703 return; |
| 704 | 704 |
| 705 if (scriptState && | 705 if (scriptState && |
| 706 v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { | 706 v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
| 707 UseCounter::count(document(), UseCounter::During_Microtask_Print); | 707 UseCounter::count(document(), UseCounter::During_Microtask_Print); |
| 708 } | 708 } |
| 709 | 709 |
| 710 if (frame()->isLoading()) { | 710 if (frame()->isLoading()) { |
| 711 m_shouldPrintWhenFinishedLoading = true; | 711 m_shouldPrintWhenFinishedLoading = true; |
| 712 return; | 712 return; |
| 713 } | 713 } |
| 714 | 714 |
| 715 UseCounter::countCrossOriginIframe(*document(), | 715 UseCounter::countCrossOriginIframe(*document(), |
| 716 UseCounter::CrossOriginWindowPrint); | 716 UseCounter::CrossOriginWindowPrint); |
| 717 | 717 |
| 718 m_shouldPrintWhenFinishedLoading = false; | 718 m_shouldPrintWhenFinishedLoading = false; |
| 719 host->chromeClient().print(frame()); | 719 page->chromeClient().print(frame()); |
| 720 } | 720 } |
| 721 | 721 |
| 722 void LocalDOMWindow::stop() { | 722 void LocalDOMWindow::stop() { |
| 723 if (!frame()) | 723 if (!frame()) |
| 724 return; | 724 return; |
| 725 frame()->loader().stopAllLoaders(); | 725 frame()->loader().stopAllLoaders(); |
| 726 } | 726 } |
| 727 | 727 |
| 728 void LocalDOMWindow::alert(ScriptState* scriptState, const String& message) { | 728 void LocalDOMWindow::alert(ScriptState* scriptState, const String& message) { |
| 729 if (!frame()) | 729 if (!frame()) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 758 UseCounter::count(document(), UseCounter::AlertEngagementMax); | 758 UseCounter::count(document(), UseCounter::AlertEngagementMax); |
| 759 break; | 759 break; |
| 760 } | 760 } |
| 761 | 761 |
| 762 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { | 762 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
| 763 UseCounter::count(document(), UseCounter::During_Microtask_Alert); | 763 UseCounter::count(document(), UseCounter::During_Microtask_Alert); |
| 764 } | 764 } |
| 765 | 765 |
| 766 document()->updateStyleAndLayoutTree(); | 766 document()->updateStyleAndLayoutTree(); |
| 767 | 767 |
| 768 FrameHost* host = frame()->host(); | 768 Page* page = frame()->page(); |
| 769 if (!host) | 769 if (!page) |
| 770 return; | 770 return; |
| 771 | 771 |
| 772 UseCounter::countCrossOriginIframe(*document(), | 772 UseCounter::countCrossOriginIframe(*document(), |
| 773 UseCounter::CrossOriginWindowAlert); | 773 UseCounter::CrossOriginWindowAlert); |
| 774 | 774 |
| 775 host->chromeClient().openJavaScriptAlert(frame(), message); | 775 page->chromeClient().openJavaScriptAlert(frame(), message); |
| 776 } | 776 } |
| 777 | 777 |
| 778 bool LocalDOMWindow::confirm(ScriptState* scriptState, const String& message) { | 778 bool LocalDOMWindow::confirm(ScriptState* scriptState, const String& message) { |
| 779 if (!frame()) | 779 if (!frame()) |
| 780 return false; | 780 return false; |
| 781 | 781 |
| 782 if (document()->isSandboxed(SandboxModals)) { | 782 if (document()->isSandboxed(SandboxModals)) { |
| 783 UseCounter::count(document(), UseCounter::DialogInSandboxedContext); | 783 UseCounter::count(document(), UseCounter::DialogInSandboxedContext); |
| 784 frameConsole()->addMessage(ConsoleMessage::create( | 784 frameConsole()->addMessage(ConsoleMessage::create( |
| 785 SecurityMessageSource, ErrorMessageLevel, | 785 SecurityMessageSource, ErrorMessageLevel, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 808 UseCounter::count(document(), UseCounter::ConfirmEngagementMax); | 808 UseCounter::count(document(), UseCounter::ConfirmEngagementMax); |
| 809 break; | 809 break; |
| 810 } | 810 } |
| 811 | 811 |
| 812 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { | 812 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
| 813 UseCounter::count(document(), UseCounter::During_Microtask_Confirm); | 813 UseCounter::count(document(), UseCounter::During_Microtask_Confirm); |
| 814 } | 814 } |
| 815 | 815 |
| 816 document()->updateStyleAndLayoutTree(); | 816 document()->updateStyleAndLayoutTree(); |
| 817 | 817 |
| 818 FrameHost* host = frame()->host(); | 818 Page* page = frame()->page(); |
| 819 if (!host) | 819 if (!page) |
| 820 return false; | 820 return false; |
| 821 | 821 |
| 822 UseCounter::countCrossOriginIframe(*document(), | 822 UseCounter::countCrossOriginIframe(*document(), |
| 823 UseCounter::CrossOriginWindowConfirm); | 823 UseCounter::CrossOriginWindowConfirm); |
| 824 | 824 |
| 825 return host->chromeClient().openJavaScriptConfirm(frame(), message); | 825 return page->chromeClient().openJavaScriptConfirm(frame(), message); |
| 826 } | 826 } |
| 827 | 827 |
| 828 String LocalDOMWindow::prompt(ScriptState* scriptState, | 828 String LocalDOMWindow::prompt(ScriptState* scriptState, |
| 829 const String& message, | 829 const String& message, |
| 830 const String& defaultValue) { | 830 const String& defaultValue) { |
| 831 if (!frame()) | 831 if (!frame()) |
| 832 return String(); | 832 return String(); |
| 833 | 833 |
| 834 if (document()->isSandboxed(SandboxModals)) { | 834 if (document()->isSandboxed(SandboxModals)) { |
| 835 UseCounter::count(document(), UseCounter::DialogInSandboxedContext); | 835 UseCounter::count(document(), UseCounter::DialogInSandboxedContext); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 860 UseCounter::count(document(), UseCounter::PromptEngagementMax); | 860 UseCounter::count(document(), UseCounter::PromptEngagementMax); |
| 861 break; | 861 break; |
| 862 } | 862 } |
| 863 | 863 |
| 864 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { | 864 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
| 865 UseCounter::count(document(), UseCounter::During_Microtask_Prompt); | 865 UseCounter::count(document(), UseCounter::During_Microtask_Prompt); |
| 866 } | 866 } |
| 867 | 867 |
| 868 document()->updateStyleAndLayoutTree(); | 868 document()->updateStyleAndLayoutTree(); |
| 869 | 869 |
| 870 FrameHost* host = frame()->host(); | 870 Page* page = frame()->page(); |
| 871 if (!host) | 871 if (!page) |
| 872 return String(); | 872 return String(); |
| 873 | 873 |
| 874 String returnValue; | 874 String returnValue; |
| 875 if (host->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue, | 875 if (page->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue, |
| 876 returnValue)) | 876 returnValue)) |
| 877 return returnValue; | 877 return returnValue; |
| 878 | 878 |
| 879 UseCounter::countCrossOriginIframe(*document(), | 879 UseCounter::countCrossOriginIframe(*document(), |
| 880 UseCounter::CrossOriginWindowPrompt); | 880 UseCounter::CrossOriginWindowPrompt); |
| 881 | 881 |
| 882 return String(); | 882 return String(); |
| 883 } | 883 } |
| 884 | 884 |
| 885 bool LocalDOMWindow::find(const String& string, | 885 bool LocalDOMWindow::find(const String& string, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 ASSERT(frame()->loader().client()); | 1085 ASSERT(frame()->loader().client()); |
| 1086 frame()->loader().client()->didChangeName(name, frame()->tree().uniqueName()); | 1086 frame()->loader().client()->didChangeName(name, frame()->tree().uniqueName()); |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 void LocalDOMWindow::setStatus(const String& string) { | 1089 void LocalDOMWindow::setStatus(const String& string) { |
| 1090 m_status = string; | 1090 m_status = string; |
| 1091 | 1091 |
| 1092 if (!frame()) | 1092 if (!frame()) |
| 1093 return; | 1093 return; |
| 1094 | 1094 |
| 1095 FrameHost* host = frame()->host(); | 1095 Page* page = frame()->page(); |
| 1096 if (!host) | 1096 if (!page) |
| 1097 return; | 1097 return; |
| 1098 | 1098 |
| 1099 host->chromeClient().setStatusbarText(m_status); | 1099 page->chromeClient().setStatusbarText(m_status); |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 void LocalDOMWindow::setDefaultStatus(const String& string) { | 1102 void LocalDOMWindow::setDefaultStatus(const String& string) { |
| 1103 m_defaultStatus = string; | 1103 m_defaultStatus = string; |
| 1104 | 1104 |
| 1105 if (!frame()) | 1105 if (!frame()) |
| 1106 return; | 1106 return; |
| 1107 | 1107 |
| 1108 FrameHost* host = frame()->host(); | 1108 Page* page = frame()->page(); |
| 1109 if (!host) | 1109 if (!page) |
| 1110 return; | 1110 return; |
| 1111 | 1111 |
| 1112 host->chromeClient().setStatusbarText(m_defaultStatus); | 1112 page->chromeClient().setStatusbarText(m_defaultStatus); |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 Document* LocalDOMWindow::document() const { | 1115 Document* LocalDOMWindow::document() const { |
| 1116 return m_document.get(); | 1116 return m_document.get(); |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 StyleMedia* LocalDOMWindow::styleMedia() const { | 1119 StyleMedia* LocalDOMWindow::styleMedia() const { |
| 1120 if (!m_media) | 1120 if (!m_media) |
| 1121 m_media = StyleMedia::create(frame()); | 1121 m_media = StyleMedia::create(frame()); |
| 1122 return m_media.get(); | 1122 return m_media.get(); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 scrollBehavior); | 1275 scrollBehavior); |
| 1276 | 1276 |
| 1277 viewport->setScrollOffset(ScrollOffset(scaledX, scaledY), ProgrammaticScroll, | 1277 viewport->setScrollOffset(ScrollOffset(scaledX, scaledY), ProgrammaticScroll, |
| 1278 scrollBehavior); | 1278 scrollBehavior); |
| 1279 } | 1279 } |
| 1280 | 1280 |
| 1281 void LocalDOMWindow::moveBy(int x, int y) const { | 1281 void LocalDOMWindow::moveBy(int x, int y) const { |
| 1282 if (!frame() || !frame()->isMainFrame()) | 1282 if (!frame() || !frame()->isMainFrame()) |
| 1283 return; | 1283 return; |
| 1284 | 1284 |
| 1285 FrameHost* host = frame()->host(); | 1285 Page* page = frame()->page(); |
| 1286 if (!host) | 1286 if (!page) |
| 1287 return; | 1287 return; |
| 1288 | 1288 |
| 1289 IntRect windowRect = host->chromeClient().rootWindowRect(); | 1289 IntRect windowRect = page->chromeClient().rootWindowRect(); |
| 1290 windowRect.saturatedMove(x, y); | 1290 windowRect.saturatedMove(x, y); |
| 1291 // Security check (the spec talks about UniversalBrowserWrite to disable this | 1291 // Security check (the spec talks about UniversalBrowserWrite to disable this |
| 1292 // check...) | 1292 // check...) |
| 1293 host->chromeClient().setWindowRectWithAdjustment(windowRect, *frame()); | 1293 page->chromeClient().setWindowRectWithAdjustment(windowRect, *frame()); |
| 1294 } | 1294 } |
| 1295 | 1295 |
| 1296 void LocalDOMWindow::moveTo(int x, int y) const { | 1296 void LocalDOMWindow::moveTo(int x, int y) const { |
| 1297 if (!frame() || !frame()->isMainFrame()) | 1297 if (!frame() || !frame()->isMainFrame()) |
| 1298 return; | 1298 return; |
| 1299 | 1299 |
| 1300 FrameHost* host = frame()->host(); | 1300 Page* page = frame()->page(); |
| 1301 if (!host) | 1301 if (!page) |
| 1302 return; | 1302 return; |
| 1303 | 1303 |
| 1304 IntRect windowRect = host->chromeClient().rootWindowRect(); | 1304 IntRect windowRect = page->chromeClient().rootWindowRect(); |
| 1305 windowRect.setLocation(IntPoint(x, y)); | 1305 windowRect.setLocation(IntPoint(x, y)); |
| 1306 // Security check (the spec talks about UniversalBrowserWrite to disable this | 1306 // Security check (the spec talks about UniversalBrowserWrite to disable this |
| 1307 // check...) | 1307 // check...) |
| 1308 host->chromeClient().setWindowRectWithAdjustment(windowRect, *frame()); | 1308 page->chromeClient().setWindowRectWithAdjustment(windowRect, *frame()); |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 void LocalDOMWindow::resizeBy(int x, int y) const { | 1311 void LocalDOMWindow::resizeBy(int x, int y) const { |
| 1312 if (!frame() || !frame()->isMainFrame()) | 1312 if (!frame() || !frame()->isMainFrame()) |
| 1313 return; | 1313 return; |
| 1314 | 1314 |
| 1315 FrameHost* host = frame()->host(); | 1315 Page* page = frame()->page(); |
| 1316 if (!host) | 1316 if (!page) |
| 1317 return; | 1317 return; |
| 1318 | 1318 |
| 1319 IntRect fr = host->chromeClient().rootWindowRect(); | 1319 IntRect fr = page->chromeClient().rootWindowRect(); |
| 1320 IntSize dest = fr.size() + IntSize(x, y); | 1320 IntSize dest = fr.size() + IntSize(x, y); |
| 1321 IntRect update(fr.location(), dest); | 1321 IntRect update(fr.location(), dest); |
| 1322 host->chromeClient().setWindowRectWithAdjustment(update, *frame()); | 1322 page->chromeClient().setWindowRectWithAdjustment(update, *frame()); |
| 1323 } | 1323 } |
| 1324 | 1324 |
| 1325 void LocalDOMWindow::resizeTo(int width, int height) const { | 1325 void LocalDOMWindow::resizeTo(int width, int height) const { |
| 1326 if (!frame() || !frame()->isMainFrame()) | 1326 if (!frame() || !frame()->isMainFrame()) |
| 1327 return; | 1327 return; |
| 1328 | 1328 |
| 1329 FrameHost* host = frame()->host(); | 1329 Page* page = frame()->page(); |
| 1330 if (!host) | 1330 if (!page) |
| 1331 return; | 1331 return; |
| 1332 | 1332 |
| 1333 IntRect fr = host->chromeClient().rootWindowRect(); | 1333 IntRect fr = page->chromeClient().rootWindowRect(); |
| 1334 IntSize dest = IntSize(width, height); | 1334 IntSize dest = IntSize(width, height); |
| 1335 IntRect update(fr.location(), dest); | 1335 IntRect update(fr.location(), dest); |
| 1336 host->chromeClient().setWindowRectWithAdjustment(update, *frame()); | 1336 page->chromeClient().setWindowRectWithAdjustment(update, *frame()); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 int LocalDOMWindow::requestAnimationFrame(FrameRequestCallback* callback) { | 1339 int LocalDOMWindow::requestAnimationFrame(FrameRequestCallback* callback) { |
| 1340 callback->m_useLegacyTimeBase = false; | 1340 callback->m_useLegacyTimeBase = false; |
| 1341 if (Document* doc = document()) | 1341 if (Document* doc = document()) |
| 1342 return doc->requestAnimationFrame(callback); | 1342 return doc->requestAnimationFrame(callback); |
| 1343 return 0; | 1343 return 0; |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 int LocalDOMWindow::webkitRequestAnimationFrame( | 1346 int LocalDOMWindow::webkitRequestAnimationFrame( |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 DOMWindow::trace(visitor); | 1635 DOMWindow::trace(visitor); |
| 1636 Supplementable<LocalDOMWindow>::trace(visitor); | 1636 Supplementable<LocalDOMWindow>::trace(visitor); |
| 1637 } | 1637 } |
| 1638 | 1638 |
| 1639 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) { | 1639 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) { |
| 1640 visitor->traceWrappers(m_customElements); | 1640 visitor->traceWrappers(m_customElements); |
| 1641 DOMWindow::traceWrappers(visitor); | 1641 DOMWindow::traceWrappers(visitor); |
| 1642 } | 1642 } |
| 1643 | 1643 |
| 1644 } // namespace blink | 1644 } // namespace blink |
| OLD | NEW |