OSDN Git Service

am 3c54ece0: am 5dc34a85: activeDocumentLoader() causes crash in WebCoreFrameBridge.cpp
[android-x86/external-webkit.git] / WebCore / css / MediaQueryExp.cpp
index 7ba6d84..a93ddcc 100644 (file)
@@ -2,6 +2,7 @@
  * CSS Media Query
  *
  * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "CSSParser.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSValueList.h"
+#include "StringBuilder.h"
 
 namespace WebCore {
 
 MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* valueList)
     : m_mediaFeature(mediaFeature)
     , m_value(0)
+    , m_isValid(true)
 {
     if (valueList) {
         if (valueList->size() == 1) {
@@ -73,6 +76,7 @@ MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueLis
             if (isValid)
                 m_value = list.release();
         }
+        m_isValid = m_value;
     }
 }
 
@@ -80,4 +84,22 @@ MediaQueryExp::~MediaQueryExp()
 {
 }
 
+String MediaQueryExp::serialize() const
+{
+    if (!m_serializationCache.isNull())
+        return m_serializationCache;
+
+    StringBuilder result;
+    result.append("(");
+    result.append(m_mediaFeature.lower());
+    if (m_value) {
+        result.append(": ");
+        result.append(m_value->cssText());
+    }
+    result.append(")");
+
+    const_cast<MediaQueryExp*>(this)->m_serializationCache = result.toString();
+    return m_serializationCache;
+}
+
 } // namespace