Changeset 188386 in webkit
- Timestamp:
- Aug 13, 2015, 10:37:27 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/Optional.h (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/loader/FrameLoader.cpp (modified) (2 diffs)
-
WebCore/page/WindowFeatures.cpp (modified) (8 diffs)
-
WebCore/page/WindowFeatures.h (modified) (4 diffs)
-
WebKit/mac/ChangeLog (modified) (1 diff)
-
WebKit/mac/WebCoreSupport/WebChromeClient.mm (modified) (1 diff)
-
WebKit/win/ChangeLog (modified) (1 diff)
-
WebKit/win/WebCoreSupport/WebChromeClient.cpp (modified) (1 diff)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/Shared/WebCoreArgumentCoders.cpp (modified) (2 diffs)
-
WebKit2/UIProcess/API/C/WKPage.cpp (modified) (1 diff)
-
WebKit2/UIProcess/API/Cocoa/WKWindowFeatures.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r188374 r188386 1 2015-08-12 Anders Carlsson <andersca@apple.com> 2 3 Use WTF::Optional in WindowFeatures 4 https://bugs.webkit.org/show_bug.cgi?id=147956 5 6 Reviewed by Sam Weinig. 7 8 Add new operators to WTF::Optional to make it more like std::optional. 9 10 * wtf/Optional.h: 11 (WTF::Optional::operator->): 12 (WTF::Optional::operator*): 13 1 14 2015-08-12 Filip Pizlo <fpizlo@apple.com> 2 15 -
trunk/Source/WTF/wtf/Optional.h
r182254 r188386 134 134 explicit operator bool() const { return m_isEngaged; } 135 135 136 const T* operator->() const 137 { 138 ASSERT(m_isEngaged); 139 return asPtr()->operator->(); 140 } 141 142 T* operator->() 143 { 144 ASSERT(m_isEngaged); 145 return asPtr()->operator->(); 146 } 147 148 const T& operator*() const { return value(); } 149 T& operator*() { return value(); } 150 136 151 T& value() 137 152 { -
trunk/Source/WebCore/ChangeLog
r188385 r188386 1 2015-08-12 Anders Carlsson <andersca@apple.com> 2 3 Use WTF::Optional in WindowFeatures 4 https://bugs.webkit.org/show_bug.cgi?id=147956 5 6 Reviewed by Sam Weinig. 7 8 * loader/FrameLoader.cpp: 9 (WebCore::createWindow): 10 * page/WindowFeatures.cpp: 11 (WebCore::WindowFeatures::WindowFeatures): 12 (WebCore::WindowFeatures::setWindowFeature): 13 (WebCore::WindowFeatures::boolFeature): 14 (WebCore::WindowFeatures::floatFeature): 15 (WebCore::WindowFeatures::parseDialogFeatures): 16 * page/WindowFeatures.h: 17 (WebCore::WindowFeatures::WindowFeatures): 18 1 19 2015-08-13 Matthew Daiter <mdaiter@apple.com> 2 20 -
trunk/Source/WebCore/loader/FrameLoader.cpp
r187962 r188386 3552 3552 FloatSize viewportSize = page->chrome().pageRect().size(); 3553 3553 FloatRect windowRect = page->chrome().windowRect(); 3554 if (features.x Set)3555 windowRect.setX( features.x);3556 if (features.y Set)3557 windowRect.setY( features.y);3554 if (features.x) 3555 windowRect.setX(*features.x); 3556 if (features.y) 3557 windowRect.setY(*features.y); 3558 3558 // Zero width and height mean using default size, not minumum one. 3559 if (features.width Set &&features.width)3560 windowRect.setWidth( features.width + (windowRect.width() - viewportSize.width()));3561 if (features.height Set &&features.height)3562 windowRect.setHeight( features.height + (windowRect.height() - viewportSize.height()));3559 if (features.width && *features.width) 3560 windowRect.setWidth(*features.width + (windowRect.width() - viewportSize.width())); 3561 if (features.height && *features.height) 3562 windowRect.setHeight(*features.height + (windowRect.height() - viewportSize.height())); 3563 3563 3564 3564 // Ensure non-NaN values, minimum size as well as being within valid screen area. … … 3572 3572 ViewportArguments arguments; 3573 3573 // Zero width and height mean using default size, not minimum one. 3574 if (features.width Set &&features.width)3575 arguments.width = features.width;3576 if (features.height Set &&features.height)3577 arguments.height = features.height;3574 if (features.width && *features.width) 3575 arguments.width = *features.width; 3576 if (features.height && *features.height) 3577 arguments.height = *features.height; 3578 3578 frame->setViewportArguments(arguments); 3579 3579 #endif -
trunk/Source/WebCore/page/WindowFeatures.cpp
r185167 r188386 38 38 39 39 WindowFeatures::WindowFeatures(const String& features) 40 : x(0) 41 , xSet(false) 42 , y(0) 43 , ySet(false) 44 , width(0) 45 , widthSet(false) 46 , height(0) 47 , heightSet(false) 48 , resizable(true) 40 : resizable(true) 49 41 , fullscreen(false) 50 42 , dialog(false) … … 135 127 // This is consistent with Firefox, but could also be handled at another level. 136 128 137 if (keyString == "left" || keyString == "screenx") { 138 xSet = true; 129 if (keyString == "left" || keyString == "screenx") 139 130 x = value; 140 } else if (keyString == "top" || keyString == "screeny") { 141 ySet = true; 131 else if (keyString == "top" || keyString == "screeny") 142 132 y = value; 143 } else if (keyString == "width" || keyString == "innerwidth") { 144 widthSet = true; 133 else if (keyString == "width" || keyString == "innerwidth") 145 134 width = value; 146 } else if (keyString == "height" || keyString == "innerheight") { 147 heightSet = true; 135 else if (keyString == "height" || keyString == "innerheight") 148 136 height = value; 149 }else if (keyString == "menubar")137 else if (keyString == "menubar") 150 138 menuBarVisible = value; 151 139 else if (keyString == "toolbar") … … 164 152 165 153 WindowFeatures::WindowFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect) 166 : widthSet(true) 167 , heightSet(true) 168 , menuBarVisible(false) 154 : menuBarVisible(false) 169 155 , toolBarVisible(false) 170 156 , locationBarVisible(false) … … 172 158 , dialog(true) 173 159 { 174 DialogFeaturesMap features; 175 parseDialogFeatures(dialogFeaturesString, features); 160 auto features = parseDialogFeatures(dialogFeaturesString); 176 161 177 162 const bool trusted = false; … … 188 173 height = floatFeature(features, "dialogheight", 100, screenAvailableRect.height(), 450); // default here came from frame size of dialog in MacIE 189 174 190 x = floatFeature(features, "dialogleft", screenAvailableRect.x(), screenAvailableRect.maxX() - width, -1); 191 xSet = x > 0; 192 y = floatFeature(features, "dialogtop", screenAvailableRect.y(), screenAvailableRect.maxY() - height, -1); 193 ySet = y > 0; 175 auto dialogLeft = floatFeature(features, "dialogleft", screenAvailableRect.x(), screenAvailableRect.maxX() - *width, -1); 176 if (dialogLeft > 0) 177 x = dialogLeft; 178 179 auto dialogTop = floatFeature(features, "dialogtop", screenAvailableRect.y(), screenAvailableRect.maxY() - *height, -1); 180 if (dialogTop > 0) 181 y = dialogTop; 194 182 195 183 if (boolFeature(features, "center", true)) { 196 if (!xSet) { 197 x = screenAvailableRect.x() + (screenAvailableRect.width() - width) / 2; 198 xSet = true; 199 } 200 if (!ySet) { 201 y = screenAvailableRect.y() + (screenAvailableRect.height() - height) / 2; 202 ySet = true; 203 } 184 if (!x) 185 x = screenAvailableRect.x() + (screenAvailableRect.width() - *width) / 2; 186 187 if (!y) 188 y = screenAvailableRect.y() + (screenAvailableRect.height() - *height) / 2; 204 189 } 205 190 … … 209 194 } 210 195 211 bool WindowFeatures::boolFeature(const DialogFeaturesMap& features, const char* key, bool defaultValue)212 { 213 DialogFeaturesMap::const_iteratorit = features.find(key);196 bool WindowFeatures::boolFeature(const HashMap<String, String>& features, const char* key, bool defaultValue) 197 { 198 auto it = features.find(key); 214 199 if (it == features.end()) 215 200 return defaultValue; 201 216 202 const String& value = it->value; 217 203 return value.isNull() || value == "1" || value == "yes" || value == "on"; 218 204 } 219 205 220 float WindowFeatures::floatFeature(const DialogFeaturesMap& features, const char* key, float min, float max, float defaultValue)221 { 222 DialogFeaturesMap::const_iteratorit = features.find(key);206 float WindowFeatures::floatFeature(const HashMap<String, String>& features, const char* key, float min, float max, float defaultValue) 207 { 208 auto it = features.find(key); 223 209 if (it == features.end()) 224 210 return defaultValue; 211 225 212 // FIXME: The toDouble function does not offer a way to tell "0q" from string with no digits in it: Both 226 213 // return the number 0 and false for ok. But "0q" should yield the minimum rather than the default. … … 233 220 if (parsedNumber > max) 234 221 return max; 222 235 223 // FIXME: Seems strange to cast a double to int and then convert back to a float. Why is this a good idea? 236 224 return static_cast<int>(parsedNumber); 237 225 } 238 226 239 void WindowFeatures::parseDialogFeatures(const String& string, DialogFeaturesMap& map) 240 { 227 HashMap<String, String> WindowFeatures::parseDialogFeatures(const String& string) 228 { 229 HashMap<String, String> features; 230 241 231 Vector<String> vector; 242 232 string.split(';', vector); 233 243 234 for (auto& featureString : vector) { 244 235 size_t separatorPosition = featureString.find('='); … … 258 249 } 259 250 260 map.set(key, value); 261 } 251 features.set(key, value); 252 } 253 254 return features; 262 255 } 263 256 -
trunk/Source/WebCore/page/WindowFeatures.h
r166072 r188386 30 30 #define WindowFeatures_h 31 31 32 #include <wtf/Forward.h> 32 33 #include <wtf/HashMap.h> 33 #include <wtf/text/WTFString.h> 34 #include <wtf/Optional.h> 35 #include <wtf/Vector.h> 36 #include <wtf/text/StringHash.h> 34 37 35 38 namespace WebCore { … … 39 42 struct WindowFeatures { 40 43 WindowFeatures() 41 : x(0) 42 , xSet(false) 43 , y(0) 44 , ySet(false) 45 , width(0) 46 , widthSet(false) 47 , height(0) 48 , heightSet(false) 49 , menuBarVisible(true) 44 : menuBarVisible(true) 50 45 , statusBarVisible(true) 51 46 , toolBarVisible(true) … … 60 55 WindowFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect); 61 56 62 float x; 63 bool xSet; 64 float y; 65 bool ySet; 66 float width; 67 bool widthSet; 68 float height; 69 bool heightSet; 57 Optional<float> x; 58 Optional<float> y; 59 Optional<float> width; 60 Optional<float> height; 70 61 71 62 bool menuBarVisible; … … 82 73 83 74 private: 84 typedef HashMap<String, String> DialogFeaturesMap; 85 static void parseDialogFeatures(const String&, HashMap<String, String>&); 86 static bool boolFeature(const DialogFeaturesMap&, const char* key, bool defaultValue = false); 87 static float floatFeature(const DialogFeaturesMap&, const char* key, float min, float max, float defaultValue); 75 static HashMap<String, String> parseDialogFeatures(const String&); 76 static bool boolFeature(const HashMap<String, String>&, const char* key, bool defaultValue = false); 77 static float floatFeature(const HashMap<String, String>&, const char* key, float min, float max, float defaultValue); 88 78 void setWindowFeature(const String& keyString, const String& valueString); 89 79 }; -
trunk/Source/WebKit/mac/ChangeLog
r188385 r188386 1 2015-08-12 Anders Carlsson <andersca@apple.com> 2 3 Use WTF::Optional in WindowFeatures 4 https://bugs.webkit.org/show_bug.cgi?id=147956 5 6 Reviewed by Sam Weinig. 7 8 * WebCoreSupport/WebChromeClient.mm: 9 (WebChromeClient::createWindow): 10 1 11 2015-08-13 Matthew Daiter <mdaiter@apple.com> 2 12 -
trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
r187002 r188386 241 241 242 242 if ([delegate respondsToSelector:@selector(webView:createWebViewWithRequest:windowFeatures:)]) { 243 NSNumber *x = features.x Set ? [[NSNumber alloc] initWithFloat:features.x] : nil;244 NSNumber *y = features.y Set ? [[NSNumber alloc] initWithFloat:features.y] : nil;245 NSNumber *width = features.width Set ? [[NSNumber alloc] initWithFloat:features.width] : nil;246 NSNumber *height = features.height Set ? [[NSNumber alloc] initWithFloat:features.height] : nil;243 NSNumber *x = features.x ? [[NSNumber alloc] initWithFloat:*features.x] : nil; 244 NSNumber *y = features.y ? [[NSNumber alloc] initWithFloat:*features.y] : nil; 245 NSNumber *width = features.width ? [[NSNumber alloc] initWithFloat:*features.width] : nil; 246 NSNumber *height = features.height ? [[NSNumber alloc] initWithFloat:*features.height] : nil; 247 247 NSNumber *menuBarVisible = [[NSNumber alloc] initWithBool:features.menuBarVisible]; 248 248 NSNumber *statusBarVisible = [[NSNumber alloc] initWithBool:features.statusBarVisible]; -
trunk/Source/WebKit/win/ChangeLog
r188215 r188386 1 2015-08-12 Anders Carlsson <andersca@apple.com> 2 3 Use WTF::Optional in WindowFeatures 4 https://bugs.webkit.org/show_bug.cgi?id=147956 5 6 Reviewed by Sam Weinig. 7 8 * WebCoreSupport/WebChromeClient.cpp: 9 (createWindowFeaturesPropertyBag): 10 1 11 2015-08-10 Per Arne Vollan <peavo@outlook.com> 2 12 -
trunk/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
r187002 r188386 171 171 { 172 172 HashMap<String, COMVariant> map; 173 if (features.x Set)174 map.set(WebWindowFeaturesXKey, features.x);175 if (features.y Set)176 map.set(WebWindowFeaturesYKey, features.y);177 if (features.width Set)178 map.set(WebWindowFeaturesWidthKey, features.width);179 if (features.height Set)180 map.set(WebWindowFeaturesHeightKey, features.height);173 if (features.x) 174 map.set(WebWindowFeaturesXKey, *features.x); 175 if (features.y) 176 map.set(WebWindowFeaturesYKey, *features.y); 177 if (features.width) 178 map.set(WebWindowFeaturesWidthKey, *features.width); 179 if (features.height) 180 map.set(WebWindowFeaturesHeightKey, *features.height); 181 181 map.set(WebWindowFeaturesMenuBarVisibleKey, features.menuBarVisible); 182 182 map.set(WebWindowFeaturesStatusBarVisibleKey, features.statusBarVisible); -
trunk/Source/WebKit2/ChangeLog
r188385 r188386 1 2015-08-12 Anders Carlsson <andersca@apple.com> 2 3 Use WTF::Optional in WindowFeatures 4 https://bugs.webkit.org/show_bug.cgi?id=147956 5 6 Reviewed by Sam Weinig. 7 8 * Shared/WebCoreArgumentCoders.cpp: 9 (IPC::ArgumentCoder<WindowFeatures>::encode): Deleted. 10 (IPC::ArgumentCoder<WindowFeatures>::decode): Deleted. 11 * UIProcess/API/C/WKPage.cpp: 12 (WKPageSetPageUIClient): 13 * UIProcess/API/Cocoa/WKWindowFeatures.mm: 14 (-[WKWindowFeatures _initWithWindowFeatures:]): 15 1 16 2015-08-13 Matthew Daiter <mdaiter@apple.com> 2 17 -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
r188115 r188386 957 957 encoder << windowFeatures.width; 958 958 encoder << windowFeatures.height; 959 encoder << windowFeatures.xSet;960 encoder << windowFeatures.ySet;961 encoder << windowFeatures.widthSet;962 encoder << windowFeatures.heightSet;963 959 encoder << windowFeatures.menuBarVisible; 964 960 encoder << windowFeatures.statusBarVisible; … … 980 976 return false; 981 977 if (!decoder.decode(windowFeatures.height)) 982 return false;983 if (!decoder.decode(windowFeatures.xSet))984 return false;985 if (!decoder.decode(windowFeatures.ySet))986 return false;987 if (!decoder.decode(windowFeatures.widthSet))988 return false;989 if (!decoder.decode(windowFeatures.heightSet))990 978 return false; 991 979 if (!decoder.decode(windowFeatures.menuBarVisible)) -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r188348 r188386 1351 1351 1352 1352 API::Dictionary::MapType map; 1353 if (windowFeatures.x Set)1354 map.set("x", API::Double::create( windowFeatures.x));1355 if (windowFeatures.y Set)1356 map.set("y", API::Double::create( windowFeatures.y));1357 if (windowFeatures.width Set)1358 map.set("width", API::Double::create( windowFeatures.width));1359 if (windowFeatures.height Set)1360 map.set("height", API::Double::create( windowFeatures.height));1353 if (windowFeatures.x) 1354 map.set("x", API::Double::create(*windowFeatures.x)); 1355 if (windowFeatures.y) 1356 map.set("y", API::Double::create(*windowFeatures.y)); 1357 if (windowFeatures.width) 1358 map.set("width", API::Double::create(*windowFeatures.width)); 1359 if (windowFeatures.height) 1360 map.set("height", API::Double::create(*windowFeatures.height)); 1361 1361 map.set("menuBarVisible", API::Boolean::create(windowFeatures.menuBarVisible)); 1362 1362 map.set("statusBarVisible", API::Boolean::create(windowFeatures.statusBarVisible)); -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeatures.mm
r166267 r188386 56 56 _allowsResizing = @(windowFeatures.resizable); 57 57 58 if (windowFeatures.x Set)59 _x = @( windowFeatures.x);60 if (windowFeatures.y Set)61 _y = @( windowFeatures.y);62 if (windowFeatures.width Set)63 _width = @( windowFeatures.width);64 if (windowFeatures.height Set)65 _height = @( windowFeatures.height);58 if (windowFeatures.x) 59 _x = @(*windowFeatures.x); 60 if (windowFeatures.y) 61 _y = @(*windowFeatures.y); 62 if (windowFeatures.width) 63 _width = @(*windowFeatures.width); 64 if (windowFeatures.height) 65 _height = @(*windowFeatures.height); 66 66 67 67 return self;
Note:
See TracChangeset
for help on using the changeset viewer.