| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2013 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 { | 64 { |
| 65 PreloadRequestStream requests; | 65 PreloadRequestStream requests; |
| 66 requests.swap(r); | 66 requests.swap(r); |
| 67 | 67 |
| 68 for (PreloadRequestStream::iterator it = requests.begin(); it != requests.en
d(); ++it) | 68 for (PreloadRequestStream::iterator it = requests.begin(); it != requests.en
d(); ++it) |
| 69 preload(it->release()); | 69 preload(it->release()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 static bool mediaAttributeMatches(Frame* frame, RenderStyle* renderStyle, const
String& attributeValue) | 72 static bool mediaAttributeMatches(Frame* frame, RenderStyle* renderStyle, const
String& attributeValue) |
| 73 { | 73 { |
| 74 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::createAllowingDescriptio
nSyntax(attributeValue); | 74 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(attributeValue); |
| 75 MediaQueryEvaluator mediaQueryEvaluator("screen", frame, renderStyle); | 75 MediaQueryEvaluator mediaQueryEvaluator("screen", frame, renderStyle); |
| 76 return mediaQueryEvaluator.eval(mediaQueries.get()); | 76 return mediaQueryEvaluator.eval(mediaQueries.get()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload) | 79 void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload) |
| 80 { | 80 { |
| 81 ASSERT(m_document->frame()); | 81 ASSERT(m_document->frame()); |
| 82 ASSERT(m_document->renderer()); | 82 ASSERT(m_document->renderer()); |
| 83 ASSERT(m_document->renderer()->style()); | 83 ASSERT(m_document->renderer()->style()); |
| 84 if (!preload->media().isEmpty() && !mediaAttributeMatches(m_document->frame(
), m_document->renderer()->style(), preload->media())) | 84 if (!preload->media().isEmpty() && !mediaAttributeMatches(m_document->frame(
), m_document->renderer()->style(), preload->media())) |
| 85 return; | 85 return; |
| 86 | 86 |
| 87 CachedResourceRequest request = preload->resourceRequest(m_document); | 87 CachedResourceRequest request = preload->resourceRequest(m_document); |
| 88 m_document->cachedResourceLoader()->preload(preload->resourceType(), request
, preload->charset()); | 88 m_document->cachedResourceLoader()->preload(preload->resourceType(), request
, preload->charset()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 } | 92 } |
| OLD | NEW |