Diff
Modified: trunk/Source/WebCore/ChangeLog (138570 => 138571)
--- trunk/Source/WebCore/ChangeLog 2012-12-29 22:17:42 UTC (rev 138570)
+++ trunk/Source/WebCore/ChangeLog 2012-12-30 00:29:52 UTC (rev 138571)
@@ -1,3 +1,46 @@
+2012-12-29 Dimitri Glazkov <[email protected]>
+
+ Move pointer to Document up from SelectorChecker to StyleResolver.
+ https://bugs.webkit.org/show_bug.cgi?id=105863
+
+ Now that SelectorChecker is mostly stateless, it no longer needs to keep a pointer to Document, which
+ makes all the code in StyleResolver that reaches for it sort of weird.
+
+ Reviewed by Eric Seidel.
+
+ No change in functionality, covered by existing tests.
+
+ * css/SelectorChecker.cpp:
+ (WebCore::SelectorChecker::SelectorChecker): Changed to take document as argument (only used to set bit fields).
+ (WebCore::SelectorChecker::checkOneSelector): Changed to use element document.
+ (WebCore::SelectorChecker::checkScrollbarPseudoClass): Ditto.
+ * css/SelectorChecker.h:
+ (WebCore): Removed unnecessary Document forward declaration.
+ (SelectorChecker): Changed constructor declaration, and removed m_document member.
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::StyleResolver): Adjusted SelectorChecker initializer accordingly.
+ (WebCore::StyleResolver::initElement): Changed to use own document accessor.
+ (WebCore::StyleResolver::initForStyleResolve): Ditto.
+ (WebCore::StyleResolver::matchUARules): Ditto.
+ (WebCore::StyleResolver::styleForPage): Ditto.
+ (WebCore::StyleResolver::applyProperty): Ditto.
+ (WebCore::StyleResolver::checkForGenericFamilyChange): Ditto.
+ (WebCore::StyleResolver::initializeFontStyle): Ditto.
+ (WebCore::StyleResolver::setFontSize): Ditto.
+ * css/StyleResolver.h:
+ (WebCore::StyleResolver::document): Changed to use own member.
+ (WebCore::StyleResolver::documentSettings): Ditto.
+ (StyleResolver): Added m_document member.
+ * dom/SelectorQuery.cpp:
+ (WebCore::SelectorQuery::matches): Changed callsite to reflect new constructor signature.
+ (WebCore::SelectorQuery::queryAll): Ditto.
+ (WebCore::SelectorQuery::queryFirst): Ditto.
+ * html/shadow/ContentSelectorQuery.cpp:
+ (WebCore::ContentSelectorChecker::ContentSelectorChecker): Ditto.
+ (WebCore::ContentSelectorQuery::ContentSelectorQuery): Ditto.
+ * html/shadow/ContentSelectorQuery.h:
+ (ContentSelectorChecker): Removed unnecessary argument.
+
2012-12-29 Otto Derek Cheung <[email protected]>
[BlackBerry] Cookies with an IP domain are not being loaded properly into memory
Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (138570 => 138571)
--- trunk/Source/WebCore/css/SelectorChecker.cpp 2012-12-29 22:17:42 UTC (rev 138570)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp 2012-12-30 00:29:52 UTC (rev 138571)
@@ -31,7 +31,6 @@
#include "CSSSelector.h"
#include "CSSSelectorList.h"
#include "Document.h"
-#include "DocumentStyleSheetCollection.h"
#include "FocusController.h"
#include "Frame.h"
#include "FrameSelection.h"
@@ -60,9 +59,8 @@
static bool htmlAttributeHasCaseInsensitiveValue(const QualifiedName& attr);
-SelectorChecker::SelectorChecker(Document* document, bool strictParsing)
- : m_document(document)
- , m_strictParsing(strictParsing)
+SelectorChecker::SelectorChecker(Document* document)
+ : m_strictParsing(!document->inQuirksMode())
, m_documentIsHTML(document->isHTMLDocument())
, m_mode(ResolvingStyle)
{
@@ -592,10 +590,10 @@
} else if (context.hasScrollbarPseudo) {
// CSS scrollbars match a specific subset of pseudo classes, and they have specialized rules for each
// (since there are no elements involved).
- return checkScrollbarPseudoClass(selector);
+ return checkScrollbarPseudoClass(element->document(), selector);
} else if (context.hasSelectionPseudo) {
if (selector->pseudoType() == CSSSelector::PseudoWindowInactive)
- return !m_document->page()->focusController()->isActive();
+ return !element->document()->page()->focusController()->isActive();
}
// Normal element pseudo class checking.
@@ -961,7 +959,7 @@
return true;
}
-bool SelectorChecker::checkScrollbarPseudoClass(CSSSelector* sel) const
+bool SelectorChecker::checkScrollbarPseudoClass(Document* document, CSSSelector* sel) const
{
RenderScrollbar* scrollbar = RenderScrollbar::scrollbarForStyleResolve();
ScrollbarPart part = RenderScrollbar::partForStyleResolve();
@@ -969,7 +967,7 @@
// FIXME: This is a temporary hack for resizers and scrollbar corners. Eventually :window-inactive should become a real
// pseudo class and just apply to everything.
if (sel->pseudoType() == CSSSelector::PseudoWindowInactive)
- return !m_document->page()->focusController()->isActive();
+ return !document->page()->focusController()->isActive();
if (!scrollbar)
return false;
Modified: trunk/Source/WebCore/css/SelectorChecker.h (138570 => 138571)
--- trunk/Source/WebCore/css/SelectorChecker.h 2012-12-29 22:17:42 UTC (rev 138570)
+++ trunk/Source/WebCore/css/SelectorChecker.h 2012-12-30 00:29:52 UTC (rev 138571)
@@ -39,13 +39,12 @@
namespace WebCore {
class CSSSelector;
-class Document;
class RenderStyle;
class SelectorChecker {
WTF_MAKE_NONCOPYABLE(SelectorChecker);
public:
- SelectorChecker(Document*, bool strictParsing);
+ explicit SelectorChecker(Document*);
enum SelectorMatch { SelectorMatches, SelectorFailsLocally, SelectorFailsAllSiblings, SelectorFailsCompletely };
enum VisitedMatchType { VisitedMatchDisabled, VisitedMatchEnabled };
@@ -86,7 +85,6 @@
static bool isFastCheckableSelector(const CSSSelector*);
bool fastCheckSelector(const CSSSelector*, const Element*) const;
- Document* document() const { return m_document; }
bool strictParsing() const { return m_strictParsing; }
Mode mode() const { return m_mode; }
@@ -103,13 +101,12 @@
static unsigned determineLinkMatchType(const CSSSelector*);
private:
- bool checkScrollbarPseudoClass(CSSSelector*) const;
+ bool checkScrollbarPseudoClass(Document*, CSSSelector*) const;
static bool isFrameFocused(const Element*);
bool fastCheckRightmostSelector(const CSSSelector*, const Element*, VisitedMatchType) const;
bool commonPseudoClassSelectorMatches(const Element*, const CSSSelector*, VisitedMatchType) const;
- Document* m_document;
bool m_strictParsing;
bool m_documentIsHTML;
Mode m_mode;
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (138570 => 138571)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2012-12-29 22:17:42 UTC (rev 138570)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2012-12-30 00:29:52 UTC (rev 138571)
@@ -264,7 +264,8 @@
, m_backgroundData(BackgroundFillLayer)
, m_matchedPropertiesCacheAdditionsSinceLastSweep(0)
, m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPropertiesCache)
- , m_checker(document, !document->inQuirksMode())
+ , m_document(document)
+ , m_checker(document)
, m_parentStyle(0)
, m_rootElementStyle(0)
, m_element(0)
@@ -964,7 +965,7 @@
if (m_element != e) {
m_element = e;
m_styledElement = m_element && m_element->isStyledElement() ? static_cast<StyledElement*>(m_element) : 0;
- m_elementLinkState = m_checker.document()->visitedLinkState()->determineLinkState(m_element);
+ m_elementLinkState = document()->visitedLinkState()->determineLinkState(m_element);
if (e && e == e->document()->documentElement()) {
e->document()->setDirectionSetOnDocumentElement(false);
e->document()->setWritingModeSetOnDocumentElement(false);
@@ -990,7 +991,7 @@
}
Node* docElement = e ? e->document()->documentElement() : 0;
- RenderStyle* docStyle = m_checker.document()->renderStyle();
+ RenderStyle* docStyle = document()->renderStyle();
m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle;
m_style = 0;
@@ -1337,7 +1338,7 @@
matchUARules(result, defaultQuirksStyle);
// If document uses view source styles (in view source mode or in xml viewer mode), then we match rules from the view source style sheet.
- if (m_checker.document()->isViewSource()) {
+ if (document()->isViewSource()) {
if (!defaultViewSourceStyle)
loadViewSourceStyle();
matchUARules(result, defaultViewSourceStyle);
@@ -1758,7 +1759,7 @@
PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
{
- initForStyleResolve(m_checker.document()->documentElement()); // m_rootElementStyle will be set to the document style.
+ initForStyleResolve(document()->documentElement()); // m_rootElementStyle will be set to the document style.
m_style = RenderStyle::create();
m_style->inheritFrom(m_rootElementStyle);
@@ -3089,7 +3090,7 @@
// We need to adjust the size to account for the generic family change from monospace
// to non-monospace.
if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize())
- setFontSize(fontDescription, fontSizeForKeyword(m_checker.document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, false));
+ setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, false));
fontDescription.setGenericFamily(initialDesc.genericFamily());
if (!initialDesc.firstFamily().familyIsEmpty())
fontDescription.setFamily(initialDesc.firstFamily());
@@ -3168,7 +3169,7 @@
// If currFamily is non-zero then we set at least one family on this description.
if (currFamily) {
if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize)
- setFontSize(fontDescription, fontSizeForKeyword(m_checker.document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize));
+ setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize));
setFontDescription(fontDescription);
}
@@ -3217,10 +3218,10 @@
if (!settings)
return;
fontDescription.setRenderingMode(settings->fontRenderingMode());
- fontDescription.setUsePrinterFont(m_checker.document()->printing() || !settings->screenFontSubstitutionEnabled());
+ fontDescription.setUsePrinterFont(document()->printing() || !settings->screenFontSubstitutionEnabled());
// Handle the zoom factor.
- fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(m_checker.document(), m_style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules()));
+ fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules()));
setFontDescription(fontDescription);
}
} else if (value->isFontValue()) {
@@ -4101,7 +4102,7 @@
// multiplying by our scale factor.
float size;
if (childFont.keywordSize())
- size = fontSizeForKeyword(m_checker.document(), CSSValueXxSmall + childFont.keywordSize() - 1, childFont.useFixedDefaultSize());
+ size = fontSizeForKeyword(document(), CSSValueXxSmall + childFont.keywordSize() - 1, childFont.useFixedDefaultSize());
else {
Settings* settings = documentSettings();
float fixedScaleFactor = (settings && settings->defaultFixedFontSize() && settings->defaultFontSize())
@@ -4122,14 +4123,14 @@
FontDescription fontDescription;
fontDescription.setGenericFamily(FontDescription::StandardFamily);
fontDescription.setRenderingMode(settings->fontRenderingMode());
- fontDescription.setUsePrinterFont(m_checker.document()->printing() || !settings->screenFontSubstitutionEnabled());
+ fontDescription.setUsePrinterFont(document()->printing() || !settings->screenFontSubstitutionEnabled());
const AtomicString& standardFontFamily = documentSettings()->standardFontFamily();
if (!standardFontFamily.isEmpty()) {
fontDescription.firstFamily().setFamily(standardFontFamily);
fontDescription.firstFamily().appendFamily(0);
}
fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
- setFontSize(fontDescription, fontSizeForKeyword(m_checker.document(), CSSValueMedium, false));
+ setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false));
m_style->setLineHeight(RenderStyle::initialLineHeight());
m_lineHeightValue = 0;
setFontDescription(fontDescription);
@@ -4138,7 +4139,7 @@
void StyleResolver::setFontSize(FontDescription& fontDescription, float size)
{
fontDescription.setSpecifiedSize(size);
- fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(m_checker.document(), m_style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules()));
+ fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules()));
}
float StyleResolver::getComputedSizeFromSpecifiedSize(Document* document, RenderStyle* style, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules)
Modified: trunk/Source/WebCore/css/StyleResolver.h (138570 => 138571)
--- trunk/Source/WebCore/css/StyleResolver.h 2012-12-29 22:17:42 UTC (rev 138570)
+++ trunk/Source/WebCore/css/StyleResolver.h 2012-12-30 00:29:52 UTC (rev 138571)
@@ -164,7 +164,7 @@
RenderStyle* parentStyle() const { return m_parentStyle; }
RenderStyle* rootElementStyle() const { return m_rootElementStyle; }
Element* element() const { return m_element; }
- Document* document() const { return m_checker.document(); }
+ Document* document() const { return m_document; }
const FontDescription& fontDescription() { return style()->fontDescription(); }
const FontDescription& parentFontDescription() { return parentStyle()->fontDescription(); }
void setFontDescription(const FontDescription& fontDescription) { m_fontDirty |= style()->setFontDescription(fontDescription); }
@@ -386,7 +386,7 @@
void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPage, const String& pageName);
void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vector<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName);
- Settings* documentSettings() { return m_checker.document()->settings(); }
+ Settings* documentSettings() { return m_document->settings(); }
bool isLeftPage(int pageIndex) const;
bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); }
@@ -488,6 +488,7 @@
PseudoId m_dynamicPseudo;
PseudoId m_pseudoStyle;
+ Document* m_document;
SelectorChecker m_checker;
SelectorFilter m_selectorFilter;
Modified: trunk/Source/WebCore/dom/SelectorQuery.cpp (138570 => 138571)
--- trunk/Source/WebCore/dom/SelectorQuery.cpp 2012-12-29 22:17:42 UTC (rev 138570)
+++ trunk/Source/WebCore/dom/SelectorQuery.cpp 2012-12-30 00:29:52 UTC (rev 138571)
@@ -152,20 +152,20 @@
bool SelectorQuery::matches(Element* element) const
{
- SelectorChecker selectorChecker(element->document(), !element->document()->inQuirksMode());
+ SelectorChecker selectorChecker(element->document());
return m_selectors.matches(selectorChecker, element);
}
PassRefPtr<NodeList> SelectorQuery::queryAll(Node* rootNode) const
{
- SelectorChecker selectorChecker(rootNode->document(), !rootNode->document()->inQuirksMode());
+ SelectorChecker selectorChecker(rootNode->document());
selectorChecker.setMode(SelectorChecker::QueryingRules);
return m_selectors.queryAll(selectorChecker, rootNode);
}
PassRefPtr<Element> SelectorQuery::queryFirst(Node* rootNode) const
{
- SelectorChecker selectorChecker(rootNode->document(), !rootNode->document()->inQuirksMode());
+ SelectorChecker selectorChecker(rootNode->document());
selectorChecker.setMode(SelectorChecker::QueryingRules);
return m_selectors.queryFirst(selectorChecker, rootNode);
}
Modified: trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp (138570 => 138571)
--- trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp 2012-12-29 22:17:42 UTC (rev 138570)
+++ trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp 2012-12-30 00:29:52 UTC (rev 138571)
@@ -35,8 +35,8 @@
namespace WebCore {
-ContentSelectorChecker::ContentSelectorChecker(Document* document, bool strictParsing)
- : m_selectorChecker(document, strictParsing)
+ContentSelectorChecker::ContentSelectorChecker(Document* document)
+ : m_selectorChecker(document)
{
m_selectorChecker.setMode(SelectorChecker::CollectingRules);
}
@@ -66,7 +66,7 @@
ContentSelectorQuery::ContentSelectorQuery(InsertionPoint* insertionPoint)
: m_insertionPoint(insertionPoint)
- , m_selectorChecker(insertionPoint->document(), !insertionPoint->document()->inQuirksMode())
+ , m_selectorChecker(insertionPoint->document())
{
if (insertionPoint->isSelectValid())
m_selectors.initialize(insertionPoint->selectorList());
Modified: trunk/Source/WebCore/html/shadow/ContentSelectorQuery.h (138570 => 138571)
--- trunk/Source/WebCore/html/shadow/ContentSelectorQuery.h 2012-12-29 22:17:42 UTC (rev 138570)
+++ trunk/Source/WebCore/html/shadow/ContentSelectorQuery.h 2012-12-30 00:29:52 UTC (rev 138571)
@@ -45,7 +45,7 @@
class ContentSelectorChecker {
public:
- ContentSelectorChecker(Document*, bool strictParsing);
+ ContentSelectorChecker(Document*);
bool checkContentSelector(CSSSelector*, const Vector<RefPtr<Node> >& siblings, int nthNode) const;
private: