Changeset 75897 in webkit
- Timestamp:
- Jan 16, 2011, 5:07:24 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r75894 r75897 8 8 * plugins/qt/PluginViewQt.cpp: 9 9 (WebCore::setXKeyEventSpecificFields): map event text to keycode 10 11 2011-01-16 Simon Fraser <simon.fraser@apple.com> 12 13 Reviewed by Dan Bernstein. 14 15 Issues with iframes and plugins when the WebView is scaled. 16 <rdar://problem/6213380> 17 18 When _scaleWebView has been called on a WebView, iframes 19 in WebKit1 render and hit-test incorrectly, and plug-ins don't scale up. 20 This is caused by AppKit NSViews not playing nicely with the scale 21 applied through style. 22 23 Work around most of these issues by adjusting the bounds size 24 of widgets to allow iframe contents to paint with the correct scale, 25 and fix various places in the code where we relied on coordinate 26 transforms via NSViews (which ignore CSS transforms). 27 28 * WebCore.exp.in: 29 * platform/Widget.cpp: 30 (WebCore::Widget::setBoundsSize): 31 * platform/Widget.h: 32 * platform/mac/WidgetMac.mm: 33 (WebCore::Widget::setBoundsSize): 34 (WebCore::Widget::paint): 35 * rendering/RenderLayerCompositor.cpp: 36 (WebCore::RenderLayerCompositor::shouldPropagateCompositingToEnclosingIFrame): 37 * rendering/RenderWidget.cpp: 38 (WebCore::RenderWidget::setWidgetGeometry): 39 (WebCore::RenderWidget::setWidget): 40 (WebCore::RenderWidget::updateWidgetPosition): 41 * rendering/RenderWidget.h: 10 42 11 43 2011-01-16 Simon Fraser <simon.fraser@apple.com> -
TabularUnified trunk/Source/WebCore/WebCore.exp.in ¶
r75857 r75897 1160 1160 __ZNK7WebCore6Editor8canPasteEv 1161 1161 __ZNK7WebCore6Editor9canDeleteEv 1162 __ZN7WebCore6Widget13setBoundsSizeERKNS_7IntSizeE 1162 1163 __ZNK7WebCore6Widget14platformWidgetEv 1163 1164 __ZNK7WebCore6Widget23convertToContainingViewERKNS_7IntRectE -
TabularUnified trunk/Source/WebCore/platform/Widget.cpp ¶
r68054 r75897 107 107 108 108 #if !PLATFORM(MAC) 109 void Widget::setBoundsSize(const IntSize&) 110 { 111 } 112 109 113 IntRect Widget::convertFromRootToContainingWindow(const Widget*, const IntRect& rect) 110 114 { -
TabularUnified trunk/Source/WebCore/platform/Widget.h ¶
r75031 r75897 154 154 155 155 virtual void setFrameRect(const IntRect&); 156 virtual void setBoundsSize(const IntSize&); 156 157 virtual IntRect frameRect() const; 157 158 IntRect boundsRect() const { return IntRect(0, 0, width(), height()); } -
TabularUnified trunk/Source/WebCore/platform/mac/WidgetMac.mm ¶
r75720 r75897 35 35 #import "Cursor.h" 36 36 #import "Document.h" 37 #import "FloatConversion.h" 37 38 #import "Font.h" 38 39 #import "Frame.h" … … 191 192 } 192 193 194 void Widget::setBoundsSize(const IntSize& size) 195 { 196 BEGIN_BLOCK_OBJC_EXCEPTIONS; 197 NSView *outerView = getOuterView(); 198 if (!outerView) 199 return; 200 201 // Take a reference to this Widget, because sending messages to outerView can invoke arbitrary 202 // code, which can deref it. 203 RefPtr<Widget> protectedThis(this); 204 205 NSSize nsSize = size; 206 if (!NSEqualSizes(nsSize, [outerView bounds].size)) { 207 [outerView setBoundsSize:nsSize]; 208 [outerView setNeedsDisplay:NO]; 209 } 210 END_BLOCK_OBJC_EXCEPTIONS; 211 } 212 193 213 NSView *Widget::getOuterView() const 194 214 { … … 215 235 RefPtr<Widget> protectedThis(this); 216 236 237 IntPoint transformOrigin = frameRect().location(); 238 AffineTransform widgetToViewTranform = makeMapBetweenRects(IntRect(IntPoint(), frameRect().size()), [view bounds]); 239 217 240 NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; 218 241 if (currentContext == [[view window] graphicsContext] || ![currentContext isDrawingToScreen]) { 219 242 // This is the common case of drawing into a window or printing. 220 243 BEGIN_BLOCK_OBJC_EXCEPTIONS; 221 [view displayRectIgnoringOpacity:[view convertRect:r fromView:[view superview]]]; 244 245 CGContextRef context = (CGContextRef)[currentContext graphicsPort]; 246 247 CGContextSaveGState(context); 248 CGContextTranslateCTM(context, transformOrigin.x(), transformOrigin.y()); 249 CGContextScaleCTM(context, narrowPrecisionToFloat(widgetToViewTranform.xScale()), narrowPrecisionToFloat(widgetToViewTranform.yScale())); 250 CGContextTranslateCTM(context, -transformOrigin.x(), -transformOrigin.y()); 251 252 IntRect dirtyRect = r; 253 dirtyRect.move(-transformOrigin.x(), -transformOrigin.y()); 254 if (![view isFlipped]) 255 dirtyRect.setY([view bounds].size.height - dirtyRect.bottom()); 256 257 [view displayRectIgnoringOpacity:dirtyRect]; 258 259 CGContextRestoreGState(context); 260 222 261 END_BLOCK_OBJC_EXCEPTIONS; 223 262 } else { … … 244 283 CGContextSaveGState(cgContext); 245 284 285 CGContextTranslateCTM(cgContext, transformOrigin.x(), transformOrigin.y()); 286 CGContextScaleCTM(cgContext, narrowPrecisionToFloat(widgetToViewTranform.xScale()), narrowPrecisionToFloat(widgetToViewTranform.yScale())); 287 CGContextTranslateCTM(cgContext, -transformOrigin.x(), -transformOrigin.y()); 288 246 289 NSRect viewFrame = [view frame]; 247 290 NSRect viewBounds = [view bounds]; … … 251 294 CGContextScaleCTM(cgContext, 1, -1); 252 295 296 IntRect dirtyRect = r; 297 dirtyRect.move(-transformOrigin.x(), -transformOrigin.y()); 298 if (![view isFlipped]) 299 dirtyRect.setY([view bounds].size.height - dirtyRect.bottom()); 300 253 301 BEGIN_BLOCK_OBJC_EXCEPTIONS; 254 302 { … … 257 305 #endif 258 306 NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES]; 259 [view displayRectIgnoringOpacity: [view convertRect:r fromView:[view superview]]inContext:nsContext];307 [view displayRectIgnoringOpacity:dirtyRect inContext:nsContext]; 260 308 } 261 309 END_BLOCK_OBJC_EXCEPTIONS; -
TabularUnified trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp ¶
r75832 r75897 1119 1119 1120 1120 // On Mac, only propagate compositing if the iframe is overlapped in the parent 1121 // document, or the parent is already compositing. 1121 // document, or the parent is already compositing, or the main frame is scaled. 1122 Frame* frame = m_renderView->frameView()->frame(); 1123 Page* page = frame ? frame->page() : 0; 1124 if (page->mainFrame()->pageScaleFactor() != 1) 1125 return true; 1126 1122 1127 RenderIFrame* iframeRenderer = toRenderIFrame(renderer); 1123 1128 if (iframeRenderer->widget()) { -
TabularUnified trunk/Source/WebCore/rendering/RenderWidget.cpp ¶
r75851 r75897 158 158 } 159 159 160 bool RenderWidget::setWidgetGeometry(const IntRect& frame )160 bool RenderWidget::setWidgetGeometry(const IntRect& frame, const IntSize& boundsSize) 161 161 { 162 162 if (!node()) … … 175 175 RefPtr<Node> protectedNode(node()); 176 176 m_widget->setFrameRect(frame); 177 m_widget->setBoundsSize(boundsSize); 177 178 178 179 #if USE(ACCELERATED_COMPOSITING) … … 202 203 if (style()) { 203 204 if (!needsLayout()) 204 setWidgetGeometry( absoluteContentBox());205 setWidgetGeometry(localToAbsoluteQuad(FloatQuad(contentBoxRect())).enclosingBoundingBox(), contentBoxRect().size()); 205 206 if (style()->visibility() != VISIBLE) 206 207 m_widget->hide(); … … 342 343 return; 343 344 344 // FIXME: This doesn't work correctly with transforms. 345 FloatPoint absPos = localToAbsolute(); 346 absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); 347 348 int w = width() - borderAndPaddingWidth(); 349 int h = height() - borderAndPaddingHeight(); 350 351 bool boundsChanged = setWidgetGeometry(IntRect(absPos.x(), absPos.y(), w, h)); 345 IntRect contentBox = contentBoxRect(); 346 IntRect absoluteContentBox = localToAbsoluteQuad(FloatQuad(contentBoxRect())).enclosingBoundingBox(); 347 bool boundsChanged = setWidgetGeometry(absoluteContentBox, contentBoxRect().size()); 352 348 353 349 // if the frame bounds got changed, or if view needs layout (possibly indicating -
TabularUnified trunk/Source/WebCore/rendering/RenderWidget.h ¶
r74524 r75897 71 71 virtual void setOverlapTestResult(bool); 72 72 73 bool setWidgetGeometry(const IntRect& );73 bool setWidgetGeometry(const IntRect&, const IntSize&); 74 74 75 75 RefPtr<Widget> m_widget; -
TabularUnified trunk/WebKit/mac/ChangeLog ¶
r75893 r75897 1 2011-01-16 Simon Fraser <simon.fraser@apple.com> 2 3 Reviewed by Dan Bernstein. 4 5 Issues with iframes and plugins when the WebView is scaled. 6 <rdar://problem/6213380> 7 8 When _scaleWebView has been called on a WebView, iframes 9 in WebKit1 render and hit-test incorrectly, and plug-ins don't scale up. 10 This is caused by AppKit NSViews not playing nicely with the scale 11 applied through style. 12 13 Work around most of these issues by adjusting the bounds size 14 of widgets to allow iframe contents to paint with the correct scale, 15 and fix various places in the code where we relied on coordinate 16 transforms via NSViews (which ignore CSS transforms). 17 18 * Plugins/Hosted/WebHostedNetscapePluginView.mm: 19 (-[WebHostedNetscapePluginView updateAndSetWindow]): 20 * WebView/WebFrameView.mm: 21 (-[WebFrameView setBoundsSize:]): 22 1 23 2011-01-16 Beth Dakin <bdakin@apple.com> 2 24 -
TabularUnified trunk/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm ¶
r75873 r75897 209 209 210 210 _proxy->resize(boundsInWindow, visibleRectInWindow); 211 212 CGRect layerBounds = NSRectToCGRect(boundsInWindow); 213 CGRect bounds = NSRectToCGRect([self bounds]); 214 CGRect frame = NSRectToCGRect([self frame]); 215 216 // We're not scaled, or in a subframe 217 CATransform3D scaleTransform = CATransform3DIdentity; 218 if (CGSizeEqualToSize(bounds.size, frame.size)) { 219 // We're in a subframe. Backing store is boundsInWindow.size. 220 if (boundsInWindow.size.width && boundsInWindow.size.height) 221 scaleTransform = CATransform3DMakeScale(frame.size.width / boundsInWindow.size.width, frame.size.height / boundsInWindow.size.height, 1); 222 } else { 223 // We're in the main frame with scaling. Need to mimic the frame/bounds scaling on Widgets. 224 if (frame.size.width && frame.size.height) 225 scaleTransform = CATransform3DMakeScale(bounds.size.width / frame.size.width, bounds.size.height / frame.size.height, 1); 226 } 227 228 _pluginLayer.get().sublayerTransform = scaleTransform; 211 229 } 212 230 -
TabularUnified trunk/WebKit/mac/WebView/WebFrameView.mm ¶
r73645 r75897 510 510 } 511 511 512 - (void)setBoundsSize:(NSSize)size 513 { 514 [super setBoundsSize:size]; 515 [[self _scrollView] setFrameSize:size]; 516 } 517 512 518 - (void)viewDidMoveToWindow 513 519 {
Note:
See TracChangeset
for help on using the changeset viewer.