Commit f2519532 authored by yuzo@google.com's avatar yuzo@google.com

2011-05-16 Yuzo Fujishima <yuzo@google.com>

        Reviewed by Antti Koivisto.

        Fix for Bug 43704 - Web font is printed as blank if it is not cached
        https://bugs.webkit.org/show_bug.cgi?id=43704

        In setting printing, we should not validate resources already cached
        for the document. If we do, web fonts used for screen are revalidated
        and possiby reloaded. Then the fonts can be shown as blank on print.
        This patch won't save the case where screen and print use different web
        fonts. Nonetheless, this is an improvement.

        No new tests because there seems to be no good way to test print images.

        * editing/Editor.cpp:
        (WebCore::Editor::paste): Use ResourceCacheValidationSuppressor instead of explicitly allowing/disallowing stale resources.
        * loader/cache/CachedResourceLoader.h:
        (WebCore::ResourceCacheValidationSuppressor::ResourceCacheValidationSuppressor): RAII class for allowing/disallowing stale resources.
        (WebCore::ResourceCacheValidationSuppressor::~ResourceCacheValidationSuppressor):
        * page/DragController.cpp:
        (WebCore::DragController::concludeEditDrag): Use ResourceCacheValidationSuppressor instead of explicitly allowing/disallowing stale resources.
        * page/Frame.cpp:
        (WebCore::Frame::setPrinting): Use ResourceCacheValidationSuppressor to allow stale resources in printing.
