Changeset 31180 in webkit
- Timestamp:
- Mar 20, 2008, 10:22:05 AM (17 years ago)
- Location:
- trunk/WebKit/win
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/win/ChangeLog
r31179 r31180 1 2008-03-20 Dave Hyatt <hyatt@apple.com> 2 3 Add full page zoom API for Windows WebKit. 4 5 Reviewed by aroben 6 7 * Interfaces/IWebView.idl: 8 * WebView.cpp: 9 (WebView::WebView): 10 (WebView::setTextSizeMultiplier): 11 (WebView::setPageSizeMultiplier): 12 (WebView::setZoomMultiplier): 13 (WebView::textSizeMultiplier): 14 (WebView::pageSizeMultiplier): 15 (WebView::zoomMultiplier): 16 (WebView::canMakeTextLarger): 17 (WebView::canZoomPageIn): 18 (WebView::canZoomIn): 19 (WebView::makeTextLarger): 20 (WebView::zoomPageIn): 21 (WebView::zoomIn): 22 (WebView::canMakeTextSmaller): 23 (WebView::canZoomPageOut): 24 (WebView::canZoomOut): 25 (WebView::makeTextSmaller): 26 (WebView::zoomPageOut): 27 (WebView::zoomOut): 28 (WebView::canMakeTextStandardSize): 29 (WebView::canResetPageZoom): 30 (WebView::canResetZoom): 31 (WebView::makeTextStandardSize): 32 (WebView::resetPageZoom): 33 (WebView::resetZoom): 34 * WebView.h: 35 1 36 2008-03-20 John Sullivan <sullivan@apple.com> 2 37 -
trunk/WebKit/win/Interfaces/IWebView.idl
r30180 r31180 816 816 */ 817 817 HRESULT toggleGrammarChecking([in] IUnknown* sender); 818 819 /*! 820 @method setPageSizeMultiplier: 821 @abstract Set a zoom factor for all views managed by this webView. 822 @param multiplier A fractional percentage value, 1.0 is 100%. 823 - (void)setPageSizeMultiplier:(float)multiplier; 824 */ 825 HRESULT setPageSizeMultiplier([in] float multiplier); 826 827 /*! 828 @method pageSizeMultiplier 829 @result The page size multipler. 830 - (float)pageSizeMultiplier; 831 */ 832 HRESULT pageSizeMultiplier([out, retval] float* multiplier); 833 834 /* 835 - (BOOL)canZoomPageIn; 836 */ 837 HRESULT canZoomPageIn([in] IUnknown* sender, [out, retval] BOOL* result); 838 839 /* 840 - (IBAction)zoomPageIn:(id)sender; 841 */ 842 HRESULT zoomPageIn([in] IUnknown* sender); 843 844 /* 845 - (BOOL)canZoomPageOut; 846 */ 847 HRESULT canZoomPageOut([in] IUnknown* sender, [out, retval] BOOL* result); 848 849 /* 850 - (IBAction)zoomPageOut:(id)sender; 851 */ 852 HRESULT zoomPageOut([in] IUnknown* sender); 853 854 /* 855 - (BOOL)canResetPageZoom; 856 */ 857 HRESULT canResetPageZoom([in] IUnknown* sender, [out, retval] BOOL* result); 858 859 /* 860 - (IBAction)resetPageZoom:(id)sender; 861 */ 862 HRESULT resetPageZoom([in] IUnknown* sender); 818 863 } 819 864 -
trunk/WebKit/win/WebView.cpp
r31156 r31180 252 252 , m_useBackForwardList(true) 253 253 , m_userAgentOverridden(false) 254 , m_textSizeMultiplier(1) 254 , m_zoomMultiplier(1.0f) 255 , m_zoomMultiplierIsTextOnly(true) 255 256 , m_mouseActivated(false) 256 257 , m_dragData(0) … … 2384 2385 /* [in] */ float multiplier) 2385 2386 { 2386 if (m_textSizeMultiplier != multiplier)2387 m_textSizeMultiplier = multiplier;2388 2389 2387 if (!m_mainFrame) 2390 2388 return E_FAIL; 2391 2392 m_mainFrame->setTextSizeMultiplier(multiplier); 2393 return S_OK; 2389 setZoomMultiplier(multiplier, true); 2390 return S_OK; 2391 } 2392 2393 HRESULT STDMETHODCALLTYPE WebView::setPageSizeMultiplier( 2394 /* [in] */ float multiplier) 2395 { 2396 if (!m_mainFrame) 2397 return E_FAIL; 2398 setZoomMultiplier(multiplier, false); 2399 return S_OK; 2400 } 2401 2402 void WebView::setZoomMultiplier(float multiplier, bool isTextOnly) 2403 { 2404 m_zoomMultiplier = multiplier; 2405 m_zoomMultiplierIsTextOnly = isTextOnly; 2406 if (Frame* coreFrame = core(m_mainFrame)) 2407 coreFrame->setZoomFactor(multiplier, isTextOnly); 2394 2408 } 2395 2409 … … 2397 2411 /* [retval][out] */ float* multiplier) 2398 2412 { 2399 *multiplier = m_textSizeMultiplier; 2400 return S_OK; 2413 *multiplier = zoomMultiplier(true); 2414 return S_OK; 2415 } 2416 2417 HRESULT STDMETHODCALLTYPE WebView::pageSizeMultiplier( 2418 /* [retval][out] */ float* multiplier) 2419 { 2420 *multiplier = zoomMultiplier(false); 2421 return S_OK; 2422 } 2423 2424 float WebView::zoomMultiplier(bool isTextOnly) 2425 { 2426 if (isTextOnly != m_zoomMultiplierIsTextOnly) 2427 return 1.0f; 2428 return m_zoomMultiplier; 2401 2429 } 2402 2430 … … 3071 3099 } 3072 3100 3073 #define MinimumTextSizeMultiplier 0.5f 3074 #define MaximumTextSizeMultiplier 3.0f 3075 #define TextSizeMultiplierRatio 1.2f 3101 // FIXME: This code should move into WebCore so it can be shared by all the WebKits. 3102 #define MinimumZoomMultiplier 0.5f 3103 #define MaximumZoomMultiplier 3.0f 3104 #define ZoomMultiplierRatio 1.2f 3076 3105 3077 3106 HRESULT STDMETHODCALLTYPE WebView::canMakeTextLarger( … … 3079 3108 /* [retval][out] */ BOOL* result) 3080 3109 { 3081 bool canGrowMore = m_textSizeMultiplier*TextSizeMultiplierRatio < MaximumTextSizeMultiplier;3110 bool canGrowMore = canZoomIn(true); 3082 3111 *result = canGrowMore ? TRUE : FALSE; 3083 3112 return S_OK; 3113 } 3114 3115 HRESULT STDMETHODCALLTYPE WebView::canZoomPageIn( 3116 /* [in] */ IUnknown* /*sender*/, 3117 /* [retval][out] */ BOOL* result) 3118 { 3119 bool canGrowMore = canZoomIn(false); 3120 *result = canGrowMore ? TRUE : FALSE; 3121 return S_OK; 3122 } 3123 3124 bool WebView::canZoomIn(bool isTextOnly) 3125 { 3126 return zoomMultiplier(isTextOnly) * ZoomMultiplierRatio < MaximumZoomMultiplier; 3084 3127 } 3085 3128 … … 3087 3130 /* [in] */ IUnknown* /*sender*/) 3088 3131 { 3089 float newScale = m_textSizeMultiplier*TextSizeMultiplierRatio; 3090 bool canGrowMore = newScale < MaximumTextSizeMultiplier; 3091 if (!canGrowMore) 3132 return canZoomIn(true); 3133 } 3134 3135 HRESULT STDMETHODCALLTYPE WebView::zoomPageIn( 3136 /* [in] */ IUnknown* /*sender*/) 3137 { 3138 return canZoomIn(false); 3139 } 3140 3141 HRESULT WebView::zoomIn(bool isTextOnly) 3142 { 3143 if (!canZoomIn(isTextOnly)) 3092 3144 return E_FAIL; 3093 return setTextSizeMultiplier(newScale);3094 3095 } 3096 3145 setZoomMultiplier(zoomMultiplier(isTextOnly) * ZoomMultiplierRatio, isTextOnly); 3146 return S_OK; 3147 } 3148 3097 3149 HRESULT STDMETHODCALLTYPE WebView::canMakeTextSmaller( 3098 3150 /* [in] */ IUnknown* /*sender*/, 3099 3151 /* [retval][out] */ BOOL* result) 3100 3152 { 3101 bool canShrinkMore = m_textSizeMultiplier/TextSizeMultiplierRatio > MinimumTextSizeMultiplier;3153 bool canShrinkMore = canZoomOut(true); 3102 3154 *result = canShrinkMore ? TRUE : FALSE; 3103 3155 return S_OK; 3156 } 3157 3158 HRESULT STDMETHODCALLTYPE WebView::canZoomPageOut( 3159 /* [in] */ IUnknown* /*sender*/, 3160 /* [retval][out] */ BOOL* result) 3161 { 3162 bool canShrinkMore = canZoomOut(false); 3163 *result = canShrinkMore ? TRUE : FALSE; 3164 return S_OK; 3165 } 3166 3167 bool WebView::canZoomOut(bool isTextOnly) 3168 { 3169 return zoomMultiplier(isTextOnly) / ZoomMultiplierRatio > MinimumZoomMultiplier; 3104 3170 } 3105 3171 … … 3107 3173 /* [in] */ IUnknown* /*sender*/) 3108 3174 { 3109 float newScale = m_textSizeMultiplier/TextSizeMultiplierRatio; 3110 bool canShrinkMore = newScale > MinimumTextSizeMultiplier; 3111 if (!canShrinkMore) 3175 return zoomOut(true); 3176 } 3177 3178 HRESULT STDMETHODCALLTYPE WebView::zoomPageOut( 3179 /* [in] */ IUnknown* /*sender*/) 3180 { 3181 return zoomOut(false); 3182 } 3183 3184 HRESULT WebView::zoomOut(bool isTextOnly) 3185 { 3186 if (!canZoomOut(isTextOnly)) 3112 3187 return E_FAIL; 3113 return setTextSizeMultiplier(newScale); 3188 setZoomMultiplier(zoomMultiplier(isTextOnly) / ZoomMultiplierRatio, isTextOnly); 3189 return S_OK; 3114 3190 } 3115 3191 … … 3118 3194 /* [retval][out] */ BOOL* result) 3119 3195 { 3120 bool notAlreadyStandard = m_textSizeMultiplier != 1.0f;3196 bool notAlreadyStandard = canResetZoom(true); 3121 3197 *result = notAlreadyStandard ? TRUE : FALSE; 3122 3198 return S_OK; 3199 } 3200 3201 HRESULT STDMETHODCALLTYPE WebView::canResetPageZoom( 3202 /* [in] */ IUnknown* /*sender*/, 3203 /* [retval][out] */ BOOL* result) 3204 { 3205 bool notAlreadyStandard = canResetZoom(false); 3206 *result = notAlreadyStandard ? TRUE : FALSE; 3207 return S_OK; 3208 } 3209 3210 bool WebView::canResetZoom(bool isTextOnly) 3211 { 3212 return zoomMultiplier(isTextOnly) != 1.0f; 3123 3213 } 3124 3214 … … 3126 3216 /* [in] */ IUnknown* /*sender*/) 3127 3217 { 3128 bool notAlreadyStandard = m_textSizeMultiplier != 1.0f; 3129 if (notAlreadyStandard) 3130 return setTextSizeMultiplier(1.0f); 3218 return resetZoom(true); 3219 } 3220 3221 HRESULT STDMETHODCALLTYPE WebView::resetPageZoom( 3222 /* [in] */ IUnknown* /*sender*/) 3223 { 3224 return resetZoom(false); 3225 } 3226 3227 HRESULT WebView::resetZoom(bool isTextOnly) 3228 { 3229 if (!canResetZoom(isTextOnly)) 3230 return E_FAIL; 3231 setZoomMultiplier(1.0f, isTextOnly); 3131 3232 return S_OK; 3132 3233 } -
trunk/WebKit/win/WebView.h
r31156 r31180 437 437 virtual HRESULT STDMETHODCALLTYPE setGrammarCheckingEnabled( 438 438 BOOL enabled); 439 440 virtual HRESULT STDMETHODCALLTYPE setPageSizeMultiplier( 441 /* [in] */ float multiplier); 442 443 virtual HRESULT STDMETHODCALLTYPE pageSizeMultiplier( 444 /* [retval][out] */ float *multiplier); 445 446 virtual HRESULT STDMETHODCALLTYPE canZoomPageIn( 447 /* [in] */ IUnknown *sender, 448 /* [retval][out] */ BOOL *result); 449 450 virtual HRESULT STDMETHODCALLTYPE zoomPageIn( 451 /* [in] */ IUnknown *sender); 452 453 virtual HRESULT STDMETHODCALLTYPE canZoomPageOut( 454 /* [in] */ IUnknown *sender, 455 /* [retval][out] */ BOOL *result); 456 457 virtual HRESULT STDMETHODCALLTYPE zoomPageOut( 458 /* [in] */ IUnknown *sender); 459 460 virtual HRESULT STDMETHODCALLTYPE canResetPageZoom( 461 /* [in] */ IUnknown *sender, 462 /* [retval][out] */ BOOL *result); 463 464 virtual HRESULT STDMETHODCALLTYPE resetPageZoom( 465 /* [in] */ IUnknown *sender); 439 466 440 467 // IWebViewUndoableEditing … … 716 743 void updateActiveState(); 717 744 745 private: 746 void setZoomMultiplier(float multiplier, bool isTextOnly); 747 float zoomMultiplier(bool isTextOnly); 748 bool canZoomIn(bool isTextOnly); 749 HRESULT zoomIn(bool isTextOnly); 750 bool canZoomOut(bool isTextOnly); 751 HRESULT zoomOut(bool isTextOnly); 752 bool canResetZoom(bool isTextOnly); 753 HRESULT resetZoom(bool isTextOnly); 754 718 755 protected: 719 756 HIMC getIMMContext(); … … 763 800 WebCore::String m_userAgentCustom; 764 801 WebCore::String m_userAgentStandard; 765 float m_textSizeMultiplier; 802 float m_zoomMultiplier; 803 bool m_zoomMultiplierIsTextOnly; 766 804 WebCore::String m_overrideEncoding; 767 805 WebCore::String m_applicationName;
Note:
See TracChangeset
for help on using the changeset viewer.