⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 194075 in webkit


Ignore:
Timestamp:
Dec 14, 2015, 4:35:16 PM (11 years ago)
Author:
matthew_hanson@apple.com
Message:

Merge r188386. rdar://problem/23816165

Location:
branches/safari-601-branch/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-601-branch/Source/WTF/ChangeLog

    r190768 r194075  
     12015-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
    1182015-10-08  Lucas Forschler  <lforschler@apple.com>
    219
  • branches/safari-601-branch/Source/WTF/wtf/Optional.h

    r182254 r194075  
    134134    explicit operator bool() const { return m_isEngaged; }
    135135
     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
    136151    T& value()
    137152    {
  • branches/safari-601-branch/Source/WebCore/ChangeLog

    r194065 r194075  
     12015-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
    1232015-12-14  Matthew Hanson  <matthew_hanson@apple.com>
    224
  • branches/safari-601-branch/Source/WebCore/loader/FrameLoader.cpp

    r191027 r194075  
    35473547    FloatSize viewportSize = page->chrome().pageRect().size();
    35483548    FloatRect windowRect = page->chrome().windowRect();
    3549     if (features.xSet)
    3550         windowRect.setX(features.x);
    3551     if (features.ySet)
    3552         windowRect.setY(features.y);
     3549    if (features.x)
     3550        windowRect.setX(*features.x);
     3551    if (features.y)
     3552        windowRect.setY(*features.y);
    35533553    // Zero width and height mean using default size, not minumum one.
    3554     if (features.widthSet && features.width)
    3555         windowRect.setWidth(features.width + (windowRect.width() - viewportSize.width()));
    3556     if (features.heightSet && 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()));
    35583558
    35593559    // Ensure non-NaN values, minimum size as well as being within valid screen area.
     
    35673567    ViewportArguments arguments;
    35683568    // Zero width and height mean using default size, not minimum one.
    3569     if (features.widthSet && features.width)
    3570         arguments.width = features.width;
    3571     if (features.heightSet && 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;
    35733573    frame->setViewportArguments(arguments);
    35743574#endif
  • branches/safari-601-branch/Source/WebCore/page/WindowFeatures.cpp

    r185167 r194075  
    3838
    3939WindowFeatures::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)
    4941    , fullscreen(false)
    5042    , dialog(false)
     
    135127    // This is consistent with Firefox, but could also be handled at another level.
    136128
    137     if (keyString == "left" || keyString == "screenx") {
    138         xSet = true;
     129    if (keyString == "left" || keyString == "screenx")
    139130        x = value;
    140     } else if (keyString == "top" || keyString == "screeny") {
    141         ySet = true;
     131    else if (keyString == "top" || keyString == "screeny")
    142132        y = value;
    143     } else if (keyString == "width" || keyString == "innerwidth") {
    144         widthSet = true;
     133    else if (keyString == "width" || keyString == "innerwidth")
    145134        width = value;
    146     } else if (keyString == "height" || keyString == "innerheight") {
    147         heightSet = true;
     135    else if (keyString == "height" || keyString == "innerheight")
    148136        height = value;
    149     } else if (keyString == "menubar")
     137    else if (keyString == "menubar")
    150138        menuBarVisible = value;
    151139    else if (keyString == "toolbar")
     
    164152
    165153WindowFeatures::WindowFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect)
    166     : widthSet(true)
    167     , heightSet(true)
    168     , menuBarVisible(false)
     154    : menuBarVisible(false)
    169155    , toolBarVisible(false)
    170156    , locationBarVisible(false)
     
    172158    , dialog(true)
    173159{
    174     DialogFeaturesMap features;
    175     parseDialogFeatures(dialogFeaturesString, features);
     160    auto features = parseDialogFeatures(dialogFeaturesString);
    176161
    177162    const bool trusted = false;
     
    188173    height = floatFeature(features, "dialogheight", 100, screenAvailableRect.height(), 450); // default here came from frame size of dialog in MacIE
    189174
    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;
    194182
    195183    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;
    204189    }
    205190
     
    209194}
    210195
    211 bool WindowFeatures::boolFeature(const DialogFeaturesMap& features, const char* key, bool defaultValue)
    212 {
    213     DialogFeaturesMap::const_iterator it = features.find(key);
     196bool WindowFeatures::boolFeature(const HashMap<String, String>& features, const char* key, bool defaultValue)
     197{
     198    auto it = features.find(key);
    214199    if (it == features.end())
    215200        return defaultValue;
     201
    216202    const String& value = it->value;
    217203    return value.isNull() || value == "1" || value == "yes" || value == "on";
    218204}
    219205
    220 float WindowFeatures::floatFeature(const DialogFeaturesMap& features, const char* key, float min, float max, float defaultValue)
    221 {
    222     DialogFeaturesMap::const_iterator it = features.find(key);
     206float WindowFeatures::floatFeature(const HashMap<String, String>& features, const char* key, float min, float max, float defaultValue)
     207{
     208    auto it = features.find(key);
    223209    if (it == features.end())
    224210        return defaultValue;
     211
    225212    // FIXME: The toDouble function does not offer a way to tell "0q" from string with no digits in it: Both
    226213    // return the number 0 and false for ok. But "0q" should yield the minimum rather than the default.
     
    233220    if (parsedNumber > max)
    234221        return max;
     222
    235223    // FIXME: Seems strange to cast a double to int and then convert back to a float. Why is this a good idea?
    236224    return static_cast<int>(parsedNumber);
    237225}
    238226
    239 void WindowFeatures::parseDialogFeatures(const String& string, DialogFeaturesMap& map)
    240 {
     227HashMap<String, String> WindowFeatures::parseDialogFeatures(const String& string)
     228{
     229    HashMap<String, String> features;
     230
    241231    Vector<String> vector;
    242232    string.split(';', vector);
     233
    243234    for (auto& featureString : vector) {
    244235        size_t separatorPosition = featureString.find('=');
     
    258249        }
    259250
    260         map.set(key, value);
    261     }
     251        features.set(key, value);
     252    }
     253
     254    return features;
    262255}
    263256
  • branches/safari-601-branch/Source/WebCore/page/WindowFeatures.h

    r166072 r194075  
    3030#define WindowFeatures_h
    3131
     32#include <wtf/Forward.h>
    3233#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>
    3437
    3538namespace WebCore {
     
    3942struct WindowFeatures {
    4043    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)
    5045        , statusBarVisible(true)
    5146        , toolBarVisible(true)
     
    6055    WindowFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect);
    6156
    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;
    7061
    7162    bool menuBarVisible;
     
    8273
    8374private:
    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);
    8878    void setWindowFeature(const String& keyString, const String& valueString);
    8979};
  • branches/safari-601-branch/Source/WebKit/mac/ChangeLog

    r193960 r194075  
     12015-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
    1152015-12-11  Matthew Hanson  <matthew_hanson@apple.com>
    216
  • branches/safari-601-branch/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm

    r185893 r194075  
    241241   
    242242    if ([delegate respondsToSelector:@selector(webView:createWebViewWithRequest:windowFeatures:)]) {
    243         NSNumber *x = features.xSet ? [[NSNumber alloc] initWithFloat:features.x] : nil;
    244         NSNumber *y = features.ySet ? [[NSNumber alloc] initWithFloat:features.y] : nil;
    245         NSNumber *width = features.widthSet ? [[NSNumber alloc] initWithFloat:features.width] : nil;
    246         NSNumber *height = features.heightSet ? [[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;
    247247        NSNumber *menuBarVisible = [[NSNumber alloc] initWithBool:features.menuBarVisible];
    248248        NSNumber *statusBarVisible = [[NSNumber alloc] initWithBool:features.statusBarVisible];
  • branches/safari-601-branch/Source/WebKit/win/ChangeLog

    r190259 r194075  
     12015-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
    1152015-09-25  Brent Fulgham  <bfulgham@apple.com>
    216
  • branches/safari-601-branch/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp

    r186121 r194075  
    171171{
    172172    HashMap<String, COMVariant> map;
    173     if (features.xSet)
    174         map.set(WebWindowFeaturesXKey, features.x);
    175     if (features.ySet)
    176         map.set(WebWindowFeaturesYKey, features.y);
    177     if (features.widthSet)
    178         map.set(WebWindowFeaturesWidthKey, features.width);
    179     if (features.heightSet)
    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);
    181181    map.set(WebWindowFeaturesMenuBarVisibleKey, features.menuBarVisible);
    182182    map.set(WebWindowFeaturesStatusBarVisibleKey, features.statusBarVisible);
  • branches/safari-601-branch/Source/WebKit2/ChangeLog

    r194074 r194075  
     12015-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
    1202015-12-08  Harris Papadopoulos  <cpapadopoulos@apple.com>
    221
  • branches/safari-601-branch/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

    r193960 r194075  
    978978    encoder << windowFeatures.width;
    979979    encoder << windowFeatures.height;
    980     encoder << windowFeatures.xSet;
    981     encoder << windowFeatures.ySet;
    982     encoder << windowFeatures.widthSet;
    983     encoder << windowFeatures.heightSet;
    984980    encoder << windowFeatures.menuBarVisible;
    985981    encoder << windowFeatures.statusBarVisible;
     
    1001997        return false;
    1002998    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))
    1011999        return false;
    10121000    if (!decoder.decode(windowFeatures.menuBarVisible))
  • branches/safari-601-branch/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r194074 r194075  
    13511351
    13521352            API::Dictionary::MapType map;
    1353             if (windowFeatures.xSet)
    1354                 map.set("x", API::Double::create(windowFeatures.x));
    1355             if (windowFeatures.ySet)
    1356                 map.set("y", API::Double::create(windowFeatures.y));
    1357             if (windowFeatures.widthSet)
    1358                 map.set("width", API::Double::create(windowFeatures.width));
    1359             if (windowFeatures.heightSet)
    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));
    13611361            map.set("menuBarVisible", API::Boolean::create(windowFeatures.menuBarVisible));
    13621362            map.set("statusBarVisible", API::Boolean::create(windowFeatures.statusBarVisible));
  • branches/safari-601-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeatures.mm

    r166267 r194075  
    5656    _allowsResizing = @(windowFeatures.resizable);
    5757
    58     if (windowFeatures.xSet)
    59         _x = @(windowFeatures.x);
    60     if (windowFeatures.ySet)
    61         _y = @(windowFeatures.y);
    62     if (windowFeatures.widthSet)
    63         _width = @(windowFeatures.width);
    64     if (windowFeatures.heightSet)
    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);
    6666
    6767    return self;
Note: See TracChangeset for help on using the changeset viewer.