OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "core/dom/DOMImplementation.h" | 37 #include "core/dom/DOMImplementation.h" |
38 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
39 #include "core/fetch/CSSStyleSheetResource.h" | 39 #include "core/fetch/CSSStyleSheetResource.h" |
40 #include "core/fetch/FontResource.h" | 40 #include "core/fetch/FontResource.h" |
41 #include "core/fetch/ImageResource.h" | 41 #include "core/fetch/ImageResource.h" |
42 #include "core/fetch/MemoryCache.h" | 42 #include "core/fetch/MemoryCache.h" |
43 #include "core/fetch/Resource.h" | 43 #include "core/fetch/Resource.h" |
44 #include "core/fetch/ResourceFetcher.h" | 44 #include "core/fetch/ResourceFetcher.h" |
45 #include "core/fetch/ScriptResource.h" | 45 #include "core/fetch/ScriptResource.h" |
46 #include "core/frame/FrameHost.h" | 46 #include "core/frame/FrameHost.h" |
| 47 #include "core/frame/FrameView.h" |
47 #include "core/frame/LocalFrame.h" | 48 #include "core/frame/LocalFrame.h" |
48 #include "core/frame/Settings.h" | 49 #include "core/frame/Settings.h" |
| 50 #include "core/frame/VisualViewport.h" |
49 #include "core/html/HTMLFrameOwnerElement.h" | 51 #include "core/html/HTMLFrameOwnerElement.h" |
50 #include "core/html/VoidCallback.h" | 52 #include "core/html/VoidCallback.h" |
51 #include "core/html/imports/HTMLImportLoader.h" | 53 #include "core/html/imports/HTMLImportLoader.h" |
52 #include "core/html/imports/HTMLImportsController.h" | 54 #include "core/html/imports/HTMLImportsController.h" |
53 #include "core/html/parser/TextResourceDecoder.h" | 55 #include "core/html/parser/TextResourceDecoder.h" |
54 #include "core/inspector/DOMPatchSupport.h" | 56 #include "core/inspector/DOMPatchSupport.h" |
55 #include "core/inspector/IdentifiersFactory.h" | 57 #include "core/inspector/IdentifiersFactory.h" |
56 #include "core/inspector/InspectedFrames.h" | 58 #include "core/inspector/InspectedFrames.h" |
57 #include "core/inspector/InspectorCSSAgent.h" | 59 #include "core/inspector/InspectorCSSAgent.h" |
58 #include "core/inspector/InspectorInstrumentation.h" | 60 #include "core/inspector/InspectorInstrumentation.h" |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 | 853 |
852 void InspectorPageAgent::setBlockedEventsWarningThreshold(ErrorString*, | 854 void InspectorPageAgent::setBlockedEventsWarningThreshold(ErrorString*, |
853 double threshold) { | 855 double threshold) { |
854 m_state->setDouble(PageAgentState::blockedEventsWarningThreshold, threshold); | 856 m_state->setDouble(PageAgentState::blockedEventsWarningThreshold, threshold); |
855 FrameHost* host = m_inspectedFrames->root()->host(); | 857 FrameHost* host = m_inspectedFrames->root()->host(); |
856 if (!host) | 858 if (!host) |
857 return; | 859 return; |
858 host->settings().setBlockedMainThreadEventsWarningThreshold(threshold); | 860 host->settings().setBlockedMainThreadEventsWarningThreshold(threshold); |
859 } | 861 } |
860 | 862 |
| 863 void InspectorPageAgent::getLayoutMetrics( |
| 864 ErrorString*, |
| 865 std::unique_ptr<protocol::Page::LayoutViewport>* outLayoutViewport, |
| 866 std::unique_ptr<protocol::Page::VisualViewport>* outVisualViewport) { |
| 867 LocalFrame* mainFrame = m_inspectedFrames->root(); |
| 868 VisualViewport& visualViewport = mainFrame->host()->visualViewport(); |
| 869 |
| 870 mainFrame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 871 |
| 872 IntRect visibleContents = mainFrame->view()->visibleContentRect(); |
| 873 *outLayoutViewport = protocol::Page::LayoutViewport::create() |
| 874 .setPageX(visibleContents.x()) |
| 875 .setPageY(visibleContents.y()) |
| 876 .setClientWidth(visibleContents.width()) |
| 877 .setClientHeight(visibleContents.height()) |
| 878 .build(); |
| 879 |
| 880 FrameView* frameView = mainFrame->view(); |
| 881 ScrollOffset pageOffset = frameView->getScrollableArea()->scrollOffset(); |
| 882 float pageZoom = mainFrame->pageZoomFactor(); |
| 883 FloatRect visibleRect = visualViewport.visibleRect(); |
| 884 float scale = visualViewport.scale(); |
| 885 float scrollbarWidth = frameView->verticalScrollbarWidth() / scale; |
| 886 float scrollbarHeight = frameView->horizontalScrollbarHeight() / scale; |
| 887 |
| 888 *outVisualViewport = |
| 889 protocol::Page::VisualViewport::create() |
| 890 .setOffsetX(adjustScrollForAbsoluteZoom(visibleRect.x(), pageZoom)) |
| 891 .setOffsetY(adjustScrollForAbsoluteZoom(visibleRect.y(), pageZoom)) |
| 892 .setPageX(adjustScrollForAbsoluteZoom(pageOffset.width(), pageZoom)) |
| 893 .setPageY(adjustScrollForAbsoluteZoom(pageOffset.height(), pageZoom)) |
| 894 .setClientWidth(visibleRect.width() - scrollbarWidth) |
| 895 .setClientHeight(visibleRect.height() - scrollbarHeight) |
| 896 .setScale(scale) |
| 897 .build(); |
| 898 } |
| 899 |
861 DEFINE_TRACE(InspectorPageAgent) { | 900 DEFINE_TRACE(InspectorPageAgent) { |
862 visitor->trace(m_inspectedFrames); | 901 visitor->trace(m_inspectedFrames); |
863 visitor->trace(m_inspectorResourceContentLoader); | 902 visitor->trace(m_inspectorResourceContentLoader); |
864 InspectorBaseAgent::trace(visitor); | 903 InspectorBaseAgent::trace(visitor); |
865 } | 904 } |
866 | 905 |
867 } // namespace blink | 906 } // namespace blink |
OLD | NEW |