Diff
Modified: trunk/Source/WebCore/ChangeLog (187244 => 187245)
--- trunk/Source/WebCore/ChangeLog 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebCore/ChangeLog 2015-07-23 19:30:02 UTC (rev 187245)
@@ -1,3 +1,29 @@
+2015-07-23 Brent Fulgham <[email protected]>
+
+ [Win] Implement High DPI support features
+ https://bugs.webkit.org/show_bug.cgi?id=146335
+ <rdar://problem/21558269>
+
+ Reviewed by Alex Christensen.
+
+ * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
+ (WebCore::PlatformCALayerWinInternal::drawTile): Don't translate the CGContext to the position
+ of the CACFLayerRef; the underlying context is already in the right position.
+ * platform/win/PlatformMouseEventWin.cpp: Update class to adjust mouse
+ event coordinates based on scaling factor.
+ (WebCore::deviceScaleFactor):
+ (WebCore::positionForEvent):
+ * platform/win/ScrollbarThemeWin.cpp:
+ (WebCore::scrollbarThicknessInPixels):
+ (WebCore::ScrollbarThemeWin::scrollbarThickness):
+ (WebCore::ScrollbarThemeWin::themeChanged):
+ * platform/win/WheelEventWin.cpp: Update class to adjust wheel event
+ coordinates based on scaling factor.
+ (WebCore::deviceScaleFactor):
+ (WebCore::positionForEvent):
+ (WebCore::globalPositionForEvent):
+ (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+
2015-07-23 Myles C. Maxfield <[email protected]>
REGRESSION(r182236): Justified Arabic text does not expand
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (187244 => 187245)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-07-23 19:30:02 UTC (rev 187245)
@@ -8122,6 +8122,7 @@
<ClCompile Include="..\platform\win\EventLoopWin.cpp" />
<ClCompile Include="..\platform\win\FileSystemWin.cpp" />
<ClCompile Include="..\platform\win\GDIObjectCounter.cpp" />
+ <ClCompile Include="..\platform\win\GDIUtilities.cpp" />
<ClCompile Include="..\platform\win\ImportedFunctionsEnumerator.cpp" />
<ClCompile Include="..\platform\win\ImportedModulesEnumerator.cpp" />
<ClCompile Include="..\platform\win\KeyEventWin.cpp" />
@@ -20235,6 +20236,7 @@
<ClInclude Include="..\platform\win\DefWndProcWindowClass.h" />
<ClInclude Include="..\platform\win\DelayLoadedModulesEnumerator.h" />
<ClInclude Include="..\platform\win\GDIObjectCounter.h" />
+ <ClInclude Include="..\platform\win\GDIUtilities.h" />
<ClInclude Include="..\platform\win\HWndDC.h" />
<ClInclude Include="..\platform\win\ImportedFunctionsEnumerator.h" />
<ClInclude Include="..\platform\win\ImportedModulesEnumerator.h" />
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (187244 => 187245)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2015-07-23 19:30:02 UTC (rev 187245)
@@ -7269,6 +7269,9 @@
<ClCompile Include="..\platform\graphics\PathUtilities.cpp">
<Filter>platform\graphics</Filter>
</ClCompile>
+ <ClCompile Include="..\platform\win\GDIUtilities.cpp">
+ <Filter>platform\graphics\win</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Modules\geolocation\Coordinates.h">
@@ -15258,6 +15261,9 @@
<ClInclude Include="..\platform\graphics\PathUtilities.h">
<Filter>platform\graphics</Filter>
</ClInclude>
+ <ClInclude Include="..\platform\win\GDIUtilities.h">
+ <Filter>platform\graphics\win</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\css\CSSGrammar.y.in">
Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp (187244 => 187245)
--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -512,9 +512,6 @@
CGContextSaveGState(context);
- // Transform context to be at the origin of the parent layer
- CGContextTranslateCTM(context, -tilePosition.x, -tilePosition.y);
-
// Set the context clipping rectangle to the current tile
CGContextClipToRect(context, CGRectMake(tilePosition.x, tilePosition.y, tileBounds.size.width, tileBounds.size.height));
Added: trunk/Source/WebCore/platform/win/GDIUtilities.cpp (0 => 187245)
--- trunk/Source/WebCore/platform/win/GDIUtilities.cpp (rev 0)
+++ trunk/Source/WebCore/platform/win/GDIUtilities.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) 2015 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "config.h"
+#include "GDIUtilities.h"
+
+#include "HWndDC.h"
+
+namespace WebCore {
+
+float deviceScaleFactorForWindow(HWND window)
+{
+ HWndDC dc(window);
+ return ::GetDeviceCaps(dc, LOGPIXELSX) / 96.0f;
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/platform/win/GDIUtilities.h (0 => 187245)
--- trunk/Source/WebCore/platform/win/GDIUtilities.h (rev 0)
+++ trunk/Source/WebCore/platform/win/GDIUtilities.h 2015-07-23 19:30:02 UTC (rev 187245)
@@ -0,0 +1,37 @@
+/*
+* Copyright (C) 2015 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef GDIUtilties_h
+#define GDIUtilties_h
+
+#include <windows.h>
+
+namespace WebCore {
+
+WEBCORE_EXPORT float deviceScaleFactorForWindow(HWND);
+
+} // namespace WebCore
+
+#endif // GDIUtilties_h
Modified: trunk/Source/WebCore/platform/win/PlatformMouseEventWin.cpp (187244 => 187245)
--- trunk/Source/WebCore/platform/win/PlatformMouseEventWin.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebCore/platform/win/PlatformMouseEventWin.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2015 Apple Inc. All rights reserved.
* Copyright (C) 2007-2008 Torch Mobile Inc.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,8 +27,11 @@
#include "config.h"
#include "PlatformMouseEvent.h"
+#include "GDIUtilities.h"
+#include "HWndDC.h"
#include <wtf/Assertions.h>
#include <wtf/CurrentTime.h>
+#include <wtf/MathExtras.h>
#include <windows.h>
#include <windowsx.h>
@@ -38,7 +41,9 @@
static IntPoint positionForEvent(HWND hWnd, LPARAM lParam)
{
- POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
+ IntPoint point(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+ float inverseScaleFactor = 1.0f / deviceScaleFactorForWindow(hWnd);
+ point.scale(inverseScaleFactor, inverseScaleFactor);
return point;
}
Modified: trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp (187244 => 187245)
--- trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -26,7 +26,9 @@
#include "config.h"
#include "ScrollbarThemeWin.h"
+#include "GDIUtilities.h"
#include "GraphicsContext.h"
+#include "HWndDC.h"
#include "LocalWindowsContext.h"
#include "PlatformMouseEvent.h"
#include "Scrollbar.h"
@@ -107,14 +109,18 @@
{
}
-int ScrollbarThemeWin::scrollbarThickness(ScrollbarControlSize)
+static int scrollbarThicknessInPixels()
{
- static int thickness;
- if (!thickness)
- thickness = ::GetSystemMetrics(SM_CXVSCROLL);
+ static int thickness = ::GetSystemMetrics(SM_CXVSCROLL);
return thickness;
}
+int ScrollbarThemeWin::scrollbarThickness(ScrollbarControlSize)
+{
+ float inverseScaleFactor = 1.0f / deviceScaleFactorForWindow(0);
+ return clampTo<int>(inverseScaleFactor * scrollbarThicknessInPixels());
+}
+
void ScrollbarThemeWin::themeChanged()
{
if (!scrollbarTheme)
Modified: trunk/Source/WebCore/platform/win/WheelEventWin.cpp (187244 => 187245)
--- trunk/Source/WebCore/platform/win/WheelEventWin.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebCore/platform/win/WheelEventWin.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -28,6 +28,8 @@
#include "FloatPoint.h"
#include "FloatSize.h"
+#include "GDIUtilities.h"
+#include "HWndDC.h"
#include <windows.h>
#include <windowsx.h>
@@ -40,13 +42,18 @@
{
POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
ScreenToClient(hWnd, &point);
- return point;
+ IntPoint logicalPoint(point);
+ float inverseScaleFactor = 1.0f / deviceScaleFactorForWindow(hWnd);
+ logicalPoint.scale(inverseScaleFactor, inverseScaleFactor);
+ return logicalPoint;
}
static IntPoint globalPositionForEvent(HWND hWnd, LPARAM lParam)
{
- POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
- return point;
+ IntPoint logicalPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+ float inverseScaleFactor = 1.0f / deviceScaleFactorForWindow(hWnd);
+ logicalPoint.scale(inverseScaleFactor, inverseScaleFactor);
+ return logicalPoint;
}
static int horizontalScrollChars()
@@ -77,11 +84,14 @@
// Global Position is just x, y location of event
POINT point = {location.x(), location.y()};
+ float inverseScaleFactor = 1.0f / deviceScaleFactorForWindow(hWnd);
m_globalPosition = point;
+ m_globalPosition.scale(inverseScaleFactor, inverseScaleFactor);
// Position needs to be translated to our client
ScreenToClient(hWnd, &point);
m_position = point;
+ m_position.scale(inverseScaleFactor, inverseScaleFactor);
}
PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
@@ -90,6 +100,8 @@
, m_globalPosition(globalPositionForEvent(hWnd, lParam))
, m_directionInvertedFromDevice(false)
{
+ float scaleFactor = deviceScaleFactorForWindow(hWnd);
+
// How many pixels should we scroll per line? Gecko uses the height of the
// current line, which means scroll distance changes as you go through the
// page or go to different pages. IE 7 is ~50 px/line, although the value
@@ -97,8 +109,8 @@
// smoothing algorithm on scrolling, it can get away with slightly larger
// scroll values without feeling jerky. Here we use 100 px per three lines
// (the default scroll amount on Windows is three lines per wheel tick).
- static const float cScrollbarPixelsPerLine = 100.0f / 3.0f;
- float delta = GET_WHEEL_DELTA_WPARAM(wParam) / static_cast<float>(WHEEL_DELTA);
+ static const float cScrollbarPixelsPerLine = scaleFactor * 100.0f / 3.0f;
+ float delta = GET_WHEEL_DELTA_WPARAM(wParam) / (scaleFactor * static_cast<float>(WHEEL_DELTA));
if (isMouseHWheel) {
// Windows is <-- -/+ -->, WebKit wants <-- +/- -->, so we negate
// |delta| after saving the original value on the wheel tick member.
Modified: trunk/Source/WebKit/win/ChangeLog (187244 => 187245)
--- trunk/Source/WebKit/win/ChangeLog 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebKit/win/ChangeLog 2015-07-23 19:30:02 UTC (rev 187245)
@@ -1,3 +1,37 @@
+2015-07-23 Brent Fulgham <[email protected]>
+
+ [Win] Implement High DPI support features
+ https://bugs.webkit.org/show_bug.cgi?id=146335
+ <rdar://problem/21558269>
+
+ Reviewed by Alex Christensen.
+
+ * WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebFrameLoaderClient::transitionToCommittedForNewPage): Size
+ page for current device scale factor.
+ * WebFrame.cpp:
+ (WebFrame::paintDocumentRectToContext): Account for device scale factor.
+ (WebFrame::paintScrollViewRectToContextAtPoint): Ditto.
+ * WebView.cpp:
+ (WebView::repaint): Adjust paint rect for device scale factor.
+ (WebView::scrollBackingStore): Adjust coordinates for scale factor.
+ (WebView::sizeChanged): Ditto.
+ (WebView::updateBackingStore): Ditto.
+ (WebView::paint): Ditto.
+ (WebView::paintIntoBackingStore): Ditto.
+ (WebView::handleContextMenuEvent): Ditto.
+ (WebView::gestureNotify): Ditto.
+ (WebView::gesture): Ditto.
+ (WebView::initializeToolTipWindow): Adjust max tool tip width
+ for device scale factor.
+ (WebView::selectionRect): Adjust coordinates for scale factor.
+ (WebView::elementAtPoint): Ditto.
+ (WebView::scrollOffset): Ditto.
+ (WebView::scrollBy): Ditto.
+ (WebView::visibleContentRect): Ditto.
+ (WebView::paintContents): Ditto.
+ * WebView.h:
+
2015-07-23 Sungmann Cho <[email protected]>
[Win] Fix typos in PluginViewWin.cpp: kWebPluginViewdowClassName -> kWebPluginViewClassName
Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp (187244 => 187245)
--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -1017,11 +1017,13 @@
{
WebView* view = m_webFrame->webView();
- RECT rect;
- view->frameRect(&rect);
+ RECT pixelRect;
+ view->frameRect(&pixelRect);
bool transparent = view->transparent();
Color backgroundColor = transparent ? Color::transparent : Color::white;
- core(m_webFrame)->createView(IntRect(rect).size(), backgroundColor, transparent);
+ IntRect logicalFrame(pixelRect);
+ logicalFrame.scale(1.0f / view->deviceScaleFactor());
+ core(m_webFrame)->createView(logicalFrame.size(), backgroundColor, transparent);
}
void WebFrameLoaderClient::didSaveToPageCache()
Modified: trunk/Source/WebKit/win/WebFrame.cpp (187244 => 187245)
--- trunk/Source/WebKit/win/WebFrame.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebKit/win/WebFrame.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -336,6 +336,8 @@
dirtyRect.setHeight(height);
gc.clip(dirtyRect);
gc.translate(-rect.left, -rect.top);
+ float scaleFactor = webView()->deviceScaleFactor();
+ gc.scale(WebCore::FloatSize(scaleFactor, scaleFactor));
view->paintContents(&gc, rect);
gc.restore();
@@ -360,6 +362,8 @@
gc.save();
IntRect dirtyRect(rect);
dirtyRect.move(-pt.x, -pt.y);
+ float scaleFactor = webView()->deviceScaleFactor();
+ gc.scale(WebCore::FloatSize(scaleFactor, scaleFactor));
view->paint(&gc, dirtyRect);
gc.restore();
Modified: trunk/Source/WebKit/win/WebPreferences.cpp (187244 => 187245)
--- trunk/Source/WebKit/win/WebPreferences.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebKit/win/WebPreferences.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -194,7 +194,7 @@
CFMutableDictionaryRef defaults = CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(defaults, CFSTR(WebKitStandardFontPreferenceKey), CFSTR("Segoe UI"));
+ CFDictionaryAddValue(defaults, CFSTR(WebKitStandardFontPreferenceKey), CFSTR("Times New Roman"));
CFDictionaryAddValue(defaults, CFSTR(WebKitFixedFontPreferenceKey), CFSTR("Courier New"));
CFDictionaryAddValue(defaults, CFSTR(WebKitSerifFontPreferenceKey), CFSTR("Times New Roman"));
CFDictionaryAddValue(defaults, CFSTR(WebKitSansSerifFontPreferenceKey), CFSTR("Arial"));
Modified: trunk/Source/WebKit/win/WebView.cpp (187244 => 187245)
--- trunk/Source/WebKit/win/WebView.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebKit/win/WebView.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -107,6 +107,7 @@
#include <WebCore/FrameWin.h>
#include <WebCore/FullScreenController.h>
#include <WebCore/GDIObjectCounter.h>
+#include <WebCore/GDIUtilities.h>
#include <WebCore/GeolocationController.h>
#include <WebCore/GeolocationError.h>
#include <WebCore/GraphicsContext.h>
@@ -364,6 +365,7 @@
const int WM_XP_THEMECHANGED = 0x031A;
const int WM_VISTA_MOUSEHWHEEL = 0x020E;
+const int WM_DPICHANGED = 0x02E0;
static const int maxToolTipWidth = 250;
@@ -822,8 +824,11 @@
return S_OK;
}
-void WebView::repaint(const WebCore::IntRect& windowRect, bool contentChanged, bool immediate, bool repaintContentOnly)
+void WebView::repaint(const WebCore::IntRect& logicalWindowRect, bool contentChanged, bool immediate, bool repaintContentOnly)
{
+ WebCore::IntRect windowRect(logicalWindowRect);
+ windowRect.scale(deviceScaleFactor());
+
if (isAcceleratedCompositing()) {
// The contentChanged, immediate, and repaintContentOnly parameters are all based on a non-
// compositing painting/scrolling model.
@@ -921,10 +926,19 @@
m_uiDelegatePrivate->webViewDidInvalidate(this);
}
-void WebView::scrollBackingStore(FrameView* frameView, int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect)
+void WebView::scrollBackingStore(FrameView* frameView, int logicalDx, int logicalDy, const IntRect& logicalScrollViewRect, const IntRect& logicalClipRect)
{
m_needsDisplay = true;
+ // Dimensions passed to us from WebCore are in logical units. We must convert to pixels:
+ float scaleFactor = deviceScaleFactor();
+ int dx = clampTo<int>(scaleFactor * logicalDx);
+ int dy = clampTo<int>(scaleFactor * logicalDy);
+ IntRect scrollViewRect(logicalScrollViewRect);
+ scrollViewRect.scale(scaleFactor);
+ IntRect clipRect(logicalClipRect);
+ clipRect.scale(scaleFactor);
+
if (isAcceleratedCompositing()) {
// FIXME: We should be doing something smarter here, like moving tiles around and painting
// any newly-exposed tiles. <http://webkit.org/b/52714>
@@ -953,7 +967,7 @@
HWndDC windowDC(m_viewWindow);
auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(windowDC));
HGDIOBJ oldBitmap = ::SelectObject(bitmapDC.get(), m_backingStoreBitmap->get());
-
+
// Scroll the bitmap.
RECT scrollRectWin(scrollViewRect);
RECT clipRectWin(clipRect);
@@ -983,8 +997,11 @@
deleteBackingStore();
- if (Frame* coreFrame = core(topLevelFrame()))
- coreFrame->view()->resize(newSize);
+ if (Frame* coreFrame = core(topLevelFrame())) {
+ IntSize logicalSize = newSize;
+ logicalSize.scale(1.0f / deviceScaleFactor());
+ coreFrame->view()->resize(logicalSize);
+ }
#if USE(CA)
if (m_layerTreeHost)
@@ -1000,6 +1017,16 @@
#endif
}
+bool WebView::dpiChanged(float, const WebCore::IntSize& newSize)
+{
+ if (!IsProcessDPIAware())
+ return false;
+
+ sizeChanged(newSize);
+
+ return true;
+}
+
// This emulates the Mac smarts for painting rects intelligently. This is very
// important for us, since we double buffer based off dirty rects.
static void getUpdateRects(HRGN region, const IntRect& dirtyRect, Vector<IntRect>& rects)
@@ -1212,7 +1239,7 @@
deleteBackingStoreSoon();
}
-void WebView::paintIntoBackingStore(FrameView* frameView, HDC bitmapDC, const IntRect& dirtyRect, WindowsToPaint windowsToPaint)
+void WebView::paintIntoBackingStore(FrameView* frameView, HDC bitmapDC, const IntRect& dirtyRectPixels, WindowsToPaint windowsToPaint)
{
// FIXME: This function should never be called in accelerated compositing mode, and we should
// assert as such. But currently it *is* sometimes called, so we can't assert yet. See
@@ -1224,7 +1251,7 @@
// but it was being hit during our layout tests, and is being investigated in
// http://webkit.org/b/29350.
- RECT rect = dirtyRect;
+ RECT rect = dirtyRectPixels;
#if FLASH_BACKING_STORE_REDRAW
{
@@ -1233,15 +1260,21 @@
FillRect(dc, &rect, yellowBrush.get());
GdiFlush();
Sleep(50);
- paintIntoWindow(bitmapDC, dc, dirtyRect);
+ paintIntoWindow(bitmapDC, dc, dirtyRectPixels);
}
#endif
+ float scaleFactor = deviceScaleFactor();
+ float inverseScaleFactor = 1.0f / scaleFactor;
+
+ IntRect logicalDirtyRect = dirtyRectPixels;
+ logicalDirtyRect.scale(inverseScaleFactor);
+
GraphicsContext gc(bitmapDC, m_transparent);
gc.setShouldIncludeChildWindows(windowsToPaint == PaintWebViewAndChildren);
gc.save();
if (m_transparent)
- gc.clearRect(dirtyRect);
+ gc.clearRect(logicalDirtyRect);
else
FillRect(bitmapDC, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
@@ -1250,15 +1283,18 @@
uiPrivate->drawBackground(this, bitmapDC, &rect);
if (frameView && frameView->frame().contentRenderer()) {
- gc.clip(dirtyRect);
- frameView->paint(&gc, dirtyRect);
+ gc.save();
+ gc.scale(FloatSize(scaleFactor, scaleFactor));
+ gc.clip(logicalDirtyRect);
+ frameView->paint(&gc, logicalDirtyRect);
+ gc.restore();
if (m_shouldInvertColors)
- gc.fillRect(dirtyRect, Color::white, ColorSpaceDeviceRGB, CompositeDifference);
+ gc.fillRect(logicalDirtyRect, Color::white, ColorSpaceDeviceRGB, CompositeDifference);
}
gc.restore();
}
-void WebView::paintIntoWindow(HDC bitmapDC, HDC windowDC, const IntRect& dirtyRect)
+void WebView::paintIntoWindow(HDC bitmapDC, HDC windowDC, const IntRect& dirtyRectPixels)
{
// FIXME: This function should never be called in accelerated compositing mode, and we should
// assert as such. But currently it *is* sometimes called, so we can't assert yet. See
@@ -1267,7 +1303,7 @@
LOCAL_GDI_COUNTER(0, __FUNCTION__);
#if FLASH_WINDOW_REDRAW
auto greenBrush = adoptGDIObject(::CreateSolidBrush(RGB(0, 255, 0)));
- RECT rect = dirtyRect;
+ RECT rect = dirtyRectPixels;
FillRect(windowDC, &rect, greenBrush.get());
GdiFlush();
Sleep(50);
@@ -1275,8 +1311,8 @@
// Blit the dirty rect from the backing store into the same position
// in the destination DC.
- BitBlt(windowDC, dirtyRect.x(), dirtyRect.y(), dirtyRect.width(), dirtyRect.height(), bitmapDC,
- dirtyRect.x(), dirtyRect.y(), SRCCOPY);
+ BitBlt(windowDC, dirtyRectPixels.x(), dirtyRectPixels.y(), dirtyRectPixels.width(), dirtyRectPixels.height(), bitmapDC,
+ dirtyRectPixels.x(), dirtyRectPixels.y(), SRCCOPY);
m_needsDisplay = false;
}
@@ -1423,9 +1459,15 @@
lParam = MAKELPARAM(coords.x, coords.y);
+ // Convert coordinates to logical pixels
+ float scaleFactor = deviceScaleFactor();
+ float inverseScaleFactor = 1.0f / scaleFactor;
+ IntPoint logicalCoords(coords);
+ logicalCoords.scale(inverseScaleFactor, inverseScaleFactor);
+
m_page->contextMenuController().clearContextMenu();
- IntPoint documentPoint(m_page->mainFrame().view()->windowToContents(coords));
+ IntPoint documentPoint(m_page->mainFrame().view()->windowToContents(logicalCoords));
HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(documentPoint);
Frame* targetFrame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document().frame() : &m_page->focusController().focusedOrMainFrame();
@@ -1450,9 +1492,11 @@
if (!view)
return false;
- POINT point(view->contentsToWindow(contextMenuController.hitTestResult().roundedPointInInnerNodeFrame()));
+ IntPoint logicalPoint = view->contentsToWindow(contextMenuController.hitTestResult().roundedPointInInnerNodeFrame());
+ logicalPoint.scale(scaleFactor, scaleFactor);
// Translate the point to screen coordinates
+ POINT point = logicalPoint;
if (!::ClientToScreen(m_viewWindow, &point))
return false;
@@ -1645,6 +1689,12 @@
bool hitScrollbar = false;
POINT gestureBeginPoint = {gn->ptsLocation.x, gn->ptsLocation.y};
+
+ float scaleFactor = deviceScaleFactor();
+ float inverseScaleFactor = 1.0f / scaleFactor;
+ IntPoint logicalGestureBeginPoint(gestureBeginPoint);
+ logicalGestureBeginPoint.scale(inverseScaleFactor, inverseScaleFactor);
+
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowShadowContent);
for (Frame* childFrame = &m_page->mainFrame(); childFrame; childFrame = EventHandler::subframeForTargetNode(m_gestureTargetNode.get())) {
FrameView* frameView = childFrame->view();
@@ -1657,7 +1707,7 @@
if (!layer)
break;
- HitTestResult result(frameView->screenToContents(gestureBeginPoint));
+ HitTestResult result(frameView->screenToContents(logicalGestureBeginPoint));
layer->hitTest(request, result);
m_gestureTargetNode = result.innerNode();
@@ -1762,13 +1812,15 @@
}
ScrollableArea* scrolledArea = 0;
+ float scaleFactor = deviceScaleFactor();
+ IntSize logicalScrollDelta(-deltaX * scaleFactor, -deltaY * scaleFactor);
if (!m_gestureTargetNode || !m_gestureTargetNode->renderer()) {
// We might directly hit the document without hitting any nodes
- coreFrame->view()->scrollBy(IntSize(-deltaX, -deltaY));
+ coreFrame->view()->scrollBy(logicalScrollDelta);
scrolledArea = coreFrame->view();
} else
- m_gestureTargetNode->renderer()->enclosingLayer()->enclosingScrollableLayer()->scrollByRecursively(IntSize(-deltaX, -deltaY), WebCore::RenderLayer::ScrollOffsetClamped, &scrolledArea);
+ m_gestureTargetNode->renderer()->enclosingLayer()->enclosingScrollableLayer()->scrollByRecursively(logicalScrollDelta, WebCore::RenderLayer::ScrollOffsetClamped, &scrolledArea);
if (!(UpdatePanningFeedbackPtr() && BeginPanningFeedbackPtr() && EndPanningFeedbackPtr())) {
CloseGestureInfoHandlePtr()(gestureHandle);
@@ -2207,7 +2259,11 @@
RECT windowRect = {0};
frameRect(&windowRect);
- repaint(windowRect, true, true);
+
+ // repaint expects logical pixels, so rescale here.
+ IntRect logicalRect(windowRect);
+ logicalRect.scale(1.0f / deviceScaleFactor());
+ repaint(logicalRect, true, true);
}
bool WebView::registerWebViewWindowClass()
@@ -2350,6 +2406,9 @@
if (lParam != 0)
webView->sizeChanged(IntSize(LOWORD(lParam), HIWORD(lParam)));
break;
+ case WM_DPICHANGED:
+ webView->dpiChanged(LOWORD(wParam), IntSize(LOWORD(lParam), HIWORD(lParam)));
+ break;
case WM_SHOWWINDOW:
lResult = DefWindowProc(hWnd, message, wParam, lParam);
if (wParam == 0) {
@@ -2917,7 +2976,7 @@
info.uId = reinterpret_cast<UINT_PTR>(m_viewWindow);
::SendMessage(m_toolTipHwnd, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&info));
- ::SendMessage(m_toolTipHwnd, TTM_SETMAXTIPWIDTH, 0, maxToolTipWidth);
+ ::SendMessage(m_toolTipHwnd, TTM_SETMAXTIPWIDTH, 0, clampTo<int>(maxToolTipWidth * deviceScaleFactor()));
::SetWindowPos(m_toolTipHwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
@@ -3688,18 +3747,20 @@
return S_OK;
}
-HRESULT STDMETHODCALLTYPE WebView::selectionRect(RECT* rc)
+HRESULT WebView::selectionRect(RECT* rc)
{
WebCore::Frame& frame = m_page->focusController().focusedOrMainFrame();
IntRect ir = enclosingIntRect(frame.selection().selectionBounds());
ir = frame.view()->convertToContainingWindow(ir);
ir.move(-frame.view()->scrollOffset().width(), -frame.view()->scrollOffset().height());
- rc->left = ir.x();
- rc->top = ir.y();
- rc->bottom = rc->top + ir.height();
- rc->right = rc->left + ir.width();
+ float scaleFactor = deviceScaleFactor();
+ rc->left = ir.x() * scaleFactor;
+ rc->top = ir.y() * scaleFactor;
+ rc->bottom = rc->top + ir.height() * scaleFactor;
+ rc->right = rc->left + ir.width() * scaleFactor;
+
return S_OK;
}
@@ -3775,9 +3836,7 @@
return S_OK;
}
-HRESULT STDMETHODCALLTYPE WebView::elementAtPoint(
- /* [in] */ LPPOINT point,
- /* [retval][out] */ IPropertyBag** elementDictionary)
+HRESULT WebView::elementAtPoint(LPPOINT point, IPropertyBag** elementDictionary)
{
if (!elementDictionary) {
ASSERT_NOT_REACHED();
@@ -3791,6 +3850,8 @@
return E_FAIL;
IntPoint webCorePoint = IntPoint(point->x, point->y);
+ float inverseScaleFactor = 1.0f / deviceScaleFactor();
+ webCorePoint.scale(inverseScaleFactor, inverseScaleFactor);
HitTestResult result = HitTestResult(webCorePoint);
if (frame->contentRenderer())
result = frame->eventHandler().hitTestResultAtPoint(webCorePoint);
@@ -5307,32 +5368,37 @@
return m_frameLoadDelegatePrivate.copyRefTo(d);
}
-HRESULT STDMETHODCALLTYPE WebView::scrollOffset(
- /* [retval][out] */ LPPOINT offset)
+HRESULT WebView::scrollOffset(LPPOINT offset)
{
if (!offset)
return E_POINTER;
IntSize offsetIntSize = m_page->mainFrame().view()->scrollOffset();
+
+ offsetIntSize.scale(deviceScaleFactor());
+
offset->x = offsetIntSize.width();
offset->y = offsetIntSize.height();
return S_OK;
}
-HRESULT STDMETHODCALLTYPE WebView::scrollBy(
- /* [in] */ LPPOINT offset)
+HRESULT WebView::scrollBy(LPPOINT offset)
{
if (!offset)
return E_POINTER;
- m_page->mainFrame().view()->scrollBy(IntSize(offset->x, offset->y));
+
+ IntSize scrollDelta(offset->x, offset->y);
+ scrollDelta.scale(1.0f / deviceScaleFactor());
+ m_page->mainFrame().view()->scrollBy(scrollDelta);
return S_OK;
}
-HRESULT STDMETHODCALLTYPE WebView::visibleContentRect(
- /* [retval][out] */ LPRECT rect)
+HRESULT WebView::visibleContentRect(LPRECT rect)
{
if (!rect)
return E_POINTER;
+
FloatRect visibleContent = m_page->mainFrame().view()->visibleContentRect();
+ visibleContent.scale(deviceScaleFactor());
rect->left = (LONG) visibleContent.x();
rect->top = (LONG) visibleContent.y();
rect->right = (LONG) visibleContent.maxX();
@@ -5687,6 +5753,8 @@
caret = targetFrame->editor().firstRectForRange(tempRange.get());
}
caret = targetFrame->view()->contentsToWindow(caret);
+ caret.scale(deviceScaleFactor());
+
CANDIDATEFORM form;
form.dwIndex = 0;
form.dwStyle = CFS_EXCLUDE;
@@ -5946,6 +6014,7 @@
caret = targetFrame->editor().firstRectForRange(tempRange.get());
}
caret = targetFrame->view()->contentsToWindow(caret);
+ caret.scale(deviceScaleFactor());
charPos->pt.x = caret.x();
charPos->pt.y = caret.y();
::ClientToScreen(m_viewWindow, &charPos->pt);
@@ -6623,7 +6692,6 @@
::GetClientRect(m_viewWindow, &clientRect);
m_backingLayer->setSize(IntRect(clientRect).size());
m_backingLayer->setNeedsDisplay();
-
m_layerTreeHost->setRootChildLayer(PlatformCALayer::platformCALayer(m_backingLayer->platformLayer()));
// We aren't going to be using our backing store while we're in accelerated compositing
@@ -6772,15 +6840,22 @@
flushPendingGraphicsLayerChangesSoon();
}
-void WebView::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& inClip)
+void WebView::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& inClipPixels)
{
Frame* frame = core(m_mainFrame);
if (!frame)
return;
+ float scaleFactor = deviceScaleFactor();
+ float inverseScaleFactor = 1.0f / scaleFactor;
+
+ FloatRect logicalClip = inClipPixels;
+ logicalClip.scale(inverseScaleFactor);
+
context.save();
- context.clip(inClip);
- frame->view()->paint(&context, enclosingIntRect(inClip));
+ context.scale(FloatSize(scaleFactor, scaleFactor));
+ context.clip(logicalClip);
+ frame->view()->paint(&context, enclosingIntRect(logicalClip));
context.restore();
}
@@ -7123,6 +7198,8 @@
IntRect rect = frame.editor().firstRectForRange(range.get());
resultIntRect = frame.view()->contentsToWindow(rect);
+ resultIntRect.scale(deviceScaleFactor());
+
resultRect->left = resultIntRect.x();
resultRect->top = resultIntRect.y();
resultRect->right = resultIntRect.x() + resultIntRect.width();
@@ -7174,12 +7251,6 @@
return S_OK;
}
-static float scaleFactorFromWindow(HWND window)
-{
- HWndDC dc(window);
- return ::GetDeviceCaps(dc, LOGPIXELSX) / 96.0f;
-}
-
float WebView::deviceScaleFactor() const
{
if (m_customDeviceScaleFactor)
@@ -7188,12 +7259,12 @@
// FIXME(146335): Should check for Windows 8.1 High DPI Features here first.
if (m_viewWindow)
- return scaleFactorFromWindow(m_viewWindow);
+ return WebCore::deviceScaleFactorForWindow(m_viewWindow);
if (m_hostWindow)
- return scaleFactorFromWindow(m_hostWindow);
+ return WebCore::deviceScaleFactorForWindow(m_hostWindow);
- return scaleFactorFromWindow(0);
+ return WebCore::deviceScaleFactorForWindow(nullptr);
}
HRESULT WebView::setCustomBackingScaleFactor(double customScaleFactor)
Modified: trunk/Source/WebKit/win/WebView.h (187244 => 187245)
--- trunk/Source/WebKit/win/WebView.h 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Source/WebKit/win/WebView.h 2015-07-23 19:30:02 UTC (rev 187245)
@@ -988,6 +988,9 @@
/* [out, retval] */ RECT* resultRect);
HRESULT STDMETHODCALLTYPE selectedRangeForTesting(/* [out] */ UINT* location, /* [out] */ UINT* length);
+
+ float deviceScaleFactor() const;
+
private:
void setZoomMultiplier(float multiplier, bool isTextOnly);
float zoomMultiplier(bool isTextOnly);
@@ -1000,6 +1003,7 @@
bool active();
void sizeChanged(const WebCore::IntSize&);
+ bool dpiChanged(float, const WebCore::IntSize&);
enum WindowsToPaint { PaintWebViewOnly, PaintWebViewAndChildren };
void paintIntoBackingStore(WebCore::FrameView*, HDC bitmapDC, const WebCore::IntRect& dirtyRect, WindowsToPaint);
@@ -1026,8 +1030,6 @@
bool m_shouldInvertColors;
void setShouldInvertColors(bool);
- float deviceScaleFactor() const;
-
protected:
static bool registerWebViewWindowClass();
static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
Modified: trunk/Tools/ChangeLog (187244 => 187245)
--- trunk/Tools/ChangeLog 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Tools/ChangeLog 2015-07-23 19:30:02 UTC (rev 187245)
@@ -1,3 +1,28 @@
+2015-07-23 Brent Fulgham <[email protected]>
+
+ [Win] Implement proper High DPI support features
+ https://bugs.webkit.org/show_bug.cgi?id=146335
+ <rdar://problem/21558269>
+
+ Reviewed by Alex Christensen.
+
+ Update WinLauncher to take device scaling factor into account.
+
+ * WinLauncher/Common.cpp:
+ (resizeSubViews): Make sure toolbars and URL bar are properly sized and using
+ a valid font.
+ (computeFullDesktopFrame): Handle high DPI desktops.
+ (WndProc): Make comments more precise.
+ * WinLauncher/WinLauncher.cpp:
+ (WinLauncher::init): Determine device scale factor at launch.
+ (WinLauncher::updateDeviceScaleFactor): Added.
+ * WinLauncher/WinLauncher.h:
+ * WinLauncher/WinLauncherWebHost.h: Use C++11 initialization.
+ * WinLauncher/WinMain.cpp: Size interface based on scaling factor.
+ (wWinMain): Ditto.
+ * win/DLLLauncher/DLLLauncherMain.cpp:
+ (wWinMain): Tell Windows we understand high DPI.
+
2015-07-23 Alex Christensen <[email protected]>
[Win] Unreviewed build fix after r187169.
Modified: trunk/Tools/WinLauncher/Common.cpp (187244 => 187245)
--- trunk/Tools/WinLauncher/Common.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Tools/WinLauncher/Common.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -65,6 +65,10 @@
static const int maxHistorySize = 10;
+#ifndef WM_DPICHANGED
+#define WM_DPICHANGED 0x02E0
+#endif
+
typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
@@ -72,6 +76,7 @@
HINSTANCE hInst;
HWND hMainWnd;
HWND hURLBarWnd;
+HGDIOBJ hURLFont;
HWND hBackButtonWnd;
HWND hForwardButtonWnd;
HWND hCacheWnd;
@@ -101,17 +106,29 @@
static void loadURL(BSTR urlBStr);
static void updateStatistics(HWND hDlg);
+namespace WebCore {
+float deviceScaleFactorForWindow(HWND);
+}
+
static void resizeSubViews()
{
if (gWinLauncher->usesLayeredWebView() || !gViewWindow)
return;
+ float scaleFactor = WebCore::deviceScaleFactorForWindow(gViewWindow);
+
RECT rcClient;
GetClientRect(hMainWnd, &rcClient);
- MoveWindow(hBackButtonWnd, 0, 0, CONTROLBUTTON_WIDTH, URLBAR_HEIGHT, TRUE);
- MoveWindow(hForwardButtonWnd, CONTROLBUTTON_WIDTH, 0, CONTROLBUTTON_WIDTH, URLBAR_HEIGHT, TRUE);
- MoveWindow(hURLBarWnd, CONTROLBUTTON_WIDTH * 2, 0, rcClient.right, URLBAR_HEIGHT, TRUE);
- MoveWindow(gViewWindow, 0, URLBAR_HEIGHT, rcClient.right, rcClient.bottom - URLBAR_HEIGHT, TRUE);
+
+ int height = scaleFactor * URLBAR_HEIGHT;
+ int width = scaleFactor * CONTROLBUTTON_WIDTH;
+
+ MoveWindow(hBackButtonWnd, 0, 0, width, height, TRUE);
+ MoveWindow(hForwardButtonWnd, width, 0, width, height, TRUE);
+ MoveWindow(hURLBarWnd, width * 2, 0, rcClient.right, height, TRUE);
+ MoveWindow(gViewWindow, 0, height, rcClient.right, rcClient.bottom - height, TRUE);
+
+ ::SendMessage(hURLBarWnd, static_cast<UINT>(WM_SETFONT), reinterpret_cast<WPARAM>(gWinLauncher->urlBarFont()), TRUE);
}
static void subclassForLayeredWindow()
@@ -132,10 +149,12 @@
if (!::SystemParametersInfo(SPI_GETWORKAREA, 0, static_cast<void*>(&desktop), 0))
return;
+ float scaleFactor = WebCore::deviceScaleFactorForWindow(nullptr);
+
s_windowPosition.x = 0;
s_windowPosition.y = 0;
- s_windowSize.cx = desktop.right - desktop.left;
- s_windowSize.cy = desktop.bottom - desktop.top;
+ s_windowSize.cx = scaleFactor * (desktop.right - desktop.left);
+ s_windowSize.cy = scaleFactor * (desktop.bottom - desktop.top);
}
BOOL WINAPI DllMain(HINSTANCE dllInstance, DWORD reason, LPVOID)
@@ -421,13 +440,13 @@
// For testing our transparent window, we need a region to use as a handle for
// dragging. The right way to do this would be to query the web view to see what's
// under the mouse. However, for testing purposes we just use an arbitrary
- // 30 pixel band at the top of the view as an arbitrary gripping location.
+ // 30 logical pixel band at the top of the view as an arbitrary gripping location.
//
// When we are within this bad, return HT_CAPTION to tell Windows we want to
// treat this region as if it were the title bar on a normal window.
int y = HIWORD(lParam);
-
- if ((y > window.top) && (y < window.top + dragBarHeight))
+ float scaledDragBarHeightFactor = dragBarHeight * gWinLauncher->deviceScaleFactor();
+ if ((y > window.top) && (y < window.top + scaledDragBarHeightFactor))
return HTCAPTION;
}
return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
@@ -519,6 +538,10 @@
resizeSubViews();
break;
+ case WM_DPICHANGED:
+ if (gWinLauncher)
+ gWinLauncher->updateDeviceScaleFactor();
+ return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
default:
return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
}
Modified: trunk/Tools/WinLauncher/WinLauncher.cpp (187244 => 187245)
--- trunk/Tools/WinLauncher/WinLauncher.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Tools/WinLauncher/WinLauncher.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008, 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2013-2015 Apple Inc. All rights reserved.
* Copyright (C) 2009, 2011 Brent Fulgham. All rights reserved.
* Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved.
* Copyright (C) 2013 Alex Christensen. All rights reserved.
@@ -47,6 +47,10 @@
#include <string>
#include <vector>
+namespace WebCore {
+float deviceScaleFactorForWindow(HWND);
+}
+
static const int maxHistorySize = 10;
typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
@@ -61,6 +65,8 @@
HRESULT WinLauncher::init()
{
+ updateDeviceScaleFactor();
+
HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&m_webView.GetInterfacePtr()));
if (FAILED(hr))
return hr;
@@ -478,3 +484,19 @@
webActions->zoomPageOut(nullptr);
}
+
+void WinLauncher::generateFontForScaleFactor(float scaleFactor)
+{
+ if (m_hURLBarFont)
+ ::DeleteObject(m_hURLBarFont);
+
+ m_hURLBarFont = ::CreateFont(scaleFactor * 18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
+ OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE, L"Times New Roman");
+}
+
+
+void WinLauncher::updateDeviceScaleFactor()
+{
+ m_deviceScaleFactor = WebCore::deviceScaleFactorForWindow(m_hMainWnd);
+ generateFontForScaleFactor(m_deviceScaleFactor);
+}
Modified: trunk/Tools/WinLauncher/WinLauncher.h (187244 => 187245)
--- trunk/Tools/WinLauncher/WinLauncher.h 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Tools/WinLauncher/WinLauncher.h 2015-07-23 19:30:02 UTC (rev 187245)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -90,7 +90,14 @@
void zoomIn();
void zoomOut();
+ float deviceScaleFactor() { return m_deviceScaleFactor; }
+ void updateDeviceScaleFactor();
+
+ HGDIOBJ urlBarFont() { return m_hURLBarFont; }
+
private:
+ void generateFontForScaleFactor(float);
+
std::vector<IWebHistoryItemPtr> m_historyItems;
std::unique_ptr<PageLoadTestClient> m_pageLoadTestClient;
@@ -112,8 +119,10 @@
IWebCoreStatisticsPtr m_statistics;
IWebCachePtr m_webCache;
- HWND m_hMainWnd;
- HWND m_hURLBarWnd;
+ HWND m_hMainWnd { nullptr };
+ HWND m_hURLBarWnd { nullptr };
+ HGDIOBJ m_hURLBarFont { nullptr };
+ float m_deviceScaleFactor { 1.0f };
bool m_useLayeredWebView;
};
Modified: trunk/Tools/WinLauncher/WinLauncherWebHost.h (187244 => 187245)
--- trunk/Tools/WinLauncher/WinLauncherWebHost.h 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Tools/WinLauncher/WinLauncherWebHost.h 2015-07-23 19:30:02 UTC (rev 187245)
@@ -76,7 +76,9 @@
HRESULT updateAddressBar(IWebView&);
private:
- HWND m_hURLBarWnd;
- ULONG m_refCount;
- WinLauncher* m_client;
+ HWND m_hURLBarWnd { 0 };
+ HGDIOBJ m_URLBarFont { 0 };
+ HGDIOBJ m_oldFont { 0 };
+ ULONG m_refCount { 0 };
+ WinLauncher* m_client { nullptr };
};
Modified: trunk/Tools/WinLauncher/WinMain.cpp (187244 => 187245)
--- trunk/Tools/WinLauncher/WinMain.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Tools/WinLauncher/WinMain.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -31,6 +31,10 @@
#include "WinLauncherWebHost.h"
#include "Common.cpp"
+namespace WebCore {
+float deviceScaleFactorForWindow(HWND);
+}
+
int WINAPI wWinMain(HINSTANCE, HINSTANCE, PWSTR, int nCmdShow)
{
#ifdef _CRTDBG_MAP_ALLOC
@@ -65,10 +69,12 @@
// Init COM
OleInitialize(nullptr);
+ float scaleFactor = WebCore::deviceScaleFactorForWindow(nullptr);
+
if (usesLayeredWebView) {
hURLBarWnd = CreateWindow(L"EDIT", L"Type URL Here",
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL,
- s_windowPosition.x, s_windowPosition.y + s_windowSize.cy, s_windowSize.cx, URLBAR_HEIGHT,
+ scaleFactor * s_windowPosition.x, scaleFactor * (s_windowPosition.y + s_windowSize.cy), scaleFactor * s_windowSize.cx, scaleFactor * URLBAR_HEIGHT,
0, 0, hInst, 0);
} else {
hMainWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
@@ -78,8 +84,8 @@
return FALSE;
hBackButtonWnd = CreateWindow(L"BUTTON", L"<", WS_CHILD | WS_VISIBLE | BS_TEXT, 0, 0, 0, 0, hMainWnd, 0, hInst, 0);
- hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE | BS_TEXT, CONTROLBUTTON_WIDTH, 0, 0, 0, hMainWnd, 0, hInst, 0);
- hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, CONTROLBUTTON_WIDTH * 2, 0, 0, 0, hMainWnd, 0, hInst, 0);
+ hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE | BS_TEXT, scaleFactor * CONTROLBUTTON_WIDTH, 0, 0, 0, hMainWnd, 0, hInst, 0);
+ hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, scaleFactor * CONTROLBUTTON_WIDTH * 2, 0, 0, 0, hMainWnd, 0, hInst, 0);
ShowWindow(hMainWnd, nCmdShow);
UpdateWindow(hMainWnd);
@@ -93,8 +99,12 @@
SetFocus(hURLBarWnd);
- RECT clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
+ RECT clientRect;
+ ::GetClientRect(hMainWnd, &clientRect);
+ if (usesLayeredWebView)
+ clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy };
+
WinLauncherWebHost* webHost = nullptr;
IWebDownloadDelegatePtr downloadDelegate;
Modified: trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp (187244 => 187245)
--- trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp 2015-07-23 19:15:16 UTC (rev 187244)
+++ trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp 2015-07-23 19:30:02 UTC (rev 187245)
@@ -193,6 +193,9 @@
_set_FMA3_enable(0);
#endif
+ BOOL didIt = SetProcessDPIAware();
+ _ASSERT(didIt);
+
#ifdef _CRTDBG_MAP_ALLOC
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);