Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/WindowFeatures.cpp |
| diff --git a/third_party/WebKit/Source/core/page/WindowFeatures.cpp b/third_party/WebKit/Source/core/page/WindowFeatures.cpp |
| index 6b2133dec9ae947ebaa626b9f4e083f8d5ea1d43..e088398af968d2208ee3c355723cdc5ecf431890 100644 |
| --- a/third_party/WebKit/Source/core/page/WindowFeatures.cpp |
| +++ b/third_party/WebKit/Source/core/page/WindowFeatures.cpp |
| @@ -46,24 +46,17 @@ WindowFeatures::WindowFeatures(const String& features) |
| width_set(false), |
| height(0), |
| height_set(false), |
| - resizable(true), |
| - fullscreen(false), |
| - dialog(false), |
| - noopener(false) { |
| - /* |
| - The IE rule is: all features except for channelmode and fullscreen default |
| - to YES, but if the user specifies a feature string, all features default to |
| - NO. (There is no public standard that applies to this method.) |
| - |
| - <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp> |
| - We always allow a window to be resized, which is consistent with Firefox. |
| - */ |
| - |
| + noopener(false), |
| + background(false), |
| + persistent(false) { |
| + // The IE rule is: all features except for channelmode default |
| + // to YES, but if the user specifies a feature string, all features default to |
| + // NO. (There is no public standard that applies to this method.) |
|
Nate Chapin
2017/05/31 16:55:13
I guess there is a spec for this now, kind of. The
|
| + // <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp> |
| if (features.IsEmpty()) { |
| menu_bar_visible = true; |
| status_bar_visible = true; |
| tool_bar_visible = true; |
| - location_bar_visible = true; |
| scrollbars_visible = true; |
| return; |
| } |
| @@ -71,7 +64,6 @@ WindowFeatures::WindowFeatures(const String& features) |
| menu_bar_visible = false; |
| status_bar_visible = false; |
| tool_bar_visible = false; |
| - location_bar_visible = false; |
| scrollbars_visible = false; |
| // Tread lightly in this code -- it was specifically designed to mimic Win |
| @@ -138,10 +130,6 @@ void WindowFeatures::SetWindowFeature(const String& key_string, |
| else |
| value = value_string.ToInt(); |
| - // 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 (key_string == "left" || key_string == "screenx") { |
| x_set = true; |
| x = value; |
| @@ -156,138 +144,18 @@ void WindowFeatures::SetWindowFeature(const String& key_string, |
| height = value; |
| } else if (key_string == "menubar") { |
| menu_bar_visible = value; |
| - } else if (key_string == "toolbar") { |
| - tool_bar_visible = value; |
| - } else if (key_string == "location") { |
| - location_bar_visible = value; |
| + } else if (key_string == "toolbar" || key_string == "location") { |
| + tool_bar_visible |= static_cast<bool>(value); |
| } else if (key_string == "status") { |
| status_bar_visible = value; |
| - } else if (key_string == "fullscreen") { |
| - fullscreen = value; |
| } else if (key_string == "scrollbars") { |
| scrollbars_visible = value; |
| } else if (key_string == "noopener") { |
| noopener = true; |
| - } else if (value == 1) { |
| - additional_features.push_back(key_string); |
| - } |
| -} |
| - |
| -WindowFeatures::WindowFeatures(const String& dialog_features_string, |
| - const IntRect& screen_available_rect) |
| - : width_set(true), |
| - height_set(true), |
| - menu_bar_visible(false), |
| - tool_bar_visible(false), |
| - location_bar_visible(false), |
| - fullscreen(false), |
| - dialog(true), |
| - noopener(false) { |
| - DialogFeaturesMap features; |
| - ParseDialogFeatures(dialog_features_string, features); |
| - |
| - const bool kTrusted = false; |
| - |
| - // The following features from Microsoft's documentation are not implemented: |
| - // - default font settings |
| - // - width, height, left, and top specified in units other than "px" |
| - // - edge (sunken or raised, default is raised) |
| - // - dialogHide: trusted && boolFeature(features, "dialoghide"), makes dialog |
| - // hide when you print |
| - // - help: boolFeature(features, "help", true), makes help icon appear in |
| - // dialog (what does it do on Windows?) |
| - // - unadorned: trusted && boolFeature(features, "unadorned"); |
| - |
| - // default here came from frame size of dialog in MacIE |
| - width = IntFeature(features, "dialogwidth", 100, |
| - screen_available_rect.Width(), 620); |
| - // default here came from frame size of dialog in MacIE |
| - height = IntFeature(features, "dialogheight", 100, |
| - screen_available_rect.Height(), 450); |
| - |
| - x = IntFeature(features, "dialogleft", screen_available_rect.X(), |
| - screen_available_rect.MaxX() - width, -1); |
| - x_set = x > 0; |
| - y = IntFeature(features, "dialogtop", screen_available_rect.Y(), |
| - screen_available_rect.MaxY() - height, -1); |
| - y_set = y > 0; |
| - |
| - if (BoolFeature(features, "center", true)) { |
| - if (!x_set) { |
| - x = screen_available_rect.X() + |
| - (screen_available_rect.Width() - width) / 2; |
| - x_set = true; |
| - } |
| - if (!y_set) { |
| - y = screen_available_rect.Y() + |
| - (screen_available_rect.Height() - height) / 2; |
| - y_set = true; |
| - } |
| - } |
| - |
| - resizable = BoolFeature(features, "resizable"); |
| - scrollbars_visible = BoolFeature(features, "scroll", true); |
| - status_bar_visible = BoolFeature(features, "status", !kTrusted); |
| -} |
| - |
| -bool WindowFeatures::BoolFeature(const DialogFeaturesMap& features, |
| - const char* key, |
| - bool default_value) { |
| - DialogFeaturesMap::const_iterator it = features.find(key); |
| - if (it == features.end()) |
| - return default_value; |
| - const String& value = it->value; |
| - return value.IsNull() || value == "1" || value == "yes" || value == "on"; |
| -} |
| - |
| -int WindowFeatures::IntFeature(const DialogFeaturesMap& features, |
| - const char* key, |
| - int min, |
| - int max, |
| - int default_value) { |
| - DialogFeaturesMap::const_iterator it = features.find(key); |
| - if (it == features.end()) |
| - return default_value; |
| - bool ok; |
| - int parsed_number = it->value.ToInt(&ok); |
| - if (!ok) |
| - return default_value; |
| - if (parsed_number < min || max <= min) |
| - return min; |
| - if (parsed_number > max) |
| - return max; |
| - return parsed_number; |
| -} |
| - |
| -void WindowFeatures::ParseDialogFeatures(const String& string, |
| - DialogFeaturesMap& map) { |
| - Vector<String> vector; |
| - string.Split(';', vector); |
| - size_t size = vector.size(); |
| - for (size_t i = 0; i < size; ++i) { |
| - const String& feature_string = vector[i]; |
| - |
| - size_t separator_position = feature_string.find('='); |
| - size_t colon_position = feature_string.find(':'); |
| - if (separator_position != kNotFound && colon_position != kNotFound) |
| - continue; // ignore strings that have both = and : |
| - if (separator_position == kNotFound) |
| - separator_position = colon_position; |
| - |
| - String key = feature_string.Left(separator_position) |
| - .StripWhiteSpace() |
| - .DeprecatedLower(); |
| - |
| - // Null string for value indicates key without value. |
| - String value; |
| - if (separator_position != kNotFound) { |
| - value = feature_string.Substring(separator_position + 1) |
| - .StripWhiteSpace() |
| - .DeprecatedLower(); |
| - value = value.Left(value.find(' ')); |
| - } |
| - |
| - map.Set(key, value); |
| + } else if (key_string == "background") { |
| + background = true; |
| + } else if (key_string == "persistent") { |
| + persistent = true; |
| } |
| } |