summaryrefslogtreecommitdiff
path: root/Source/WebCore/css
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-25 15:09:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-25 15:09:11 +0200
commita89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd (patch)
treeb7abd9f49ae1d4d2e426a5883bfccd42b8e2ee12 /Source/WebCore/css
parent8d473cf9743f1d30a16a27114e93bd5af5648d23 (diff)
downloadqtwebkit-a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd.tar.gz
Imported WebKit commit eb5c1b8fe4d4b1b90b5137433fc58a91da0e6878 (http://svn.webkit.org/repository/webkit/trunk@118516)
Diffstat (limited to 'Source/WebCore/css')
-rw-r--r--Source/WebCore/css/CSSComputedStyleDeclaration.cpp46
-rw-r--r--Source/WebCore/css/CSSFontFaceSrcValue.cpp4
-rw-r--r--Source/WebCore/css/CSSFontFaceSrcValue.h2
-rw-r--r--Source/WebCore/css/CSSGrammar.y2
-rw-r--r--Source/WebCore/css/CSSImportRule.cpp108
-rw-r--r--Source/WebCore/css/CSSImportRule.h58
-rw-r--r--Source/WebCore/css/CSSMediaRule.cpp2
-rw-r--r--Source/WebCore/css/CSSParser.cpp242
-rw-r--r--Source/WebCore/css/CSSParser.h23
-rw-r--r--Source/WebCore/css/CSSParserMode.h1
-rw-r--r--Source/WebCore/css/CSSPrimitiveValue.cpp4
-rw-r--r--Source/WebCore/css/CSSPrimitiveValue.h2
-rw-r--r--Source/WebCore/css/CSSPrimitiveValueMappings.h2
-rw-r--r--Source/WebCore/css/CSSProperty.cpp7
-rw-r--r--Source/WebCore/css/CSSPropertyNames.in20
-rw-r--r--Source/WebCore/css/CSSReflectValue.cpp2
-rw-r--r--Source/WebCore/css/CSSReflectValue.h2
-rw-r--r--Source/WebCore/css/CSSRule.cpp9
-rw-r--r--Source/WebCore/css/CSSRule.h7
-rw-r--r--Source/WebCore/css/CSSRule.idl2
-rw-r--r--Source/WebCore/css/CSSStyleSheet.cpp488
-rw-r--r--Source/WebCore/css/CSSStyleSheet.h156
-rw-r--r--Source/WebCore/css/CSSValue.cpp2
-rw-r--r--Source/WebCore/css/CSSValue.h4
-rw-r--r--Source/WebCore/css/CSSValueKeywords.in2
-rw-r--r--Source/WebCore/css/CSSValueList.cpp2
-rw-r--r--Source/WebCore/css/CSSValueList.h2
-rw-r--r--Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp4
-rw-r--r--Source/WebCore/css/PropertySetCSSStyleDeclaration.h4
-rw-r--r--Source/WebCore/css/StyleBuilder.cpp6
-rw-r--r--Source/WebCore/css/StylePropertySet.cpp71
-rw-r--r--Source/WebCore/css/StylePropertySet.h25
-rw-r--r--Source/WebCore/css/StylePropertyShorthand.cpp14
-rw-r--r--Source/WebCore/css/StylePropertyShorthand.h2
-rw-r--r--Source/WebCore/css/StyleResolver.cpp75
-rw-r--r--Source/WebCore/css/StyleResolver.h6
-rw-r--r--Source/WebCore/css/StyleRule.cpp16
-rw-r--r--Source/WebCore/css/StyleRuleImport.cpp131
-rw-r--r--Source/WebCore/css/StyleRuleImport.h85
-rw-r--r--Source/WebCore/css/StyleSheet.h1
-rw-r--r--Source/WebCore/css/StyleSheetContents.cpp444
-rw-r--r--Source/WebCore/css/StyleSheetContents.h172
-rw-r--r--Source/WebCore/css/WebKitCSSKeyframesRule.cpp2
-rw-r--r--Source/WebCore/css/WebKitCSSRegionRule.cpp4
-rw-r--r--Source/WebCore/css/WebKitCSSRegionRule.h6
-rw-r--r--Source/WebCore/css/WebKitCSSRegionRule.idl4
-rw-r--r--Source/WebCore/css/html.css2
-rw-r--r--Source/WebCore/css/mediaControlsEflFullscreen.css128
48 files changed, 1427 insertions, 976 deletions
diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
index ec20807bf..52b41b726 100644
--- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -41,11 +41,6 @@
#include "ContentData.h"
#include "CounterContent.h"
#include "CursorList.h"
-#if ENABLE(CSS_SHADERS)
-#include "CustomFilterNumberParameter.h"
-#include "CustomFilterOperation.h"
-#include "CustomFilterParameter.h"
-#endif
#include "Document.h"
#include "ExceptionCode.h"
#include "FontFeatureSettings.h"
@@ -59,12 +54,19 @@
#include "ShadowValue.h"
#include "StylePropertySet.h"
#include "StylePropertyShorthand.h"
+#include "WebKitCSSTransformValue.h"
+#include "WebKitFontFamilyNames.h"
+
+#if ENABLE(CSS_SHADERS)
+#include "CustomFilterNumberParameter.h"
+#include "CustomFilterOperation.h"
+#include "CustomFilterParameter.h"
+#endif
+
#if ENABLE(CSS_FILTERS)
#include "StyleCustomFilterProgram.h"
#include "WebKitCSSFilterValue.h"
#endif
-#include "WebKitCSSTransformValue.h"
-#include "WebKitFontFamilyNames.h"
#if ENABLE(DASHBOARD_SUPPORT)
#include "DashboardRegion.h"
@@ -236,13 +238,10 @@ static const CSSPropertyID computedProperties[] = {
CSSPropertyWebkitFontKerning,
CSSPropertyWebkitFontSmoothing,
CSSPropertyWebkitFontVariantLigatures,
-#if ENABLE(CSS_GRID_LAYOUT)
CSSPropertyWebkitGridColumns,
CSSPropertyWebkitGridRows,
-
CSSPropertyWebkitGridColumn,
CSSPropertyWebkitGridRow,
-#endif
CSSPropertyWebkitHighlight,
CSSPropertyWebkitHyphenateCharacter,
CSSPropertyWebkitHyphenateLimitAfter,
@@ -284,8 +283,10 @@ static const CSSPropertyID computedProperties[] = {
CSSPropertyWebkitPerspectiveOrigin,
CSSPropertyWebkitPrintColorAdjust,
CSSPropertyWebkitRtlOrdering,
+#if ENABLE(CSS_EXCLUSIONS)
CSSPropertyWebkitShapeInside,
CSSPropertyWebkitShapeOutside,
+#endif
#if ENABLE(TOUCH_EVENTS)
CSSPropertyWebkitTapHighlightColor,
#endif
@@ -310,18 +311,21 @@ static const CSSPropertyID computedProperties[] = {
CSSPropertyWebkitUserModify,
CSSPropertyWebkitUserSelect,
CSSPropertyWebkitWritingMode,
+#if ENABLE(CSS_REGIONS)
CSSPropertyWebkitFlowInto,
CSSPropertyWebkitFlowFrom,
CSSPropertyWebkitRegionOverflow,
CSSPropertyWebkitRegionBreakAfter,
CSSPropertyWebkitRegionBreakBefore,
CSSPropertyWebkitRegionBreakInside,
+#endif
+#if ENABLE(CSS_EXCLUSIONS)
CSSPropertyWebkitWrapFlow,
CSSPropertyWebkitWrapMargin,
CSSPropertyWebkitWrapPadding,
- CSSPropertyWebkitWrapThrough
+ CSSPropertyWebkitWrapThrough,
+#endif
#if ENABLE(SVG)
- ,
CSSPropertyClipPath,
CSSPropertyClipRule,
CSSPropertyMask,
@@ -894,7 +898,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(RenderStyle* st
}
#endif
-#if ENABLE(CSS_GRID_LAYOUT)
static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackLength, const RenderStyle* style)
{
if (trackLength.isPercent())
@@ -927,7 +930,6 @@ static PassRefPtr<CSSValue> valueForGridPosition(const Length& position)
ASSERT(position.isFixed());
return cssValuePool().createValue(position.value(), CSSPrimitiveValue::CSS_NUMBER);
}
-#endif
static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
{
@@ -1327,6 +1329,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
RefPtr<RenderStyle> style;
if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
+ AnimationUpdateBlock animationUpdateBlock(renderer->animation());
style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
if (m_pseudoElementSpecifier) {
// FIXME: This cached pseudo style will only exist if the animation has been run at least once.
@@ -1594,12 +1597,14 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return zoomAdjustedPixelValue(style->columnWidth(), style.get());
case CSSPropertyTabSize:
return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
+#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitRegionBreakAfter:
return cssValuePool().createValue(style->regionBreakAfter());
case CSSPropertyWebkitRegionBreakBefore:
return cssValuePool().createValue(style->regionBreakBefore());
case CSSPropertyWebkitRegionBreakInside:
return cssValuePool().createValue(style->regionBreakInside());
+#endif
case CSSPropertyCursor: {
RefPtr<CSSValueList> list;
CursorList* cursors = style->cursors();
@@ -1702,7 +1707,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
}
return list.release();
}
-#if ENABLE(CSS_GRID_LAYOUT)
case CSSPropertyWebkitGridColumns: {
return valueForGridTrackList(style->gridColumns(), style.get());
}
@@ -1714,7 +1718,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return valueForGridPosition(style->gridItemColumn());
case CSSPropertyWebkitGridRow:
return valueForGridPosition(style->gridItemRow());
-#endif
+
case CSSPropertyHeight:
if (renderer) {
// According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
@@ -2316,6 +2320,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return counterToCSSValue(style.get(), propertyID);
case CSSPropertyCounterReset:
return counterToCSSValue(style.get(), propertyID);
+#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitFlowInto:
if (style->flowThread().isNull())
return cssValuePool().createIdentifierValue(CSSValueNone);
@@ -2326,6 +2331,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
case CSSPropertyWebkitRegionOverflow:
return cssValuePool().createValue(style->regionOverflow());
+#endif
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrapFlow:
return cssValuePool().createValue(style->wrapFlow());
case CSSPropertyWebkitWrapMargin:
@@ -2342,6 +2349,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return cssValuePool().createValue(style->wrapShapeOutside());
case CSSPropertyWebkitWrapThrough:
return cssValuePool().createValue(style->wrapThrough());
+#endif
#if ENABLE(CSS_FILTERS)
case CSSPropertyWebkitFilter:
return valueForFilter(style.get());
@@ -2472,7 +2480,9 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
case CSSPropertyWebkitTransformOriginY:
case CSSPropertyWebkitTransformOriginZ:
case CSSPropertyWebkitTransition:
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrap:
+#endif
break;
#if ENABLE(SVG)
@@ -2620,14 +2630,14 @@ PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getCSSPropertyValuesForSid
PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
{
- Vector<CSSProperty> list;
+ StylePropertyVector list;
list.reserveInitialCapacity(length);
for (unsigned i = 0; i < length; ++i) {
RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
if (value)
list.append(CSSProperty(set[i], value.release(), false));
}
- return StylePropertySet::create(list);
+ return StylePropertySet::adopt(list);
}
CSSRule* CSSComputedStyleDeclaration::parentRule() const
diff --git a/Source/WebCore/css/CSSFontFaceSrcValue.cpp b/Source/WebCore/css/CSSFontFaceSrcValue.cpp
index 83eab3998..08518a763 100644
--- a/Source/WebCore/css/CSSFontFaceSrcValue.cpp
+++ b/Source/WebCore/css/CSSFontFaceSrcValue.cpp
@@ -25,12 +25,12 @@
#include "config.h"
#include "CSSFontFaceSrcValue.h"
-#include "CSSStyleSheet.h"
#include "CachedFont.h"
#include "CachedResourceLoader.h"
#include "Document.h"
#include "FontCustomPlatformData.h"
#include "Node.h"
+#include "StyleSheetContents.h"
namespace WebCore {
@@ -73,7 +73,7 @@ String CSSFontFaceSrcValue::customCssText() const
return result;
}
-void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
+void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
{
if (!isLocal())
addSubresourceURL(urls, styleSheet->completeURL(m_resource));
diff --git a/Source/WebCore/css/CSSFontFaceSrcValue.h b/Source/WebCore/css/CSSFontFaceSrcValue.h
index 670d82a59..a529c1644 100644
--- a/Source/WebCore/css/CSSFontFaceSrcValue.h
+++ b/Source/WebCore/css/CSSFontFaceSrcValue.h
@@ -65,7 +65,7 @@ public:
String customCssText() const;
- void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
+ void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
CachedFont* cachedFont(Document*);
diff --git a/Source/WebCore/css/CSSGrammar.y b/Source/WebCore/css/CSSGrammar.y
index dbee3d9ba..b6168858e 100644
--- a/Source/WebCore/css/CSSGrammar.y
+++ b/Source/WebCore/css/CSSGrammar.y
@@ -30,12 +30,12 @@
#include "CSSPropertyNames.h"
#include "CSSSelector.h"
#include "CSSSelectorList.h"
-#include "CSSStyleSheet.h"
#include "Document.h"
#include "HTMLNames.h"
#include "MediaList.h"
#include "MediaQueryExp.h"
#include "StyleRule.h"
+#include "StyleSheetContents.h"
#include "WebKitCSSKeyframeRule.h"
#include "WebKitCSSKeyframesRule.h"
#include <wtf/FastMalloc.h>
diff --git a/Source/WebCore/css/CSSImportRule.cpp b/Source/WebCore/css/CSSImportRule.cpp
index d150fb935..fa10a287c 100644
--- a/Source/WebCore/css/CSSImportRule.cpp
+++ b/Source/WebCore/css/CSSImportRule.cpp
@@ -1,7 +1,7 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* (C) 2002-2003 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2002, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2002, 2005, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -28,108 +28,12 @@
#include "Document.h"
#include "MediaList.h"
#include "SecurityOrigin.h"
-#include "Settings.h"
-#include <wtf/StdLibExtras.h>
+#include "StyleRuleImport.h"
+#include "StyleSheetContents.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
-PassRefPtr<StyleRuleImport> StyleRuleImport::create(const String& href, PassRefPtr<MediaQuerySet> media)
-{
- return adoptRef(new StyleRuleImport(href, media));
-}
-
-StyleRuleImport::StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet> media)
- : StyleRuleBase(Import, 0)
- , m_parentStyleSheet(0)
- , m_styleSheetClient(this)
- , m_strHref(href)
- , m_mediaQueries(media)
- , m_cachedSheet(0)
- , m_loading(false)
-{
- if (!m_mediaQueries)
- m_mediaQueries = MediaQuerySet::create(String());
-}
-
-StyleRuleImport::~StyleRuleImport()
-{
- if (m_styleSheet)
- m_styleSheet->clearOwnerRule();
- if (m_cachedSheet)
- m_cachedSheet->removeClient(&m_styleSheetClient);
-}
-
-void StyleRuleImport::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* cachedStyleSheet)
-{
- if (m_styleSheet)
- m_styleSheet->clearOwnerRule();
-
- CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : CSSStrictMode;
- context.charset = charset;
- if (!baseURL.isNull())
- context.baseURL = baseURL;
-
- m_styleSheet = StyleSheetInternal::create(this, href, baseURL, context);
-
- Document* document = m_parentStyleSheet ? m_parentStyleSheet->singleOwnerDocument() : 0;
- m_styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document ? document->securityOrigin() : 0);
-
- m_loading = false;
-
- if (m_parentStyleSheet) {
- m_parentStyleSheet->notifyLoadedSheet(cachedStyleSheet);
- m_parentStyleSheet->checkLoaded();
- }
-}
-
-bool StyleRuleImport::isLoading() const
-{
- return m_loading || (m_styleSheet && m_styleSheet->isLoading());
-}
-
-void StyleRuleImport::requestStyleSheet()
-{
- if (!m_parentStyleSheet)
- return;
- Document* document = m_parentStyleSheet->singleOwnerDocument();
- if (!document)
- return;
-
- CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
- if (!cachedResourceLoader)
- return;
-
- String absHref = m_strHref;
- if (!m_parentStyleSheet->finalURL().isNull())
- // use parent styleheet's URL as the base URL
- absHref = KURL(m_parentStyleSheet->finalURL(), m_strHref).string();
-
- // Check for a cycle in our import chain. If we encounter a stylesheet
- // in our parent chain with the same URL, then just bail.
- StyleSheetInternal* rootSheet = m_parentStyleSheet;
- for (StyleSheetInternal* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
- if (absHref == sheet->finalURL().string() || absHref == sheet->originalURL())
- return;
- rootSheet = sheet;
- }
-
- ResourceRequest request(document->completeURL(absHref));
- if (m_parentStyleSheet->isUserStyleSheet())
- m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, m_parentStyleSheet->charset());
- else
- m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, m_parentStyleSheet->charset());
- if (m_cachedSheet) {
- // if the import rule is issued dynamically, the sheet may be
- // removed from the pending sheet count, so let the doc know
- // the sheet being imported is pending.
- if (m_parentStyleSheet && m_parentStyleSheet->loadCompleted() && rootSheet == m_parentStyleSheet)
- m_parentStyleSheet->startLoadingDynamicSheet();
- m_loading = true;
- m_cachedSheet->addClient(&m_styleSheetClient);
- }
-}
-
CSSImportRule::CSSImportRule(StyleRuleImport* importRule, CSSStyleSheet* parent)
: CSSRule(parent, CSSRule::IMPORT_RULE)
, m_importRule(importRule)
@@ -144,6 +48,11 @@ CSSImportRule::~CSSImportRule()
m_mediaCSSOMWrapper->clearParentRule();
}
+String CSSImportRule::href() const
+{
+ return m_importRule->href();
+}
+
MediaList* CSSImportRule::media() const
{
if (!m_mediaCSSOMWrapper)
@@ -177,5 +86,4 @@ CSSStyleSheet* CSSImportRule::styleSheet() const
return m_styleSheetCSSOMWrapper.get();
}
-
} // namespace WebCore
diff --git a/Source/WebCore/css/CSSImportRule.h b/Source/WebCore/css/CSSImportRule.h
index ef2fd4287..9ee306611 100644
--- a/Source/WebCore/css/CSSImportRule.h
+++ b/Source/WebCore/css/CSSImportRule.h
@@ -1,7 +1,7 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* (C) 2002-2003 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2002, 2006, 2008, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,65 +23,13 @@
#define CSSImportRule_h
#include "CSSRule.h"
-#include "CachedResourceHandle.h"
-#include "CachedStyleSheetClient.h"
-#include "PlatformString.h"
-#include "StyleRule.h"
namespace WebCore {
class CachedCSSStyleSheet;
class MediaList;
class MediaQuerySet;
-class StyleSheetInternal;
-
-class StyleRuleImport : public StyleRuleBase {
-public:
- static PassRefPtr<StyleRuleImport> create(const String& href, PassRefPtr<MediaQuerySet>);
-
- ~StyleRuleImport();
-
- StyleSheetInternal* parentStyleSheet() const { return m_parentStyleSheet; }
- void setParentStyleSheet(StyleSheetInternal* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; }
- void clearParentStyleSheet() { m_parentStyleSheet = 0; }
-
- String href() const { return m_strHref; }
- StyleSheetInternal* styleSheet() const { return m_styleSheet.get(); }
-
- bool isLoading() const;
- MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); }
-
- void requestStyleSheet();
-
-private:
- // NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it
- // to avoid adding a vptr to StyleRuleImport.
- class ImportedStyleSheetClient : public CachedStyleSheetClient {
- public:
- ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }
- virtual ~ImportedStyleSheetClient() { }
- virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)
- {
- m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);
- }
- private:
- StyleRuleImport* m_ownerRule;
- };
-
- void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
- friend class ImportedStyleSheetClient;
-
- StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet>);
-
- StyleSheetInternal* m_parentStyleSheet;
-
- ImportedStyleSheetClient m_styleSheetClient;
- String m_strHref;
- RefPtr<MediaQuerySet> m_mediaQueries;
- RefPtr<StyleSheetInternal> m_styleSheet;
- CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
- bool m_loading;
-};
+class StyleRuleImport;
class CSSImportRule : public CSSRule {
public:
@@ -89,7 +37,7 @@ public:
~CSSImportRule();
- String href() const { return m_importRule->href(); }
+ String href() const;
MediaList* media() const;
CSSStyleSheet* styleSheet() const;
diff --git a/Source/WebCore/css/CSSMediaRule.cpp b/Source/WebCore/css/CSSMediaRule.cpp
index e09904209..6db320c27 100644
--- a/Source/WebCore/css/CSSMediaRule.cpp
+++ b/Source/WebCore/css/CSSMediaRule.cpp
@@ -63,7 +63,7 @@ unsigned CSSMediaRule::insertRule(const String& ruleString, unsigned index, Exce
CSSParser parser(parserContext());
CSSStyleSheet* styleSheet = parentStyleSheet();
- RefPtr<StyleRuleBase> newRule = parser.parseRule(styleSheet ? styleSheet->internal() : 0, ruleString);
+ RefPtr<StyleRuleBase> newRule = parser.parseRule(styleSheet ? styleSheet->contents() : 0, ruleString);
if (!newRule) {
// SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.
ec = SYNTAX_ERR;
diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp
index 1b250eb29..e14ed8ae9 100644
--- a/Source/WebCore/css/CSSParser.cpp
+++ b/Source/WebCore/css/CSSParser.cpp
@@ -35,11 +35,7 @@
#include "CSSFontFaceSrcValue.h"
#include "CSSFunctionValue.h"
#include "CSSGradientValue.h"
-#if ENABLE(CSS_IMAGE_SET)
-#include "CSSImageSetValue.h"
-#endif
#include "CSSImageValue.h"
-#include "CSSImportRule.h"
#include "CSSInheritedValue.h"
#include "CSSInitialValue.h"
#include "CSSLineBoxContainValue.h"
@@ -50,8 +46,6 @@
#include "CSSPropertySourceData.h"
#include "CSSReflectValue.h"
#include "CSSSelector.h"
-#include "CSSStyleRule.h"
-#include "CSSStyleSheet.h"
#include "CSSTimingFunctionValue.h"
#include "CSSUnicodeRangeValue.h"
#include "CSSValueKeywords.h"
@@ -77,23 +71,32 @@
#include "StylePropertySet.h"
#include "StylePropertyShorthand.h"
#include "StyleRule.h"
+#include "StyleRuleImport.h"
+#include "StyleSheetContents.h"
#include "TextEncoding.h"
-#if ENABLE(CSS_FILTERS)
-#include "WebKitCSSFilterValue.h"
-#endif
#include "WebKitCSSKeyframeRule.h"
#include "WebKitCSSKeyframesRule.h"
#include "WebKitCSSRegionRule.h"
#include "WebKitCSSTransformValue.h"
-#if ENABLE(CSS_SHADERS)
-#include "WebKitCSSShaderValue.h"
-#endif
#include <limits.h>
+#include <wtf/BitArray.h>
#include <wtf/HexNumber.h>
#include <wtf/dtoa.h>
#include <wtf/text/StringBuffer.h>
#include <wtf/text/StringBuilder.h>
+#if ENABLE(CSS_IMAGE_SET)
+#include "CSSImageSetValue.h"
+#endif
+
+#if ENABLE(CSS_FILTERS)
+#include "WebKitCSSFilterValue.h"
+#endif
+
+#if ENABLE(CSS_SHADERS)
+#include "WebKitCSSShaderValue.h"
+#endif
+
#if ENABLE(DASHBOARD_SUPPORT)
#include "DashboardRegion.h"
#endif
@@ -187,6 +190,7 @@ CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL)
, isHTMLDocument(false)
, isCSSCustomFilterEnabled(false)
, isCSSRegionsEnabled(false)
+ , isCSSGridLayoutEnabled(false)
, needsSiteSpecificQuirks(false)
, enforcesCSSMIMETypeInNoQuirksMode(true)
{
@@ -199,6 +203,7 @@ CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
, isHTMLDocument(document->isHTMLDocument())
, isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCSSCustomFilterEnabled() : false)
, isCSSRegionsEnabled(document->cssRegionsEnabled())
+ , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled())
, needsSiteSpecificQuirks(document->settings() ? document->settings()->needsSiteSpecificQuirks() : false)
, enforcesCSSMIMETypeInNoQuirksMode(!document->settings() || document->settings()->enforceCSSMIMETypeInNoQuirksMode())
{
@@ -212,6 +217,7 @@ bool operator==(const CSSParserContext& a, const CSSParserContext& b)
&& a.isHTMLDocument == b.isHTMLDocument
&& a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled
&& a.isCSSRegionsEnabled == b.isCSSRegionsEnabled
+ && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled
&& a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks
&& a.enforcesCSSMIMETypeInNoQuirksMode == b.enforcesCSSMIMETypeInNoQuirksMode;
}
@@ -298,7 +304,7 @@ void CSSParser::setupParser(const char* prefix, const String& string, const char
resetRuleBodyMarks();
}
-void CSSParser::parseSheet(StyleSheetInternal* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
+void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
{
setStyleSheet(sheet);
m_defaultNamespace = starAtom; // Reset the default namespace.
@@ -316,7 +322,7 @@ void CSSParser::parseSheet(StyleSheetInternal* sheet, const String& string, int
m_rule = 0;
}
-PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetInternal* sheet, const String& string)
+PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetContents* sheet, const String& string)
{
setStyleSheet(sheet);
m_allowNamespaceDeclarations = false;
@@ -325,7 +331,7 @@ PassRefPtr<StyleRuleBase> CSSParser::parseRule(StyleSheetInternal* sheet, const
return m_rule.release();
}
-PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetInternal* sheet, const String& string)
+PassRefPtr<StyleKeyframe> CSSParser::parseKeyframeRule(StyleSheetContents* sheet, const String& string)
{
setStyleSheet(sheet);
setupParser("@-webkit-keyframe-rule{ ", string, "} ");
@@ -415,10 +421,12 @@ static inline bool isSimpleLengthPropertyID(CSSPropertyID propertyId, bool& acce
case CSSPropertyWebkitPaddingStart:
acceptsNegativeNumbers = false;
return true;
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrapMargin:
case CSSPropertyWebkitWrapPadding:
acceptsNegativeNumbers = false;
return RuntimeEnabledFeatures::cssExclusionsEnabled();
+#endif
case CSSPropertyBottom:
case CSSPropertyLeft:
case CSSPropertyMarginBottom:
@@ -490,7 +498,7 @@ static bool parseSimpleLengthValue(StylePropertySet* declaration, CSSPropertyID
return true;
}
-static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int valueID)
+static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int valueID, const CSSParserContext& parserContext)
{
if (!valueID)
return false;
@@ -533,13 +541,16 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
// inline-table | table-row-group | table-header-group | table-footer-group | table-row |
// table-column-group | table-column | table-cell | table-caption | -webkit-box | -webkit-inline-box | none | inherit
// -webkit-flex | -webkit-inline-flex | -webkit-grid | -webkit-inline-grid
- if ((valueID >= CSSValueInline && valueID <= CSSValueWebkitInlineFlex) || valueID == CSSValueNone)
+ if ((valueID >= CSSValueInline && valueID <= CSSValueWebkitInlineBox) || valueID == CSSValueNone)
return true;
-#if ENABLE(CSS_GRID_LAYOUT)
- if (valueID == CSSValueWebkitGrid || valueID == CSSValueWebkitInlineGrid)
+#if ENABLE(CSS3_FLEXBOX)
+ if (valueID == CSSValueWebkitFlex || valueID == CSSValueWebkitInlineFlex)
return true;
#endif
+ if (parserContext.isCSSGridLayoutEnabled && (valueID == CSSValueWebkitGrid || valueID == CSSValueWebkitInlineGrid))
+ return true;
break;
+
case CSSPropertyEmptyCells: // show | hide | inherit
if (valueID == CSSValueShow || valueID == CSSValueHide)
return true;
@@ -575,6 +586,18 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
if (valueID == CSSValueVisible || valueID == CSSValueHidden || valueID == CSSValueScroll || valueID == CSSValueAuto || valueID == CSSValueOverlay || valueID == CSSValueWebkitMarquee)
return true;
break;
+ case CSSPropertyPageBreakAfter: // auto | always | avoid | left | right | inherit
+ case CSSPropertyPageBreakBefore:
+ case CSSPropertyWebkitColumnBreakAfter:
+ case CSSPropertyWebkitColumnBreakBefore:
+ if (valueID == CSSValueAuto || valueID == CSSValueAlways || valueID == CSSValueAvoid || valueID == CSSValueLeft || valueID == CSSValueRight)
+ return true;
+ break;
+ case CSSPropertyPageBreakInside: // avoid | auto | inherit
+ case CSSPropertyWebkitColumnBreakInside:
+ if (valueID == CSSValueAuto || valueID == CSSValueAvoid)
+ return true;
+ break;
case CSSPropertyPointerEvents:
// none | visiblePainted | visibleFill | visibleStroke | visible |
// painted | fill | stroke | auto | all | inherit
@@ -743,6 +766,21 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
if (valueID == CSSValueExact || valueID == CSSValueEconomy)
return true;
break;
+#if ENABLE(CSS_REGIONS)
+ case CSSPropertyWebkitRegionBreakAfter:
+ case CSSPropertyWebkitRegionBreakBefore:
+ if (parserContext.isCSSRegionsEnabled && (valueID == CSSValueAuto || valueID == CSSValueAlways || valueID == CSSValueAvoid || valueID == CSSValueLeft || valueID == CSSValueRight))
+ return true;
+ break;
+ case CSSPropertyWebkitRegionBreakInside:
+ if (parserContext.isCSSRegionsEnabled && (valueID == CSSValueAuto || valueID == CSSValueAvoid))
+ return true;
+ break;
+ case CSSPropertyWebkitRegionOverflow:
+ if (parserContext.isCSSRegionsEnabled && (valueID == CSSValueAuto || valueID == CSSValueBreak))
+ return true;
+ break;
+#endif
case CSSPropertyWebkitRtlOrdering:
if (valueID == CSSValueLogical || valueID == CSSValueVisual)
return true;
@@ -780,6 +818,7 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText)
return true;
break;
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrapFlow:
if (!RuntimeEnabledFeatures::cssExclusionsEnabled())
return false;
@@ -792,6 +831,7 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
if (valueID == CSSValueWrap || valueID == CSSValueNone)
return true;
break;
+#endif
case CSSPropertyWebkitWritingMode:
if (valueID >= CSSValueHorizontalTb && valueID <= CSSValueHorizontalBt)
return true;
@@ -837,6 +877,9 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
case CSSPropertyOutlineStyle:
case CSSPropertyOverflowX:
case CSSPropertyOverflowY:
+ case CSSPropertyPageBreakAfter:
+ case CSSPropertyPageBreakBefore:
+ case CSSPropertyPageBreakInside:
case CSSPropertyPointerEvents:
case CSSPropertyPosition:
case CSSPropertyResize:
@@ -865,6 +908,9 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
case CSSPropertyWebkitBoxOrient:
case CSSPropertyWebkitBoxPack:
case CSSPropertyWebkitColorCorrection:
+ case CSSPropertyWebkitColumnBreakAfter:
+ case CSSPropertyWebkitColumnBreakBefore:
+ case CSSPropertyWebkitColumnBreakInside:
case CSSPropertyWebkitColumnRuleStyle:
case CSSPropertyWebkitFlexAlign:
case CSSPropertyWebkitFlexDirection:
@@ -890,6 +936,12 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
case CSSPropertyWebkitOverflowScrolling:
#endif
case CSSPropertyWebkitPrintColorAdjust:
+#if ENABLE(CSS_REGIONS)
+ case CSSPropertyWebkitRegionBreakAfter:
+ case CSSPropertyWebkitRegionBreakBefore:
+ case CSSPropertyWebkitRegionBreakInside:
+ case CSSPropertyWebkitRegionOverflow:
+#endif
case CSSPropertyWebkitRtlOrdering:
case CSSPropertyWebkitTextCombine:
case CSSPropertyWebkitTextEmphasisPosition:
@@ -899,8 +951,10 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
case CSSPropertyWebkitUserDrag:
case CSSPropertyWebkitUserModify:
case CSSPropertyWebkitUserSelect:
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrapFlow:
case CSSPropertyWebkitWrapThrough:
+#endif
case CSSPropertyWebkitWritingMode:
case CSSPropertyWhiteSpace:
case CSSPropertyWordBreak:
@@ -911,7 +965,7 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId)
}
}
-static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important)
+static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext)
{
ASSERT(!string.isEmpty());
@@ -931,7 +985,7 @@ static bool parseKeywordValue(StylePropertySet* declaration, CSSPropertyID prope
value = cssValuePool().createInheritedValue();
else if (valueID == CSSValueInitial)
value = cssValuePool().createExplicitInitialValue();
- else if (isValidKeywordPropertyAndValue(propertyId, valueID))
+ else if (isValidKeywordPropertyAndValue(propertyId, valueID, parserContext))
value = cssValuePool().createIdentifierValue(valueID);
else
return false;
@@ -950,14 +1004,14 @@ PassRefPtr<CSSValueList> CSSParser::parseFontFaceValue(const AtomicString& strin
return static_pointer_cast<CSSValueList>(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily));
}
-bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetInternal* contextStyleSheet)
+bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, CSSParserMode cssParserMode, StyleSheetContents* contextStyleSheet)
{
ASSERT(!string.isEmpty());
if (parseSimpleLengthValue(declaration, propertyID, string, important, cssParserMode))
return true;
if (parseColorValue(declaration, propertyID, string, important, cssParserMode))
return true;
- if (parseKeywordValue(declaration, propertyID, string, important))
+ if (parseKeywordValue(declaration, propertyID, string, important, contextStyleSheet->parserContext()))
return true;
CSSParserContext context(cssParserMode);
@@ -969,7 +1023,7 @@ bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID property
return parser.parseValue(declaration, propertyID, string, important, contextStyleSheet);
}
-bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetInternal* contextStyleSheet)
+bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, StyleSheetContents* contextStyleSheet)
{
setStyleSheet(contextStyleSheet);
@@ -987,7 +1041,7 @@ bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID property
deleteFontFaceOnlyValues();
if (!m_parsedProperties.isEmpty()) {
ok = true;
- declaration->addParsedProperties(m_parsedProperties.data(), m_parsedProperties.size());
+ declaration->addParsedProperties(m_parsedProperties);
clearProperties();
}
@@ -1047,7 +1101,7 @@ bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document*
void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorList)
{
- RefPtr<StyleSheetInternal> dummyStyleSheet = StyleSheetInternal::create();
+ RefPtr<StyleSheetContents> dummyStyleSheet = StyleSheetContents::create();
setStyleSheet(dummyStyleSheet.get());
m_selectorListForParseSelector = &selectorList;
@@ -1061,7 +1115,7 @@ void CSSParser::parseSelector(const String& string, CSSSelectorList& selectorLis
ASSERT(dummyStyleSheet->hasOneRef());
}
-bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData, StyleSheetInternal* contextStyleSheet)
+bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData, StyleSheetContents* contextStyleSheet)
{
// Length of the "@-webkit-decls{" prefix.
static const unsigned prefixLength = 15;
@@ -1083,7 +1137,7 @@ bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& st
deleteFontFaceOnlyValues();
if (!m_parsedProperties.isEmpty()) {
ok = true;
- declaration->addParsedProperties(m_parsedProperties.data(), m_parsedProperties.size());
+ declaration->addParsedProperties(m_parsedProperties);
clearProperties();
}
@@ -1119,6 +1173,42 @@ PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string)
return m_mediaQuery.release();
}
+PassRefPtr<StylePropertySet> CSSParser::createStylePropertySet()
+{
+ BitArray<numCSSProperties> seenProperties;
+ BitArray<numCSSProperties> seenImportantProperties;
+
+ StylePropertyVector results;
+ results.reserveInitialCapacity(m_parsedProperties.size());
+
+ for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
+ const CSSProperty& property = m_parsedProperties[i];
+ const unsigned propertyIDIndex = property.id() - firstCSSProperty;
+
+ // Ignore non-important properties if we already have an important property with the same ID.
+ if (!property.isImportant() && seenImportantProperties.get(propertyIDIndex))
+ continue;
+
+ // If we already had this property, this new one takes precedence, so wipe out the old one.
+ if (seenProperties.get(propertyIDIndex)) {
+ for (unsigned i = 0; i < results.size(); ++i) {
+ if (results[i].id() == property.id()) {
+ results.remove(i);
+ break;
+ }
+ }
+ }
+
+ if (property.isImportant())
+ seenImportantProperties.set(propertyIDIndex);
+ seenProperties.set(propertyIDIndex);
+
+ results.uncheckedAppend(property);
+ }
+
+ return StylePropertySet::adopt(results, m_context.mode);
+}
+
void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit)
{
m_parsedProperties.append(CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand || implicit));
@@ -1138,7 +1228,7 @@ void CSSParser::clearProperties()
m_hasFontFaceOnlyValues = false;
}
-void CSSParser::setStyleSheet(StyleSheetInternal* styleSheet)
+void CSSParser::setStyleSheet(StyleSheetContents* styleSheet)
{
m_styleSheet = styleSheet;
}
@@ -1418,7 +1508,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
}
if (isKeywordPropertyID(propId)) {
- if (!isValidKeywordPropertyAndValue(propId, id))
+ if (!isValidKeywordPropertyAndValue(propId, id, m_context))
return false;
if (m_valueList->next() && !inShorthand())
return false;
@@ -1465,27 +1555,6 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
}
break;
- case CSSPropertyPageBreakAfter: // auto | always | avoid | left | right | inherit
- case CSSPropertyPageBreakBefore:
- case CSSPropertyWebkitColumnBreakAfter:
- case CSSPropertyWebkitColumnBreakBefore:
- case CSSPropertyWebkitRegionBreakAfter:
- case CSSPropertyWebkitRegionBreakBefore:
- if (id == CSSValueAuto
- || id == CSSValueAlways
- || id == CSSValueAvoid
- || id == CSSValueLeft
- || id == CSSValueRight)
- validPrimitive = ((propId == CSSPropertyWebkitRegionBreakAfter) || (propId == CSSPropertyWebkitRegionBreakBefore)) ? cssRegionsEnabled() : true;
- break;
-
- case CSSPropertyPageBreakInside: // avoid | auto | inherit
- case CSSPropertyWebkitColumnBreakInside:
- case CSSPropertyWebkitRegionBreakInside:
- if (id == CSSValueAuto || id == CSSValueAvoid)
- validPrimitive = (propId == CSSPropertyWebkitRegionBreakInside) ? cssRegionsEnabled() : true;
- break;
-
case CSSPropertyContent: // [ <string> | <uri> | <counter> | attr(X) | open-quote |
// close-quote | no-open-quote | no-close-quote ]+ | inherit
return parseContent(propId, important);
@@ -2054,6 +2123,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
else
validPrimitive = validUnit(value, FTime | FInteger | FNonNeg);
break;
+#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitFlowInto:
if (!cssRegionsEnabled())
return false;
@@ -2062,10 +2132,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
if (!cssRegionsEnabled())
return false;
return parseRegionThread(propId, important);
- case CSSPropertyWebkitRegionOverflow:
- if (cssRegionsEnabled() && (id == CSSValueAuto || id == CSSValueBreak))
- validPrimitive = true;
- break;
+#endif
case CSSPropertyWebkitTransform:
if (id == CSSValueNone)
validPrimitive = true;
@@ -2144,16 +2211,20 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
}
return false;
}
-#if ENABLE(CSS_GRID_LAYOUT)
+
case CSSPropertyWebkitGridColumns:
case CSSPropertyWebkitGridRows:
+ if (!cssGridLayoutEnabled())
+ return false;
return parseGridTrackList(propId, important);
case CSSPropertyWebkitGridColumn:
case CSSPropertyWebkitGridRow:
+ if (!cssGridLayoutEnabled())
+ return false;
validPrimitive = id == CSSValueAuto || validUnit(value, FInteger);
break;
-#endif
+
case CSSPropertyWebkitMarginCollapse: {
if (num == 1) {
ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
@@ -2407,7 +2478,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
else
return parseFontVariantLigatures(important);
break;
-
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitShapeInside:
case CSSPropertyWebkitShapeOutside:
if (!RuntimeEnabledFeatures::cssExclusionsEnabled())
@@ -2423,6 +2494,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
break;
case CSSPropertyWebkitWrap:
return RuntimeEnabledFeatures::cssExclusionsEnabled() && parseShorthand(propId, webkitWrapShorthand(), important);
+#endif
case CSSPropertyBorderBottomStyle:
case CSSPropertyBorderCollapse:
case CSSPropertyBorderLeftStyle:
@@ -2442,6 +2514,9 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyOutlineStyle:
case CSSPropertyOverflowX:
case CSSPropertyOverflowY:
+ case CSSPropertyPageBreakAfter:
+ case CSSPropertyPageBreakBefore:
+ case CSSPropertyPageBreakInside:
case CSSPropertyPointerEvents:
case CSSPropertyPosition:
case CSSPropertyResize:
@@ -2470,6 +2545,9 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyWebkitBoxOrient:
case CSSPropertyWebkitBoxPack:
case CSSPropertyWebkitColorCorrection:
+ case CSSPropertyWebkitColumnBreakAfter:
+ case CSSPropertyWebkitColumnBreakBefore:
+ case CSSPropertyWebkitColumnBreakInside:
case CSSPropertyWebkitColumnRuleStyle:
case CSSPropertyWebkitFlexAlign:
case CSSPropertyWebkitFlexDirection:
@@ -2495,6 +2573,12 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyWebkitOverflowScrolling:
#endif
case CSSPropertyWebkitPrintColorAdjust:
+#if ENABLE(CSS_REGIONS)
+ case CSSPropertyWebkitRegionBreakAfter:
+ case CSSPropertyWebkitRegionBreakBefore:
+ case CSSPropertyWebkitRegionBreakInside:
+ case CSSPropertyWebkitRegionOverflow:
+#endif
case CSSPropertyWebkitRtlOrdering:
case CSSPropertyWebkitTextCombine:
case CSSPropertyWebkitTextEmphasisPosition:
@@ -2504,8 +2588,10 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
case CSSPropertyWebkitUserDrag:
case CSSPropertyWebkitUserModify:
case CSSPropertyWebkitUserSelect:
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrapFlow:
case CSSPropertyWebkitWrapThrough:
+#endif
case CSSPropertyWebkitWritingMode:
case CSSPropertyWhiteSpace:
case CSSPropertyWordBreak:
@@ -3371,9 +3457,13 @@ PassRefPtr<CSSValue> CSSParser::parseFillSize(CSSPropertyID propId, bool& allowC
if (value->unit == CSSParserValue::Operator && value->iValue == ',')
allowComma = false;
else if (value->id != CSSValueAuto) {
- if (!validUnit(value, FLength | FPercent))
- return 0;
- parsedValue2 = createPrimitiveNumericValue(value);
+ if (!validUnit(value, FLength | FPercent)) {
+ if (!inShorthand())
+ return 0;
+ // We need to rewind the value list, so that when it is advanced we'll end up back at this value.
+ m_valueList->previous();
+ } else
+ parsedValue2 = createPrimitiveNumericValue(value);
}
} else if (!parsedValue2 && propId == CSSPropertyWebkitBackgroundSize) {
// For backwards compatibility we set the second value to the first if it is omitted.
@@ -3837,7 +3927,6 @@ bool CSSParser::parseAnimationProperty(CSSPropertyID propId, RefPtr<CSSValue>& r
return false;
}
-#if ENABLE(CSS_GRID_LAYOUT)
bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important)
{
CSSParserValue* value = m_valueList->current();
@@ -3862,8 +3951,6 @@ bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important)
addProperty(propId, values.release(), important);
return true;
}
-#endif
-
#if ENABLE(DASHBOARD_SUPPORT)
@@ -4108,6 +4195,8 @@ bool CSSParser::parseClipShape(CSSPropertyID propId, bool important)
return false;
}
+#if ENABLE(CSS_EXCLUSIONS)
+
PassRefPtr<CSSWrapShape> CSSParser::parseExclusionShapeRectangle(CSSParserValueList* args)
{
ASSERT(args);
@@ -4330,6 +4419,8 @@ bool CSSParser::parseExclusionShape(bool shapeInside, bool important)
return false;
}
+#endif
+
// [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family'
bool CSSParser::parseFont(bool important)
{
@@ -4346,7 +4437,7 @@ bool CSSParser::parseFont(bool important)
bool fontWeightParsed = false;
CSSParserValue* value;
while ((value = m_valueList->current())) {
- if (!fontStyleParsed && isValidKeywordPropertyAndValue(CSSPropertyFontStyle, value->id)) {
+ if (!fontStyleParsed && isValidKeywordPropertyAndValue(CSSPropertyFontStyle, value->id, m_context)) {
addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(value->id), important);
fontStyleParsed = true;
} else if (!fontVariantParsed && (value->id == CSSValueNormal || value->id == CSSValueSmallCaps)) {
@@ -7240,6 +7331,7 @@ PassRefPtr<CSSValueList> CSSParser::parseFilter()
}
#endif
+#if ENABLE(CSS_REGIONS)
static bool validFlowName(const String& flowName)
{
return !(equalIgnoringCase(flowName, "auto")
@@ -7248,15 +7340,22 @@ static bool validFlowName(const String& flowName)
|| equalIgnoringCase(flowName, "initial")
|| equalIgnoringCase(flowName, "none"));
}
+#endif
bool CSSParser::cssRegionsEnabled() const
{
return m_context.isCSSRegionsEnabled;
}
+bool CSSParser::cssGridLayoutEnabled() const
+{
+ return m_context.isCSSGridLayoutEnabled;
+}
+
+#if ENABLE(CSS_REGIONS)
bool CSSParser::parseFlowThread(const String& flowName)
{
- RefPtr<StyleSheetInternal> dummyStyleSheet = StyleSheetInternal::create();
+ RefPtr<StyleSheetContents> dummyStyleSheet = StyleSheetContents::create();
setStyleSheet(dummyStyleSheet.get());
setupParser("@-webkit-decls{-webkit-flow-into:", flowName, "}");
@@ -7329,6 +7428,7 @@ bool CSSParser::parseRegionThread(CSSPropertyID propId, bool important)
return true;
}
+#endif
bool CSSParser::parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtr<CSSValue>& value, RefPtr<CSSValue>& value2, RefPtr<CSSValue>& value3)
{
@@ -8425,8 +8525,10 @@ inline void CSSParser::detectAtToken(int length, bool hasEscape)
return;
case 15:
+#if ENABLE(CSS_REGIONS)
if (!hasEscape && isEqualToCSSIdentifier(name + 2, "webkit-region"))
m_token = WEBKIT_REGION_RULE_SYM;
+#endif
return;
case 17:
@@ -9031,7 +9133,7 @@ StyleRuleBase* CSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* se
rule->parserAdoptSelectorVector(*selectors);
if (m_hasFontFaceOnlyValues)
deleteFontFaceOnlyValues();
- rule->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));
+ rule->setProperties(createStylePropertySet());
result = rule.get();
m_parsedRules.append(rule.release());
if (m_ruleRangeMap) {
@@ -9067,7 +9169,7 @@ StyleRuleBase* CSSParser::createFontFaceRule()
}
}
RefPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create();
- rule->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));
+ rule->setProperties(createStylePropertySet());
clearProperties();
StyleRuleFontFace* result = rule.get();
m_parsedRules.append(rule.release());
@@ -9140,7 +9242,7 @@ StyleRuleBase* CSSParser::createPageRule(PassOwnPtr<CSSParserSelector> pageSelec
Vector<OwnPtr<CSSParserSelector> > selectorVector;
selectorVector.append(pageSelector);
rule->parserAdoptSelectorVector(selectorVector);
- rule->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));
+ rule->setProperties(createStylePropertySet());
pageRule = rule.get();
m_parsedRules.append(rule.release());
}
@@ -9218,7 +9320,7 @@ StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys)
RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
keyframe->setKeyText(keyString);
- keyframe->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));
+ keyframe->setProperties(createStylePropertySet());
clearProperties();
diff --git a/Source/WebCore/css/CSSParser.h b/Source/WebCore/css/CSSParser.h
index 2c5a27ab8..f52394413 100644
--- a/Source/WebCore/css/CSSParser.h
+++ b/Source/WebCore/css/CSSParser.h
@@ -61,7 +61,7 @@ class StylePropertyShorthand;
class StyleRuleBase;
class StyleRuleKeyframes;
class StyleKeyframe;
-class StyleSheetInternal;
+class StyleSheetContents;
class StyledElement;
class CSSParser {
@@ -70,15 +70,15 @@ public:
~CSSParser();
- void parseSheet(StyleSheetInternal*, const String&, int startLineNumber = 0, StyleRuleRangeMap* = 0);
- PassRefPtr<StyleRuleBase> parseRule(StyleSheetInternal*, const String&);
- PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetInternal*, const String&);
- static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetInternal*);
+ void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0, StyleRuleRangeMap* = 0);
+ PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&);
+ PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const String&);
+ static bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, CSSParserMode, StyleSheetContents*);
static bool parseColor(RGBA32& color, const String&, bool strict = false);
static bool parseSystemColor(RGBA32& color, const String&, Document*);
static PassRefPtr<CSSValueList> parseFontFaceValue(const AtomicString&);
PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int ident, CSSParserValue*);
- bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>*, StyleSheetInternal* contextStyleSheet);
+ bool parseDeclaration(StylePropertySet*, const String&, RefPtr<CSSStyleSourceData>*, StyleSheetContents* contextStyleSheet);
PassOwnPtr<MediaQuery> parseMediaQuery(const String&);
void addProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false);
@@ -129,9 +129,8 @@ public:
bool parseTransitionShorthand(bool important);
bool parseAnimationShorthand(bool important);
-#if ENABLE(CSS_GRID_LAYOUT)
+ bool cssGridLayoutEnabled() const;
bool parseGridTrackList(CSSPropertyID, bool important);
-#endif
bool parseDashboardRegions(CSSPropertyID, bool important);
@@ -283,11 +282,13 @@ public:
void clearProperties();
+ PassRefPtr<StylePropertySet> createStylePropertySet();
+
CSSParserContext m_context;
bool m_important;
CSSPropertyID m_id;
- StyleSheetInternal* m_styleSheet;
+ StyleSheetContents* m_styleSheet;
RefPtr<StyleRuleBase> m_rule;
RefPtr<StyleKeyframe> m_keyframe;
OwnPtr<MediaQuery> m_mediaQuery;
@@ -348,7 +349,7 @@ private:
inline void detectDashToken(int);
inline void detectAtToken(int, bool);
- void setStyleSheet(StyleSheetInternal*);
+ void setStyleSheet(StyleSheetContents*);
inline bool inStrictMode() const { return m_context.mode == CSSStrictMode || m_context.mode == SVGAttributeMode; }
inline bool inQuirksMode() const { return m_context.mode == CSSQuirksMode; }
@@ -368,7 +369,7 @@ private:
bool isGeneratedImageValue(CSSParserValue*) const;
bool parseGeneratedImage(CSSParserValueList*, RefPtr<CSSValue>&);
- bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, StyleSheetInternal* contextStyleSheet);
+ bool parseValue(StylePropertySet*, CSSPropertyID, const String&, bool important, StyleSheetContents* contextStyleSheet);
enum SizeParameterType {
None,
diff --git a/Source/WebCore/css/CSSParserMode.h b/Source/WebCore/css/CSSParserMode.h
index 4e74f8c2e..d9200b72c 100644
--- a/Source/WebCore/css/CSSParserMode.h
+++ b/Source/WebCore/css/CSSParserMode.h
@@ -64,6 +64,7 @@ struct CSSParserContext {
bool isHTMLDocument;
bool isCSSCustomFilterEnabled;
bool isCSSRegionsEnabled;
+ bool isCSSGridLayoutEnabled;
bool needsSiteSpecificQuirks;
bool enforcesCSSMIMETypeInNoQuirksMode;
};
diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp
index 704a42d2a..0bf66ad96 100644
--- a/Source/WebCore/css/CSSPrimitiveValue.cpp
+++ b/Source/WebCore/css/CSSPrimitiveValue.cpp
@@ -25,7 +25,6 @@
#include "CSSHelper.h"
#include "CSSParser.h"
#include "CSSPropertyNames.h"
-#include "CSSStyleSheet.h"
#include "CSSValueKeywords.h"
#include "CSSWrapShapes.h"
#include "CalculationValue.h"
@@ -37,6 +36,7 @@
#include "RGBColor.h"
#include "Rect.h"
#include "RenderStyle.h"
+#include "StyleSheetContents.h"
#include <wtf/ASCIICType.h>
#include <wtf/DecimalNumber.h>
#include <wtf/StdLibExtras.h>
@@ -1064,7 +1064,7 @@ String CSSPrimitiveValue::customCssText() const
return text;
}
-void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
+void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
{
if (m_primitiveUnitType == CSS_URI)
addSubresourceURL(urls, styleSheet->completeURL(m_value.string));
diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h
index 78f5cd90e..a8a0bbcd9 100644
--- a/Source/WebCore/css/CSSPrimitiveValue.h
+++ b/Source/WebCore/css/CSSPrimitiveValue.h
@@ -283,7 +283,7 @@ public:
bool isQuirkValue() { return m_isQuirkValue; }
- void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
+ void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
Length viewportPercentageLength();
diff --git a/Source/WebCore/css/CSSPrimitiveValueMappings.h b/Source/WebCore/css/CSSPrimitiveValueMappings.h
index 822ad51b6..c734e065a 100644
--- a/Source/WebCore/css/CSSPrimitiveValueMappings.h
+++ b/Source/WebCore/css/CSSPrimitiveValueMappings.h
@@ -1117,14 +1117,12 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e)
case INLINE_FLEX:
m_value.ident = CSSValueWebkitInlineFlex;
break;
-#if ENABLE(CSS_GRID_LAYOUT)
case GRID:
m_value.ident = CSSValueWebkitGrid;
break;
case INLINE_GRID:
m_value.ident = CSSValueWebkitInlineGrid;
break;
-#endif
case NONE:
m_value.ident = CSSValueNone;
break;
diff --git a/Source/WebCore/css/CSSProperty.cpp b/Source/WebCore/css/CSSProperty.cpp
index a00e774ad..fc76a5e7a 100644
--- a/Source/WebCore/css/CSSProperty.cpp
+++ b/Source/WebCore/css/CSSProperty.cpp
@@ -547,13 +547,10 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
case CSSPropertyWebkitFlexLinePack:
case CSSPropertyWebkitFlexWrap:
case CSSPropertyWebkitFontSizeDelta:
-#if ENABLE(CSS_GRID_LAYOUT)
case CSSPropertyWebkitGridColumns:
case CSSPropertyWebkitGridRows:
-
case CSSPropertyWebkitGridColumn:
case CSSPropertyWebkitGridRow:
-#endif
case CSSPropertyWebkitLineClamp:
case CSSPropertyWebkitLogicalWidth:
case CSSPropertyWebkitLogicalHeight:
@@ -616,12 +613,15 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
case CSSPropertyWebkitTransitionProperty:
case CSSPropertyWebkitTransitionTimingFunction:
case CSSPropertyWebkitUserDrag:
+#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitFlowInto:
case CSSPropertyWebkitFlowFrom:
case CSSPropertyWebkitRegionOverflow:
case CSSPropertyWebkitRegionBreakAfter:
case CSSPropertyWebkitRegionBreakBefore:
case CSSPropertyWebkitRegionBreakInside:
+#endif
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrap:
case CSSPropertyWebkitWrapFlow:
case CSSPropertyWebkitWrapMargin:
@@ -629,6 +629,7 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
case CSSPropertyWebkitShapeInside:
case CSSPropertyWebkitShapeOutside:
case CSSPropertyWebkitWrapThrough:
+#endif
#if ENABLE(SVG)
case CSSPropertyClipPath:
case CSSPropertyMask:
diff --git a/Source/WebCore/css/CSSPropertyNames.in b/Source/WebCore/css/CSSPropertyNames.in
index 1a22f254d..eddd71503 100644
--- a/Source/WebCore/css/CSSPropertyNames.in
+++ b/Source/WebCore/css/CSSPropertyNames.in
@@ -266,6 +266,10 @@ z-index
-webkit-flex-pack
-webkit-flex-wrap
-webkit-font-size-delta
+-webkit-grid-columns
+-webkit-grid-rows
+-webkit-grid-column
+-webkit-grid-row
-webkit-highlight
-webkit-hyphenate-character
-webkit-hyphenate-limit-after
@@ -360,28 +364,26 @@ z-index
-webkit-user-drag
-webkit-user-modify
-webkit-user-select
+#if defined(ENABLE_CSS_REGIONS) && ENABLE_CSS_REGIONS
-webkit-flow-into
-webkit-flow-from
-webkit-region-overflow
+-webkit-region-break-after
+-webkit-region-break-before
+-webkit-region-break-inside
+#endif
+#if defined(ENABLE_CSS_EXCLUSIONS) && ENABLE_CSS_EXCLUSIONS
-webkit-shape-inside
-webkit-shape-outside
-webkit-wrap-margin
-webkit-wrap-padding
--webkit-region-break-after
--webkit-region-break-before
--webkit-region-break-inside
-webkit-wrap-flow
-webkit-wrap-through
-webkit-wrap
+#endif
#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
-webkit-tap-highlight-color
#endif
-#if defined(ENABLE_CSS_GRID_LAYOUT) && ENABLE_CSS_GRID_LAYOUT
--webkit-grid-columns
--webkit-grid-rows
--webkit-grid-column
--webkit-grid-row
-#endif
#if defined(ENABLE_DASHBOARD_SUPPORT) && ENABLE_DASHBOARD_SUPPORT
-webkit-dashboard-region
#endif
diff --git a/Source/WebCore/css/CSSReflectValue.cpp b/Source/WebCore/css/CSSReflectValue.cpp
index bc786b588..f5d658e18 100644
--- a/Source/WebCore/css/CSSReflectValue.cpp
+++ b/Source/WebCore/css/CSSReflectValue.cpp
@@ -59,7 +59,7 @@ String CSSReflectValue::customCssText() const
return result;
}
-void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
+void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
{
if (m_mask)
m_mask->addSubresourceStyleURLs(urls, styleSheet);
diff --git a/Source/WebCore/css/CSSReflectValue.h b/Source/WebCore/css/CSSReflectValue.h
index 1514775f0..9a844259e 100644
--- a/Source/WebCore/css/CSSReflectValue.h
+++ b/Source/WebCore/css/CSSReflectValue.h
@@ -49,7 +49,7 @@ public:
String customCssText() const;
- void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
+ void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
private:
CSSReflectValue(CSSReflectionDirection direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
diff --git a/Source/WebCore/css/CSSRule.cpp b/Source/WebCore/css/CSSRule.cpp
index 09643ea9e..09e356de0 100644
--- a/Source/WebCore/css/CSSRule.cpp
+++ b/Source/WebCore/css/CSSRule.cpp
@@ -35,6 +35,7 @@
#include "WebKitCSSRegionRule.h"
#include "NotImplemented.h"
#include "StyleRule.h"
+#include "StyleSheetContents.h"
namespace WebCore {
@@ -71,8 +72,10 @@ String CSSRule::cssText() const
return static_cast<const WebKitCSSKeyframesRule*>(this)->cssText();
case WEBKIT_KEYFRAME_RULE:
return static_cast<const WebKitCSSKeyframeRule*>(this)->cssText();
+#if ENABLE(CSS_REGIONS)
case WEBKIT_REGION_RULE:
return static_cast<const WebKitCSSRegionRule*>(this)->cssText();
+#endif
}
ASSERT_NOT_REACHED();
return String();
@@ -108,9 +111,11 @@ void CSSRule::destroy()
case WEBKIT_KEYFRAME_RULE:
delete static_cast<WebKitCSSKeyframeRule*>(this);
return;
+#if ENABLE(CSS_REGIONS)
case WEBKIT_REGION_RULE:
delete static_cast<WebKitCSSRegionRule*>(this);
return;
+#endif
}
ASSERT_NOT_REACHED();
}
@@ -146,9 +151,11 @@ void CSSRule::reattach(StyleRuleBase* rule)
// No need to reattach, the underlying data is shareable on mutation.
ASSERT_NOT_REACHED();
return;
+#if ENABLE(CSS_REGIONS)
case WEBKIT_REGION_RULE:
static_cast<WebKitCSSRegionRule*>(this)->reattach(static_cast<StyleRuleRegion*>(rule));
return;
+#endif
}
ASSERT_NOT_REACHED();
}
@@ -156,7 +163,7 @@ void CSSRule::reattach(StyleRuleBase* rule)
const CSSParserContext& CSSRule::parserContext() const
{
CSSStyleSheet* styleSheet = parentStyleSheet();
- return styleSheet ? styleSheet->internal()->parserContext() : strictCSSParserContext();
+ return styleSheet ? styleSheet->contents()->parserContext() : strictCSSParserContext();
}
} // namespace WebCore
diff --git a/Source/WebCore/css/CSSRule.h b/Source/WebCore/css/CSSRule.h
index 5ec2f7aa8..5c35ad5e7 100644
--- a/Source/WebCore/css/CSSRule.h
+++ b/Source/WebCore/css/CSSRule.h
@@ -57,7 +57,9 @@ public:
// <https://bugs.webkit.org/show_bug.cgi?id=71293>.
WEBKIT_KEYFRAMES_RULE,
WEBKIT_KEYFRAME_RULE,
+#if ENABLE(CSS_REGIONS)
WEBKIT_REGION_RULE = 10
+#endif
};
Type type() const { return static_cast<Type>(m_type); }
@@ -69,9 +71,12 @@ public:
bool isMediaRule() const { return type() == MEDIA_RULE; }
bool isPageRule() const { return type() == PAGE_RULE; }
bool isStyleRule() const { return type() == STYLE_RULE; }
- bool isRegionRule() const { return type() == WEBKIT_REGION_RULE; }
bool isImportRule() const { return type() == IMPORT_RULE; }
+#if ENABLE(CSS_REGIONS)
+ bool isRegionRule() const { return type() == WEBKIT_REGION_RULE; }
+#endif
+
void setParentStyleSheet(CSSStyleSheet* styleSheet)
{
m_parentIsRule = false;
diff --git a/Source/WebCore/css/CSSRule.idl b/Source/WebCore/css/CSSRule.idl
index dc65688d7..05854a27a 100644
--- a/Source/WebCore/css/CSSRule.idl
+++ b/Source/WebCore/css/CSSRule.idl
@@ -39,7 +39,9 @@ module css {
const unsigned short PAGE_RULE = 6;
const unsigned short WEBKIT_KEYFRAMES_RULE = 7;
const unsigned short WEBKIT_KEYFRAME_RULE = 8;
+#if defined(ENABLE_CSS_REGIONS) && ENABLE_CSS_REGIONS
const unsigned short WEBKIT_REGION_RULE = 10;
+#endif
readonly attribute unsigned short type;
diff --git a/Source/WebCore/css/CSSStyleSheet.cpp b/Source/WebCore/css/CSSStyleSheet.cpp
index 329fc8d14..00b2d91c5 100644
--- a/Source/WebCore/css/CSSStyleSheet.cpp
+++ b/Source/WebCore/css/CSSStyleSheet.cpp
@@ -35,9 +35,8 @@
#include "Node.h"
#include "SVGNames.h"
#include "SecurityOrigin.h"
-#include "StylePropertySet.h"
#include "StyleRule.h"
-#include <wtf/Deque.h>
+#include "StyleSheetContents.h"
namespace WebCore {
@@ -72,436 +71,40 @@ static bool isAcceptableCSSStyleSheetParent(Node* parentNode)
}
#endif
-// Rough size estimate for the memory cache.
-unsigned StyleSheetInternal::estimatedSizeInBytes() const
-{
- // Note that this does not take into account size of the strings hanging from various objects.
- // The assumption is that nearly all of of them are atomic and would exist anyway.
- unsigned size = sizeof(*this);
-
- // FIXME: This ignores the children of media and region rules.
- // Most rules are StyleRules.
- size += ruleCount() * StyleRule::averageSizeInBytes();
-
- for (unsigned i = 0; i < m_importRules.size(); ++i) {
- if (StyleSheetInternal* sheet = m_importRules[i]->styleSheet())
- size += sheet->estimatedSizeInBytes();
- }
- return size;
-}
-
-StyleSheetInternal::StyleSheetInternal(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const CSSParserContext& context)
- : m_ownerRule(ownerRule)
- , m_originalURL(originalURL)
- , m_finalURL(finalURL)
- , m_loadCompleted(false)
- , m_isUserStyleSheet(ownerRule && ownerRule->parentStyleSheet() && ownerRule->parentStyleSheet()->isUserStyleSheet())
- , m_hasSyntacticallyValidCSSHeader(true)
- , m_didLoadErrorOccur(false)
- , m_usesRemUnits(false)
- , m_isMutable(false)
- , m_isInMemoryCache(false)
- , m_parserContext(context)
-{
-}
-
-StyleSheetInternal::StyleSheetInternal(const StyleSheetInternal& o)
- : RefCounted<StyleSheetInternal>()
- , m_ownerRule(0)
- , m_originalURL(o.m_originalURL)
- , m_finalURL(o.m_finalURL)
- , m_encodingFromCharsetRule(o.m_encodingFromCharsetRule)
- , m_importRules(o.m_importRules.size())
- , m_childRules(o.m_childRules.size())
- , m_namespaces(o.m_namespaces)
- , m_loadCompleted(true)
- , m_isUserStyleSheet(o.m_isUserStyleSheet)
- , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader)
- , m_didLoadErrorOccur(false)
- , m_usesRemUnits(o.m_usesRemUnits)
- , m_isMutable(false)
- , m_isInMemoryCache(false)
- , m_parserContext(o.m_parserContext)
-{
- ASSERT(o.isCacheable());
-
- // FIXME: Copy import rules.
- ASSERT(o.m_importRules.isEmpty());
-
- for (unsigned i = 0; i < m_childRules.size(); ++i)
- m_childRules[i] = o.m_childRules[i]->copy();
-}
-
-StyleSheetInternal::~StyleSheetInternal()
-{
- clearRules();
-}
-
-bool StyleSheetInternal::isCacheable() const
-{
- // FIXME: Support copying import rules.
- if (!m_importRules.isEmpty())
- return false;
- // FIXME: Support cached stylesheets in import rules.
- if (m_ownerRule)
- return false;
- // This would require dealing with multiple clients for load callbacks.
- if (!m_loadCompleted)
- return false;
- if (m_didLoadErrorOccur)
- return false;
- // It is not the original sheet anymore.
- if (m_isMutable)
- return false;
- // If the header is valid we are not going to need to check the SecurityOrigin.
- // FIXME: Valid mime type avoids the check too.
- if (!m_hasSyntacticallyValidCSSHeader)
- return false;
- return true;
-}
-
-void StyleSheetInternal::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
-{
- ASSERT(!rule->isCharsetRule());
- if (rule->isImportRule()) {
- // Parser enforces that @import rules come before anything else except @charset.
- ASSERT(m_childRules.isEmpty());
- m_importRules.append(static_cast<StyleRuleImport*>(rule.get()));
- m_importRules.last()->setParentStyleSheet(this);
- m_importRules.last()->requestStyleSheet();
- return;
- }
- m_childRules.append(rule);
-}
-
-StyleRuleBase* StyleSheetInternal::ruleAt(unsigned index) const
-{
- ASSERT(index < ruleCount());
-
- unsigned childVectorIndex = index;
- if (hasCharsetRule()) {
- if (index == 0)
- return 0;
- --childVectorIndex;
- }
- if (childVectorIndex < m_importRules.size())
- return m_importRules[childVectorIndex].get();
-
- childVectorIndex -= m_importRules.size();
- return m_childRules[childVectorIndex].get();
-}
-
-unsigned StyleSheetInternal::ruleCount() const
-{
- unsigned result = 0;
- result += hasCharsetRule() ? 1 : 0;
- result += m_importRules.size();
- result += m_childRules.size();
- return result;
-}
-
-void StyleSheetInternal::clearCharsetRule()
-{
- m_encodingFromCharsetRule = String();
-}
-
-void StyleSheetInternal::clearRules()
-{
- for (unsigned i = 0; i < m_importRules.size(); ++i) {
- ASSERT(m_importRules.at(i)->parentStyleSheet() == this);
- m_importRules[i]->clearParentStyleSheet();
- }
- m_importRules.clear();
- m_childRules.clear();
- clearCharsetRule();
-}
-
-void StyleSheetInternal::parserSetEncodingFromCharsetRule(const String& encoding)
-{
- // Parser enforces that there is ever only one @charset.
- ASSERT(m_encodingFromCharsetRule.isNull());
- m_encodingFromCharsetRule = encoding;
-}
-
-bool StyleSheetInternal::wrapperInsertRule(PassRefPtr<StyleRuleBase> rule, unsigned index)
-{
- ASSERT(m_isMutable);
- ASSERT(index <= ruleCount());
- // Parser::parseRule doesn't currently allow @charset so we don't need to deal with it.
- ASSERT(!rule->isCharsetRule());
-
- unsigned childVectorIndex = index;
- // m_childRules does not contain @charset which is always in index 0 if it exists.
- if (hasCharsetRule()) {
- if (childVectorIndex == 0) {
- // Nothing can be inserted before @charset.
- return false;
- }
- --childVectorIndex;
- }
-
- if (childVectorIndex < m_importRules.size() || (childVectorIndex == m_importRules.size() && rule->isImportRule())) {
- // Inserting non-import rule before @import is not allowed.
- if (!rule->isImportRule())
- return false;
- m_importRules.insert(childVectorIndex, static_cast<StyleRuleImport*>(rule.get()));
- m_importRules[childVectorIndex]->setParentStyleSheet(this);
- m_importRules[childVectorIndex]->requestStyleSheet();
- // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded.
- return true;
- }
- // Inserting @import rule after a non-import rule is not allowed.
- if (rule->isImportRule())
- return false;
- childVectorIndex -= m_importRules.size();
-
- m_childRules.insert(childVectorIndex, rule);
- return true;
-}
-
-void StyleSheetInternal::wrapperDeleteRule(unsigned index)
-{
- ASSERT(m_isMutable);
- ASSERT(index < ruleCount());
-
- unsigned childVectorIndex = index;
- if (hasCharsetRule()) {
- if (childVectorIndex == 0) {
- clearCharsetRule();
- return;
- }
- --childVectorIndex;
- }
- if (childVectorIndex < m_importRules.size()) {
- m_importRules[childVectorIndex]->clearParentStyleSheet();
- m_importRules.remove(childVectorIndex);
- return;
- }
- childVectorIndex -= m_importRules.size();
-
- m_childRules.remove(childVectorIndex);
-}
-
-void StyleSheetInternal::parserAddNamespace(const AtomicString& prefix, const AtomicString& uri)
-{
- if (uri.isNull() || prefix.isNull())
- return;
- m_namespaces.add(prefix, uri);
-}
-
-const AtomicString& StyleSheetInternal::determineNamespace(const AtomicString& prefix)
-{
- if (prefix.isNull())
- return nullAtom; // No namespace. If an element/attribute has a namespace, we won't match it.
- if (prefix == starAtom)
- return starAtom; // We'll match any namespace.
- PrefixNamespaceURIMap::const_iterator it = m_namespaces.find(prefix);
- if (it == m_namespaces.end())
- return nullAtom;
- return it->second;
-}
-
-void StyleSheetInternal::parseAuthorStyleSheet(const CachedCSSStyleSheet* cachedStyleSheet, const SecurityOrigin* securityOrigin)
-{
- // Check to see if we should enforce the MIME type of the CSS resource in strict mode.
- // Running in iWeb 2 is one example of where we don't want to - <rdar://problem/6099748>
- bool enforceMIMEType = isStrictParserMode(m_parserContext.mode) && m_parserContext.enforcesCSSMIMETypeInNoQuirksMode;
- bool hasValidMIMEType = false;
- String sheetText = cachedStyleSheet->sheetText(enforceMIMEType, &hasValidMIMEType);
-
- CSSParser p(parserContext());
- p.parseSheet(this, sheetText, 0);
-
- // If we're loading a stylesheet cross-origin, and the MIME type is not standard, require the CSS
- // to at least start with a syntactically valid CSS rule.
- // This prevents an attacker playing games by injecting CSS strings into HTML, XML, JSON, etc. etc.
- if (!hasValidMIMEType && !hasSyntacticallyValidCSSHeader()) {
- bool isCrossOriginCSS = !securityOrigin || !securityOrigin->canRequest(finalURL());
- if (isCrossOriginCSS) {
- clearRules();
- return;
- }
- }
- if (m_parserContext.needsSiteSpecificQuirks && isStrictParserMode(m_parserContext.mode)) {
- // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
- DEFINE_STATIC_LOCAL(const String, slashKHTMLFixesDotCss, ("/KHTMLFixes.css"));
- DEFINE_STATIC_LOCAL(const String, mediaWikiKHTMLFixesStyleSheet, ("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n"));
- // There are two variants of KHTMLFixes.css. One is equal to mediaWikiKHTMLFixesStyleSheet,
- // while the other lacks the second trailing newline.
- if (finalURL().string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
- && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1)
- clearRules();
- }
-}
-
-bool StyleSheetInternal::parseString(const String& sheetText)
-{
- return parseStringAtLine(sheetText, 0);
-}
-
-bool StyleSheetInternal::parseStringAtLine(const String& sheetText, int startLineNumber)
-{
- CSSParser p(parserContext());
- p.parseSheet(this, sheetText, startLineNumber);
-
- return true;
-}
-
-bool StyleSheetInternal::isLoading() const
-{
- for (unsigned i = 0; i < m_importRules.size(); ++i) {
- if (m_importRules[i]->isLoading())
- return true;
- }
- return false;
-}
-
-void StyleSheetInternal::checkLoaded()
-{
- if (isLoading())
- return;
-
- // Avoid |this| being deleted by scripts that run via
- // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
- // See <rdar://problem/6622300>.
- RefPtr<StyleSheetInternal> protector(this);
- StyleSheetInternal* parentSheet = parentStyleSheet();
- if (parentSheet) {
- parentSheet->checkLoaded();
- m_loadCompleted = true;
- return;
- }
- RefPtr<Node> ownerNode = singleOwnerNode();
- if (!ownerNode) {
- m_loadCompleted = true;
- return;
- }
- m_loadCompleted = ownerNode->sheetLoaded();
- if (m_loadCompleted)
- ownerNode->notifyLoadedSheetAndAllCriticalSubresources(m_didLoadErrorOccur);
-}
-
-void StyleSheetInternal::notifyLoadedSheet(const CachedCSSStyleSheet* sheet)
-{
- ASSERT(sheet);
- m_didLoadErrorOccur |= sheet->errorOccurred();
-}
-
-void StyleSheetInternal::startLoadingDynamicSheet()
-{
- if (Node* owner = singleOwnerNode())
- owner->startLoadingDynamicSheet();
-}
-
-StyleSheetInternal* StyleSheetInternal::rootStyleSheet() const
-{
- const StyleSheetInternal* root = this;
- while (root->parentStyleSheet())
- root = root->parentStyleSheet();
- return const_cast<StyleSheetInternal*>(root);
-}
-
-Node* StyleSheetInternal::singleOwnerNode() const
-{
- StyleSheetInternal* root = rootStyleSheet();
- if (root->m_clients.isEmpty())
- return 0;
- ASSERT(root->m_clients.size() == 1);
- return root->m_clients[0]->ownerNode();
-}
-
-Document* StyleSheetInternal::singleOwnerDocument() const
-{
- Node* ownerNode = singleOwnerNode();
- return ownerNode ? ownerNode->document() : 0;
-}
-
-KURL StyleSheetInternal::completeURL(const String& url) const
-{
- return CSSParser::completeURL(m_parserContext, url);
-}
-
-void StyleSheetInternal::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
-{
- Deque<StyleSheetInternal*> styleSheetQueue;
- styleSheetQueue.append(this);
-
- while (!styleSheetQueue.isEmpty()) {
- StyleSheetInternal* styleSheet = styleSheetQueue.takeFirst();
-
- for (unsigned i = 0; i < styleSheet->m_importRules.size(); ++i) {
- StyleRuleImport* importRule = styleSheet->m_importRules[i].get();
- if (importRule->styleSheet()) {
- styleSheetQueue.append(importRule->styleSheet());
- addSubresourceURL(urls, importRule->styleSheet()->baseURL());
- }
- }
- for (unsigned i = 0; i < styleSheet->m_childRules.size(); ++i) {
- StyleRuleBase* rule = styleSheet->m_childRules[i].get();
- if (rule->isStyleRule())
- static_cast<StyleRule*>(rule)->properties()->addSubresourceStyleURLs(urls, this);
- else if (rule->isFontFaceRule())
- static_cast<StyleRuleFontFace*>(rule)->properties()->addSubresourceStyleURLs(urls, this);
- }
- }
-}
-
-StyleSheetInternal* StyleSheetInternal::parentStyleSheet() const
-{
- return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
-}
-
-void StyleSheetInternal::registerClient(CSSStyleSheet* sheet)
-{
- ASSERT(!m_clients.contains(sheet));
- m_clients.append(sheet);
-}
-
-void StyleSheetInternal::unregisterClient(CSSStyleSheet* sheet)
-{
- size_t position = m_clients.find(sheet);
- ASSERT(position != notFound);
- m_clients.remove(position);
-}
-
-void StyleSheetInternal::addedToMemoryCache()
-{
- ASSERT(!m_isInMemoryCache);
- ASSERT(isCacheable());
- m_isInMemoryCache = true;
+PassRefPtr<CSSStyleSheet> CSSStyleSheet::create(PassRefPtr<StyleSheetContents> sheet, CSSImportRule* ownerRule)
+{
+ return adoptRef(new CSSStyleSheet(sheet, ownerRule));
}
-void StyleSheetInternal::removedFromMemoryCache()
-{
- ASSERT(m_isInMemoryCache);
- ASSERT(isCacheable());
- m_isInMemoryCache = false;
+PassRefPtr<CSSStyleSheet> CSSStyleSheet::create(PassRefPtr<StyleSheetContents> sheet, Node* ownerNode)
+{
+ return adoptRef(new CSSStyleSheet(sheet, ownerNode));
}
PassRefPtr<CSSStyleSheet> CSSStyleSheet::createInline(Node* ownerNode, const KURL& baseURL, const String& encoding)
{
CSSParserContext parserContext(ownerNode->document(), baseURL, encoding);
- RefPtr<StyleSheetInternal> sheet = StyleSheetInternal::create(baseURL.string(), baseURL, parserContext);
+ RefPtr<StyleSheetContents> sheet = StyleSheetContents::create(baseURL.string(), baseURL, parserContext);
return adoptRef(new CSSStyleSheet(sheet.release(), ownerNode));
}
-CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetInternal> styleSheet, CSSImportRule* ownerRule)
- : m_internal(styleSheet)
+CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetContents> contents, CSSImportRule* ownerRule)
+ : m_contents(contents)
, m_isDisabled(false)
, m_ownerNode(0)
, m_ownerRule(ownerRule)
{
- m_internal->registerClient(this);
+ m_contents->registerClient(this);
}
-CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetInternal> styleSheet, Node* ownerNode)
- : m_internal(styleSheet)
+CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetContents> contents, Node* ownerNode)
+ : m_contents(contents)
, m_isDisabled(false)
, m_ownerNode(ownerNode)
, m_ownerRule(0)
{
ASSERT(isAcceptableCSSStyleSheetParent(ownerNode));
- m_internal->registerClient(this);
+ m_contents->registerClient(this);
}
CSSStyleSheet::~CSSStyleSheet()
@@ -516,25 +119,25 @@ CSSStyleSheet::~CSSStyleSheet()
if (m_mediaCSSOMWrapper)
m_mediaCSSOMWrapper->clearParentStyleSheet();
- m_internal->unregisterClient(this);
+ m_contents->unregisterClient(this);
}
void CSSStyleSheet::willMutateRules()
{
// If we are the only client it is safe to mutate.
- if (m_internal->hasOneClient() && !m_internal->isInMemoryCache()) {
- m_internal->setMutable();
+ if (m_contents->hasOneClient() && !m_contents->isInMemoryCache()) {
+ m_contents->setMutable();
return;
}
// Only cacheable stylesheets should have multiple clients.
- ASSERT(m_internal->isCacheable());
+ ASSERT(m_contents->isCacheable());
// Copy-on-write.
- m_internal->unregisterClient(this);
- m_internal = m_internal->copy();
- m_internal->registerClient(this);
+ m_contents->unregisterClient(this);
+ m_contents = m_contents->copy();
+ m_contents->registerClient(this);
- m_internal->setMutable();
+ m_contents->setMutable();
// Any existing CSSOM wrappers need to be connected to the copied child rules.
reattachChildRuleCSSOMWrappers();
@@ -542,8 +145,8 @@ void CSSStyleSheet::willMutateRules()
void CSSStyleSheet::didMutateRules()
{
- ASSERT(m_internal->isMutable());
- ASSERT(m_internal->hasOneClient());
+ ASSERT(m_contents->isMutable());
+ ASSERT(m_contents->hasOneClient());
didMutate();
}
@@ -561,7 +164,7 @@ void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
if (!m_childRuleCSSOMWrappers[i])
continue;
- m_childRuleCSSOMWrappers[i]->reattach(m_internal->ruleAt(i));
+ m_childRuleCSSOMWrappers[i]->reattach(m_contents->ruleAt(i));
}
}
@@ -581,7 +184,7 @@ void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries)
unsigned CSSStyleSheet::length() const
{
- return m_internal->ruleCount();
+ return m_contents->ruleCount();
}
CSSRule* CSSStyleSheet::item(unsigned index)
@@ -596,18 +199,18 @@ CSSRule* CSSStyleSheet::item(unsigned index)
RefPtr<CSSRule>& cssRule = m_childRuleCSSOMWrappers[index];
if (!cssRule) {
- if (index == 0 && m_internal->hasCharsetRule()) {
- ASSERT(!m_internal->ruleAt(0));
- cssRule = CSSCharsetRule::create(this, m_internal->encodingFromCharsetRule());
+ if (index == 0 && m_contents->hasCharsetRule()) {
+ ASSERT(!m_contents->ruleAt(0));
+ cssRule = CSSCharsetRule::create(this, m_contents->encodingFromCharsetRule());
} else
- cssRule = m_internal->ruleAt(index)->createCSSOMWrapper(this);
+ cssRule = m_contents->ruleAt(index)->createCSSOMWrapper(this);
}
return cssRule.get();
}
PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
{
- KURL url = m_internal->finalURL();
+ KURL url = m_contents->finalURL();
Document* document = ownerDocument();
if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
return 0;
@@ -625,15 +228,15 @@ PassRefPtr<CSSRuleList> CSSStyleSheet::rules()
unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec)
{
- ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_internal->ruleCount());
+ ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_contents->ruleCount());
ec = 0;
if (index > length()) {
ec = INDEX_SIZE_ERR;
return 0;
}
- CSSParser p(m_internal->parserContext());
- RefPtr<StyleRuleBase> rule = p.parseRule(m_internal.get(), ruleString);
+ CSSParser p(m_contents->parserContext());
+ RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString);
if (!rule) {
ec = SYNTAX_ERR;
@@ -641,7 +244,7 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
}
RuleMutationScope mutationScope(this);
- bool success = m_internal->wrapperInsertRule(rule, index);
+ bool success = m_contents->wrapperInsertRule(rule, index);
if (!success) {
ec = HIERARCHY_REQUEST_ERR;
return 0;
@@ -654,7 +257,7 @@ unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec)
{
- ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_internal->ruleCount());
+ ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_contents->ruleCount());
ec = 0;
if (index >= length()) {
@@ -663,7 +266,7 @@ void CSSStyleSheet::deleteRule(unsigned index, ExceptionCode& ec)
}
RuleMutationScope mutationScope(this);
- m_internal->wrapperDeleteRule(index);
+ m_contents->wrapperDeleteRule(index);
if (!m_childRuleCSSOMWrappers.isEmpty()) {
if (m_childRuleCSSOMWrappers[index])
@@ -688,7 +291,7 @@ int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio
PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules()
{
- KURL url = m_internal->finalURL();
+ KURL url = m_contents->finalURL();
Document* document = ownerDocument();
if (!url.isEmpty() && document && !document->securityOrigin()->canRequest(url))
return 0;
@@ -697,6 +300,21 @@ PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules()
return m_ruleListCSSOMWrapper.get();
}
+String CSSStyleSheet::href() const
+{
+ return m_contents->originalURL();
+}
+
+KURL CSSStyleSheet::baseURL() const
+{
+ return m_contents->baseURL();
+}
+
+bool CSSStyleSheet::isLoading() const
+{
+ return m_contents->isLoading();
+}
+
MediaList* CSSStyleSheet::media() const
{
if (!m_mediaQueries)
diff --git a/Source/WebCore/css/CSSStyleSheet.h b/Source/WebCore/css/CSSStyleSheet.h
index 425f675ba..5a839e0ee 100644
--- a/Source/WebCore/css/CSSStyleSheet.h
+++ b/Source/WebCore/css/CSSStyleSheet.h
@@ -37,153 +37,17 @@ class CSSRule;
class CSSRuleList;
class CSSStyleSheet;
class CachedCSSStyleSheet;
-class CachedResourceLoader;
class Document;
class MediaQuerySet;
class SecurityOrigin;
-class StyleRuleBase;
-class StyleRuleImport;
+class StyleSheetContents;
typedef int ExceptionCode;
-class StyleSheetInternal : public RefCounted<StyleSheetInternal> {
-public:
- static PassRefPtr<StyleSheetInternal> create(const CSSParserContext& context = CSSParserContext(CSSStrictMode))
- {
- return adoptRef(new StyleSheetInternal(0, String(), KURL(), context));
- }
- static PassRefPtr<StyleSheetInternal> create(const String& originalURL, const KURL& finalURL, const CSSParserContext& context)
- {
- return adoptRef(new StyleSheetInternal(0, originalURL, finalURL, context));
- }
- static PassRefPtr<StyleSheetInternal> create(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const CSSParserContext& context)
- {
- return adoptRef(new StyleSheetInternal(ownerRule, originalURL, finalURL, context));
- }
-
- ~StyleSheetInternal();
-
- const CSSParserContext& parserContext() const { return m_parserContext; }
-
- const AtomicString& determineNamespace(const AtomicString& prefix);
-
- void parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*);
- bool parseString(const String&);
- bool parseStringAtLine(const String&, int startLineNumber);
-
- bool isCacheable() const;
-
- bool isLoading() const;
-
- void checkLoaded();
- void startLoadingDynamicSheet();
-
- StyleSheetInternal* rootStyleSheet() const;
- Node* singleOwnerNode() const;
- Document* singleOwnerDocument() const;
-
- const String& charset() const { return m_parserContext.charset; }
-
- bool loadCompleted() const { return m_loadCompleted; }
-
- KURL completeURL(const String& url) const;
- void addSubresourceStyleURLs(ListHashSet<KURL>&);
-
- void setIsUserStyleSheet(bool b) { m_isUserStyleSheet = b; }
- bool isUserStyleSheet() const { return m_isUserStyleSheet; }
- void setHasSyntacticallyValidCSSHeader(bool b) { m_hasSyntacticallyValidCSSHeader = b; }
- bool hasSyntacticallyValidCSSHeader() const { return m_hasSyntacticallyValidCSSHeader; }
-
- void parserAddNamespace(const AtomicString& prefix, const AtomicString& uri);
- void parserAppendRule(PassRefPtr<StyleRuleBase>);
- void parserSetEncodingFromCharsetRule(const String& encoding);
- void parserSetUsesRemUnits(bool b) { m_usesRemUnits = b; }
-
- void clearRules();
-
- bool hasCharsetRule() const { return !m_encodingFromCharsetRule.isNull(); }
- String encodingFromCharsetRule() const { return m_encodingFromCharsetRule; }
- // Rules other than @charset and @import.
- const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRules; }
- const Vector<RefPtr<StyleRuleImport> >& importRules() const { return m_importRules; }
-
- void notifyLoadedSheet(const CachedCSSStyleSheet*);
-
- StyleSheetInternal* parentStyleSheet() const;
- StyleRuleImport* ownerRule() const { return m_ownerRule; }
- void clearOwnerRule() { m_ownerRule = 0; }
-
- // Note that href is the URL that started the redirect chain that led to
- // this style sheet. This property probably isn't useful for much except
- // the JavaScript binding (which needs to use this value for security).
- String originalURL() const { return m_originalURL; }
-
- const KURL& finalURL() const { return m_finalURL; }
- const KURL& baseURL() const { return m_parserContext.baseURL; }
-
- unsigned ruleCount() const;
- StyleRuleBase* ruleAt(unsigned index) const;
-
- bool usesRemUnits() const { return m_usesRemUnits; }
-
- unsigned estimatedSizeInBytes() const;
-
- bool wrapperInsertRule(PassRefPtr<StyleRuleBase>, unsigned index);
- void wrapperDeleteRule(unsigned index);
-
- PassRefPtr<StyleSheetInternal> copy() const { return adoptRef(new StyleSheetInternal(*this)); }
-
- void registerClient(CSSStyleSheet*);
- void unregisterClient(CSSStyleSheet*);
- bool hasOneClient() { return m_clients.size() == 1; }
-
- bool isMutable() const { return m_isMutable; }
- void setMutable() { m_isMutable = true; }
-
- bool isInMemoryCache() const { return m_isInMemoryCache; }
- void addedToMemoryCache();
- void removedFromMemoryCache();
-
-private:
- StyleSheetInternal(StyleRuleImport* ownerRule, const String& originalURL, const KURL& baseURL, const CSSParserContext&);
- StyleSheetInternal(const StyleSheetInternal&);
-
- void clearCharsetRule();
-
- StyleRuleImport* m_ownerRule;
-
- String m_originalURL;
- KURL m_finalURL;
-
- String m_encodingFromCharsetRule;
- Vector<RefPtr<StyleRuleImport> > m_importRules;
- Vector<RefPtr<StyleRuleBase> > m_childRules;
- typedef HashMap<AtomicString, AtomicString> PrefixNamespaceURIMap;
- PrefixNamespaceURIMap m_namespaces;
-
- bool m_loadCompleted : 1;
- bool m_isUserStyleSheet : 1;
- bool m_hasSyntacticallyValidCSSHeader : 1;
- bool m_didLoadErrorOccur : 1;
- bool m_usesRemUnits : 1;
- bool m_isMutable : 1;
- bool m_isInMemoryCache : 1;
-
- CSSParserContext m_parserContext;
-
- Vector<CSSStyleSheet*> m_clients;
-};
-
class CSSStyleSheet : public StyleSheet {
public:
- static RefPtr<CSSStyleSheet> create(PassRefPtr<StyleSheetInternal> sheet, CSSImportRule* ownerRule = 0)
- {
- return adoptRef(new CSSStyleSheet(sheet, ownerRule));
- }
- static RefPtr<CSSStyleSheet> create(PassRefPtr<StyleSheetInternal> sheet, Node* ownerNode)
- {
- return adoptRef(new CSSStyleSheet(sheet, ownerNode));
- }
+ static PassRefPtr<CSSStyleSheet> create(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule = 0);
+ static PassRefPtr<CSSStyleSheet> create(PassRefPtr<StyleSheetContents>, Node* ownerNode);
static PassRefPtr<CSSStyleSheet> createInline(Node*, const KURL&, const String& encoding = String());
virtual ~CSSStyleSheet();
@@ -191,7 +55,7 @@ public:
virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE;
virtual Node* ownerNode() const OVERRIDE { return m_ownerNode; }
virtual MediaList* media() const OVERRIDE;
- virtual String href() const OVERRIDE { return m_internal->originalURL(); }
+ virtual String href() const OVERRIDE;
virtual String title() const OVERRIDE { return m_title; }
virtual bool disabled() const OVERRIDE { return m_isDisabled; }
virtual void setDisabled(bool) OVERRIDE;
@@ -212,8 +76,8 @@ public:
virtual void clearOwnerNode() OVERRIDE { m_ownerNode = 0; }
virtual CSSImportRule* ownerRule() const OVERRIDE { return m_ownerRule; }
- virtual KURL baseURL() const OVERRIDE { return m_internal->baseURL(); }
- virtual bool isLoading() const OVERRIDE { return m_internal->isLoading(); }
+ virtual KURL baseURL() const OVERRIDE;
+ virtual bool isLoading() const OVERRIDE;
void clearOwnerRule() { m_ownerRule = 0; }
Document* ownerDocument() const;
@@ -239,16 +103,16 @@ public:
void clearChildRuleCSSOMWrappers();
void reattachChildRuleCSSOMWrappers();
- StyleSheetInternal* internal() const { return m_internal.get(); }
+ StyleSheetContents* contents() const { return m_contents.get(); }
private:
- CSSStyleSheet(PassRefPtr<StyleSheetInternal>, CSSImportRule* ownerRule);
- CSSStyleSheet(PassRefPtr<StyleSheetInternal>, Node* ownerNode);
+ CSSStyleSheet(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule);
+ CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode);
virtual bool isCSSStyleSheet() const { return true; }
virtual String type() const { return "text/css"; }
- RefPtr<StyleSheetInternal> m_internal;
+ RefPtr<StyleSheetContents> m_contents;
bool m_isDisabled;
String m_title;
RefPtr<MediaQuerySet> m_mediaQueries;
diff --git a/Source/WebCore/css/CSSValue.cpp b/Source/WebCore/css/CSSValue.cpp
index 018a26788..1151959e0 100644
--- a/Source/WebCore/css/CSSValue.cpp
+++ b/Source/WebCore/css/CSSValue.cpp
@@ -99,7 +99,7 @@ CSSValue::Type CSSValue::cssValueType() const
return CSS_CUSTOM;
}
-void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
+void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
{
// This should get called for internal instances only.
ASSERT(!isCSSOMSafe());
diff --git a/Source/WebCore/css/CSSValue.h b/Source/WebCore/css/CSSValue.h
index 8207c51ef..d5c023105 100644
--- a/Source/WebCore/css/CSSValue.h
+++ b/Source/WebCore/css/CSSValue.h
@@ -29,7 +29,7 @@
namespace WebCore {
-class StyleSheetInternal;
+class StyleSheetContents;
// FIXME: The current CSSValue and subclasses should be turned into internal types (StyleValue).
// The few subtypes that are actually exposed in CSSOM can be seen in the cloneForCSSOM() function.
@@ -107,7 +107,7 @@ public:
PassRefPtr<CSSValue> cloneForCSSOM() const;
- void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
+ void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
protected:
diff --git a/Source/WebCore/css/CSSValueKeywords.in b/Source/WebCore/css/CSSValueKeywords.in
index e9e2111b5..b626949e8 100644
--- a/Source/WebCore/css/CSSValueKeywords.in
+++ b/Source/WebCore/css/CSSValueKeywords.in
@@ -334,10 +334,8 @@ table-caption
-webkit-inline-box
-webkit-flex
-webkit-inline-flex
-#if defined(ENABLE_CSS_GRID_LAYOUT) && ENABLE_CSS_GRID_LAYOUT
-webkit-grid
-webkit-inline-grid
-#endif
//none
//
// CSS_PROP_CURSOR:
diff --git a/Source/WebCore/css/CSSValueList.cpp b/Source/WebCore/css/CSSValueList.cpp
index 63773919a..537f135da 100644
--- a/Source/WebCore/css/CSSValueList.cpp
+++ b/Source/WebCore/css/CSSValueList.cpp
@@ -136,7 +136,7 @@ String CSSValueList::customCssText() const
return result.toString();
}
-void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetInternal* styleSheet)
+void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet)
{
size_t size = m_values.size();
for (size_t i = 0; i < size; ++i)
diff --git a/Source/WebCore/css/CSSValueList.h b/Source/WebCore/css/CSSValueList.h
index 3d23a6048..a80152112 100644
--- a/Source/WebCore/css/CSSValueList.h
+++ b/Source/WebCore/css/CSSValueList.h
@@ -60,7 +60,7 @@ public:
String customCssText() const;
- void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
+ void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*);
PassRefPtr<CSSValueList> cloneForCSSOM() const;
diff --git a/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp b/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
index 33f21a10a..2ad4d207c 100644
--- a/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
+++ b/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
@@ -305,10 +305,10 @@ CSSValue* PropertySetCSSStyleDeclaration::cloneAndCacheForCSSOM(CSSValue* intern
return clonedValue.get();
}
-StyleSheetInternal* PropertySetCSSStyleDeclaration::contextStyleSheet() const
+StyleSheetContents* PropertySetCSSStyleDeclaration::contextStyleSheet() const
{
CSSStyleSheet* cssStyleSheet = parentStyleSheet();
- return cssStyleSheet ? cssStyleSheet->internal() : 0;
+ return cssStyleSheet ? cssStyleSheet->contents() : 0;
}
PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::copy() const
diff --git a/Source/WebCore/css/PropertySetCSSStyleDeclaration.h b/Source/WebCore/css/PropertySetCSSStyleDeclaration.h
index bf9694c2d..caf63bd48 100644
--- a/Source/WebCore/css/PropertySetCSSStyleDeclaration.h
+++ b/Source/WebCore/css/PropertySetCSSStyleDeclaration.h
@@ -34,7 +34,7 @@ class CSSRule;
class CSSProperty;
class CSSValue;
class StylePropertySet;
-class StyleSheetInternal;
+class StyleSheetContents;
class StyledElement;
class PropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
@@ -43,7 +43,7 @@ public:
virtual StyledElement* parentElement() const { return 0; }
virtual void clearParentElement() { ASSERT_NOT_REACHED(); }
- StyleSheetInternal* contextStyleSheet() const;
+ StyleSheetContents* contextStyleSheet() const;
virtual void ref() OVERRIDE;
virtual void deref() OVERRIDE;
diff --git a/Source/WebCore/css/StyleBuilder.cpp b/Source/WebCore/css/StyleBuilder.cpp
index 7f6884cf9..53d384c8b 100644
--- a/Source/WebCore/css/StyleBuilder.cpp
+++ b/Source/WebCore/css/StyleBuilder.cpp
@@ -1940,8 +1940,10 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyWebkitFlexOrder, ApplyPropertyDefault<int, &RenderStyle::flexOrder, int, &RenderStyle::setFlexOrder, int, &RenderStyle::initialFlexOrder>::createHandler());
setPropertyHandler(CSSPropertyWebkitFlexPack, ApplyPropertyDefault<EFlexPack, &RenderStyle::flexPack, EFlexPack, &RenderStyle::setFlexPack, EFlexPack, &RenderStyle::initialFlexPack>::createHandler());
setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault<EFlexWrap, &RenderStyle::flexWrap, EFlexWrap, &RenderStyle::setFlexWrap, EFlexWrap, &RenderStyle::initialFlexWrap>::createHandler());
+#if ENABLE(CSS_REGIONS)
setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString<MapNoneToNull, &RenderStyle::regionThread, &RenderStyle::setRegionThread, &RenderStyle::initialRegionThread>::createHandler());
setPropertyHandler(CSSPropertyWebkitFlowInto, ApplyPropertyString<MapNoneToNull, &RenderStyle::flowThread, &RenderStyle::setFlowThread, &RenderStyle::initialFlowThread>::createHandler());
+#endif
setPropertyHandler(CSSPropertyWebkitFontKerning, ApplyPropertyFont<FontDescription::Kerning, &FontDescription::kerning, &FontDescription::setKerning, FontDescription::AutoKerning>::createHandler());
setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont<FontSmoothingMode, &FontDescription::fontSmoothing, &FontDescription::setFontSmoothing, AutoSmoothing>::createHandler());
setPropertyHandler(CSSPropertyWebkitFontVariantLigatures, ApplyPropertyFontVariantLigatures::createHandler());
@@ -1986,10 +1988,12 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyWebkitPerspectiveOriginX, ApplyPropertyLength<&RenderStyle::perspectiveOriginX, &RenderStyle::setPerspectiveOriginX, &RenderStyle::initialPerspectiveOriginX>::createHandler());
setPropertyHandler(CSSPropertyWebkitPerspectiveOriginY, ApplyPropertyLength<&RenderStyle::perspectiveOriginY, &RenderStyle::setPerspectiveOriginY, &RenderStyle::initialPerspectiveOriginY>::createHandler());
setPropertyHandler(CSSPropertyWebkitPrintColorAdjust, ApplyPropertyDefault<PrintColorAdjust, &RenderStyle::printColorAdjust, PrintColorAdjust, &RenderStyle::setPrintColorAdjust, PrintColorAdjust, &RenderStyle::initialPrintColorAdjust>::createHandler());
+#if ENABLE(CSS_REGIONS)
setPropertyHandler(CSSPropertyWebkitRegionBreakAfter, ApplyPropertyDefault<EPageBreak, &RenderStyle::regionBreakAfter, EPageBreak, &RenderStyle::setRegionBreakAfter, EPageBreak, &RenderStyle::initialPageBreak>::createHandler());
setPropertyHandler(CSSPropertyWebkitRegionBreakBefore, ApplyPropertyDefault<EPageBreak, &RenderStyle::regionBreakBefore, EPageBreak, &RenderStyle::setRegionBreakBefore, EPageBreak, &RenderStyle::initialPageBreak>::createHandler());
setPropertyHandler(CSSPropertyWebkitRegionBreakInside, ApplyPropertyDefault<EPageBreak, &RenderStyle::regionBreakInside, EPageBreak, &RenderStyle::setRegionBreakInside, EPageBreak, &RenderStyle::initialPageBreak>::createHandler());
setPropertyHandler(CSSPropertyWebkitRegionOverflow, ApplyPropertyDefault<RegionOverflow, &RenderStyle::regionOverflow, RegionOverflow, &RenderStyle::setRegionOverflow, RegionOverflow, &RenderStyle::initialRegionOverflow>::createHandler());
+#endif
setPropertyHandler(CSSPropertyWebkitRtlOrdering, ApplyPropertyDefault<Order, &RenderStyle::rtlOrdering, Order, &RenderStyle::setRTLOrdering, Order, &RenderStyle::initialRTLOrdering>::createHandler());
setPropertyHandler(CSSPropertyWebkitTextCombine, ApplyPropertyDefault<TextCombine, &RenderStyle::textCombine, TextCombine, &RenderStyle::setTextCombine, TextCombine, &RenderStyle::initialTextCombine>::createHandler());
setPropertyHandler(CSSPropertyWebkitTextEmphasisColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textEmphasisColor, &RenderStyle::setTextEmphasisColor, &RenderStyle::setVisitedLinkTextEmphasisColor, &RenderStyle::color>::createHandler());
@@ -2011,11 +2015,13 @@ StyleBuilder::StyleBuilder()
setPropertyHandler(CSSPropertyWebkitUserDrag, ApplyPropertyDefault<EUserDrag, &RenderStyle::userDrag, EUserDrag, &RenderStyle::setUserDrag, EUserDrag, &RenderStyle::initialUserDrag>::createHandler());
setPropertyHandler(CSSPropertyWebkitUserModify, ApplyPropertyDefault<EUserModify, &RenderStyle::userModify, EUserModify, &RenderStyle::setUserModify, EUserModify, &RenderStyle::initialUserModify>::createHandler());
setPropertyHandler(CSSPropertyWebkitUserSelect, ApplyPropertyDefault<EUserSelect, &RenderStyle::userSelect, EUserSelect, &RenderStyle::setUserSelect, EUserSelect, &RenderStyle::initialUserSelect>::createHandler());
+#if ENABLE(CSS_EXCLUSIONS)
setPropertyHandler(CSSPropertyWebkitWrap, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitWrapFlow, CSSPropertyWebkitWrapMargin, CSSPropertyWebkitWrapPadding>::createHandler());
setPropertyHandler(CSSPropertyWebkitWrapFlow, ApplyPropertyDefault<WrapFlow, &RenderStyle::wrapFlow, WrapFlow, &RenderStyle::setWrapFlow, WrapFlow, &RenderStyle::initialWrapFlow>::createHandler());
setPropertyHandler(CSSPropertyWebkitWrapMargin, ApplyPropertyLength<&RenderStyle::wrapMargin, &RenderStyle::setWrapMargin, &RenderStyle::initialWrapMargin>::createHandler());
setPropertyHandler(CSSPropertyWebkitWrapPadding, ApplyPropertyLength<&RenderStyle::wrapPadding, &RenderStyle::setWrapPadding, &RenderStyle::initialWrapPadding>::createHandler());
setPropertyHandler(CSSPropertyWebkitWrapThrough, ApplyPropertyDefault<WrapThrough, &RenderStyle::wrapThrough, WrapThrough, &RenderStyle::setWrapThrough, WrapThrough, &RenderStyle::initialWrapThrough>::createHandler());
+#endif
setPropertyHandler(CSSPropertyWhiteSpace, ApplyPropertyDefault<EWhiteSpace, &RenderStyle::whiteSpace, EWhiteSpace, &RenderStyle::setWhiteSpace, EWhiteSpace, &RenderStyle::initialWhiteSpace>::createHandler());
setPropertyHandler(CSSPropertyWidows, ApplyPropertyDefault<short, &RenderStyle::widows, short, &RenderStyle::setWidows, short, &RenderStyle::initialWidows>::createHandler());
setPropertyHandler(CSSPropertyWidth, ApplyPropertyLength<&RenderStyle::width, &RenderStyle::setWidth, &RenderStyle::initialSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneDisabled, UndefinedDisabled>::createHandler());
diff --git a/Source/WebCore/css/StylePropertySet.cpp b/Source/WebCore/css/StylePropertySet.cpp
index ac7eacd8c..2cc488701 100644
--- a/Source/WebCore/css/StylePropertySet.cpp
+++ b/Source/WebCore/css/StylePropertySet.cpp
@@ -23,14 +23,14 @@
#include "StylePropertySet.h"
#include "CSSParser.h"
-#include "CSSStyleSheet.h"
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "CSSValuePool.h"
#include "Document.h"
#include "PropertySetCSSStyleDeclaration.h"
#include "StylePropertyShorthand.h"
-#include <wtf/BitVector.h>
+#include "StyleSheetContents.h"
+#include <wtf/BitArray.h>
#include <wtf/text/StringBuilder.h>
#ifndef NDEBUG
@@ -56,36 +56,14 @@ StylePropertySet::StylePropertySet(CSSParserMode cssParserMode)
{
}
-StylePropertySet::StylePropertySet(const Vector<CSSProperty>& properties)
- : m_properties(properties)
- , m_cssParserMode(CSSStrictMode)
- , m_ownsCSSOMWrapper(false)
-{
- m_properties.shrinkToFit();
-}
-
-StylePropertySet::StylePropertySet(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)
+StylePropertySet::StylePropertySet(StylePropertyVector& properties, CSSParserMode cssParserMode)
: m_cssParserMode(cssParserMode)
, m_ownsCSSOMWrapper(false)
{
- // FIXME: This logic belongs in CSSParser.
-
- m_properties.reserveInitialCapacity(numProperties);
- HashMap<int, bool> candidates;
- for (int i = 0; i < numProperties; ++i) {
- const CSSProperty& property = properties[i];
- bool important = property.isImportant();
-
- HashMap<int, bool>::iterator it = candidates.find(property.id());
- if (it != candidates.end()) {
- if (!important && it->second)
- continue;
- removeProperty(property.id());
- }
+ m_properties.swap(properties);
- m_properties.append(property);
- candidates.set(property.id(), important);
- }
+ // This shrinkToFit() will be a no-op in the typical case (no duplicate properties were eliminated after parsing.)
+ m_properties.shrinkToFit();
}
StylePropertySet::StylePropertySet(const StylePropertySet& o)
@@ -166,8 +144,10 @@ String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const
return getLayeredShorthandValue(webkitTransitionShorthand());
case CSSPropertyWebkitAnimation:
return getLayeredShorthandValue(webkitAnimationShorthand());
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrap:
return getShorthandValue(webkitWrapShorthand());
+#endif
#if ENABLE(SVG)
case CSSPropertyMarker: {
RefPtr<CSSValue> value = getPropertyCSSValue(CSSPropertyMarkerStart);
@@ -532,7 +512,7 @@ bool StylePropertySet::isPropertyImplicit(CSSPropertyID propertyID) const
return property ? property->isImplicit() : false;
}
-bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetInternal* contextStyleSheet)
+bool StylePropertySet::setProperty(CSSPropertyID propertyID, const String& value, bool important, StyleSheetContents* contextStyleSheet)
{
// Setting the value to an empty string just removes the property in both IE and Gecko.
// Setting it to null seems to produce less consistent results, but we treat it just the same.
@@ -579,7 +559,7 @@ bool StylePropertySet::setProperty(CSSPropertyID propertyID, int identifier, boo
return true;
}
-void StylePropertySet::parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet)
+void StylePropertySet::parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet)
{
m_properties.clear();
@@ -592,10 +572,10 @@ void StylePropertySet::parseDeclaration(const String& styleDeclaration, StyleShe
parser.parseDeclaration(this, styleDeclaration, 0, contextStyleSheet);
}
-void StylePropertySet::addParsedProperties(const CSSProperty* properties, int numProperties)
+void StylePropertySet::addParsedProperties(const Vector<CSSProperty>& properties)
{
- m_properties.reserveCapacity(numProperties);
- for (int i = 0; i < numProperties; ++i)
+ m_properties.reserveCapacity(m_properties.size() + properties.size());
+ for (unsigned i = 0; i < properties.size(); ++i)
addParsedProperty(properties[i]);
}
@@ -615,9 +595,8 @@ String StylePropertySet::asText() const
const CSSProperty* repeatXProp = 0;
const CSSProperty* repeatYProp = 0;
- // FIXME: Stack-allocate the buffer for these BitVectors.
- BitVector shorthandPropertyUsed;
- BitVector shorthandPropertyAppeared;
+ BitArray<numCSSProperties> shorthandPropertyUsed;
+ BitArray<numCSSProperties> shorthandPropertyAppeared;
unsigned size = m_properties.size();
for (unsigned n = 0; n < size; ++n) {
@@ -663,7 +642,7 @@ String StylePropertySet::asText() const
if (!shorthandPropertyAppeared.get(CSSPropertyBorder - firstCSSProperty)) {
value = borderPropertyValue(ReturnNullOnUncommonValues);
if (value.isNull())
- shorthandPropertyAppeared.ensureSizeAndSet(CSSPropertyBorder - firstCSSProperty, numCSSProperties);
+ shorthandPropertyAppeared.set(CSSPropertyBorder - firstCSSProperty);
else
shorthandPropertyID = CSSPropertyBorder;
} else if (shorthandPropertyUsed.get(CSSPropertyBorder - firstCSSProperty))
@@ -745,11 +724,13 @@ String StylePropertySet::asText() const
case CSSPropertyWebkitTransitionDelay:
shorthandPropertyID = CSSPropertyWebkitTransition;
break;
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrapFlow:
case CSSPropertyWebkitWrapMargin:
case CSSPropertyWebkitWrapPadding:
shorthandPropertyID = CSSPropertyWebkitWrap;
break;
+#endif
default:
break;
}
@@ -760,12 +741,12 @@ String StylePropertySet::asText() const
continue;
if (!shorthandPropertyAppeared.get(shortPropertyIndex) && value.isNull())
value = getPropertyValue(shorthandPropertyID);
- shorthandPropertyAppeared.ensureSizeAndSet(shortPropertyIndex, numCSSProperties);
+ shorthandPropertyAppeared.set(shortPropertyIndex);
}
if (!value.isNull()) {
propertyID = shorthandPropertyID;
- shorthandPropertyUsed.ensureSizeAndSet(shortPropertyIndex, numCSSProperties);
+ shorthandPropertyUsed.set(shortPropertyIndex);
} else
value = prop.value()->cssText();
@@ -840,7 +821,7 @@ void StylePropertySet::merge(const StylePropertySet* other, bool argOverridesOnC
}
}
-void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleSheetInternal* contextStyleSheet)
+void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleSheetContents* contextStyleSheet)
{
size_t size = m_properties.size();
for (size_t i = 0; i < size; ++i)
@@ -865,9 +846,11 @@ static const CSSPropertyID blockProperties[] = {
CSSPropertyPageBreakAfter,
CSSPropertyPageBreakBefore,
CSSPropertyPageBreakInside,
+#if ENABLE(CSS_REGIONS)
CSSPropertyWebkitRegionBreakAfter,
CSSPropertyWebkitRegionBreakBefore,
CSSPropertyWebkitRegionBreakInside,
+#endif
CSSPropertyTextAlign,
CSSPropertyTextIndent,
CSSPropertyWidows
@@ -895,7 +878,7 @@ bool StylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned
for (unsigned i = 0; i < length; ++i)
toRemove.add(set[i]);
- Vector<CSSProperty, 4> newProperties;
+ StylePropertyVector newProperties;
newProperties.reserveInitialCapacity(m_properties.size());
unsigned size = m_properties.size();
@@ -973,14 +956,14 @@ PassRefPtr<StylePropertySet> StylePropertySet::copy() const
PassRefPtr<StylePropertySet> StylePropertySet::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
{
- Vector<CSSProperty> list;
+ StylePropertyVector list;
list.reserveInitialCapacity(length);
for (unsigned i = 0; i < length; ++i) {
RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
if (value)
list.append(CSSProperty(set[i], value.release(), false));
}
- return StylePropertySet::create(list);
+ return StylePropertySet::adopt(list);
}
CSSStyleDeclaration* StylePropertySet::ensureCSSStyleDeclaration() const
@@ -1024,7 +1007,7 @@ unsigned StylePropertySet::averageSizeInBytes()
// See the function above if you need to update this.
class SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet> {
- Vector<CSSProperty, 4> properties;
+ StylePropertyVector properties;
unsigned bitfield;
};
COMPILE_ASSERT(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), style_property_set_should_stay_small);
diff --git a/Source/WebCore/css/StylePropertySet.h b/Source/WebCore/css/StylePropertySet.h
index d500398d0..e14f89c3f 100644
--- a/Source/WebCore/css/StylePropertySet.h
+++ b/Source/WebCore/css/StylePropertySet.h
@@ -37,7 +37,9 @@ class KURL;
class PropertySetCSSStyleDeclaration;
class StyledElement;
class StylePropertyShorthand;
-class StyleSheetInternal;
+class StyleSheetContents;
+
+typedef Vector<CSSProperty, 4> StylePropertyVector;
class StylePropertySet : public RefCounted<StylePropertySet> {
public:
@@ -47,13 +49,9 @@ public:
{
return adoptRef(new StylePropertySet(cssParserMode));
}
- static PassRefPtr<StylePropertySet> create(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)
- {
- return adoptRef(new StylePropertySet(properties, numProperties, cssParserMode));
- }
- static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties)
+ static PassRefPtr<StylePropertySet> adopt(StylePropertyVector& properties, CSSParserMode cssParserMode = CSSStrictMode)
{
- return adoptRef(new StylePropertySet(properties));
+ return adoptRef(new StylePropertySet(properties, cssParserMode));
}
unsigned propertyCount() const { return m_properties.size(); }
@@ -69,7 +67,7 @@ public:
bool isPropertyImplicit(CSSPropertyID) const;
// These expand shorthand properties into multiple properties.
- bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetInternal* contextStyleSheet = 0);
+ bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);
// These do not. FIXME: This is too messy, we can do better.
@@ -78,9 +76,9 @@ public:
bool removeProperty(CSSPropertyID, String* returnText = 0);
- void parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet);
+ void parseDeclaration(const String& styleDeclaration, StyleSheetContents* contextStyleSheet);
- void addParsedProperties(const CSSProperty*, int numProperties);
+ void addParsedProperties(const Vector<CSSProperty>&);
void addParsedProperty(const CSSProperty&);
PassRefPtr<StylePropertySet> copyBlockProperties() const;
@@ -92,7 +90,7 @@ public:
void setCSSParserMode(CSSParserMode cssParserMode) { m_cssParserMode = cssParserMode; }
CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
- void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetInternal* contextStyleSheet);
+ void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetContents* contextStyleSheet);
PassRefPtr<StylePropertySet> copy() const;
// Used by StyledElement::copyNonAttributeProperties().
@@ -121,9 +119,8 @@ public:
private:
StylePropertySet(CSSParserMode);
- StylePropertySet(const Vector<CSSProperty>&);
+ StylePropertySet(StylePropertyVector&, CSSParserMode);
StylePropertySet(const StylePropertySet&);
- StylePropertySet(const CSSProperty*, int numProperties, CSSParserMode);
void setNeedsStyleRecalc();
@@ -143,7 +140,7 @@ private:
const CSSProperty* findPropertyWithId(CSSPropertyID) const;
CSSProperty* findPropertyWithId(CSSPropertyID);
- Vector<CSSProperty, 4> m_properties;
+ StylePropertyVector m_properties;
unsigned m_cssParserMode : 2;
mutable unsigned m_ownsCSSOMWrapper : 1;
diff --git a/Source/WebCore/css/StylePropertyShorthand.cpp b/Source/WebCore/css/StylePropertyShorthand.cpp
index 6bd0780d4..9c4cd370d 100644
--- a/Source/WebCore/css/StylePropertyShorthand.cpp
+++ b/Source/WebCore/css/StylePropertyShorthand.cpp
@@ -28,16 +28,16 @@ namespace WebCore {
const StylePropertyShorthand& backgroundShorthand()
{
static const CSSPropertyID backgroundProperties[] = {
- CSSPropertyBackgroundColor,
CSSPropertyBackgroundImage,
+ CSSPropertyBackgroundPositionX,
+ CSSPropertyBackgroundPositionY,
+ CSSPropertyBackgroundSize,
CSSPropertyBackgroundRepeatX,
CSSPropertyBackgroundRepeatY,
CSSPropertyBackgroundAttachment,
- CSSPropertyBackgroundClip,
CSSPropertyBackgroundOrigin,
- CSSPropertyBackgroundPositionX,
- CSSPropertyBackgroundPositionY,
- CSSPropertyBackgroundSize
+ CSSPropertyBackgroundClip,
+ CSSPropertyBackgroundColor
};
DEFINE_STATIC_LOCAL(StylePropertyShorthand, backgroundShorthand, (backgroundProperties, WTF_ARRAY_LENGTH(backgroundProperties)));
return backgroundShorthand;
@@ -404,6 +404,7 @@ const StylePropertyShorthand& webkitTransformOriginShorthand()
return webkitTransformOriginLonghands;
}
+#if ENABLE(CSS_EXCLUSIONS)
const StylePropertyShorthand& webkitWrapShorthand()
{
static const CSSPropertyID webkitWrapProperties[] = {
@@ -414,6 +415,7 @@ const StylePropertyShorthand& webkitWrapShorthand()
DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitWrapLonghands, (webkitWrapProperties, WTF_ARRAY_LENGTH(webkitWrapProperties)));
return webkitWrapLonghands;
}
+#endif
// Returns an empty list if the property is not a shorthand
const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID)
@@ -495,8 +497,10 @@ const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID)
return webkitTransitionShorthand();
case CSSPropertyWebkitTransformOrigin:
return webkitTransformOriginShorthand();
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrap:
return webkitWrapShorthand();
+#endif
default: {
DEFINE_STATIC_LOCAL(StylePropertyShorthand, emptyShorthand, ());
return emptyShorthand;
diff --git a/Source/WebCore/css/StylePropertyShorthand.h b/Source/WebCore/css/StylePropertyShorthand.h
index 175e3e1e5..d97a9a68a 100644
--- a/Source/WebCore/css/StylePropertyShorthand.h
+++ b/Source/WebCore/css/StylePropertyShorthand.h
@@ -96,7 +96,9 @@ const StylePropertyShorthand& webkitTextEmphasisShorthand();
const StylePropertyShorthand& webkitTextStrokeShorthand();
const StylePropertyShorthand& webkitTransitionShorthand();
const StylePropertyShorthand& webkitTransformOriginShorthand();
+#if ENABLE(CSS_EXCLUSIONS)
const StylePropertyShorthand& webkitWrapShorthand();
+#endif
// Returns an empty list if the property is not a shorthand
const StylePropertyShorthand& shorthandForProperty(CSSPropertyID);
diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp
index 1d946912a..07290a64e 100644
--- a/Source/WebCore/css/StyleResolver.cpp
+++ b/Source/WebCore/css/StyleResolver.cpp
@@ -52,6 +52,7 @@
#include "CachedImage.h"
#include "CalculationValue.h"
#include "ContentData.h"
+#include "ContextEnabledFeatures.h"
#include "Counter.h"
#include "CounterContent.h"
#include "CursorList.h"
@@ -89,7 +90,6 @@
#include "RenderStyleConstants.h"
#include "RenderTheme.h"
#include "RotateTransformOperation.h"
-#include "RuntimeEnabledFeatures.h"
#include "SVGDocumentExtensions.h"
#include "SVGFontFaceElement.h"
#include "ScaleTransformOperation.h"
@@ -104,6 +104,8 @@
#include "StyleGeneratedImage.h"
#include "StylePendingImage.h"
#include "StyleRule.h"
+#include "StyleRuleImport.h"
+#include "StyleSheetContents.h"
#include "StyleSheetList.h"
#include "Text.h"
#include "TransformationMatrix.h"
@@ -148,7 +150,7 @@
#include "StyleCachedImageSet.h"
#endif
-#if PLATFORM(QT) || PLATFORM(BLACKBERRY)
+#if PLATFORM(BLACKBERRY)
#define FIXED_POSITION_CREATES_STACKING_CONTEXT 1
#endif
@@ -239,7 +241,7 @@ public:
typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<RuleData> > > AtomRuleMap;
- void addRulesFromSheet(StyleSheetInternal*, const MediaQueryEvaluator&, StyleResolver* = 0, const ContainerNode* = 0);
+ void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, StyleResolver* = 0, const ContainerNode* = 0);
void addStyleRule(StyleRule*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false);
void addRule(StyleRule*, CSSSelector*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false);
@@ -289,13 +291,13 @@ static RuleSet* defaultStyle;
static RuleSet* defaultQuirksStyle;
static RuleSet* defaultPrintStyle;
static RuleSet* defaultViewSourceStyle;
-static StyleSheetInternal* simpleDefaultStyleSheet;
-static StyleSheetInternal* defaultStyleSheet;
-static StyleSheetInternal* quirksStyleSheet;
-static StyleSheetInternal* svgStyleSheet;
-static StyleSheetInternal* mathMLStyleSheet;
-static StyleSheetInternal* mediaControlsStyleSheet;
-static StyleSheetInternal* fullscreenStyleSheet;
+static StyleSheetContents* simpleDefaultStyleSheet;
+static StyleSheetContents* defaultStyleSheet;
+static StyleSheetContents* quirksStyleSheet;
+static StyleSheetContents* svgStyleSheet;
+static StyleSheetContents* mathMLStyleSheet;
+static StyleSheetContents* mediaControlsStyleSheet;
+static StyleSheetContents* fullscreenStyleSheet;
RenderStyle* StyleResolver::s_styleNotYetAvailable;
@@ -403,7 +405,7 @@ StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles)
// FIXME: This sucks! The user sheet is reparsed every time!
OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
if (CSSStyleSheet* pageUserSheet = document->pageUserSheet())
- tempUserStyle->addRulesFromSheet(pageUserSheet->internal(), *m_medium, this);
+ tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), *m_medium, this);
addAuthorRulesAndCollectUserRulesFromSheets(document->pageGroupUserSheets(), *tempUserStyle);
addAuthorRulesAndCollectUserRulesFromSheets(document->documentUserSheets(), *tempUserStyle);
if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0)
@@ -444,7 +446,7 @@ void StyleResolver::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<Ref
unsigned length = userSheets->size();
for (unsigned i = 0; i < length; i++) {
- StyleSheetInternal* sheet = userSheets->at(i)->internal();
+ StyleSheetContents* sheet = userSheets->at(i)->contents();
if (sheet->isUserStyleSheet())
userStyle.addRulesFromSheet(sheet, *m_medium, this);
else
@@ -488,7 +490,7 @@ const ContainerNode* StyleResolver::determineScope(const CSSStyleSheet* sheet)
{
ASSERT(sheet);
- if (!RuntimeEnabledFeatures::styleScopedEnabled())
+ if (!ContextEnabledFeatures::styleScopedEnabled(document()))
return 0;
Node* ownerNode = sheet->ownerNode();
@@ -528,7 +530,7 @@ void StyleResolver::appendAuthorStylesheets(unsigned firstNew, const Vector<RefP
continue;
if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), this))
continue;
- StyleSheetInternal* sheet = cssSheet->internal();
+ StyleSheetContents* sheet = cssSheet->contents();
#if ENABLE(STYLE_SCOPED)
const ContainerNode* scope = determineScope(cssSheet);
if (scope) {
@@ -705,14 +707,14 @@ void StyleResolver::Features::clear()
usesLinkRules = false;
}
-static StyleSheetInternal* parseUASheet(const String& str)
+static StyleSheetContents* parseUASheet(const String& str)
{
- StyleSheetInternal* sheet = StyleSheetInternal::create().leakRef(); // leak the sheet on purpose
+ StyleSheetContents* sheet = StyleSheetContents::create().leakRef(); // leak the sheet on purpose
sheet->parseString(str);
return sheet;
}
-static StyleSheetInternal* parseUASheet(const char* characters, unsigned size)
+static StyleSheetContents* parseUASheet(const char* characters, unsigned size)
{
return parseUASheet(String(characters, size));
}
@@ -1913,9 +1915,7 @@ static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s
case TABLE:
case BOX:
case FLEX:
-#if ENABLE(CSS_GRID_LAYOUT)
case GRID:
-#endif
return display;
case LIST_ITEM:
@@ -1929,10 +1929,8 @@ static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s
return BOX;
case INLINE_FLEX:
return FLEX;
-#if ENABLE(CSS_GRID_LAYOUT)
case INLINE_GRID:
return GRID;
-#endif
case INLINE:
case RUN_IN:
@@ -2051,6 +2049,8 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
|| style->hasTransformRelatedProperty() || style->hasMask() || style->boxReflect() || style->hasFilter()
#ifdef FIXED_POSITION_CREATES_STACKING_CONTEXT
|| style->position() == FixedPosition
+#else
+ || (style->position() == FixedPosition && e && e->document()->page()->settings()->fixedPositionCreatesStackingContext())
#endif
#if ENABLE(OVERFLOW_SCROLLING)
// Touch overflow scrolling creates a stacking context.
@@ -2130,6 +2130,10 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
|| style->hasFilter()))
style->setTransformStyle3D(TransformStyle3DFlat);
+ // Seamless iframes behave like blocks. Map their display to inline-block when marked inline.
+ if (e && e->hasTagName(iframeTag) && style->display() == INLINE && static_cast<HTMLIFrameElement*>(e)->shouldDisplaySeamlessly())
+ style->setDisplay(INLINE_BLOCK);
+
#if ENABLE(SVG)
if (e && e->isSVGElement()) {
// Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
@@ -2289,7 +2293,7 @@ bool StyleResolver::checkRegionSelector(CSSSelector* regionSelector, Element* re
return false;
}
-bool StyleResolver::determineStylesheetSelectorScopes(StyleSheetInternal* stylesheet, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes)
+bool StyleResolver::determineStylesheetSelectorScopes(StyleSheetContents* stylesheet, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes)
{
ASSERT(!stylesheet->isLoading());
@@ -2515,7 +2519,7 @@ void RuleSet::addRegionRule(StyleRuleRegion* regionRule, bool hasDocumentSecurit
m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selectorList().first(), regionRuleSet.release()));
}
-void RuleSet::addRulesFromSheet(StyleSheetInternal* sheet, const MediaQueryEvaluator& medium, StyleResolver* styleSelector, const ContainerNode* scope)
+void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvaluator& medium, StyleResolver* styleSelector, const ContainerNode* scope)
{
ASSERT(sheet);
@@ -2578,12 +2582,15 @@ void RuleSet::addRulesFromSheet(StyleSheetInternal* sheet, const MediaQueryEvalu
if (scope)
continue;
styleSelector->addKeyframeStyle(static_cast<StyleRuleKeyframes*>(rule));
- } else if (rule->isRegionRule() && styleSelector) {
+ }
+#if ENABLE(CSS_REGIONS)
+ else if (rule->isRegionRule() && styleSelector) {
// FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style sheets for the moment.
if (scope)
continue;
addRegionRule(static_cast<StyleRuleRegion*>(rule), hasDocumentSecurityOrigin);
}
+#endif
}
if (m_autoShrinkToFitEnabled)
shrinkToFit();
@@ -2942,8 +2949,10 @@ static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra
collectCSSOMWrappers(wrapperMap, static_cast<CSSImportRule*>(cssRule)->styleSheet());
else if (cssRule->isMediaRule())
collectCSSOMWrappers(wrapperMap, static_cast<CSSMediaRule*>(cssRule));
+#if ENABLE(CSS_REGIONS)
else if (cssRule->isRegionRule())
collectCSSOMWrappers(wrapperMap, static_cast<WebKitCSSRegionRule*>(cssRule));
+#endif
else if (cssRule->isStyleRule()) {
CSSStyleRule* cssStyleRule = static_cast<CSSStyleRule*>(cssRule);
wrapperMap.add(cssStyleRule->styleRule(), cssStyleRule);
@@ -2951,7 +2960,7 @@ static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wra
}
}
-static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, HashSet<RefPtr<CSSStyleSheet> >& sheetWrapperSet, StyleSheetInternal* styleSheet)
+static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, HashSet<RefPtr<CSSStyleSheet> >& sheetWrapperSet, StyleSheetContents* styleSheet)
{
if (!styleSheet)
return;
@@ -3042,6 +3051,7 @@ inline bool StyleResolver::isValidRegionStyleProperty(CSSPropertyID id)
{
switch (id) {
case CSSPropertyBackgroundColor:
+ case CSSPropertyColor:
return true;
default:
break;
@@ -3063,8 +3073,6 @@ bool StyleResolver::useSVGZoomRules()
return m_element && m_element->isSVGElement();
}
-#if ENABLE(CSS_GRID_LAYOUT)
-
static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, Length& length)
{
Length workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
@@ -3123,7 +3131,6 @@ static bool createGridPosition(CSSValue* value, Length& position)
position.setValue(primitiveValue->getIntValue());
return true;
}
-#endif
void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value)
{
@@ -3856,7 +3863,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value)
m_style->setLineBoxContain(lineBoxContainValue->value());
return;
}
-
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitShapeInside:
HANDLE_INHERIT_AND_INITIAL(wrapShapeInside, WrapShapeInside);
if (!primitiveValue)
@@ -3876,7 +3883,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value)
else if (primitiveValue->isShape())
m_style->setWrapShapeOutside(primitiveValue->getShapeValue());
return;
-
+#endif
// CSS Fonts Module Level 3
case CSSPropertyWebkitFontFeatureSettings: {
if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) {
@@ -3912,7 +3919,6 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value)
return;
}
#endif
-#if ENABLE(CSS_GRID_LAYOUT)
case CSSPropertyWebkitGridColumns: {
Vector<Length> lengths;
if (!createGridTrackList(value, lengths, this))
@@ -3942,7 +3948,6 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value)
m_style->setGridItemRow(row);
return;
}
-#endif
// These properties are implemented in the StyleBuilder lookup table.
case CSSPropertyBackgroundAttachment:
@@ -4109,8 +4114,10 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value)
case CSSPropertyWebkitFlexOrder:
case CSSPropertyWebkitFlexPack:
case CSSPropertyWebkitFlexWrap:
+#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitFlowFrom:
case CSSPropertyWebkitFlowInto:
+#endif
case CSSPropertyWebkitFontKerning:
case CSSPropertyWebkitFontSmoothing:
case CSSPropertyWebkitFontVariantLigatures:
@@ -4150,10 +4157,12 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value)
case CSSPropertyWebkitPerspectiveOriginX:
case CSSPropertyWebkitPerspectiveOriginY:
case CSSPropertyWebkitPrintColorAdjust:
+#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitRegionBreakAfter:
case CSSPropertyWebkitRegionBreakBefore:
case CSSPropertyWebkitRegionBreakInside:
case CSSPropertyWebkitRegionOverflow:
+#endif
case CSSPropertyWebkitRtlOrdering:
case CSSPropertyWebkitTextCombine:
case CSSPropertyWebkitTextEmphasisColor:
@@ -4175,11 +4184,13 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue *value)
case CSSPropertyWebkitUserDrag:
case CSSPropertyWebkitUserModify:
case CSSPropertyWebkitUserSelect:
+#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitWrap:
case CSSPropertyWebkitWrapFlow:
case CSSPropertyWebkitWrapMargin:
case CSSPropertyWebkitWrapPadding:
case CSSPropertyWebkitWrapThrough:
+#endif
case CSSPropertyWhiteSpace:
case CSSPropertyWidows:
case CSSPropertyWidth:
diff --git a/Source/WebCore/css/StyleResolver.h b/Source/WebCore/css/StyleResolver.h
index 377add29b..f382d5f8a 100644
--- a/Source/WebCore/css/StyleResolver.h
+++ b/Source/WebCore/css/StyleResolver.h
@@ -80,7 +80,7 @@ class StyleRulePage;
class StyleRuleRegion;
class StyleShader;
class StyleSheet;
-class StyleSheetInternal;
+class StyleSheetContents;
class StyleSheetList;
class StyledElement;
class WebKitCSSFilterValue;
@@ -158,7 +158,7 @@ public:
void appendAuthorStylesheets(unsigned firstNew, const Vector<RefPtr<StyleSheet> >&);
// Find the ids or classes the selectors on a stylesheet are scoped to. The selectors only apply to elements in subtrees where the root element matches the scope.
- static bool determineStylesheetSelectorScopes(StyleSheetInternal*, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes);
+ static bool determineStylesheetSelectorScopes(StyleSheetContents*, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes);
private:
void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
@@ -510,7 +510,7 @@ private:
#endif
#if ENABLE(STYLE_SCOPED)
- static const ContainerNode* determineScope(const CSSStyleSheet*);
+ const ContainerNode* determineScope(const CSSStyleSheet*);
typedef HashMap<const ContainerNode*, OwnPtr<RuleSet> > ScopedRuleSetMap;
diff --git a/Source/WebCore/css/StyleRule.cpp b/Source/WebCore/css/StyleRule.cpp
index 83b2a6153..400f41b23 100644
--- a/Source/WebCore/css/StyleRule.cpp
+++ b/Source/WebCore/css/StyleRule.cpp
@@ -28,6 +28,7 @@
#include "CSSMediaRule.h"
#include "CSSPageRule.h"
#include "CSSStyleRule.h"
+#include "StyleRuleImport.h"
#include "WebKitCSSKeyframeRule.h"
#include "WebKitCSSKeyframesRule.h"
#include "WebKitCSSRegionRule.h"
@@ -59,9 +60,11 @@ void StyleRuleBase::destroy()
case Media:
delete static_cast<StyleRuleMedia*>(this);
return;
+#if ENABLE(CSS_REGIONS)
case Region:
delete static_cast<StyleRuleRegion*>(this);
return;
+#endif
case Import:
delete static_cast<StyleRuleImport*>(this);
return;
@@ -71,6 +74,9 @@ void StyleRuleBase::destroy()
case Unknown:
case Charset:
case Keyframe:
+#if !ENABLE(CSS_REGIONS)
+ case Region:
+#endif
ASSERT_NOT_REACHED();
return;
}
@@ -88,8 +94,10 @@ PassRefPtr<StyleRuleBase> StyleRuleBase::copy() const
return static_cast<const StyleRuleFontFace*>(this)->copy();
case Media:
return static_cast<const StyleRuleMedia*>(this)->copy();
+#if ENABLE(CSS_REGIONS)
case Region:
return static_cast<const StyleRuleRegion*>(this)->copy();
+#endif
case Import:
// FIXME: Copy import rules.
ASSERT_NOT_REACHED();
@@ -99,6 +107,9 @@ PassRefPtr<StyleRuleBase> StyleRuleBase::copy() const
case Unknown:
case Charset:
case Keyframe:
+#if !ENABLE(CSS_REGIONS)
+ case Region:
+#endif
ASSERT_NOT_REACHED();
return 0;
}
@@ -123,9 +134,11 @@ PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet
case Media:
rule = CSSMediaRule::create(static_cast<StyleRuleMedia*>(self), parentSheet);
break;
+#if ENABLE(CSS_REGIONS)
case Region:
rule = WebKitCSSRegionRule::create(static_cast<StyleRuleRegion*>(self), parentSheet);
break;
+#endif
case Import:
rule = CSSImportRule::create(static_cast<StyleRuleImport*>(self), parentSheet);
break;
@@ -135,6 +148,9 @@ PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet
case Unknown:
case Charset:
case Keyframe:
+#if !ENABLE(CSS_REGIONS)
+ case Region:
+#endif
ASSERT_NOT_REACHED();
return 0;
}
diff --git a/Source/WebCore/css/StyleRuleImport.cpp b/Source/WebCore/css/StyleRuleImport.cpp
new file mode 100644
index 000000000..df8fa0774
--- /dev/null
+++ b/Source/WebCore/css/StyleRuleImport.cpp
@@ -0,0 +1,131 @@
+/*
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 2005, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "StyleRuleImport.h"
+
+#include "CSSStyleSheet.h"
+#include "CachedCSSStyleSheet.h"
+#include "CachedResourceLoader.h"
+#include "Document.h"
+#include "SecurityOrigin.h"
+#include "StyleSheetContents.h"
+#include <wtf/StdLibExtras.h>
+
+namespace WebCore {
+
+PassRefPtr<StyleRuleImport> StyleRuleImport::create(const String& href, PassRefPtr<MediaQuerySet> media)
+{
+ return adoptRef(new StyleRuleImport(href, media));
+}
+
+StyleRuleImport::StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet> media)
+ : StyleRuleBase(Import, 0)
+ , m_parentStyleSheet(0)
+ , m_styleSheetClient(this)
+ , m_strHref(href)
+ , m_mediaQueries(media)
+ , m_cachedSheet(0)
+ , m_loading(false)
+{
+ if (!m_mediaQueries)
+ m_mediaQueries = MediaQuerySet::create(String());
+}
+
+StyleRuleImport::~StyleRuleImport()
+{
+ if (m_styleSheet)
+ m_styleSheet->clearOwnerRule();
+ if (m_cachedSheet)
+ m_cachedSheet->removeClient(&m_styleSheetClient);
+}
+
+void StyleRuleImport::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* cachedStyleSheet)
+{
+ if (m_styleSheet)
+ m_styleSheet->clearOwnerRule();
+
+ CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : CSSStrictMode;
+ context.charset = charset;
+ if (!baseURL.isNull())
+ context.baseURL = baseURL;
+
+ m_styleSheet = StyleSheetContents::create(this, href, baseURL, context);
+
+ Document* document = m_parentStyleSheet ? m_parentStyleSheet->singleOwnerDocument() : 0;
+ m_styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document ? document->securityOrigin() : 0);
+
+ m_loading = false;
+
+ if (m_parentStyleSheet) {
+ m_parentStyleSheet->notifyLoadedSheet(cachedStyleSheet);
+ m_parentStyleSheet->checkLoaded();
+ }
+}
+
+bool StyleRuleImport::isLoading() const
+{
+ return m_loading || (m_styleSheet && m_styleSheet->isLoading());
+}
+
+void StyleRuleImport::requestStyleSheet()
+{
+ if (!m_parentStyleSheet)
+ return;
+ Document* document = m_parentStyleSheet->singleOwnerDocument();
+ if (!document)
+ return;
+
+ CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
+ if (!cachedResourceLoader)
+ return;
+
+ String absHref = m_strHref;
+ if (!m_parentStyleSheet->finalURL().isNull())
+ // use parent styleheet's URL as the base URL
+ absHref = KURL(m_parentStyleSheet->finalURL(), m_strHref).string();
+
+ // Check for a cycle in our import chain. If we encounter a stylesheet
+ // in our parent chain with the same URL, then just bail.
+ StyleSheetContents* rootSheet = m_parentStyleSheet;
+ for (StyleSheetContents* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
+ if (absHref == sheet->finalURL().string() || absHref == sheet->originalURL())
+ return;
+ rootSheet = sheet;
+ }
+
+ ResourceRequest request(document->completeURL(absHref));
+ if (m_parentStyleSheet->isUserStyleSheet())
+ m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, m_parentStyleSheet->charset());
+ else
+ m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, m_parentStyleSheet->charset());
+ if (m_cachedSheet) {
+ // if the import rule is issued dynamically, the sheet may be
+ // removed from the pending sheet count, so let the doc know
+ // the sheet being imported is pending.
+ if (m_parentStyleSheet && m_parentStyleSheet->loadCompleted() && rootSheet == m_parentStyleSheet)
+ m_parentStyleSheet->startLoadingDynamicSheet();
+ m_loading = true;
+ m_cachedSheet->addClient(&m_styleSheetClient);
+ }
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/css/StyleRuleImport.h b/Source/WebCore/css/StyleRuleImport.h
new file mode 100644
index 000000000..3a8d01389
--- /dev/null
+++ b/Source/WebCore/css/StyleRuleImport.h
@@ -0,0 +1,85 @@
+/*
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 2006, 2008, 2012 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef StyleRuleImport_h
+#define StyleRuleImport_h
+
+#include "CachedResourceHandle.h"
+#include "CachedStyleSheetClient.h"
+#include "StyleRule.h"
+
+namespace WebCore {
+
+class CachedCSSStyleSheet;
+class MediaQuerySet;
+class StyleSheetContents;
+
+class StyleRuleImport : public StyleRuleBase {
+public:
+ static PassRefPtr<StyleRuleImport> create(const String& href, PassRefPtr<MediaQuerySet>);
+
+ ~StyleRuleImport();
+
+ StyleSheetContents* parentStyleSheet() const { return m_parentStyleSheet; }
+ void setParentStyleSheet(StyleSheetContents* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; }
+ void clearParentStyleSheet() { m_parentStyleSheet = 0; }
+
+ String href() const { return m_strHref; }
+ StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
+
+ bool isLoading() const;
+ MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); }
+
+ void requestStyleSheet();
+
+private:
+ // NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it
+ // to avoid adding a vptr to StyleRuleImport.
+ class ImportedStyleSheetClient : public CachedStyleSheetClient {
+ public:
+ ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }
+ virtual ~ImportedStyleSheetClient() { }
+ virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)
+ {
+ m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);
+ }
+ private:
+ StyleRuleImport* m_ownerRule;
+ };
+
+ void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
+ friend class ImportedStyleSheetClient;
+
+ StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet>);
+
+ StyleSheetContents* m_parentStyleSheet;
+
+ ImportedStyleSheetClient m_styleSheetClient;
+ String m_strHref;
+ RefPtr<MediaQuerySet> m_mediaQueries;
+ RefPtr<StyleSheetContents> m_styleSheet;
+ CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
+ bool m_loading;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/StyleSheet.h b/Source/WebCore/css/StyleSheet.h
index 7b413752d..9f4ecd181 100644
--- a/Source/WebCore/css/StyleSheet.h
+++ b/Source/WebCore/css/StyleSheet.h
@@ -32,7 +32,6 @@ namespace WebCore {
class CSSImportRule;
class MediaList;
class Node;
-class StyleRuleImport;
class StyleSheet;
class StyleSheet : public RefCounted<StyleSheet> {
diff --git a/Source/WebCore/css/StyleSheetContents.cpp b/Source/WebCore/css/StyleSheetContents.cpp
new file mode 100644
index 000000000..970c828ca
--- /dev/null
+++ b/Source/WebCore/css/StyleSheetContents.cpp
@@ -0,0 +1,444 @@
+/*
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "StyleSheetContents.h"
+
+#include "CSSImportRule.h"
+#include "CSSParser.h"
+#include "CSSStyleSheet.h"
+#include "CachedCSSStyleSheet.h"
+#include "Document.h"
+#include "Node.h"
+#include "SecurityOrigin.h"
+#include "StylePropertySet.h"
+#include "StyleRule.h"
+#include "StyleRuleImport.h"
+#include <wtf/Deque.h>
+
+namespace WebCore {
+
+// Rough size estimate for the memory cache.
+unsigned StyleSheetContents::estimatedSizeInBytes() const
+{
+ // Note that this does not take into account size of the strings hanging from various objects.
+ // The assumption is that nearly all of of them are atomic and would exist anyway.
+ unsigned size = sizeof(*this);
+
+ // FIXME: This ignores the children of media and region rules.
+ // Most rules are StyleRules.
+ size += ruleCount() * StyleRule::averageSizeInBytes();
+
+ for (unsigned i = 0; i < m_importRules.size(); ++i) {
+ if (StyleSheetContents* sheet = m_importRules[i]->styleSheet())
+ size += sheet->estimatedSizeInBytes();
+ }
+ return size;
+}
+
+StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const CSSParserContext& context)
+ : m_ownerRule(ownerRule)
+ , m_originalURL(originalURL)
+ , m_finalURL(finalURL)
+ , m_loadCompleted(false)
+ , m_isUserStyleSheet(ownerRule && ownerRule->parentStyleSheet() && ownerRule->parentStyleSheet()->isUserStyleSheet())
+ , m_hasSyntacticallyValidCSSHeader(true)
+ , m_didLoadErrorOccur(false)
+ , m_usesRemUnits(false)
+ , m_isMutable(false)
+ , m_isInMemoryCache(false)
+ , m_parserContext(context)
+{
+}
+
+StyleSheetContents::StyleSheetContents(const StyleSheetContents& o)
+ : RefCounted<StyleSheetContents>()
+ , m_ownerRule(0)
+ , m_originalURL(o.m_originalURL)
+ , m_finalURL(o.m_finalURL)
+ , m_encodingFromCharsetRule(o.m_encodingFromCharsetRule)
+ , m_importRules(o.m_importRules.size())
+ , m_childRules(o.m_childRules.size())
+ , m_namespaces(o.m_namespaces)
+ , m_loadCompleted(true)
+ , m_isUserStyleSheet(o.m_isUserStyleSheet)
+ , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader)
+ , m_didLoadErrorOccur(false)
+ , m_usesRemUnits(o.m_usesRemUnits)
+ , m_isMutable(false)
+ , m_isInMemoryCache(false)
+ , m_parserContext(o.m_parserContext)
+{
+ ASSERT(o.isCacheable());
+
+ // FIXME: Copy import rules.
+ ASSERT(o.m_importRules.isEmpty());
+
+ for (unsigned i = 0; i < m_childRules.size(); ++i)
+ m_childRules[i] = o.m_childRules[i]->copy();
+}
+
+StyleSheetContents::~StyleSheetContents()
+{
+ clearRules();
+}
+
+bool StyleSheetContents::isCacheable() const
+{
+ // FIXME: Support copying import rules.
+ if (!m_importRules.isEmpty())
+ return false;
+ // FIXME: Support cached stylesheets in import rules.
+ if (m_ownerRule)
+ return false;
+ // This would require dealing with multiple clients for load callbacks.
+ if (!m_loadCompleted)
+ return false;
+ if (m_didLoadErrorOccur)
+ return false;
+ // It is not the original sheet anymore.
+ if (m_isMutable)
+ return false;
+ // If the header is valid we are not going to need to check the SecurityOrigin.
+ // FIXME: Valid mime type avoids the check too.
+ if (!m_hasSyntacticallyValidCSSHeader)
+ return false;
+ return true;
+}
+
+void StyleSheetContents::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
+{
+ ASSERT(!rule->isCharsetRule());
+ if (rule->isImportRule()) {
+ // Parser enforces that @import rules come before anything else except @charset.
+ ASSERT(m_childRules.isEmpty());
+ m_importRules.append(static_cast<StyleRuleImport*>(rule.get()));
+ m_importRules.last()->setParentStyleSheet(this);
+ m_importRules.last()->requestStyleSheet();
+ return;
+ }
+ m_childRules.append(rule);
+}
+
+StyleRuleBase* StyleSheetContents::ruleAt(unsigned index) const
+{
+ ASSERT(index < ruleCount());
+
+ unsigned childVectorIndex = index;
+ if (hasCharsetRule()) {
+ if (index == 0)
+ return 0;
+ --childVectorIndex;
+ }
+ if (childVectorIndex < m_importRules.size())
+ return m_importRules[childVectorIndex].get();
+
+ childVectorIndex -= m_importRules.size();
+ return m_childRules[childVectorIndex].get();
+}
+
+unsigned StyleSheetContents::ruleCount() const
+{
+ unsigned result = 0;
+ result += hasCharsetRule() ? 1 : 0;
+ result += m_importRules.size();
+ result += m_childRules.size();
+ return result;
+}
+
+void StyleSheetContents::clearCharsetRule()
+{
+ m_encodingFromCharsetRule = String();
+}
+
+void StyleSheetContents::clearRules()
+{
+ for (unsigned i = 0; i < m_importRules.size(); ++i) {
+ ASSERT(m_importRules.at(i)->parentStyleSheet() == this);
+ m_importRules[i]->clearParentStyleSheet();
+ }
+ m_importRules.clear();
+ m_childRules.clear();
+ clearCharsetRule();
+}
+
+void StyleSheetContents::parserSetEncodingFromCharsetRule(const String& encoding)
+{
+ // Parser enforces that there is ever only one @charset.
+ ASSERT(m_encodingFromCharsetRule.isNull());
+ m_encodingFromCharsetRule = encoding;
+}
+
+bool StyleSheetContents::wrapperInsertRule(PassRefPtr<StyleRuleBase> rule, unsigned index)
+{
+ ASSERT(m_isMutable);
+ ASSERT(index <= ruleCount());
+ // Parser::parseRule doesn't currently allow @charset so we don't need to deal with it.
+ ASSERT(!rule->isCharsetRule());
+
+ unsigned childVectorIndex = index;
+ // m_childRules does not contain @charset which is always in index 0 if it exists.
+ if (hasCharsetRule()) {
+ if (childVectorIndex == 0) {
+ // Nothing can be inserted before @charset.
+ return false;
+ }
+ --childVectorIndex;
+ }
+
+ if (childVectorIndex < m_importRules.size() || (childVectorIndex == m_importRules.size() && rule->isImportRule())) {
+ // Inserting non-import rule before @import is not allowed.
+ if (!rule->isImportRule())
+ return false;
+ m_importRules.insert(childVectorIndex, static_cast<StyleRuleImport*>(rule.get()));
+ m_importRules[childVectorIndex]->setParentStyleSheet(this);
+ m_importRules[childVectorIndex]->requestStyleSheet();
+ // FIXME: Stylesheet doesn't actually change meaningfully before the imported sheets are loaded.
+ return true;
+ }
+ // Inserting @import rule after a non-import rule is not allowed.
+ if (rule->isImportRule())
+ return false;
+ childVectorIndex -= m_importRules.size();
+
+ m_childRules.insert(childVectorIndex, rule);
+ return true;
+}
+
+void StyleSheetContents::wrapperDeleteRule(unsigned index)
+{
+ ASSERT(m_isMutable);
+ ASSERT(index < ruleCount());
+
+ unsigned childVectorIndex = index;
+ if (hasCharsetRule()) {
+ if (childVectorIndex == 0) {
+ clearCharsetRule();
+ return;
+ }
+ --childVectorIndex;
+ }
+ if (childVectorIndex < m_importRules.size()) {
+ m_importRules[childVectorIndex]->clearParentStyleSheet();
+ m_importRules.remove(childVectorIndex);
+ return;
+ }
+ childVectorIndex -= m_importRules.size();
+
+ m_childRules.remove(childVectorIndex);
+}
+
+void StyleSheetContents::parserAddNamespace(const AtomicString& prefix, const AtomicString& uri)
+{
+ if (uri.isNull() || prefix.isNull())
+ return;
+ m_namespaces.add(prefix, uri);
+}
+
+const AtomicString& StyleSheetContents::determineNamespace(const AtomicString& prefix)
+{
+ if (prefix.isNull())
+ return nullAtom; // No namespace. If an element/attribute has a namespace, we won't match it.
+ if (prefix == starAtom)
+ return starAtom; // We'll match any namespace.
+ PrefixNamespaceURIMap::const_iterator it = m_namespaces.find(prefix);
+ if (it == m_namespaces.end())
+ return nullAtom;
+ return it->second;
+}
+
+void StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cachedStyleSheet, const SecurityOrigin* securityOrigin)
+{
+ // Check to see if we should enforce the MIME type of the CSS resource in strict mode.
+ // Running in iWeb 2 is one example of where we don't want to - <rdar://problem/6099748>
+ bool enforceMIMEType = isStrictParserMode(m_parserContext.mode) && m_parserContext.enforcesCSSMIMETypeInNoQuirksMode;
+ bool hasValidMIMEType = false;
+ String sheetText = cachedStyleSheet->sheetText(enforceMIMEType, &hasValidMIMEType);
+
+ CSSParser p(parserContext());
+ p.parseSheet(this, sheetText, 0);
+
+ // If we're loading a stylesheet cross-origin, and the MIME type is not standard, require the CSS
+ // to at least start with a syntactically valid CSS rule.
+ // This prevents an attacker playing games by injecting CSS strings into HTML, XML, JSON, etc. etc.
+ if (!hasValidMIMEType && !hasSyntacticallyValidCSSHeader()) {
+ bool isCrossOriginCSS = !securityOrigin || !securityOrigin->canRequest(finalURL());
+ if (isCrossOriginCSS) {
+ clearRules();
+ return;
+ }
+ }
+ if (m_parserContext.needsSiteSpecificQuirks && isStrictParserMode(m_parserContext.mode)) {
+ // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
+ DEFINE_STATIC_LOCAL(const String, slashKHTMLFixesDotCss, ("/KHTMLFixes.css"));
+ DEFINE_STATIC_LOCAL(const String, mediaWikiKHTMLFixesStyleSheet, ("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n"));
+ // There are two variants of KHTMLFixes.css. One is equal to mediaWikiKHTMLFixesStyleSheet,
+ // while the other lacks the second trailing newline.
+ if (finalURL().string().endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
+ && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1)
+ clearRules();
+ }
+}
+
+bool StyleSheetContents::parseString(const String& sheetText)
+{
+ return parseStringAtLine(sheetText, 0);
+}
+
+bool StyleSheetContents::parseStringAtLine(const String& sheetText, int startLineNumber)
+{
+ CSSParser p(parserContext());
+ p.parseSheet(this, sheetText, startLineNumber);
+
+ return true;
+}
+
+bool StyleSheetContents::isLoading() const
+{
+ for (unsigned i = 0; i < m_importRules.size(); ++i) {
+ if (m_importRules[i]->isLoading())
+ return true;
+ }
+ return false;
+}
+
+void StyleSheetContents::checkLoaded()
+{
+ if (isLoading())
+ return;
+
+ // Avoid |this| being deleted by scripts that run via
+ // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
+ // See <rdar://problem/6622300>.
+ RefPtr<StyleSheetContents> protector(this);
+ StyleSheetContents* parentSheet = parentStyleSheet();
+ if (parentSheet) {
+ parentSheet->checkLoaded();
+ m_loadCompleted = true;
+ return;
+ }
+ RefPtr<Node> ownerNode = singleOwnerNode();
+ if (!ownerNode) {
+ m_loadCompleted = true;
+ return;
+ }
+ m_loadCompleted = ownerNode->sheetLoaded();
+ if (m_loadCompleted)
+ ownerNode->notifyLoadedSheetAndAllCriticalSubresources(m_didLoadErrorOccur);
+}
+
+void StyleSheetContents::notifyLoadedSheet(const CachedCSSStyleSheet* sheet)
+{
+ ASSERT(sheet);
+ m_didLoadErrorOccur |= sheet->errorOccurred();
+}
+
+void StyleSheetContents::startLoadingDynamicSheet()
+{
+ if (Node* owner = singleOwnerNode())
+ owner->startLoadingDynamicSheet();
+}
+
+StyleSheetContents* StyleSheetContents::rootStyleSheet() const
+{
+ const StyleSheetContents* root = this;
+ while (root->parentStyleSheet())
+ root = root->parentStyleSheet();
+ return const_cast<StyleSheetContents*>(root);
+}
+
+Node* StyleSheetContents::singleOwnerNode() const
+{
+ StyleSheetContents* root = rootStyleSheet();
+ if (root->m_clients.isEmpty())
+ return 0;
+ ASSERT(root->m_clients.size() == 1);
+ return root->m_clients[0]->ownerNode();
+}
+
+Document* StyleSheetContents::singleOwnerDocument() const
+{
+ Node* ownerNode = singleOwnerNode();
+ return ownerNode ? ownerNode->document() : 0;
+}
+
+KURL StyleSheetContents::completeURL(const String& url) const
+{
+ return CSSParser::completeURL(m_parserContext, url);
+}
+
+void StyleSheetContents::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
+{
+ Deque<StyleSheetContents*> styleSheetQueue;
+ styleSheetQueue.append(this);
+
+ while (!styleSheetQueue.isEmpty()) {
+ StyleSheetContents* styleSheet = styleSheetQueue.takeFirst();
+
+ for (unsigned i = 0; i < styleSheet->m_importRules.size(); ++i) {
+ StyleRuleImport* importRule = styleSheet->m_importRules[i].get();
+ if (importRule->styleSheet()) {
+ styleSheetQueue.append(importRule->styleSheet());
+ addSubresourceURL(urls, importRule->styleSheet()->baseURL());
+ }
+ }
+ for (unsigned i = 0; i < styleSheet->m_childRules.size(); ++i) {
+ StyleRuleBase* rule = styleSheet->m_childRules[i].get();
+ if (rule->isStyleRule())
+ static_cast<StyleRule*>(rule)->properties()->addSubresourceStyleURLs(urls, this);
+ else if (rule->isFontFaceRule())
+ static_cast<StyleRuleFontFace*>(rule)->properties()->addSubresourceStyleURLs(urls, this);
+ }
+ }
+}
+
+StyleSheetContents* StyleSheetContents::parentStyleSheet() const
+{
+ return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
+}
+
+void StyleSheetContents::registerClient(CSSStyleSheet* sheet)
+{
+ ASSERT(!m_clients.contains(sheet));
+ m_clients.append(sheet);
+}
+
+void StyleSheetContents::unregisterClient(CSSStyleSheet* sheet)
+{
+ size_t position = m_clients.find(sheet);
+ ASSERT(position != notFound);
+ m_clients.remove(position);
+}
+
+void StyleSheetContents::addedToMemoryCache()
+{
+ ASSERT(!m_isInMemoryCache);
+ ASSERT(isCacheable());
+ m_isInMemoryCache = true;
+}
+
+void StyleSheetContents::removedFromMemoryCache()
+{
+ ASSERT(m_isInMemoryCache);
+ ASSERT(isCacheable());
+ m_isInMemoryCache = false;
+}
+
+}
diff --git a/Source/WebCore/css/StyleSheetContents.h b/Source/WebCore/css/StyleSheetContents.h
new file mode 100644
index 000000000..7df34b703
--- /dev/null
+++ b/Source/WebCore/css/StyleSheetContents.h
@@ -0,0 +1,172 @@
+/*
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef StyleSheetContents_h
+#define StyleSheetContents_h
+
+#include "CSSParserMode.h"
+#include "KURL.h"
+#include <wtf/HashMap.h>
+#include <wtf/ListHashSet.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+#include <wtf/text/AtomicStringHash.h>
+
+namespace WebCore {
+
+class CSSStyleSheet;
+class CachedCSSStyleSheet;
+class Document;
+class Node;
+class SecurityOrigin;
+class StyleRuleBase;
+class StyleRuleImport;
+
+class StyleSheetContents : public RefCounted<StyleSheetContents> {
+public:
+ static PassRefPtr<StyleSheetContents> create(const CSSParserContext& context = CSSParserContext(CSSStrictMode))
+ {
+ return adoptRef(new StyleSheetContents(0, String(), KURL(), context));
+ }
+ static PassRefPtr<StyleSheetContents> create(const String& originalURL, const KURL& finalURL, const CSSParserContext& context)
+ {
+ return adoptRef(new StyleSheetContents(0, originalURL, finalURL, context));
+ }
+ static PassRefPtr<StyleSheetContents> create(StyleRuleImport* ownerRule, const String& originalURL, const KURL& finalURL, const CSSParserContext& context)
+ {
+ return adoptRef(new StyleSheetContents(ownerRule, originalURL, finalURL, context));
+ }
+
+ ~StyleSheetContents();
+
+ const CSSParserContext& parserContext() const { return m_parserContext; }
+
+ const AtomicString& determineNamespace(const AtomicString& prefix);
+
+ void parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*);
+ bool parseString(const String&);
+ bool parseStringAtLine(const String&, int startLineNumber);
+
+ bool isCacheable() const;
+
+ bool isLoading() const;
+
+ void checkLoaded();
+ void startLoadingDynamicSheet();
+
+ StyleSheetContents* rootStyleSheet() const;
+ Node* singleOwnerNode() const;
+ Document* singleOwnerDocument() const;
+
+ const String& charset() const { return m_parserContext.charset; }
+
+ bool loadCompleted() const { return m_loadCompleted; }
+
+ KURL completeURL(const String& url) const;
+ void addSubresourceStyleURLs(ListHashSet<KURL>&);
+
+ void setIsUserStyleSheet(bool b) { m_isUserStyleSheet = b; }
+ bool isUserStyleSheet() const { return m_isUserStyleSheet; }
+ void setHasSyntacticallyValidCSSHeader(bool b) { m_hasSyntacticallyValidCSSHeader = b; }
+ bool hasSyntacticallyValidCSSHeader() const { return m_hasSyntacticallyValidCSSHeader; }
+
+ void parserAddNamespace(const AtomicString& prefix, const AtomicString& uri);
+ void parserAppendRule(PassRefPtr<StyleRuleBase>);
+ void parserSetEncodingFromCharsetRule(const String& encoding);
+ void parserSetUsesRemUnits(bool b) { m_usesRemUnits = b; }
+
+ void clearRules();
+
+ bool hasCharsetRule() const { return !m_encodingFromCharsetRule.isNull(); }
+ String encodingFromCharsetRule() const { return m_encodingFromCharsetRule; }
+ // Rules other than @charset and @import.
+ const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRules; }
+ const Vector<RefPtr<StyleRuleImport> >& importRules() const { return m_importRules; }
+
+ void notifyLoadedSheet(const CachedCSSStyleSheet*);
+
+ StyleSheetContents* parentStyleSheet() const;
+ StyleRuleImport* ownerRule() const { return m_ownerRule; }
+ void clearOwnerRule() { m_ownerRule = 0; }
+
+ // Note that href is the URL that started the redirect chain that led to
+ // this style sheet. This property probably isn't useful for much except
+ // the JavaScript binding (which needs to use this value for security).
+ String originalURL() const { return m_originalURL; }
+
+ const KURL& finalURL() const { return m_finalURL; }
+ const KURL& baseURL() const { return m_parserContext.baseURL; }
+
+ unsigned ruleCount() const;
+ StyleRuleBase* ruleAt(unsigned index) const;
+
+ bool usesRemUnits() const { return m_usesRemUnits; }
+
+ unsigned estimatedSizeInBytes() const;
+
+ bool wrapperInsertRule(PassRefPtr<StyleRuleBase>, unsigned index);
+ void wrapperDeleteRule(unsigned index);
+
+ PassRefPtr<StyleSheetContents> copy() const { return adoptRef(new StyleSheetContents(*this)); }
+
+ void registerClient(CSSStyleSheet*);
+ void unregisterClient(CSSStyleSheet*);
+ bool hasOneClient() { return m_clients.size() == 1; }
+
+ bool isMutable() const { return m_isMutable; }
+ void setMutable() { m_isMutable = true; }
+
+ bool isInMemoryCache() const { return m_isInMemoryCache; }
+ void addedToMemoryCache();
+ void removedFromMemoryCache();
+
+private:
+ StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const KURL& baseURL, const CSSParserContext&);
+ StyleSheetContents(const StyleSheetContents&);
+
+ void clearCharsetRule();
+
+ StyleRuleImport* m_ownerRule;
+
+ String m_originalURL;
+ KURL m_finalURL;
+
+ String m_encodingFromCharsetRule;
+ Vector<RefPtr<StyleRuleImport> > m_importRules;
+ Vector<RefPtr<StyleRuleBase> > m_childRules;
+ typedef HashMap<AtomicString, AtomicString> PrefixNamespaceURIMap;
+ PrefixNamespaceURIMap m_namespaces;
+
+ bool m_loadCompleted : 1;
+ bool m_isUserStyleSheet : 1;
+ bool m_hasSyntacticallyValidCSSHeader : 1;
+ bool m_didLoadErrorOccur : 1;
+ bool m_usesRemUnits : 1;
+ bool m_isMutable : 1;
+ bool m_isInMemoryCache : 1;
+
+ CSSParserContext m_parserContext;
+
+ Vector<CSSStyleSheet*> m_clients;
+};
+
+} // namespace
+
+#endif
diff --git a/Source/WebCore/css/WebKitCSSKeyframesRule.cpp b/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
index dcd79034f..12700e9fd 100644
--- a/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
+++ b/Source/WebCore/css/WebKitCSSKeyframesRule.cpp
@@ -116,7 +116,7 @@ void WebKitCSSKeyframesRule::insertRule(const String& ruleText)
CSSParser parser(parserContext());
CSSStyleSheet* styleSheet = parentStyleSheet();
- RefPtr<StyleKeyframe> keyframe = parser.parseKeyframeRule(styleSheet ? styleSheet->internal() : 0, ruleText);
+ RefPtr<StyleKeyframe> keyframe = parser.parseKeyframeRule(styleSheet ? styleSheet->contents() : 0, ruleText);
if (!keyframe)
return;
diff --git a/Source/WebCore/css/WebKitCSSRegionRule.cpp b/Source/WebCore/css/WebKitCSSRegionRule.cpp
index 677a9f81c..bdab5acce 100644
--- a/Source/WebCore/css/WebKitCSSRegionRule.cpp
+++ b/Source/WebCore/css/WebKitCSSRegionRule.cpp
@@ -36,6 +36,8 @@
#include "StyleRule.h"
#include <wtf/text/StringBuilder.h>
+#if ENABLE(CSS_REGIONS)
+
namespace WebCore {
WebKitCSSRegionRule::WebKitCSSRegionRule(StyleRuleRegion* regionRule, CSSStyleSheet* parent)
: CSSRule(parent, CSSRule::WEBKIT_REGION_RULE)
@@ -107,3 +109,5 @@ void WebKitCSSRegionRule::reattach(StyleRuleRegion* rule)
}
} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/WebKitCSSRegionRule.h b/Source/WebCore/css/WebKitCSSRegionRule.h
index 1987ef2ca..2b4216699 100644
--- a/Source/WebCore/css/WebKitCSSRegionRule.h
+++ b/Source/WebCore/css/WebKitCSSRegionRule.h
@@ -35,6 +35,8 @@
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
+#if ENABLE(CSS_REGIONS)
+
namespace WebCore {
class CSSRuleList;
@@ -68,4 +70,6 @@ private:
}
-#endif
+#endif // ENABLE(CSS_REGIONS)
+
+#endif // WebKitCSSRegionRule_h
diff --git a/Source/WebCore/css/WebKitCSSRegionRule.idl b/Source/WebCore/css/WebKitCSSRegionRule.idl
index 6c1a8972b..ec3e6d515 100644
--- a/Source/WebCore/css/WebKitCSSRegionRule.idl
+++ b/Source/WebCore/css/WebKitCSSRegionRule.idl
@@ -29,7 +29,9 @@
module css {
- interface WebKitCSSRegionRule : CSSRule {
+ interface [
+ Conditional=CSS_REGIONS,
+ ] WebKitCSSRegionRule : CSSRule {
readonly attribute CSSRuleList cssRules;
};
diff --git a/Source/WebCore/css/html.css b/Source/WebCore/css/html.css
index 65217d67f..d1e373bf6 100644
--- a/Source/WebCore/css/html.css
+++ b/Source/WebCore/css/html.css
@@ -510,8 +510,6 @@ input::-webkit-input-placeholder, isindex::-webkit-input-placeholder {
white-space: pre;
word-wrap: normal;
overflow: hidden;
- padding-left: 1px;
- padding-right: 1px;
}
input[type="password"] {
diff --git a/Source/WebCore/css/mediaControlsEflFullscreen.css b/Source/WebCore/css/mediaControlsEflFullscreen.css
new file mode 100644
index 000000000..1724d4032
--- /dev/null
+++ b/Source/WebCore/css/mediaControlsEflFullscreen.css
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* EFLWebKit media controls for fullscreen. */
+
+video::-webkit-media-controls-panel {
+ display: -webkit-box;
+ -webkit-box-orient: horizontal;
+ -webkit-box-align: center;
+ -webkit-user-select: none;
+ position: relative;
+ bottom: 0;
+ width: 100%;
+ z-index: 0;
+ overflow: hidden;
+ height: 20px;
+ text-align: right;
+}
+
+video:-webkit-full-page-media::-webkit-media-controls-panel {
+ display: none;
+}
+
+video::-webkit-media-controls-mute-button {
+ display: none;
+}
+
+video::-webkit-media-controls-play-button {
+ -webkit-appearance: media-play-button;
+ display: -webkit-box;
+ width: 20px;
+ height: 20px;
+ background-color: initial;
+ border: initial;
+ color: inherit;
+}
+
+video::-webkit-media-controls-timeline-container {
+ -webkit-appearance: media-controls-background;
+ display: -webkit-box;
+ -webkit-box-orient: horizontal;
+ -webkit-box-align: center;
+ -webkit-box-pack: end;
+ -webkit-box-flex: 1;
+ -webkit-user-select: none;
+ height: 20px;
+}
+
+video::-webkit-media-controls-current-time-display {
+ -webkit-appearance: media-current-time-display;
+ -webkit-user-select: none;
+ display: inline-block;
+ height: 20px;
+ padding: 4px;
+ text-align: center;
+ font-size: 10px;
+}
+
+video::-webkit-media-controls-time-remaining-display {
+ display: none;
+}
+
+video::-webkit-media-controls-timeline {
+ -webkit-appearance: media-slider;
+ display: -webkit-box;
+ -webkit-box-flex: 1;
+ height: 20px;
+ padding: 0px 2px;
+ background-color: initial;
+ border: initial;
+ color: inherit;
+ margin: initial;
+}
+
+video::-webkit-media-controls-volume-slider-container {
+ -webkit-appearance: media-volume-slider-container;
+ display: none;
+}
+
+video::-webkit-media-controls-volume-slider {
+ -webkit-appearance: media-volume-slider;
+ display: none;
+}
+
+video::-webkit-media-controls-seek-back-button {
+ display: none;
+}
+
+video::-webkit-media-controls-seek-forward-button {
+ display: none;
+}
+
+video::-webkit-media-controls-fullscreen-button {
+ display: none;
+}
+
+video::-webkit-media-controls-rewind-button {
+ display: none;
+}
+
+video::-webkit-media-controls-return-to-realtime-button {
+ display: none;
+}
+
+video::-webkit-media-controls-toggle-closed-captions-button {
+ display: none;
+}