Changeset 77257 in webkit
- Timestamp:
- Feb 1, 2011 10:44:10 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r77254 r77257 1 2011-02-01 Dave Hyatt <hyatt@apple.com> 2 3 Reviewed by Darin Adler. 4 5 https://bugs.webkit.org/show_bug.cgi?id=46422, make printing and pagination work 6 with vertical text. 7 8 Change printing functions to check writing-mode and properly swap width and height 9 as needed. 10 11 Fix the setScrollOrigin function so that the origin doesn't cause 12 scroll spasming during printing (this is only partially successful, but it's better 13 than it was). 14 15 Rewrite computePageRects to handle both RTL documents properly as well as vertical 16 text documents properly. 17 18 * WebCore.exp.in: 19 * page/FrameView.cpp: 20 (WebCore::FrameView::adjustViewSize): 21 (WebCore::FrameView::forceLayoutForPagination): 22 * page/PrintContext.cpp: 23 (WebCore::PrintContext::computePageRects): 24 (WebCore::PrintContext::computePageRectsWithPageSizeInternal): 25 (WebCore::PrintContext::computeAutomaticScaleFactor): 26 (WebCore::PrintContext::spoolPage): 27 (WebCore::PrintContext::spoolRect): 28 * page/PrintContext.h: 29 * page/mac/WebCoreFrameView.h: 30 * platform/ScrollView.cpp: 31 (WebCore::ScrollView::wheelEvent): 32 * platform/ScrollView.h: 33 * platform/mac/ScrollViewMac.mm: 34 (WebCore::ScrollView::platformSetScrollOrigin): 35 * rendering/RenderView.cpp: 36 (WebCore::RenderView::layout): 37 1 38 2011-02-01 Mikhail Naganov <mnaganov@chromium.org> 2 39 -
trunk/Source/WebCore/WebCore.exp.in
r77220 r77257 267 267 __ZN7WebCore12PrintContext20pageNumberForElementEPNS_7ElementERKNS_9FloatSizeE 268 268 __ZN7WebCore12PrintContext26pageSizeAndMarginsInPixelsEPNS_5FrameEiiiiiii 269 __ZN7WebCore12PrintContext27computeAutomaticScaleFactorE f269 __ZN7WebCore12PrintContext27computeAutomaticScaleFactorERKNS_9FloatSizeE 270 270 __ZN7WebCore12PrintContext27spoolAllPagesWithBoundariesEPNS_5FrameERNS_15GraphicsContextERKNS_9FloatSizeE 271 271 __ZN7WebCore12PrintContext28computePageRectsWithPageSizeERKNS_9FloatSizeEb … … 1222 1222 __ZTVN7WebCore17FrameLoaderClientE 1223 1223 __ZTVN7WebCore25HistoryPropertyListWriterE 1224 __ZNK7WebCore12RenderObject4viewEv 1225 __ZNK7WebCore10RenderView7docLeftEv 1226 __ZNK7WebCore10RenderView6docTopEv 1227 __ZNK7WebCore10RenderView8docRightEv 1228 __ZNK7WebCore10RenderView9docBottomEv 1229 __ZNK7WebCore8Document10renderViewEv 1224 1230 _filenameByFixingIllegalCharacters 1225 1231 _hasCaseInsensitiveSubstring … … 1437 1443 __ZN7WebCore16jsStringSlowCaseEPN3JSC9ExecStateERNS0_9WeakGCMapIPN3WTF10StringImplENS0_8JSStringEEES6_ 1438 1444 __ZN7WebCore17HTMLPlugInElement11getNPObjectEv 1439 __ZNK7WebCore12RenderObject4viewEv1440 1445 __ZNK7WebCore14SecurityOrigin9canAccessEPKS0_ 1441 1446 __ZNK7WebCore4KURL10protocolIsEPKc -
trunk/Source/WebCore/page/FrameView.cpp
r76872 r77257 454 454 IntSize size = IntSize(root->docWidth(), root->docHeight()); 455 455 456 ScrollView::setScrollOrigin(IntPoint(-root->docLeft(), -root->docTop()), size == contentsSize());456 ScrollView::setScrollOrigin(IntPoint(-root->docLeft(), -root->docTop()), !m_frame->document()->printing(), size == contentsSize()); 457 457 458 458 setContentsSize(size); … … 2278 2278 RenderView *root = toRenderView(m_frame->document()->renderer()); 2279 2279 if (root) { 2280 int pageW = ceilf(pageSize.width()); 2281 root->setWidth(pageW); 2282 root->setPageLogicalHeight(pageSize.height()); 2280 float pageLogicalWidth = root->style()->isHorizontalWritingMode() ? pageSize.width() : pageSize.height(); 2281 float pageLogicalHeight = root->style()->isHorizontalWritingMode() ? pageSize.height() : pageSize.width(); 2282 2283 int flooredPageLogicalWidth = static_cast<int>(pageLogicalWidth); 2284 root->setLogicalWidth(flooredPageLogicalWidth); 2285 root->setPageLogicalHeight(pageLogicalHeight); 2283 2286 root->setNeedsLayoutAndPrefWidthsRecalc(); 2284 2287 forceLayout(); 2285 2288 2286 2289 // If we don't fit in the given page width, we'll lay out again. If we don't fit in the 2287 2290 // page width when shrunk, we will lay out at maximum shrink and clip extra content. 2288 2291 // FIXME: We are assuming a shrink-to-fit printing implementation. A cropping 2289 2292 // implementation should not do this! 2290 int doc Width = root->docWidth();2291 if (doc Width > pageSize.width()) {2292 pageW = std::min<int>(docWidth, ceilf(pageSize.width() * maximumShrinkFactor));2293 if (page Size.height())2294 root->setPageLogicalHeight( pageW/ pageSize.width() * pageSize.height());2295 root->set Width(pageW);2293 int docLogicalWidth = root->style()->isHorizontalWritingMode() ? root->docWidth() : root->docHeight(); 2294 if (docLogicalWidth > pageLogicalWidth) { 2295 flooredPageLogicalWidth = std::min<int>(docLogicalWidth, pageLogicalWidth * maximumShrinkFactor); 2296 if (pageLogicalHeight) 2297 root->setPageLogicalHeight(flooredPageLogicalWidth / pageSize.width() * pageSize.height()); 2298 root->setLogicalWidth(flooredPageLogicalWidth); 2296 2299 root->setNeedsLayoutAndPrefWidthsRecalc(); 2297 2300 forceLayout(); 2298 int docHeight = root->docHeight();2299 2301 root->clearLayoutOverflow(); 2300 root->addLayoutOverflow(IntRect(0, 0, pageW, docHeight)); // This is how we clip in case we overflow again. 2302 int docLogicalHeight = root->style()->isHorizontalWritingMode() ? root->docHeight() : root->docWidth(); 2303 int docLogicalTop = root->style()->isHorizontalWritingMode() ? root->docTop() : root->docLeft(); 2304 int docLogicalRight = root->style()->isHorizontalWritingMode() ? root->docRight() : root->docBottom(); 2305 int clippedLogicalLeft = 0; 2306 if (!root->style()->isLeftToRightDirection()) 2307 clippedLogicalLeft = docLogicalRight - flooredPageLogicalWidth; 2308 IntRect overflow(clippedLogicalLeft, docLogicalTop, flooredPageLogicalWidth, docLogicalHeight); 2309 if (!root->style()->isHorizontalWritingMode()) 2310 overflow = overflow.transposedRect(); 2311 root->addLayoutOverflow(overflow); // This is how we clip in case we overflow again. 2301 2312 } 2302 2313 } -
trunk/Source/WebCore/page/PrintContext.cpp
r76821 r77257 81 81 RenderView* view = toRenderView(m_frame->document()->renderer()); 82 82 83 float ratio = printRect.height() / printRect.width(); 84 85 float pageWidth = view->docWidth(); 86 float pageHeight = floorf(pageWidth * ratio); 83 bool isHorizontal = view->style()->isHorizontalWritingMode(); 84 85 float pageWidth; 86 float pageHeight; 87 if (isHorizontal) { 88 float ratio = printRect.height() / printRect.width(); 89 pageWidth = view->docWidth(); 90 pageHeight = floorf(pageWidth * ratio); 91 } else { 92 float ratio = printRect.width() / printRect.height(); 93 pageHeight = view->docHeight(); 94 pageWidth = floorf(pageHeight * ratio); 95 } 96 87 97 outPageHeight = pageHeight; // this is the height of the page adjusted by margins 88 98 pageHeight -= headerHeight + footerHeight; … … 102 112 } 103 113 104 void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allow HorizontalTiling)114 void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowInlineDirectionTiling) 105 115 { 106 116 if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderer()) … … 114 124 int pageHeight = pageSizeInPixels.height(); 115 125 116 unsigned pageCount = ceilf((float)docRect.height() / pageHeight); 126 bool isHorizontal = view->style()->isHorizontalWritingMode(); 127 128 int docLogicalHeight = isHorizontal ? docRect.height() : docRect.width(); 129 int pageLogicalHeight = isHorizontal ? pageHeight : pageWidth; 130 int pageLogicalWidth = isHorizontal ? pageWidth : pageHeight; 131 132 int inlineDirectionStart; 133 int inlineDirectionEnd; 134 int blockDirectionStart; 135 int blockDirectionEnd; 136 if (isHorizontal) { 137 if (view->style()->isFlippedBlocksWritingMode()) { 138 blockDirectionStart = docRect.bottom(); 139 blockDirectionEnd = docRect.y(); 140 } else { 141 blockDirectionStart = docRect.y(); 142 blockDirectionEnd = docRect.bottom(); 143 } 144 inlineDirectionStart = view->style()->isLeftToRightDirection() ? docRect.x() : docRect.right(); 145 inlineDirectionEnd = view->style()->isLeftToRightDirection() ? docRect.right() : docRect.x(); 146 } else { 147 if (view->style()->isFlippedBlocksWritingMode()) { 148 blockDirectionStart = docRect.right(); 149 blockDirectionEnd = docRect.x(); 150 } else { 151 blockDirectionStart = docRect.x(); 152 blockDirectionEnd = docRect.right(); 153 } 154 inlineDirectionStart = view->style()->isLeftToRightDirection() ? docRect.y() : docRect.bottom(); 155 inlineDirectionEnd = view->style()->isLeftToRightDirection() ? docRect.bottom() : docRect.y(); 156 } 157 158 unsigned pageCount = ceilf((float)docLogicalHeight / pageLogicalHeight); 117 159 for (unsigned i = 0; i < pageCount; ++i) { 118 if (allowHorizontalTiling) { 119 for (int currentX = docRect.x(); currentX < docRect.right(); currentX += pageWidth) 120 m_pageRects.append(IntRect(currentX, docRect.y() + i * pageHeight, pageWidth, pageHeight)); 121 } else 122 m_pageRects.append(IntRect(docRect.x(), docRect.y() + i * pageHeight, pageWidth, pageHeight)); 160 int pageLogicalTop = blockDirectionEnd > blockDirectionStart ? 161 blockDirectionStart + i * pageLogicalHeight : 162 blockDirectionStart - (i + 1) * pageLogicalHeight; 163 if (allowInlineDirectionTiling) { 164 for (int currentInlinePosition = inlineDirectionStart; 165 inlineDirectionEnd > inlineDirectionStart ? currentInlinePosition < inlineDirectionEnd : currentInlinePosition > inlineDirectionEnd; 166 currentInlinePosition += (inlineDirectionEnd > inlineDirectionStart ? pageLogicalWidth : -pageLogicalWidth)) { 167 int pageLogicalLeft = inlineDirectionEnd > inlineDirectionStart ? currentInlinePosition : currentInlinePosition - pageLogicalWidth; 168 IntRect pageRect(pageLogicalLeft, pageLogicalTop, pageLogicalWidth, pageLogicalHeight); 169 if (!isHorizontal) 170 pageRect = pageRect.transposedRect(); 171 m_pageRects.append(pageRect); 172 } 173 } else { 174 int pageLogicalLeft = inlineDirectionEnd > inlineDirectionStart ? inlineDirectionStart : inlineDirectionStart - pageLogicalWidth; 175 IntRect pageRect(pageLogicalLeft, pageLogicalTop, pageLogicalWidth, pageLogicalHeight); 176 if (!isHorizontal) 177 pageRect = pageRect.transposedRect(); 178 m_pageRects.append(pageRect); 179 } 123 180 } 124 181 } … … 136 193 } 137 194 138 float PrintContext::computeAutomaticScaleFactor( float availablePaperWidth)195 float PrintContext::computeAutomaticScaleFactor(const FloatSize& availablePaperSize) 139 196 { 140 197 if (!m_frame->view()) 141 198 return 1; 142 199 143 float viewWidth = m_frame->view()->contentsWidth(); 144 if (viewWidth < 1) 200 bool useViewWidth = true; 201 if (m_frame->document() && m_frame->document()->renderView()) 202 useViewWidth = m_frame->document()->renderView()->style()->isHorizontalWritingMode(); 203 204 float viewLogicalWidth = useViewWidth ? m_frame->view()->contentsWidth() : m_frame->view()->contentsHeight(); 205 if (viewLogicalWidth < 1) 145 206 return 1; 146 207 147 208 float maxShrinkToFitScaleFactor = 1 / printingMaximumShrinkFactor; 148 float shrinkToFitScaleFactor = availablePaperWidth / viewWidth;209 float shrinkToFitScaleFactor = (useViewWidth ? availablePaperSize.width() : availablePaperSize.height()) / viewLogicalWidth; 149 210 return max(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor); 150 211 } … … 152 213 void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width) 153 214 { 215 // FIXME: Not correct for vertical text. 154 216 IntRect pageRect = m_pageRects[pageNumber]; 155 217 float scale = width / pageRect.width(); … … 165 227 void PrintContext::spoolRect(GraphicsContext& ctx, const IntRect& rect) 166 228 { 229 // FIXME: Not correct for vertical text. 167 230 ctx.save(); 168 231 ctx.translate(-rect.x(), -rect.y()); -
trunk/Source/WebCore/page/PrintContext.h
r75955 r77257 55 55 const Vector<IntRect>& pageRects() const { return m_pageRects; } 56 56 57 float computeAutomaticScaleFactor( float availablePaperWidth);57 float computeAutomaticScaleFactor(const FloatSize& availablePaperSize); 58 58 59 59 // Enter print mode, updating layout for new page size. -
trunk/Source/WebCore/page/mac/WebCoreFrameView.h
r73063 r77257 34 34 - (void)scrollingModes:(WebCore::ScrollbarMode*)hMode vertical:(WebCore::ScrollbarMode*)vMode; 35 35 - (void)setScrollBarsSuppressed:(BOOL)suppressed repaintOnUnsuppress:(BOOL)repaint; 36 - (void)setScrollOrigin:(NSPoint)origin updatePosition :(BOOL)updatePosition;36 - (void)setScrollOrigin:(NSPoint)origin updatePositionAtAll:(BOOL)updatePositionAtAll immediately:(BOOL)updatePositionImmediately; 37 37 - (NSPoint)scrollOrigin; 38 38 @end -
trunk/Source/WebCore/platform/ScrollView.cpp
r76956 r77257 1095 1095 } 1096 1096 1097 void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePosition )1097 void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAll, bool updatePositionSynchronously) 1098 1098 { 1099 1099 if (m_scrollOrigin == origin) … … 1103 1103 1104 1104 if (platformWidget()) { 1105 platformSetScrollOrigin(origin, updatePosition );1105 platformSetScrollOrigin(origin, updatePositionAtAll, updatePositionSynchronously); 1106 1106 return; 1107 1107 } 1108 1108 1109 1109 // Update if the scroll origin changes, since our position will be different if the content size did not change. 1110 if (updatePosition )1110 if (updatePositionAtAll && updatePositionSynchronously) 1111 1111 updateScrollbars(scrollOffset()); 1112 1112 } … … 1142 1142 } 1143 1143 1144 void ScrollView::platformSetScrollOrigin(const IntPoint&, bool updatePosition )1144 void ScrollView::platformSetScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updatePositionSynchronously) 1145 1145 { 1146 1146 } -
trunk/Source/WebCore/platform/ScrollView.h
r76956 r77257 297 297 virtual void scrollContentsSlowPath(const IntRect& updateRect); 298 298 299 void setScrollOrigin(const IntPoint&, bool updatePosition );299 void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updatePositionSynchronously); 300 300 IntPoint scrollOrigin() { return m_scrollOrigin; } 301 301 … … 384 384 bool platformIsOffscreen() const; 385 385 386 void platformSetScrollOrigin(const IntPoint&, bool updatePosition );386 void platformSetScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updatePositionSynchronously); 387 387 388 388 #if PLATFORM(MAC) && defined __OBJC__ -
trunk/Source/WebCore/platform/mac/ScrollViewMac.mm
r73063 r77257 204 204 } 205 205 206 void ScrollView::platformSetScrollOrigin(const IntPoint& origin, bool updatePosition )207 { 208 BEGIN_BLOCK_OBJC_EXCEPTIONS; 209 [scrollView() setScrollOrigin:origin updatePosition :updatePosition];206 void ScrollView::platformSetScrollOrigin(const IntPoint& origin, bool updatePositionAtAll, bool updatePositionSynchronously) 207 { 208 BEGIN_BLOCK_OBJC_EXCEPTIONS; 209 [scrollView() setScrollOrigin:origin updatePositionAtAll:updatePositionAtAll immediately:updatePositionSynchronously]; 210 210 END_BLOCK_OBJC_EXCEPTIONS; 211 211 } -
trunk/Source/WebCore/rendering/RenderView.cpp
r75892 r77257 106 106 107 107 if (printing()) 108 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = width();108 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth(); 109 109 110 110 // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. -
trunk/Source/WebKit/mac/ChangeLog
r77151 r77257 1 2011-02-01 Dave Hyatt <hyatt@apple.com> 2 3 Reviewed by Darin Adler. 4 5 https://bugs.webkit.org/show_bug.cgi?id=46422, make printing and pagination work 6 with vertical text. 7 8 Change printing functions to check writing-mode and properly swap width and height 9 as needed. 10 11 * WebView/WebDynamicScrollBarsView.mm: 12 (-[WebDynamicScrollBarsView setScrollOrigin:updatePositionAtAll:immediately:]): 13 * WebView/WebFrame.mm: 14 (-[WebFrame _computePageRectsWithPrintScaleFactor:pageSize:]): 15 * WebView/WebFrameInternal.h: 16 * WebView/WebHTMLView.mm: 17 (-[WebHTMLView _web_setPrintingModeRecursive]): 18 (-[WebHTMLView _web_clearPrintingModeRecursive]): 19 (-[WebHTMLView _web_setPrintingModeRecursiveAndAdjustViewSize]): 20 (-[WebHTMLView _beginPrintModeWithMinimumPageWidth:height:maximumPageWidth:]): 21 (-[WebHTMLView _beginPrintModeWithPageWidth:height:shrinkToFit:]): 22 (-[WebHTMLView _endPrintMode]): 23 (-[WebHTMLView _beginScreenPaginationModeWithPageSize:shrinkToFit:]): 24 (-[WebHTMLView _endScreenPaginationMode]): 25 (-[WebHTMLView layoutToMinimumPageWidth:height:maximumPageWidth:adjustingViewSize:]): 26 (-[WebHTMLView _setPrinting:minimumPageLogicalWidth:logicalHeight:maximumPageLogicalWidth:adjustViewSize:paginateScreenContent:]): 27 (-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]): 28 (-[WebHTMLView _scaleFactorForPrintOperation:]): 29 (-[WebHTMLView setPageWidthForPrinting:]): 30 (-[WebHTMLView knowsPageRange:]): 31 1 32 2011-01-31 Oliver Hunt <oliver@apple.com> 2 33 -
trunk/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
r76044 r77257 569 569 } 570 570 571 - (void)setScrollOrigin:(NSPoint)scrollOrigin updatePosition :(BOOL)updatePosition571 - (void)setScrollOrigin:(NSPoint)scrollOrigin updatePositionAtAll:(BOOL)updatePositionAtAll immediately:(BOOL)updatePositionSynchronously 572 572 { 573 573 // The cross-platform ScrollView call already checked to see if the old/new scroll origins were the same or not … … 580 580 [docView setBoundsOrigin:NSMakePoint(-scrollOrigin.x, -scrollOrigin.y)]; 581 581 582 _private->scrollOriginChanged = true; 582 if (updatePositionAtAll) 583 _private->scrollOriginChanged = true; 583 584 584 585 // Maintain our original position in the presence of the new scroll origin. 585 586 _private->scrollPositionExcludingOrigin = NSMakePoint(visibleRect.origin.x + scrollOrigin.x, visibleRect.origin.y + scrollOrigin.y); 586 587 587 if (updatePosition ) // Otherwise we'll just let the snap happen when we update for the resize.588 if (updatePositionAtAll && updatePositionSynchronously) // Otherwise we'll just let the snap happen when we update for the resize. 588 589 [self adjustForScrollOriginChange]; 589 590 } -
trunk/Source/WebKit/mac/WebView/WebFrame.mm
r76107 r77257 588 588 589 589 // Used by pagination code called from AppKit when a standalone web page is printed. 590 - (NSArray*)_computePageRectsWithPrint WidthScaleFactor:(float)printWidthScaleFactor printHeight:(float)printHeight590 - (NSArray*)_computePageRectsWithPrintScaleFactor:(float)printScaleFactor pageSize:(NSSize)pageSize 591 591 { 592 592 NSMutableArray* pages = [NSMutableArray arrayWithCapacity:5]; 593 if (printWidthScaleFactor <= 0) { 594 LOG_ERROR("printWidthScaleFactor has bad value %.2f", printWidthScaleFactor); 595 return pages; 596 } 597 598 if (printHeight <= 0) { 599 LOG_ERROR("printHeight has bad value %.2f", printHeight); 593 if (printScaleFactor <= 0) { 594 LOG_ERROR("printScaleFactor has bad value %.2f", printScaleFactor); 600 595 return pages; 601 596 } … … 613 608 return pages; 614 609 615 float docWidth = root->layer()->width(); 616 float printWidth = docWidth / printWidthScaleFactor; 610 float docWidth = root->docWidth(); 611 float docHeight = root->docHeight(); 612 613 float printWidth = root->style()->isHorizontalWritingMode() ? docWidth / printScaleFactor : pageSize.width; 614 float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : docHeight / printScaleFactor; 617 615 618 616 PrintContext printContext(_private->coreFrame); -
trunk/Source/WebKit/mac/WebView/WebFrameInternal.h
r75031 r77257 125 125 - (void)_drawRect:(NSRect)rect contentsOnly:(BOOL)contentsOnly; 126 126 - (BOOL)_getVisibleRect:(NSRect*)rect; 127 - (NSArray*)_computePageRectsWithPrint WidthScaleFactor:(float)printWidthScaleFactor printHeight:(float)printHeight;127 - (NSArray*)_computePageRectsWithPrintScaleFactor:(float)printWidthScaleFactor pageSize:(NSSize)pageSize; 128 128 129 129 - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string; -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r76813 r77257 105 105 #import <WebCore/Range.h> 106 106 #import <WebCore/RenderWidget.h> 107 #import <WebCore/RenderView.h> 107 108 #import <WebCore/RuntimeApplicationChecks.h> 108 109 #import <WebCore/SelectionController.h> … … 429 430 430 431 @interface WebHTMLView (WebForwardDeclaration) // FIXME: Put this in a normal category and stop doing the forward declaration trick. 431 - (void)_setPrinting:(BOOL)printing minimumPage Width:(float)minPageWidth height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize paginateScreenContent:(BOOL)paginateScreenContent;432 - (void)_setPrinting:(BOOL)printing minimumPageLogicalWidth:(float)minPageWidth logicalHeight:(float)minPageHeight maximumPageLogicalWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize paginateScreenContent:(BOOL)paginateScreenContent; 432 433 @end 433 434 … … 1081 1082 - (void)_web_setPrintingModeRecursive 1082 1083 { 1083 [self _setPrinting:YES minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];1084 [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]]; 1084 1085 1085 1086 #ifndef NDEBUG … … 1093 1094 unsigned count = [descendantWebHTMLViews count]; 1094 1095 for (unsigned i = 0; i < count; ++i) 1095 [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];1096 [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]]; 1096 1097 1097 1098 [descendantWebHTMLViews release]; … … 1104 1105 - (void)_web_clearPrintingModeRecursive 1105 1106 { 1106 [self _setPrinting:NO minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];1107 [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]]; 1107 1108 1108 1109 #ifndef NDEBUG … … 1116 1117 unsigned count = [descendantWebHTMLViews count]; 1117 1118 for (unsigned i = 0; i < count; ++i) 1118 [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];1119 [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]]; 1119 1120 1120 1121 [descendantWebHTMLViews release]; … … 1127 1128 - (void)_web_setPrintingModeRecursiveAndAdjustViewSize 1128 1129 { 1129 [self _setPrinting:YES minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];1130 [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]]; 1130 1131 1131 1132 #ifndef NDEBUG … … 1139 1140 unsigned count = [descendantWebHTMLViews count]; 1140 1141 for (unsigned i = 0; i < count; ++i) 1141 [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];1142 [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]]; 1142 1143 1143 1144 [descendantWebHTMLViews release]; … … 2202 2203 } 2203 2204 2204 [self _setPrinting:YES minimumPage Width:minimumPageWidth height:minimumPageHeight maximumPageWidth:maximumPageWidth adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];2205 [self _setPrinting:YES minimumPageLogicalWidth:minimumPageWidth logicalHeight:minimumPageHeight maximumPageLogicalWidth:maximumPageWidth adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]]; 2205 2206 return YES; 2206 2207 } … … 2212 2213 return NO; 2213 2214 2214 float minLayoutWidth = 0; 2215 float minLayoutHeight = 0; 2216 float maxLayoutWidth = 0; 2215 Document* document = frame->document(); 2216 bool isHorizontal = !document || !document->renderView() || document->renderView()->style()->isHorizontalWritingMode(); 2217 2218 float minLayoutLogicalWidth = isHorizontal ? pageWidth : pageHeight; 2219 float minLayoutLogicalHeight = isHorizontal ? pageHeight : pageWidth; 2220 float maxLayoutLogicalWidth = minLayoutLogicalWidth; 2217 2221 2218 2222 // If we are a frameset just print with the layout we have onscreen, otherwise relayout 2219 2223 // according to the page width. 2220 if ( !frame->document() || !frame->document()->isFrameSet()) {2221 minLayout Width = shrinkToFit ? pageWidth * _WebHTMLViewPrintingMinimumShrinkFactor : pageWidth;2222 minLayout Height = shrinkToFit ? pageHeight * _WebHTMLViewPrintingMinimumShrinkFactor : pageHeight;2223 maxLayout Width = shrinkToFit ? pageWidth * _WebHTMLViewPrintingMaximumShrinkFactor : pageWidth;2224 } 2225 [self _setPrinting:YES minimumPage Width:minLayoutWidth height:minLayoutHeight maximumPageWidth:maxLayoutWidth adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];2224 if (shrinkToFit && (!frame->document() || !frame->document()->isFrameSet())) { 2225 minLayoutLogicalWidth *= _WebHTMLViewPrintingMinimumShrinkFactor; 2226 minLayoutLogicalHeight *= _WebHTMLViewPrintingMinimumShrinkFactor; 2227 maxLayoutLogicalWidth *= _WebHTMLViewPrintingMaximumShrinkFactor; 2228 } 2229 [self _setPrinting:YES minimumPageLogicalWidth:minLayoutLogicalWidth logicalHeight:minLayoutLogicalHeight maximumPageLogicalWidth:maxLayoutLogicalWidth adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]]; 2226 2230 2227 2231 return YES; … … 2230 2234 - (void)_endPrintMode 2231 2235 { 2232 [self _setPrinting:NO minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];2236 [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]]; 2233 2237 } 2234 2238 … … 2244 2248 return NO; 2245 2249 2246 CGFloat minLayoutWidth = 0; 2247 CGFloat minLayoutHeight = 0; 2248 CGFloat maxLayoutWidth = 0; 2249 2250 // If we are a frameset just print with the layout we have on the screen. Otherwise do a relayout 2250 Document* document = frame->document(); 2251 bool isHorizontal = !document || !document->renderView() || document->renderView()->style()->isHorizontalWritingMode(); 2252 2253 float minLayoutLogicalWidth = isHorizontal ? pageSize.width : pageSize.height; 2254 float minLayoutLogicalHeight = isHorizontal ? pageSize.height : pageSize.width; 2255 float maxLayoutLogicalWidth = minLayoutLogicalWidth; 2256 2257 // If we are a frameset just print with the layout we have onscreen, otherwise relayout 2251 2258 // according to the page width. 2252 if ( !frame->document() || !frame->document()->isFrameSet()) {2253 minLayout Width = shrinkToFit ? pageSize.width * _WebHTMLViewPrintingMinimumShrinkFactor : pageSize.width;2254 minLayout Height = shrinkToFit ? pageSize.height * _WebHTMLViewPrintingMinimumShrinkFactor : pageSize.height;2255 maxLayout Width = shrinkToFit ? pageSize.width * _WebHTMLViewPrintingMaximumShrinkFactor : pageSize.width;2256 } 2257 [self _setPrinting:[self _isInPrintMode] minimumPage Width:minLayoutWidth height:minLayoutHeight maximumPageWidth:maxLayoutWidth adjustViewSize:YES paginateScreenContent:YES];2259 if (shrinkToFit && (!frame->document() || !frame->document()->isFrameSet())) { 2260 minLayoutLogicalWidth *= _WebHTMLViewPrintingMinimumShrinkFactor; 2261 minLayoutLogicalHeight *= _WebHTMLViewPrintingMinimumShrinkFactor; 2262 maxLayoutLogicalWidth *= _WebHTMLViewPrintingMaximumShrinkFactor; 2263 } 2264 [self _setPrinting:[self _isInPrintMode] minimumPageLogicalWidth:minLayoutLogicalWidth logicalHeight:minLayoutLogicalHeight maximumPageLogicalWidth:maxLayoutLogicalWidth adjustViewSize:YES paginateScreenContent:YES]; 2258 2265 2259 2266 return YES; … … 2262 2269 - (void)_endScreenPaginationMode 2263 2270 { 2264 [self _setPrinting:[self _isInPrintMode] minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:YES paginateScreenContent:NO];2271 [self _setPrinting:[self _isInPrintMode] minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:YES paginateScreenContent:NO]; 2265 2272 } 2266 2273 … … 3118 3125 // Do a layout, but set up a new fixed width for the purposes of doing printing layout. 3119 3126 // minPageWidth==0 implies a non-printing layout 3120 - (void)layoutToMinimumPageWidth:(float)minPage Width height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustViewSize3127 - (void)layoutToMinimumPageWidth:(float)minPageLogicalWidth height:(float)minPageLogicalHeight maximumPageWidth:(float)maxPageLogicalWidth adjustingViewSize:(BOOL)adjustViewSize 3121 3128 { 3122 3129 if (![self _needsLayout]) … … 3134 3141 3135 3142 if (FrameView* coreView = coreFrame->view()) { 3136 if (minPageWidth > 0.0) 3137 coreView->forceLayoutForPagination(FloatSize(minPageWidth, minPageHeight), maxPageWidth / minPageWidth, adjustViewSize ? Frame::AdjustViewSize : Frame::DoNotAdjustViewSize); 3138 else { 3143 if (minPageLogicalWidth > 0.0) { 3144 FloatSize pageSize(minPageLogicalWidth, minPageLogicalHeight); 3145 if (coreFrame->document() && coreFrame->document()->renderView() && !coreFrame->document()->renderView()->style()->isHorizontalWritingMode()) 3146 pageSize = FloatSize(minPageLogicalHeight, minPageLogicalWidth); 3147 coreView->forceLayoutForPagination(pageSize, maxPageLogicalWidth / minPageLogicalWidth, adjustViewSize ? Frame::AdjustViewSize : Frame::DoNotAdjustViewSize); 3148 } else { 3139 3149 coreView->forceLayout(!adjustViewSize); 3140 3150 if (adjustViewSize) … … 3878 3888 // Does setNeedsDisplay:NO as a side effect when printing is ending. 3879 3889 // pageWidth != 0 implies we will relayout to a new width 3880 - (void)_setPrinting:(BOOL)printing minimumPage Width:(float)minPageWidth height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize paginateScreenContent:(BOOL)paginateScreenContent3890 - (void)_setPrinting:(BOOL)printing minimumPageLogicalWidth:(float)minPageLogicalWidth logicalHeight:(float)minPageLogicalHeight maximumPageLogicalWidth:(float)maxPageLogicalWidth adjustViewSize:(BOOL)adjustViewSize paginateScreenContent:(BOOL)paginateScreenContent 3881 3891 { 3882 3892 if (printing == _private->printing && paginateScreenContent == _private->paginateScreenContent) … … 3891 3901 WebFrameView *frameView = [subframe frameView]; 3892 3902 if ([[subframe _dataSource] _isDocumentHTML]) { 3893 [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:adjustViewSize paginateScreenContent:paginateScreenContent];3903 [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:adjustViewSize paginateScreenContent:paginateScreenContent]; 3894 3904 } 3895 3905 } … … 3912 3922 3913 3923 [self setNeedsLayout:YES]; 3914 [self layoutToMinimumPageWidth:minPage Width height:minPageHeight maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];3924 [self layoutToMinimumPageWidth:minPageLogicalWidth height:minPageLogicalHeight maximumPageWidth:maxPageLogicalWidth adjustingViewSize:adjustViewSize]; 3915 3925 if (!printing) { 3916 3926 // Can't do this when starting printing or nested printing won't work, see 3491427. … … 3932 3942 BOOL wasInPrintingMode = _private->printing; 3933 3943 if (!wasInPrintingMode) 3934 [self _setPrinting:YES minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];3944 [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]]; 3935 3945 3936 3946 *newBottom = [self _adjustedBottomOfPageWithTop:oldTop bottom:oldBottom limit:bottomLimit]; … … 3943 3953 else 3944 3954 // not sure if this is actually ever invoked, it probably shouldn't be 3945 [self _setPrinting:NO minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];3955 [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]]; 3946 3956 } 3947 3957 } … … 3949 3959 - (float)_scaleFactorForPrintOperation:(NSPrintOperation *)printOperation 3950 3960 { 3951 float viewWidth = NSWidth([self bounds]); 3952 if (viewWidth < 1) { 3953 LOG_ERROR("%@ has no width when printing", self); 3961 bool useViewWidth = true; 3962 Frame* coreFrame = core([self _frame]); 3963 if (coreFrame) { 3964 Document* document = coreFrame->document(); 3965 if (document && document->renderView()) 3966 useViewWidth = document->renderView()->style()->isHorizontalWritingMode(); 3967 } 3968 3969 float viewLogicalWidth = useViewWidth ? NSWidth([self bounds]) : NSHeight([self bounds]); 3970 if (viewLogicalWidth < 1) { 3971 LOG_ERROR("%@ has no logical width when printing", self); 3954 3972 return 1.0f; 3955 3973 } … … 3957 3975 float userScaleFactor = [printOperation _web_pageSetupScaleFactor]; 3958 3976 float maxShrinkToFitScaleFactor = 1.0f / _WebHTMLViewPrintingMaximumShrinkFactor; 3959 float shrinkToFitScaleFactor = [printOperation _web_availablePaperWidth] / viewWidth;3977 float shrinkToFitScaleFactor = (useViewWidth ? [printOperation _web_availablePaperWidth] : [printOperation _web_availablePaperHeight]) / viewLogicalWidth; 3960 3978 return userScaleFactor * max(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor); 3961 3979 } … … 3972 3990 - (void)setPageWidthForPrinting:(float)pageWidth 3973 3991 { 3974 [self _setPrinting:NO minimumPage Width:0 height:0 maximumPageWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];3975 [self _setPrinting:YES minimumPage Width:pageWidth height:0 maximumPageWidth:pageWidth adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];3992 [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumPageLogicalWidth:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]]; 3993 [self _setPrinting:YES minimumPageLogicalWidth:pageWidth logicalHeight:0 maximumPageLogicalWidth:pageWidth adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]]; 3976 3994 } 3977 3995 … … 4037 4055 float userScaleFactor = [printOperation _web_pageSetupScaleFactor]; 4038 4056 [_private->pageRects release]; 4057 float fullPageWidth = floorf([printOperation _web_availablePaperWidth] / totalScaleFactor); 4039 4058 float fullPageHeight = floorf([printOperation _web_availablePaperHeight] / totalScaleFactor); 4040 4059 WebFrame *frame = [self _frame]; 4041 NSArray *newPageRects = [frame _computePageRectsWithPrint WidthScaleFactor:userScaleFactor printHeight:fullPageHeight];4060 NSArray *newPageRects = [frame _computePageRectsWithPrintScaleFactor:userScaleFactor pageSize:NSMakeSize(fullPageWidth, fullPageHeight)]; 4042 4061 4043 4062 // AppKit gets all messed up if you give it a zero-length page count (see 3576334), so if we -
trunk/Source/WebKit2/ChangeLog
r77220 r77257 1 2011-02-01 Dave Hyatt <hyatt@apple.com> 2 3 Reviewed by Darin Adler. 4 5 https://bugs.webkit.org/show_bug.cgi?id=46422, make printing and pagination work 6 with vertical text. 7 8 Change printing functions to check writing-mode and properly swap width and height 9 as needed. 10 11 * WebProcess/WebPage/WebPage.cpp: 12 (WebKit::WebPage::computePagesForPrinting): 13 1 14 2011-01-31 Alexey Proskuryakov <ap@apple.com> 2 15 -
trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp
r76916 r77257 276 276 if (messageID == MessageID(CoreIPCMessage::SyncMessageReply)) { 277 277 MutexLocker locker(m_syncReplyStateMutex); 278 ASSERT(!m_pendingSyncReplies.isEmpty()); 279 280 PendingSyncReply& pendingSyncReply = m_pendingSyncReplies.last(); 281 ASSERT(pendingSyncReply.syncRequestID == arguments->destinationID()); 282 283 pendingSyncReply.replyDecoder = arguments.leakPtr(); 284 pendingSyncReply.didReceiveReply = true; 285 278 if (!m_pendingSyncReplies.isEmpty()) { 279 ASSERT(!m_pendingSyncReplies.isEmpty()); 280 281 PendingSyncReply& pendingSyncReply = m_pendingSyncReplies.last(); 282 ASSERT(pendingSyncReply.syncRequestID == arguments->destinationID()); 283 284 pendingSyncReply.replyDecoder = arguments.leakPtr(); 285 pendingSyncReply.didReceiveReply = true; 286 } 286 287 m_waitForSyncReplySemaphore.signal(); 287 288 return;
Note: See TracChangeset
for help on using the changeset viewer.