diff options
author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebKit/mac/WebView/WebFrame.mm | |
parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebKit/mac/WebView/WebFrame.mm')
-rw-r--r-- | Source/WebKit/mac/WebView/WebFrame.mm | 91 |
1 files changed, 48 insertions, 43 deletions
diff --git a/Source/WebKit/mac/WebView/WebFrame.mm b/Source/WebKit/mac/WebView/WebFrame.mm index e792539..584b09e 100644 --- a/Source/WebKit/mac/WebView/WebFrame.mm +++ b/Source/WebKit/mac/WebView/WebFrame.mm @@ -579,51 +579,14 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) } if (contentsOnly) - _private->coreFrame->view()->paintContents(&context, enclosingIntRect(rect)); + view->paintContents(&context, enclosingIntRect(rect)); else - _private->coreFrame->view()->paint(&context, enclosingIntRect(rect)); + view->paint(&context, enclosingIntRect(rect)); if (shouldFlatten) view->setPaintBehavior(oldBehavior); } -// Used by pagination code called from AppKit when a standalone web page is printed. -- (NSArray*)_computePageRectsWithPrintScaleFactor:(float)printScaleFactor pageSize:(NSSize)pageSize -{ - NSMutableArray* pages = [NSMutableArray arrayWithCapacity:5]; - if (printScaleFactor <= 0) { - LOG_ERROR("printScaleFactor has bad value %.2f", printScaleFactor); - return pages; - } - - if (!_private->coreFrame || !_private->coreFrame->document() || !_private->coreFrame->view()) return pages; - RenderView* root = toRenderView(_private->coreFrame->document()->renderer()); - if (!root) return pages; - - FrameView* view = _private->coreFrame->view(); - if (!view) - return pages; - - NSView* documentView = view->documentView(); - if (!documentView) - return pages; - - float docWidth = root->docWidth(); - float docHeight = root->docHeight(); - - float printWidth = root->style()->isHorizontalWritingMode() ? docWidth / printScaleFactor : pageSize.width; - float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : docHeight / printScaleFactor; - - PrintContext printContext(_private->coreFrame); - printContext.computePageRectsWithPageSize(FloatSize(printWidth, printHeight), true); - - const Vector<IntRect>& pageRects = printContext.pageRects(); - const size_t pageCount = pageRects.size(); - for (size_t pageNumber = 0; pageNumber < pageCount; ++pageNumber) - [pages addObject: [NSValue valueWithRect: NSRect(pageRects[pageNumber])]]; - return pages; -} - - (BOOL)_getVisibleRect:(NSRect*)rect { ASSERT_ARG(rect, rect); @@ -1347,10 +1310,18 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) - (BOOL)hasSpellingMarker:(int)from length:(int)length { - Frame* coreFrame = _private->coreFrame; + Frame* coreFrame = core(self); + if (!coreFrame) + return NO; + return coreFrame->editor()->selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); +} + +- (BOOL)hasGrammarMarker:(int)from length:(int)length +{ + Frame* coreFrame = core(self); if (!coreFrame) return NO; - return coreFrame->editor()->selectionStartHasSpellingMarkerFor(from, length); + return coreFrame->editor()->selectionStartHasMarkerFor(DocumentMarker::Grammar, from, length); } - (id)accessibilityRoot @@ -1358,8 +1329,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) #if HAVE(ACCESSIBILITY) if (!AXObjectCache::accessibilityEnabled()) { AXObjectCache::enableAccessibility(); - if ([[NSApp accessibilityAttributeValue:NSAccessibilityEnhancedUserInterfaceAttribute] boolValue]) - AXObjectCache::enableEnhancedUserInterfaceAccessibility(); + AXObjectCache::setEnhancedUserInterfaceAccessibility([[NSApp accessibilityAttributeValue:NSAccessibilityEnhancedUserInterfaceAttribute] boolValue]); } if (!_private->coreFrame || !_private->coreFrame->document()) @@ -1387,6 +1357,41 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) coreFrame->loader()->setOpener(0); } +// Used by pagination code called from AppKit when a standalone web page is printed. +- (NSArray *)_computePageRectsWithPrintScaleFactor:(float)printScaleFactor pageSize:(NSSize)pageSize +{ + if (printScaleFactor <= 0) { + LOG_ERROR("printScaleFactor has bad value %.2f", printScaleFactor); + return [NSArray array]; + } + + if (!_private->coreFrame) + return [NSArray array]; + if (!_private->coreFrame->document()) + return [NSArray array]; + if (!_private->coreFrame->view()) + return [NSArray array]; + if (!_private->coreFrame->view()->documentView()) + return [NSArray array]; + + RenderView* root = toRenderView(_private->coreFrame->document()->renderer()); + if (!root) + return [NSArray array]; + + float printWidth = root->style()->isHorizontalWritingMode() ? root->docWidth() / printScaleFactor : pageSize.width; + float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : root->docHeight() / printScaleFactor; + + PrintContext printContext(_private->coreFrame); + printContext.computePageRectsWithPageSize(FloatSize(printWidth, printHeight), true); + const Vector<IntRect>& pageRects = printContext.pageRects(); + + size_t size = pageRects.size(); + NSMutableArray *pages = [NSMutableArray arrayWithCapacity:size]; + for (size_t i = 0; i < size; ++i) + [pages addObject:[NSValue valueWithRect:NSRect(pageRects[i])]]; + return pages; +} + @end @implementation WebFrame |