diff options
Diffstat (limited to 'WebCore/css')
-rw-r--r-- | WebCore/css/CSSCanvasValue.cpp | 2 | ||||
-rw-r--r-- | WebCore/css/CSSFontFaceSource.h | 2 | ||||
-rw-r--r-- | WebCore/css/CSSFontSelector.cpp | 2 | ||||
-rw-r--r-- | WebCore/css/CSSFontSelector.h | 2 | ||||
-rw-r--r-- | WebCore/css/CSSNamespace.h | 2 | ||||
-rw-r--r-- | WebCore/css/CSSParser.cpp | 84 | ||||
-rw-r--r-- | WebCore/css/CSSParser.h | 2 | ||||
-rw-r--r-- | WebCore/css/CSSParserValues.h | 2 | ||||
-rw-r--r-- | WebCore/css/CSSSelector.cpp | 70 | ||||
-rw-r--r-- | WebCore/css/CSSSelector.h | 5 | ||||
-rw-r--r-- | WebCore/css/CSSStyleDeclaration.cpp | 6 | ||||
-rw-r--r-- | WebCore/css/CSSStyleSelector.cpp | 70 | ||||
-rw-r--r-- | WebCore/css/CSSStyleSelector.h | 2 | ||||
-rw-r--r-- | WebCore/css/CSSVariablesDeclaration.h | 2 | ||||
-rw-r--r-- | WebCore/css/MediaFeatureNames.h | 2 | ||||
-rw-r--r-- | WebCore/css/MediaQueryExp.h | 2 | ||||
-rw-r--r-- | WebCore/css/WebKitCSSKeyframesRule.h | 2 | ||||
-rw-r--r-- | WebCore/css/mathml.css | 3 | ||||
-rw-r--r-- | WebCore/css/mediaControlsQt.css | 2 |
19 files changed, 172 insertions, 92 deletions
diff --git a/WebCore/css/CSSCanvasValue.cpp b/WebCore/css/CSSCanvasValue.cpp index 0c1c3f9..767c11e 100644 --- a/WebCore/css/CSSCanvasValue.cpp +++ b/WebCore/css/CSSCanvasValue.cpp @@ -90,7 +90,7 @@ Image* CSSCanvasValue::image(RenderObject* renderer, const IntSize& /*size*/) HTMLCanvasElement* elt = element(renderer->document()); if (!elt || !elt->buffer()) return 0; - return elt->buffer()->image(); + return elt->copiedImage(); } } // namespace WebCore diff --git a/WebCore/css/CSSFontFaceSource.h b/WebCore/css/CSSFontFaceSource.h index 278ba72..4ec54d6 100644 --- a/WebCore/css/CSSFontFaceSource.h +++ b/WebCore/css/CSSFontFaceSource.h @@ -26,10 +26,10 @@ #ifndef CSSFontFaceSource_h #define CSSFontFaceSource_h -#include "AtomicString.h" #include "CachedResourceClient.h" #include "CachedResourceHandle.h" #include <wtf/HashMap.h> +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/css/CSSFontSelector.cpp b/WebCore/css/CSSFontSelector.cpp index 752798d..b98dcae 100644 --- a/WebCore/css/CSSFontSelector.cpp +++ b/WebCore/css/CSSFontSelector.cpp @@ -27,7 +27,6 @@ #include "config.h" #include "CSSFontSelector.h" -#include "AtomicString.h" #include "CachedFont.h" #include "CSSFontFace.h" #include "CSSFontFaceRule.h" @@ -48,6 +47,7 @@ #include "RenderObject.h" #include "Settings.h" #include "SimpleFontData.h" +#include <wtf/text/AtomicString.h> #if ENABLE(SVG) #include "SVGFontFaceElement.h" diff --git a/WebCore/css/CSSFontSelector.h b/WebCore/css/CSSFontSelector.h index d9cce1c..abf82cd 100644 --- a/WebCore/css/CSSFontSelector.h +++ b/WebCore/css/CSSFontSelector.h @@ -27,10 +27,10 @@ #define CSSFontSelector_h #include "FontSelector.h" -#include "StringHash.h" #include <wtf/Forward.h> #include <wtf/HashMap.h> #include <wtf/RefPtr.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/css/CSSNamespace.h b/WebCore/css/CSSNamespace.h index 0a1119d..d7fab4c 100644 --- a/WebCore/css/CSSNamespace.h +++ b/WebCore/css/CSSNamespace.h @@ -22,7 +22,7 @@ #ifndef CSSNamespace_h #define CSSNamespace_h -#include "AtomicString.h" +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index cdd6294..7528cd8 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -66,12 +66,12 @@ #include "Pair.h" #include "Rect.h" #include "ShadowValue.h" -#include "StringBuffer.h" #include "WebKitCSSKeyframeRule.h" #include "WebKitCSSKeyframesRule.h" #include "WebKitCSSTransformValue.h" #include <limits.h> #include <wtf/dtoa.h> +#include <wtf/text/StringBuffer.h> #if ENABLE(DASHBOARD_SUPPORT) #include "DashboardRegion.h" @@ -319,7 +319,7 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int id, cons // possible to set up a default color. bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) { - // First try creating a color specified by name, rgb() or "#" syntax. + // First try creating a color specified by name, rgba(), rgb() or "#" syntax. if (parseColor(string, color, strict)) return true; @@ -3830,6 +3830,63 @@ static inline bool parseColorInt(const UChar*& string, const UChar* end, UChar t return true; } +static inline bool isTenthAlpha(const UChar* string, const int length) +{ + // "0.X" + if (length == 3 && string[0] == '0' && string[1] == '.' && isASCIIDigit(string[2])) + return true; + + // ".X" + if (length == 2 && string[0] == '.' && isASCIIDigit(string[1])) + return true; + + return false; +} + +static inline bool parseAlphaValue(const UChar*& string, const UChar* end, UChar terminator, int& value) +{ + while (string != end && isCSSWhitespace(*string)) + string++; + + value = 0; + + int length = end - string; + if (length < 2) + return false; + + if (string[0] != '0' && string[0] != '1' && string[0] != '.') + return false; + + if (string[length - 1] != terminator) + return false; + + if (length == 2 && string[0] != '.') { + value = string[0] == '1' ? 255 : 0; + string = end; + return true; + } + + if (isTenthAlpha(string, length - 1)) { + static const int tenthAlphaValues[] = { 0, 25, 51, 76, 102, 127, 153, 179, 204, 230 }; + value = tenthAlphaValues[string[length - 2] - '0']; + string = end; + return true; + } + + Vector<char, 8> bytes(length + 1); + for (int i = 0; i < length; ++i) { + if (!isASCIIDigit(string[i]) && string[i] != '.' && string[i] != terminator) + return false; + bytes[i] = string[i]; + } + bytes[length] = '\0'; + char* foundTerminator; + double d = WTF::strtod(bytes.data(), &foundTerminator); + value = static_cast<int>(d * nextafter(256.0, 0.0)); + string += (foundTerminator - bytes.data()) + 1; + return *foundTerminator == terminator; +} + bool CSSParser::parseColor(const String &name, RGBA32& rgb, bool strict) { const UChar* characters = name.characters(); @@ -3845,6 +3902,28 @@ bool CSSParser::parseColor(const String &name, RGBA32& rgb, bool strict) } } + // Try rgba() syntax. + if (name.startsWith("rgba(")) { + const UChar* current = characters + 5; + const UChar* end = characters + length; + int red; + int green; + int blue; + int alpha; + if (!parseColorInt(current, end, ',', red)) + return false; + if (!parseColorInt(current, end, ',', green)) + return false; + if (!parseColorInt(current, end, ',', blue)) + return false; + if (!parseAlphaValue(current, end, ')', alpha)) + return false; + if (current != end) + return false; + rgb = makeRGBA(red, green, blue, alpha); + return true; + } + // Try rgb() syntax. if (name.startsWith("rgb(")) { const UChar* current = characters + 4; @@ -3863,6 +3942,7 @@ bool CSSParser::parseColor(const String &name, RGBA32& rgb, bool strict) rgb = makeRGB(red, green, blue); return true; } + // Try named colors. Color tc; tc.setNamedColor(name); diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h index 5d76a41..1e233c8 100644 --- a/WebCore/css/CSSParser.h +++ b/WebCore/css/CSSParser.h @@ -23,7 +23,6 @@ #ifndef CSSParser_h #define CSSParser_h -#include "AtomicString.h" #include "Color.h" #include "CSSParserValues.h" #include "CSSSelectorList.h" @@ -31,6 +30,7 @@ #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/Vector.h> +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/css/CSSParserValues.h b/WebCore/css/CSSParserValues.h index a421fe0..5c6f55e 100644 --- a/WebCore/css/CSSParserValues.h +++ b/WebCore/css/CSSParserValues.h @@ -21,7 +21,7 @@ #ifndef CSSParserValues_h #define CSSParserValues_h -#include "AtomicString.h" +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/css/CSSSelector.cpp b/WebCore/css/CSSSelector.cpp index 03974d9..1f336a2 100644 --- a/WebCore/css/CSSSelector.cpp +++ b/WebCore/css/CSSSelector.cpp @@ -67,42 +67,46 @@ private: Vector<CSSSelector*, 16> m_stack; }; -unsigned int CSSSelector::specificity() +unsigned CSSSelector::specificity() const { - if (m_isForPage) - return specificityForPage(); + // make sure the result doesn't overflow + static const unsigned maxValueMask = 0xffffff; + unsigned total = 0; + for (const CSSSelector* selector = this; selector; selector = selector->tagHistory()) { + if (selector->m_isForPage) + return (total + selector->specificityForPage()) & maxValueMask; + total = (total + selector->specificityForOneSelector()) & maxValueMask; + } + return total; +} +inline unsigned CSSSelector::specificityForOneSelector() const +{ // FIXME: Pseudo-elements and pseudo-classes do not have the same specificity. This function // isn't quite correct. - int s = (m_tag.localName() == starAtom ? 0 : 1); + unsigned s = (m_tag.localName() == starAtom ? 0 : 1); switch (m_match) { - case Id: - s += 0x10000; - break; - case Exact: - case Class: - case Set: - case List: - case Hyphen: - case PseudoClass: - case PseudoElement: - case Contain: - case Begin: - case End: - s += 0x100; - case None: - break; + case Id: + s += 0x10000; + break; + case Exact: + case Class: + case Set: + case List: + case Hyphen: + case PseudoClass: + case PseudoElement: + case Contain: + case Begin: + case End: + s += 0x100; + case None: + break; } - - // FIXME: Avoid recursive calls to prevent possible stack overflow. - if (CSSSelector* tagHistory = this->tagHistory()) - s += tagHistory->specificity(); - - // make sure it doesn't overflow - return s & 0xffffff; + return s; } -unsigned CSSSelector::specificityForPage() +unsigned CSSSelector::specificityForPage() const { // See http://dev.w3.org/csswg/css3-page/#cascading-and-page-context unsigned s = (m_tag.localName() == starAtom ? 0 : 4); @@ -902,8 +906,8 @@ bool CSSSelector::RareData::parseNth() m_a = 2; m_b = 0; } else { - int n = argument.find('n'); - if (n != -1) { + size_t n = argument.find('n'); + if (n != notFound) { if (argument[0] == '-') { if (n == 1) m_a = -1; // -n == -1n @@ -914,12 +918,12 @@ bool CSSSelector::RareData::parseNth() else m_a = argument.substring(0, n).toInt(); - int p = argument.find('+', n); - if (p != -1) + size_t p = argument.find('+', n); + if (p != notFound) m_b = argument.substring(p + 1, argument.length() - p - 1).toInt(); else { p = argument.find('-', n); - if (p != -1) + if (p != notFound) m_b = -argument.substring(p + 1, argument.length() - p - 1).toInt(); } } else diff --git a/WebCore/css/CSSSelector.h b/WebCore/css/CSSSelector.h index 34e4af0..e253949 100644 --- a/WebCore/css/CSSSelector.h +++ b/WebCore/css/CSSSelector.h @@ -85,7 +85,7 @@ namespace WebCore { // tag == -1 means apply to all elements (Selector = *) - unsigned specificity(); + unsigned specificity() const; /* how the attribute value has to match.... Default is Exact */ enum Match { @@ -294,7 +294,8 @@ namespace WebCore { void releaseOwnedSelectorsToBag(CSSSelectorBag&); void deleteReachableSelectors(); - unsigned specificityForPage(); + unsigned specificityForOneSelector() const; + unsigned specificityForPage() const; void extractPseudoType() const; struct RareData : Noncopyable { diff --git a/WebCore/css/CSSStyleDeclaration.cpp b/WebCore/css/CSSStyleDeclaration.cpp index 404a978..996d573 100644 --- a/WebCore/css/CSSStyleDeclaration.cpp +++ b/WebCore/css/CSSStyleDeclaration.cpp @@ -82,8 +82,8 @@ bool CSSStyleDeclaration::isPropertyImplicit(const String& propertyName) void CSSStyleDeclaration::setProperty(const String& propertyName, const String& value, ExceptionCode& ec) { - int important = value.find("!important", 0, false); - if (important == -1) + size_t important = value.find("!important", 0, false); + if (important == notFound) setProperty(propertyName, value, "", ec); else setProperty(propertyName, value.left(important - 1), "important", ec); @@ -96,7 +96,7 @@ void CSSStyleDeclaration::setProperty(const String& propertyName, const String& // FIXME: Should we raise an exception here? return; } - bool important = priority.find("important", 0, false) != -1; + bool important = priority.find("important", 0, false) != notFound; setProperty(propID, value, important, ec); } diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp index bd94b68..fd411d9 100644 --- a/WebCore/css/CSSStyleSelector.cpp +++ b/WebCore/css/CSSStyleSelector.cpp @@ -125,8 +125,6 @@ namespace WebCore { using namespace HTMLNames; -// #define STYLE_SHARING_STATS 1 - #define HANDLE_INHERIT(prop, Prop) \ if (isInherit) { \ m_style->set##Prop(m_parentStyle->prop()); \ @@ -460,32 +458,37 @@ CSSStyleSelector::CSSStyleSelector(Document* doc, StyleSheetList* styleSheets, C m_medium = new MediaQueryEvaluator(view->mediaType(), view->frame(), m_rootDefaultStyle.get()); } + m_authorStyle = new CSSRuleSet(); + // FIXME: This sucks! The user sheet is reparsed every time! - if (pageUserSheet || pageGroupUserSheets) { - m_userStyle = new CSSRuleSet(); - if (pageUserSheet) - m_userStyle->addRulesFromSheet(pageUserSheet, *m_medium, this); - if (pageGroupUserSheets) { - unsigned length = pageGroupUserSheets->size(); - for (unsigned i = 0; i < length; i++) - m_userStyle->addRulesFromSheet(pageGroupUserSheets->at(i).get(), *m_medium, this); + OwnPtr<CSSRuleSet> tempUserStyle(new CSSRuleSet); + if (pageUserSheet) + tempUserStyle->addRulesFromSheet(pageUserSheet, *m_medium, this); + if (pageGroupUserSheets) { + unsigned length = pageGroupUserSheets->size(); + for (unsigned i = 0; i < length; i++) { + if (pageGroupUserSheets->at(i)->isUserStyleSheet()) + tempUserStyle->addRulesFromSheet(pageGroupUserSheets->at(i).get(), *m_medium, this); + else + m_authorStyle->addRulesFromSheet(pageGroupUserSheets->at(i).get(), *m_medium, this); } } - // add stylesheets from document - m_authorStyle = new CSSRuleSet(); - + if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRuleCount > 0) + m_userStyle = tempUserStyle.leakPtr(); + // Add rules from elements like SVG's <font-face> if (mappedElementSheet) m_authorStyle->addRulesFromSheet(mappedElementSheet, *m_medium, this); + // add stylesheets from document unsigned length = styleSheets->length(); for (unsigned i = 0; i < length; i++) { StyleSheet* sheet = styleSheets->item(i); if (sheet->isCSSStyleSheet() && !sheet->disabled()) m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(sheet), *m_medium, this); } - + if (doc->renderer() && doc->renderer()->style()) doc->renderer()->style()->font().update(fontSelector()); } @@ -948,11 +951,6 @@ bool CSSStyleSelector::SelectorChecker::checkSelector(CSSSelector* sel, Element* return checkSelector(sel, element, 0, dynamicPseudo, false, false) == SelectorMatches; } -#ifdef STYLE_SHARING_STATS -static int fraction = 0; -static int total = 0; -#endif - static const unsigned cStyleSearchThreshold = 10; Node* CSSStyleSelector::locateCousinList(Element* parent, unsigned depth) @@ -1737,23 +1735,17 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e) style->hasTransformRelatedProperty() || style->hasMask() || style->boxReflect())) style->setZIndex(0); - // Button, legend, input, select and textarea all consider width values of 'auto' to be 'intrinsic'. - // This will be important when we use block flows for all form controls. - if (e && (e->hasTagName(legendTag) || e->hasTagName(buttonTag) || e->hasTagName(inputTag) || - e->hasTagName(selectTag) || e->hasTagName(textareaTag) || e->hasTagName(datagridTag) #if ENABLE(WML) - || e->hasTagName(WMLNames::insertedLegendTag) - || e->hasTagName(WMLNames::inputTag) + if (e && (e->hasTagName(WMLNames::insertedLegendTag) + || e->hasTagName(WMLNames::inputTag)) + && style->width().isAuto()) + style->setWidth(Length(Intrinsic)); #endif - )) { - if (style->width().isAuto()) - style->setWidth(Length(Intrinsic)); - // Textarea considers overflow visible as auto. - if (e && e->hasTagName(textareaTag)) { - style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->overflowX()); - style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->overflowY()); - } + // Textarea considers overflow visible as auto. + if (e && e->hasTagName(textareaTag)) { + style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->overflowX()); + style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->overflowY()); } // Finally update our text decorations in effect, but don't allow text-decoration to percolate through @@ -2127,18 +2119,18 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme if (sel->m_value.contains(' ') || sel->m_value.isEmpty()) return false; - int startSearchAt = 0; + unsigned startSearchAt = 0; while (true) { - int foundPos = value.find(sel->m_value, startSearchAt, caseSensitive); - if (foundPos == -1) + size_t foundPos = value.find(sel->m_value, startSearchAt, caseSensitive); + if (foundPos == notFound) return false; - if (foundPos == 0 || value[foundPos-1] == ' ') { + if (foundPos == 0 || value[foundPos - 1] == ' ') { unsigned endStr = foundPos + sel->m_value.length(); if (endStr == value.length() || value[endStr] == ' ') break; // We found a match. } - // No match. Keep looking. + // No match. Keep looking. startSearchAt = foundPos + 1; } break; @@ -2623,7 +2615,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme n = n->parent(); } const AtomicString& argument = sel->argument(); - if (value.isNull() || !value.startsWith(argument, false)) + if (value.isEmpty() || !value.startsWith(argument, false)) break; if (value.length() != argument.length() && value[argument.length()] != '-') break; diff --git a/WebCore/css/CSSStyleSelector.h b/WebCore/css/CSSStyleSelector.h index 6e4a26b..ad801da 100644 --- a/WebCore/css/CSSStyleSelector.h +++ b/WebCore/css/CSSStyleSelector.h @@ -26,11 +26,11 @@ #include "LinkHash.h" #include "MediaQueryExp.h" #include "RenderStyle.h" -#include "StringHash.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/css/CSSVariablesDeclaration.h b/WebCore/css/CSSVariablesDeclaration.h index f16b011..6838743 100644 --- a/WebCore/css/CSSVariablesDeclaration.h +++ b/WebCore/css/CSSVariablesDeclaration.h @@ -27,11 +27,11 @@ #define CSSVariablesDeclaration_h #include "PlatformString.h" -#include "StringHash.h" #include "StyleBase.h" #include <wtf/HashMap.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/css/MediaFeatureNames.h b/WebCore/css/MediaFeatureNames.h index b8f2720..1daa4e9 100644 --- a/WebCore/css/MediaFeatureNames.h +++ b/WebCore/css/MediaFeatureNames.h @@ -20,7 +20,7 @@ #ifndef MediaFeatureNames_h #define MediaFeatureNames_h -#include "AtomicString.h" +#include <wtf/text/AtomicString.h> namespace WebCore { namespace MediaFeatureNames { diff --git a/WebCore/css/MediaQueryExp.h b/WebCore/css/MediaQueryExp.h index 24f2207..4b42611 100644 --- a/WebCore/css/MediaQueryExp.h +++ b/WebCore/css/MediaQueryExp.h @@ -29,10 +29,10 @@ #ifndef MediaQueryExp_h #define MediaQueryExp_h -#include "AtomicString.h" #include "CSSValue.h" #include "MediaFeatureNames.h" #include <wtf/RefPtr.h> +#include <wtf/text/AtomicString.h> namespace WebCore { class CSSParserValueList; diff --git a/WebCore/css/WebKitCSSKeyframesRule.h b/WebCore/css/WebKitCSSKeyframesRule.h index 2836942..6ac0243 100644 --- a/WebCore/css/WebKitCSSKeyframesRule.h +++ b/WebCore/css/WebKitCSSKeyframesRule.h @@ -29,7 +29,7 @@ #include "CSSRule.h" #include <wtf/Forward.h> #include <wtf/RefPtr.h> -#include "AtomicString.h" +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/css/mathml.css b/WebCore/css/mathml.css index fd125c0..a5df17c 100644 --- a/WebCore/css/mathml.css +++ b/WebCore/css/mathml.css @@ -25,6 +25,9 @@ math > * { mrow, mfenced { display: inline-block; white-space: nowrap; +} + +mfenced { padding-left: 1px; padding-right: 1px; } diff --git a/WebCore/css/mediaControlsQt.css b/WebCore/css/mediaControlsQt.css index d49fe96..4ea444c 100644 --- a/WebCore/css/mediaControlsQt.css +++ b/WebCore/css/mediaControlsQt.css @@ -47,7 +47,7 @@ audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { } video:-webkit-full-page-media::-webkit-media-controls-panel { - display: none; + bottom: 0px; } audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { |