| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R
ights Reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R
ights Reserved. |
| 3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "sky/engine/config.h" | 20 #include "sky/engine/config.h" |
| 21 #include "sky/engine/core/page/Page.h" | 21 #include "sky/engine/core/page/Page.h" |
| 22 | 22 |
| 23 #include "sky/engine/core/dom/ClientRectList.h" | 23 #include "sky/engine/core/dom/ClientRectList.h" |
| 24 #include "sky/engine/core/dom/Document.h" |
| 24 #include "sky/engine/core/dom/DocumentMarkerController.h" | 25 #include "sky/engine/core/dom/DocumentMarkerController.h" |
| 25 #include "sky/engine/core/dom/StyleEngine.h" | 26 #include "sky/engine/core/dom/StyleEngine.h" |
| 26 #include "sky/engine/core/editing/Caret.h" | 27 #include "sky/engine/core/editing/Caret.h" |
| 27 #include "sky/engine/core/editing/UndoStack.h" | 28 #include "sky/engine/core/editing/UndoStack.h" |
| 28 #include "sky/engine/core/events/Event.h" | 29 #include "sky/engine/core/events/Event.h" |
| 29 #include "sky/engine/core/fetch/ResourceFetcher.h" | 30 #include "sky/engine/core/fetch/ResourceFetcher.h" |
| 30 #include "sky/engine/core/frame/DOMTimer.h" | 31 #include "sky/engine/core/frame/DOMTimer.h" |
| 31 #include "sky/engine/core/frame/FrameConsole.h" | 32 #include "sky/engine/core/frame/FrameConsole.h" |
| 32 #include "sky/engine/core/frame/FrameHost.h" | 33 #include "sky/engine/core/frame/FrameHost.h" |
| 33 #include "sky/engine/core/frame/FrameView.h" | 34 #include "sky/engine/core/frame/FrameView.h" |
| 34 #include "sky/engine/core/frame/LocalDOMWindow.h" | 35 #include "sky/engine/core/frame/LocalDOMWindow.h" |
| 35 #include "sky/engine/core/frame/LocalFrame.h" | 36 #include "sky/engine/core/frame/LocalFrame.h" |
| 36 #include "sky/engine/core/frame/Settings.h" | 37 #include "sky/engine/core/frame/Settings.h" |
| 37 #include "sky/engine/core/page/AutoscrollController.h" | 38 #include "sky/engine/core/page/AutoscrollController.h" |
| 38 #include "sky/engine/core/page/Chrome.h" | |
| 39 #include "sky/engine/core/page/ChromeClient.h" | 39 #include "sky/engine/core/page/ChromeClient.h" |
| 40 #include "sky/engine/core/page/FocusController.h" | 40 #include "sky/engine/core/page/FocusController.h" |
| 41 #include "sky/engine/core/page/PageLifecycleNotifier.h" | 41 #include "sky/engine/core/page/PageLifecycleNotifier.h" |
| 42 #include "sky/engine/core/rendering/RenderView.h" | 42 #include "sky/engine/core/rendering/RenderView.h" |
| 43 #include "sky/engine/platform/geometry/FloatRect.h" |
| 44 #include "sky/engine/public/platform/WebScreenInfo.h" |
| 43 #include "sky/engine/wtf/HashMap.h" | 45 #include "sky/engine/wtf/HashMap.h" |
| 46 #include "sky/engine/wtf/PassRefPtr.h" |
| 44 #include "sky/engine/wtf/RefCountedLeakCounter.h" | 47 #include "sky/engine/wtf/RefCountedLeakCounter.h" |
| 45 #include "sky/engine/wtf/StdLibExtras.h" | 48 #include "sky/engine/wtf/StdLibExtras.h" |
| 49 #include "sky/engine/wtf/Vector.h" |
| 46 #include "sky/engine/wtf/text/Base64.h" | 50 #include "sky/engine/wtf/text/Base64.h" |
| 47 | 51 |
| 48 namespace blink { | 52 namespace blink { |
| 49 | 53 |
| 50 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page")); | 54 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page")); |
| 51 | 55 |
| 52 float deviceScaleFactor(LocalFrame* frame) | 56 float deviceScaleFactor(LocalFrame* frame) |
| 53 { | 57 { |
| 54 if (!frame) | 58 if (!frame) |
| 55 return 1; | 59 return 1; |
| 56 Page* page = frame->page(); | 60 Page* page = frame->page(); |
| 57 if (!page) | 61 if (!page) |
| 58 return 1; | 62 return 1; |
| 59 return page->deviceScaleFactor(); | 63 return page->deviceScaleFactor(); |
| 60 } | 64 } |
| 61 | 65 |
| 62 Page::Page(PageClients& pageClients, ServiceProvider& services) | 66 Page::Page(PageClients& pageClients, ServiceProvider& services) |
| 63 : SettingsDelegate(Settings::create()) | 67 : SettingsDelegate(Settings::create()) |
| 64 , m_animator(this) | 68 , m_animator(this) |
| 65 , m_autoscrollController(AutoscrollController::create(*this)) | 69 , m_autoscrollController(AutoscrollController::create(*this)) |
| 66 , m_chrome(Chrome::create(pageClients.chromeClient)) | 70 , m_chromeClient(pageClients.chromeClient) |
| 67 , m_dragCaretController(DragCaretController::create()) | 71 , m_dragCaretController(DragCaretController::create()) |
| 68 , m_focusController(FocusController::create(this)) | 72 , m_focusController(FocusController::create(this)) |
| 69 , m_undoStack(UndoStack::create()) | 73 , m_undoStack(UndoStack::create()) |
| 70 , m_mainFrame(0) | 74 , m_mainFrame(0) |
| 71 , m_editorClient(pageClients.editorClient) | 75 , m_editorClient(pageClients.editorClient) |
| 72 , m_spellCheckerClient(pageClients.spellCheckerClient) | 76 , m_spellCheckerClient(pageClients.spellCheckerClient) |
| 73 , m_deviceScaleFactor(1) | 77 , m_deviceScaleFactor(1) |
| 74 , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval()) | 78 , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval()) |
| 75 , m_visibilityState(PageVisibilityStateVisible) | 79 , m_visibilityState(PageVisibilityStateVisible) |
| 76 , m_isCursorVisible(true) | 80 , m_isCursorVisible(true) |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 { | 267 { |
| 264 RefPtr<LocalFrame> mainFrame = m_mainFrame; | 268 RefPtr<LocalFrame> mainFrame = m_mainFrame; |
| 265 | 269 |
| 266 mainFrame->detach(); | 270 mainFrame->detach(); |
| 267 mainFrame->setView(nullptr); | 271 mainFrame->setView(nullptr); |
| 268 | 272 |
| 269 #ifndef NDEBUG | 273 #ifndef NDEBUG |
| 270 pageCounter.decrement(); | 274 pageCounter.decrement(); |
| 271 #endif | 275 #endif |
| 272 | 276 |
| 273 m_chrome->willBeDestroyed(); | |
| 274 m_mainFrame = 0; | 277 m_mainFrame = 0; |
| 275 } | 278 } |
| 276 | 279 |
| 280 IntRect Page::rootViewToScreen(const IntRect& rect) const |
| 281 { |
| 282 return m_chromeClient->rootViewToScreen(rect); |
| 283 } |
| 284 |
| 285 blink::WebScreenInfo Page::screenInfo() const |
| 286 { |
| 287 return m_chromeClient->screenInfo(); |
| 288 } |
| 289 |
| 290 void Page::setWindowRect(const FloatRect& rect) const |
| 291 { |
| 292 m_chromeClient->setWindowRect(rect); |
| 293 } |
| 294 |
| 295 FloatRect Page::windowRect() const |
| 296 { |
| 297 return m_chromeClient->windowRect(); |
| 298 } |
| 299 |
| 300 void Page::focus() const |
| 301 { |
| 302 m_chromeClient->focus(); |
| 303 } |
| 304 |
| 305 bool Page::canTakeFocus(FocusType type) const |
| 306 { |
| 307 return m_chromeClient->canTakeFocus(type); |
| 308 } |
| 309 |
| 310 void Page::takeFocus(FocusType type) const |
| 311 { |
| 312 m_chromeClient->takeFocus(type); |
| 313 } |
| 314 |
| 315 void Page::focusedNodeChanged(Node* node) const |
| 316 { |
| 317 m_chromeClient->focusedNodeChanged(node); |
| 318 } |
| 319 |
| 320 void Page::focusedFrameChanged(LocalFrame* frame) const |
| 321 { |
| 322 m_chromeClient->focusedFrameChanged(frame); |
| 323 } |
| 324 |
| 325 void Page::scheduleVisualUpdate() |
| 326 { |
| 327 m_chromeClient->scheduleVisualUpdate(); |
| 328 } |
| 329 |
| 330 void Page::setCursor(const Cursor& cursor) |
| 331 { |
| 332 m_chromeClient->setCursor(cursor); |
| 333 } |
| 334 |
| 335 bool Page::shouldReportDetailedMessageForSource(const String& source) |
| 336 { |
| 337 return m_chromeClient->shouldReportDetailedMessageForSource(source); |
| 338 } |
| 339 |
| 340 void Page::addMessageToConsole(LocalFrame* localFrame, MessageSource source, Mes
sageLevel level, const String& message, unsigned lineNumber, const String& sourc
eID, const String& stackTrace) |
| 341 { |
| 342 m_chromeClient->addMessageToConsole(localFrame, source, level, message, line
Number, sourceID, stackTrace); |
| 343 } |
| 344 |
| 345 void* Page::webView() const |
| 346 { |
| 347 return m_chromeClient->webView(); |
| 348 } |
| 349 |
| 277 Page::PageClients::PageClients() | 350 Page::PageClients::PageClients() |
| 278 : chromeClient(0) | 351 : chromeClient(0) |
| 279 , editorClient(0) | 352 , editorClient(0) |
| 280 , spellCheckerClient(0) | 353 , spellCheckerClient(0) |
| 281 { | 354 { |
| 282 } | 355 } |
| 283 | 356 |
| 284 Page::PageClients::~PageClients() | 357 Page::PageClients::~PageClients() |
| 285 { | 358 { |
| 286 } | 359 } |
| 287 | 360 |
| 288 } // namespace blink | 361 } // namespace blink |
| OLD | NEW |