Skip to content

Commit dcf58ad

Browse files
committed
Make WebPageProxy keep track of the current device scale factor
The device scale factor is no longer considered part of WebPageProxy's "view state". It now has its own setter/getter. This made the code a little simpler and more similar to the page scale factor. Each port-specific WebKit2 view is now responsible for calling WebPageProxy::setDeviceScaleFactor whenever it thinks the device scale factor might have changed. Fixes <http://webkit.org/b/66466> WebKit2 requires every port-specific view to keep track of the current device scale factor Reviewed by Anders Carlsson. * UIProcess/API/efl/PageClientImpl.cpp: * UIProcess/API/efl/PageClientImpl.h: * UIProcess/API/gtk/PageClientImpl.h: * UIProcess/API/mac/PageClientImpl.h: * UIProcess/API/mac/PageClientImpl.mm: * UIProcess/PageClient.h: * UIProcess/qt/QtWebPageProxy.h: * UIProcess/win/WebView.h: Removed deviceScaleFactor. * UIProcess/API/mac/WKView.mm: (-[WKView _deviceScaleFactor]): Added. Code came from PageClientImpl::deviceScaleFactor. (-[WKView _windowDidChangeResolution:]): Changed to call WebPageProxy::setDeviceScaleFactor. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::WebPageProxy): Initialize m_deviceScaleFactor. (WebKit::WebPageProxy::viewStateDidChange): Removed device-scale-factor-related code. (WebKit::WebPageProxy::setDeviceScaleFactor): Added. Records the new device scale factor and tells the DrawingAreaProxy about it if it's actually changed. (WebKit::WebPageProxy::creationParameters): Use m_deviceScaleFactor instead of calling out to the PageClient. * UIProcess/WebPageProxy.h: Added m_deviceScaleFactor and setDeviceScaleFactor, which replaces the DeviceScaleFactor ViewStateFlag. (WebKit::WebPageProxy::deviceScaleFactor): Inlined this now-simple getter. Canonical link: https://commits.webkit.org/82310@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 1a2200e commit dcf58ad

12 files changed

Lines changed: 70 additions & 37 deletions

File tree

Source/WebKit2/ChangeLog

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
2011-08-18 Adam Roben <[email protected]>
2+
3+
Make WebPageProxy keep track of the current device scale factor
4+
5+
The device scale factor is no longer considered part of WebPageProxy's "view state". It now
6+
has its own setter/getter. This made the code a little simpler and more similar to the page
7+
scale factor. Each port-specific WebKit2 view is now responsible for calling
8+
WebPageProxy::setDeviceScaleFactor whenever it thinks the device scale factor might have
9+
changed.
10+
11+
Fixes <http://webkit.org/b/66466> WebKit2 requires every port-specific view to keep track of
12+
the current device scale factor
13+
14+
Reviewed by Anders Carlsson.
15+
16+
* UIProcess/API/efl/PageClientImpl.cpp:
17+
* UIProcess/API/efl/PageClientImpl.h:
18+
* UIProcess/API/gtk/PageClientImpl.h:
19+
* UIProcess/API/mac/PageClientImpl.h:
20+
* UIProcess/API/mac/PageClientImpl.mm:
21+
* UIProcess/PageClient.h:
22+
* UIProcess/qt/QtWebPageProxy.h:
23+
* UIProcess/win/WebView.h:
24+
Removed deviceScaleFactor.
25+
26+
* UIProcess/API/mac/WKView.mm:
27+
(-[WKView _deviceScaleFactor]): Added. Code came from PageClientImpl::deviceScaleFactor.
28+
(-[WKView _windowDidChangeResolution:]): Changed to call WebPageProxy::setDeviceScaleFactor.
29+
30+
* UIProcess/WebPageProxy.cpp:
31+
(WebKit::WebPageProxy::WebPageProxy): Initialize m_deviceScaleFactor.
32+
(WebKit::WebPageProxy::viewStateDidChange): Removed device-scale-factor-related code.
33+
(WebKit::WebPageProxy::setDeviceScaleFactor): Added. Records the new device scale factor and
34+
tells the DrawingAreaProxy about it if it's actually changed.
35+
(WebKit::WebPageProxy::creationParameters): Use m_deviceScaleFactor instead of calling out
36+
to the PageClient.
37+
38+
* UIProcess/WebPageProxy.h: Added m_deviceScaleFactor and setDeviceScaleFactor, which
39+
replaces the DeviceScaleFactor ViewStateFlag.
40+
(WebKit::WebPageProxy::deviceScaleFactor): Inlined this now-simple getter.
41+
142
2011-08-17 Adam Roben <[email protected]>
243

344
Make WebCore keep track of the current device scale factor

Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,4 @@ void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, Fin
255255
notImplemented();
256256
}
257257

258-
float PageClientImpl::deviceScaleFactor() const
259-
{
260-
return 0.0;
261-
}
262-
263258
} // namespace WebKit

Source/WebKit2/UIProcess/API/efl/PageClientImpl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ class PageClientImpl : public PageClient {
9898
virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
9999
virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);
100100

101-
virtual float deviceScaleFactor() const;
102-
103101
private:
104102
RefPtr<WebPageProxy> m_page;
105103
Evas_Object* m_viewObject;

Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class PageClientImpl : public PageClient {
8484
virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
8585
virtual void didChangeScrollbarsForMainFrame() const;
8686
virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
87-
virtual float deviceScaleFactor() const { return 1; }
8887
virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&);
8988
virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
9089
virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);

Source/WebKit2/UIProcess/API/mac/PageClientImpl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ class PageClientImpl : public PageClient {
120120
virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel);
121121
virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString);
122122