2011-05-16  Yuzo Fujishima  <yuzo@google.com>

        Reviewed by Antti Koivisto.

        Fix for Bug 43704 - Web font is printed as blank if it is not cached
        https://bugs.webkit.org/show_bug.cgi?id=43704

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:paginateScreenContent:]): Use ResourceCacheValidationSuppressor to allow stale resources in printing.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86601 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ed97d199
2011-05-16 Yuzo Fujishima <yuzo@google.com>
Reviewed by Antti Koivisto.
Fix for Bug 43704 - Web font is printed as blank if it is not cached
https://bugs.webkit.org/show_bug.cgi?id=43704
In setting printing, we should not validate resources already cached
for the document. If we do, web fonts used for screen are revalidated
and possiby reloaded. Then the fonts can be shown as blank on print.
This patch won't save the case where screen and print use different web
fonts. Nonetheless, this is an improvement.
No new tests because there seems to be no good way to test print images.
* editing/Editor.cpp:
(WebCore::Editor::paste): Use ResourceCacheValidationSuppressor instead of explicitly allowing/disallowing stale resources.
* loader/cache/CachedResourceLoader.h:
(WebCore::ResourceCacheValidationSuppressor::ResourceCacheValidationSuppressor): RAII class for allowing/disallowing stale resources.
(WebCore::ResourceCacheValidationSuppressor::~ResourceCacheValidationSuppressor):
* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag): Use ResourceCacheValidationSuppressor instead of explicitly allowing/disallowing stale resources.
* page/Frame.cpp:
(WebCore::Frame::setPrinting): Use ResourceCacheValidationSuppressor to allow stale resources in printing.
2011-05-16 Dan Bernstein <mitz@apple.com>
Reviewed by Darin Adler.
......@@ -1216,12 +1216,11 @@ void Editor::paste()
return;
updateMarkersForWordsAffectedByEditing(false);
CachedResourceLoader* loader = m_frame->document()->cachedResourceLoader();
loader->setAllowStaleResources(true);
ResourceCacheValidationSuppressor validationSuppressor(loader);
if (m_frame->selection()->isContentRichlyEditable())
pasteWithPasteboard(Pasteboard::generalPasteboard(), true);
else
pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard());
loader->setAllowStaleResources(false);
}
void Editor::pasteAsPlainText()
......
......@@ -54,6 +54,7 @@ class KURL;
class CachedResourceLoader {
WTF_MAKE_NONCOPYABLE(CachedResourceLoader); WTF_MAKE_FAST_ALLOCATED;
friend class ImageLoader;
friend class ResourceCacheValidationSuppressor;
public:
CachedResourceLoader(Document*);
......@@ -96,8 +97,6 @@ public:
void loadDone(CachedResourceRequest*);
void cancelRequests();
void setAllowStaleResources(bool allowStaleResources) { m_allowStaleResources = allowStaleResources; }
void incrementRequestCount(const CachedResource*);
void decrementRequestCount(const CachedResource*);
int requestCount();
......@@ -149,6 +148,29 @@ private:
bool m_allowStaleResources : 1;
};
}
class ResourceCacheValidationSuppressor {
WTF_MAKE_NONCOPYABLE(ResourceCacheValidationSuppressor);
WTF_MAKE_FAST_ALLOCATED;
public:
ResourceCacheValidationSuppressor(CachedResourceLoader* loader)
: m_loader(loader)
, m_previousState(false)
{
if (m_loader) {
m_previousState = m_loader->m_allowStaleResources;
m_loader->m_allowStaleResources = true;
}
}
~ResourceCacheValidationSuppressor()
{
if (m_loader)
m_loader->m_allowStaleResources = m_previousState;
}
private:
CachedResourceLoader* m_loader;
bool m_previousState;
};
} // namespace WebCore
#endif
......@@ -447,12 +447,11 @@ bool DragController::concludeEditDrag(DragData* dragData)
if (!range)
return false;
CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedResourceLoader();
cachedResourceLoader->setAllowStaleResources(true);
ResourceCacheValidationSuppressor validationSuppressor(cachedResourceLoader);
if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRichlyEditable()) {
bool chosePlainText = false;
RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame, range, true, chosePlainText);
if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
cachedResourceLoader->setAllowStaleResources(false);
return false;
}
......@@ -476,7 +475,6 @@ bool DragController::concludeEditDrag(DragData* dragData)
} else {
String text = dragData->asPlainText(innerFrame);
if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, range.get(), EditorInsertActionDropped)) {
cachedResourceLoader->setAllowStaleResources(false);
return false;
}
......@@ -484,7 +482,6 @@ bool DragController::concludeEditDrag(DragData* dragData)
if (setSelectionToDragCaret(innerFrame, dragCaret, range, point))
applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), createFragmentFromText(range.get(), text), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
}
cachedResourceLoader->setAllowStaleResources(false);
return true;
}
......
......@@ -547,6 +547,10 @@ Color Frame::getDocumentBackgroundColor() const
void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)
{
// In setting printing, we should not validate resources already cached for the document.
// See https://bugs.webkit.org/show_bug.cgi?id=43704
ResourceCacheValidationSuppressor validationSuppressor(m_doc->cachedResourceLoader());
m_doc->setPrinting(printing);
view()->adjustMediaTypeForPrinting(printing);
......
2011-05-16 Yuzo Fujishima <yuzo@google.com>
Reviewed by Antti Koivisto.
Fix for Bug 43704 - Web font is printed as blank if it is not cached
https://bugs.webkit.org/show_bug.cgi?id=43704
* WebView/WebHTMLView.mm:
(-[WebHTMLView _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:paginateScreenContent:]): Use ResourceCacheValidationSuppressor to allow stale resources in printing.
2011-05-16 David Kilzer <ddkilzer@apple.com>
<http://webkit.org/b/60913> C++ exceptions should not be enabled when building with llvm-gcc-4.2
......
......@@ -76,6 +76,7 @@
#import <WebCore/CSSMutableStyleDeclaration.h>
#import <WebCore/CachedImage.h>
#import <WebCore/CachedResourceClient.h>
#import <WebCore/CachedResourceLoader.h>
#import <WebCore/Chrome.h>
#import <WebCore/ColorMac.h>
#import <WebCore/ContextMenu.h>
......@@ -3834,6 +3835,10 @@ static PassRefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
if (FrameView* coreView = coreFrame->view())
coreView->setMediaType(_private->printing ? "print" : "screen");
if (Document* document = coreFrame->document()) {
// In setting printing, we should not validate resources already cached for the document.
// See https://bugs.webkit.org/show_bug.cgi?id=43704
ResourceCacheValidationSuppressor validationSuppressor(document->cachedResourceLoader());
document->setPaginatedForScreen(_private->paginateScreenContent);
document->setPrinting(_private->printing);
document->styleSelectorChanged(RecalcStyleImmediately);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment