Changeset 68869 in webkit
- Timestamp:
- Oct 1, 2010 12:32:27 AM (14 years ago)
- Location:
- trunk/WebKit/chromium
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/chromium/ChangeLog
r68865 r68869 1 2010-09-29 John Abd-El-Malek <jam@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 [chromium] Changes to consolidate plugin zoom 6 https://bugs.webkit.org/show_bug.cgi?id=46550 7 8 * public/WebPlugin.h: 9 (WebKit::WebPlugin::setZoomLevel): 10 * public/WebPluginContainer.h: 11 * public/WebView.h: 12 * public/WebViewClient.h: 13 (WebKit::WebViewClient::zoomLimitsChanged): 14 (WebKit::WebViewClient::zoomLevelChanged): 15 * src/FrameLoaderClientImpl.cpp: 16 (WebKit::FrameLoaderClientImpl::createPlugin): 17 * src/WebPluginContainerImpl.cpp: 18 (WebKit::WebPluginContainerImpl::loadFrameRequest): 19 (WebKit::WebPluginContainerImpl::zoomChanged): 20 (WebKit::WebPluginContainerImpl::zoomLimitsChanged): 21 * src/WebPluginContainerImpl.h: 22 * src/WebViewImpl.cpp: 23 (WebKit::WebViewImpl::WebViewImpl): 24 (WebKit::WebViewImpl::zoomLevel): 25 (WebKit::WebViewImpl::setZoomLevel): 26 (WebKit::WebViewImpl::zoomLimitsChanged): 27 (WebKit::WebViewImpl::fullFramePluginZoomLevelChanged): 28 (WebKit::WebView::zoomLevelToZoomFactor): 29 (WebKit::WebView::zoomFactorToZoomLevel): 30 * src/WebViewImpl.h: 31 1 32 2010-09-30 MORITA Hajime <morrita@google.com> 2 33 -
trunk/WebKit/chromium/public/WebPlugin.h
r63330 r68869 100 100 101 101 // Used for zooming of full page plugins. 102 virtual void setZoom Factor(float scale, bool textOnly) { }102 virtual void setZoomLevel(double level, bool textOnly) { } 103 103 104 104 // Find interface. -
trunk/WebKit/chromium/public/WebPluginContainer.h
r61942 r68869 79 79 const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData) = 0; 80 80 81 // Notifies that the zoom level has changed. 82 virtual void zoomLevelChanged(double zoomLevel) = 0; 83 81 84 virtual WebPlugin* plugin() = 0; 82 85 virtual void setPlugin(WebPlugin*) = 0; -
trunk/WebKit/chromium/public/WebView.h
r68367 r68869 37 37 #include "WebWidget.h" 38 38 39 // FIXME(jam): take this out after Chrome is updated 40 #define ZOOM_LEVEL_IS_DOUBLE 41 39 42 namespace WebKit { 40 43 … … 55 58 class WebView : public WebWidget { 56 59 public: 60 WEBKIT_API static const double textSizeMultiplierRatio; 61 WEBKIT_API static const double minTextSizeMultiplier; 62 WEBKIT_API static const double maxTextSizeMultiplier; 63 57 64 // Controls the time that user scripts injected into the document run. 58 65 enum UserScriptInjectAt { … … 162 169 163 170 // Returns the current zoom level. 0 is "original size", and each increment 164 // above or below represents zooming 20% larger or smaller to limits of 300% 165 // and 50% of original size, respectively. 166 virtual int zoomLevel() = 0; 171 // above or below represents zooming 20% larger or smaller to default limits 172 // of 300% and 50% of original size, respectively. Only plugins use 173 // non whole-numbers, since they might choose to have specific zoom level so 174 // that fixed-width content is fit-to-page-width, for example. 175 virtual double zoomLevel() = 0; 167 176 168 177 // Changes the zoom level to the specified level, clamping at the limits … … 174 183 // at one time. Changing the mode while the page is zoomed will have odd 175 184 // effects. 176 virtual int setZoomLevel(bool textOnly, int zoomLevel) = 0; 185 virtual double setZoomLevel(bool textOnly, double zoomLevel) = 0; 186 187 // Updates the zoom limits for this view. 188 virtual void zoomLimitsChanged(double minimumZoomLevel, 189 double maximumZoomLevel) = 0; 190 191 // Helper functions to convert between zoom level and zoom factor. zoom 192 // factor is zoom percent / 100, so 300% = 3.0. 193 WEBKIT_API static double zoomLevelToZoomFactor(double zoomLevel); 194 WEBKIT_API static double zoomFactorToZoomLevel(double factor); 177 195 178 196 -
trunk/WebKit/chromium/public/WebViewClient.h
r68240 r68869 349 349 virtual WebDeviceOrientationClient* deviceOrientationClient() { return 0; } 350 350 351 352 // Zoom ---------------------------------------------------------------- 353 354 // Informs the browser that the zoom levels for this frame have changed from 355 // the default values. 356 virtual void zoomLimitsChanged(double minimumLevel, double maximumLevel) { } 357 358 // Informs the browser that the zoom level has changed as a result of an 359 // action that wasn't initiated by the client. 360 virtual void zoomLevelChanged() { } 361 351 362 protected: 352 363 ~WebViewClient() { } -
trunk/WebKit/chromium/src/FrameLoaderClientImpl.cpp
r68576 r68869 1412 1412 return 0; 1413 1413 1414 bool zoomTextOnly = m_webFrame->viewImpl()->zoomTextOnly();1415 float zoomFactor = zoomTextOnly ? m_webFrame->frame()->textZoomFactor() : m_webFrame->frame()->pageZoomFactor();1416 if (zoomFactor != 1) {1417 // There's a saved zoom level, so tell the plugin about it since1418 // WebViewImpl::setZoomLevel was called before the plugin was created.1419 webPlugin->setZoomFactor(zoomFactor, zoomTextOnly);1420 }1421 1422 1414 // The element might have been removed during plugin initialization! 1423 1415 if (!element->renderer()) -
trunk/WebKit/chromium/src/WebPluginContainerImpl.cpp
r68656 r68869 49 49 #include "WebURLRequest.h" 50 50 #include "WebVector.h" 51 #include "WebViewImpl.h" 51 52 #include "WrappedResourceResponse.h" 52 53 … … 349 350 } 350 351 352 void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel) 353 { 354 WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->page()); 355 view->fullFramePluginZoomLevelChanged(zoomLevel); 356 } 357 351 358 void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response) 352 359 { -
trunk/WebKit/chromium/src/WebPluginContainerImpl.h
r62743 r68869 84 84 virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed); 85 85 virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData); 86 virtual void zoomLevelChanged(double zoomLevel); 86 87 87 88 // This cannot be null. -
trunk/WebKit/chromium/src/WebViewImpl.cpp
r68865 r68869 147 147 // text zoom to half and 3x the original text size. These three values match 148 148 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm 149 static const double textSizeMultiplierRatio = 1.2; 150 static const double minTextSizeMultiplier = 0.5; 151 static const double maxTextSizeMultiplier = 3.0; 149 const double WebView::textSizeMultiplierRatio = 1.2; 150 const double WebView::minTextSizeMultiplier = 0.5; 151 const double WebView::maxTextSizeMultiplier = 3.0; 152 152 153 153 154 // The group name identifies a namespace of pages. Page group is used on OSX … … 254 255 #endif 255 256 , m_zoomLevel(0) 256 , m_zoomTextOnly(false) 257 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) 258 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) 257 259 , m_contextMenuAllowed(false) 258 260 , m_doingDragAndDrop(false) … … 1528 1530 } 1529 1531 1530 intWebViewImpl::zoomLevel()1532 double WebViewImpl::zoomLevel() 1531 1533 { 1532 1534 return m_zoomLevel; 1533 1535 } 1534 1536 1535 int WebViewImpl::setZoomLevel(bool textOnly, int zoomLevel) 1536 { 1537 float zoomFactor = static_cast<float>( 1538 std::max(std::min(std::pow(textSizeMultiplierRatio, zoomLevel), 1539 maxTextSizeMultiplier), 1540 minTextSizeMultiplier)); 1537 double WebViewImpl::setZoomLevel(bool textOnly, double zoomLevel) 1538 { 1539 if (zoomLevel < m_minimumZoomLevel) 1540 m_zoomLevel = m_minimumZoomLevel; 1541 else if (zoomLevel > m_maximumZoomLevel) 1542 m_zoomLevel = m_maximumZoomLevel; 1543 else 1544 m_zoomLevel = zoomLevel; 1545 1541 1546 Frame* frame = mainFrameImpl()->frame(); 1542 1543 float oldZoomFactor = m_zoomTextOnly ? frame->textZoomFactor() : frame->pageZoomFactor(); 1544 1545 if (textOnly) 1546 frame->setPageAndTextZoomFactors(1, zoomFactor); 1547 else 1548 frame->setPageAndTextZoomFactors(zoomFactor, 1); 1549 1550 if (oldZoomFactor != zoomFactor || textOnly != m_zoomTextOnly) { 1551 WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame); 1552 if (pluginContainer) 1553 pluginContainer->plugin()->setZoomFactor(zoomFactor, textOnly); 1554 } 1555 1556 m_zoomLevel = zoomLevel; 1557 m_zoomTextOnly = textOnly; 1558 1547 WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame); 1548 if (pluginContainer) 1549 pluginContainer->plugin()->setZoomLevel(m_zoomLevel, textOnly); 1550 else { 1551 double zoomFactor = zoomLevelToZoomFactor(m_zoomLevel); 1552 if (textOnly) 1553 frame->setPageAndTextZoomFactors(1, zoomFactor); 1554 else 1555 frame->setPageAndTextZoomFactors(zoomFactor, 1); 1556 } 1559 1557 return m_zoomLevel; 1558 } 1559 1560 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, 1561 double maximumZoomLevel) 1562 { 1563 m_minimumZoomLevel = minimumZoomLevel; 1564 m_maximumZoomLevel = maximumZoomLevel; 1565 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); 1566 } 1567 1568 void WebViewImpl::fullFramePluginZoomLevelChanged(double zoomLevel) 1569 { 1570 if (zoomLevel == m_zoomLevel) 1571 return; 1572 1573 m_zoomLevel = std::max(std::min(zoomLevel, m_maximumZoomLevel), m_minimumZoomLevel); 1574 m_client->zoomLevelChanged(); 1575 } 1576 1577 double WebView::zoomLevelToZoomFactor(double zoomLevel) 1578 { 1579 return std::pow(textSizeMultiplierRatio, zoomLevel); 1580 } 1581 1582 double WebView::zoomFactorToZoomLevel(double factor) 1583 { 1584 // Since factor = 1.2^level, level = log(factor) / log(1.2) 1585 return log(factor) / log(textSizeMultiplierRatio); 1560 1586 } 1561 1587 -
trunk/WebKit/chromium/src/WebViewImpl.h
r68865 r68869 133 133 virtual void setInitialFocus(bool reverse); 134 134 virtual void clearFocusedNode(); 135 virtual int zoomLevel(); 136 virtual int setZoomLevel(bool textOnly, int zoomLevel); 135 virtual double zoomLevel(); 136 virtual double setZoomLevel(bool textOnly, double zoomLevel); 137 virtual void zoomLimitsChanged(double minimumZoomLevel, 138 double maximumZoomLevel); 137 139 virtual void performMediaPlayerAction( 138 140 const WebMediaPlayerAction& action, … … 343 345 WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); } 344 346 345 bool zoomTextOnly() const { return m_zoomTextOnly; }346 347 347 // Returns true if the event leads to scrolling. 348 348 static bool mapKeyCodeForScroll(int keyCode, 349 349 WebCore::ScrollDirection* scrollDirection, 350 350 WebCore::ScrollGranularity* scrollGranularity); 351 352 // Called by a full frame plugin inside this view to inform it that its 353 // zoom level has been updated. The plugin should only call this function 354 // if the zoom change was triggered by the browser, it's only needed in case 355 // a plugin can update its own zoom, say because of its own UI. 356 void fullFramePluginZoomLevelChanged(double zoomLevel); 351 357 352 358 private: … … 441 447 // Keeps track of the current zoom level. 0 means no zoom, positive numbers 442 448 // mean zoom in, negative numbers mean zoom out. 443 int m_zoomLevel; 444 445 bool m_zoomTextOnly; 449 double m_zoomLevel; 450 451 double m_minimumZoomLevel; 452 453 double m_maximumZoomLevel; 446 454 447 455 bool m_contextMenuAllowed;
Note: See TracChangeset
for help on using the changeset viewer.