| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * (C) 1999-2003 Lars Knoll (knoll@kde.org) |    2  * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 
|    3  * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. |    3  * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. | 
|    4  * |    4  * | 
|    5  * This library is free software; you can redistribute it and/or |    5  * This library is free software; you can redistribute it and/or | 
|    6  * modify it under the terms of the GNU Library General Public |    6  * modify it under the terms of the GNU Library General Public | 
|    7  * License as published by the Free Software Foundation; either |    7  * License as published by the Free Software Foundation; either | 
|    8  * version 2 of the License, or (at your option) any later version. |    8  * version 2 of the License, or (at your option) any later version. | 
|    9  * |    9  * | 
|   10  * This library is distributed in the hope that it will be useful, |   10  * This library is distributed in the hope that it will be useful, | 
|   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of |   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU |   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|   13  * Library General Public License for more details. |   13  * Library General Public License for more details. | 
|   14  * |   14  * | 
|   15  * You should have received a copy of the GNU Library General Public License |   15  * You should have received a copy of the GNU Library General Public License | 
|   16  * along with this library; see the file COPYING.LIB.  If not, write to |   16  * along with this library; see the file COPYING.LIB.  If not, write to | 
|   17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |   17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 
|   18  * Boston, MA 02110-1301, USA. |   18  * Boston, MA 02110-1301, USA. | 
|   19  */ |   19  */ | 
|   20  |   20  | 
|   21 #include "config.h" |   21 #include "config.h" | 
|   22 #include "core/css/StyleSheetContents.h" |   22 #include "core/css/StyleSheetContents.h" | 
|   23  |   23  | 
|   24 #include "core/css/parser/BisonCSSParser.h" |  | 
|   25 #include "core/css/CSSStyleSheet.h" |   24 #include "core/css/CSSStyleSheet.h" | 
|   26 #include "core/css/MediaList.h" |   25 #include "core/css/MediaList.h" | 
|   27 #include "core/css/StylePropertySet.h" |   26 #include "core/css/StylePropertySet.h" | 
|   28 #include "core/css/StyleRule.h" |   27 #include "core/css/StyleRule.h" | 
|   29 #include "core/css/StyleRuleImport.h" |   28 #include "core/css/StyleRuleImport.h" | 
 |   29 #include "core/css/parser/CSSParser.h" | 
