361
361
void addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map,
362
362
CSSStyleRule* rule, CSSSelector* sel);
364
CSSRuleDataList* getIDRules(AtomicStringImpl* key) { return m_idRules.get(key); }
365
CSSRuleDataList* getClassRules(AtomicStringImpl* key) { return m_classRules.get(key); }
366
CSSRuleDataList* getTagRules(AtomicStringImpl* key) { return m_tagRules.get(key); }
364
CSSRuleDataList* getIDRules(AtomicStringImpl* key) { m_idRules.checkConsistency(); return m_idRules.get(key); }
365
CSSRuleDataList* getClassRules(AtomicStringImpl* key) { m_classRules.checkConsistency(); return m_classRules.get(key); }
366
CSSRuleDataList* getTagRules(AtomicStringImpl* key) { m_tagRules.checkConsistency(); return m_tagRules.get(key); }
367
367
CSSRuleDataList* getUniversalRules() { return m_universalRules; }
441
441
m_medium = new MediaQueryEvaluator("all");
444
m_rootDefaultStyle = styleForElement(root, 0, false, true); // dont ref, because the RenderStyle is allocated from global heap
444
m_rootDefaultStyle = styleForElement(root, 0, false, true); // don't ref, because the RenderStyle is allocated from global heap
446
446
if (m_rootDefaultStyle && view) {
463
463
// add stylesheets from document
464
464
m_authorStyle = new CSSRuleSet();
466
// Add rules from elments like SVG's <font-face>
466
// Add rules from elements like SVG's <font-face>
467
467
if (mappedElementSheet)
468
468
m_authorStyle->addRulesFromSheet(mappedElementSheet, *m_medium, this);
473
473
if (sheet->isCSSStyleSheet() && !sheet->disabled())
474
474
m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(sheet), *m_medium, this);
477
if (doc->renderer() && doc->renderer()->style())
478
doc->renderer()->style()->font().update(fontSelector());
478
481
// This is a simplified style setting function for keyframe styles
762
// Peform a merge sort for larger lists.
765
// Perform a merge sort for larger lists.
763
766
unsigned mid = (start + end) / 2;
764
767
sortMatchedRules(start, mid);
765
768
sortMatchedRules(mid, end);
1002
1005
if (s->isDefaultButtonForForm() != m_element->isDefaultButtonForForm())
1005
if ((s->willValidate() && s->isValidFormControlElement()) !=
1006
(m_element->willValidate() && m_element->isValidFormControlElement()))
1008
if (!m_element->document()->containsValidityStyleRules())
1011
bool willValidate = s->willValidate();
1012
if (willValidate != m_element->willValidate())
1015
if (willValidate && (s->isValidFormControlElement() != m_element->isValidFormControlElement()))
1101
PassRefPtr<RenderStyle> CSSStyleSelector::styleForDocument(Document* document)
1103
RefPtr<RenderStyle> documentStyle = RenderStyle::create();
1104
documentStyle->setDisplay(BLOCK);
1105
documentStyle->setVisuallyOrdered(document->visuallyOrdered());
1106
documentStyle->setZoom(document->frame()->pageZoomFactor());
1108
FontDescription fontDescription;
1109
fontDescription.setUsePrinterFont(document->printing());
1110
if (Settings* settings = document->settings()) {
1111
fontDescription.setRenderingMode(settings->fontRenderingMode());
1112
if (document->printing() && !settings->shouldPrintBackgrounds())
1113
documentStyle->setForceBackgroundsToWhite(true);
1114
const AtomicString& stdfont = settings->standardFontFamily();
1115
if (!stdfont.isEmpty()) {
1116
fontDescription.firstFamily().setFamily(stdfont);
1117
fontDescription.firstFamily().appendFamily(0);
1119
fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
1120
int size = CSSStyleSelector::fontSizeForKeyword(document, CSSValueMedium, false);
1121
fontDescription.setSpecifiedSize(size);
1122
fontDescription.setComputedSize(CSSStyleSelector::getComputedSizeFromSpecifiedSize(document, fontDescription.isAbsoluteSize(), size, documentStyle->effectiveZoom()));
1125
documentStyle->setFontDescription(fontDescription);
1126
documentStyle->font().update(0);
1127
if (document->inCompatMode())
1128
documentStyle->setHtmlHacks(true); // enable html specific rendering tricks
1130
return documentStyle.release();
1092
1133
// If resolveForRootDefault is true, style based on user agent style sheet only. This is used in media queries, where
1093
1134
// relative units are interpreted according to document root element style, styled only with UA stylesheet
2407
2450
return e && e->isOptionalFormControl();
2408
2451
case CSSSelector::PseudoRequired:
2409
2452
return e && e->isRequiredFormControl();
2410
case CSSSelector::PseudoValid:
2411
return e && e->willValidate() && e->isValidFormControlElement();
2412
case CSSSelector::PseudoInvalid:
2413
return e && e->willValidate() && !e->isValidFormControlElement();
2414
case CSSSelector::PseudoChecked: {
2453
case CSSSelector::PseudoValid: {
2456
e->document()->setContainsValidityStyleRules();
2457
return e->willValidate() && e->isValidFormControlElement();
2458
} case CSSSelector::PseudoInvalid: {
2461
e->document()->setContainsValidityStyleRules();
2462
return e->willValidate() && !e->isValidFormControlElement();
2463
} case CSSSelector::PseudoChecked: {
2415
2464
if (!e || !e->isFormControlElement())
2417
2466
// Even though WinIE allows checked and indeterminate to co-exist, the CSS selector spec says that
2871
2920
case CSSPropertyFontVariant:
2872
2921
case CSSPropertyZoom:
2873
2922
// these have to be applied first, because other properties use the computed
2874
// values of these porperties.
2923
// values of these properties.
3036
3085
#if ENABLE(WCSS)
3037
3086
if (primitiveValue) {
3038
3087
if (primitiveValue->getIdent() == CSSValueWapMarquee) {
3039
// Initialize Wap Marquee style
3088
// Initialize WAP Marquee style
3040
3089
m_style->setOverflowX(OMARQUEE);
3041
3090
m_style->setOverflowY(OMARQUEE);
3042
3091
m_style->setWhiteSpace(NOWRAP);
3885
3934
if (m_parentNode)
3886
3935
fontDescription.setKeywordSize(m_parentStyle->fontDescription().keywordSize());
3887
3936
} else if (isInitial) {
3888
size = fontSizeForKeyword(CSSValueMedium, m_style->htmlHacks(), fontDescription.useFixedDefaultSize());
3937
size = fontSizeForKeyword(m_checker.m_document, CSSValueMedium, fontDescription.useFixedDefaultSize());
3889
3938
fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
3890
3939
} else if (primitiveValue->getIdent()) {
3891
3940
// Keywords are being used.
3898
3947
case CSSValueXLarge:
3899
3948
case CSSValueXxLarge:
3900
3949
case CSSValueWebkitXxxLarge:
3901
size = fontSizeForKeyword(primitiveValue->getIdent(), m_style->htmlHacks(), fontDescription.useFixedDefaultSize());
3950
size = fontSizeForKeyword(m_checker.m_document, primitiveValue->getIdent(), fontDescription.useFixedDefaultSize());
3902
3951
fontDescription.setKeywordSize(primitiveValue->getIdent() - CSSValueXxSmall + 1);
3904
3953
case CSSValueLarger:
4147
4196
// We need to adjust the size to account for the generic family change from monospace
4148
4197
// to non-monospace.
4149
4198
if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize())
4150
setFontSize(fontDescription, fontSizeForKeyword(CSSValueXxSmall + fontDescription.keywordSize() - 1, m_style->htmlHacks(), false));
4199
setFontSize(fontDescription, fontSizeForKeyword(m_checker.m_document, CSSValueXxSmall + fontDescription.keywordSize() - 1, false));
4151
4200
fontDescription.setGenericFamily(initialDesc.genericFamily());
4152
4201
if (!initialDesc.firstFamily().familyIsEmpty())
4153
4202
fontDescription.setFamily(initialDesc.firstFamily());
4224
4273
// If currFamily is non-zero then we set at least one family on this description.
4225
4274
if (currFamily) {
4226
4275
if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize)
4227
setFontSize(fontDescription, fontSizeForKeyword(CSSValueXxSmall + fontDescription.keywordSize() - 1, m_style->htmlHacks(), !oldFamilyUsedFixedDefaultSize));
4276
setFontSize(fontDescription, fontSizeForKeyword(m_checker.m_document, CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize));
4229
4278
if (m_style->setFontDescription(fontDescription))
4230
4279
m_fontDirty = true;
4444
4493
fontDescription.firstFamily().appendFamily(0);
4446
4495
fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
4447
setFontSize(fontDescription, fontSizeForKeyword(CSSValueMedium, m_style->htmlHacks(), false));
4496
setFontSize(fontDescription, fontSizeForKeyword(m_checker.m_document, CSSValueMedium, false));
4448
4497
m_style->setLineHeight(RenderStyle::initialLineHeight());
4449
4498
m_lineHeightValue = 0;
4450
4499
if (m_style->setFontDescription(fontDescription))
4467
4516
fontDescription.setUsePrinterFont(m_checker.m_document->printing());
4469
4518
// Handle the zoom factor.
4470
fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription.isAbsoluteSize(), fontDescription.specifiedSize()));
4519
fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(m_checker.m_document, fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), m_style->effectiveZoom()));
4471
4520
if (m_style->setFontDescription(fontDescription))
4472
4521
m_fontDirty = true;
5789
5838
// multiplying by our scale factor.
5791
5840
if (childFont.keywordSize())
5792
size = fontSizeForKeyword(CSSValueXxSmall + childFont.keywordSize() - 1, style->htmlHacks(), childFont.useFixedDefaultSize());
5841
size = fontSizeForKeyword(m_checker.m_document, CSSValueXxSmall + childFont.keywordSize() - 1, childFont.useFixedDefaultSize());
5794
5843
Settings* settings = m_checker.m_document->settings();
5795
5844
float fixedScaleFactor = settings
5808
5857
void CSSStyleSelector::setFontSize(FontDescription& fontDescription, float size)
5810
5859
fontDescription.setSpecifiedSize(size);
5811
fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription.isAbsoluteSize(), size));
5860
fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(m_checker.m_document, fontDescription.isAbsoluteSize(), size, m_style->effectiveZoom()));
5814
float CSSStyleSelector::getComputedSizeFromSpecifiedSize(bool isAbsoluteSize, float specifiedSize)
5863
float CSSStyleSelector::getComputedSizeFromSpecifiedSize(Document* document, bool isAbsoluteSize, float specifiedSize, float zoomFactor)
5816
5865
// We support two types of minimum font size. The first is a hard override that applies to
5817
5866
// all fonts. This is "minSize." The second type of minimum font size is a "smart minimum"
5823
5872
// However we always allow the page to set an explicit pixel size that is smaller,
5824
5873
// since sites will mis-render otherwise (e.g., http://www.gamespot.com with a 9px minimum).
5826
Settings* settings = m_checker.m_document->settings();
5875
Settings* settings = document->settings();
5830
5879
int minSize = settings->minimumFontSize();
5831
5880
int minLogicalSize = settings->minimumLogicalFontSize();
5833
float zoomFactor = m_style->effectiveZoom();
5834
if (m_checker.m_document->frame() && m_checker.m_document->frame()->shouldApplyTextZoom())
5835
zoomFactor *= m_checker.m_document->frame()->textZoomFactor();
5882
if (document->frame() && document->frame()->shouldApplyTextZoom())
5883
zoomFactor *= document->frame()->textZoomFactor();
5837
5885
float zoomedSize = specifiedSize * zoomFactor;
5894
5942
// factors for each keyword value.
5895
5943
static const float fontSizeFactors[totalKeywords] = { 0.60f, 0.75f, 0.89f, 1.0f, 1.2f, 1.5f, 2.0f, 3.0f };
5897
float CSSStyleSelector::fontSizeForKeyword(int keyword, bool quirksMode, bool fixed) const
5945
float CSSStyleSelector::fontSizeForKeyword(Document* document, int keyword, bool fixed)
5899
Settings* settings = m_checker.m_document->settings();
5947
Settings* settings = document->settings();
5951
bool quirksMode = document->inCompatMode();
5903
5952
int mediumSize = fixed ? settings->defaultFixedFontSize() : settings->defaultFontSize();
5904
5953
if (mediumSize >= fontSizeTableMin && mediumSize <= fontSizeTableMax) {
5905
5954
// Look up the entry in the table.