From ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Mon, 16 May 2011 16:25:10 +0100 Subject: Merge WebKit at r76408: Initial merge by git. Change-Id: I5b91decbd693ccbf5c1b8354b37cd68cc9a1ea53 --- Source/WebCore/css/CSSGradientValue.cpp | 106 ++++++----- Source/WebCore/css/CSSImageValue.h | 1 + Source/WebCore/css/CSSImportRule.h | 1 + Source/WebCore/css/CSSMutableStyleDeclaration.h | 2 + Source/WebCore/css/CSSNamespace.h | 4 +- Source/WebCore/css/CSSParser.cpp | 3 +- Source/WebCore/css/CSSParser.h | 3 +- Source/WebCore/css/CSSParserValues.h | 7 +- Source/WebCore/css/CSSProperty.h | 3 +- Source/WebCore/css/CSSSelector.cpp | 4 +- Source/WebCore/css/CSSSelector.h | 26 ++- Source/WebCore/css/CSSSelectorList.h | 4 +- Source/WebCore/css/CSSStyleSelector.cpp | 226 +++++++++++++++++------ Source/WebCore/css/CSSStyleSelector.h | 16 +- Source/WebCore/css/MediaQuery.h | 3 +- Source/WebCore/css/MediaQueryEvaluator.h | 3 +- Source/WebCore/css/MediaQueryExp.h | 3 +- Source/WebCore/css/WebKitCSSMatrix.cpp | 1 - Source/WebCore/css/mediaControlsQt.css | 132 +++++++++++-- Source/WebCore/css/mediaControlsQtFullscreen.css | 103 +---------- 20 files changed, 417 insertions(+), 234 deletions(-) (limited to 'Source/WebCore/css') diff --git a/Source/WebCore/css/CSSGradientValue.cpp b/Source/WebCore/css/CSSGradientValue.cpp index fde4a4e..b6b9ebe 100644 --- a/Source/WebCore/css/CSSGradientValue.cpp +++ b/Source/WebCore/css/CSSGradientValue.cpp @@ -230,58 +230,68 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend // We can't just push this logic down into the platform-specific Gradient code, // because we have to know the extent of the gradient, and possible move the end points. if (m_repeating && numStops > 1) { - float maxExtent = 1; - - // Radial gradients may need to extend further than the endpoints, because they have - // to repeat out to the corners of the box. - if (isRadialGradient()) { - if (!computedGradientLength) { - FloatSize gradientSize(gradientStart - gradientEnd); - gradientLength = gradientSize.diagonalLength(); - } - - if (maxLengthForRepeat > gradientLength) - maxExtent = maxLengthForRepeat / gradientLength; - } + // If the difference in the positions of the first and last color-stops is 0, + // the gradient defines a solid-color image with the color of the last color-stop in the rule. + float gradientRange = stops[numStops - 1].offset - stops[0].offset; + if (!gradientRange) { + stops.first().offset = 0; + stops.first().color = stops.last().color; + stops.shrink(1); + numStops = 1; + } else { + float maxExtent = 1; - size_t originalNumStops = numStops; - size_t originalFirstStopIndex = 0; + // Radial gradients may need to extend further than the endpoints, because they have + // to repeat out to the corners of the box. + if (isRadialGradient()) { + if (!computedGradientLength) { + FloatSize gradientSize(gradientStart - gradientEnd); + gradientLength = gradientSize.diagonalLength(); + } + + if (maxLengthForRepeat > gradientLength) + maxExtent = maxLengthForRepeat / gradientLength; + } - // Work backwards from the first, adding stops until we get one before 0. - float firstOffset = stops[0].offset; - if (firstOffset > 0) { - float currOffset = firstOffset; - size_t srcStopOrdinal = originalNumStops - 1; - - while (true) { - GradientStop newStop = stops[originalFirstStopIndex + srcStopOrdinal]; - newStop.offset = currOffset; - stops.prepend(newStop); - ++originalFirstStopIndex; - if (currOffset < 0) - break; + size_t originalNumStops = numStops; + size_t originalFirstStopIndex = 0; - if (srcStopOrdinal) - currOffset -= stops[originalFirstStopIndex + srcStopOrdinal].offset - stops[originalFirstStopIndex + srcStopOrdinal - 1].offset; - srcStopOrdinal = (srcStopOrdinal + originalNumStops - 1) % originalNumStops; + // Work backwards from the first, adding stops until we get one before 0. + float firstOffset = stops[0].offset; + if (firstOffset > 0) { + float currOffset = firstOffset; + size_t srcStopOrdinal = originalNumStops - 1; + + while (true) { + GradientStop newStop = stops[originalFirstStopIndex + srcStopOrdinal]; + newStop.offset = currOffset; + stops.prepend(newStop); + ++originalFirstStopIndex; + if (currOffset < 0) + break; + + if (srcStopOrdinal) + currOffset -= stops[originalFirstStopIndex + srcStopOrdinal].offset - stops[originalFirstStopIndex + srcStopOrdinal - 1].offset; + srcStopOrdinal = (srcStopOrdinal + originalNumStops - 1) % originalNumStops; + } } - } - - // Work forwards from the end, adding stops until we get one after 1. - float lastOffset = stops[stops.size() - 1].offset; - if (lastOffset < maxExtent) { - float currOffset = lastOffset; - size_t srcStopOrdinal = 0; - - while (true) { - GradientStop newStop = stops[srcStopOrdinal]; - newStop.offset = currOffset; - stops.append(newStop); - if (currOffset > maxExtent) - break; - if (srcStopOrdinal < originalNumStops - 1) - currOffset += stops[originalFirstStopIndex + srcStopOrdinal + 1].offset - stops[originalFirstStopIndex + srcStopOrdinal].offset; - srcStopOrdinal = (srcStopOrdinal + 1) % originalNumStops; + + // Work forwards from the end, adding stops until we get one after 1. + float lastOffset = stops[stops.size() - 1].offset; + if (lastOffset < maxExtent) { + float currOffset = lastOffset; + size_t srcStopOrdinal = 0; + + while (true) { + GradientStop newStop = stops[srcStopOrdinal]; + newStop.offset = currOffset; + stops.append(newStop); + if (currOffset > maxExtent) + break; + if (srcStopOrdinal < originalNumStops - 1) + currOffset += stops[originalFirstStopIndex + srcStopOrdinal + 1].offset - stops[originalFirstStopIndex + srcStopOrdinal].offset; + srcStopOrdinal = (srcStopOrdinal + 1) % originalNumStops; + } } } } diff --git a/Source/WebCore/css/CSSImageValue.h b/Source/WebCore/css/CSSImageValue.h index 833d7fe..174f1ed 100644 --- a/Source/WebCore/css/CSSImageValue.h +++ b/Source/WebCore/css/CSSImageValue.h @@ -32,6 +32,7 @@ class StyleCachedImage; class StyleImage; class CSSImageValue : public CSSPrimitiveValue, private CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr create() { return adoptRef(new CSSImageValue); } static PassRefPtr create(const String& url) { return adoptRef(new CSSImageValue(url)); } diff --git a/Source/WebCore/css/CSSImportRule.h b/Source/WebCore/css/CSSImportRule.h index 943d53e..3f44f5b 100644 --- a/Source/WebCore/css/CSSImportRule.h +++ b/Source/WebCore/css/CSSImportRule.h @@ -34,6 +34,7 @@ class CachedCSSStyleSheet; class MediaList; class CSSImportRule : public CSSRule, private CachedResourceClient { + WTF_MAKE_FAST_ALLOCATED; public: static PassRefPtr create(CSSStyleSheet* parent, const String& href, PassRefPtr media) { diff --git a/Source/WebCore/css/CSSMutableStyleDeclaration.h b/Source/WebCore/css/CSSMutableStyleDeclaration.h index f7d8ca9..35f1cc4 100644 --- a/Source/WebCore/css/CSSMutableStyleDeclaration.h +++ b/Source/WebCore/css/CSSMutableStyleDeclaration.h @@ -135,6 +135,8 @@ public: bool useStrictParsing() const { return m_strictParsing; } void addSubresourceStyleURLs(ListHashSet&); + + bool propertiesEqual(const CSSMutableStyleDeclaration* o) const { return m_properties == o->m_properties; } protected: CSSMutableStyleDeclaration(CSSRule* parentRule); diff --git a/Source/WebCore/css/CSSNamespace.h b/Source/WebCore/css/CSSNamespace.h index 6225c36..92638f2 100644 --- a/Source/WebCore/css/CSSNamespace.h +++ b/Source/WebCore/css/CSSNamespace.h @@ -26,7 +26,9 @@ namespace WebCore { - struct CSSNamespace : Noncopyable { + struct CSSNamespace { + WTF_MAKE_NONCOPYABLE(CSSNamespace); WTF_MAKE_FAST_ALLOCATED; + public: AtomicString prefix; AtomicString uri; OwnPtr parent; diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index fd5841f..9142e67 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -1965,7 +1965,8 @@ void CSSParser::addFillValue(RefPtr& lval, PassRefPtr rval) static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr& cssValue) { - if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddingBox || parserValue->id == CSSValueWebkitText) { + if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddingBox + || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueWebkitText) { cssValue = CSSPrimitiveValue::createIdentifier(parserValue->id); return true; } diff --git a/Source/WebCore/css/CSSParser.h b/Source/WebCore/css/CSSParser.h index 496a21a..d326812 100644 --- a/Source/WebCore/css/CSSParser.h +++ b/Source/WebCore/css/CSSParser.h @@ -340,7 +340,8 @@ namespace WebCore { int cssPropertyID(const String&); int cssValueKeywordID(const CSSParserString&); - class ShorthandScope : public FastAllocBase { + class ShorthandScope { + WTF_MAKE_FAST_ALLOCATED; public: ShorthandScope(CSSParser* parser, int propId) : m_parser(parser) { diff --git a/Source/WebCore/css/CSSParserValues.h b/Source/WebCore/css/CSSParserValues.h index 993ae28..996e783 100644 --- a/Source/WebCore/css/CSSParserValues.h +++ b/Source/WebCore/css/CSSParserValues.h @@ -59,7 +59,8 @@ struct CSSParserValue { PassRefPtr createCSSValue(); }; -class CSSParserValueList : public FastAllocBase { +class CSSParserValueList { + WTF_MAKE_FAST_ALLOCATED; public: CSSParserValueList() : m_current(0) @@ -83,7 +84,9 @@ private: Vector m_values; }; -struct CSSParserFunction : FastAllocBase { +struct CSSParserFunction { + WTF_MAKE_FAST_ALLOCATED; +public: CSSParserString name; OwnPtr args; }; diff --git a/Source/WebCore/css/CSSProperty.h b/Source/WebCore/css/CSSProperty.h index 106171d..10e593c 100644 --- a/Source/WebCore/css/CSSProperty.h +++ b/Source/WebCore/css/CSSProperty.h @@ -29,7 +29,8 @@ namespace WebCore { -class CSSProperty : public FastAllocBase { +class CSSProperty { + WTF_MAKE_FAST_ALLOCATED; public: CSSProperty(int propID, PassRefPtr value, bool important = false, int shorthandID = 0, bool implicit = false) : m_id(propID) diff --git a/Source/WebCore/css/CSSSelector.cpp b/Source/WebCore/css/CSSSelector.cpp index 400dd40..ca3814a 100644 --- a/Source/WebCore/css/CSSSelector.cpp +++ b/Source/WebCore/css/CSSSelector.cpp @@ -37,8 +37,10 @@ namespace WebCore { using namespace HTMLNames; -class CSSSelectorBag : public Noncopyable { +class CSSSelectorBag { + WTF_MAKE_NONCOPYABLE(CSSSelectorBag); public: + CSSSelectorBag() { } ~CSSSelectorBag() { ASSERT(isEmpty()); diff --git a/Source/WebCore/css/CSSSelector.h b/Source/WebCore/css/CSSSelector.h index 1101eed..b930353 100644 --- a/Source/WebCore/css/CSSSelector.h +++ b/Source/WebCore/css/CSSSelector.h @@ -33,7 +33,8 @@ namespace WebCore { class CSSSelectorBag; // this class represents a selector for a StyleRule - class CSSSelector : public Noncopyable { + class CSSSelector { + WTF_MAKE_NONCOPYABLE(CSSSelector); WTF_MAKE_FAST_ALLOCATED; public: CSSSelector() : m_relation(Descendant) @@ -278,6 +279,7 @@ namespace WebCore { return m_match == PseudoElement; } bool isUnknownPseudoElement() const; + bool isSiblingSelector() const; Relation relation() const { return static_cast(m_relation); } @@ -305,7 +307,9 @@ namespace WebCore { unsigned specificityForPage() const; void extractPseudoType() const; - struct RareData : Noncopyable { + struct RareData { + WTF_MAKE_NONCOPYABLE(RareData); WTF_MAKE_FAST_ALLOCATED; + public: RareData(PassOwnPtr tagHistory) : m_a(0) , m_b(0) @@ -350,6 +354,24 @@ inline bool CSSSelector::isUnknownPseudoElement() const return m_match == PseudoElement && m_pseudoType == PseudoUnknown; } +inline bool CSSSelector::isSiblingSelector() const +{ + PseudoType type = pseudoType(); + return m_relation == DirectAdjacent + || m_relation == IndirectAdjacent + || type == PseudoEmpty + || type == PseudoFirstChild + || type == PseudoFirstOfType + || type == PseudoLastChild + || type == PseudoLastOfType + || type == PseudoOnlyChild + || type == PseudoOnlyOfType + || type == PseudoNthChild + || type == PseudoNthOfType + || type == PseudoNthLastChild + || type == PseudoNthLastOfType; +} + } // namespace WebCore #endif // CSSSelector_h diff --git a/Source/WebCore/css/CSSSelectorList.h b/Source/WebCore/css/CSSSelectorList.h index 7adc6b9..abd9bc8 100644 --- a/Source/WebCore/css/CSSSelectorList.h +++ b/Source/WebCore/css/CSSSelectorList.h @@ -27,11 +27,11 @@ #define CSSSelectorList_h #include "CSSSelector.h" -#include namespace WebCore { -class CSSSelectorList : public Noncopyable { +class CSSSelectorList { + WTF_MAKE_NONCOPYABLE(CSSSelectorList); WTF_MAKE_FAST_ALLOCATED; public: CSSSelectorList() : m_selectorArray(0) { } ~CSSSelectorList(); diff --git a/Source/WebCore/css/CSSStyleSelector.cpp b/Source/WebCore/css/CSSStyleSelector.cpp index b98b90d..5a21615 100644 --- a/Source/WebCore/css/CSSStyleSelector.cpp +++ b/Source/WebCore/css/CSSStyleSelector.cpp @@ -352,7 +352,8 @@ if (id == propID) { \ return; \ } -class CSSRuleData : public Noncopyable { +class CSSRuleData { + WTF_MAKE_NONCOPYABLE(CSSRuleData); public: CSSRuleData(unsigned pos, CSSStyleRule* r, CSSSelector* sel, CSSRuleData* prev = 0) : m_position(pos) @@ -380,7 +381,8 @@ private: CSSRuleData* m_next; }; -class CSSRuleDataList : public Noncopyable { +class CSSRuleDataList { + WTF_MAKE_NONCOPYABLE(CSSRuleDataList); public: CSSRuleDataList(unsigned pos, CSSStyleRule* rule, CSSSelector* sel) : m_first(new CSSRuleData(pos, rule, sel)) @@ -400,8 +402,8 @@ public: } } - CSSRuleData* first() { return m_first; } - CSSRuleData* last() { return m_last; } + CSSRuleData* first() const { return m_first; } + CSSRuleData* last() const { return m_last; } void append(unsigned pos, CSSStyleRule* rule, CSSSelector* sel) { m_last = new CSSRuleData(pos, rule, sel, m_last); } @@ -410,7 +412,8 @@ private: CSSRuleData* m_last; }; -class CSSRuleSet : public Noncopyable { +class CSSRuleSet { + WTF_MAKE_NONCOPYABLE(CSSRuleSet); public: CSSRuleSet(); ~CSSRuleSet(); @@ -425,6 +428,8 @@ public: void addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map, CSSStyleRule* rule, CSSSelector* sel); + void collectIdsAndSiblingRules(HashSet& ids, OwnPtr& siblingRules) const; + CSSRuleDataList* getIDRules(AtomicStringImpl* key) { return m_idRules.get(key); } CSSRuleDataList* getClassRules(AtomicStringImpl* key) { return m_classRules.get(key); } CSSRuleDataList* getTagRules(AtomicStringImpl* key) { return m_tagRules.get(key); } @@ -448,6 +453,8 @@ static CSSRuleSet* defaultQuirksStyle; static CSSRuleSet* defaultPrintStyle; static CSSRuleSet* defaultViewSourceStyle; static CSSStyleSheet* simpleDefaultStyleSheet; + +static CSSRuleSet* siblingRulesInDefaultStyle; RenderStyle* CSSStyleSelector::s_styleNotYetAvailable; @@ -459,11 +466,31 @@ static void loadSimpleDefaultStyle(); // FIXME: It would be nice to use some mechanism that guarantees this is in sync with the real UA stylesheet. static const char* simpleUserAgentStyleSheet = "html,body,div{display:block}body{margin:8px}div:focus,span:focus{outline:auto 5px -webkit-focus-ring-color}a:-webkit-any-link{color:-webkit-link;text-decoration:underline}a:-webkit-any-link:active{color:-webkit-activelink}"; -static bool elementCanUseSimpleDefaultStyle(Element* e) +static inline bool elementCanUseSimpleDefaultStyle(Element* e) { return e->hasTagName(htmlTag) || e->hasTagName(bodyTag) || e->hasTagName(divTag) || e->hasTagName(spanTag) || e->hasTagName(brTag) || e->hasTagName(aTag); } +static inline void collectSiblingRulesInDefaultStyle() +{ + OwnPtr siblingRules; + HashSet ids; + defaultStyle->collectIdsAndSiblingRules(ids, siblingRules); + ASSERT(ids.isEmpty()); + delete siblingRulesInDefaultStyle; + siblingRulesInDefaultStyle = siblingRules.leakPtr(); +} + +static inline void assertNoSiblingRulesInDefaultStyle() +{ +#ifndef NDEBUG + if (siblingRulesInDefaultStyle) + return; + collectSiblingRulesInDefaultStyle(); + ASSERT(!siblingRulesInDefaultStyle); +#endif +} + static const MediaQueryEvaluator& screenEval() { DEFINE_STATIC_LOCAL(const MediaQueryEvaluator, staticScreenEval, ("screen")); @@ -549,6 +576,16 @@ CSSStyleSelector::CSSStyleSelector(Document* document, StyleSheetList* styleShee if (sheet->isCSSStyleSheet() && !sheet->disabled()) m_authorStyle->addRulesFromSheet(static_cast(sheet), *m_medium, this); } + + // Collect all ids and rules using sibling selectors (:first-child and similar) + // in the current set of stylesheets. Style sharing code uses this information to reject + // sharing candidates. + // Usually there are no sibling rules in the default style but the MathML sheet has some. + if (siblingRulesInDefaultStyle) + siblingRulesInDefaultStyle->collectIdsAndSiblingRules(m_idsInRules, m_siblingRules); + m_authorStyle->collectIdsAndSiblingRules(m_idsInRules, m_siblingRules); + if (m_userStyle) + m_userStyle->collectIdsAndSiblingRules(m_idsInRules, m_siblingRules); if (document->renderer() && document->renderer()->style()) document->renderer()->style()->font().update(fontSelector()); @@ -944,40 +981,52 @@ static const unsigned cStyleSearchThreshold = 10; Node* CSSStyleSelector::locateCousinList(Element* parent, unsigned depth) const { - if (parent && parent->isStyledElement()) { - StyledElement* p = static_cast(parent); - if (!p->inlineStyleDecl() && !p->hasID()) { - Node* r = p->previousSibling(); - unsigned subcount = 0; - RenderStyle* st = p->renderStyle(); - while (r) { - if (r->renderStyle() == st) - return r->lastChild(); - if (subcount++ == cStyleSearchThreshold) - return 0; - r = r->previousSibling(); - } - if (!r && depth < cStyleSearchThreshold) - r = locateCousinList(parent->parentElement(), depth + 1); - while (r) { - if (r->renderStyle() == st) - return r->lastChild(); - if (subcount++ == cStyleSearchThreshold) - return 0; - r = r->previousSibling(); - } - } + if (!parent || !parent->isStyledElement()) + return 0; + StyledElement* p = static_cast(parent); + if (p->inlineStyleDecl()) + return 0; + if (p->hasID() && m_idsInRules.contains(p->idForStyleResolution().impl())) + return 0; + Node* r = p->previousSibling(); + unsigned subcount = 0; + RenderStyle* st = p->renderStyle(); + while (r) { + if (r->renderStyle() == st) + return r->lastChild(); + if (subcount++ == cStyleSearchThreshold) + return 0; + r = r->previousSibling(); + } + if (!r && depth < cStyleSearchThreshold) + r = locateCousinList(parent->parentElement(), depth + 1); + while (r) { + if (r->renderStyle() == st) + return r->lastChild(); + if (subcount++ == cStyleSearchThreshold) + return 0; + r = r->previousSibling(); } return 0; } +bool CSSStyleSelector::matchesSiblingRules() +{ + int firstSiblingRule = -1, lastSiblingRule = -1; + matchRules(m_siblingRules.get(), firstSiblingRule, lastSiblingRule, false); + if (m_matchedDecls.isEmpty()) + return false; + m_matchedDecls.clear(); + return true; +} + bool CSSStyleSelector::canShareStyleWithElement(Node* n) const { if (n->isStyledElement()) { StyledElement* s = static_cast(n); RenderStyle* style = s->renderStyle(); if (style && !style->unique() && - (s->tagQName() == m_element->tagQName()) && !s->hasID() && + (s->tagQName() == m_element->tagQName()) && (s->hasClass() == m_element->hasClass()) && !s->inlineStyleDecl() && (s->hasMappedAttributes() == m_styledElement->hasMappedAttributes()) && (s->isLink() == m_element->isLink()) && @@ -992,6 +1041,10 @@ bool CSSStyleSelector::canShareStyleWithElement(Node* n) const (s->fastGetAttribute(langAttr) == m_element->fastGetAttribute(langAttr)) && (s->fastGetAttribute(readonlyAttr) == m_element->fastGetAttribute(readonlyAttr)) && (s->fastGetAttribute(cellpaddingAttr) == m_element->fastGetAttribute(cellpaddingAttr))) { + + if (s->hasID() && m_idsInRules.contains(s->idForStyleResolution().impl())) + return 0; + bool isControl = s->isFormControlElement(); if (isControl != m_element->isFormControlElement()) return false; @@ -1062,32 +1115,46 @@ bool CSSStyleSelector::canShareStyleWithElement(Node* n) const } return false; } - -ALWAYS_INLINE RenderStyle* CSSStyleSelector::locateSharedStyle() const + +inline Node* CSSStyleSelector::findSiblingForStyleSharing(Node* node, unsigned& count) const { - if (m_styledElement && !m_styledElement->inlineStyleDecl() && !m_styledElement->hasID() && !m_styledElement->document()->usesSiblingRules()) { - // Check previous siblings. - unsigned count = 0; - Node* n; - for (n = m_element->previousSibling(); n && !n->isElementNode(); n = n->previousSibling()) { } - while (n) { - if (canShareStyleWithElement(n)) - return n->renderStyle(); - if (count++ == cStyleSearchThreshold) - return 0; - for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling()) { } - } - if (!n) - n = locateCousinList(m_element->parentElement()); - while (n) { - if (canShareStyleWithElement(n)) - return n->renderStyle(); - if (count++ == cStyleSearchThreshold) - return 0; - for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling()) { } - } + for (; node; node = node->previousSibling()) { + if (!node->isElementNode()) + continue; + if (canShareStyleWithElement(node)) + break; + if (count++ == cStyleSearchThreshold) + return 0; } - return 0; + return node; +} + +ALWAYS_INLINE RenderStyle* CSSStyleSelector::locateSharedStyle() +{ + if (!m_styledElement || !m_parentStyle) + return 0; + // If the element has inline style it is probably unique. + if (m_styledElement->inlineStyleDecl()) + return 0; + // Ids stop style sharing if they show up in the stylesheets. + if (m_styledElement->hasID() && m_idsInRules.contains(m_styledElement->idForStyleResolution().impl())) + return 0; + // Check previous siblings. + unsigned count = 0; + Node* shareNode = findSiblingForStyleSharing(m_styledElement->previousSibling(), count); + if (!shareNode) { + Node* cousinList = locateCousinList(m_styledElement->parentElement()); + shareNode = findSiblingForStyleSharing(cousinList, count); + if (!shareNode) + return 0; + } + // Can't share if sibling rules apply. This is checked at the end as it should rarely fail. + if (matchesSiblingRules()) + return 0; + // Tracking child index requires unique style for each node. This may get set by the sibling rule match above. + if (m_parentStyle->childrenAffectedByPositionalRules()) + return 0; + return shareNode->renderStyle(); } void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule) @@ -1180,12 +1247,12 @@ PassRefPtr CSSStyleSelector::styleForElement(Element* e, RenderStyl } initElement(e); + initForStyleResolve(e, defaultParent); if (allowSharing) { RenderStyle* sharedStyle = locateSharedStyle(); if (sharedStyle) return sharedStyle; } - initForStyleResolve(e, defaultParent); // Compute our style allowing :visited to match first. RefPtr visitedStyle; @@ -1227,6 +1294,7 @@ PassRefPtr CSSStyleSelector::styleForElement(Element* e, RenderStyl #if ENABLE(FULLSCREEN_API) loadFullScreenRulesIfNeeded(e->document()); #endif + assertNoSiblingRulesInDefaultStyle(); } #if ENABLE(SVG) @@ -1237,6 +1305,7 @@ PassRefPtr CSSStyleSelector::styleForElement(Element* e, RenderStyl CSSStyleSheet* svgSheet = parseUASheet(svgUserAgentStyleSheet, sizeof(svgUserAgentStyleSheet)); defaultStyle->addRulesFromSheet(svgSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(svgSheet, printEval()); + assertNoSiblingRulesInDefaultStyle(); } #endif @@ -1248,6 +1317,8 @@ PassRefPtr CSSStyleSelector::styleForElement(Element* e, RenderStyl CSSStyleSheet* mathMLSheet = parseUASheet(mathmlUserAgentStyleSheet, sizeof(mathmlUserAgentStyleSheet)); defaultStyle->addRulesFromSheet(mathMLSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(mathMLSheet, printEval()); + // There are some sibling rules here. + collectSiblingRulesInDefaultStyle(); } #endif @@ -1259,6 +1330,7 @@ PassRefPtr CSSStyleSelector::styleForElement(Element* e, RenderStyl CSSStyleSheet* wmlSheet = parseUASheet(wmlUserAgentStyleSheet, sizeof(wmlUserAgentStyleSheet)); defaultStyle->addRulesFromSheet(wmlSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(wmlSheet, printEval()); + assertNoSiblingRulesInDefaultStyle(); } #endif @@ -1270,6 +1342,7 @@ PassRefPtr CSSStyleSelector::styleForElement(Element* e, RenderStyl CSSStyleSheet* mediaControlsSheet = parseUASheet(mediaRules); defaultStyle->addRulesFromSheet(mediaControlsSheet, screenEval()); defaultPrintStyle->addRulesFromSheet(mediaControlsSheet, printEval()); + assertNoSiblingRulesInDefaultStyle(); } #endif @@ -2794,7 +2867,7 @@ bool CSSStyleSelector::SelectorChecker::checkScrollbarPseudoClass(CSSSelector* s return false; } case CSSSelector::PseudoCornerPresent: - return scrollbar->client()->scrollbarCornerPresent(); + return scrollbar->scrollableArea()->scrollbarCornerPresent(); default: return false; } @@ -2927,6 +3000,47 @@ void CSSRuleSet::addStyleRule(CSSStyleRule* rule) } } +static void collectIdsAndSiblingRulesFromList(HashSet& ids, OwnPtr& siblingRules, const CSSRuleDataList* rules) +{ + for (CSSRuleData* data = rules->first(); data; data = data->next()) { + bool foundSiblingSelector = false; + for (CSSSelector* selector = data->selector(); selector; selector = selector->tagHistory()) { + if (selector->m_match == CSSSelector::Id && !selector->m_value.isEmpty()) + ids.add(selector->m_value.impl()); + if (CSSSelector* simpleSelector = selector->simpleSelector()) { + ASSERT(!simpleSelector->simpleSelector()); + if (simpleSelector->m_match == CSSSelector::Id && !simpleSelector->m_value.isEmpty()) + ids.add(simpleSelector->m_value.impl()); + } + if (selector->isSiblingSelector()) + foundSiblingSelector = true; + } + if (foundSiblingSelector) { + if (!siblingRules) + siblingRules = adoptPtr(new CSSRuleSet); + siblingRules->addRule(data->rule(), data->selector()); + } + } +} + +void CSSRuleSet::collectIdsAndSiblingRules(HashSet& ids, OwnPtr& siblingRules) const +{ + AtomRuleMap::const_iterator end = m_idRules.end(); + for (AtomRuleMap::const_iterator it = m_idRules.begin(); it != end; ++it) + collectIdsAndSiblingRulesFromList(ids, siblingRules, it->second); + end = m_classRules.end(); + for (AtomRuleMap::const_iterator it = m_classRules.begin(); it != end; ++it) + collectIdsAndSiblingRulesFromList(ids, siblingRules, it->second); + end = m_tagRules.end(); + for (AtomRuleMap::const_iterator it = m_tagRules.begin(); it != end; ++it) + collectIdsAndSiblingRulesFromList(ids, siblingRules, it->second); + end = m_pseudoRules.end(); + for (AtomRuleMap::const_iterator it = m_pseudoRules.begin(); it != end; ++it) + collectIdsAndSiblingRulesFromList(ids, siblingRules, it->second); + if (m_universalRules) + collectIdsAndSiblingRulesFromList(ids, siblingRules, m_universalRules.get()); +} + // ------------------------------------------------------------------------------------- // this is mostly boring stuff on how to apply a certain rule to the renderstyle... diff --git a/Source/WebCore/css/CSSStyleSelector.h b/Source/WebCore/css/CSSStyleSelector.h index b57ba13..e035af2 100644 --- a/Source/WebCore/css/CSSStyleSelector.h +++ b/Source/WebCore/css/CSSStyleSelector.h @@ -69,7 +69,8 @@ class StyledElement; class WebKitCSSKeyframeRule; class WebKitCSSKeyframesRule; -class MediaQueryResult : public Noncopyable { +class MediaQueryResult { + WTF_MAKE_NONCOPYABLE(MediaQueryResult); WTF_MAKE_FAST_ALLOCATED; public: MediaQueryResult(const MediaQueryExp& expr, bool result) : m_expression(expr) @@ -82,7 +83,8 @@ public: }; // This class selects a RenderStyle for a given element based on a collection of stylesheets. - class CSSStyleSelector : public Noncopyable { + class CSSStyleSelector { + WTF_MAKE_NONCOPYABLE(CSSStyleSelector); WTF_MAKE_FAST_ALLOCATED; public: CSSStyleSelector(Document*, StyleSheetList* authorSheets, CSSStyleSheet* mappedElementSheet, CSSStyleSheet* pageUserSheet, const Vector >* pageGroupUserSheets, @@ -108,8 +110,10 @@ public: private: void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO); void initElement(Element*); - ALWAYS_INLINE RenderStyle* locateSharedStyle() const; + RenderStyle* locateSharedStyle(); + bool matchesSiblingRules(); Node* locateCousinList(Element* parent, unsigned depth = 1) const; + Node* findSiblingForStyleSharing(Node*, unsigned& count) const; bool canShareStyleWithElement(Node*) const; RenderStyle* style() const { return m_style.get(); } @@ -197,6 +201,9 @@ public: OwnPtr m_authorStyle; OwnPtr m_userStyle; + + OwnPtr m_siblingRules; + HashSet m_idsInRules; bool m_hasUAAppearance; BorderData m_borderData; @@ -209,7 +216,8 @@ public: public: static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; } - class SelectorChecker : public Noncopyable { + class SelectorChecker { + WTF_MAKE_NONCOPYABLE(SelectorChecker); public: SelectorChecker(Document*, bool strictParsing); diff --git a/Source/WebCore/css/MediaQuery.h b/Source/WebCore/css/MediaQuery.h index 281009b..a638ac9 100644 --- a/Source/WebCore/css/MediaQuery.h +++ b/Source/WebCore/css/MediaQuery.h @@ -37,7 +37,8 @@ namespace WebCore { class MediaQueryExp; -class MediaQuery : public Noncopyable { +class MediaQuery { + WTF_MAKE_NONCOPYABLE(MediaQuery); WTF_MAKE_FAST_ALLOCATED; public: enum Restrictor { Only, Not, None diff --git a/Source/WebCore/css/MediaQueryEvaluator.h b/Source/WebCore/css/MediaQueryEvaluator.h index 00ac394..07c4d0d 100644 --- a/Source/WebCore/css/MediaQueryEvaluator.h +++ b/Source/WebCore/css/MediaQueryEvaluator.h @@ -49,7 +49,8 @@ class MediaQueryExp; * the device characteristics are not known. This can be used to prune the loading * of stylesheets to only those which are probable to match. */ -class MediaQueryEvaluator : public Noncopyable { +class MediaQueryEvaluator { + WTF_MAKE_NONCOPYABLE(MediaQueryEvaluator); WTF_MAKE_FAST_ALLOCATED; public: /** Creates evaluator which evaluates only simple media queries * Evaluator returns true for "all", and returns value of \mediaFeatureResult diff --git a/Source/WebCore/css/MediaQueryExp.h b/Source/WebCore/css/MediaQueryExp.h index 72d3fff..7e4d477 100644 --- a/Source/WebCore/css/MediaQueryExp.h +++ b/Source/WebCore/css/MediaQueryExp.h @@ -38,7 +38,8 @@ namespace WebCore { class CSSParserValueList; -class MediaQueryExp : public FastAllocBase { +class MediaQueryExp { + WTF_MAKE_FAST_ALLOCATED; public: static PassOwnPtr create(const AtomicString& mediaFeature, CSSParserValueList* values); ~MediaQueryExp(); diff --git a/Source/WebCore/css/WebKitCSSMatrix.cpp b/Source/WebCore/css/WebKitCSSMatrix.cpp index 7d60f8c..14f6b4e 100644 --- a/Source/WebCore/css/WebKitCSSMatrix.cpp +++ b/Source/WebCore/css/WebKitCSSMatrix.cpp @@ -32,7 +32,6 @@ #include "CSSPropertyNames.h" #include "CSSValueKeywords.h" #include "ExceptionCode.h" -#include "RenderStyle.h" #include namespace WebCore { diff --git a/Source/WebCore/css/mediaControlsQt.css b/Source/WebCore/css/mediaControlsQt.css index 4ea444c..871a5b8 100644 --- a/Source/WebCore/css/mediaControlsQt.css +++ b/Source/WebCore/css/mediaControlsQt.css @@ -32,7 +32,21 @@ audio { width: 400px; } -audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { +audio::-webkit-media-controls-panel { + display: -webkit-box; + -webkit-box-orient: horizontal; + -webkit-box-align: end; + -webkit-user-select: none; + position: absolute; + bottom: 0; + width: 100%; + z-index: 0; + overflow: visible; + height: 100%; + text-align: right; +} + +video::-webkit-media-controls-panel { display: -webkit-box; -webkit-box-orient: horizontal; -webkit-box-align: end; @@ -50,25 +64,61 @@ video:-webkit-full-page-media::-webkit-media-controls-panel { bottom: 0px; } -audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { +audio::-webkit-media-controls-mute-button { width: 12px; height: 12px; padding: 6px; margin: 5px 5px 5px 3px; } -audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { +video::-webkit-media-controls-mute-button { + width: 12px; + height: 12px; + padding: 6px; + margin: 5px 5px 5px 3px; +} + +audio::-webkit-media-controls-play-button { width: 9px; height: 12px; padding: 6px 12px 6px 11px; margin: 5px 3px 5px 5px; } -audio::-webkit-media-controls-timeline-container, video::-webkit-media-controls-timeline-container { +video::-webkit-media-controls-play-button { + width: 9px; + height: 12px; + padding: 6px 12px 6px 11px; + margin: 5px 3px 5px 5px; +} + +audio::-webkit-media-controls-timeline-container { + height: 34px; +} + +video::-webkit-media-controls-timeline-container { height: 34px; } -audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display { +audio::-webkit-media-controls-current-time-display { + -webkit-appearance: media-current-time-display; + -webkit-user-select: none; + display: inline-block; + height: 12px; + padding: 6px; + margin: 5px 3px; + + overflow: hidden; + cursor: default; + + text-align: center; + font-size: 10px; + font-family: Verdana; + font-weight: bold; + color: white; +} + +video::-webkit-media-controls-current-time-display { -webkit-appearance: media-current-time-display; -webkit-user-select: none; display: inline-block; @@ -86,24 +136,41 @@ audio::-webkit-media-controls-current-time-display, video::-webkit-media-control color: white; } -audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display { +audio::-webkit-media-controls-time-remaining-display { + display: none; +} + +video::-webkit-media-controls-time-remaining-display { display: none; } -audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { +audio::-webkit-media-controls-timeline { height: 12px; padding: 6px 8px; margin: 5px 3px; } -audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-controls-volume-slider-container { +video::-webkit-media-controls-timeline { + height: 12px; + padding: 6px 8px; + margin: 5px 3px; +} + +audio::-webkit-media-controls-volume-slider-container { + -webkit-appearance: media-volume-slider-container; + position: absolute; + height: 103px; + width: 24px; +} + +video::-webkit-media-controls-volume-slider-container { -webkit-appearance: media-volume-slider-container; position: absolute; height: 103px; width: 24px; } -audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volume-slider { +audio::-webkit-media-controls-volume-slider { -webkit-appearance: media-volume-slider; display: inline; position: absolute; @@ -114,27 +181,62 @@ audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volum margin: 0 0 3px 0; } -audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { +video::-webkit-media-controls-volume-slider { + -webkit-appearance: media-volume-slider; + display: inline; + position: absolute; + + width: 12px; + padding: 6px; + height: 88px; + margin: 0 0 3px 0; +} + +audio::-webkit-media-controls-seek-back-button { + display: none; +} + +video::-webkit-media-controls-seek-back-button { + display: none; +} + +audio::-webkit-media-controls-seek-forward-button { + display: none; +} + +video::-webkit-media-controls-seek-forward-button { + display: none; +} + +audio::-webkit-media-controls-fullscreen-button { + display: none; +} + +video::-webkit-media-controls-fullscreen-button { + display: none; +} + +audio::-webkit-media-controls-rewind-button { display: none; } -audio::-webkit-media-controls-seek-forward-button, video::-webkit-media-controls-seek-forward-button { +video::-webkit-media-controls-rewind-button { display: none; } -audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button { +audio::-webkit-media-controls-return-to-realtime-button { display: none; } -audio::-webkit-media-controls-rewind-button, video::-webkit-media-controls-rewind-button { +video::-webkit-media-controls-return-to-realtime-button { display: none; } -audio::-webkit-media-controls-return-to-realtime-button, video::-webkit-media-controls-return-to-realtime-button { +audio::-webkit-media-controls-toggle-closed-captions-button { display: none; } -audio::-webkit-media-controls-toggle-closed-captions-button, video::-webkit-media-controls-toggle-closed-captions-button { +video::-webkit-media-controls-toggle-closed-captions-button { display: none; } diff --git a/Source/WebCore/css/mediaControlsQtFullscreen.css b/Source/WebCore/css/mediaControlsQtFullscreen.css index d191331..35cbf75 100644 --- a/Source/WebCore/css/mediaControlsQtFullscreen.css +++ b/Source/WebCore/css/mediaControlsQtFullscreen.css @@ -21,26 +21,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -audio { - height: 34px; - width: 400px; -} - -audio::-webkit-media-controls-panel { - display: -webkit-box; - -webkit-box-orient: horizontal; - -webkit-box-align: end; - -webkit-user-select: none; - position: absolute; - bottom: 0; - width: 100%; - z-index: 0; - overflow: visible; - height: 100%; - text-align: right; -} - video::-webkit-media-controls-panel { /* The control panel is only play button for full screen */ display: -webkit-box; @@ -54,24 +34,10 @@ video:-webkit-full-page-media::-webkit-media-controls-panel { display: none; } -audio::-webkit-media-controls-mute-button { - width: 12px; - height: 12px; - padding: 6px; - margin: 5px 5px 5px 3px; -} - video::-webkit-media-controls-mute-button { display: none; } -audio::-webkit-media-controls-play-button { - width: 9px; - height: 12px; - padding: 6px 12px 6px 11px; - margin: 5px 3px 5px 5px; -} - video::-webkit-media-controls-play-button { display: -webkit-box; -webkit-box-align: center; @@ -81,110 +47,55 @@ video::-webkit-media-controls-play-button { padding: 20px; } -audio::-webkit-media-controls-timeline-container { - height: 34px; -} - video::-webkit-media-controls-timeline-container { display: none; } -audio::-webkit-media-controls-current-time-display { - -webkit-appearance: media-current-time-display; - -webkit-user-select: none; - display: inline-block; - height: 12px; - padding: 6px; - margin: 5px 3px; - - overflow: hidden; - cursor: default; - - text-align: center; - font-size: 10px; - font-family: Verdana; - font-weight: bold; - color: white; -} - video::-webkit-media-controls-current-time-display { -webkit-appearance: media-current-time-display; -webkit-user-select: none; display: none; } -audio::-webkit-media-controls-time-remaining-display, video::-webkit-media-controls-time-remaining-display { +video::-webkit-media-controls-time-remaining-display { display: none; } -audio::-webkit-media-controls-timeline { - height: 12px; - padding: 6px 8px; - margin: 5px 3px; -} - video::-webkit-media-controls-timeline { display: none; } -audio::-webkit-media-controls-volume-slider-container { - -webkit-appearance: media-volume-slider-container; - position: absolute; - height: 103px; - width: 24px; -} - video::-webkit-media-controls-volume-slider-container { -webkit-appearance: media-volume-slider-container; display: none; } -audio::-webkit-media-controls-volume-slider { - -webkit-appearance: media-volume-slider; - display: inline; - position: absolute; - - width: 12px; - padding: 6px; - height: 88px; - margin: 0 0 3px 0; -} - video::-webkit-media-controls-volume-slider { -webkit-appearance: media-volume-slider; display: none; } -audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { +video::-webkit-media-controls-seek-back-button { display: none; } -audio::-webkit-media-controls-seek-forward-button, video::-webkit-media-controls-seek-forward-button { +video::-webkit-media-controls-seek-forward-button { display: none; } -audio::-webkit-media-controls-fullscreen-button { - position: absolute; - top: 0px; - right: 0px; - width: 12px; - height: 12px; - padding: 6px; - margin: 5px 5px 5px 3px; -} - video::-webkit-media-controls-fullscreen-button { display: none; } -audio::-webkit-media-controls-rewind-button, video::-webkit-media-controls-rewind-button { +video::-webkit-media-controls-rewind-button { display: none; } -audio::-webkit-media-controls-return-to-realtime-button, video::-webkit-media-controls-return-to-realtime-button { +video::-webkit-media-controls-return-to-realtime-button { display: none; } -audio::-webkit-media-controls-toggle-closed-captions-button, video::-webkit-media-controls-toggle-closed-captions-button { +video::-webkit-media-controls-toggle-closed-captions-button { display: none; } + -- cgit v1.1