Skip to content

Commit a3fb12e

Browse files
committed
https://bugs.webkit.org/show_bug.cgi?id=67150
Would like API to use a custom device scale factor for a particular WebView/WKView -and corresponding- <rdar://problem/10041016> Reviewed by Darin Adler. Source/WebKit/mac: New API is _setOverrideBackingScaleFactor:(CGFloat) * WebView/WebView.mm: (-[WebView _setOverrideBackingScaleFactor:]): (-[WebView _deviceScaleFactor]): * WebView/WebViewData.h: * WebView/WebViewPrivate.h: Source/WebKit2: New API is setOverrideBackingScaleFactor() on WKPage * UIProcess/API/C/WKPage.cpp: (WKPageGetOverrideBackingScaleFactor): (WKPageSetOverrideBackingScaleFactor): * UIProcess/API/C/WKPage.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::WebPageProxy): (WebKit::WebPageProxy::deviceScaleFactor): (WebKit::WebPageProxy::setOverrideBackingScaleFactor): * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::overrideBackingScaleFactor): Canonical link: https://commits.webkit.org/83050@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@94122 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent e16662b commit a3fb12e

9 files changed

Lines changed: 96 additions & 1 deletion

File tree

Source/WebKit/mac/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2011-08-30 Beth Dakin <bdakin@apple.com>
2+
3+
https://bugs.webkit.org/show_bug.cgi?id=67150
4+
Would like API to use a custom device scale factor for a particular WebView/WKView
5+
-and corresponding-
6+
<rdar://problem/10041016>
7+
8+
Reviewed by Darin Adler.
9+
10+
New API is _setOverrideBackingScaleFactor:(CGFloat)
11+
* WebView/WebView.mm:
12+
(-[WebView _setOverrideBackingScaleFactor:]):
13+
(-[WebView _deviceScaleFactor]):
14+
* WebView/WebViewData.h:
15+
* WebView/WebViewPrivate.h:
16+
117
2011-08-30 Aaron Colwell <acolwell@chromium.org>
218

319
Add MediaSource API to HTMLMediaElement

Source/WebKit/mac/WebView/WebView.mm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,6 +2793,16 @@ - (NSSize)_fixedLayoutSize
27932793
return view->fixedLayoutSize();
27942794
}
27952795

