Changeset 58374 in webkit
- Timestamp:
- Apr 27, 2010 8:42:15 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r58373 r58374 1 2010-04-27 Yuzo Fujishima <yuzo@google.com> 2 3 Reviewed by David Hyatt. 4 5 Retry of: Enhance CSS parser for Paged Media (Iteration 1) 6 7 In this change, the grammar is extended and skeletal methods for creating page rules and margin at-rules are defined. 8 The contents of the methods should be implemented by other changes. 9 10 https://bugs.webkit.org/show_bug.cgi?id=35329 11 12 * fast/css/parsing-page-rule-expected.txt: Copied from LayoutTests/editing/selection/5136696-expected.txt. 13 * fast/css/parsing-page-rule.html: Added. 14 1 15 2010-04-27 Julien Chaffraix <jchaffraix@webkit.org> 2 16 -
trunk/WebCore/ChangeLog
r58373 r58374 1 2010-04-27 Yuzo Fujishima <yuzo@google.com> 2 3 Reviewed by David Hyatt. 4 5 Retry of: Enhance CSS parser for Paged Media (Iteration 1) 6 7 In this change, the grammar is extended and skeletal methods for creating page rules and margin at-rules are defined. 8 The contents of the methods should be implemented by other changes. 9 10 https://bugs.webkit.org/show_bug.cgi?id=35329 11 12 Test: fast/css/parsing-page-rule.html 13 14 * css/CSSGrammar.y: 15 * css/CSSParser.cpp: 16 (WebCore::CSSParser::CSSParser): 17 (WebCore::CSSParser::clearProperties): 18 (WebCore::CSSParser::createPageRule): 19 (WebCore::CSSParser::createMarginAtRule): 20 (WebCore::CSSParser::startDeclarationsForMarginBox): 21 (WebCore::CSSParser::endDeclarationsForMarginBox): 22 * css/CSSParser.h: 23 * css/CSSSelector.cpp: 24 (WebCore::CSSSelector::pseudoId): 25 (WebCore::nameToPseudoTypeMap): 26 (WebCore::CSSSelector::extractPseudoType): 27 * css/CSSSelector.h: 28 (WebCore::CSSSelector::): 29 * css/tokenizer.flex: 30 1 31 2010-04-27 Julien Chaffraix <jchaffraix@webkit.org> 2 32 -
trunk/WebCore/css/CSSGrammar.y
r58301 r58374 71 71 CSSSelector* selector; 72 72 Vector<CSSSelector*>* selectorList; 73 CSSSelector::MarginBoxType marginBox; 73 74 CSSSelector::Relation relation; 74 75 MediaList* mediaList; … … 98 99 %} 99 100 100 %expect 5 4101 %expect 55 101 102 102 103 %nonassoc LOWEST_PREC … … 143 144 %token VARIABLES_FOR 144 145 %token WEBKIT_VARIABLES_DECLS_SYM 146 %token <marginBox> TOPLEFTCORNER_SYM 147 %token <marginBox> TOPLEFT_SYM 148 %token <marginBox> TOPCENTER_SYM 149 %token <marginBox> TOPRIGHT_SYM 150 %token <marginBox> TOPRIGHTCORNER_SYM 151 %token <marginBox> BOTTOMLEFTCORNER_SYM 152 %token <marginBox> BOTTOMLEFT_SYM 153 %token <marginBox> BOTTOMCENTER_SYM 154 %token <marginBox> BOTTOMRIGHT_SYM 155 %token <marginBox> BOTTOMRIGHTCORNER_SYM 156 %token <marginBox> LEFTTOP_SYM 157 %token <marginBox> LEFTMIDDLE_SYM 158 %token <marginBox> LEFTBOTTOM_SYM 159 %token <marginBox> RIGHTTOP_SYM 160 %token <marginBox> RIGHTMIDDLE_SYM 161 %token <marginBox> RIGHTBOTTOM_SYM 162 145 163 %token ATKEYWORD 146 164 … … 189 207 %type <rule> namespace 190 208 %type <rule> page 209 %type <rule> margin_box 191 210 %type <rule> font_face 192 211 %type <rule> keyframes … … 210 229 %type <string> medium 211 230 %type <string> hexcolor 231 %type <marginBox> margin_sym 212 232 213 233 %type <string> media_feature … … 238 258 %type <selector> attrib 239 259 %type <selector> pseudo 260 %type <selector> page_selector 240 261 241 262 %type <boolean> declaration_list 242 263 %type <boolean> decl_list 243 264 %type <boolean> declaration 265 %type <boolean> declarations_and_margins 244 266 245 267 %type <boolean> prio … … 730 752 ; 731 753 732 /*733 754 page: 734 PAGE_SYM maybe_space IDENT? pseudo_page? maybe_space 735 '{' maybe_space declaration [ ';' maybe_space declaration ]* '}' maybe_space 736 ; 737 738 pseudo_page 739 : ':' IDENT 740 ; 741 */ 742 743 page: 744 PAGE_SYM error invalid_block { 755 PAGE_SYM maybe_space page_selector maybe_space 756 '{' maybe_space declarations_and_margins closing_brace { 757 CSSParser* p = static_cast<CSSParser*>(parser); 758 $$ = p->createPageRule(p->sinkFloatingSelector($3)); 759 } 760 | PAGE_SYM error invalid_block { 745 761 $$ = 0; 746 762 } 747 | PAGE_SYM error ';' {763 | PAGE_SYM error ';' { 748 764 $$ = 0; 765 } 766 ; 767 768 page_selector: 769 IDENT { 770 CSSParser* p = static_cast<CSSParser*>(parser); 771 $$ = p->createFloatingSelector(); 772 $$->m_tag = QualifiedName(nullAtom, $1, p->m_defaultNamespace); 773 } 774 | IDENT pseudo { 775 CSSParser* p = static_cast<CSSParser*>(parser); 776 $$ = $2; 777 if ($$) 778 $$->m_tag = QualifiedName(nullAtom, $1, p->m_defaultNamespace); 779 } 780 | pseudo { 781 $$ = $1; 782 } 783 | /* empty */ { 784 CSSParser* p = static_cast<CSSParser*>(parser); 785 $$ = p->createFloatingSelector(); 786 } 787 ; 788 789 declarations_and_margins: 790 declaration_list 791 | declarations_and_margins margin_box maybe_space declaration_list 792 ; 793 794 margin_box: 795 margin_sym { 796 static_cast<CSSParser*>(parser)->startDeclarationsForMarginBox(); 797 } maybe_space '{' maybe_space declaration_list closing_brace { 798 $$ = static_cast<CSSParser*>(parser)->createMarginAtRule($1); 799 } 800 ; 801 802 margin_sym : 803 TOPLEFTCORNER_SYM { 804 $$ = CSSSelector::TopLeftCornerMarginBox; 805 } 806 | TOPLEFT_SYM { 807 $$ = CSSSelector::TopLeftMarginBox; 808 } 809 | TOPCENTER_SYM { 810 $$ = CSSSelector::TopCenterMarginBox; 811 } 812 | TOPRIGHT_SYM { 813 $$ = CSSSelector::TopRightMarginBox; 814 } 815 | TOPRIGHTCORNER_SYM { 816 $$ = CSSSelector::TopRightCornerMarginBox; 817 } 818 | BOTTOMLEFTCORNER_SYM { 819 $$ = CSSSelector::BottomLeftCornerMarginBox; 820 } 821 | BOTTOMLEFT_SYM { 822 $$ = CSSSelector::BottomLeftMarginBox; 823 } 824 | BOTTOMCENTER_SYM { 825 $$ = CSSSelector::BottomCenterMarginBox; 826 } 827 | BOTTOMRIGHT_SYM { 828 $$ = CSSSelector::BottomRightMarginBox; 829 } 830 | BOTTOMRIGHTCORNER_SYM { 831 $$ = CSSSelector::BottomRightCornerMarginBox; 832 } 833 | LEFTTOP_SYM { 834 $$ = CSSSelector::LeftTopMarginBox; 835 } 836 | LEFTMIDDLE_SYM { 837 $$ = CSSSelector::LeftMiddleMarginBox; 838 } 839 | LEFTBOTTOM_SYM { 840 $$ = CSSSelector::LeftBottomMarginBox; 841 } 842 | RIGHTTOP_SYM { 843 $$ = CSSSelector::RightTopMarginBox; 844 } 845 | RIGHTMIDDLE_SYM { 846 $$ = CSSSelector::RightMiddleMarginBox; 847 } 848 | RIGHTBOTTOM_SYM { 849 $$ = CSSSelector::RightBottomMarginBox; 749 850 } 750 851 ; -
trunk/WebCore/css/CSSParser.cpp
r58301 r58374 70 70 #include "WebKitCSSKeyframesRule.h" 71 71 #include "WebKitCSSTransformValue.h" 72 #include <limits.h> 72 73 #include <wtf/dtoa.h> 73 74 … … 91 92 92 93 namespace WebCore { 94 95 static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX; 93 96 94 97 static bool equal(const CSSParserString& a, const char* b) … … 136 139 , m_numParsedProperties(0) 137 140 , m_maxParsedProperties(32) 141 , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES) 138 142 , m_inParseShorthand(0) 139 143 , m_currentShorthand(0) … … 397 401 delete m_parsedProperties[i]; 398 402 m_numParsedProperties = 0; 403 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; 399 404 m_hasFontFaceOnlyValues = false; 400 405 } … … 5194 5199 #endif 5195 5200 5201 CSSRule* CSSParser::createPageRule(CSSSelector* /* pageSelector */) 5202 { 5203 // FIXME: Create page rule here, using: 5204 // - pageSelector->pseudoType(): the page pseudo-class, i.e., :left, :right, or :first 5205 // - pageSelector->m_tag: the page name 5206 // - m_parsedProperties: the page properties 5207 5208 clearProperties(); 5209 return 0; // until this method is implemented. 5210 } 5211 5212 CSSRule* CSSParser::createMarginAtRule(CSSSelector::MarginBoxType /* marginBox */) 5213 { 5214 // FIXME: Implement margin at-rule here, using: 5215 // - marginBox: margin box 5216 // - m_parsedProperties: properties at [m_numParsedPropertiesBeforeMarginBox, m_numParsedProperties) are for this at-rule. 5217 5218 endDeclarationsForMarginBox(); 5219 return 0; // until this method is implemented. 5220 } 5221 5222 void CSSParser::startDeclarationsForMarginBox() 5223 { 5224 m_numParsedPropertiesBeforeMarginBox = m_numParsedProperties; 5225 } 5226 5227 void CSSParser::endDeclarationsForMarginBox() 5228 { 5229 ASSERT(m_numParsedPropertiesBeforeMarginBox != INVALID_NUM_PARSED_PROPERTIES); 5230 rollbackLastProperties(m_numParsedProperties - m_numParsedPropertiesBeforeMarginBox); 5231 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; 5232 } 5233 5196 5234 void CSSParser::clearVariables() 5197 5235 { -
trunk/WebCore/css/CSSParser.h
r58301 r58374 180 180 CSSRule* createFontFaceRule(); 181 181 CSSRule* createVariablesRule(MediaList*, bool variablesKeyword); 182 CSSRule* createPageRule(CSSSelector* pageSelector); 183 CSSRule* createMarginAtRule(CSSSelector::MarginBoxType marginBox); 184 void startDeclarationsForMarginBox(); 185 void endDeclarationsForMarginBox(); 182 186 183 187 MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, CSSParserValueList*); … … 213 217 unsigned m_numParsedProperties; 214 218 unsigned m_maxParsedProperties; 219 unsigned m_numParsedPropertiesBeforeMarginBox; 215 220 216 221 int m_inParseShorthand; -
trunk/WebCore/css/CSSSelector.cpp
r58301 r58374 204 204 case PseudoSingleButton: 205 205 case PseudoNoButton: 206 case PseudoFirstPage: 207 case PseudoLeftPage: 208 case PseudoRightPage: 206 209 return NOPSEUDO; 207 210 case PseudoNotParsed: … … 306 309 DEFINE_STATIC_LOCAL(AtomicString, noButton, ("no-button")); 307 310 DEFINE_STATIC_LOCAL(AtomicString, cornerPresent, ("corner-present")); 311 // Paged Media pseudo-classes 312 DEFINE_STATIC_LOCAL(AtomicString, firstPage, ("first")); 313 DEFINE_STATIC_LOCAL(AtomicString, leftPage, ("left")); 314 DEFINE_STATIC_LOCAL(AtomicString, rightPage, ("right")); 308 315 309 316 static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoType = 0; … … 400 407 nameToPseudoType->set(target.impl(), CSSSelector::PseudoTarget); 401 408 nameToPseudoType->set(visited.impl(), CSSSelector::PseudoVisited); 409 nameToPseudoType->set(firstPage.impl(), CSSSelector::PseudoFirstPage); 410 nameToPseudoType->set(leftPage.impl(), CSSSelector::PseudoLeftPage); 411 nameToPseudoType->set(rightPage.impl(), CSSSelector::PseudoRightPage); 402 412 } 403 413 return nameToPseudoType; … … 516 526 case PseudoNoButton: 517 527 case PseudoNotParsed: 528 case PseudoFirstPage: 529 case PseudoLeftPage: 530 case PseudoRightPage: 518 531 break; 519 532 } -
trunk/WebCore/css/CSSSelector.h
r58301 r58374 189 189 PseudoOuterSpinButton, 190 190 PseudoProgressBarValue, 191 PseudoLeftPage, 192 PseudoRightPage, 193 PseudoFirstPage, 194 }; 195 196 enum MarginBoxType { 197 TopLeftCornerMarginBox, 198 TopLeftMarginBox, 199 TopCenterMarginBox, 200 TopRightMarginBox, 201 TopRightCornerMarginBox, 202 BottomLeftCornerMarginBox, 203 BottomLeftMarginBox, 204 BottomCenterMarginBox, 205 BottomRightMarginBox, 206 BottomRightCornerMarginBox, 207 LeftTopMarginBox, 208 LeftMiddleMarginBox, 209 LeftBottomMarginBox, 210 RightTopMarginBox, 211 RightMiddleMarginBox, 212 RightBottomMarginBox, 191 213 }; 192 214 -
trunk/WebCore/css/tokenizer.flex
r58301 r58374 54 54 "@import" {BEGIN(mediaquery); yyTok = IMPORT_SYM; return yyTok;} 55 55 "@page" {yyTok = PAGE_SYM; return yyTok;} 56 "@top-left-corner" {yyTok = TOPLEFTCORNER_SYM; return yyTok;} 57 "@top-left" {yyTok = TOPLEFT_SYM; return yyTok;} 58 "@top-center" {yyTok = TOPCENTER_SYM; return yyTok;} 59 "@top-right" {yyTok = TOPRIGHT_SYM; return yyTok;} 60 "@top-right-corner" {yyTok = TOPRIGHTCORNER_SYM; return yyTok;} 61 "@bottom-left-corner" {yyTok = BOTTOMLEFTCORNER_SYM; return yyTok;} 62 "@bottom-left" {yyTok = BOTTOMLEFT_SYM; return yyTok;} 63 "@bottom-center" {yyTok = BOTTOMCENTER_SYM; return yyTok;} 64 "@bottom-right" {yyTok = BOTTOMRIGHT_SYM; return yyTok;} 65 "@bottom-right-corner" {yyTok = BOTTOMRIGHTCORNER_SYM; return yyTok;} 66 "@left-top" {yyTok = LEFTTOP_SYM; return yyTok;} 67 "@left-middle" {yyTok = LEFTMIDDLE_SYM; return yyTok;} 68 "@left-bottom" {yyTok = LEFTBOTTOM_SYM; return yyTok;} 69 "@right-top" {yyTok = RIGHTTOP_SYM; return yyTok;} 70 "@right-middle" {yyTok = RIGHTMIDDLE_SYM; return yyTok;} 71 "@right-bottom" {yyTok = RIGHTBOTTOM_SYM; return yyTok;} 56 72 "@media" {BEGIN(mediaquery); yyTok = MEDIA_SYM; return yyTok;} 57 73 "@font-face" {yyTok = FONT_FACE_SYM; return yyTok;}
Note: See TracChangeset
for help on using the changeset viewer.