Changeset 14779 in webkit
- Timestamp:
- Jun 9, 2006, 10:09:08 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 234 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r14777 r14779 1 2006-06-09 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com> 2 3 Reviewed by Hyatt. 4 5 Test cases for CSS3 Media Queries implementation. 6 <http://bugzilla.opendarwin.org/show_bug.cgi?id=4127> 7 8 * fast/media/import-p-green.css: Added. 9 * fast/media/import-p-red.css: Added. 10 * fast/media/media-descriptor-syntax-01-expected.checksum: Added. 11 * fast/media/media-descriptor-syntax-01-expected.png: Added. 12 * fast/media/media-descriptor-syntax-01-expected.txt: Added. 13 * fast/media/media-descriptor-syntax-01.html: Added. 14 * fast/media/media-descriptor-syntax-02-expected.checksum: Added. 15 * fast/media/media-descriptor-syntax-02-expected.png: Added. 16 * fast/media/media-descriptor-syntax-02-expected.txt: Added. 17 * fast/media/media-descriptor-syntax-02.html: Added. 18 * fast/media/media-descriptor-syntax-03-expected.checksum: Added. 19 * fast/media/media-descriptor-syntax-03-expected.png: Added. 20 * fast/media/media-descriptor-syntax-03-expected.txt: Added. 21 * fast/media/media-descriptor-syntax-03.html: Added. 22 * fast/media/media-descriptor-syntax-04-expected.checksum: Added. 23 * fast/media/media-descriptor-syntax-04-expected.png: Added. 24 * fast/media/media-descriptor-syntax-04-expected.txt: Added. 25 * fast/media/media-descriptor-syntax-04.html: Added. 26 * fast/media/media-descriptor-syntax-05-expected.checksum: Added. 27 * fast/media/media-descriptor-syntax-05-expected.png: Added. 28 * fast/media/media-descriptor-syntax-05-expected.txt: Added. 29 * fast/media/media-descriptor-syntax-05.html: Added. 30 * fast/media/media-descriptor-syntax-06-expected.checksum: Added. 31 * fast/media/media-descriptor-syntax-06-expected.png: Added. 32 * fast/media/media-descriptor-syntax-06-expected.txt: Added. 33 * fast/media/media-descriptor-syntax-06.html: Added. 34 * fast/media/media-type-syntax-01-expected.checksum: Added. 35 * fast/media/media-type-syntax-01-expected.png: Added. 36 * fast/media/media-type-syntax-01-expected.txt: Added. 37 * fast/media/media-type-syntax-01.html: Added. 38 * fast/media/media-type-syntax-02-expected.checksum: Added. 39 * fast/media/media-type-syntax-02-expected.png: Added. 40 * fast/media/media-type-syntax-02-expected.txt: Added. 41 * fast/media/media-type-syntax-02.html: Added. 42 * fast/media/mq-compound-query-01-expected.checksum: Added. 43 * fast/media/mq-compound-query-01-expected.png: Added. 44 * fast/media/mq-compound-query-01-expected.txt: Added. 45 * fast/media/mq-compound-query-01.html: Added. 46 * fast/media/mq-compound-query-02-expected.checksum: Added. 47 * fast/media/mq-compound-query-02-expected.png: Added. 48 * fast/media/mq-compound-query-02-expected.txt: Added. 49 * fast/media/mq-compound-query-02.html: Added. 50 * fast/media/mq-compound-query-03-expected.checksum: Added. 51 * fast/media/mq-compound-query-03-expected.png: Added. 52 * fast/media/mq-compound-query-03-expected.txt: Added. 53 * fast/media/mq-compound-query-03.html: Added. 54 * fast/media/mq-compound-query-04-expected.checksum: Added. 55 * fast/media/mq-compound-query-04-expected.png: Added. 56 * fast/media/mq-compound-query-04-expected.txt: Added. 57 * fast/media/mq-compound-query-04.html: Added. 58 * fast/media/mq-compound-query-05-expected.checksum: Added. 59 * fast/media/mq-compound-query-05-expected.png: Added. 60 * fast/media/mq-compound-query-05-expected.txt: Added. 61 * fast/media/mq-compound-query-05.html: Added. 62 * fast/media/mq-grid-01-expected.checksum: Added. 63 * fast/media/mq-grid-01-expected.png: Added. 64 * fast/media/mq-grid-01-expected.txt: Added. 65 * fast/media/mq-grid-01.html: Added. 66 * fast/media/mq-grid-02-expected.checksum: Added. 67 * fast/media/mq-grid-02-expected.png: Added. 68 * fast/media/mq-grid-02-expected.txt: Added. 69 * fast/media/mq-grid-02.html: Added. 70 * fast/media/mq-invalid-media-feature-01-expected.checksum: Added. 71 * fast/media/mq-invalid-media-feature-01-expected.png: Added. 72 * fast/media/mq-invalid-media-feature-01-expected.txt: Added. 73 * fast/media/mq-invalid-media-feature-01.html: Added. 74 * fast/media/mq-invalid-media-feature-02-expected.checksum: Added. 75 * fast/media/mq-invalid-media-feature-02-expected.png: Added. 76 * fast/media/mq-invalid-media-feature-02-expected.txt: Added. 77 * fast/media/mq-invalid-media-feature-02.html: Added. 78 * fast/media/mq-invalid-media-feature-03-expected.checksum: Added. 79 * fast/media/mq-invalid-media-feature-03-expected.png: Added. 80 * fast/media/mq-invalid-media-feature-03-expected.txt: Added. 81 * fast/media/mq-invalid-media-feature-03.html: Added. 82 * fast/media/mq-invalid-media-feature-04-expected.checksum: Added. 83 * fast/media/mq-invalid-media-feature-04-expected.png: Added. 84 * fast/media/mq-invalid-media-feature-04-expected.txt: Added. 85 * fast/media/mq-invalid-media-feature-04.html: Added. 86 * fast/media/mq-invalid-syntax-01-expected.checksum: Added. 87 * fast/media/mq-invalid-syntax-01-expected.png: Added. 88 * fast/media/mq-invalid-syntax-01-expected.txt: Added. 89 * fast/media/mq-invalid-syntax-01.html: Added. 90 * fast/media/mq-invalid-syntax-02-expected.checksum: Added. 91 * fast/media/mq-invalid-syntax-02-expected.png: Added. 92 * fast/media/mq-invalid-syntax-02-expected.txt: Added. 93 * fast/media/mq-invalid-syntax-02.html: Added. 94 * fast/media/mq-invalid-syntax-03-expected.checksum: Added. 95 * fast/media/mq-invalid-syntax-03-expected.png: Added. 96 * fast/media/mq-invalid-syntax-03-expected.txt: Added. 97 * fast/media/mq-invalid-syntax-03.html: Added. 98 * fast/media/mq-invalid-syntax-04-expected.checksum: Added. 99 * fast/media/mq-invalid-syntax-04-expected.png: Added. 100 * fast/media/mq-invalid-syntax-04-expected.txt: Added. 101 * fast/media/mq-invalid-syntax-04.html: Added. 102 * fast/media/mq-invalid-syntax-05-expected.checksum: Added. 103 * fast/media/mq-invalid-syntax-05-expected.png: Added. 104 * fast/media/mq-invalid-syntax-05-expected.txt: Added. 105 * fast/media/mq-invalid-syntax-05.html: Added. 106 * fast/media/mq-js-media-except-01-expected.checksum: Added. 107 * fast/media/mq-js-media-except-01-expected.png: Added. 108 * fast/media/mq-js-media-except-01-expected.txt: Added. 109 * fast/media/mq-js-media-except-01.html: Added. 110 * fast/media/mq-js-media-except-02-expected.checksum: Added. 111 * fast/media/mq-js-media-except-02-expected.png: Added. 112 * fast/media/mq-js-media-except-02-expected.txt: Added. 113 * fast/media/mq-js-media-except-02.html: Added. 114 * fast/media/mq-js-media-except-03-expected.checksum: Added. 115 * fast/media/mq-js-media-except-03-expected.png: Added. 116 * fast/media/mq-js-media-except-03-expected.txt: Added. 117 * fast/media/mq-js-media-except-03.html: Added. 118 * fast/media/mq-js-media-forward-syntax-expected.checksum: Added. 119 * fast/media/mq-js-media-forward-syntax-expected.png: Added. 120 * fast/media/mq-js-media-forward-syntax-expected.txt: Added. 121 * fast/media/mq-js-media-forward-syntax.html: Added. 122 * fast/media/mq-js-stylesheet-media-01-expected.checksum: Added. 123 * fast/media/mq-js-stylesheet-media-01-expected.png: Added. 124 * fast/media/mq-js-stylesheet-media-01-expected.txt: Added. 125 * fast/media/mq-js-stylesheet-media-01.html: Added. 126 * fast/media/mq-js-stylesheet-media-02-expected.checksum: Added. 127 * fast/media/mq-js-stylesheet-media-02-expected.png: Added. 128 * fast/media/mq-js-stylesheet-media-02-expected.txt: Added. 129 * fast/media/mq-js-stylesheet-media-02.html: Added. 130 * fast/media/mq-js-stylesheet-media-03-expected.checksum: Added. 131 * fast/media/mq-js-stylesheet-media-03-expected.png: Added. 132 * fast/media/mq-js-stylesheet-media-03-expected.txt: Added. 133 * fast/media/mq-js-stylesheet-media-03.html: Added. 134 * fast/media/mq-js-stylesheet-media-04-expected.checksum: Added. 135 * fast/media/mq-js-stylesheet-media-04-expected.png: Added. 136 * fast/media/mq-js-stylesheet-media-04-expected.txt: Added. 137 * fast/media/mq-js-stylesheet-media-04.html: Added. 138 * fast/media/mq-min-constraint-expected.checksum: Added. 139 * fast/media/mq-min-constraint-expected.png: Added. 140 * fast/media/mq-min-constraint-expected.txt: Added. 141 * fast/media/mq-min-constraint.html: Added. 142 * fast/media/mq-relative-constraints-02-expected.checksum: Added. 143 * fast/media/mq-relative-constraints-02-expected.png: Added. 144 * fast/media/mq-relative-constraints-02-expected.txt: Added. 145 * fast/media/mq-relative-constraints-02.html: Added. 146 * fast/media/mq-relative-constraints-03-expected.checksum: Added. 147 * fast/media/mq-relative-constraints-03-expected.png: Added. 148 * fast/media/mq-relative-constraints-03-expected.txt: Added. 149 * fast/media/mq-relative-constraints-03.html: Added. 150 * fast/media/mq-relative-constraints-04-expected.checksum: Added. 151 * fast/media/mq-relative-constraints-04-expected.png: Added. 152 * fast/media/mq-relative-constraints-04-expected.txt: Added. 153 * fast/media/mq-relative-constraints-04.html: Added. 154 * fast/media/mq-relative-constraints-05-expected.checksum: Added. 155 * fast/media/mq-relative-constraints-05-expected.png: Added. 156 * fast/media/mq-relative-constraints-05-expected.txt: Added. 157 * fast/media/mq-relative-constraints-05.html: Added. 158 * fast/media/mq-relative-constraints-06-expected.checksum: Added. 159 * fast/media/mq-relative-constraints-06-expected.png: Added. 160 * fast/media/mq-relative-constraints-06-expected.txt: Added. 161 * fast/media/mq-relative-constraints-06.html: Added. 162 * fast/media/mq-relative-constraints-07-expected.checksum: Added. 163 * fast/media/mq-relative-constraints-07-expected.png: Added. 164 * fast/media/mq-relative-constraints-07-expected.txt: Added. 165 * fast/media/mq-relative-constraints-07.html: Added. 166 * fast/media/mq-relative-constraints-08-expected.checksum: Added. 167 * fast/media/mq-relative-constraints-08-expected.png: Added. 168 * fast/media/mq-relative-constraints-08-expected.txt: Added. 169 * fast/media/mq-relative-constraints-08.html: Added. 170 * fast/media/mq-relative-constraints-09-expected.checksum: Added. 171 * fast/media/mq-relative-constraints-09-expected.png: Added. 172 * fast/media/mq-relative-constraints-09-expected.txt: Added. 173 * fast/media/mq-relative-constraints-09.html: Added. 174 * fast/media/mq-simple-neg-query-01-expected.checksum: Added. 175 * fast/media/mq-simple-neg-query-01-expected.png: Added. 176 * fast/media/mq-simple-neg-query-01-expected.txt: Added. 177 * fast/media/mq-simple-neg-query-01.html: Added. 178 * fast/media/mq-simple-neg-query-02-expected.checksum: Added. 179 * fast/media/mq-simple-neg-query-02-expected.png: Added. 180 * fast/media/mq-simple-neg-query-02-expected.txt: Added. 181 * fast/media/mq-simple-neg-query-02.html: Added. 182 * fast/media/mq-simple-neg-query-03-expected.checksum: Added. 183 * fast/media/mq-simple-neg-query-03-expected.png: Added. 184 * fast/media/mq-simple-neg-query-03-expected.txt: Added. 185 * fast/media/mq-simple-neg-query-03.html: Added. 186 * fast/media/mq-simple-neg-query-04-expected.checksum: Added. 187 * fast/media/mq-simple-neg-query-04-expected.png: Added. 188 * fast/media/mq-simple-neg-query-04-expected.txt: Added. 189 * fast/media/mq-simple-neg-query-04.html: Added. 190 * fast/media/mq-simple-neg-query-05-expected.checksum: Added. 191 * fast/media/mq-simple-neg-query-05-expected.png: Added. 192 * fast/media/mq-simple-neg-query-05-expected.txt: Added. 193 * fast/media/mq-simple-neg-query-05.html: Added. 194 * fast/media/mq-simple-query-01-expected.checksum: Added. 195 * fast/media/mq-simple-query-01-expected.png: Added. 196 * fast/media/mq-simple-query-01-expected.txt: Added. 197 * fast/media/mq-simple-query-01.html: Added. 198 * fast/media/mq-simple-query-02-expected.checksum: Added. 199 * fast/media/mq-simple-query-02-expected.png: Added. 200 * fast/media/mq-simple-query-02-expected.txt: Added. 201 * fast/media/mq-simple-query-02.html: Added. 202 * fast/media/mq-simple-query-03-expected.checksum: Added. 203 * fast/media/mq-simple-query-03-expected.png: Added. 204 * fast/media/mq-simple-query-03-expected.txt: Added. 205 * fast/media/mq-simple-query-03.html: Added. 206 * fast/media/mq-simple-query-04-expected.checksum: Added. 207 * fast/media/mq-simple-query-04-expected.png: Added. 208 * fast/media/mq-simple-query-04-expected.txt: Added. 209 * fast/media/mq-simple-query-04.html: Added. 210 * fast/media/mq-simple-query-05-expected.checksum: Added. 211 * fast/media/mq-simple-query-05-expected.png: Added. 212 * fast/media/mq-simple-query-05-expected.txt: Added. 213 * fast/media/mq-simple-query-05.html: Added. 214 * fast/media/mq-valueless-expected.checksum: Added. 215 * fast/media/mq-valueless-expected.png: Added. 216 * fast/media/mq-valueless-expected.txt: Added. 217 * fast/media/mq-valueless.html: Added. 218 * fast/media/mq-width-absolute-01-expected.checksum: Added. 219 * fast/media/mq-width-absolute-01-expected.png: Added. 220 * fast/media/mq-width-absolute-01-expected.txt: Added. 221 * fast/media/mq-width-absolute-01.html: Added. 222 * fast/media/mq-width-absolute-02-expected.checksum: Added. 223 * fast/media/mq-width-absolute-02-expected.png: Added. 224 * fast/media/mq-width-absolute-02-expected.txt: Added. 225 * fast/media/mq-width-absolute-02.html: Added. 226 * fast/media/mq-width-absolute-03-expected.checksum: Added. 227 * fast/media/mq-width-absolute-03-expected.png: Added. 228 * fast/media/mq-width-absolute-03-expected.txt: Added. 229 * fast/media/mq-width-absolute-03.html: Added. 230 * fast/media/mq-width-absolute-04-expected.checksum: Added. 231 * fast/media/mq-width-absolute-04-expected.png: Added. 232 * fast/media/mq-width-absolute-04-expected.txt: Added. 233 * fast/media/mq-width-absolute-04.html: Added. 234 1 235 2006-06-08 Justin Garcia <justin.garcia@apple.com> 2 236 -
trunk/WebCore/ChangeLog
r14778 r14779 1 2006-06-09 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com> 2 3 Reviewed by Hyatt. Tweaked by Maciej. Tweaks reviewed by Beth. 4 Landed by Beth. 5 6 CSS3 Media Queries implementation. 7 <http://bugzilla.opendarwin.org/show_bug.cgi?id=4127> 8 9 * WebCore.xcodeproj/project.pbxproj: 10 * bindings/js/kjs_css.cpp: 11 (KJS::DOMMediaList::put): 12 (KJS::KJS::DOMMediaListProtoFunc::callAsFunction): 13 * bindings/objc/DOMCSS.mm: 14 (-[DOMMediaList setMediaText:]): 15 (-[DOMMediaList deleteMedium:]): 16 (-[DOMMediaList appendMedium:]): 17 * css/CSSGrammar.y: 18 * css/MediaFeatureNames.cpp: Added. 19 (WebCore::MediaFeatureNames::init): 20 * css/MediaFeatureNames.h: Added. 21 * css/MediaList.cpp: 22 (WebCore::MediaList::MediaList): 23 (WebCore::MediaList::~MediaList): 24 (WebCore::parseMediaDescriptor): 25 (WebCore::MediaList::deleteMedium): 26 (WebCore::MediaList::mediaText): 27 (WebCore::MediaList::setMediaText): 28 (WebCore::MediaList::item): 29 (WebCore::MediaList::appendMedium): 30 (WebCore::MediaList::appendMediaQuery): 31 * css/MediaList.h: 32 (WebCore::MediaList::MediaList): 33 (WebCore::MediaList::length): 34 (WebCore::MediaList::mediaQueries): 35 * css/MediaQuery.cpp: Added. 36 (WebCore::MediaQuery::MediaQuery): 37 (WebCore::MediaQuery::~MediaQuery): 38 (WebCore::MediaQuery::operator==): 39 (WebCore::MediaQuery::cssText): 40 * css/MediaQuery.h: Added. 41 (WebCore::MediaQuery::): 42 (WebCore::MediaQuery::restrictor): 43 (WebCore::MediaQuery::expressions): 44 (WebCore::MediaQuery::mediaType): 45 (WebCore::MediaQuery::append): 46 * css/MediaQueryEvaluator.cpp: Added. 47 (WebCore::): 48 (WebCore::MediaQueryEvaluator): 49 (WebCore::MediaQueryEvaluator::~MediaQueryEvaluator): 50 (WebCore::MediaQueryEvaluator::mediaTypeMatch): 51 (WebCore::applyRestrictor): 52 (WebCore::MediaQueryEvaluator::eval): 53 (WebCore::parseAspectRatio): 54 (WebCore::cmpvalue): 55 (WebCore::numberValue): 56 (WebCore::colorMediaFeatureEval): 57 (WebCore::monochromeMediaFeatureEval): 58 (WebCore::device_aspect_ratioMediaFeatureEval): 59 (WebCore::gridMediaFeatureEval): 60 (WebCore::device_heightMediaFeatureEval): 61 (WebCore::device_widthMediaFeatureEval): 62 (WebCore::heightMediaFeatureEval): 63 (WebCore::widthMediaFeatureEval): 64 (WebCore::min_colorMediaFeatureEval): 65 (WebCore::max_colorMediaFeatureEval): 66 (WebCore::min_monochromeMediaFeatureEval): 67 (WebCore::max_monochromeMediaFeatureEval): 68 (WebCore::min_device_aspect_ratioMediaFeatureEval): 69 (WebCore::max_device_aspect_ratioMediaFeatureEval): 70 (WebCore::min_heightMediaFeatureEval): 71 (WebCore::max_heightMediaFeatureEval): 72 (WebCore::min_widthMediaFeatureEval): 73 (WebCore::max_widthMediaFeatureEval): 74 (WebCore::min_device_heightMediaFeatureEval): 75 (WebCore::max_device_heightMediaFeatureEval): 76 (WebCore::min_device_widthMediaFeatureEval): 77 (WebCore::max_device_widthMediaFeatureEval): 78 (WebCore::createFunctionMap): 79 * css/MediaQueryEvaluator.h: Added. 80 * css/MediaQueryExp.cpp: Added. 81 (WebCore::MediaQueryExp::MediaQueryExp): 82 (WebCore::MediaQueryExp::~MediaQueryExp): 83 * css/MediaQueryExp.h: Added. 84 (WebCore::MediaQueryExp::mediaFeature): 85 (WebCore::MediaQueryExp::value): 86 (WebCore::MediaQueryExp::operator==): 87 * css/StyleSheet.cpp: 88 (WebCore::StyleSheet::setMedia): 89 * css/cssparser.cpp: 90 (WebCore::CSSParser::CSSParser): 91 (WebCore::CSSParser::~CSSParser): 92 (WebCore::CSSParser::setupParser): 93 (WebCore::CSSParser::parseMediaQuery): 94 (WebCore::CSSParser::createFloatingMediaQueryExp): 95 (WebCore::CSSParser::sinkFloatingMediaQueryExp): 96 (WebCore::CSSParser::createFloatingMediaQueryExpList): 97 (WebCore::CSSParser::sinkFloatingMediaQueryExpList): 98 (WebCore::CSSParser::createFloatingMediaQuery): 99 (WebCore::CSSParser::sinkFloatingMediaQuery): 100 * css/cssparser.h: 101 * css/cssstyleselector.cpp: 102 (WebCore::CSSStyleSelector::CSSStyleSelector): 103 (WebCore::CSSStyleSelector::init): 104 (WebCore::CSSStyleSelector::~CSSStyleSelector): 105 (WebCore::CSSStyleSelector::loadDefaultStyle): 106 (WebCore::CSSStyleSelector::matchUARules): 107 (WebCore::CSSStyleSelector::styleForElement): 108 (WebCore::CSSStyleSelector::pseudoStyleForElement): 109 (WebCore::CSSStyleSelector::updateFont): 110 (WebCore::CSSStyleSelector::cacheBorderAndBackground): 111 (WebCore::CSSStyleSelector::styleRulesForElement): 112 (WebCore::CSSRuleSet::addRulesFromSheet): 113 * css/cssstyleselector.h: 114 * css/maketokenizer: 115 * css/tokenizer.flex: 116 * dom/DOMImplementation.cpp: 117 (WebCore::DOMImplementation::createCSSStyleSheet): 118 * html/HTMLLinkElement.cpp: 119 (WebCore::HTMLLinkElement::process): 120 (WebCore::HTMLLinkElement::setStyleSheet): 121 * html/HTMLStyleElement.cpp: 122 (WebCore::HTMLStyleElement::childrenChanged): 123 * ksvg2/svg/SVGDOMImplementation.cpp: 124 (SVGDOMImplementation::createCSSStyleSheet): 125 * ksvg2/svg/SVGStyleElement.cpp: 126 (WebCore::SVGStyleElement::childrenChanged): 127 * page/Frame.cpp: 128 (WebCore::Frame::Frame): 129 * platform/Screen.h: 130 * platform/mac/ScreenMac.mm: 131 (WebCore::screenDepthPerComponent): 132 (WebCore::screenIsMonochrome): 133 1 134 2006-06-08 Justin Garcia <justin.garcia@apple.com> 2 135 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r14777 r14779 151 151 1AE2AEE60A1D2A7500B42B25 /* JSHTMLBlockquoteElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE2AEE40A1D2A7500B42B25 /* JSHTMLBlockquoteElement.cpp */; }; 152 152 1AE2AEE70A1D2A7500B42B25 /* JSHTMLBlockquoteElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE2AEE50A1D2A7500B42B25 /* JSHTMLBlockquoteElement.h */; }; 153 4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */; }; 154 4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */; }; 155 4E1959290A39DACC00220FE5 /* MediaQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E1959230A39DACC00220FE5 /* MediaQuery.cpp */; }; 156 4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959240A39DACC00220FE5 /* MediaQuery.h */; }; 157 4E19592B0A39DACC00220FE5 /* MediaQueryEvaluator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E1959250A39DACC00220FE5 /* MediaQueryEvaluator.cpp */; }; 158 4E19592C0A39DACC00220FE5 /* MediaQueryEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */; }; 159 4E19592D0A39DACC00220FE5 /* MediaQueryExp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E1959270A39DACC00220FE5 /* MediaQueryExp.cpp */; }; 160 4E19592E0A39DACC00220FE5 /* MediaQueryExp.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959280A39DACC00220FE5 /* MediaQueryExp.h */; }; 153 161 5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5126E6B90A2E3B12005C29FA /* IconDatabase.cpp */; }; 154 162 5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 5126E6BA0A2E3B12005C29FA /* IconDatabase.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1736 1744 2D90660C0665D937006B6F1A /* ClipboardMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ClipboardMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 1737 1745 4758C44308C5F217009BAF05 /* KCanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 1746 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFeatureNames.cpp; sourceTree = "<group>"; }; 1747 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaFeatureNames.h; sourceTree = "<group>"; }; 1748 4E1959230A39DACC00220FE5 /* MediaQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQuery.cpp; sourceTree = "<group>"; }; 1749 4E1959240A39DACC00220FE5 /* MediaQuery.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaQuery.h; sourceTree = "<group>"; }; 1750 4E1959250A39DACC00220FE5 /* MediaQueryEvaluator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryEvaluator.cpp; sourceTree = "<group>"; }; 1751 4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaQueryEvaluator.h; sourceTree = "<group>"; }; 1752 4E1959270A39DACC00220FE5 /* MediaQueryExp.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryExp.cpp; sourceTree = "<group>"; }; 1753 4E1959280A39DACC00220FE5 /* MediaQueryExp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaQueryExp.h; sourceTree = "<group>"; }; 1738 1754 5126E6B90A2E3B12005C29FA /* IconDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IconDatabase.cpp; sourceTree = "<group>"; }; 1739 1755 5126E6BA0A2E3B12005C29FA /* IconDatabase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IconDatabase.h; sourceTree = "<group>"; }; … … 5058 5074 isa = PBXGroup; 5059 5075 children = ( 5076 4E1959230A39DACC00220FE5 /* MediaQuery.cpp */, 5077 4E1959240A39DACC00220FE5 /* MediaQuery.h */, 5078 4E1959250A39DACC00220FE5 /* MediaQueryEvaluator.cpp */, 5079 4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */, 5080 4E1959270A39DACC00220FE5 /* MediaQueryExp.cpp */, 5081 4E1959280A39DACC00220FE5 /* MediaQueryExp.h */, 5082 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */, 5083 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */, 5060 5084 A80E6CDA0A1989CA007FB8C5 /* Counter.h */, 5061 5085 930705C709E0C95F00B17FE4 /* Counter.idl */, … … 6208 6232 5126E6BF0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h in Headers */, 6209 6233 D07DEABA0A36554A00CA30F8 /* InsertListCommand.h in Headers */, 6234 4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */, 6235 4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */, 6236 4E19592C0A39DACC00220FE5 /* MediaQueryEvaluator.h in Headers */, 6237 4E19592E0A39DACC00220FE5 /* MediaQueryExp.h in Headers */, 6210 6238 ); 6211 6239 runOnlyForDeploymentPostprocessing = 0; … … 7045 7073 5126E6C00A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm in Sources */, 7046 7074 D07DEAB90A36554A00CA30F8 /* InsertListCommand.cpp in Sources */, 7075 4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */, 7076 4E1959290A39DACC00220FE5 /* MediaQuery.cpp in Sources */, 7077 4E19592B0A39DACC00220FE5 /* MediaQueryEvaluator.cpp in Sources */, 7078 4E19592D0A39DACC00220FE5 /* MediaQueryExp.cpp in Sources */, 7047 7079 ); 7048 7080 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/js/kjs_css.cpp
r14735 r14779 531 531 void DOMMediaList::put(ExecState* exec, const Identifier &propertyName, JSValue* value, int attr) 532 532 { 533 DOMExceptionTranslator exception(exec); 533 534 MediaList &mediaList = *m_impl; 534 535 if (propertyName == "mediaText") 535 mediaList.setMediaText(value->toString(exec) );536 mediaList.setMediaText(value->toString(exec), exception); 536 537 else 537 538 DOMObject::put(exec, propertyName, value, attr); … … 547 548 if (!thisObj->inherits(&KJS::DOMMediaList::info)) 548 549 return throwError(exec, TypeError); 549 MediaList &mediaList = *static_cast<DOMMediaList*>(thisObj)->impl(); 550 DOMExceptionTranslator exception(exec); 551 MediaList& mediaList = *static_cast<DOMMediaList *>(thisObj)->impl(); 550 552 switch (id) { 551 553 case DOMMediaList::Item: 552 554 return jsStringOrNull(mediaList.item(args[0]->toInt32(exec))); 553 555 case DOMMediaList::DeleteMedium: 554 mediaList.deleteMedium(args[0]->toString(exec) );556 mediaList.deleteMedium(args[0]->toString(exec), exception); 555 557 return jsUndefined(); 556 558 case DOMMediaList::AppendMedium: 557 mediaList.appendMedium(args[0]->toString(exec) );559 mediaList.appendMedium(args[0]->toString(exec), exception); 558 560 return jsUndefined(); 559 561 default: -
trunk/WebCore/bindings/objc/DOMCSS.mm
r14407 r14779 334 334 - (void)setMediaText:(NSString *)mediaText 335 335 { 336 [self _mediaList]->setMediaText(mediaText); 336 ExceptionCode ec = 0; 337 [self _mediaList]->setMediaText(mediaText, ec); 338 raiseOnDOMError(ec); 337 339 } 338 340 … … 349 351 - (void)deleteMedium:(NSString *)oldMedium 350 352 { 351 [self _mediaList]->deleteMedium(oldMedium); 353 ExceptionCode ec = 0; 354 [self _mediaList]->deleteMedium(oldMedium, ec); 355 raiseOnDOMError(ec); 352 356 } 353 357 354 358 - (void)appendMedium:(NSString *)newMedium 355 359 { 356 [self _mediaList]->appendMedium(newMedium); 360 ExceptionCode ec = 0; 361 [self _mediaList]->appendMedium(newMedium, ec); 362 raiseOnDOMError(ec); 357 363 } 358 364 -
trunk/WebCore/css/CSSGrammar.y
r14408 r14779 39 39 #include <stdlib.h> 40 40 #include <string.h> 41 #include "MediaQuery.h" 42 #include "MediaQueryExp.h" 41 43 42 44 #if SVG_SUPPORT … … 140 142 Value value; 141 143 ValueList* valueList; 144 145 MediaQuery* mediaQuery; 146 MediaQueryExp* mediaQueryExp; 147 Vector<MediaQueryExp*>* mediaQueryExpList; 148 MediaQuery::Restrictor mediaQueryRestrictor; 142 149 } 143 150 … … 182 189 %token WEBKIT_DECLS_SYM 183 190 %token WEBKIT_VALUE_SYM 191 %token WEBKIT_MEDIAQUERY_SYM 184 192 185 193 %token IMPORTANT_SYM 194 %token MEDIA_ONLY 195 %token MEDIA_NOT 196 %token MEDIA_AND 186 197 187 198 %token <val> QEMS … … 232 243 %type <string> hexcolor 233 244 245 %type <string> media_feature 234 246 %type <mediaList> media_list 235 247 %type <mediaList> maybe_media_list 248 %type <mediaQuery> media_query 249 %type <mediaQueryRestrictor> maybe_media_restrictor 250 %type <valueList> maybe_media_value 251 %type <mediaQueryExp> media_query_exp 252 %type <mediaQueryExpList> media_query_exp_list 253 %type <mediaQueryExpList> maybe_media_query_exp_list 236 254 237 255 %type <ruleList> ruleset_list … … 273 291 | webkit_decls maybe_space 274 292 | webkit_value maybe_space 293 | webkit_mediaquery maybe_space 275 294 ; 276 295 … … 301 320 ; 302 321 322 webkit_mediaquery: 323 WEBKIT_MEDIAQUERY_SYM WHITESPACE maybe_space media_query '}' { 324 CSSParser* p = static_cast<CSSParser*>(parser); 325 p->mediaQuery = p->sinkFloatingMediaQuery($4); 326 } 327 ; 328 303 329 maybe_space: 304 330 /* empty */ %prec UNIMPORTANT_TOK … … 384 410 ; 385 411 412 media_feature: 413 IDENT maybe_space { 414 $$ = $1; 415 } 416 ; 417 418 maybe_media_value: 419 /*empty*/ { 420 $$ = 0; 421 } 422 | ':' maybe_space expr maybe_space { 423 $$ = $3; 424 } 425 ; 426 427 media_query_exp: 428 MEDIA_AND maybe_space '(' maybe_space media_feature maybe_space maybe_media_value ')' maybe_space { 429 $5.lower(); 430 $$ = static_cast<CSSParser*>(parser)->createFloatingMediaQueryExp(atomicString($5), $7); 431 } 432 ; 433 434 media_query_exp_list: 435 media_query_exp { 436 CSSParser* p = static_cast<CSSParser*>(parser); 437 $$ = p->createFloatingMediaQueryExpList(); 438 $$->append(p->sinkFloatingMediaQueryExp($1)); 439 } 440 | media_query_exp_list media_query_exp { 441 $$ = $1; 442 $$->append(static_cast<CSSParser*>(parser)->sinkFloatingMediaQueryExp($2)); 443 } 444 ; 445 446 maybe_media_query_exp_list: 447 /*empty*/ { 448 $$ = static_cast<CSSParser*>(parser)->createFloatingMediaQueryExpList(); 449 } 450 | media_query_exp_list 451 ; 452 453 maybe_media_restrictor: 454 /*empty*/ { 455 $$ = MediaQuery::None; 456 } 457 | MEDIA_ONLY { 458 $$ = MediaQuery::Only; 459 } 460 | MEDIA_NOT { 461 $$ = MediaQuery::Not; 462 } 463 ; 464 465 media_query: 466 maybe_media_restrictor maybe_space medium maybe_media_query_exp_list { 467 CSSParser* p = static_cast<CSSParser*>(parser); 468 $3.lower(); 469 $$ = p->createFloatingMediaQuery($1, domString($3), p->sinkFloatingMediaQueryExpList($4)); 470 } 471 ; 472 386 473 maybe_media_list: 387 474 /* empty */ { … … 389 476 } 390 477 | media_list 391 ; 392 478 ; 393 479 394 480 media_list: 395 medium { 396 $$ = static_cast<CSSParser*>(parser)->createMediaList(); 397 $$->appendMedium(domString($1).lower()); 398 } 399 | media_list ',' maybe_space medium { 481 media_query { 482 CSSParser* p = static_cast<CSSParser*>(parser); 483 $$ = p->createMediaList(); 484 $$->appendMediaQuery(p->sinkFloatingMediaQuery($1)); 485 } 486 | media_list ',' maybe_space media_query { 400 487 $$ = $1; 401 488 if ($$) 402 $$->appendMedi um(domString($4).lower());489 $$->appendMediaQuery(static_cast<CSSParser*>(parser)->sinkFloatingMediaQuery($4)); 403 490 } 404 491 | media_list error { -
trunk/WebCore/css/MediaList.cpp
r14407 r14779 26 26 #include "CSSStyleSheet.h" 27 27 #include "DeprecatedStringList.h" 28 #include "ExceptionCode.h" 29 #include "MediaQuery.h" 30 #include "cssparser.h" 31 28 32 29 33 namespace WebCore { 30 34 31 MediaList::MediaList(CSSStyleSheet* parentSheet) 35 /* MediaList is used to store 3 types of media related entities which mean the same: 36 * Media Queries, Media Types and Media Descriptors. 37 * Currently MediaList always tries to parse media queries and if parsing fails, 38 * tries to fallback to Media Descriptors if m_fallback flag is set. 39 * Slight problem with syntax error handling: 40 * CSS 2.1 Spec (http://www.w3.org/TR/CSS21/media.html) 41 * specifies that failing media type parsing is a syntax error 42 * CSS 3 Media Queries Spec (http://www.w3.org/TR/css3-mediaqueries/) 43 * specifies that failing media query is a syntax error 44 * HTML 4.01 spec (http://www.w3.org/TR/REC-html40/present/styles.html#adef-media) 45 * specifies that Media Descriptors should be parsed with forward-compatible syntax 46 * DOM Level 2 Style Sheet spec (http://www.w3.org/TR/DOM-Level-2-Style/) 47 * talks about MediaList.mediaText and refers 48 * - to Media Descriptors of HTML 4.0 in context of StyleSheet 49 * - to Media Types of CSS 2.0 in context of CSSMediaRule and CSSImportRule 50 * 51 * These facts create situation where same (illegal) media specification may result in 52 * different parses depending on whether it is media attr of style element or part of 53 * css @media rule. 54 * <style media="screen and resolution > 40dpi"> ..</style> will be enabled on screen devices where as 55 * @media screen and resolution > 40dpi {..} will not. 56 * This gets more counter-intuitive in JavaScript: 57 * document.styleSheets[0].media.mediaText = "screen and resolution > 40dpi" will be ok and 58 * enabled, while 59 * document.styleSheets[0].cssRules[0].media.mediaText = "screen and resolution > 40dpi" will 60 * throw SYNTAX_ERR exception. 61 */ 62 63 MediaList::MediaList(CSSStyleSheet* parentSheet, bool fallbackToDescriptor) 32 64 : StyleBase(parentSheet) 33 { 34 } 35 36 MediaList::MediaList(CSSStyleSheet* parentSheet, const String& media) 65 , m_fallback(fallbackToDescriptor) 66 { 67 } 68 69 MediaList::MediaList(CSSStyleSheet* parentSheet, const String& media, bool fallbackToDescriptor) 37 70 : StyleBase(parentSheet) 38 { 39 setMediaText(media); 40 } 41 42 MediaList::MediaList(CSSRule* parentRule, const String& media) 71 , m_fallback(fallbackToDescriptor) 72 { 73 ExceptionCode ec = 0; 74 setMediaText(media, ec); 75 // FIXME: parsing can fail. The problem with failing constructor is that 76 // we would need additional flag saying MediaList is not valid 77 // Parse can fail only when fallbackToDescriptor == false, i.e when HTML4 media descriptor 78 // forward-compatible syntax is not in use. 79 // DOMImplementationCSS seems to mandate that media descriptors are used 80 // for both html and svg, even though svg:style doesn't use media descriptors 81 // Currently the only places where parsing can fail are 82 // creating <svg:style>, creating css media / import rules from js 83 if (ec) 84 setMediaText("invalid", ec); 85 } 86 87 MediaList::MediaList(CSSRule* parentRule, const String& media, bool fallbackToDescriptor) 43 88 : StyleBase(parentRule) 44 { 45 setMediaText(media); 46 } 47 48 bool MediaList::contains(const String& medium) const 49 { 50 return m_lstMedia.count() == 0 || m_lstMedia.contains(medium) || m_lstMedia.contains("all"); 89 , m_fallback(fallbackToDescriptor) 90 { 91 ExceptionCode ec = 0; 92 setMediaText(media, ec); 93 //FIXME: parsing can fail. 94 if (ec) 95 setMediaText("invalid", ec); 96 } 97 98 MediaList::~MediaList() 99 { 100 deleteAllValues(m_queries); 51 101 } 52 102 … … 61 111 } 62 112 63 void MediaList::deleteMedium(const String& oldMedium) 64 { 65 for (DeprecatedValueList<String>::Iterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it) { 66 if ((*it) == oldMedium) { 67 m_lstMedia.remove(it); 68 return; 113 static String parseMediaDescriptor(const String& s) 114 { 115 int len = s.length(); 116 117 // http://www.w3.org/TR/REC-html40/types.html#type-media-descriptors 118 // "Each entry is truncated just before the first character that isn't a 119 // US ASCII letter [a-zA-Z] (ISO 10646 hex 41-5a, 61-7a), digit [0-9] (hex 30-39), 120 // or hyphen (hex 2d)." 121 int i; 122 unsigned short c; 123 for (i = 0; i < len; ++i) { 124 c = s[i]; 125 if (! ((c >= 'a' && c <= 'z') 126 || (c >= 'A' && c <= 'Z') 127 || (c >= '1' && c <= '9') 128 || (c == '-'))) 129 break; 130 } 131 return s.left(i); 132 } 133 134 void MediaList::deleteMedium(const String& oldMedium, ExceptionCode& ec) 135 { 136 MediaList tempMediaList; 137 CSSParser p(true); 138 139 MediaQuery* oldQuery = 0; 140 bool deleteOldQuery = false; 141 142 if (p.parseMediaQuery(&tempMediaList, oldMedium)) { 143 if (tempMediaList.m_queries.size() > 0) 144 oldQuery = tempMediaList.m_queries[0]; 145 } else if (m_fallback) { 146 String medium = parseMediaDescriptor(oldMedium); 147 if (!medium.isNull()) { 148 oldQuery = new MediaQuery(MediaQuery::None, medium, 0); 149 deleteOldQuery = true; 69 150 } 70 151 } 152 153 // DOM Style Sheets spec doesn't allow SYNTAX_ERR to be thrown in deleteMedium 154 ec = NOT_FOUND_ERR; 155 156 if (oldQuery) { 157 for(size_t i = 0; i < m_queries.size(); ++i) { 158 MediaQuery* a = m_queries[i]; 159 if (*a == *oldQuery) { 160 m_queries.remove(i); 161 delete a; 162 ec = 0; 163 break; 164 } 165 } 166 if (deleteOldQuery) 167 delete oldQuery; 168 } 71 169 } 72 170 73 171 WebCore::String MediaList::mediaText() const 74 172 { 75 String text = ""; 76 for (DeprecatedValueList<String>::ConstIterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it) { 77 if (text.length() > 0) 173 String text(""); 174 175 bool first = true; 176 for (size_t i = 0; i < m_queries.size(); ++i) { 177 if (!first) 78 178 text += ", "; 79 text += *it; 80 } 179 else 180 first = false; 181 text += m_queries[i]->cssText(); 182 } 183 81 184 return text; 82 185 } 83 186 84 void MediaList::setMediaText(const WebCore::String& value) 85 { 86 m_lstMedia.clear(); 187 void MediaList::setMediaText(const WebCore::String& value, ExceptionCode& ec) 188 { 189 MediaList tempMediaList; 190 CSSParser p(true); 191 87 192 DeprecatedStringList list = DeprecatedStringList::split(',', value.deprecatedString()); 88 193 for (DeprecatedStringList::Iterator it = list.begin(); it != list.end(); ++it) { 89 194 String medium = (*it).stripWhiteSpace(); 90 if (!medium.isEmpty()) 91 m_lstMedia.append(medium); 92 } 93 } 94 95 } 195 if (!medium.isEmpty()) { 196 if (!p.parseMediaQuery(&tempMediaList, medium)) { 197 if (m_fallback) { 198 String mediaDescriptor = parseMediaDescriptor(medium); 199 if (!mediaDescriptor.isNull()) 200 tempMediaList.m_queries.append(new MediaQuery(MediaQuery::None, mediaDescriptor, 0)); 201 } else { 202 ec = SYNTAX_ERR; 203 return; 204 } 205 } 206 } else if (!m_fallback) { 207 ec = SYNTAX_ERR; 208 return; 209 } 210 } 211 // ",,,," falls straight through, but is not valid unless fallback 212 if (!m_fallback && list.begin() == list.end()) { 213 String s = value.deprecatedString().stripWhiteSpace(); 214 if (!s.isEmpty()) { 215 ec = SYNTAX_ERR; 216 return; 217 } 218 } 219 220 ec = 0; 221 deleteAllValues(m_queries); 222 m_queries = tempMediaList.m_queries; 223 tempMediaList.m_queries.clear(); 224 } 225 226 String MediaList::item(unsigned index) const 227 { 228 if (index < m_queries.size()) { 229 MediaQuery* query = m_queries[index]; 230 return query->cssText(); 231 } 232 233 return String(); 234 } 235 236 void MediaList::appendMedium(const String& newMedium, ExceptionCode& ec) 237 { 238 ec = INVALID_CHARACTER_ERR; 239 CSSParser p(true); 240 if (p.parseMediaQuery(this, newMedium)) { 241 ec = 0; 242 } else if (m_fallback) { 243 String medium = parseMediaDescriptor(newMedium); 244 if (!medium.isNull()) { 245 m_queries.append(new MediaQuery(MediaQuery::None, medium, 0)); 246 ec = 0; 247 } 248 } 249 } 250 251 void MediaList::appendMediaQuery(MediaQuery* mediaQuery) 252 { 253 m_queries.append(mediaQuery); 254 } 255 256 } -
trunk/WebCore/css/MediaList.h
r14408 r14779 25 25 26 26 #include "StyleBase.h" 27 #include "DeprecatedValueList.h"27 #include <wtf/Vector.h> 28 28 #include "PlatformString.h" 29 29 30 30 namespace WebCore { 31 31 typedef int ExceptionCode; 32 32 class CSSStyleSheet; 33 class MediaQuery; 33 34 class CSSRule; 34 35 … … 36 37 { 37 38 public: 38 MediaList() : StyleBase(0) {} 39 MediaList(CSSStyleSheet* parentSheet); 40 MediaList(CSSStyleSheet* parentSheet, const String& media); 41 MediaList(CSSRule* parentRule, const String& media); 39 MediaList(bool fallbackToDescription = false) : StyleBase(0), m_fallback(fallbackToDescription) {} 40 MediaList(CSSStyleSheet* parentSheet, bool fallbackToDescription = false); 41 MediaList(CSSStyleSheet* parentSheet, const String& media, bool fallbackToDescription = false); 42 MediaList(CSSRule* parentRule, const String& media, bool fallbackToDescription = false); 43 ~MediaList(); 42 44 43 45 virtual bool isMediaList() { return true; } … … 45 47 CSSStyleSheet* parentStyleSheet() const; 46 48 CSSRule* parentRule() const; 47 unsigned length() const { return m_lstMedia.count(); }48 String item(unsigned index) const { return m_lstMedia[index]; }49 void deleteMedium(const String& oldMedium );50 void appendMedium(const String& newMedium ) { m_lstMedia.append(newMedium); }49 unsigned length() const { return (unsigned) m_queries.size(); } 50 String item(unsigned index) const; 51 void deleteMedium(const String& oldMedium, ExceptionCode&); 52 void appendMedium(const String& newMedium, ExceptionCode&); 51 53 52 54 String mediaText() const; 53 void setMediaText(const String& );55 void setMediaText(const String&, ExceptionCode&xo); 54 56 55 /** 56 * Check if the list contains either the requested medium, or the 57 * catch-all "all" media type. Returns true when found, false otherwise. 58 * Since not specifying media types should be treated as "all" according 59 * to DOM specs, an empty list always returns true. 60 * 61 * _NOT_ part of the DOM! 62 */ 63 bool contains(const String& medium) const; 57 void appendMediaQuery(MediaQuery* mediaQuery); 58 const Vector<MediaQuery*>* mediaQueries() const { return &m_queries; } 64 59 65 60 protected: 66 DeprecatedValueList<String> m_lstMedia; 61 Vector<MediaQuery*> m_queries; 62 bool m_fallback; // true if failed media query parsing should fallback to media description parsing 67 63 }; 68 64 -
trunk/WebCore/css/StyleSheet.cpp
r14401 r14779 65 65 void StyleSheet::setMedia(MediaList* media) 66 66 { 67 if (m_media) 68 m_media->setParent(0); 69 67 70 m_media = media; 71 m_media->setParent(this); 68 72 } 69 73 -
trunk/WebCore/css/cssparser.cpp
r14763 r14779 51 51 #include "ShadowValue.h" 52 52 #include "csshelper.h" 53 #include "MediaQueryExp.h" 53 54 54 55 #define YYDEBUG 0 … … 94 95 95 96 CSSParser::CSSParser(bool strictParsing) 97 : m_floatingMediaQuery(0) 98 , m_floatingMediaQueryExp(0) 99 , m_floatingMediaQueryExpList(0) 96 100 { 97 101 #ifdef CSS_DEBUG … … 130 134 fastFree(data); 131 135 136 if (m_floatingMediaQueryExpList) { 137 deleteAllValues(*m_floatingMediaQueryExpList); 138 delete m_floatingMediaQueryExpList; 139 } 140 delete m_floatingMediaQueryExp; 141 delete m_floatingMediaQuery; 132 142 deleteAllValues(m_floatingSelectors); 133 143 deleteAllValues(m_floatingValueLists); … … 152 162 { 153 163 int length = string.length() + strlen(prefix) + strlen(suffix) + 2; 164 165 if (data) 166 fastFree(data); 154 167 155 168 data = static_cast<UChar*>(fastMalloc(length * sizeof(UChar))); … … 289 302 declaration->addParsedProperties(parsedProperties, numParsedProperties); 290 303 clearProperties(); 304 } 305 306 return ok; 307 } 308 309 bool CSSParser::parseMediaQuery(MediaList* queries, const String& string) 310 { 311 if (string.isEmpty() || string.isNull()) { 312 return true; 313 } 314 315 mediaQuery = 0; 316 // can't use { because tokenizer state switches from mediaquery to initial state when it sees { token. 317 // instead insert one " " (which is WHITESPACE in CSSGrammar.y) 318 setupParser ("@-webkit-mediaquery ", string, "} "); 319 320 CSSParser* old = currentParser; 321 currentParser = this; 322 cssyyparse(this); 323 currentParser = old; 324 325 bool ok = false; 326 if (mediaQuery) { 327 ok = true; 328 queries->appendMediaQuery(mediaQuery); 329 mediaQuery = 0; 291 330 } 292 331 … … 2869 2908 } 2870 2909 2910 MediaQueryExp* CSSParser::createFloatingMediaQueryExp(const AtomicString& mediaFeature, ValueList* values) 2911 { 2912 delete m_floatingMediaQueryExp; 2913 m_floatingMediaQueryExp = new MediaQueryExp(mediaFeature, values); 2914 return m_floatingMediaQueryExp; 2915 } 2916 2917 MediaQueryExp* CSSParser::sinkFloatingMediaQueryExp(MediaQueryExp* e) 2918 { 2919 ASSERT(e == m_floatingMediaQueryExp); 2920 m_floatingMediaQueryExp = 0; 2921 return e; 2922 } 2923 2924 Vector<MediaQueryExp*>* CSSParser::createFloatingMediaQueryExpList() 2925 { 2926 if (m_floatingMediaQueryExpList) { 2927 deleteAllValues(*m_floatingMediaQueryExpList); 2928 delete m_floatingMediaQueryExpList; 2929 } 2930 m_floatingMediaQueryExpList = new Vector<MediaQueryExp*>; 2931 return m_floatingMediaQueryExpList; 2932 } 2933 2934 Vector<MediaQueryExp*>* CSSParser::sinkFloatingMediaQueryExpList(Vector<MediaQueryExp*>* l) 2935 { 2936 ASSERT(l == m_floatingMediaQueryExpList); 2937 m_floatingMediaQueryExpList = 0; 2938 return l; 2939 } 2940 2941 MediaQuery* CSSParser::createFloatingMediaQuery(MediaQuery::Restrictor r, const String& mediaType, Vector<MediaQueryExp*>* exprs) 2942 { 2943 delete m_floatingMediaQuery; 2944 m_floatingMediaQuery = new MediaQuery(r, mediaType, exprs); 2945 return m_floatingMediaQuery; 2946 } 2947 2948 MediaQuery* CSSParser::sinkFloatingMediaQuery(MediaQuery* mq) 2949 { 2950 ASSERT(mq == m_floatingMediaQuery); 2951 m_floatingMediaQuery = 0; 2952 return mq; 2953 } 2954 2871 2955 MediaList* CSSParser::createMediaList() 2872 2956 { … … 2948 3032 #define yyterminate() yyTok = END_TOKEN; return yyTok 2949 3033 #define YY_FATAL_ERROR(a) 3034 // The line below is needed to build the tokenizer with conditon stack. 3035 // The macro is used in the tokenizer grammar with lines containing 3036 // BEGIN(mediaqueries) and BEGIN(initial). yy_start acts as index to 3037 // tokenizer transition table, and 'mediaqueries' and 'initial' are 3038 // offset multipliers that specify which transitions are active 3039 // in the tokenizer during in each condition (tokenizer state) 3040 #define BEGIN yy_start = 1 + 2 * 2950 3041 2951 3042 #include "tokenizer.cpp" -
trunk/WebCore/css/cssparser.h
r14352 r14779 28 28 #include <wtf/HashSet.h> 29 29 #include <wtf/Vector.h> 30 #include "MediaQuery.h" 30 31 31 32 namespace WebCore { … … 44 45 class StyleBase; 45 46 class StyleList; 47 class MediaList; 48 class MediaQueryExp; 49 46 50 47 51 struct ParseString { … … 111 115 bool parseColor(CSSMutableStyleDeclaration*, const String&); 112 116 bool parseDeclaration(CSSMutableStyleDeclaration*, const String&); 117 bool parseMediaQuery(MediaList*, const String&); 113 118 114 119 static CSSParser* current() { return currentParser; } … … 178 183 CSSRule* createStyleRule(CSSSelector*); 179 184 185 MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, ValueList*); 186 MediaQueryExp* sinkFloatingMediaQueryExp(MediaQueryExp*); 187 Vector<MediaQueryExp*>* createFloatingMediaQueryExpList(); 188 Vector<MediaQueryExp*>* sinkFloatingMediaQueryExpList(Vector<MediaQueryExp*>*); 189 MediaQuery* createFloatingMediaQuery(MediaQuery::Restrictor, const String&, Vector<MediaQueryExp*>*); 190 MediaQuery* sinkFloatingMediaQuery(MediaQuery*); 191 180 192 public: 181 193 bool strict; … … 184 196 StyleList* styleElement; 185 197 RefPtr<CSSRule> rule; 198 MediaQuery* mediaQuery; 186 199 ValueList* valueList; 187 200 CSSProperty** parsedProperties; … … 226 239 HashSet<ValueList*> m_floatingValueLists; 227 240 HashSet<Function*> m_floatingFunctions; 241 242 MediaQuery* m_floatingMediaQuery; 243 MediaQueryExp* m_floatingMediaQueryExp; 244 Vector<MediaQueryExp*>* m_floatingMediaQueryExpList; 228 245 229 246 // defines units allowed for a certain property, used in parseUnit -
trunk/WebCore/css/cssstyleselector.cpp
r14763 r14779 49 49 #include "KWQKHTMLSettings.h" 50 50 #include "MediaList.h" 51 #include "MediaQueryEvaluator.h" 51 52 #include "Pair.h" 52 53 #include "RectImpl.h" … … 173 174 typedef HashMap<AtomicStringImpl*, CSSRuleDataList*> AtomRuleMap; 174 175 175 void addRulesFromSheet(CSSStyleSheet* sheet, const String &medium = "screen");176 void addRulesFromSheet(CSSStyleSheet* sheet, MediaQueryEvaluator* medium); 176 177 177 178 void addRule(CSSStyleRule* rule, CSSSelector* sel); … … 215 216 if (!defaultStyle) 216 217 loadDefaultStyle(); 217 m_mediaType = view ? view->mediaType() : String("all");218 218 219 219 m_userStyle = 0; 220 220 m_userSheet = 0; 221 222 // construct document root element default style. this is needed 223 // to evaluate media queries that contain relative constraints, like "screen and (max-width: 10em)" 224 // This is here instead of constructor, because when constructor is run, 225 // document doesn't have documentElement 226 // NOTE: this assumes that element that gets passed to styleForElement -call 227 // is always from the document that owns the style selector 228 if (view) 229 m_medium = new MediaQueryEvaluator(view->mediaType()); 230 else 231 m_medium = new MediaQueryEvaluator("all"); 232 233 Element* root = doc->documentElement(); 234 235 if (root) 236 m_rootDefaultStyle = styleForElement(root, 0, false, true); // dont ref, because the RenderStyle is allocated from global heap 237 238 if (m_rootDefaultStyle && view) { 239 delete m_medium; 240 m_medium = new MediaQueryEvaluator(view->mediaType(), view, m_rootDefaultStyle); 241 } 242 221 243 222 244 // FIXME: This sucks! The user sheet is reparsed every time! … … 226 248 227 249 m_userStyle = new CSSRuleSet(); 228 m_userStyle->addRulesFromSheet(m_userSheet, m_medi aType);250 m_userStyle->addRulesFromSheet(m_userSheet, m_medium); 229 251 } 230 252 … … 235 257 for (; it.current(); ++it) 236 258 if (it.current()->isCSSStyleSheet() && !it.current()->disabled()) 237 m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(it.current()), m_mediaType); 238 239 m_ruleList = 0; 240 m_collectRulesOnly = false; 259 m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(it.current()), m_medium); 260 241 261 } 242 262 … … 248 268 loadDefaultStyle(); 249 269 FrameView *view = sheet->doc()->view(); 250 m_mediaType = view ? view->mediaType() : String("all"); 270 271 if (view) 272 m_medium = new MediaQueryEvaluator(view->mediaType()); 273 else 274 m_medium = new MediaQueryEvaluator("all"); 275 276 Element* root = sheet->doc()->documentElement(); 277 if (root) 278 m_rootDefaultStyle = styleForElement(root, 0, false, true); 279 280 if (m_rootDefaultStyle && view) { 281 delete m_medium; 282 m_medium = new MediaQueryEvaluator(view->mediaType(), view, m_rootDefaultStyle); 283 } 251 284 252 285 m_authorStyle = new CSSRuleSet(); 253 m_authorStyle->addRulesFromSheet(sheet, m_medi aType);286 m_authorStyle->addRulesFromSheet(sheet, m_medium); 254 287 } 255 288 … … 259 292 settings = 0; 260 293 m_matchedRuleCount = m_matchedDeclCount = m_tmpRuleCount = 0; 294 m_ruleList = 0; 295 m_collectRulesOnly = false; 296 m_rootDefaultStyle = 0; 297 m_medium = 0; 261 298 } 262 299 … … 280 317 CSSStyleSelector::~CSSStyleSelector() 281 318 { 319 delete m_medium; 320 ::delete m_rootDefaultStyle; 321 282 322 delete m_authorStyle; 283 323 delete m_userStyle; … … 308 348 defaultQuirksStyle = new CSSRuleSet; 309 349 350 MediaQueryEvaluator screenEval("screen"); 351 MediaQueryEvaluator printEval("print"); 352 310 353 // Strict-mode rules. 311 354 defaultSheet = parseUASheet(html4UserAgentStyleSheet); 312 defaultStyle->addRulesFromSheet(defaultSheet, "screen");313 defaultPrintStyle->addRulesFromSheet(defaultSheet, "print");355 defaultStyle->addRulesFromSheet(defaultSheet, &screenEval); 356 defaultPrintStyle->addRulesFromSheet(defaultSheet, &printEval); 314 357 315 358 #if SVG_SUPPORT 316 359 // SVG rules. 317 360 svgSheet = parseUASheet(svgUserAgentStyleSheet); 318 defaultStyle->addRulesFromSheet(svgSheet, "screen");319 defaultPrintStyle->addRulesFromSheet(svgSheet, "print");361 defaultStyle->addRulesFromSheet(svgSheet, &screenEval); 362 defaultPrintStyle->addRulesFromSheet(svgSheet, &printEval); 320 363 #endif 321 364 322 365 // Quirks-mode rules. 323 366 quirksSheet = parseUASheet(quirksUserAgentStyleSheet); 324 defaultQuirksStyle->addRulesFromSheet(quirksSheet, "screen");367 defaultQuirksStyle->addRulesFromSheet(quirksSheet, &screenEval); 325 368 } 326 369 … … 701 744 } 702 745 703 704 RenderStyle* CSSStyleSelector::styleForElement(Element* e, RenderStyle* defaultParent, bool allowSharing) 746 void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule) 747 { 748 // 1. First we match rules from the user agent sheet. 749 matchRules(defaultStyle, firstUARule, lastUARule); 750 751 // 2. In quirks mode, we match rules from the quirks user agent sheet. 752 if (!strictParsing) 753 matchRules(defaultQuirksStyle, firstUARule, lastUARule); 754 755 // 3. If our medium is print, then we match rules from the print sheet. 756 if (m_medium->mediaTypeMatch("print")) 757 matchRules(defaultPrintStyle, firstUARule, lastUARule); 758 } 759 760 // If resolveForRootDefault is true, style based on user agent style sheet only. This is used in media queries, where 761 // relative units are interpreted according to document root element style, styled only with UA stylesheet 762 763 RenderStyle* CSSStyleSelector::styleForElement(Element* e, RenderStyle* defaultParent, bool allowSharing, bool resolveForRootDefault) 705 764 { 706 765 if (allowSharing && !e->document()->haveStylesheetsLoaded()) { … … 729 788 initForStyleResolve(e, defaultParent); 730 789 731 style = new (e->document()->renderArena()) RenderStyle(); 732 style->ref(); 790 if (resolveForRootDefault) { 791 style = ::new RenderStyle(); 792 // don't ref, because we want to delete this, but we cannot unref it 793 } else { 794 style = new (e->document()->renderArena()) RenderStyle(); 795 style->ref(); 796 } 733 797 if (parentStyle) 734 798 style->inheritFrom(parentStyle); 735 799 else 736 800 parentStyle = style; 737 738 // 1. First we match rules from the user agent sheet. 801 739 802 int firstUARule = -1, lastUARule = -1; 740 matchRules(defaultStyle, firstUARule, lastUARule);741 742 // 2. In quirks mode, we match rules from the quirks user agent sheet.743 if (!strictParsing)744 matchRules(defaultQuirksStyle, firstUARule, lastUARule);745 746 // 3. If our medium is print, then we match rules from the print sheet.747 if (m_mediaType == "print")748 matchRules(defaultPrintStyle, firstUARule, lastUARule);749 750 // 4. Now we check user sheet rules.751 803 int firstUserRule = -1, lastUserRule = -1; 752 matchRules(m_userStyle, firstUserRule, lastUserRule);753 754 // 5. Now check author rules, beginning first with presentational attributes755 // mapped from HTML.756 804 int firstAuthorRule = -1, lastAuthorRule = -1; 757 if (styledElement) { 758 // Ask if the HTML element has mapped attributes. 759 if (styledElement->hasMappedAttributes()) { 760 // Walk our attribute list and add in each decl. 761 const NamedMappedAttrMap* map = styledElement->mappedAttributes(); 762 for (unsigned i = 0; i < map->length(); i++) { 763 MappedAttribute* attr = map->attributeItem(i); 764 if (attr->decl()) { 765 if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount; 766 lastAuthorRule = m_matchedDeclCount; 767 addMatchedDeclaration(attr->decl()); 805 matchUARules(firstUARule, lastUARule); 806 807 if (!resolveForRootDefault) { 808 // 4. Now we check user sheet rules. 809 matchRules(m_userStyle, firstUserRule, lastUserRule); 810 811 // 5. Now check author rules, beginning first with presentational attributes 812 // mapped from HTML. 813 if (styledElement) { 814 // Ask if the HTML element has mapped attributes. 815 if (styledElement->hasMappedAttributes()) { 816 // Walk our attribute list and add in each decl. 817 const NamedMappedAttrMap* map = styledElement->mappedAttributes(); 818 for (unsigned i = 0; i < map->length(); i++) { 819 MappedAttribute* attr = map->attributeItem(i); 820 if (attr->decl()) { 821 if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount; 822 lastAuthorRule = m_matchedDeclCount; 823 addMatchedDeclaration(attr->decl()); 824 } 768 825 } 769 826 } 770 } 771 772 // Now we check additional mapped declarations.773 // Tables and table cells share an additional mapped rule that must be applied774 // after all attributes, since their mapped style depends on the values of multiple attributes.775 CSSMutableStyleDeclaration* attributeDecl = styledElement->additionalAttributeStyleDecl();776 if (attributeDecl) {777 if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;778 lastAuthorRule = m_matchedDeclCount;779 addMatchedDeclaration(attributeDecl);780 } 781 }782 783 // 6. Check the rules in author sheets next.784 matchRules(m_authorStyle, firstAuthorRule, lastAuthorRule);785 786 // 7. Now check our inline style attribute.787 if (styledElement) {788 CSSMutableStyleDeclaration* inlineDecl = styledElement->inlineStyleDecl();789 if (inlineDecl) {790 if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;791 lastAuthorRule = m_matchedDeclCount;792 addMatchedDeclaration(inlineDecl);793 } 794 } 795 827 828 // Now we check additional mapped declarations. 829 // Tables and table cells share an additional mapped rule that must be applied 830 // after all attributes, since their mapped style depends on the values of multiple attributes. 831 CSSMutableStyleDeclaration* attributeDecl = styledElement->additionalAttributeStyleDecl(); 832 if (attributeDecl) { 833 if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount; 834 lastAuthorRule = m_matchedDeclCount; 835 addMatchedDeclaration(attributeDecl); 836 } 837 } 838 839 // 6. Check the rules in author sheets next. 840 matchRules(m_authorStyle, firstAuthorRule, lastAuthorRule); 841 842 // 7. Now check our inline style attribute. 843 if (styledElement) { 844 CSSMutableStyleDeclaration* inlineDecl = styledElement->inlineStyleDecl(); 845 if (inlineDecl) { 846 if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount; 847 lastAuthorRule = m_matchedDeclCount; 848 addMatchedDeclaration(inlineDecl); 849 } 850 } 851 } 852 796 853 // Now we have all of the matched rules in the appropriate order. Walk the rules and apply 797 854 // high-priority properties first, i.e., those properties that other properties depend on. … … 799 856 // and (4) normal important. 800 857 applyDeclarations(true, false, 0, m_matchedDeclCount-1); 801 applyDeclarations(true, true, firstAuthorRule, lastAuthorRule); 802 applyDeclarations(true, true, firstUserRule, lastUserRule); 858 if (!resolveForRootDefault) { 859 applyDeclarations(true, true, firstAuthorRule, lastAuthorRule); 860 applyDeclarations(true, true, firstUserRule, lastUserRule); 861 } 803 862 applyDeclarations(true, true, firstUARule, lastUARule); 804 863 805 864 // If our font got dirtied, go ahead and update it now. 806 if (fontDirty) { 807 checkForTextSizeAdjust(); 808 checkForGenericFamilyChange(style, parentStyle); 809 style->font().update(); 810 fontDirty = false; 811 } 865 if (fontDirty) 866 updateFont(); 812 867 813 868 // Now do the normal priority UA properties. … … 815 870 816 871 // Cache our border and background so that we can examine them later. 817 m_hasUAAppearance = style->hasAppearance(); 818 if (m_hasUAAppearance) { 819 m_borderData = style->border(); 820 m_backgroundData = *style->backgroundLayers(); 821 m_backgroundColor = style->backgroundColor(); 822 } 872 cacheBorderAndBackground(); 823 873 824 874 // Now do the author and user normal priority properties and all the !important properties. 825 applyDeclarations(false, false, lastUARule+1, m_matchedDeclCount-1); 826 applyDeclarations(false, true, firstAuthorRule, lastAuthorRule); 827 applyDeclarations(false, true, firstUserRule, lastUserRule); 875 if (!resolveForRootDefault) { 876 applyDeclarations(false, false, lastUARule+1, m_matchedDeclCount-1); 877 applyDeclarations(false, true, firstAuthorRule, lastAuthorRule); 878 applyDeclarations(false, true, firstUserRule, lastUserRule); 879 } 828 880 applyDeclarations(false, true, firstUARule, lastUARule); 829 881 830 882 // If our font got dirtied by one of the non-essential font props, 831 883 // go ahead and update it a second time. 832 if (fontDirty) { 833 checkForTextSizeAdjust(); 834 checkForGenericFamilyChange(style, parentStyle); 835 style->font().update(); 836 fontDirty = false; 837 } 884 if (fontDirty) 885 updateFont(); 838 886 839 887 // Clean up our style object's display and text decorations (among other fixups). … … 884 932 885 933 // If our font got dirtied, go ahead and update it now. 886 if (fontDirty) { 887 checkForTextSizeAdjust(); 888 checkForGenericFamilyChange(style, parentStyle); 889 style->font().update(); 890 fontDirty = false; 891 } 934 if (fontDirty) 935 updateFont(); 892 936 893 937 // Now do the normal priority properties. … … 895 939 896 940 // Cache our border and background so that we can examine them later. 897 m_hasUAAppearance = style->hasAppearance(); 898 if (m_hasUAAppearance) { 899 m_borderData = style->border(); 900 m_backgroundData = *style->backgroundLayers(); 901 m_backgroundColor = style->backgroundColor(); 902 } 941 cacheBorderAndBackground(); 903 942 904 943 applyDeclarations(false, false, lastUARule+1, m_matchedDeclCount-1); … … 909 948 // If our font got dirtied by one of the non-essential font props, 910 949 // go ahead and update it a second time. 911 if (fontDirty) { 912 checkForTextSizeAdjust(); 913 checkForGenericFamilyChange(style, parentStyle); 914 style->font().update(); 915 fontDirty = false; 916 } 917 950 if (fontDirty) 951 updateFont(); 918 952 // Clean up our style object's display and text decorations (among other fixups). 919 953 adjustRenderStyle(style, 0); … … 1039 1073 } 1040 1074 1075 void CSSStyleSelector::updateFont() 1076 { 1077 checkForTextSizeAdjust(); 1078 checkForGenericFamilyChange(style, parentStyle); 1079 style->font().update(); 1080 fontDirty = false; 1081 } 1082 1083 void CSSStyleSelector::cacheBorderAndBackground() 1084 { 1085 m_hasUAAppearance = style->hasAppearance(); 1086 if (m_hasUAAppearance) { 1087 m_borderData = style->border(); 1088 m_backgroundData = *style->backgroundLayers(); 1089 m_backgroundColor = style->backgroundColor(); 1090 } 1091 } 1092 1041 1093 RefPtr<CSSRuleList> CSSStyleSelector::styleRulesForElement(Element* e, bool authorOnly) 1042 1094 { … … 1050 1102 1051 1103 if (!authorOnly) { 1104 int firstUARule = -1, lastUARule = -1; 1052 1105 // First we match rules from the user agent sheet. 1053 int firstUARule = -1, lastUARule = -1; 1054 matchRules(defaultStyle, firstUARule, lastUARule); 1055 1056 // In quirks mode, we match rules from the quirks user agent sheet. 1057 if (!strictParsing) 1058 matchRules(defaultQuirksStyle, firstUARule, lastUARule); 1059 1060 // If our medium is print, then we match rules from the print sheet. 1061 if (m_mediaType == "print") 1062 matchRules(defaultPrintStyle, firstUARule, lastUARule); 1106 matchUARules(firstUARule, lastUARule); 1063 1107 1064 1108 // Now we check user sheet rules. … … 1589 1633 } 1590 1634 1591 void CSSRuleSet::addRulesFromSheet(CSSStyleSheet *sheet, const String &medium)1635 void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, MediaQueryEvaluator* medium) 1592 1636 { 1593 1637 if (!sheet || !sheet->isCSSStyleSheet()) … … 1596 1640 // No media implies "all", but if a media list exists it must 1597 1641 // contain our current medium 1598 if (sheet->media() && ! sheet->media()->contains(medium))1642 if (sheet->media() && !medium->eval(sheet->media())) 1599 1643 return; // the style sheet doesn't apply 1600 1644 … … 1610 1654 else if(item->isImportRule()) { 1611 1655 CSSImportRule* import = static_cast<CSSImportRule*>(item); 1612 if (!import->media() || import->media()->contains(medium))1656 if (!import->media() || medium->eval(import->media())) 1613 1657 addRulesFromSheet(import->styleSheet(), medium); 1614 1658 } … … 1617 1661 CSSRuleList* rules = r->cssRules(); 1618 1662 1619 if ((!r->media() || r->media()->contains(medium)) && rules) {1663 if ((!r->media() || medium->eval(r->media())) && rules) { 1620 1664 // Traverse child elements of the @media rule. 1621 1665 for (unsigned j = 0; j < rules->length(); j++) { -
trunk/WebCore/css/cssstyleselector.h
r14433 r14779 45 45 class CSSStyleSheet; 46 46 class CSSValue; 47 class MediaQueryEvaluator; 47 48 class Document; 48 49 class Element; … … 94 95 void initElementAndPseudoState(Element* e); 95 96 void initForStyleResolve(Element* e, RenderStyle* parentStyle); 96 RenderStyle *styleForElement(Element*, RenderStyle* parentStyle=0, bool allowSharing=true );97 RenderStyle *styleForElement(Element*, RenderStyle* parentStyle=0, bool allowSharing=true, bool resolveForRootDefault=false); 97 98 RenderStyle* pseudoStyleForElement(RenderStyle::PseudoId, Element*, RenderStyle* parentStyle=0); 98 99 … … 178 179 private: 179 180 void init(); 180 181 182 void matchUARules(int& firstUARule, int& lastUARule); 183 void updateFont(); 184 void cacheBorderAndBackground(); 185 181 186 void mapBackgroundAttachment(BackgroundLayer* layer, CSSValue* value); 182 187 void mapBackgroundClip(BackgroundLayer* layer, CSSValue* value); … … 204 209 bool m_collectRulesOnly; 205 210 206 String m_mediaType; 211 MediaQueryEvaluator* m_medium; 212 RenderStyle* m_rootDefaultStyle; 207 213 208 214 RenderStyle::PseudoId dynamicPseudo; -
trunk/WebCore/css/maketokenizer
r14274 r14779 54 54 } 55 55 56 # media query, tokenizer state support 57 while (<>) { 58 last if /yytext/; 59 } 60 while (<>) { 61 last if not (/define/ || /line/) ; 62 print; 63 } 64 56 65 while (<>) { 57 66 last if /^YY_DECL/; -
trunk/WebCore/css/tokenizer.flex
r14352 r14779 2 2 %option noyywrap 3 3 %option 8bit 4 %option stack 5 %s mediaquery 4 6 5 7 h [0-9a-fA-F] … … 35 37 "$=" {yyTok = ENDSWITH; return yyTok;} 36 38 "*=" {yyTok = CONTAINS; return yyTok;} 39 <mediaquery>"not" {yyTok = MEDIA_NOT; return yyTok;} 40 <mediaquery>"only" {yyTok = MEDIA_ONLY; return yyTok;} 41 <mediaquery>"and" {yyTok = MEDIA_AND; return yyTok;} 37 42 38 43 {string} {yyTok = STRING; return yyTok;} … … 42 47 "#"{name} {yyTok = HASH; return yyTok;} 43 48 44 "@import" { yyTok = IMPORT_SYM; return yyTok;}49 "@import" {BEGIN(mediaquery); yyTok = IMPORT_SYM; return yyTok;} 45 50 "@page" {yyTok = PAGE_SYM; return yyTok;} 46 "@media" { yyTok = MEDIA_SYM; return yyTok;}51 "@media" {BEGIN(mediaquery); yyTok = MEDIA_SYM; return yyTok;} 47 52 "@font-face" {yyTok = FONT_FACE_SYM; return yyTok;} 48 53 "@charset" {yyTok = CHARSET_SYM; return yyTok;} … … 51 56 "@-webkit-decls" {yyTok = WEBKIT_DECLS_SYM; return yyTok; } 52 57 "@-webkit-value" {yyTok = WEBKIT_VALUE_SYM; return yyTok; } 58 "@-webkit-mediaquery" {BEGIN(mediaquery); yyTok = WEBKIT_MEDIAQUERY_SYM; return yyTok; } 53 59 54 60 "!"{w}"important" {yyTok = IMPORTANT_SYM; return yyTok;} … … 82 88 U\+{h}{1,6}-{h}{1,6} {yyTok = UNICODERANGE; return yyTok;} 83 89 90 <mediaquery>"{" | 91 <mediaquery>";" {BEGIN(INITIAL); yyTok = *yytext; return yyTok; } 84 92 . {yyTok = *yytext; return yyTok;} 85 93 -
trunk/WebCore/dom/DOMImplementation.cpp
r14729 r14779 167 167 CSSStyleSheet* const nullSheet = 0; 168 168 RefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(nullSheet); 169 sheet->setMedia(new MediaList(sheet.get(), media ));169 sheet->setMedia(new MediaList(sheet.get(), media, true)); 170 170 return sheet.release(); 171 171 } -
trunk/WebCore/html/HTMLLinkElement.cpp
r14714 r14779 33 33 #include "MediaList.h" 34 34 #include "csshelper.h" 35 #include "MediaQueryEvaluator.h" 35 36 36 37 namespace WebCore { … … 169 170 // ### there may be in some situations e.g. for an editor or script to manipulate 170 171 // also, don't load style sheets for standalone documents 171 if (m_media.isNull() || m_media.contains("screen") || m_media.contains("all") || m_media.contains("print")) { 172 MediaQueryEvaluator allEval(true); 173 MediaQueryEvaluator screenEval("screen", true); 174 MediaQueryEvaluator printEval("print", true); 175 RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true); 176 if (allEval.eval(media.get()) || screenEval.eval(media.get()) || printEval.eval(media.get())) { 172 177 173 178 // Add ourselves as a pending sheet, but only if we aren't an alternate … … 212 217 m_sheet->parseString(sheetStr, !document()->inCompatMode()); 213 218 214 MediaList* media = new MediaList(m_sheet.get(), m_media);215 m_sheet->setMedia(media );219 RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true); 220 m_sheet->setMedia(media.get()); 216 221 217 222 m_loading = false; -
trunk/WebCore/html/HTMLStyleElement.cpp
r14401 r14779 28 28 #include "HTMLNames.h" 29 29 #include "MediaList.h" 30 #include "MediaQueryEvaluator.h" 30 31 31 32 namespace WebCore { … … 84 85 85 86 m_loading = false; 86 if ((m_type.isEmpty() || m_type == "text/css") // Type must be empty or CSS 87 && (m_media.isNull() || m_media.contains("screen") || m_media.contains("all") || m_media.contains("print"))) { 88 document()->addPendingSheet(); 89 m_loading = true; 90 m_sheet = new CSSStyleSheet(this); 91 m_sheet->parseString(text, !document()->inCompatMode()); 92 MediaList* media = new MediaList(m_sheet.get(), m_media); 93 m_sheet->setMedia(media); 94 m_loading = false; 87 if (m_type.isEmpty() || m_type == "text/css") { // Type must be empty or CSS 88 RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true); 89 MediaQueryEvaluator screenEval("screen", true); 90 MediaQueryEvaluator printEval("print", true); 91 if (screenEval.eval(media.get()) || printEval.eval(media.get())) { 92 document()->addPendingSheet(); 93 m_loading = true; 94 m_sheet = new CSSStyleSheet(this); 95 m_sheet->parseString(text, !document()->inCompatMode()); 96 m_sheet->setMedia(media.get()); 97 m_loading = false; 98 } 95 99 } 96 100 -
trunk/WebCore/ksvg2/svg/SVGDOMImplementation.cpp
r14729 r14779 192 192 RefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(parent); 193 193 //sheet->setTitle(title); 194 sheet->setMedia(new MediaList(sheet.get(), media)); 194 // http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-DOMImplementationCSS says 195 // that media descriptors should be used, even though svg:style has only 196 // css media types. Hence the third parameter (true). 197 sheet->setMedia(new MediaList(sheet.get(), media, true)); 195 198 return sheet.release(); 196 199 } -
trunk/WebCore/ksvg2/svg/SVGStyleElement.cpp
r14401 r14779 31 31 #include "ExceptionCode.h" 32 32 #include "MediaList.h" 33 #include "MediaQueryEvaluator.h" 33 34 #include "PlatformString.h" 34 35 … … 97 98 98 99 m_loading = false; 99 const AtomicString& _media = media(); 100 if ((type().isEmpty() || type() == "text/css") && (_media.isNull() || _media.contains("screen") || _media.contains("all") || _media.contains("print"))) { 100 MediaQueryEvaluator screenEval("screen", true); 101 MediaQueryEvaluator printEval("print", true); 102 RefPtr<MediaList> mediaList = new MediaList((CSSStyleSheet*)0, media()); 103 if ((type().isEmpty() || type() == "text/css") && (screenEval.eval(mediaList.get()) || printEval.eval(mediaList.get()))) { 101 104 ownerDocument()->addPendingSheet(); 102 105 … … 105 108 m_sheet = new CSSStyleSheet(this); 106 109 m_sheet->parseString(textContent()); // SVG css is always parsed in strict mode 107 108 MediaList* mediaList = new MediaList(m_sheet.get(), _media); 109 m_sheet->setMedia(mediaList); 110 111 m_sheet->setMedia(mediaList.get()); 110 112 m_loading = false; 111 113 } -
trunk/WebCore/page/Frame.cpp
r14777 r14779 51 51 #include "HTMLGenericFormElement.h" 52 52 #include "HTMLNames.h" 53 #include "MediaFeatureNames.h" 53 54 #include "HTMLObjectElement.h" 54 55 #include "ImageDocument.h" … … 152 153 HTMLNames::init(); 153 154 QualifiedName::init(); 155 MediaFeatureNames::init(); 154 156 155 157 #if SVG_SUPPORT -
trunk/WebCore/platform/Screen.h
r14643 r14779 33 33 34 34 int screenDepth(Widget*); 35 int screenDepthPerComponent(Widget*); 36 bool screenIsMonochrome(Widget*); 35 37 FloatRect screenRect(Widget*); 36 38 FloatRect usableScreenRect(Widget*); -
trunk/WebCore/platform/mac/ScreenMac.mm
r14678 r14779 87 87 } 88 88 89 int screenDepthPerComponent(Widget* widget) 90 { 91 return NSBitsPerSampleFromDepth([screen(widget) depth]); 92 } 93 94 bool screenIsMonochrome(Widget* widget) 95 { 96 NSScreen* s = screen(widget); 97 NSDictionary* dd = [s deviceDescription]; 98 NSString* colorSpaceName = [dd objectForKey:NSDeviceColorSpaceName]; 99 return colorSpaceName == NSCalibratedWhiteColorSpace 100 || colorSpaceName == NSCalibratedBlackColorSpace 101 || colorSpaceName == NSDeviceWhiteColorSpace 102 || colorSpaceName == NSDeviceBlackColorSpace; 103 } 104 89 105 // These methods scale between window and WebView coordinates because JavaScript/DOM operations 90 106 // assume that the WebView and the window share the same coordinate system.
Note:
See TracChangeset
for help on using the changeset viewer.