| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 return WebString(); | 174 return WebString(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 WebElementCollection WebDocument::all() | 177 WebElementCollection WebDocument::all() |
| 178 { | 178 { |
| 179 return WebElementCollection(unwrap<Document>()->all()); | 179 return WebElementCollection(unwrap<Document>()->all()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void WebDocument::forms(WebVector<WebFormElement>& results) const | 182 void WebDocument::forms(WebVector<WebFormElement>& results) const |
| 183 { | 183 { |
| 184 RefPtrWillBeRawPtr<HTMLCollection> forms = const_cast<Document*>(constUnwrap
<Document>())->forms(); | 184 RawPtr<HTMLCollection> forms = const_cast<Document*>(constUnwrap<Document>()
)->forms(); |
| 185 size_t sourceLength = forms->length(); | 185 size_t sourceLength = forms->length(); |
| 186 Vector<WebFormElement> temp; | 186 Vector<WebFormElement> temp; |
| 187 temp.reserveCapacity(sourceLength); | 187 temp.reserveCapacity(sourceLength); |
| 188 for (size_t i = 0; i < sourceLength; ++i) { | 188 for (size_t i = 0; i < sourceLength; ++i) { |
| 189 Element* element = forms->item(i); | 189 Element* element = forms->item(i); |
| 190 // Strange but true, sometimes node can be 0. | 190 // Strange but true, sometimes node can be 0. |
| 191 if (element && element->isHTMLElement()) | 191 if (element && element->isHTMLElement()) |
| 192 temp.append(WebFormElement(toHTMLFormElement(element))); | 192 temp.append(WebFormElement(toHTMLFormElement(element))); |
| 193 } | 193 } |
| 194 results.assign(temp); | 194 results.assign(temp); |
| 195 } | 195 } |
| 196 | 196 |
| 197 WebURL WebDocument::completeURL(const WebString& partialURL) const | 197 WebURL WebDocument::completeURL(const WebString& partialURL) const |
| 198 { | 198 { |
| 199 return constUnwrap<Document>()->completeURL(partialURL); | 199 return constUnwrap<Document>()->completeURL(partialURL); |
| 200 } | 200 } |
| 201 | 201 |
| 202 WebElement WebDocument::getElementById(const WebString& id) const | 202 WebElement WebDocument::getElementById(const WebString& id) const |
| 203 { | 203 { |
| 204 return WebElement(constUnwrap<Document>()->getElementById(id)); | 204 return WebElement(constUnwrap<Document>()->getElementById(id)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 WebElement WebDocument::focusedElement() const | 207 WebElement WebDocument::focusedElement() const |
| 208 { | 208 { |
| 209 return WebElement(constUnwrap<Document>()->focusedElement()); | 209 return WebElement(constUnwrap<Document>()->focusedElement()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void WebDocument::insertStyleSheet(const WebString& sourceCode) | 212 void WebDocument::insertStyleSheet(const WebString& sourceCode) |
| 213 { | 213 { |
| 214 RefPtrWillBeRawPtr<Document> document = unwrap<Document>(); | 214 RawPtr<Document> document = unwrap<Document>(); |
| 215 ASSERT(document); | 215 ASSERT(document); |
| 216 RefPtrWillBeRawPtr<StyleSheetContents> parsedSheet = StyleSheetContents::cre
ate(CSSParserContext(*document, 0)); | 216 RawPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(CSSParse
rContext(*document, 0)); |
| 217 parsedSheet->parseString(sourceCode); | 217 parsedSheet->parseString(sourceCode); |
| 218 document->styleEngine().injectAuthorSheet(parsedSheet); | 218 document->styleEngine().injectAuthorSheet(parsedSheet); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void WebDocument::watchCSSSelectors(const WebVector<WebString>& webSelectors) | 221 void WebDocument::watchCSSSelectors(const WebVector<WebString>& webSelectors) |
| 222 { | 222 { |
| 223 RefPtrWillBeRawPtr<Document> document = unwrap<Document>(); | 223 RawPtr<Document> document = unwrap<Document>(); |
| 224 CSSSelectorWatch* watch = CSSSelectorWatch::fromIfExists(*document); | 224 CSSSelectorWatch* watch = CSSSelectorWatch::fromIfExists(*document); |
| 225 if (!watch && webSelectors.isEmpty()) | 225 if (!watch && webSelectors.isEmpty()) |
| 226 return; | 226 return; |
| 227 Vector<String> selectors; | 227 Vector<String> selectors; |
| 228 selectors.append(webSelectors.data(), webSelectors.size()); | 228 selectors.append(webSelectors.data(), webSelectors.size()); |
| 229 CSSSelectorWatch::from(*document).watchCSSSelectors(selectors); | 229 CSSSelectorWatch::from(*document).watchCSSSelectors(selectors); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void WebDocument::cancelFullScreen() | 232 void WebDocument::cancelFullScreen() |
| 233 { | 233 { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 if (!linkElement) | 314 if (!linkElement) |
| 315 return false; | 315 return false; |
| 316 return equalIgnoringCase(linkElement->fastGetAttribute(HTMLNames::crossorigi
nAttr), "use-credentials"); | 316 return equalIgnoringCase(linkElement->fastGetAttribute(HTMLNames::crossorigi
nAttr), "use-credentials"); |
| 317 } | 317 } |
| 318 | 318 |
| 319 WebDistillabilityFeatures WebDocument::distillabilityFeatures() | 319 WebDistillabilityFeatures WebDocument::distillabilityFeatures() |
| 320 { | 320 { |
| 321 return DocumentStatisticsCollector::collectStatistics(*unwrap<Document>()); | 321 return DocumentStatisticsCollector::collectStatistics(*unwrap<Document>()); |
| 322 } | 322 } |
| 323 | 323 |
| 324 WebDocument::WebDocument(const PassRefPtrWillBeRawPtr<Document>& elem) | 324 WebDocument::WebDocument(const RawPtr<Document>& elem) |
| 325 : WebNode(elem) | 325 : WebNode(elem) |
| 326 { | 326 { |
| 327 } | 327 } |
| 328 | 328 |
| 329 DEFINE_WEB_NODE_TYPE_CASTS(WebDocument, constUnwrap<Node>()->isDocumentNode()); | 329 DEFINE_WEB_NODE_TYPE_CASTS(WebDocument, constUnwrap<Node>()->isDocumentNode()); |
| 330 | 330 |
| 331 WebDocument& WebDocument::operator=(const PassRefPtrWillBeRawPtr<Document>& elem
) | 331 WebDocument& WebDocument::operator=(const RawPtr<Document>& elem) |
| 332 { | 332 { |
| 333 m_private = elem; | 333 m_private = elem; |
| 334 return *this; | 334 return *this; |
| 335 } | 335 } |
| 336 | 336 |
| 337 WebDocument::operator PassRefPtrWillBeRawPtr<Document>() const | 337 WebDocument::operator RawPtr<Document>() const |
| 338 { | 338 { |
| 339 return toDocument(m_private.get()); | 339 return toDocument(m_private.get()); |
| 340 } | 340 } |
| 341 | 341 |
| 342 } // namespace blink | 342 } // namespace blink |
| OLD | NEW |