Changeset 194075 in webkit
- Timestamp:
- Dec 14, 2015, 4:35:16 PM (11 years ago)
- Location:
- branches/safari-601-branch/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
-
branches/safari-601-branch/Source/WTF/ChangeLog
r190768 r194075 1 2015-12-08 Harris Papadopoulos <cpapadopoulos@apple.com> 2 3 Merge r188386. rdar://problem/23816165 4 5 2015-08-12 Anders Carlsson <andersca@apple.com> 6 7 Use WTF::Optional in WindowFeatures 8 https://bugs.webkit.org/show_bug.cgi?id=147956 9 10 Reviewed by Sam Weinig. 11 12 Add new operators to WTF::Optional to make it more like std::optional. 13 14 * wtf/Optional.h: 15 (WTF::Optional::operator->): 16 (WTF::Optional::operator*): 17 1 18 2015-10-08 Lucas Forschler <lforschler@apple.com> 2 19 -
branches/safari-601-branch/Source/WTF/wtf/Optional.h
r182254 r194075 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 { -
branches/safari-601-branch/Source/WebCore/ChangeLog
r194065 r194075 1 2015-12-08 Harris Papadopoulos <cpapadopoulos@apple.com> 2 3 Merge r188386. rdar://problem/23816165 4 5 2015-08-12 Anders Carlsson <andersca@apple.com> 6 7 Use WTF::Optional in WindowFeatures 8 https://bugs.webkit.org/show_bug.cgi?id=147956 9 10 Reviewed by Sam Weinig. 11 12 * loader/FrameLoader.cpp: 13 (WebCore::createWindow): 14 * page/WindowFeatures.cpp: 15 (WebCore::WindowFeatures::WindowFeatures): 16 (WebCore::WindowFeatures::setWindowFeature): 17 (WebCore::WindowFeatures::boolFeature): 18 (WebCore::WindowFeatures::floatFeature): 19 (WebCore::WindowFeatures::parseDialogFeatures): 20 * page/WindowFeatures.h: 21 (WebCore::WindowFeatures::WindowFeatures): 22 1 23 2015-12-14 Matthew Hanson <matthew_hanson@apple.com> 2 24 -
branches/safari-601-branch/Source/WebCore/loader/FrameLoader.cpp
r191027 r194075 3547 3547 FloatSize viewportSize = page->chrome().pageRect().size(); 3548 3548 FloatRect windowRect = page->chrome().windowRect(); 3549 if (features.x Set)3550 windowRect.setX( features.x);3551 if (features.y Set)3552 windowRect.setY( features.y);3549 if (features.x) 3550 windowRect.setX(*features.x); 3551 if (features.y) 3552 windowRect.setY(*features.y); 3553 3553 // Zero width and height mean using default size, not minumum one. 3554 if (features.width Set &&features.width)3555 windowRect.setWidth( features.width + (windowRect.width() - viewportSize.width()));3556 if (features.height Set &&features.height)3557 windowRect.setHeight( features.height + (windowRect.height() - viewportSize.height()));3554 if (features.width && *features.width) 3555 windowRect.setWidth(*features.width + (windowRect.width() - viewportSize.width())); 3556 if (features.height && *features.height) 3557 windowRect.setHeight(*features.height + (windowRect.height() - viewportSize.height())); 3558 3558 3559 3559 // Ensure non-NaN values, minimum size as well as being within valid screen area. … … 3567 3567 ViewportArguments arguments; 3568 3568 // Zero width and height mean using default size, not minimum one. 3569 if (features.width Set &&features.width)3570 arguments.width = features.width;3571 if (features.height Set &&features.height)3572 arguments.height = features.height;3569 if (features.width && *features.width) 3570 arguments.width = *features.width; 3571 if (features.height && *features.height) 3572 arguments.height = *features.height; 3573 3573 frame->setViewportArguments(arguments); 3574 3574 #endif -
branches/safari-601-branch/Source/WebCore/page/WindowFeatures.cpp
r185167 r194075 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 -
branches/safari-601-branch/Source/WebCore/page/WindowFeatures.h
r166072 r194075 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 }; -
branches/safari-601-branch/Source/WebKit/mac/ChangeLog
r193960 r194075 1 2015-12-08 Harris Papadopoulos <cpapadopoulos@apple.com> 2 3 Merge r188386. rdar://problem/23816165 4 5 2015-08-12 Anders Carlsson <andersca@apple.com> 6 7 Use WTF::Optional in WindowFeatures 8 https://bugs.webkit.org/show_bug.cgi?id=147956 9 10 Reviewed by Sam Weinig. 11 12 * WebCoreSupport/WebChromeClient.mm: 13 (WebChromeClient::createWindow): 14 1 15 2015-12-11 Matthew Hanson <matthew_hanson@apple.com> 2 16 -
branches/safari-601-branch/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
r185893 r194075 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]; -
branches/safari-601-branch/Source/WebKit/win/ChangeLog
r190259 r194075 1 2015-12-08 Harris Papadopoulos <cpapadopoulos@apple.com> 2 3 Merge r188386. rdar://problem/23816165 4 5 2015-08-12 Anders Carlsson <andersca@apple.com> 6 7 Use WTF::Optional in WindowFeatures 8 https://bugs.webkit.org/show_bug.cgi?id=147956 9 10 Reviewed by Sam Weinig. 11 12 * WebCoreSupport/WebChromeClient.cpp: 13 (createWindowFeaturesPropertyBag): 14 1 15 2015-09-25 Brent Fulgham <bfulgham@apple.com> 2 16 -
branches/safari-601-branch/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
r186121 r194075 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); -
branches/safari-601-branch/Source/WebKit2/ChangeLog
r194074 r194075 1 2015-12-08 Harris Papadopoulos <cpapadopoulos@apple.com> 2 3 Merge r188386. rdar://problem/23816165 4 5 2015-08-12 Anders Carlsson <andersca@apple.com> 6 7 Use WTF::Optional in WindowFeatures 8 https://bugs.webkit.org/show_bug.cgi?id=147956 9 10 Reviewed by Sam Weinig. 11 12 * Shared/WebCoreArgumentCoders.cpp: 13 (IPC::ArgumentCoder<WindowFeatures>::encode): Deleted. 14 (IPC::ArgumentCoder<WindowFeatures>::decode): Deleted. 15 * UIProcess/API/C/WKPage.cpp: 16 (WKPageSetPageUIClient): 17 * UIProcess/API/Cocoa/WKWindowFeatures.mm: 18 (-[WKWindowFeatures _initWithWindowFeatures:]): 19 1 20 2015-12-08 Harris Papadopoulos <cpapadopoulos@apple.com> 2 21 -
branches/safari-601-branch/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
r193960 r194075 978 978 encoder << windowFeatures.width; 979 979 encoder << windowFeatures.height; 980 encoder << windowFeatures.xSet;981 encoder << windowFeatures.ySet;982 encoder << windowFeatures.widthSet;983 encoder << windowFeatures.heightSet;984 980 encoder << windowFeatures.menuBarVisible; 985 981 encoder << windowFeatures.statusBarVisible; … … 1001 997 return false; 1002 998 if (!decoder.decode(windowFeatures.height)) 1003 return false;1004 if (!decoder.decode(windowFeatures.xSet))1005 return false;1006 if (!decoder.decode(windowFeatures.ySet))1007 return false;1008 if (!decoder.decode(windowFeatures.widthSet))1009 return false;1010 if (!decoder.decode(windowFeatures.heightSet))1011 999 return false; 1012 1000 if (!decoder.decode(windowFeatures.menuBarVisible)) -
branches/safari-601-branch/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r194074 r194075 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)); -
branches/safari-601-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeatures.mm
r166267 r194075 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.