| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 m_spellCheckClient = spellCheckClient; | 143 m_spellCheckClient = spellCheckClient; |
| 144 } | 144 } |
| 145 | 145 |
| 146 WebViewImpl::WebViewImpl(WebViewClient* client) | 146 WebViewImpl::WebViewImpl(WebViewClient* client) |
| 147 : m_client(client) | 147 : m_client(client) |
| 148 , m_spellCheckClient(0) | 148 , m_spellCheckClient(0) |
| 149 , m_chromeClientImpl(this) | 149 , m_chromeClientImpl(this) |
| 150 , m_editorClientImpl(this) | 150 , m_editorClientImpl(this) |
| 151 , m_spellCheckerClientImpl(this) | 151 , m_spellCheckerClientImpl(this) |
| 152 , m_fixedLayoutSizeLock(false) | 152 , m_fixedLayoutSizeLock(false) |
| 153 , m_zoomLevel(0) | |
| 154 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) | |
| 155 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) | |
| 156 , m_doingDragAndDrop(false) | 153 , m_doingDragAndDrop(false) |
| 157 , m_ignoreInputEvents(false) | 154 , m_ignoreInputEvents(false) |
| 158 , m_compositorDeviceScaleFactorOverride(0) | 155 , m_compositorDeviceScaleFactorOverride(0) |
| 159 , m_rootLayerScale(1) | 156 , m_rootLayerScale(1) |
| 160 , m_suppressNextKeypressEvent(false) | 157 , m_suppressNextKeypressEvent(false) |
| 161 , m_imeAcceptEvents(true) | 158 , m_imeAcceptEvents(true) |
| 162 , m_isTransparent(false) | 159 , m_isTransparent(false) |
| 163 , m_tabsToLinks(false) | 160 , m_tabsToLinks(false) |
| 164 , m_layerTreeView(0) | 161 , m_layerTreeView(0) |
| 165 , m_rootLayer(0) | 162 , m_rootLayer(0) |
| 166 , m_rootGraphicsLayer(0) | 163 , m_rootGraphicsLayer(0) |
| 167 , m_rootTransformLayer(0) | 164 , m_rootTransformLayer(0) |
| 168 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this))) | 165 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this))) |
| 169 , m_isAcceleratedCompositingActive(false) | 166 , m_isAcceleratedCompositingActive(false) |
| 170 , m_layerTreeViewCommitsDeferred(false) | 167 , m_layerTreeViewCommitsDeferred(false) |
| 171 , m_layerTreeViewClosed(false) | 168 , m_layerTreeViewClosed(false) |
| 172 , m_matchesHeuristicsForGpuRasterization(false) | 169 , m_matchesHeuristicsForGpuRasterization(false) |
| 173 , m_recreatingGraphicsContext(false) | 170 , m_recreatingGraphicsContext(false) |
| 174 , m_flingModifier(0) | 171 , m_flingModifier(0) |
| 175 , m_flingSourceDevice(false) | 172 , m_flingSourceDevice(false) |
| 176 , m_showFPSCounter(false) | 173 , m_showFPSCounter(false) |
| 177 , m_showPaintRects(false) | 174 , m_showPaintRects(false) |
| 178 , m_showDebugBorders(false) | 175 , m_showDebugBorders(false) |
| 179 , m_continuousPaintingEnabled(false) | 176 , m_continuousPaintingEnabled(false) |
| 180 , m_showScrollBottleneckRects(false) | 177 , m_showScrollBottleneckRects(false) |
| 181 , m_baseBackgroundColor(Color::white) | 178 , m_baseBackgroundColor(Color::white) |
| 182 , m_backgroundColorOverride(Color::transparent) | 179 , m_backgroundColorOverride(Color::transparent) |
| 183 , m_zoomFactorOverride(0) | |
| 184 , m_userGestureObserved(false) | 180 , m_userGestureObserved(false) |
| 185 { | 181 { |
| 186 Page::PageClients pageClients; | 182 Page::PageClients pageClients; |
| 187 pageClients.chromeClient = &m_chromeClientImpl; | 183 pageClients.chromeClient = &m_chromeClientImpl; |
| 188 pageClients.editorClient = &m_editorClientImpl; | 184 pageClients.editorClient = &m_editorClientImpl; |
| 189 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; | 185 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; |
| 190 | 186 |
| 191 m_page = adoptPtr(new Page(pageClients, m_client->services())); | 187 m_page = adoptPtr(new Page(pageClients, m_client->services())); |
| 192 m_page->makeOrdinary(); | 188 m_page->makeOrdinary(); |
| 193 | 189 |
| (...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float&
newScale, IntPoint& newScroll, bool& needAnimation) | 1711 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float&
newScale, IntPoint& newScroll, bool& needAnimation) |
| 1716 { | 1712 { |
| 1717 //FIXME(sky) | 1713 //FIXME(sky) |
| 1718 } | 1714 } |
| 1719 | 1715 |
| 1720 void WebViewImpl::advanceFocus(bool reverse) | 1716 void WebViewImpl::advanceFocus(bool reverse) |
| 1721 { | 1717 { |
| 1722 page()->focusController().advanceFocus(reverse ? FocusTypeBackward : FocusTy
peForward); | 1718 page()->focusController().advanceFocus(reverse ? FocusTypeBackward : FocusTy
peForward); |
| 1723 } | 1719 } |
| 1724 | 1720 |
| 1725 double WebViewImpl::zoomLevel() | |
| 1726 { | |
| 1727 return m_zoomLevel; | |
| 1728 } | |
| 1729 | |
| 1730 double WebViewImpl::setZoomLevel(double zoomLevel) | |
| 1731 { | |
| 1732 if (zoomLevel < m_minimumZoomLevel) | |
| 1733 m_zoomLevel = m_minimumZoomLevel; | |
| 1734 else if (zoomLevel > m_maximumZoomLevel) | |
| 1735 m_zoomLevel = m_maximumZoomLevel; | |
| 1736 else | |
| 1737 m_zoomLevel = zoomLevel; | |
| 1738 | |
| 1739 LocalFrame* frame = mainFrameImpl()->frame(); | |
| 1740 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_cast
<float>(zoomLevelToZoomFactor(m_zoomLevel)); | |
| 1741 frame->setPageZoomFactor(zoomFactor); | |
| 1742 | |
| 1743 return m_zoomLevel; | |
| 1744 } | |
| 1745 | |
| 1746 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, | |
| 1747 double maximumZoomLevel) | |
| 1748 { | |
| 1749 m_minimumZoomLevel = minimumZoomLevel; | |
| 1750 m_maximumZoomLevel = maximumZoomLevel; | |
| 1751 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); | |
| 1752 } | |
| 1753 | |
| 1754 float WebViewImpl::textZoomFactor() | |
| 1755 { | |
| 1756 return mainFrameImpl()->frame()->textZoomFactor(); | |
| 1757 } | |
| 1758 | |
| 1759 float WebViewImpl::setTextZoomFactor(float textZoomFactor) | |
| 1760 { | |
| 1761 LocalFrame* frame = mainFrameImpl()->frame(); | |
| 1762 frame->setTextZoomFactor(textZoomFactor); | |
| 1763 return textZoomFactor; | |
| 1764 } | |
| 1765 | |
| 1766 double WebView::zoomLevelToZoomFactor(double zoomLevel) | |
| 1767 { | |
| 1768 return pow(textSizeMultiplierRatio, zoomLevel); | |
| 1769 } | |
| 1770 | |
| 1771 double WebView::zoomFactorToZoomLevel(double factor) | |
| 1772 { | |
| 1773 // Since factor = 1.2^level, level = log(factor) / log(1.2) | |
| 1774 return log(factor) / log(textSizeMultiplierRatio); | |
| 1775 } | |
| 1776 | |
| 1777 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) | 1721 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) |
| 1778 { | 1722 { |
| 1779 FrameView* view = mainFrameImpl()->frameView(); | 1723 FrameView* view = mainFrameImpl()->frameView(); |
| 1780 if (!view) | 1724 if (!view) |
| 1781 return offset; | 1725 return offset; |
| 1782 | 1726 |
| 1783 return view->clampOffsetAtScale(offset, scale); | 1727 return view->clampOffsetAtScale(offset, scale); |
| 1784 } | 1728 } |
| 1785 | 1729 |
| 1786 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin) | 1730 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1833 } | 1777 } |
| 1834 | 1778 |
| 1835 WebSize WebViewImpl::contentsPreferredMinimumSize() | 1779 WebSize WebViewImpl::contentsPreferredMinimumSize() |
| 1836 { | 1780 { |
| 1837 Document* document = m_page->mainFrame()->document(); | 1781 Document* document = m_page->mainFrame()->document(); |
| 1838 if (!document || !document->renderView() || !document->documentElement()) | 1782 if (!document || !document->renderView() || !document->documentElement()) |
| 1839 return WebSize(); | 1783 return WebSize(); |
| 1840 | 1784 |
| 1841 layout(); | 1785 layout(); |
| 1842 FontCachePurgePreventer fontCachePurgePreventer; // Required by minPreferred
LogicalWidth(). | 1786 FontCachePurgePreventer fontCachePurgePreventer; // Required by minPreferred
LogicalWidth(). |
| 1843 IntSize preferredMinimumSize(document->renderView()->minPreferredLogicalWidt
h(), document->documentElement()->scrollHeight()); | 1787 return IntSize(document->renderView()->minPreferredLogicalWidth(), document-
>documentElement()->scrollHeight()); |
| 1844 preferredMinimumSize.scale(zoomLevelToZoomFactor(zoomLevel())); | |
| 1845 return preferredMinimumSize; | |
| 1846 } | 1788 } |
| 1847 | 1789 |
| 1848 void WebViewImpl::resetScrollAndScaleState() | 1790 void WebViewImpl::resetScrollAndScaleState() |
| 1849 { | 1791 { |
| 1850 // FIXME(sky): Remove | 1792 // FIXME(sky): Remove |
| 1851 } | 1793 } |
| 1852 | 1794 |
| 1853 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize) | 1795 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize) |
| 1854 { | 1796 { |
| 1855 if (!page()) | 1797 if (!page()) |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2090 ASSERT(m_ignoreInputEvents != newValue); | 2032 ASSERT(m_ignoreInputEvents != newValue); |
| 2091 m_ignoreInputEvents = newValue; | 2033 m_ignoreInputEvents = newValue; |
| 2092 } | 2034 } |
| 2093 | 2035 |
| 2094 void WebViewImpl::setBackgroundColorOverride(WebColor color) | 2036 void WebViewImpl::setBackgroundColorOverride(WebColor color) |
| 2095 { | 2037 { |
| 2096 m_backgroundColorOverride = color; | 2038 m_backgroundColorOverride = color; |
| 2097 updateLayerTreeBackgroundColor(); | 2039 updateLayerTreeBackgroundColor(); |
| 2098 } | 2040 } |
| 2099 | 2041 |
| 2100 void WebViewImpl::setZoomFactorOverride(float zoomFactor) | |
| 2101 { | |
| 2102 m_zoomFactorOverride = zoomFactor; | |
| 2103 setZoomLevel(zoomLevel()); | |
| 2104 } | |
| 2105 | |
| 2106 void WebViewImpl::setOverlayLayer(GraphicsLayer* layer) | 2042 void WebViewImpl::setOverlayLayer(GraphicsLayer* layer) |
| 2107 { | 2043 { |
| 2108 if (!m_rootGraphicsLayer) | 2044 if (!m_rootGraphicsLayer) |
| 2109 return; | 2045 return; |
| 2110 | 2046 |
| 2111 // FIXME(bokan): This path goes away after virtual viewport pinch is enabled
everywhere. | 2047 // FIXME(bokan): This path goes away after virtual viewport pinch is enabled
everywhere. |
| 2112 if (!m_rootTransformLayer) | 2048 if (!m_rootTransformLayer) |
| 2113 m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compos
itor()->ensureRootTransformLayer(); | 2049 m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compos
itor()->ensureRootTransformLayer(); |
| 2114 | 2050 |
| 2115 if (m_rootTransformLayer) { | 2051 if (m_rootTransformLayer) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 m_layerTreeView->setVisible(visible); | 2293 m_layerTreeView->setVisible(visible); |
| 2358 } | 2294 } |
| 2359 } | 2295 } |
| 2360 | 2296 |
| 2361 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 2297 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 2362 { | 2298 { |
| 2363 return true; | 2299 return true; |
| 2364 } | 2300 } |
| 2365 | 2301 |
| 2366 } // namespace blink | 2302 } // namespace blink |
| OLD | NEW |