Changeset 86601 in webkit


Ignore:
Timestamp:
May 16, 2011 1:24:42 PM (13 years ago)
Author:
yuzo@google.com
Message:

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.
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86599 r86601  
     12011-05-16  Yuzo Fujishima  <yuzo@google.com>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Fix for Bug 43704 - Web font is printed as blank if it is not cached
     6        https://bugs.webkit.org/show_bug.cgi?id=43704
     7
     8        In setting printing, we should not validate resources already cached
     9        for the document. If we do, web fonts used for screen are revalidated
     10        and possiby reloaded. Then the fonts can be shown as blank on print.
     11        This patch won't save the case where screen and print use different web
     12        fonts. Nonetheless, this is an improvement.
     13
     14        No new tests because there seems to be no good way to test print images.
     15
     16        * editing/Editor.cpp:
     17        (WebCore::Editor::paste): Use ResourceCacheValidationSuppressor instead of explicitly allowing/disallowing stale resources.
     18        * loader/cache/CachedResourceLoader.h:
     19        (WebCore::ResourceCacheValidationSuppressor::ResourceCacheValidationSuppressor): RAII class for allowing/disallowing stale resources.
     20        (WebCore::ResourceCacheValidationSuppressor::~ResourceCacheValidationSuppressor):
     21        * page/DragController.cpp:
     22        (WebCore::DragController::concludeEditDrag): Use ResourceCacheValidationSuppressor instead of explicitly allowing/disallowing stale resources.
     23        * page/Frame.cpp:
     24        (WebCore::Frame::setPrinting): Use ResourceCacheValidationSuppressor to allow stale resources in printing.
     25
    1262011-05-16  Dan Bernstein  <mitz@apple.com>
    227
  • trunk/Source/WebCore/editing/Editor.cpp

    r86520 r86601  
    12171217    updateMarkersForWordsAffectedByEditing(false);
    12181218    CachedResourceLoader* loader = m_frame->document()->cachedResourceLoader();
    1219     loader->setAllowStaleResources(true);
     1219    ResourceCacheValidationSuppressor validationSuppressor(loader);
    12201220    if (m_frame->selection()->isContentRichlyEditable())
    12211221        pasteWithPasteboard(Pasteboard::generalPasteboard(), true);
    12221222    else
    12231223        pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard());
    1224     loader->setAllowStaleResources(false);
    12251224}
    12261225
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.h

    r84681 r86601  
    5555    WTF_MAKE_NONCOPYABLE(CachedResourceLoader); WTF_MAKE_FAST_ALLOCATED;
    5656friend class ImageLoader;
     57friend class ResourceCacheValidationSuppressor;
    5758
    5859public:
     
    9798    void cancelRequests();
    9899   
    99     void setAllowStaleResources(bool allowStaleResources) { m_allowStaleResources = allowStaleResources; }
    100 
    101100    void incrementRequestCount(const CachedResource*);
    102101    void decrementRequestCount(const CachedResource*);
     
    150149};
    151150
    152 }
     151class ResourceCacheValidationSuppressor {
     152    WTF_MAKE_NONCOPYABLE(ResourceCacheValidationSuppressor);
     153    WTF_MAKE_FAST_ALLOCATED;
     154public:
     155    ResourceCacheValidationSuppressor(CachedResourceLoader* loader)
     156        : m_loader(loader)
     157        , m_previousState(false)
     158    {
     159        if (m_loader) {
     160            m_previousState = m_loader->m_allowStaleResources;
     161            m_loader->m_allowStaleResources = true;
     162        }
     163    }
     164    ~ResourceCacheValidationSuppressor()
     165    {
     166        if (m_loader)
     167            m_loader->m_allowStaleResources = m_previousState;
     168    }
     169private:
     170    CachedResourceLoader* m_loader;
     171    bool m_previousState;
     172};
     173
     174} // namespace WebCore
    153175
    154176#endif
  • trunk/Source/WebCore/page/DragController.cpp

    r86472 r86601  
    448448        return false;
    449449    CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedResourceLoader();
    450     cachedResourceLoader->setAllowStaleResources(true);
     450    ResourceCacheValidationSuppressor validationSuppressor(cachedResourceLoader);
    451451    if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRichlyEditable()) {
    452452        bool chosePlainText = false;
    453453        RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame, range, true, chosePlainText);
    454454        if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
    455             cachedResourceLoader->setAllowStaleResources(false);
    456455            return false;
    457456        }
     
    477476        String text = dragData->asPlainText(innerFrame);
    478477        if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, range.get(), EditorInsertActionDropped)) {
    479             cachedResourceLoader->setAllowStaleResources(false);
    480478            return false;
    481479        }
     
    485483            applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), createFragmentFromText(range.get(), text),  ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
    486484    }
    487     cachedResourceLoader->setAllowStaleResources(false);
    488485
    489486    return true;
  • trunk/Source/WebCore/page/Frame.cpp

    r86584 r86601  
    548548void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)
    549549{
     550    // In setting printing, we should not validate resources already cached for the document.
     551    // See https://bugs.webkit.org/show_bug.cgi?id=43704
     552    ResourceCacheValidationSuppressor validationSuppressor(m_doc->cachedResourceLoader());
     553
    550554    m_doc->setPrinting(printing);
    551555    view()->adjustMediaTypeForPrinting(printing);
  • trunk/Source/WebKit/mac/ChangeLog

    r86598 r86601  
     12011-05-16  Yuzo Fujishima  <yuzo@google.com>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Fix for Bug 43704 - Web font is printed as blank if it is not cached
     6        https://bugs.webkit.org/show_bug.cgi?id=43704
     7
     8        * WebView/WebHTMLView.mm:
     9        (-[WebHTMLView _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:paginateScreenContent:]): Use ResourceCacheValidationSuppressor to allow stale resources in printing.
     10
    1112011-05-16  David Kilzer  <ddkilzer@apple.com>
    212
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r86451 r86601  
    7777#import <WebCore/CachedImage.h>
    7878#import <WebCore/CachedResourceClient.h>
     79#import <WebCore/CachedResourceLoader.h>
    7980#import <WebCore/Chrome.h>
    8081#import <WebCore/ColorMac.h>
     
    38353836            coreView->setMediaType(_private->printing ? "print" : "screen");
    38363837        if (Document* document = coreFrame->document()) {
     3838            // In setting printing, we should not validate resources already cached for the document.
     3839            // See https://bugs.webkit.org/show_bug.cgi?id=43704
     3840            ResourceCacheValidationSuppressor validationSuppressor(document->cachedResourceLoader());
     3841
    38373842            document->setPaginatedForScreen(_private->paginateScreenContent);
    38383843            document->setPrinting(_private->printing);
Note: See TracChangeset for help on using the changeset viewer.