Changeset 58299 in webkit
- Timestamp:
- Apr 27, 2010 2:35:16 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r58277 r58299 1 2010-04-27 Yuzo Fujishima <yuzo@google.com> 2 3 Reviewed by David Hyatt. 4 5 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/doubleclick-whitespace-img-crash-expected.txt. 13 * fast/css/parsing-page-rule.html: Added. 14 1 15 2010-04-26 Yuzo Fujishima <yuzo@google.com> 2 16 -
trunk/WebCore/ChangeLog
r58298 r58299 1 2010-04-27 Yuzo Fujishima <yuzo@google.com> 2 3 Reviewed by David Hyatt. 4 5 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::lex): 19 (WebCore::CSSParser::text): 20 (WebCore::CSSParser::createPageRule): 21 (WebCore::CSSParser::createMarginAtRule): 22 (WebCore::CSSParser::startDeclarationsForMarginBox): 23 (WebCore::CSSParser::endDeclarationsForMarginBox): 24 * css/CSSParser.h: 25 * css/CSSSelector.cpp: 26 (WebCore::CSSSelector::extractPseudoType): 27 * css/CSSSelector.h: 28 (WebCore::CSSSelector::): 29 * css/tokenizer.flex: 30 1 31 2010-04-27 Adam Barth <abarth@webkit.org> 2 32 -
trunk/WebCore/css/CSSGrammar.y
r57299 r58299 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 … … 730 751 ; 731 752 732 /*733 753 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 { 754 PAGE_SYM maybe_space page_selector maybe_space 755 '{' maybe_space declarations_and_margins closing_brace { 756 CSSParser* p = static_cast<CSSParser*>(parser); 757 $$ = p->createPageRule(p->sinkFloatingSelector($3)); 758 } 759 | PAGE_SYM error invalid_block { 745 760 $$ = 0; 746 761 } 747 | PAGE_SYM error ';' {762 | PAGE_SYM error ';' { 748 763 $$ = 0; 764 } 765 ; 766 767 page_selector: 768 IDENT { 769 CSSParser* p = static_cast<CSSParser*>(parser); 770 $$ = p->createFloatingSelector(); 771 $$->m_tag = QualifiedName(nullAtom, $1, p->m_defaultNamespace); 772 } 773 | IDENT pseudo { 774 CSSParser* p = static_cast<CSSParser*>(parser); 775 $$ = $2; 776 if ($$) 777 $$->m_tag = QualifiedName(nullAtom, $1, p->m_defaultNamespace); 778 } 779 | pseudo { 780 $$ = $1; 781 } 782 | /* empty */ { 783 CSSParser* p = static_cast<CSSParser*>(parser); 784 $$ = p->createFloatingSelector(); 785 } 786 ; 787 788 declarations_and_margins: 789 declaration_list 790 | declarations_and_margins margin_box maybe_space declaration_list 791 ; 792 793 margin_box: 794 margin_sym { 795 static_cast<CSSParser*>(parser)->startDeclarationsForMarginBox(); 796 } maybe_space '{' maybe_space declaration_list closing_brace { 797 $$ = static_cast<CSSParser*>(parser)->createMarginAtRule($1); 798 } 799 ; 800 801 margin_sym : 802 TOPLEFTCORNER_SYM { 803 $$ = CSSSelector::TopLeftCornerMarginBox; 804 } 805 | TOPLEFT_SYM { 806 $$ = CSSSelector::TopLeftMarginBox; 807 } 808 | TOPCENTER_SYM { 809 $$ = CSSSelector::TopCenterMarginBox; 810 } 811 | TOPRIGHT_SYM { 812 $$ = CSSSelector::TopRightMarginBox; 813 } 814 | TOPRIGHTCORNER_SYM { 815 $$ = CSSSelector::TopRightCornerMarginBox; 816 } 817 | BOTTOMLEFTCORNER_SYM { 818 $$ = CSSSelector::BottomLeftCornerMarginBox; 819 } 820 | BOTTOMLEFT_SYM { 821 $$ = CSSSelector::BottomLeftMarginBox; 822 } 823 | BOTTOMCENTER_SYM { 824 $$ = CSSSelector::BottomCenterMarginBox; 825 } 826 | BOTTOMRIGHT_SYM { 827 $$ = CSSSelector::BottomRightMarginBox; 828 } 829 | BOTTOMRIGHTCORNER_SYM { 830 $$ = CSSSelector::BottomRightCornerMarginBox; 831 } 832 | LEFTTOP_SYM { 833 $$ = CSSSelector::LeftTopMarginBox; 834 } 835 | LEFTMIDDLE_SYM { 836 $$ = CSSSelector::LeftMiddleMarginBox; 837 } 838 | LEFTBOTTOM_SYM { 839 $$ = CSSSelector::LeftBottomMarginBox; 840 } 841 | RIGHTTOP_SYM { 842 $$ = CSSSelector::RightTopMarginBox; 843 } 844 | RIGHTMIDDLE_SYM { 845 $$ = CSSSelector::RightMiddleMarginBox; 846 } 847 | RIGHTBOTTOM_SYM { 848 $$ = CSSSelector::RightBottomMarginBox; 749 849 } 750 850 ; -
trunk/WebCore/css/CSSParser.cpp
r57105 r58299 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
r57105 r58299 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
r58228 r58299 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
r58228 r58299 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
r56414 r58299 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.