Changeset 61232 in webkit
- Timestamp:
- Jun 15, 2010 8:23:12 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r61229 r61232 1095 1095 1096 1096 * platform/chromium/test_expectations.txt: 1097 1098 2010-06-10 Yuzo Fujishima <yuzo@google.com> 1099 1100 Reviewed by Shinichiro Hamaji. 1101 1102 Implement render style selection for pages to support CSS3 Paged Media. 1103 https://bugs.webkit.org/show_bug.cgi?id=35961 1104 1105 * platform/chromium/test_expectations.txt: 1106 * platform/gtk/Skipped: 1107 * platform/qt/Skipped: 1108 * platform/win/Skipped: 1109 * printing/page-rule-selection-expected.txt: Added. 1110 * printing/page-rule-selection.html: Added. 1097 1111 1098 1112 2010-06-10 Yuzo Fujishima <yuzo@google.com> -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r61229 r61232 2918 2918 // Whitespace difference between TestShell and DRT. 2919 2919 BUGDARIN : fast/history/history-back-within-subframe.html = TEXT 2920 2921 // LayoutTestController::pageProperty is not implemented for Chromium yet. 2922 BUGWK35961 : printing/page-rule-selection.html = TEXT -
trunk/LayoutTests/platform/gtk/Skipped
r61173 r61232 5938 5938 fast/forms/slider-mouse-events.html 5939 5939 fast/forms/slider-zoomed.html 5940 5941 # LayoutTestController::pageProperty is not implemented for GTK yet. 5942 printing/page-rule-selection.html -
trunk/LayoutTests/platform/qt/Skipped
r61173 r61232 854 854 fast/ruby/rubyDOM-remove-text1.html 855 855 fast/ruby/rubyDOM-remove-text2.html 856 857 # Missing LayoutTestController::pageProperty. 858 # https://bugs.webkit.org/show_bug.cgi?id=35961 859 printing/page-rule-selection.html 856 860 857 861 # ============================================================================= # -
trunk/LayoutTests/platform/win/Skipped
r60960 r61232 894 894 fast/dom/DeviceOrientation 895 895 fast/dom/Window/window-properties-on-device-orientation.html 896 897 # LayoutTestController::pageProperty is not implemented for WIN yet. 898 printing/page-rule-selection.html -
trunk/WebCore/ChangeLog
r61231 r61232 3537 3537 Reviewed by Shinichiro Hamaji. 3538 3538 3539 Implement render style selection for pages to support CSS3 Paged Media. 3540 https://bugs.webkit.org/show_bug.cgi?id=35961 3541 3542 Test: printing/page-rule-selection.html 3543 3544 * WebCore.base.exp: 3545 * css/CSSGrammar.y: 3546 * css/CSSSelector.cpp: 3547 (WebCore::CSSSelector::specificity): 3548 (WebCore::CSSSelector::specificityForPage): 3549 * css/CSSSelector.h: 3550 (WebCore::CSSSelector::CSSSelector): 3551 (WebCore::CSSSelector::isForPage): 3552 (WebCore::CSSSelector::setForPage): 3553 * css/CSSStyleSelector.cpp: 3554 (WebCore::CSSStyleSelector::styleForPage): 3555 (WebCore::CSSStyleSelector::matchPageRules): 3556 (WebCore::CSSStyleSelector::matchPageRulesForList): 3557 (WebCore::CSSStyleSelector::isLeftPage): 3558 (WebCore::CSSStyleSelector::isFirstPage): 3559 (WebCore::CSSStyleSelector::pageName): 3560 * css/CSSStyleSelector.h: 3561 (WebCore::CSSStyleSelector::isRightPage): 3562 * css/html.css: 3563 (@page): 3564 * dom/Document.cpp: 3565 (WebCore::Document::styleForPage): 3566 * dom/Document.h: 3567 * page/PrintContext.cpp: 3568 (WebCore::PrintContext::pageProperty): 3569 * page/PrintContext.h: 3570 3571 3572 2010-06-10 Yuzo Fujishima <yuzo@google.com> 3573 3574 Reviewed by Shinichiro Hamaji. 3575 3539 3576 Fix Bug 40452: REGRESSION: printing is broken if stylesheet has @page 3540 3577 https://bugs.webkit.org/show_bug.cgi?id=40452 -
trunk/WebCore/WebCore.base.exp
r61178 r61232 249 249 __ZN7WebCore12IconDatabase9setClientEPNS_18IconDatabaseClientE 250 250 __ZN7WebCore12PluginWidget14invalidateRectERKNS_7IntRectE 251 __ZN7WebCore12PrintContext12pagePropertyEPNS_5FrameEPKci 251 252 __ZN7WebCore12PrintContext13numberOfPagesEPNS_5FrameERKNS_9FloatSizeE 252 253 __ZN7WebCore12PrintContext20pageNumberForElementEPNS_7ElementERKNS_9FloatSizeE -
trunk/WebCore/css/CSSGrammar.y
r60227 r61232 779 779 $$ = p->createFloatingSelector(); 780 780 $$->m_tag = QualifiedName(nullAtom, $1, p->m_defaultNamespace); 781 $$->setForPage(); 781 782 } 782 783 | IDENT pseudo_page { 783 784 CSSParser* p = static_cast<CSSParser*>(parser); 784 785 $$ = $2; 786 if ($$) { 787 $$->m_tag = QualifiedName(nullAtom, $1, p->m_defaultNamespace); 788 $$->setForPage(); 789 } 790 } 791 | pseudo_page { 792 $$ = $1; 785 793 if ($$) 786 $$->m_tag = QualifiedName(nullAtom, $1, p->m_defaultNamespace); 787 } 788 | pseudo_page { 789 $$ = $1; 794 $$->setForPage(); 790 795 } 791 796 | /* empty */ { 792 797 CSSParser* p = static_cast<CSSParser*>(parser); 793 798 $$ = p->createFloatingSelector(); 799 $$->setForPage(); 794 800 } 795 801 ; -
trunk/WebCore/css/CSSSelector.cpp
r60880 r61232 38 38 unsigned int CSSSelector::specificity() 39 39 { 40 if (m_isForPage) 41 return specificityForPage(); 42 40 43 // FIXME: Pseudo-elements and pseudo-classes do not have the same specificity. This function 41 44 // isn't quite correct. … … 65 68 // make sure it doesn't overflow 66 69 return s & 0xffffff; 70 } 71 72 unsigned CSSSelector::specificityForPage() 73 { 74 // See http://dev.w3.org/csswg/css3-page/#cascading-and-page-context 75 unsigned s = (m_tag.localName() == starAtom ? 0 : 4); 76 77 switch (pseudoType()) { 78 case PseudoFirstPage: 79 s += 2; 80 break; 81 case PseudoLeftPage: 82 case PseudoRightPage: 83 s += 1; 84 break; 85 case PseudoNotParsed: 86 break; 87 default: 88 ASSERT_NOT_REACHED(); 89 } 90 return s; 67 91 } 68 92 -
trunk/WebCore/css/CSSSelector.h
r59751 r61232 40 40 , m_isLastInSelectorList(false) 41 41 , m_hasRareData(false) 42 , m_isForPage(false) 42 43 , m_tag(anyQName()) 43 44 { … … 51 52 , m_isLastInSelectorList(false) 52 53 , m_hasRareData(false) 54 , m_isForPage(false) 53 55 , m_tag(qName) 54 56 { … … 254 256 bool isSimple() const; 255 257 258 bool isForPage() const { return m_isForPage; } 259 void setForPage() { m_isForPage = true; } 260 256 261 unsigned m_relation : 3; // enum Relation 257 262 mutable unsigned m_match : 4; // enum Match … … 262 267 bool m_isLastInSelectorList : 1; 263 268 bool m_hasRareData : 1; 264 269 bool m_isForPage : 1; 270 271 unsigned specificityForPage(); 265 272 void extractPseudoType() const; 266 273 -
trunk/WebCore/css/CSSStyleSelector.cpp
r61094 r61232 1549 1549 } 1550 1550 1551 PassRefPtr<RenderStyle> CSSStyleSelector::styleForPage(int pageIndex) 1552 { 1553 initForStyleResolve(m_checker.m_document->body()); 1554 1555 m_style = RenderStyle::create(); 1556 m_style->inheritFrom(m_rootElementStyle); 1557 1558 const bool isLeft = isLeftPage(pageIndex); 1559 const bool isFirst = isFirstPage(pageIndex); 1560 const String page = pageName(pageIndex); 1561 matchPageRules(defaultPrintStyle, isLeft, isFirst, page); 1562 matchPageRules(m_userStyle, isLeft, isFirst, page); 1563 matchPageRules(m_authorStyle, isLeft, isFirst, page); 1564 m_lineHeightValue = 0; 1565 applyDeclarations<true>(false, 0, m_matchedDecls.size() - 1); 1566 1567 // If our font got dirtied, go ahead and update it now. 1568 if (m_fontDirty) 1569 updateFont(); 1570 1571 // Line-height is set when we are sure we decided on the font-size 1572 if (m_lineHeightValue) 1573 applyProperty(CSSPropertyLineHeight, m_lineHeightValue); 1574 1575 applyDeclarations<false>(false, 0, m_matchedDecls.size() - 1); 1576 1577 // Now return the style. 1578 return m_style.release(); 1579 } 1580 1551 1581 #if ENABLE(DATAGRID) 1552 1582 … … 2888 2918 } 2889 2919 } 2920 } 2921 2922 void CSSStyleSelector::matchPageRules(CSSRuleSet* rules, bool isLeftPage, bool isFirstPage, const String& pageName) 2923 { 2924 m_matchedRules.clear(); 2925 2926 if (!rules) 2927 return; 2928 2929 matchPageRulesForList(rules->getPageRules(), isLeftPage, isFirstPage, pageName); 2930 2931 // If we didn't match any rules, we're done. 2932 if (m_matchedRules.isEmpty()) 2933 return; 2934 2935 // Sort the set of matched rules. 2936 sortMatchedRules(0, m_matchedRules.size()); 2937 2938 // Now transfer the set of matched rules over to our list of decls. 2939 for (unsigned i = 0; i < m_matchedRules.size(); i++) 2940 addMatchedDeclaration(m_matchedRules[i]->rule()->declaration()); 2941 } 2942 2943 void CSSStyleSelector::matchPageRulesForList(CSSRuleDataList* rules, bool isLeftPage, bool isFirstPage, const String& pageName) 2944 { 2945 if (!rules) 2946 return; 2947 2948 for (CSSRuleData* d = rules->first(); d; d = d->next()) { 2949 CSSStyleRule* rule = d->rule(); 2950 const AtomicString& selectorLocalName = d->selector()->m_tag.localName(); 2951 if (selectorLocalName != starAtom && selectorLocalName != pageName) 2952 continue; 2953 CSSSelector::PseudoType pseudoType = d->selector()->pseudoType(); 2954 if ((pseudoType == CSSSelector::PseudoLeftPage && !isLeftPage) 2955 || (pseudoType == CSSSelector::PseudoRightPage && isLeftPage) 2956 || (pseudoType == CSSSelector::PseudoFirstPage && !isFirstPage)) 2957 continue; 2958 2959 // If the rule has no properties to apply, then ignore it. 2960 CSSMutableStyleDeclaration* decl = rule->declaration(); 2961 if (!decl || !decl->length()) 2962 continue; 2963 2964 // Add this rule to our list of matched rules. 2965 addMatchedRule(d); 2966 } 2967 } 2968 2969 bool CSSStyleSelector::isLeftPage(int pageIndex) const 2970 { 2971 bool isFirstPageLeft = false; 2972 if (m_rootElementStyle->direction() == RTL) 2973 isFirstPageLeft = true; 2974 2975 return (pageIndex + (isFirstPageLeft ? 1 : 0)) % 2; 2976 } 2977 2978 bool CSSStyleSelector::isFirstPage(int pageIndex) const 2979 { 2980 // FIXME: In case of forced left/right page, page at index 1 (not 0) can be the first page. 2981 return (!pageIndex); 2982 } 2983 2984 String CSSStyleSelector::pageName(int /* pageIndex */) const 2985 { 2986 // FIXME: Implement page index to page name mapping. 2987 return ""; 2890 2988 } 2891 2989 -
trunk/WebCore/css/CSSStyleSelector.h
r59387 r61232 94 94 PassRefPtr<RenderStyle> pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle = 0, bool matchVisitedPseudoClass = false); 95 95 96 PassRefPtr<RenderStyle> styleForPage(int pageIndex); 97 96 98 static PassRefPtr<RenderStyle> styleForDocument(Document*); 97 99 … … 181 183 template <bool firstPass> 182 184 void applyDeclarations(bool important, int startIndex, int endIndex); 185 186 void matchPageRules(CSSRuleSet*, bool isLeftPage, bool isFirstPage, const String& pageName); 187 void matchPageRulesForList(CSSRuleDataList*, bool isLeftPage, bool isFirstPage, const String& pageName); 188 bool isLeftPage(int pageIndex) const; 189 bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } 190 bool isFirstPage(int pageIndex) const; 191 String pageName(int pageIndex) const; 183 192 184 193 CSSRuleSet* m_authorStyle; -
trunk/WebCore/css/html.css
r59541 r61232 684 684 } 685 685 686 /* page */ 687 688 @page { 689 /* FIXME: Define the right default values for page properties. */ 690 margin: 1in; 691 } 692 686 693 /* noscript is handled internally, as it depends on settings */ -
trunk/WebCore/dom/Document.cpp
r61126 r61232 1497 1497 } 1498 1498 1499 PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex) 1500 { 1501 RefPtr<RenderStyle> style = styleSelector()->styleForPage(pageIndex); 1502 return style.release(); 1503 } 1504 1499 1505 void Document::createStyleSelector() 1500 1506 { -
trunk/WebCore/dom/Document.h
r61126 r61232 483 483 void updateLayoutIgnorePendingStylesheets(); 484 484 PassRefPtr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*); 485 PassRefPtr<RenderStyle> styleForPage(int pageIndex); 485 486 static void updateStyleForAllDocuments(); // FIXME: Try to reduce the # of calls to this function. 486 487 DocLoader* docLoader() { return m_docLoader.get(); } -
trunk/WebCore/page/PrintContext.cpp
r60943 r61232 200 200 } 201 201 202 String PrintContext::pageProperty(Frame* frame, const char* propertyName, int pageNumber) 203 { 204 Document* document = frame->document(); 205 document->updateLayout(); 206 RefPtr<RenderStyle> style = document->styleForPage(pageNumber); 207 208 // Implement formatters for properties we care about. 209 if (!strcmp(propertyName, "margin-left")) 210 return String::format("%d", style->marginLeft().rawValue()); 211 if (!strcmp(propertyName, "line-height")) 212 return String::format("%d", style->lineHeight().rawValue()); 213 if (!strcmp(propertyName, "font-size")) 214 return String::format("%d", style->fontDescription().computedPixelSize()); 215 if (!strcmp(propertyName, "font-family")) 216 return String::format("%s", style->fontDescription().family().family().string().utf8().data()); 217 218 return String::format("pageProperty() unimplemented for: %s", propertyName); 219 } 220 202 221 int PrintContext::numberOfPages(Frame* frame, const FloatSize& pageSizeInPixels) 203 222 { -
trunk/WebCore/page/PrintContext.h
r57384 r61232 32 32 class GraphicsContext; 33 33 class IntRect; 34 class String; 34 35 35 36 class PrintContext { … … 55 56 // Used by layout tests. 56 57 static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels); 58 static String pageProperty(Frame* frame, const char* propertyName, int pageNumber); 57 59 static int numberOfPages(Frame*, const FloatSize& pageSizeInPixels); 58 60 -
trunk/WebKit/mac/ChangeLog
r61217 r61232 1 2010-06-10 Yuzo Fujishima <yuzo@google.com> 2 3 Reviewed by Shinichiro Hamaji. 4 5 Implement render style selection for pages to support CSS3 Paged Media. 6 https://bugs.webkit.org/show_bug.cgi?id=35961 7 8 * Misc/WebCoreStatistics.h: 9 * Misc/WebCoreStatistics.mm: 10 (-[WebFrame pageProperty:propertyName:]): 11 1 12 2010-06-15 Darin Adler <darin@apple.com> 2 13 -
trunk/WebKit/mac/Misc/WebCoreStatistics.h
r58386 r61232 88 88 - (int)pageNumberForElement:(DOMElement*)element:(float)pageWidthInPixels:(float)pageHeightInPixels; 89 89 - (int)numberOfPages:(float)pageWidthInPixels:(float)pageHeightInPixels; 90 - (NSString *)pageProperty:(const char*)propertyName:(int)pageNumber; 90 91 @end -
trunk/WebKit/mac/Misc/WebCoreStatistics.mm
r58386 r61232 276 276 } 277 277 278 - (NSString *)pageProperty:(const char *)propertyName:(int)pageNumber 279 { 280 return PrintContext::pageProperty(_private->coreFrame, propertyName, pageNumber); 281 } 282 278 283 @end -
trunk/WebKitTools/ChangeLog
r61222 r61232 1 2010-06-10 Yuzo Fujishima <yuzo@google.com> 2 3 Reviewed by Shinichiro Hamaji. 4 5 Implement render style selection for pages to support CSS3 Paged Media. 6 https://bugs.webkit.org/show_bug.cgi?id=35961 7 8 * DumpRenderTree/LayoutTestController.cpp: 9 (parsePagePropertyParameters): 10 (pagePropertyCallback): 11 (LayoutTestController::staticFunctions): 12 * DumpRenderTree/LayoutTestController.h: 13 * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: 14 (LayoutTestController::pageProperty): 15 * DumpRenderTree/mac/LayoutTestControllerMac.mm: 16 (LayoutTestController::pageProperty): 17 * DumpRenderTree/win/LayoutTestControllerWin.cpp: 18 (LayoutTestController::pageProperty): 19 1 20 2010-06-15 Sam Weinig <sam@webkit.org> 2 21 -
trunk/WebKitTools/DumpRenderTree/LayoutTestController.cpp
r59840 r61232 522 522 } 523 523 524 // Caller needs to delete[] propertyName. 525 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber) 526 { 527 pageNumber = 0; 528 switch (argumentCount) { 529 case 2: 530 pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception)); 531 if (*exception) 532 return false; 533 // Fall through. 534 case 1: { 535 JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception)); 536 if (*exception) 537 return false; 538 539 size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get()); 540 propertyName = new char[maxLength + 1]; 541 JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1); 542 return true; 543 } 544 case 0: 545 default: 546 return false; 547 } 548 } 549 524 550 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 525 551 { … … 547 573 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); 548 574 return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels)); 575 } 576 577 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 578 { 579 char* propertyName = 0; 580 int pageNumber = 0; 581 if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber)) 582 return JSValueMakeUndefined(context); 583 584 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); 585 JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get()); 586 587 delete[] propertyName; 588 return value; 549 589 } 550 590 … … 1602 1642 { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1603 1643 { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1644 { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1604 1645 { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1605 1646 { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, -
trunk/WebKitTools/DumpRenderTree/LayoutTestController.h
r59840 r61232 63 63 void overridePreference(JSStringRef key, JSStringRef value); 64 64 int pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels); 65 JSRetainPtr<JSStringRef> pageProperty(const char* propertyName, int pageNumber) const; 65 66 JSStringRef pathToLocalResource(JSContextRef, JSStringRef url); 66 67 void queueBackNavigation(int howFarBackward); -
trunk/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
r59840 r61232 172 172 } 173 173 174 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const 175 { 176 // FIXME: implement 177 return JSRetainPtr<JSStringRef>(); 178 } 179 174 180 size_t LayoutTestController::webHistoryItemCount() 175 181 { -
trunk/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
r60488 r61232 213 213 } 214 214 215 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const 216 { 217 JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame pageProperty:propertyName:pageNumber])); 218 return propertyValue; 219 } 220 215 221 int LayoutTestController::numberOfPages(float pageWidthInPixels, float pageHeightInPixels) 216 222 { -
trunk/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
r59840 r61232 1238 1238 } 1239 1239 1240 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const 1241 { 1242 // FIXME: Implement this. 1243 return JSRetainPtr<JSStringRef>(); 1244 } 1245 1240 1246 void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL) 1241 1247 {
Note: See TracChangeset
for help on using the changeset viewer.