123-
virtual float deviceScaleFactor() const;
124-
125123
virtual WKView* wkView() const { return m_wkView; }
126124

127125
WKView* m_wkView;

Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -462,20 +462,6 @@ - (void)redoEditing:(id)sender
462462
#endif
463463
}
464464

465-
float PageClientImpl::deviceScaleFactor() const
466-
{
467-
NSWindow *window = [m_wkView window];
468-
#if !defined(BUILDING_ON_SNOW_LEOPARD)
469-
if (window)
470-
return [window backingScaleFactor];
471-
return [[NSScreen mainScreen] backingScaleFactor];
472-
#else
473-
if (window)
474-
return [window userSpaceScaleFactor];
475-
return [[NSScreen mainScreen] userSpaceScaleFactor];
476-
#endif
477-
}
478-
479465
bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
480466
{
481467
return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)];

Source/WebKit2/UIProcess/API/mac/WKView.mm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,9 +1836,23 @@ - (void)_windowDidOrderOnScreen:(NSNotification *)notification
18361836
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
18371837
}
18381838

1839+
- (float)_deviceScaleFactor
1840+
{
1841+
NSWindow *window = [self window];
1842+
#if !defined(BUILDING_ON_SNOW_LEOPARD)
1843+
if (window)
1844+
return [window backingScaleFactor];
1845+
return [[NSScreen mainScreen] backingScaleFactor];
1846+
#else
1847+
if (window)
1848+
return [window userSpaceScaleFactor];
1849+
return [[NSScreen mainScreen] userSpaceScaleFactor];
1850+
#endif
1851+
}
1852+
18391853
- (void)_windowDidChangeResolution:(NSNotification *)notification
18401854
{
1841-
_data->_page->viewStateDidChange(WebPageProxy::DeviceScaleFactor);
1855+
_data->_page->setDeviceScaleFactor([self _deviceScaleFactor]);
18421856
}
18431857

18441858
static void drawPageBackground(CGContextRef context, WebPageProxy* page, const IntRect& rect)

Source/WebKit2/UIProcess/PageClient.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ class PageClient {
185185
virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects) = 0;
186186
virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) = 0;
187187
virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) = 0;
188-
189-
virtual float deviceScaleFactor() const = 0;
190188
};
191189

192190
} // namespace WebKit

Source/WebKit2/UIProcess/WebPageProxy.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p
153153
, m_textZoomFactor(1)
154154
, m_pageZoomFactor(1)
155155
, m_pageScaleFactor(1)
156+
, m_deviceScaleFactor(1)
156157
, m_drawsBackground(true)
157158
, m_drawsTransparentBackground(false)
158159
, m_areMemoryCacheClientCallsEnabled(true)
@@ -682,9 +683,6 @@ void WebPageProxy::viewStateDidChange(ViewStateFlags flags)
682683
}
683684
}
684685

685-
if (flags & DeviceScaleFactor)
686-
m_drawingArea->deviceScaleFactorDidChange();
687-
688686
updateBackingStoreDiscardableState();
689687
}
690688

@@ -1217,9 +1215,16 @@ void WebPageProxy::scalePage(double scale, const IntPoint& origin)
12171215
process()->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
12181216
}
12191217

1220-
float WebPageProxy::deviceScaleFactor() const
1218+
void WebPageProxy::setDeviceScaleFactor(float scaleFactor)
12211219
{
1222-
return m_pageClient->deviceScaleFactor();
1220+
if (!isValid())
1221+
return;
1222+
1223+
if (m_deviceScaleFactor == scaleFactor)
1224+
return;
1225+
1226+
m_deviceScaleFactor = scaleFactor;
1227+
m_drawingArea->deviceScaleFactorDidChange();
12231228
}
12241229

12251230
void WebPageProxy::setUseFixedLayout(bool fixed)
@@ -3089,7 +3094,7 @@ WebPageCreationParameters WebPageProxy::creationParameters() const
30893094
parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID();
30903095
parameters.canRunBeforeUnloadConfirmPanel = m_uiClient.canRunBeforeUnloadConfirmPanel();
30913096
parameters.canRunModal = m_uiClient.canRunModal();
3092-
parameters.deviceScaleFactor = m_pageClient->deviceScaleFactor();
3097+
parameters.deviceScaleFactor = m_deviceScaleFactor;
30933098

30943099
#if PLATFORM(MAC)
30953100
parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;

Source/WebKit2/UIProcess/WebPageProxy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
274274
ViewIsFocused = 1 << 1,
275275
ViewIsVisible = 1 << 2,
276276
ViewIsInWindow = 1 << 3,
277-
DeviceScaleFactor = 1 << 4,
278277
};
279278
typedef unsigned ViewStateFlags;
280279
void viewStateDidChange(ViewStateFlags flags);
@@ -387,7 +386,8 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
387386
void scalePage(double scale, const WebCore::IntPoint& origin);
388387
double pageScaleFactor() const { return m_pageScaleFactor; }
389388

390-
float deviceScaleFactor() const;
389+
void setDeviceScaleFactor(float);
390+
float deviceScaleFactor() const { return m_deviceScaleFactor; }
391391

392392
void setUseFixedLayout(bool);
393393
void setFixedLayoutSize(const WebCore::IntSize&);
@@ -862,6 +862,7 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
862862
double m_textZoomFactor;
863863
double m_pageZoomFactor;
864864
double m_pageScaleFactor;
865+
float m_deviceScaleFactor;
865866

866867
bool m_drawsBackground;
867868
bool m_drawsTransparentBackground;

0 commit comments

Comments
 (0)