| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 { | 60 { |
| 61 WebDragDataPrivate* p = const_cast<WebDragDataPrivate*>(other.m_private); | 61 WebDragDataPrivate* p = const_cast<WebDragDataPrivate*>(other.m_private); |
| 62 if (p) | 62 if (p) |
| 63 p->ref(); | 63 p->ref(); |
| 64 assign(p); | 64 assign(p); |
| 65 } | 65 } |
| 66 | 66 |
| 67 WebURL WebDragData::url() const | 67 WebURL WebDragData::url() const |
| 68 { | 68 { |
| 69 ASSERT(!isNull()); | 69 ASSERT(!isNull()); |
| 70 return m_private->url; | 70 return m_private->mainURL(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void WebDragData::setURL(const WebURL& url) | 73 void WebDragData::setURL(const WebURL& url) |
| 74 { | 74 { |
| 75 ensureMutable(); | 75 ensureMutable(); |
| 76 m_private->url = url; | 76 m_private->setMainURL(url); |
| 77 } | 77 } |
| 78 | 78 |
| 79 WebString WebDragData::urlTitle() const | 79 WebString WebDragData::urlTitle() const |
| 80 { | 80 { |
| 81 ASSERT(!isNull()); | 81 ASSERT(!isNull()); |
| 82 return m_private->urlTitle; | 82 return m_private->mainURLTitle(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void WebDragData::setURLTitle(const WebString& urlTitle) | 85 void WebDragData::setURLTitle(const WebString& urlTitle) |
| 86 { | 86 { |
| 87 ensureMutable(); | 87 ensureMutable(); |
| 88 m_private->urlTitle = urlTitle; | 88 m_private->setMainURLTitle(urlTitle); |
| 89 } | 89 } |
| 90 | 90 |
| 91 WebString WebDragData::fileExtension() const | 91 WebString WebDragData::fileExtension() const |
| 92 { | 92 { |
| 93 ASSERT(!isNull()); | 93 ASSERT(!isNull()); |
| 94 return m_private->fileExtension; | 94 return m_private->contentFileExtension(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void WebDragData::setFileExtension(const WebString& fileExtension) | 97 void WebDragData::setFileExtension(const WebString& fileExtension) |
| 98 { | 98 { |
| 99 ensureMutable(); | 99 ensureMutable(); |
| 100 m_private->fileExtension = fileExtension; | 100 m_private->setContentFileExtension(fileExtension); |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool WebDragData::hasFileNames() const | 103 bool WebDragData::hasFileNames() const |
| 104 { | 104 { |
| 105 ASSERT(!isNull()); | 105 ASSERT(!isNull()); |
| 106 return !m_private->filenames.isEmpty(); | 106 return m_private->containsFileNames(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void WebDragData::fileNames(WebVector<WebString>& fileNames) const | 109 void WebDragData::fileNames(WebVector<WebString>& fileNames) const |
| 110 { | 110 { |
| 111 ASSERT(!isNull()); | 111 ASSERT(!isNull()); |
| 112 fileNames = m_private->filenames; | 112 fileNames = m_private->fileNames(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WebDragData::setFileNames(const WebVector<WebString>& fileNames) | 115 void WebDragData::setFileNames(const WebVector<WebString>& fileNames) |
| 116 { | 116 { |
| 117 ensureMutable(); | 117 ensureMutable(); |
| 118 m_private->filenames.clear(); | 118 m_private->clearFileNames(); |
| 119 m_private->filenames.append(fileNames.data(), fileNames.size()); | 119 // This is a comparatively slow operation (potentially causing multiple |
| 120 // re-allocations), but for the purposes of this interface it's probably |
| 121 // sufficient. A faster interface OTOH would require exposing more of the |
| 122 // internal data structures. |
| 123 for (size_t i = 0; i < fileNames.size(); ++i) |
| 124 m_private->appendToFileNames(fileNames[i]); |
| 120 } | 125 } |
| 121 | 126 |
| 122 void WebDragData::appendToFileNames(const WebString& fileName) | 127 void WebDragData::appendToFileNames(const WebString& fileName) |
| 123 { | 128 { |
| 124 ensureMutable(); | 129 ensureMutable(); |
| 125 m_private->filenames.append(fileName); | 130 m_private->appendToFileNames(fileName); |
| 126 } | 131 } |
| 127 | 132 |
| 128 WebString WebDragData::plainText() const | 133 WebString WebDragData::plainText() const |
| 129 { | 134 { |
| 130 ASSERT(!isNull()); | 135 ASSERT(!isNull()); |
| 131 return m_private->plainText; | 136 return m_private->textPlain(); |
| 132 } | 137 } |
| 133 | 138 |
| 134 void WebDragData::setPlainText(const WebString& plainText) | 139 void WebDragData::setPlainText(const WebString& plainText) |
| 135 { | 140 { |
| 136 ensureMutable(); | 141 ensureMutable(); |
| 137 m_private->plainText = plainText; | 142 m_private->setTextPlain(plainText); |
| 138 } | 143 } |
| 139 | 144 |
| 140 WebString WebDragData::htmlText() const | 145 WebString WebDragData::htmlText() const |
| 141 { | 146 { |
| 142 ASSERT(!isNull()); | 147 ASSERT(!isNull()); |
| 143 return m_private->textHtml; | 148 return m_private->textHTML(); |
| 144 } | 149 } |
| 145 | 150 |
| 146 void WebDragData::setHTMLText(const WebString& htmlText) | 151 void WebDragData::setHTMLText(const WebString& htmlText) |
| 147 { | 152 { |
| 148 ensureMutable(); | 153 ensureMutable(); |
| 149 m_private->textHtml = htmlText; | 154 m_private->setTextHTML(htmlText); |
| 150 } | 155 } |
| 151 | 156 |
| 152 WebURL WebDragData::htmlBaseURL() const | 157 WebURL WebDragData::htmlBaseURL() const |
| 153 { | 158 { |
| 154 ASSERT(!isNull()); | 159 ASSERT(!isNull()); |
| 155 return m_private->htmlBaseUrl; | 160 return m_private->htmlBaseURL(); |
| 156 } | 161 } |
| 157 | 162 |
| 158 void WebDragData::setHTMLBaseURL(const WebURL& htmlBaseURL) | 163 void WebDragData::setHTMLBaseURL(const WebURL& htmlBaseURL) |
| 159 { | 164 { |
| 160 ensureMutable(); | 165 ensureMutable(); |
| 161 m_private->htmlBaseUrl = htmlBaseURL; | 166 m_private->setHTMLBaseURL(htmlBaseURL); |
| 162 } | 167 } |
| 163 | 168 |
| 164 WebString WebDragData::fileContentFileName() const | 169 WebString WebDragData::fileContentFileName() const |
| 165 { | 170 { |
| 166 ASSERT(!isNull()); | 171 ASSERT(!isNull()); |
| 167 return m_private->fileContentFilename; | 172 return m_private->contentFileName(); |
| 168 } | 173 } |
| 169 | 174 |
| 170 void WebDragData::setFileContentFileName(const WebString& fileName) | 175 void WebDragData::setFileContentFileName(const WebString& fileName) |
| 171 { | 176 { |
| 172 ensureMutable(); | 177 ensureMutable(); |
| 173 m_private->fileContentFilename = fileName; | 178 m_private->setContentFileName(fileName); |
| 174 } | 179 } |
| 175 | 180 |
| 176 WebData WebDragData::fileContent() const | 181 WebData WebDragData::fileContent() const |
| 177 { | 182 { |
| 178 ASSERT(!isNull()); | 183 ASSERT(!isNull()); |
| 179 return WebData(m_private->fileContent); | 184 return WebData(m_private->content()); |
| 180 } | 185 } |
| 181 | 186 |
| 182 void WebDragData::setFileContent(const WebData& fileContent) | 187 void WebDragData::setFileContent(const WebData& fileContent) |
| 183 { | 188 { |
| 184 ensureMutable(); | 189 ensureMutable(); |
| 185 m_private->fileContent = fileContent; | 190 m_private->setContent(fileContent); |
| 186 } | 191 } |
| 187 | 192 |
| 188 WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data) | 193 WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data) |
| 189 : m_private(static_cast<WebDragDataPrivate*>(data.releaseRef())) | 194 : m_private(static_cast<WebDragDataPrivate*>(data.releaseRef())) |
| 190 { | 195 { |
| 191 } | 196 } |
| 192 | 197 |
| 193 WebDragData& WebDragData::operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data) | 198 WebDragData& WebDragData::operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data) |
| 194 { | 199 { |
| 195 assign(static_cast<WebDragDataPrivate*>(data.releaseRef())); | 200 assign(static_cast<WebDragDataPrivate*>(data.releaseRef())); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 210 } | 215 } |
| 211 | 216 |
| 212 void WebDragData::ensureMutable() | 217 void WebDragData::ensureMutable() |
| 213 { | 218 { |
| 214 ASSERT(!isNull()); | 219 ASSERT(!isNull()); |
| 215 if (!m_private->hasOneRef()) | 220 if (!m_private->hasOneRef()) |
| 216 assign(static_cast<WebDragDataPrivate*>(m_private->copy().releaseRef())); | 221 assign(static_cast<WebDragDataPrivate*>(m_private->copy().releaseRef())); |
| 217 } | 222 } |
| 218 | 223 |
| 219 } // namespace WebKit | 224 } // namespace WebKit |
| OLD | NEW |