summaryrefslogtreecommitdiffstats
path: root/WebCore/css
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/css')
-rw-r--r--WebCore/css/CSSParser.cpp40
-rw-r--r--WebCore/css/CSSPrimitiveValueMappings.h1
-rw-r--r--WebCore/css/CSSSelector.cpp74
-rw-r--r--WebCore/css/CSSSelector.h21
-rw-r--r--WebCore/css/CSSStyleSelector.cpp4
5 files changed, 77 insertions, 63 deletions
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index 6bf7751..645e354 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -5677,27 +5677,31 @@ static int cssPropertyID(const UChar* propertyName, unsigned length)
const char* name = buffer;
if (buffer[0] == '-') {
- if (!strcmp(buffer, "-apple-dashboard-region") || !strcmp(buffer, "-apple-line-clamp")) {
- // Support two Apple-specific CSS properties previously used for
- // the Dashboard and Safari RSS line clamping.
+ // If the prefix is -apple- or -khtml-, change it to -webkit-.
+ // This makes the string one character longer.
+ if (hasPrefix(buffer, length, "-apple-") || hasPrefix(buffer, length, "-khtml-")) {
memmove(buffer + 7, buffer + 6, length + 1 - 6);
memcpy(buffer, "-webkit", 7);
++length;
- } else if (!strcmp(buffer, "-webkit-opacity")) {
- // Honor -webkit-opacity as a synonym for opacity. This was the only
- // syntax that worked in Safari 1.1, and may be in use on some websites and widgets.
- const char* const opacity = "opacity";
- name = opacity;
- length = 7;
- } else if (hasPrefix(buffer, length, "-webkit-border-")) {
- // -webkit-border-*-*-radius worked in Safari 4 and earlier. -webkit-border-radius syntax
- // differs from border-radius, so it remains as a distinct property.
- if (!strcmp(buffer + 15, "top-left-radius")
- || !strcmp(buffer + 15, "top-right-radius")
- || !strcmp(buffer + 15, "bottom-right-radius")
- || !strcmp(buffer + 15, "bottom-left-radius")) {
- name = buffer + 8;
- length -= 8;
+ }
+
+ if (hasPrefix(buffer, length, "-webkit")) {
+ if (strcmp(buffer, "-webkit-opacity") == 0) {
+ // Honor -webkit-opacity as a synonym for opacity.
+ // This was the only syntax that worked in Safari 1.1, and may be in use on some websites and widgets.
+ const char* const opacity = "opacity";
+ name = opacity;
+ length = strlen(opacity);
+ } else if (hasPrefix(buffer + 7, length - 7, "-border-")) {
+ // -webkit-border-*-*-radius worked in Safari 4 and earlier. -webkit-border-radius syntax
+ // differs from border-radius, so it is remains as a distinct property.
+ if (!strcmp(buffer + 15, "top-left-radius")
+ || !strcmp(buffer + 15, "top-right-radius")
+ || !strcmp(buffer + 15, "bottom-right-radius")
+ || !strcmp(buffer + 15, "bottom-left-radius")) {
+ name = buffer + 8;
+ length -= 8;
+ }
}
}
}
diff --git a/WebCore/css/CSSPrimitiveValueMappings.h b/WebCore/css/CSSPrimitiveValueMappings.h
index 9533f68..b1d2d3d 100644
--- a/WebCore/css/CSSPrimitiveValueMappings.h
+++ b/WebCore/css/CSSPrimitiveValueMappings.h
@@ -36,6 +36,7 @@
#include "FontSmoothingMode.h"
#include "GraphicsTypes.h"
#include "Path.h"
+#include "RenderStyleConstants.h"
#include "SVGRenderStyleDefs.h"
#include "TextDirection.h"
#include "TextRenderingMode.h"
diff --git a/WebCore/css/CSSSelector.cpp b/WebCore/css/CSSSelector.cpp
index b1de4ec..facce83 100644
--- a/WebCore/css/CSSSelector.cpp
+++ b/WebCore/css/CSSSelector.cpp
@@ -37,12 +37,11 @@ namespace WebCore {
using namespace HTMLNames;
-// A helper class to hold CSSSelectors.
class CSSSelectorBag : public Noncopyable {
public:
~CSSSelectorBag()
{
- deleteAllValues(m_stack);
+ ASSERT(isEmpty());
}
bool isEmpty() const
@@ -50,7 +49,7 @@ public:
return m_stack.isEmpty();
}
- void append(PassOwnPtr<CSSSelector> selector)
+ void add(PassOwnPtr<CSSSelector> selector)
{
if (selector)
m_stack.append(selector.leakPtr());
@@ -68,46 +67,6 @@ private:
Vector<CSSSelector*, 16> m_stack;
};
-CSSSelector::~CSSSelector()
-{
- // We should avoid a recursive destructor call, which causes stack overflow
- // if CSS Selectors are deeply nested.
-
- // Early exit if we have already processed the children of this selector.
- if (m_hasRareData) {
- if (!m_data.m_rareData)
- return;
- } else if (!m_data.m_tagHistory)
- return;
-
- CSSSelectorBag selectorsToBeDeleted;
- if (m_hasRareData) {
- selectorsToBeDeleted.append(m_data.m_rareData->m_tagHistory.release());
- selectorsToBeDeleted.append(m_data.m_rareData->m_simpleSelector.release());
- delete m_data.m_rareData;
- } else
- selectorsToBeDeleted.append(adoptPtr(m_data.m_tagHistory));
-
- // Traverse the tree of CSSSelector and delete each CSSSelector iteratively.
- while (!selectorsToBeDeleted.isEmpty()) {
- OwnPtr<CSSSelector> selector(selectorsToBeDeleted.takeAny());
- ASSERT(selector);
- if (selector->m_hasRareData) {
- ASSERT(selector->m_data.m_rareData);
- selectorsToBeDeleted.append(selector->m_data.m_rareData->m_tagHistory.release());
- selectorsToBeDeleted.append(selector->m_data.m_rareData->m_simpleSelector.release());
- delete selector->m_data.m_rareData;
- // Clear the pointer so that a destructor of the selector, which is
- // about to be called, can know the children are already processed.
- selector->m_data.m_rareData = 0;
- } else {
- selectorsToBeDeleted.append(adoptPtr(selector->m_data.m_tagHistory));
- // Clear the pointer for the same reason.
- selector->m_data.m_tagHistory = 0;
- }
- }
-}
-
unsigned int CSSSelector::specificity()
{
if (m_isForPage)
@@ -980,4 +939,33 @@ bool CSSSelector::RareData::matchNth(int count)
}
}
+inline void CSSSelector::releaseOwnedSelectorsToBag(CSSSelectorBag& bag)
+{
+ if (m_hasRareData) {
+ ASSERT(m_data.m_rareData);
+ bag.add(m_data.m_rareData->m_tagHistory.release());
+ bag.add(m_data.m_rareData->m_simpleSelector.release());
+ delete m_data.m_rareData;
+ // Clear the pointer so that a destructor of this selector will not
+ // traverse this chain.
+ m_data.m_rareData = 0;
+ } else {
+ bag.add(adoptPtr(m_data.m_tagHistory));
+ // Clear the pointer for the same reason.
+ m_data.m_tagHistory = 0;
+ }
+}
+
+void CSSSelector::deleteReachableSelectors()
+{
+ // Traverse the chain of selectors and delete each iteratively.
+ CSSSelectorBag selectorsToBeDeleted;
+ releaseOwnedSelectorsToBag(selectorsToBeDeleted);
+ while (!selectorsToBeDeleted.isEmpty()) {
+ OwnPtr<CSSSelector> selector(selectorsToBeDeleted.takeAny());
+ ASSERT(selector);
+ selector->releaseOwnedSelectorsToBag(selectorsToBeDeleted);
+ }
+}
+
} // namespace WebCore
diff --git a/WebCore/css/CSSSelector.h b/WebCore/css/CSSSelector.h
index 518ff2c..34e4af0 100644
--- a/WebCore/css/CSSSelector.h
+++ b/WebCore/css/CSSSelector.h
@@ -30,6 +30,8 @@
namespace WebCore {
+ class CSSSelectorBag;
+
// this class represents a selector for a StyleRule
class CSSSelector : public Noncopyable {
public:
@@ -57,7 +59,21 @@ namespace WebCore {
{
}
- ~CSSSelector();
+ ~CSSSelector()
+ {
+ // Exit if this selector does not own any objects to be deleted.
+ if (m_hasRareData) {
+ if (!m_data.m_rareData)
+ return;
+ } else if (!m_data.m_tagHistory)
+ return;
+
+ // We can not delete the owned object(s) by simply calling delete
+ // directly on them. That would lead to recursive destructor calls
+ // which might cause stack overflow. We have to delete them
+ // iteratively.
+ deleteReachableSelectors();
+ }
/**
* Re-create selector text from selector's data
@@ -275,6 +291,9 @@ namespace WebCore {
bool m_hasRareData : 1;
bool m_isForPage : 1;
+ void releaseOwnedSelectorsToBag(CSSSelectorBag&);
+ void deleteReachableSelectors();
+
unsigned specificityForPage();
void extractPseudoType() const;
diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp
index 516e0e2..89d4f3e 100644
--- a/WebCore/css/CSSStyleSelector.cpp
+++ b/WebCore/css/CSSStyleSelector.cpp
@@ -4304,6 +4304,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
FontDescription fontDescription = m_style->fontDescription();
fontDescription.setGenericFamily(parentFontDescription.genericFamily());
fontDescription.setFamily(parentFontDescription.firstFamily());
+ fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont());
if (m_style->setFontDescription(fontDescription))
m_fontDirty = true;
return;
@@ -4377,6 +4378,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
firstFamily.setFamily(face);
firstFamily.appendFamily(0); // Remove any inherited family-fallback list.
currFamily = &firstFamily;
+ fontDescription.setIsSpecifiedFont(fontDescription.genericFamily() == FontDescription::NoFamily);
} else {
RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create();
newFamily->setFamily(face);
@@ -4621,7 +4623,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
FontDescription fontDescription;
RenderTheme::defaultTheme()->systemFont(primitiveValue->getIdent(), fontDescription);
-
+
// Double-check and see if the theme did anything. If not, don't bother updating the font.
if (fontDescription.isAbsoluteSize()) {
// Make sure the rendering mode and printer font settings are updated.