|   30 #include "core/dom/Document.h" |   30 #include "core/dom/Document.h" | 
|   31 #include "core/dom/Node.h" |   31 #include "core/dom/Node.h" | 
|   32 #include "core/dom/StyleEngine.h" |   32 #include "core/dom/StyleEngine.h" | 
|   33 #include "core/fetch/CSSStyleSheetResource.h" |   33 #include "core/fetch/CSSStyleSheetResource.h" | 
|   34 #include "core/frame/UseCounter.h" |   34 #include "core/frame/UseCounter.h" | 
|   35 #include "platform/TraceEvent.h" |   35 #include "platform/TraceEvent.h" | 
|   36 #include "platform/weborigin/SecurityOrigin.h" |   36 #include "platform/weborigin/SecurityOrigin.h" | 
|   37 #include "wtf/Deque.h" |   37 #include "wtf/Deque.h" | 
|   38  |   38  | 
|   39 namespace blink { |   39 namespace blink { | 
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  320 { |  320 { | 
|  321     TRACE_EVENT0("blink", "StyleSheetContents::parseAuthorStyleSheet"); |  321     TRACE_EVENT0("blink", "StyleSheetContents::parseAuthorStyleSheet"); | 
|  322  |  322  | 
|  323     bool quirksMode = isQuirksModeBehavior(m_parserContext.mode()); |  323     bool quirksMode = isQuirksModeBehavior(m_parserContext.mode()); | 
|  324  |  324  | 
|  325     bool enforceMIMEType = !quirksMode; |  325     bool enforceMIMEType = !quirksMode; | 
|  326     bool hasValidMIMEType = false; |  326     bool hasValidMIMEType = false; | 
|  327     String sheetText = cachedStyleSheet->sheetText(enforceMIMEType, &hasValidMIM
     EType); |  327     String sheetText = cachedStyleSheet->sheetText(enforceMIMEType, &hasValidMIM
     EType); | 
|  328  |  328  | 
|  329     CSSParserContext context(parserContext(), UseCounter::getFrom(this)); |  329     CSSParserContext context(parserContext(), UseCounter::getFrom(this)); | 
|  330     BisonCSSParser p(context); |  330     CSSParser::parseSheet(context, this, sheetText, TextPosition::minimumPositio
     n(), 0, true); | 
|  331     p.parseSheet(this, sheetText, TextPosition::minimumPosition(), 0, true); |  | 
|  332  |  331  | 
|  333     // If we're loading a stylesheet cross-origin, and the MIME type is not stan
     dard, require the CSS |  332     // If we're loading a stylesheet cross-origin, and the MIME type is not stan
     dard, require the CSS | 
|  334     // to at least start with a syntactically valid CSS rule. |  333     // to at least start with a syntactically valid CSS rule. | 
|  335     // This prevents an attacker playing games by injecting CSS strings into HTM
     L, XML, JSON, etc. etc. |  334     // This prevents an attacker playing games by injecting CSS strings into HTM
     L, XML, JSON, etc. etc. | 
|  336     if (!hasValidMIMEType && !hasSyntacticallyValidCSSHeader()) { |  335     if (!hasValidMIMEType && !hasSyntacticallyValidCSSHeader()) { | 
|  337         bool isCrossOriginCSS = !securityOrigin || !securityOrigin->canRequest(b
     aseURL()); |  336         bool isCrossOriginCSS = !securityOrigin || !securityOrigin->canRequest(b
     aseURL()); | 
|  338         if (isCrossOriginCSS) { |  337         if (isCrossOriginCSS) { | 
|  339             clearRules(); |  338             clearRules(); | 
|  340             return; |  339             return; | 
|  341         } |  340         } | 
|  342     } |  341     } | 
|  343 } |  342 } | 
|  344  |  343  | 
|  345 bool StyleSheetContents::parseString(const String& sheetText) |  344 bool StyleSheetContents::parseString(const String& sheetText) | 
|  346 { |  345 { | 
|  347     return parseStringAtPosition(sheetText, TextPosition::minimumPosition(), fal
     se); |  346     return parseStringAtPosition(sheetText, TextPosition::minimumPosition(), fal
     se); | 
|  348 } |  347 } | 
|  349  |  348  | 
|  350 bool StyleSheetContents::parseStringAtPosition(const String& sheetText, const Te
     xtPosition& startPosition, bool createdByParser) |  349 bool StyleSheetContents::parseStringAtPosition(const String& sheetText, const Te
     xtPosition& startPosition, bool createdByParser) | 
|  351 { |  350 { | 
|  352     CSSParserContext context(parserContext(), UseCounter::getFrom(this)); |  351     CSSParserContext context(parserContext(), UseCounter::getFrom(this)); | 
|  353     BisonCSSParser p(context); |  352     CSSParser::parseSheet(context, this, sheetText, startPosition, 0, createdByP
     arser); | 
|  354     p.parseSheet(this, sheetText, startPosition, 0, createdByParser); |  | 
|  355  |  353  | 
|  356     return true; |  354     return true; | 
|  357 } |  355 } | 
|  358  |  356  | 
|  359 bool StyleSheetContents::isLoading() const |  357 bool StyleSheetContents::isLoading() const | 
|  360 { |  358 { | 
|  361     for (unsigned i = 0; i < m_importRules.size(); ++i) { |  359     for (unsigned i = 0; i < m_importRules.size(); ++i) { | 
|  362         if (m_importRules[i]->isLoading()) |  360         if (m_importRules[i]->isLoading()) | 
|  363             return true; |  361             return true; | 
|  364     } |  362     } | 
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  689     visitor->trace(m_ownerRule); |  687     visitor->trace(m_ownerRule); | 
|  690     visitor->trace(m_importRules); |  688     visitor->trace(m_importRules); | 
|  691     visitor->trace(m_childRules); |  689     visitor->trace(m_childRules); | 
|  692     visitor->trace(m_loadingClients); |  690     visitor->trace(m_loadingClients); | 
|  693     visitor->trace(m_completedClients); |  691     visitor->trace(m_completedClients); | 
|  694     visitor->trace(m_ruleSet); |  692     visitor->trace(m_ruleSet); | 
|  695 #endif |  693 #endif | 
|  696 } |  694 } | 
|  697  |  695  | 
|  698 } |  696 } | 
| OLD | NEW |