Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / CSSStyleSheet.cpp
index 1d0336a..705d328 100644 (file)
 #include "config.h"
 #include "core/css/CSSStyleSheet.h"
 
-#include "HTMLNames.h"
-#include "SVGNames.h"
-#include "bindings/v8/ExceptionState.h"
-#include "bindings/v8/V8PerIsolateData.h"
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/V8Binding.h"
+#include "bindings/core/v8/V8PerIsolateData.h"
+#include "core/HTMLNames.h"
+#include "core/SVGNames.h"
 #include "core/css/CSSCharsetRule.h"
 #include "core/css/CSSImportRule.h"
-#include "core/css/parser/BisonCSSParser.h"
 #include "core/css/CSSRuleList.h"
 #include "core/css/MediaList.h"
 #include "core/css/StyleRule.h"
 #include "core/css/StyleSheetContents.h"
+#include "core/css/parser/CSSParser.h"
 #include "core/dom/Document.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/Node.h"
 #include "platform/weborigin/SecurityOrigin.h"
 #include "wtf/text/StringBuilder.h"
 
-namespace WebCore {
+namespace blink {
 
-class StyleSheetCSSRuleList FINAL : public CSSRuleList {
+class StyleSheetCSSRuleList final : public CSSRuleList {
 public:
     static PassOwnPtrWillBeRawPtr<StyleSheetCSSRuleList> create(CSSStyleSheet* sheet)
     {
         return adoptPtrWillBeNoop(new StyleSheetCSSRuleList(sheet));
     }
 
-    virtual void trace(Visitor* visitor) OVERRIDE
+    virtual void trace(Visitor* visitor) override
     {
         visitor->trace(m_styleSheet);
+        CSSRuleList::trace(visitor);
     }
 
 private:
     StyleSheetCSSRuleList(CSSStyleSheet* sheet) : m_styleSheet(sheet) { }
 
 #if !ENABLE(OILPAN)
-    virtual void ref() OVERRIDE { m_styleSheet->ref(); }
-    virtual void deref() OVERRIDE { m_styleSheet->deref(); }
+    virtual void ref() override { m_styleSheet->ref(); }
+    virtual void deref() override { m_styleSheet->deref(); }
 #endif
 
-    virtual unsigned length() const OVERRIDE { return m_styleSheet->length(); }
-    virtual CSSRule* item(unsigned index) const OVERRIDE { return m_styleSheet->item(index); }
+    virtual unsigned length() const override { return m_styleSheet->length(); }
+    virtual CSSRule* item(unsigned index) const override { return m_styleSheet->item(index); }
 
-    virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_styleSheet; }
+    virtual CSSStyleSheet* styleSheet() const override { return m_styleSheet; }
 
     RawPtrWillBeMember<CSSStyleSheet> m_styleSheet;
 };
 
-#if !ASSERT_DISABLED
+#if ENABLE(ASSERT)
 static bool isAcceptableCSSStyleSheetParent(Node* parentNode)
 {
-    // Only these nodes can be parents of StyleSheets, and they need to call clearOwnerNode() when moved out of document.
+    // Only these nodes can be parents of StyleSheets, and they need to call
+    // clearOwnerNode() when moved out of document.
+    // Destruction of the style sheet counts as being "moved out of the
+    // document", but only in the non-oilpan version of blink. I.e. don't call
+    // clearOwnerNode() in the owner's destructor in oilpan.
     return !parentNode
         || parentNode->isDocumentNode()
         || isHTMLLinkElement(*parentNode)
@@ -112,7 +118,7 @@ CSSStyleSheet::CSSStyleSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> contents
     : m_contents(contents)
     , m_isInlineStylesheet(false)
     , m_isDisabled(false)
-    , m_ownerNode(0)
+    , m_ownerNode(nullptr)
     , m_ownerRule(ownerRule)
     , m_startPosition(TextPosition::minimumPosition())
     , m_loadCompleted(false)
@@ -199,7 +205,7 @@ void CSSStyleSheet::didMutate(StyleSheetUpdateType updateType)
     // Need FullStyleUpdate when insertRule or deleteRule,
     // because StyleSheetCollection::analyzeStyleSheetChange cannot detect partial rule update.
     StyleResolverUpdateMode updateMode = updateType != PartialRuleUpdate ? AnalyzedStyleUpdate : FullStyleUpdate;
-    owner->modifiedStyleSheet(this, RecalcStyleDeferred, updateMode);
+    owner->modifiedStyleSheet(this, updateMode);
 }
 
 void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
@@ -261,7 +267,7 @@ void CSSStyleSheet::clearOwnerNode()
     didMutate(EntireStyleSheetUpdate);
     if (m_ownerNode)
         m_contents->unregisterClient(this);
-    m_ownerNode = 0;
+    m_ownerNode = nullptr;
 }
 
 bool CSSStyleSheet::canAccessRules() const
@@ -304,8 +310,7 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
         return 0;
     }
     CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(this));
-    BisonCSSParser p(context);
-    RefPtrWillBeRawPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString);
+    RefPtrWillBeRawPtr<StyleRuleBase> rule = CSSParser::parseRule(context, m_contents.get(), ruleString);
 
     if (!rule) {
         exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule '" + ruleString + "'.");
@@ -452,10 +457,12 @@ void CSSStyleSheet::trace(Visitor* visitor)
 {
     visitor->trace(m_contents);
     visitor->trace(m_mediaQueries);
+    visitor->trace(m_ownerNode);
     visitor->trace(m_ownerRule);
     visitor->trace(m_mediaCSSOMWrapper);
     visitor->trace(m_childRuleCSSOMWrappers);
     visitor->trace(m_ruleListCSSOMWrapper);
+    StyleSheet::trace(visitor);
 }
 
-}
+} // namespace blink