Fix for missing image in MHTML Page save
authorSantosh <santosh.ma@samsung.com>
Sat, 27 Apr 2013 12:54:40 +0000 (21:54 +0900)
committerSantosh <santosh.ma@samsung.com>
Mon, 6 May 2013 07:30:00 +0000 (16:30 +0900)
[Title] Fix for missing image in MHTML Page save by handling
resources under @Media
[Issue#] TD-9513
[Problem] Some Image was missing in MTHML format of Page saving
[Cause] Image resource specified in CSS under @media
are ignored by pageserializer
[Solution] Added the code to get the resources specified
under rule @media
[Developer] Santosh Mahto[santosh.ma@samsung.com)

Change-Id: I4fdd26a96b16b49ed2d32a009e3131c0cfea664c

Source/WTF/wtf/Platform.h
Source/WebCore/page/PageSerializer.cpp

index baf08f0..ec796fb 100644 (file)
@@ -796,6 +796,7 @@ com) : Patch to do not adjust cover rect as fixed pixel size*/
 #define ENABLE_TIZEN_FIND_STRING 1 /* Jinwoo Song(jinwoo7.song@samsung.com) : Fix the bug to enable searching the web page which has the 'webkit-user-select: none' CSS property and value. */
 
 #define ENABLE_TIZEN_GET_EXTERNAL_RESOURCES_IN_MHTML_FROM_NETWORK 1 /* Praveen(praveen.ks@samsung.com) : Allow external resources in MHTML file to be fetched from network rather than failing them */
+#define ENABLE_TIZEN_MHTML_CSS_MEDIA_RULE_RESOURCE 1 /* Santosh Mahto(santosh.ma@samsung.com) : Collect the subresource specified in css media rule in mhtml PageSerializing */
 
 #define ENABLE_TIZEN_MAIN_THREAD_SCHEDULE_DISCARD_DUPLICATE_REQUEST 1 /* Jihye Kang(jye.kang@samsung.com) : Fix lockup while doing stress test for filewriter */
 
index d5cb86d..6ada614 100644 (file)
@@ -33,6 +33,9 @@
 
 #include "CSSImageValue.h"
 #include "CSSImportRule.h"
+#if ENABLE(TIZEN_MHTML_CSS_MEDIA_RULE_RESOURCE)
+#include "CSSMediaRule.h"
+#endif
 #include "CSSStyleRule.h"
 #include "CachedImage.h"
 #include "Document.h"
@@ -275,6 +278,14 @@ void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KUR
         } else if (rule->isFontFaceRule()) {
             // FIXME: Add support for font face rule. It is not clear to me at this point if the actual otf/eot file can
             // be retrieved from the CSSFontFaceRule object.
+#if ENABLE(TIZEN_MHTML_CSS_MEDIA_RULE_RESOURCE)
+        } else if (rule->isMediaRule()) {
+            CSSMediaRule* mediaRule = static_cast<CSSMediaRule*>(rule);
+            for (int i = 0; i < mediaRule->length(); ++i) {
+                if (mediaRule->item(i)->isStyleRule())
+                    retrieveResourcesForRule(static_cast<CSSStyleRule*>(mediaRule->item(i))->styleRule(), document);
+            }
+#endif
         } else if (rule->isStyleRule())
             retrieveResourcesForRule(static_cast<CSSStyleRule*>(rule)->styleRule(), document);
     }