2796+
- (void)_setOverrideBackingScaleFactor:(CGFloat)overrideScaleFactor
2797+
{
2798+
float oldScaleFactor = [self _deviceScaleFactor];
2799+
2800+
_private->overrideBackingScaleFactor = overrideScaleFactor;
2801+
2802+
if (oldScaleFactor != [self _deviceScaleFactor])
2803+
_private->page->setDeviceScaleFactor(overrideScaleFactor);
2804+
}
2805+
27962806
- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit
27972807
{
27982808
return [self countMatchesForText:string options:(caseFlag ? 0 : WebFindOptionsCaseInsensitive) highlight:highlight limit:limit markMatches:YES];
@@ -5520,6 +5530,9 @@ @implementation WebView (WebFileInternal)
55205530

55215531
- (float)_deviceScaleFactor
55225532
{
5533+
if (_private->overrideBackingScaleFactor != 0)
5534+
return _private->overrideBackingScaleFactor;
5535+
55235536
NSWindow *window = [self window];
55245537
#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
55255538
if (window)

Source/WebKit/mac/WebView/WebViewData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,7 @@ extern int pluginDatabaseClientCount;
193193

194194
BOOL interactiveFormValidationEnabled;
195195
int validationMessageTimerMagnification;
196+
197+
float overrideBackingScaleFactor;
196198
}
197199
@end

Source/WebKit/mac/WebView/WebViewPrivate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,8 @@ Could be worth adding to the API.
549549
- (BOOL)_useFixedLayout;
550550
- (NSSize)_fixedLayoutSize;
551551

552+
- (void)_setOverrideBackingScaleFactor:(CGFloat)overrideScaleFactor;
553+
552554
// Deprecated. Use the methods in pending public above instead.
553555
- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit;
554556
- (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches;

Source/WebKit2/ChangeLog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2011-08-30 Beth Dakin <bdakin@apple.com>
2+
3+
https://bugs.webkit.org/show_bug.cgi?id=67150
4+
Would like API to use a custom device scale factor for a particular WebView/WKView
5+
-and corresponding-
6+
<rdar://problem/10041016>
7+
8+
Reviewed by Darin Adler.
9+
10+
New API is setOverrideBackingScaleFactor() on WKPage
11+
* UIProcess/API/C/WKPage.cpp:
12+
(WKPageGetOverrideBackingScaleFactor):
13+
(WKPageSetOverrideBackingScaleFactor):
14+
* UIProcess/API/C/WKPage.h:
15+
* UIProcess/WebPageProxy.cpp:
16+
(WebKit::WebPageProxy::WebPageProxy):
17+
(WebKit::WebPageProxy::deviceScaleFactor):
18+
(WebKit::WebPageProxy::setOverrideBackingScaleFactor):
19+
* UIProcess/WebPageProxy.h:
20+
(WebKit::WebPageProxy::overrideBackingScaleFactor):
21+
122
2011-08-30 Aaron Colwell <acolwell@chromium.org>
223

324
Add MediaSource API to HTMLMediaElement

Source/WebKit2/UIProcess/API/C/WKPage.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,16 @@ double WKPageGetTextZoomFactor(WKPageRef pageRef)
258258
return toImpl(pageRef)->textZoomFactor();
259259
}
260260

261+
double WKPageGetOverrideBackingScaleFactor(WKPageRef pageRef)
262+
{
263+
return toImpl(pageRef)->overrideBackingScaleFactor();
264+
}
265+
266+
void WKPageSetOverrideBackingScaleFactor(WKPageRef pageRef, double overrideScaleFactor)
267+
{
268+
toImpl(pageRef)->setOverrideBackingScaleFactor(overrideScaleFactor);
269+
}
270+
261271
bool WKPageSupportsTextZoom(WKPageRef pageRef)
262272
{
263273
return toImpl(pageRef)->supportsTextZoom();

Source/WebKit2/UIProcess/API/C/WKPage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ typedef bool (*WKPageSessionStateFilterCallback)(WKPageRef page, WKStringRef val
349349
WK_EXPORT WKDataRef WKPageCopySessionState(WKPageRef page, void* context, WKPageSessionStateFilterCallback urlAllowedCallback);
350350
WK_EXPORT void WKPageRestoreFromSessionState(WKPageRef page, WKDataRef sessionStateData);
351351

352+
WK_EXPORT double WKPageGetOverrideBackingScaleFactor(WKPageRef page);
353+
WK_EXPORT void WKPageSetOverrideBackingScaleFactor(WKPageRef page, double overrideScaleFactor);
354+
352355
WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page);
353356
WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page);
354357
WK_EXPORT void WKPageSetTextZoomFactor(WKPageRef page, double zoomFactor);

Source/WebKit2/UIProcess/WebPageProxy.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p
145145
, m_pageZoomFactor(1)
146146
, m_pageScaleFactor(1)
147147
, m_deviceScaleFactor(1)
148+
, m_overrideBackingScaleFactor(0)
148149
, m_drawsBackground(true)
149150
, m_drawsTransparentBackground(false)
150151
, m_areMemoryCacheClientCallsEnabled(true)
@@ -1118,6 +1119,29 @@ void WebPageProxy::setDeviceScaleFactor(float scaleFactor)
11181119
m_drawingArea->deviceScaleFactorDidChange();
11191120
}
11201121

1122+
float WebPageProxy::deviceScaleFactor() const
1123+
{
1124+
if (m_overrideBackingScaleFactor)
1125+
return m_overrideBackingScaleFactor;
1126+
return m_deviceScaleFactor;
1127+
}
1128+
1129+
void WebPageProxy::setOverrideBackingScaleFactor(float overrideScaleFactor)
1130+
{
1131+
if (!isValid())
1132+
return;
1133+
1134+
if (m_overrideBackingScaleFactor == overrideScaleFactor)
1135+
return;
1136+
1137+
float oldScaleFactor = deviceScaleFactor();
1138+
1139+
m_overrideBackingScaleFactor = overrideScaleFactor;
1140+
1141+
if (deviceScaleFactor() != oldScaleFactor)
1142+
m_drawingArea->deviceScaleFactorDidChange();
1143+
}
1144+
11211145
void WebPageProxy::setUseFixedLayout(bool fixed)
11221146
{
11231147
if (!isValid())

Source/WebKit2/UIProcess/WebPageProxy.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
387387
double pageScaleFactor() const { return m_pageScaleFactor; }
388388

389389
void setDeviceScaleFactor(float);
390-
float deviceScaleFactor() const { return m_deviceScaleFactor; }
390+
float deviceScaleFactor() const;
391+
392+
void setOverrideBackingScaleFactor(float);
393+
float overrideBackingScaleFactor() const { return m_overrideBackingScaleFactor; }
391394

392395
void setUseFixedLayout(bool);
393396
void setFixedLayoutSize(const WebCore::IntSize&);
@@ -860,6 +863,7 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
860863
double m_pageZoomFactor;
861864
double m_pageScaleFactor;
862865
float m_deviceScaleFactor;
866+
float m_overrideBackingScaleFactor;
863867

864868
bool m_drawsBackground;
865869
bool m_drawsTransparentBackground;

0 commit comments

Comments
 (0)