Changeset 162097 in webkit


Ignore:
Timestamp:
Jan 15, 2014 3:26:19 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

toStringVector static function definition should not be redundant.
https://bugs.webkit.org/show_bug.cgi?id=126872.

Patch by Piotr Grad <p.grad@samsung.com> on 2014-01-15
Reviewed by Anders Carlsson.

toStringVector function was declared twice in InjectedBundle.cpp and WebPageGroup.cpp as static.
In order to remove redundant definition this function was moved into API::Array.

  • Shared/APIArray.cpp:

(API::Array::toStringVector):

  • Shared/APIArray.h:
  • UIProcess/WebPageGroup.cpp:

(WebKit::WebPageGroup::addUserStyleSheet):
(WebKit::WebPageGroup::addUserScript):

  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::addUserScript):
(WebKit::InjectedBundle::addUserStyleSheet):

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r162088 r162097  
     12014-01-15  Piotr Grad  <p.grad@samsung.com>
     2
     3        toStringVector static function definition should not be redundant.
     4        https://bugs.webkit.org/show_bug.cgi?id=126872.
     5
     6        Reviewed by Anders Carlsson.
     7
     8        toStringVector function was declared twice in InjectedBundle.cpp and WebPageGroup.cpp as static.
     9        In order to remove redundant definition this function was moved into API::Array.
     10
     11        * Shared/APIArray.cpp:
     12        (API::Array::toStringVector):
     13        * Shared/APIArray.h:
     14        * UIProcess/WebPageGroup.cpp:
     15        (WebKit::WebPageGroup::addUserStyleSheet):
     16        (WebKit::WebPageGroup::addUserScript):
     17        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     18        (WebKit::InjectedBundle::addUserScript):
     19        (WebKit::InjectedBundle::addUserStyleSheet):
     20
    1212014-01-10  Gavin Barraclough  <barraclough@apple.com>
    222
  • trunk/Source/WebKit2/Shared/APIArray.cpp

    r160608 r162097  
    5252}
    5353
     54Vector<WTF::String> Array::toStringVector()
     55{
     56    Vector<WTF::String> patternsVector;
     57
     58    size_t size = this->size();
     59    if (!size)
     60        return patternsVector;
     61
     62    patternsVector.reserveInitialCapacity(size);
     63    for (const auto& entry : elementsOfType<API::String>())
     64        patternsVector.uncheckedAppend(entry->string());
     65    return patternsVector;
     66}
     67
    5468Array::Array(Vector<RefPtr<Object>> elements)
    5569    : m_elements(std::move(elements))
  • trunk/Source/WebKit2/Shared/APIArray.h

    r161770 r162097  
    5555    static PassRefPtr<Array> create(Vector<RefPtr<Object>> elements);
    5656    static PassRefPtr<Array> createStringArray(const Vector<WTF::String>&);
     57    Vector<WTF::String> toStringVector();
    5758
    5859    virtual ~Array();
  • trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp

    r161045 r162097  
    135135}
    136136
    137 static Vector<String> toStringVector(API::Array* array)
    138 {
    139     Vector<String> patternVector;
    140     if (!array)
    141         return patternVector;
    142 
    143     size_t size = array->size();
    144     if (!size)
    145         return patternVector;
    146    
    147     patternVector.reserveInitialCapacity(size);
    148     for (size_t i = 0; i < size; ++i) {
    149         API::String* string = array->at<API::String>(i);
    150         ASSERT(string);
    151         patternVector.uncheckedAppend(string->string());
    152     }
    153    
    154     return patternVector;
    155 }
    156 
    157137void WebPageGroup::addUserStyleSheet(const String& source, const String& baseURL, API::Array* whitelist, API::Array* blacklist, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserStyleLevel level)
    158138{
     
    160140        return;
    161141
    162     WebCore::UserStyleSheet userStyleSheet = WebCore::UserStyleSheet(source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURL)), toStringVector(whitelist), toStringVector(blacklist), injectedFrames, level);
     142    WebCore::UserStyleSheet userStyleSheet = WebCore::UserStyleSheet(source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURL)), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames, level);
    163143
    164144    m_data.userStyleSheets.append(userStyleSheet);
     
    171151        return;
    172152
    173     WebCore::UserScript userScript = WebCore::UserScript(source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURL)), toStringVector(whitelist), toStringVector(blacklist), injectionTime, injectedFrames);
     153    WebCore::UserScript userScript = WebCore::UserScript(source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::URL(WebCore::URL(), baseURL)), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames);
    174154
    175155    m_data.userScripts.append(userScript);
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r161152 r162097  
    473473}
    474474
    475 static Vector<String> toStringVector(API::Array* patterns)
    476 {
    477     Vector<String> patternsVector;
    478 
    479     if (!patterns)
    480         return patternsVector;
    481 
    482     size_t size = patterns->size();
    483     if (!size)
    484         return patternsVector;
    485 
    486     patternsVector.reserveInitialCapacity(size);
    487     for (const auto& entry : patterns->elementsOfType<API::String>())
    488         patternsVector.uncheckedAppend(entry->string());
    489     return patternsVector;
    490 }
    491 
    492475void InjectedBundle::addUserScript(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, API::Array* whitelist, API::Array* blacklist, WebCore::UserScriptInjectionTime injectionTime, WebCore::UserContentInjectedFrames injectedFrames)
    493476{
    494477    // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version.
    495     PageGroup::pageGroup(pageGroup->identifier())->addUserScriptToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), toStringVector(whitelist), toStringVector(blacklist), injectionTime, injectedFrames);
     478    PageGroup::pageGroup(pageGroup->identifier())->addUserScriptToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames);
    496479}
    497480
     
    499482{
    500483    // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version.
    501     PageGroup::pageGroup(pageGroup->identifier())->addUserStyleSheetToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), toStringVector(whitelist), toStringVector(blacklist), injectedFrames);
     484    PageGroup::pageGroup(pageGroup->identifier())->addUserStyleSheetToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames);
    502485}
    503486
Note: See TracChangeset for help on using the changeset viewer.