Changeset 50906 in webkit


Ignore:
Timestamp:
Nov 12, 2009 2:40:38 PM (14 years ago)
Author:
Adam Roben
Message:

Small clean-up in WebView's user content functions

Preparation for <http://webkit.org/b/31414> Implement new SPI for
dealing with user scripts/stylesheets and isolated worlds

Reviewed by Dave Hyatt.

  • WebView.cpp:

(toString):
(toKURL):
Added these helper functions to convert BSTRs to WebCore types.

(toStringVector):
(WebView::addUserScriptToGroup):
(WebView::addUserStyleSheetToGroup):
(WebView::removeUserScriptFromGroup):
(WebView::removeUserStyleSheetFromGroup):
(WebView::removeUserScriptsFromGroup):
(WebView::removeUserStyleSheetsFromGroup):
(WebView::removeAllUserContentFromGroup):
Use the new helper functions.

Location:
trunk/WebKit/win
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/win/ChangeLog

    r50856 r50906  
     12009-11-12  Adam Roben  <aroben@apple.com>
     2
     3        Small clean-up in WebView's user content functions
     4
     5        Preparation for <http://webkit.org/b/31414> Implement new SPI for
     6        dealing with user scripts/stylesheets and isolated worlds
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * WebView.cpp:
     11        (toString):
     12        (toKURL):
     13        Added these helper functions to convert BSTRs to WebCore types.
     14
     15        (toStringVector):
     16        (WebView::addUserScriptToGroup):
     17        (WebView::addUserStyleSheetToGroup):
     18        (WebView::removeUserScriptFromGroup):
     19        (WebView::removeUserStyleSheetFromGroup):
     20        (WebView::removeUserScriptsFromGroup):
     21        (WebView::removeUserStyleSheetsFromGroup):
     22        (WebView::removeAllUserContentFromGroup):
     23        Use the new helper functions.
     24
    1252009-11-11  Beth Dakin  <bdakin@apple.com>
    226
  • trunk/WebKit/win/WebView.cpp

    r50007 r50906  
    54705470}
    54715471
     5472static String toString(BSTR bstr)
     5473{
     5474    return String(bstr, SysStringLen(bstr));
     5475}
     5476
     5477static KURL toKURL(BSTR bstr)
     5478{
     5479    return KURL(KURL(), toString(bstr));
     5480}
     5481
    54725482static PassOwnPtr<Vector<String> > toStringVector(unsigned patternsCount, BSTR* patterns)
    54735483{
     
    54775487    Vector<String>* patternsVector = new Vector<String>;
    54785488    for (unsigned i = 0; i < patternsCount; ++i)
    5479         patternsVector->append(String(patterns[i], SysStringLen(patterns[i])));
     5489        patternsVector->append(toString(patterns[i]));
    54805490    return patternsVector;
    54815491}
     
    54865496                                      WebUserScriptInjectionTime injectionTime)
    54875497{
    5488     String group(groupName, SysStringLen(groupName));
     5498    String group = toString(groupName);
    54895499    if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
    54905500        return E_INVALIDARG;
     
    54955505        return E_FAIL;
    54965506
    5497     pageGroup->addUserScriptToWorld(worldID, String(source, SysStringLen(source)), KURL(KURL(), String(url, SysStringLen(url))),
     5507    pageGroup->addUserScriptToWorld(worldID, toString(source), toKURL(url),
    54985508                                    toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist),
    54995509                                    injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
     
    55065516                                          unsigned blacklistCount, BSTR* blacklist)
    55075517{
    5508     String group(groupName, SysStringLen(groupName));
     5518    String group = toString(groupName);
    55095519    if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
    55105520        return E_INVALIDARG;
     
    55155525        return E_FAIL;
    55165526
    5517     pageGroup->addUserStyleSheetToWorld(worldID, String(source, SysStringLen(source)), KURL(KURL(), String(url, SysStringLen(url))),
     5527    pageGroup->addUserStyleSheetToWorld(worldID, toString(source), toKURL(url),
    55185528                                        toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist));
    55195529
     
    55235533HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url)
    55245534{
    5525     String group(groupName, SysStringLen(groupName));
     5535    String group = toString(groupName);
    55265536    if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
    55275537        return E_INVALIDARG;
     
    55325542        return E_FAIL;
    55335543
    5534     pageGroup->removeUserScriptFromWorld(worldID, KURL(KURL(), String(url, SysStringLen(url))));
     5544    pageGroup->removeUserScriptFromWorld(worldID, toKURL(url));
    55355545
    55365546    return S_OK;
     
    55395549HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url)
    55405550{
    5541     String group(groupName, SysStringLen(groupName));
     5551    String group = toString(groupName);
    55425552    if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
    55435553        return E_INVALIDARG;
     
    55485558        return E_FAIL;
    55495559
    5550     pageGroup->removeUserStyleSheetFromWorld(worldID, KURL(KURL(), String(url, SysStringLen(url))));
     5560    pageGroup->removeUserStyleSheetFromWorld(worldID, toKURL(url));
    55515561
    55525562    return S_OK;
     
    55555565HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, unsigned worldID)
    55565566{
    5557     String group(groupName, SysStringLen(groupName));
     5567    String group = toString(groupName);
    55585568    if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
    55595569        return E_INVALIDARG;
     
    55705580HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID)
    55715581{
    5572     String group(groupName, SysStringLen(groupName));
     5582    String group = toString(groupName);
    55735583    if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
    55745584        return E_INVALIDARG;
     
    55855595HRESULT WebView::removeAllUserContentFromGroup(BSTR groupName)
    55865596{
    5587     String group(groupName, SysStringLen(groupName));
     5597    String group = toString(groupName);
    55885598    if (group.isEmpty())
    55895599        return E_INVALIDARG;
Note: See TracChangeset for help on using the changeset viewer.