| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #include "sky/engine/core/frame/FrameHost.h" | 58 #include "sky/engine/core/frame/FrameHost.h" |
| 59 #include "sky/engine/core/frame/FrameView.h" | 59 #include "sky/engine/core/frame/FrameView.h" |
| 60 #include "sky/engine/core/frame/LocalFrame.h" | 60 #include "sky/engine/core/frame/LocalFrame.h" |
| 61 #include "sky/engine/core/frame/Location.h" | 61 #include "sky/engine/core/frame/Location.h" |
| 62 #include "sky/engine/core/frame/Screen.h" | 62 #include "sky/engine/core/frame/Screen.h" |
| 63 #include "sky/engine/core/frame/Settings.h" | 63 #include "sky/engine/core/frame/Settings.h" |
| 64 #include "sky/engine/core/inspector/ConsoleMessage.h" | 64 #include "sky/engine/core/inspector/ConsoleMessage.h" |
| 65 #include "sky/engine/core/inspector/ConsoleMessageStorage.h" | 65 #include "sky/engine/core/inspector/ConsoleMessageStorage.h" |
| 66 #include "sky/engine/core/inspector/InspectorTraceEvents.h" | 66 #include "sky/engine/core/inspector/InspectorTraceEvents.h" |
| 67 #include "sky/engine/core/loader/FrameLoaderClient.h" | 67 #include "sky/engine/core/loader/FrameLoaderClient.h" |
| 68 #include "sky/engine/core/page/Chrome.h" | |
| 69 #include "sky/engine/core/page/ChromeClient.h" | 68 #include "sky/engine/core/page/ChromeClient.h" |
| 70 #include "sky/engine/core/page/EventHandler.h" | 69 #include "sky/engine/core/page/EventHandler.h" |
| 71 #include "sky/engine/core/page/Page.h" | 70 #include "sky/engine/core/page/Page.h" |
| 72 #include "sky/engine/core/rendering/style/RenderStyle.h" | 71 #include "sky/engine/core/rendering/style/RenderStyle.h" |
| 73 #include "sky/engine/platform/EventDispatchForbiddenScope.h" | 72 #include "sky/engine/platform/EventDispatchForbiddenScope.h" |
| 74 #include "sky/engine/platform/PlatformScreen.h" | 73 #include "sky/engine/platform/PlatformScreen.h" |
| 75 #include "sky/engine/platform/geometry/FloatRect.h" | 74 #include "sky/engine/platform/geometry/FloatRect.h" |
| 76 #include "sky/engine/platform/weborigin/KURL.h" | 75 #include "sky/engine/platform/weborigin/KURL.h" |
| 77 #include "sky/engine/platform/weborigin/SecurityPolicy.h" | 76 #include "sky/engine/platform/weborigin/SecurityPolicy.h" |
| 78 #include "sky/engine/public/platform/Platform.h" | 77 #include "sky/engine/public/platform/Platform.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // 2) Constrains the window rect to the minimum window size and no bigger than t
he float rect's dimensions. | 143 // 2) Constrains the window rect to the minimum window size and no bigger than t
he float rect's dimensions. |
| 145 // 3) Constrains the window rect to within the top and left boundaries of the av
ailable screen rect. | 144 // 3) Constrains the window rect to within the top and left boundaries of the av
ailable screen rect. |
| 146 // 4) Constrains the window rect to within the bottom and right boundaries of th
e available screen rect. | 145 // 4) Constrains the window rect to within the bottom and right boundaries of th
e available screen rect. |
| 147 // 5) Translate the window rect coordinates to be within the coordinate space of
the screen. | 146 // 5) Translate the window rect coordinates to be within the coordinate space of
the screen. |
| 148 FloatRect LocalDOMWindow::adjustWindowRect(LocalFrame& frame, const FloatRect& p
endingChanges) | 147 FloatRect LocalDOMWindow::adjustWindowRect(LocalFrame& frame, const FloatRect& p
endingChanges) |
| 149 { | 148 { |
| 150 FrameHost* host = frame.host(); | 149 FrameHost* host = frame.host(); |
| 151 ASSERT(host); | 150 ASSERT(host); |
| 152 | 151 |
| 153 FloatRect screen = screenAvailableRect(frame.view()); | 152 FloatRect screen = screenAvailableRect(frame.view()); |
| 154 FloatRect window = host->chrome().windowRect(); | 153 FloatRect window = host->page().windowRect(); |
| 155 | 154 |
| 156 // Make sure we're in a valid state before adjusting dimensions. | 155 // Make sure we're in a valid state before adjusting dimensions. |
| 157 ASSERT(std::isfinite(screen.x())); | 156 ASSERT(std::isfinite(screen.x())); |
| 158 ASSERT(std::isfinite(screen.y())); | 157 ASSERT(std::isfinite(screen.y())); |
| 159 ASSERT(std::isfinite(screen.width())); | 158 ASSERT(std::isfinite(screen.width())); |
| 160 ASSERT(std::isfinite(screen.height())); | 159 ASSERT(std::isfinite(screen.height())); |
| 161 ASSERT(std::isfinite(window.x())); | 160 ASSERT(std::isfinite(window.x())); |
| 162 ASSERT(std::isfinite(window.y())); | 161 ASSERT(std::isfinite(window.y())); |
| 163 ASSERT(std::isfinite(window.width())); | 162 ASSERT(std::isfinite(window.width())); |
| 164 ASSERT(std::isfinite(window.height())); | 163 ASSERT(std::isfinite(window.height())); |
| 165 | 164 |
| 166 // Update window values if new requested values are not NaN. | 165 // Update window values if new requested values are not NaN. |
| 167 if (!std::isnan(pendingChanges.x())) | 166 if (!std::isnan(pendingChanges.x())) |
| 168 window.setX(pendingChanges.x()); | 167 window.setX(pendingChanges.x()); |
| 169 if (!std::isnan(pendingChanges.y())) | 168 if (!std::isnan(pendingChanges.y())) |
| 170 window.setY(pendingChanges.y()); | 169 window.setY(pendingChanges.y()); |
| 171 if (!std::isnan(pendingChanges.width())) | 170 if (!std::isnan(pendingChanges.width())) |
| 172 window.setWidth(pendingChanges.width()); | 171 window.setWidth(pendingChanges.width()); |
| 173 if (!std::isnan(pendingChanges.height())) | 172 if (!std::isnan(pendingChanges.height())) |
| 174 window.setHeight(pendingChanges.height()); | 173 window.setHeight(pendingChanges.height()); |
| 175 | 174 |
| 176 FloatSize minimumSize = host->chrome().client().minimumWindowSize(); | 175 // TODO(esprehn): What? |
| 176 FloatSize minimumSize = FloatSize(100, 100); |
| 177 // Let size 0 pass through, since that indicates default size, not minimum s
ize. | 177 // Let size 0 pass through, since that indicates default size, not minimum s
ize. |
| 178 if (window.width()) | 178 if (window.width()) |
| 179 window.setWidth(min(max(minimumSize.width(), window.width()), screen.wid
th())); | 179 window.setWidth(min(max(minimumSize.width(), window.width()), screen.wid
th())); |
| 180 if (window.height()) | 180 if (window.height()) |
| 181 window.setHeight(min(max(minimumSize.height(), window.height()), screen.
height())); | 181 window.setHeight(min(max(minimumSize.height(), window.height()), screen.
height())); |
| 182 | 182 |
| 183 // Constrain the window position within the valid screen area. | 183 // Constrain the window position within the valid screen area. |
| 184 window.setX(max(screen.x(), min(window.x(), screen.maxX() - window.width()))
); | 184 window.setX(max(screen.x(), min(window.x(), screen.maxX() - window.width()))
); |
| 185 window.setY(max(screen.y(), min(window.y(), screen.maxY() - window.height())
)); | 185 window.setY(max(screen.y(), min(window.y(), screen.maxY() - window.height())
)); |
| 186 | 186 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 void LocalDOMWindow::focus(ExecutionContext* context) | 433 void LocalDOMWindow::focus(ExecutionContext* context) |
| 434 { | 434 { |
| 435 if (!m_frame) | 435 if (!m_frame) |
| 436 return; | 436 return; |
| 437 | 437 |
| 438 FrameHost* host = m_frame->host(); | 438 FrameHost* host = m_frame->host(); |
| 439 if (!host) | 439 if (!host) |
| 440 return; | 440 return; |
| 441 | 441 |
| 442 host->chrome().focus(); | 442 host->page().focus(); |
| 443 | 443 |
| 444 if (!m_frame) | 444 if (!m_frame) |
| 445 return; | 445 return; |
| 446 | 446 |
| 447 m_frame->eventHandler().focusDocumentView(); | 447 m_frame->eventHandler().focusDocumentView(); |
| 448 } | 448 } |
| 449 | 449 |
| 450 int LocalDOMWindow::outerHeight() const | 450 int LocalDOMWindow::outerHeight() const |
| 451 { | 451 { |
| 452 if (!m_frame) | 452 if (!m_frame) |
| 453 return 0; | 453 return 0; |
| 454 | 454 |
| 455 FrameHost* host = m_frame->host(); | 455 FrameHost* host = m_frame->host(); |
| 456 if (!host) | 456 if (!host) |
| 457 return 0; | 457 return 0; |
| 458 | 458 |
| 459 return static_cast<int>(host->chrome().windowRect().height()); | 459 return static_cast<int>(host->page().windowRect().height()); |
| 460 } | 460 } |
| 461 | 461 |
| 462 int LocalDOMWindow::outerWidth() const | 462 int LocalDOMWindow::outerWidth() const |
| 463 { | 463 { |
| 464 if (!m_frame) | 464 if (!m_frame) |
| 465 return 0; | 465 return 0; |
| 466 | 466 |
| 467 FrameHost* host = m_frame->host(); | 467 FrameHost* host = m_frame->host(); |
| 468 if (!host) | 468 if (!host) |
| 469 return 0; | 469 return 0; |
| 470 | 470 |
| 471 return static_cast<int>(host->chrome().windowRect().width()); | 471 return static_cast<int>(host->page().windowRect().width()); |
| 472 } | 472 } |
| 473 | 473 |
| 474 int LocalDOMWindow::innerHeight() const | 474 int LocalDOMWindow::innerHeight() const |
| 475 { | 475 { |
| 476 if (!m_frame) | 476 if (!m_frame) |
| 477 return 0; | 477 return 0; |
| 478 | 478 |
| 479 FrameView* view = m_frame->view(); | 479 FrameView* view = m_frame->view(); |
| 480 if (!view) | 480 if (!view) |
| 481 return 0; | 481 return 0; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 497 | 497 |
| 498 int LocalDOMWindow::screenX() const | 498 int LocalDOMWindow::screenX() const |
| 499 { | 499 { |
| 500 if (!m_frame) | 500 if (!m_frame) |
| 501 return 0; | 501 return 0; |
| 502 | 502 |
| 503 FrameHost* host = m_frame->host(); | 503 FrameHost* host = m_frame->host(); |
| 504 if (!host) | 504 if (!host) |
| 505 return 0; | 505 return 0; |
| 506 | 506 |
| 507 return static_cast<int>(host->chrome().windowRect().x()); | 507 return static_cast<int>(host->page().windowRect().x()); |
| 508 } | 508 } |
| 509 | 509 |
| 510 int LocalDOMWindow::screenY() const | 510 int LocalDOMWindow::screenY() const |
| 511 { | 511 { |
| 512 if (!m_frame) | 512 if (!m_frame) |
| 513 return 0; | 513 return 0; |
| 514 | 514 |
| 515 FrameHost* host = m_frame->host(); | 515 FrameHost* host = m_frame->host(); |
| 516 if (!host) | 516 if (!host) |
| 517 return 0; | 517 return 0; |
| 518 | 518 |
| 519 return static_cast<int>(host->chrome().windowRect().y()); | 519 return static_cast<int>(host->page().windowRect().y()); |
| 520 } | 520 } |
| 521 | 521 |
| 522 LocalDOMWindow* LocalDOMWindow::window() const | 522 LocalDOMWindow* LocalDOMWindow::window() const |
| 523 { | 523 { |
| 524 if (!m_frame) | 524 if (!m_frame) |
| 525 return 0; | 525 return 0; |
| 526 | 526 |
| 527 return m_frame->domWindow(); | 527 return m_frame->domWindow(); |
| 528 } | 528 } |
| 529 | 529 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 550 | 550 |
| 551 void LocalDOMWindow::moveBy(float x, float y) const | 551 void LocalDOMWindow::moveBy(float x, float y) const |
| 552 { | 552 { |
| 553 if (!m_frame) | 553 if (!m_frame) |
| 554 return; | 554 return; |
| 555 | 555 |
| 556 FrameHost* host = m_frame->host(); | 556 FrameHost* host = m_frame->host(); |
| 557 if (!host) | 557 if (!host) |
| 558 return; | 558 return; |
| 559 | 559 |
| 560 FloatRect windowRect = host->chrome().windowRect(); | 560 FloatRect windowRect = host->page().windowRect(); |
| 561 windowRect.move(x, y); | 561 windowRect.move(x, y); |
| 562 // Security check (the spec talks about UniversalBrowserWrite to disable thi
s check...) | 562 // Security check (the spec talks about UniversalBrowserWrite to disable thi
s check...) |
| 563 host->chrome().setWindowRect(adjustWindowRect(*m_frame, windowRect)); | 563 host->page().setWindowRect(adjustWindowRect(*m_frame, windowRect)); |
| 564 } | 564 } |
| 565 | 565 |
| 566 void LocalDOMWindow::moveTo(float x, float y) const | 566 void LocalDOMWindow::moveTo(float x, float y) const |
| 567 { | 567 { |
| 568 if (!m_frame) | 568 if (!m_frame) |
| 569 return; | 569 return; |
| 570 | 570 |
| 571 FrameHost* host = m_frame->host(); | 571 FrameHost* host = m_frame->host(); |
| 572 if (!host) | 572 if (!host) |
| 573 return; | 573 return; |
| 574 | 574 |
| 575 FloatRect windowRect = host->chrome().windowRect(); | 575 FloatRect windowRect = host->page().windowRect(); |
| 576 windowRect.setLocation(FloatPoint(x, y)); | 576 windowRect.setLocation(FloatPoint(x, y)); |
| 577 // Security check (the spec talks about UniversalBrowserWrite to disable thi
s check...) | 577 // Security check (the spec talks about UniversalBrowserWrite to disable thi
s check...) |
| 578 host->chrome().setWindowRect(adjustWindowRect(*m_frame, windowRect)); | 578 host->page().setWindowRect(adjustWindowRect(*m_frame, windowRect)); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void LocalDOMWindow::resizeBy(float x, float y) const | 581 void LocalDOMWindow::resizeBy(float x, float y) const |
| 582 { | 582 { |
| 583 if (!m_frame) | 583 if (!m_frame) |
| 584 return; | 584 return; |
| 585 | 585 |
| 586 FrameHost* host = m_frame->host(); | 586 FrameHost* host = m_frame->host(); |
| 587 if (!host) | 587 if (!host) |
| 588 return; | 588 return; |
| 589 | 589 |
| 590 FloatRect fr = host->chrome().windowRect(); | 590 FloatRect fr = host->page().windowRect(); |
| 591 FloatSize dest = fr.size() + FloatSize(x, y); | 591 FloatSize dest = fr.size() + FloatSize(x, y); |
| 592 FloatRect update(fr.location(), dest); | 592 FloatRect update(fr.location(), dest); |
| 593 host->chrome().setWindowRect(adjustWindowRect(*m_frame, update)); | 593 host->page().setWindowRect(adjustWindowRect(*m_frame, update)); |
| 594 } | 594 } |
| 595 | 595 |
| 596 void LocalDOMWindow::resizeTo(float width, float height) const | 596 void LocalDOMWindow::resizeTo(float width, float height) const |
| 597 { | 597 { |
| 598 if (!m_frame) | 598 if (!m_frame) |
| 599 return; | 599 return; |
| 600 | 600 |
| 601 FrameHost* host = m_frame->host(); | 601 FrameHost* host = m_frame->host(); |
| 602 if (!host) | 602 if (!host) |
| 603 return; | 603 return; |
| 604 | 604 |
| 605 FloatRect fr = host->chrome().windowRect(); | 605 FloatRect fr = host->page().windowRect(); |
| 606 FloatSize dest = FloatSize(width, height); | 606 FloatSize dest = FloatSize(width, height); |
| 607 FloatRect update(fr.location(), dest); | 607 FloatRect update(fr.location(), dest); |
| 608 host->chrome().setWindowRect(adjustWindowRect(*m_frame, update)); | 608 host->page().setWindowRect(adjustWindowRect(*m_frame, update)); |
| 609 } | 609 } |
| 610 | 610 |
| 611 int LocalDOMWindow::requestAnimationFrame(PassOwnPtr<RequestAnimationFrameCallba
ck> callback) | 611 int LocalDOMWindow::requestAnimationFrame(PassOwnPtr<RequestAnimationFrameCallba
ck> callback) |
| 612 { | 612 { |
| 613 callback->m_useLegacyTimeBase = false; | 613 callback->m_useLegacyTimeBase = false; |
| 614 if (Document* d = document()) | 614 if (Document* d = document()) |
| 615 return d->requestAnimationFrame(callback); | 615 return d->requestAnimationFrame(callback); |
| 616 return 0; | 616 return 0; |
| 617 } | 617 } |
| 618 | 618 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 { | 723 { |
| 724 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin
dow>::lifecycleNotifier()); | 724 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin
dow>::lifecycleNotifier()); |
| 725 } | 725 } |
| 726 | 726 |
| 727 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo
tifier() | 727 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo
tifier() |
| 728 { | 728 { |
| 729 return DOMWindowLifecycleNotifier::create(this); | 729 return DOMWindowLifecycleNotifier::create(this); |
| 730 } | 730 } |
| 731 | 731 |
| 732 } // namespace blink | 732 } // namespace blink |
| OLD | NEW |