Diff
Modified: trunk/Source/WTF/ChangeLog (188385 => 188386)
--- trunk/Source/WTF/ChangeLog 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WTF/ChangeLog 2015-08-13 17:37:27 UTC (rev 188386)
@@ -1,3 +1,16 @@
+2015-08-12 Anders Carlsson <ander...@apple.com>
+
+ Use WTF::Optional in WindowFeatures
+ https://bugs.webkit.org/show_bug.cgi?id=147956
+
+ Reviewed by Sam Weinig.
+
+ Add new operators to WTF::Optional to make it more like std::optional.
+
+ * wtf/Optional.h:
+ (WTF::Optional::operator->):
+ (WTF::Optional::operator*):
+
2015-08-12 Filip Pizlo <fpi...@apple.com>
WTF::Lock should not suffer from the thundering herd
Modified: trunk/Source/WTF/wtf/Optional.h (188385 => 188386)
--- trunk/Source/WTF/wtf/Optional.h 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WTF/wtf/Optional.h 2015-08-13 17:37:27 UTC (rev 188386)
@@ -133,6 +133,21 @@
explicit operator bool() const { return m_isEngaged; }
+ const T* operator->() const
+ {
+ ASSERT(m_isEngaged);
+ return asPtr()->operator->();
+ }
+
+ T* operator->()
+ {
+ ASSERT(m_isEngaged);
+ return asPtr()->operator->();
+ }
+
+ const T& operator*() const { return value(); }
+ T& operator*() { return value(); }
+
T& value()
{
ASSERT(m_isEngaged);
Modified: trunk/Source/WebCore/ChangeLog (188385 => 188386)
--- trunk/Source/WebCore/ChangeLog 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebCore/ChangeLog 2015-08-13 17:37:27 UTC (rev 188386)
@@ -1,3 +1,21 @@
+2015-08-12 Anders Carlsson <ander...@apple.com>
+
+ Use WTF::Optional in WindowFeatures
+ https://bugs.webkit.org/show_bug.cgi?id=147956
+
+ Reviewed by Sam Weinig.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::createWindow):
+ * page/WindowFeatures.cpp:
+ (WebCore::WindowFeatures::WindowFeatures):
+ (WebCore::WindowFeatures::setWindowFeature):
+ (WebCore::WindowFeatures::boolFeature):
+ (WebCore::WindowFeatures::floatFeature):
+ (WebCore::WindowFeatures::parseDialogFeatures):
+ * page/WindowFeatures.h:
+ (WebCore::WindowFeatures::WindowFeatures):
+
2015-08-13 Matthew Daiter <mdai...@apple.com>
UserMediaRequest should supply IDs of devices selected by user
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (188385 => 188386)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2015-08-13 17:37:27 UTC (rev 188386)
@@ -3551,15 +3551,15 @@
#if !PLATFORM(IOS)
FloatSize viewportSize = page->chrome().pageRect().size();
FloatRect windowRect = page->chrome().windowRect();
- if (features.xSet)
- windowRect.setX(features.x);
- if (features.ySet)
- windowRect.setY(features.y);
+ if (features.x)
+ windowRect.setX(*features.x);
+ if (features.y)
+ windowRect.setY(*features.y);
// Zero width and height mean using default size, not minumum one.
- if (features.widthSet && features.width)
- windowRect.setWidth(features.width + (windowRect.width() - viewportSize.width()));
- if (features.heightSet && features.height)
- windowRect.setHeight(features.height + (windowRect.height() - viewportSize.height()));
+ if (features.width && *features.width)
+ windowRect.setWidth(*features.width + (windowRect.width() - viewportSize.width()));
+ if (features.height && *features.height)
+ windowRect.setHeight(*features.height + (windowRect.height() - viewportSize.height()));
// Ensure non-NaN values, minimum size as well as being within valid screen area.
FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect);
@@ -3571,10 +3571,10 @@
// On iOS, width and height refer to the viewport dimensions.
ViewportArguments arguments;
// Zero width and height mean using default size, not minimum one.
- if (features.widthSet && features.width)
- arguments.width = features.width;
- if (features.heightSet && features.height)
- arguments.height = features.height;
+ if (features.width && *features.width)
+ arguments.width = *features.width;
+ if (features.height && *features.height)
+ arguments.height = *features.height;
frame->setViewportArguments(arguments);
#endif
Modified: trunk/Source/WebCore/page/WindowFeatures.cpp (188385 => 188386)
--- trunk/Source/WebCore/page/WindowFeatures.cpp 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebCore/page/WindowFeatures.cpp 2015-08-13 17:37:27 UTC (rev 188386)
@@ -37,15 +37,7 @@
}
WindowFeatures::WindowFeatures(const String& features)
- : x(0)
- , xSet(false)
- , y(0)
- , ySet(false)
- , width(0)
- , widthSet(false)
- , height(0)
- , heightSet(false)
- , resizable(true)
+ : resizable(true)
, fullscreen(false)
, dialog(false)
{
@@ -134,19 +126,15 @@
// We treat keyString of "resizable" here as an additional feature rather than setting resizeable to true.
// This is consistent with Firefox, but could also be handled at another level.
- if (keyString == "left" || keyString == "screenx") {
- xSet = true;
+ if (keyString == "left" || keyString == "screenx")
x = value;
- } else if (keyString == "top" || keyString == "screeny") {
- ySet = true;
+ else if (keyString == "top" || keyString == "screeny")
y = value;
- } else if (keyString == "width" || keyString == "innerwidth") {
- widthSet = true;
+ else if (keyString == "width" || keyString == "innerwidth")
width = value;
- } else if (keyString == "height" || keyString == "innerheight") {
- heightSet = true;
+ else if (keyString == "height" || keyString == "innerheight")
height = value;
- } else if (keyString == "menubar")
+ else if (keyString == "menubar")
menuBarVisible = value;
else if (keyString == "toolbar")
toolBarVisible = value;
@@ -163,16 +151,13 @@
}
WindowFeatures::WindowFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect)
- : widthSet(true)
- , heightSet(true)
- , menuBarVisible(false)
+ : menuBarVisible(false)
, toolBarVisible(false)
, locationBarVisible(false)
, fullscreen(false)
, dialog(true)
{
- DialogFeaturesMap features;
- parseDialogFeatures(dialogFeaturesString, features);
+ auto features = parseDialogFeatures(dialogFeaturesString);
const bool trusted = false;
@@ -187,20 +172,20 @@
width = floatFeature(features, "dialogwidth", 100, screenAvailableRect.width(), 620); // default here came from frame size of dialog in MacIE
height = floatFeature(features, "dialogheight", 100, screenAvailableRect.height(), 450); // default here came from frame size of dialog in MacIE
- x = floatFeature(features, "dialogleft", screenAvailableRect.x(), screenAvailableRect.maxX() - width, -1);
- xSet = x > 0;
- y = floatFeature(features, "dialogtop", screenAvailableRect.y(), screenAvailableRect.maxY() - height, -1);
- ySet = y > 0;
+ auto dialogLeft = floatFeature(features, "dialogleft", screenAvailableRect.x(), screenAvailableRect.maxX() - *width, -1);
+ if (dialogLeft > 0)
+ x = dialogLeft;
+ auto dialogTop = floatFeature(features, "dialogtop", screenAvailableRect.y(), screenAvailableRect.maxY() - *height, -1);
+ if (dialogTop > 0)
+ y = dialogTop;
+
if (boolFeature(features, "center", true)) {
- if (!xSet) {
- x = screenAvailableRect.x() + (screenAvailableRect.width() - width) / 2;
- xSet = true;
- }
- if (!ySet) {
- y = screenAvailableRect.y() + (screenAvailableRect.height() - height) / 2;
- ySet = true;
- }
+ if (!x)
+ x = screenAvailableRect.x() + (screenAvailableRect.width() - *width) / 2;
+
+ if (!y)
+ y = screenAvailableRect.y() + (screenAvailableRect.height() - *height) / 2;
}
resizable = boolFeature(features, "resizable");
@@ -208,20 +193,22 @@
statusBarVisible = boolFeature(features, "status", !trusted);
}
-bool WindowFeatures::boolFeature(const DialogFeaturesMap& features, const char* key, bool defaultValue)
+bool WindowFeatures::boolFeature(const HashMap<String, String>& features, const char* key, bool defaultValue)
{
- DialogFeaturesMap::const_iterator it = features.find(key);
+ auto it = features.find(key);
if (it == features.end())
return defaultValue;
+
const String& value = it->value;
return value.isNull() || value == "1" || value == "yes" || value == "on";
}
-float WindowFeatures::floatFeature(const DialogFeaturesMap& features, const char* key, float min, float max, float defaultValue)
+float WindowFeatures::floatFeature(const HashMap<String, String>& features, const char* key, float min, float max, float defaultValue)
{
- DialogFeaturesMap::const_iterator it = features.find(key);
+ auto it = features.find(key);
if (it == features.end())
return defaultValue;
+
// FIXME: The toDouble function does not offer a way to tell "0q" from string with no digits in it: Both
// return the number 0 and false for ok. But "0q" should yield the minimum rather than the default.
bool ok;
@@ -232,14 +219,18 @@
return min;
if (parsedNumber > max)
return max;
+
// FIXME: Seems strange to cast a double to int and then convert back to a float. Why is this a good idea?
return static_cast<int>(parsedNumber);
}
-void WindowFeatures::parseDialogFeatures(const String& string, DialogFeaturesMap& map)
+HashMap<String, String> WindowFeatures::parseDialogFeatures(const String& string)
{
+ HashMap<String, String> features;
+
Vector<String> vector;
string.split(';', vector);
+
for (auto& featureString : vector) {
size_t separatorPosition = featureString.find('=');
size_t colonPosition = featureString.find(':');
@@ -257,8 +248,10 @@
value = value.left(value.find(' '));
}
- map.set(key, value);
+ features.set(key, value);
}
+
+ return features;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/page/WindowFeatures.h (188385 => 188386)
--- trunk/Source/WebCore/page/WindowFeatures.h 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebCore/page/WindowFeatures.h 2015-08-13 17:37:27 UTC (rev 188386)
@@ -29,8 +29,11 @@
#ifndef WindowFeatures_h
#define WindowFeatures_h
+#include <wtf/Forward.h>
#include <wtf/HashMap.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/Optional.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
namespace WebCore {
@@ -38,15 +41,7 @@
struct WindowFeatures {
WindowFeatures()
- : x(0)
- , xSet(false)
- , y(0)
- , ySet(false)
- , width(0)
- , widthSet(false)
- , height(0)
- , heightSet(false)
- , menuBarVisible(true)
+ : menuBarVisible(true)
, statusBarVisible(true)
, toolBarVisible(true)
, locationBarVisible(true)
@@ -59,14 +54,10 @@
explicit WindowFeatures(const String& windowFeaturesString);
WindowFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect);
- float x;
- bool xSet;
- float y;
- bool ySet;
- float width;
- bool widthSet;
- float height;
- bool heightSet;
+ Optional<float> x;
+ Optional<float> y;
+ Optional<float> width;
+ Optional<float> height;
bool menuBarVisible;
bool statusBarVisible;
@@ -81,10 +72,9 @@
Vector<String> additionalFeatures;
private:
- typedef HashMap<String, String> DialogFeaturesMap;
- static void parseDialogFeatures(const String&, HashMap<String, String>&);
- static bool boolFeature(const DialogFeaturesMap&, const char* key, bool defaultValue = false);
- static float floatFeature(const DialogFeaturesMap&, const char* key, float min, float max, float defaultValue);
+ static HashMap<String, String> parseDialogFeatures(const String&);
+ static bool boolFeature(const HashMap<String, String>&, const char* key, bool defaultValue = false);
+ static float floatFeature(const HashMap<String, String>&, const char* key, float min, float max, float defaultValue);
void setWindowFeature(const String& keyString, const String& valueString);
};
Modified: trunk/Source/WebKit/mac/ChangeLog (188385 => 188386)
--- trunk/Source/WebKit/mac/ChangeLog 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebKit/mac/ChangeLog 2015-08-13 17:37:27 UTC (rev 188386)
@@ -1,3 +1,13 @@
+2015-08-12 Anders Carlsson <ander...@apple.com>
+
+ Use WTF::Optional in WindowFeatures
+ https://bugs.webkit.org/show_bug.cgi?id=147956
+
+ Reviewed by Sam Weinig.
+
+ * WebCoreSupport/WebChromeClient.mm:
+ (WebChromeClient::createWindow):
+
2015-08-13 Matthew Daiter <mdai...@apple.com>
Linking device query ability from WebKit2 to clients
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm (188385 => 188386)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm 2015-08-13 17:37:27 UTC (rev 188386)
@@ -240,10 +240,10 @@
#endif
if ([delegate respondsToSelector:@selector(webView:createWebViewWithRequest:windowFeatures:)]) {
- NSNumber *x = features.xSet ? [[NSNumber alloc] initWithFloat:features.x] : nil;
- NSNumber *y = features.ySet ? [[NSNumber alloc] initWithFloat:features.y] : nil;
- NSNumber *width = features.widthSet ? [[NSNumber alloc] initWithFloat:features.width] : nil;
- NSNumber *height = features.heightSet ? [[NSNumber alloc] initWithFloat:features.height] : nil;
+ NSNumber *x = features.x ? [[NSNumber alloc] initWithFloat:*features.x] : nil;
+ NSNumber *y = features.y ? [[NSNumber alloc] initWithFloat:*features.y] : nil;
+ NSNumber *width = features.width ? [[NSNumber alloc] initWithFloat:*features.width] : nil;
+ NSNumber *height = features.height ? [[NSNumber alloc] initWithFloat:*features.height] : nil;
NSNumber *menuBarVisible = [[NSNumber alloc] initWithBool:features.menuBarVisible];
NSNumber *statusBarVisible = [[NSNumber alloc] initWithBool:features.statusBarVisible];
NSNumber *toolBarVisible = [[NSNumber alloc] initWithBool:features.toolBarVisible];
Modified: trunk/Source/WebKit/win/ChangeLog (188385 => 188386)
--- trunk/Source/WebKit/win/ChangeLog 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebKit/win/ChangeLog 2015-08-13 17:37:27 UTC (rev 188386)
@@ -1,3 +1,13 @@
+2015-08-12 Anders Carlsson <ander...@apple.com>
+
+ Use WTF::Optional in WindowFeatures
+ https://bugs.webkit.org/show_bug.cgi?id=147956
+
+ Reviewed by Sam Weinig.
+
+ * WebCoreSupport/WebChromeClient.cpp:
+ (createWindowFeaturesPropertyBag):
+
2015-08-10 Per Arne Vollan <pe...@outlook.com>
[Win] Small repaint issues when device scale factor != 1.
Modified: trunk/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp (188385 => 188386)
--- trunk/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp 2015-08-13 17:37:27 UTC (rev 188386)
@@ -170,14 +170,14 @@
static COMPtr<IPropertyBag> createWindowFeaturesPropertyBag(const WindowFeatures& features)
{
HashMap<String, COMVariant> map;
- if (features.xSet)
- map.set(WebWindowFeaturesXKey, features.x);
- if (features.ySet)
- map.set(WebWindowFeaturesYKey, features.y);
- if (features.widthSet)
- map.set(WebWindowFeaturesWidthKey, features.width);
- if (features.heightSet)
- map.set(WebWindowFeaturesHeightKey, features.height);
+ if (features.x)
+ map.set(WebWindowFeaturesXKey, *features.x);
+ if (features.y)
+ map.set(WebWindowFeaturesYKey, *features.y);
+ if (features.width)
+ map.set(WebWindowFeaturesWidthKey, *features.width);
+ if (features.height)
+ map.set(WebWindowFeaturesHeightKey, *features.height);
map.set(WebWindowFeaturesMenuBarVisibleKey, features.menuBarVisible);
map.set(WebWindowFeaturesStatusBarVisibleKey, features.statusBarVisible);
map.set(WebWindowFeaturesToolBarVisibleKey, features.toolBarVisible);
Modified: trunk/Source/WebKit2/ChangeLog (188385 => 188386)
--- trunk/Source/WebKit2/ChangeLog 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebKit2/ChangeLog 2015-08-13 17:37:27 UTC (rev 188386)
@@ -1,3 +1,18 @@
+2015-08-12 Anders Carlsson <ander...@apple.com>
+
+ Use WTF::Optional in WindowFeatures
+ https://bugs.webkit.org/show_bug.cgi?id=147956
+
+ Reviewed by Sam Weinig.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<WindowFeatures>::encode): Deleted.
+ (IPC::ArgumentCoder<WindowFeatures>::decode): Deleted.
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageSetPageUIClient):
+ * UIProcess/API/Cocoa/WKWindowFeatures.mm:
+ (-[WKWindowFeatures _initWithWindowFeatures:]):
+
2015-08-13 Matthew Daiter <mdai...@apple.com>
Linking device query ability from WebKit2 to clients
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (188385 => 188386)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2015-08-13 17:37:27 UTC (rev 188386)
@@ -956,10 +956,6 @@
encoder << windowFeatures.y;
encoder << windowFeatures.width;
encoder << windowFeatures.height;
- encoder << windowFeatures.xSet;
- encoder << windowFeatures.ySet;
- encoder << windowFeatures.widthSet;
- encoder << windowFeatures.heightSet;
encoder << windowFeatures.menuBarVisible;
encoder << windowFeatures.statusBarVisible;
encoder << windowFeatures.toolBarVisible;
@@ -980,14 +976,6 @@
return false;
if (!decoder.decode(windowFeatures.height))
return false;
- if (!decoder.decode(windowFeatures.xSet))
- return false;
- if (!decoder.decode(windowFeatures.ySet))
- return false;
- if (!decoder.decode(windowFeatures.widthSet))
- return false;
- if (!decoder.decode(windowFeatures.heightSet))
- return false;
if (!decoder.decode(windowFeatures.menuBarVisible))
return false;
if (!decoder.decode(windowFeatures.statusBarVisible))
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (188385 => 188386)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2015-08-13 17:37:27 UTC (rev 188386)
@@ -1350,14 +1350,14 @@
return 0;
API::Dictionary::MapType map;
- if (windowFeatures.xSet)
- map.set("x", API::Double::create(windowFeatures.x));
- if (windowFeatures.ySet)
- map.set("y", API::Double::create(windowFeatures.y));
- if (windowFeatures.widthSet)
- map.set("width", API::Double::create(windowFeatures.width));
- if (windowFeatures.heightSet)
- map.set("height", API::Double::create(windowFeatures.height));
+ if (windowFeatures.x)
+ map.set("x", API::Double::create(*windowFeatures.x));
+ if (windowFeatures.y)
+ map.set("y", API::Double::create(*windowFeatures.y));
+ if (windowFeatures.width)
+ map.set("width", API::Double::create(*windowFeatures.width));
+ if (windowFeatures.height)
+ map.set("height", API::Double::create(*windowFeatures.height));
map.set("menuBarVisible", API::Boolean::create(windowFeatures.menuBarVisible));
map.set("statusBarVisible", API::Boolean::create(windowFeatures.statusBarVisible));
map.set("toolBarVisible", API::Boolean::create(windowFeatures.toolBarVisible));
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeatures.mm (188385 => 188386)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeatures.mm 2015-08-13 17:33:43 UTC (rev 188385)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeatures.mm 2015-08-13 17:37:27 UTC (rev 188386)
@@ -55,14 +55,14 @@
_toolbarsVisibility = @(windowFeatures.toolBarVisible || windowFeatures.locationBarVisible);
_allowsResizing = @(windowFeatures.resizable);
- if (windowFeatures.xSet)
- _x = @(windowFeatures.x);
- if (windowFeatures.ySet)
- _y = @(windowFeatures.y);
- if (windowFeatures.widthSet)
- _width = @(windowFeatures.width);
- if (windowFeatures.heightSet)
- _height = @(windowFeatures.height);
+ if (windowFeatures.x)
+ _x = @(*windowFeatures.x);
+ if (windowFeatures.y)
+ _y = @(*windowFeatures.y);
+ if (windowFeatures.width)
+ _width = @(*windowFeatures.width);
+ if (windowFeatures.height)
+ _height = @(*windowFeatures.height);
return self;
}