Changeset 64242 in webkit


Ignore:
Timestamp:
Jul 28, 2010 4:21:22 PM (14 years ago)
Author:
tony@chromium.org
Message:

2010-07-28 Tony Chang <tony@chromium.org>

Reviewed by Ojan Vafai.

implement getData('text/html') for webkit win
https://bugs.webkit.org/show_bug.cgi?id=37981

  • platform/win/Skipped: 2 tests now pass

2010-07-28 Tony Chang <tony@chromium.org>

Reviewed by Ojan Vafai.

implement getData('text/html') for webkit win
https://bugs.webkit.org/show_bug.cgi?id=37981

  • platform/win/ClipboardUtilitiesWin.cpp: (WebCore::extractMarkupFromCFHTML): (WebCore::getCFHTML): (WebCore::fragmentFromCFHTML): (WebCore::fragmentFromHTML):
  • platform/win/ClipboardUtilitiesWin.h:
  • platform/win/ClipboardWin.cpp: (WebCore::): (WebCore::clipboardTypeFromMIMEType): (WebCore::ClipboardWin::getData):
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r64241 r64242  
     12010-07-28  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Ojan Vafai.
     4
     5        implement getData('text/html') for webkit win
     6        https://bugs.webkit.org/show_bug.cgi?id=37981
     7
     8        * platform/win/Skipped: 2 tests now pass
     9
    1102010-07-28  Alex Nicolaou  <anicolao@chromium.org>
    211
  • trunk/LayoutTests/platform/win/Skipped

    r64110 r64242  
    847847fast/overflow/scrollbar-restored-and-then-locked.html
    848848
    849 # Need to handle getting text/html in ClipboardWin::getData.
    850 editing/pasteboard/onpaste-text-html.html
    851 fast/events/ondrop-text-html.html
    852 
    853849# <http://webkit.org/b/37096> http/tests/security/xss-DENIED-iframe-src-alias.html sometimes times out on Windows
    854850http/tests/security/xss-DENIED-iframe-src-alias.html
  • trunk/WebCore/ChangeLog

    r64237 r64242  
     12010-07-28  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Ojan Vafai.
     4
     5        implement getData('text/html') for webkit win
     6        https://bugs.webkit.org/show_bug.cgi?id=37981
     7
     8        * platform/win/ClipboardUtilitiesWin.cpp:
     9        (WebCore::extractMarkupFromCFHTML):
     10        (WebCore::getCFHTML):
     11        (WebCore::fragmentFromCFHTML):
     12        (WebCore::fragmentFromHTML):
     13        * platform/win/ClipboardUtilitiesWin.h:
     14        * platform/win/ClipboardWin.cpp:
     15        (WebCore::):
     16        (WebCore::clipboardTypeFromMIMEType):
     17        (WebCore::ClipboardWin::getData):
     18
    1192010-07-28  Adam Barth  <abarth@webkit.org>
    220
  • trunk/WebCore/platform/win/ClipboardUtilitiesWin.cpp

    r64062 r64242  
    170170}
    171171
     172static String getFullCFHTML(IDataObject* data, bool& success)
     173{
     174    STGMEDIUM store;
     175    if (SUCCEEDED(data->GetData(htmlFormat(), &store))) {
     176        // MS HTML Format parsing
     177        char* data = static_cast<char*>(GlobalLock(store.hGlobal));
     178        SIZE_T dataSize = ::GlobalSize(store.hGlobal);
     179        String cfhtml(UTF8Encoding().decode(data, dataSize));
     180        GlobalUnlock(store.hGlobal);
     181        ReleaseStgMedium(&store);
     182        success = true;
     183        return cfhtml;
     184    }
     185    success = false;
     186    return String();
     187}
     188
    172189static void append(Vector<char>& vector, const char* string)
    173190{
     
    178195{
    179196    vector.append(string.data(), string.length());
     197}
     198
     199// Find the markup between "<!--StartFragment -->" and "<!--EndFragment -->", accounting for browser quirks.
     200static String extractMarkupFromCFHTML(const String& cfhtml)
     201{
     202    unsigned markupStart = cfhtml.find("<html", 0, false);
     203    unsigned tagStart = cfhtml.find("startfragment", markupStart, false);
     204    unsigned fragmentStart = cfhtml.find('>', tagStart) + 1;
     205    unsigned tagEnd = cfhtml.find("endfragment", fragmentStart, false);
     206    unsigned fragmentEnd = cfhtml.reverseFind('<', tagEnd);
     207    return cfhtml.substring(fragmentStart, fragmentEnd - fragmentStart).stripWhiteSpace();
    180208}
    181209
     
    397425}
    398426
     427String getCFHTML(IDataObject* data, bool& success)
     428{
     429    String cfhtml = getFullCFHTML(data, success);
     430    if (success)
     431        return extractMarkupFromCFHTML(cfhtml);
     432    return String();
     433}
     434
    399435PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*)
    400436{
     
    411447// Convert a String containing CF_HTML formatted text to a DocumentFragment
    412448PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfhtml)
    413 {       
     449{
    414450    // obtain baseURL if present
    415451    String srcURLStr("sourceURL:");
     
    424460    }
    425461
    426     // find the markup between "<!--StartFragment -->" and "<!--EndFragment -->", accounting for browser quirks
    427     unsigned markupStart = cfhtml.find("<html", 0, false);
    428     unsigned tagStart = cfhtml.find("startfragment", markupStart, false);
    429     unsigned fragmentStart = cfhtml.find('>', tagStart) + 1;
    430     unsigned tagEnd = cfhtml.find("endfragment", fragmentStart, false);
    431     unsigned fragmentEnd = cfhtml.reverseFind('<', tagEnd);
    432     String markup = cfhtml.substring(fragmentStart, fragmentEnd - fragmentStart).stripWhiteSpace();
    433 
     462    String markup = extractMarkupFromCFHTML(cfhtml);
    434463    return createFragmentFromMarkup(doc, markup, srcURL, FragmentScriptingNotAllowed);
    435464}
    436 
    437465
    438466PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data)
     
    441469        return 0;
    442470
    443     STGMEDIUM store;
    444     String html;
    445     String srcURL;
    446     if (SUCCEEDED(data->GetData(htmlFormat(), &store))) {
    447         // MS HTML Format parsing
    448         char* data = static_cast<char*>(GlobalLock(store.hGlobal));
    449         SIZE_T dataSize = ::GlobalSize(store.hGlobal);
    450         String cfhtml(UTF8Encoding().decode(data, dataSize));
    451         GlobalUnlock(store.hGlobal);
    452         ReleaseStgMedium(&store);
     471    bool success = false;
     472    String cfhtml = getFullCFHTML(data, success);
     473    if (success) {
    453474        if (PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(doc, cfhtml))
    454475            return fragment;
    455     }
    456     bool success = false;
    457     html = getTextHTML(data, success);
     476    }
     477
     478    String html = getTextHTML(data, success);
     479    String srcURL;
    458480    if (success)
    459481        return createFragmentFromMarkup(doc, html, srcURL, FragmentScriptingNotAllowed);
  • trunk/WebCore/platform/win/ClipboardUtilitiesWin.h

    r63734 r64242  
    6565String getPlainText(IDataObject*, bool& success);
    6666String getTextHTML(IDataObject*, bool& success);
     67String getCFHTML(IDataObject*, bool& success);
    6768
    6869} // namespace WebCore
  • trunk/WebCore/platform/win/ClipboardWin.cpp

    r64152 r64242  
    7171// see http://www.whatwg.org/specs/web-apps/current-work/ Section 6.3.5.3
    7272
    73 enum ClipboardDataType { ClipboardDataTypeNone, ClipboardDataTypeURL, ClipboardDataTypeText };
     73enum ClipboardDataType { ClipboardDataTypeNone, ClipboardDataTypeURL, ClipboardDataTypeText, ClipboardDataTypeTextHTML };
    7474
    7575static ClipboardDataType clipboardTypeFromMIMEType(const String& type)
     
    8282    if (qType == "url" || qType == "text/uri-list")
    8383        return ClipboardDataTypeURL;
     84    if (qType == "text/html")
     85        return ClipboardDataTypeTextHTML;
    8486
    8587    return ClipboardDataTypeNone;
     
    506508    if (dataType == ClipboardDataTypeURL)
    507509        return getURL(m_dataObject.get(), DragData::DoNotConvertFilenames, success);
     510    else if (dataType == ClipboardDataTypeTextHTML) {
     511        String data = getTextHTML(m_dataObject.get(), success);
     512        if (success)
     513            return data;
     514        return getCFHTML(m_dataObject.get(), success);
     515    }
    508516   
    509517    return "";
Note: See TracChangeset for help on using the changeset viewer.