Example #1
0
WindowFeatures::WindowFeatures(const String& dialogFeaturesString,
                               const IntRect& screenAvailableRect)
    : widthSet(true),
      heightSet(true),
      menuBarVisible(false),
      toolBarVisible(false),
      locationBarVisible(false),
      fullscreen(false),
      dialog(true),
      noopener(false) {
    DialogFeaturesMap features;
    parseDialogFeatures(dialogFeaturesString, features);

    const bool trusted = 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, screenAvailableRect.width(),
                       620);
    // default here came from frame size of dialog in MacIE
    height = intFeature(features, "dialogheight", 100,
                        screenAvailableRect.height(), 450);

    x = intFeature(features, "dialogleft", screenAvailableRect.x(),
                   screenAvailableRect.maxX() - width, -1);
    xSet = x > 0;
    y = intFeature(features, "dialogtop", screenAvailableRect.y(),
                   screenAvailableRect.maxY() - height, -1);
    ySet = y > 0;

    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;
        }
    }

    resizable = boolFeature(features, "resizable");
    scrollbarsVisible = boolFeature(features, "scroll", true);
    statusBarVisible = boolFeature(features, "status", !trusted);
}
Example #2
0
WindowFeatures parseDialogFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect)
{
    auto featuresMap = parseDialogFeaturesMap(dialogFeaturesString);

    // 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");

    WindowFeatures features;

    features.menuBarVisible = false;
    features.toolBarVisible = false;
    features.locationBarVisible = false;
    features.dialog = true;

    float width = floatFeature(featuresMap, "dialogwidth", 100, screenAvailableRect.width()).valueOr(620); // default here came from frame size of dialog in MacIE
    float height = floatFeature(featuresMap, "dialogheight", 100, screenAvailableRect.height()).valueOr(450); // default here came from frame size of dialog in MacIE

    features.width = width;
    features.height = height;

    features.x = floatFeature(featuresMap, "dialogleft", screenAvailableRect.x(), screenAvailableRect.maxX() - width);
    features.y = floatFeature(featuresMap, "dialogtop", screenAvailableRect.y(), screenAvailableRect.maxY() - height);

    if (boolFeature(featuresMap, "center").valueOr(true)) {
        if (!features.x)
            features.x = screenAvailableRect.x() + (screenAvailableRect.width() - width) / 2;
        if (!features.y)
            features.y = screenAvailableRect.y() + (screenAvailableRect.height() - height) / 2;
    }

    features.resizable = boolFeature(featuresMap, "resizable").valueOr(false);
    features.scrollbarsVisible = boolFeature(featuresMap, "scroll").valueOr(true);
    features.statusBarVisible = boolFeature(featuresMap, "status").valueOr(false);

    return features;
}