Changeset 167598 in webkit


Ignore:
Timestamp:
Apr 21, 2014 11:08:49 AM (10 years ago)
Author:
Darin Adler
Message:

REGRESSION (r160908): Safari doesn't draw rotated images properly first time
https://bugs.webkit.org/show_bug.cgi?id=131930

Reviewed by Anders Carlsson.

With render tree creation sufficiently lazy, we had to put some explicit
calls to updateStyleIfNeeded into the ImageDocument class.

  • dom/DOMImplementation.cpp:

(WebCore::DOMImplementation::createDocument): Pass a Frame&.

  • html/ImageDocument.cpp:

(WebCore::ImageDocument::imageSize): Added this helper function. This updates
style so we can use the renderer to compute an image size taking things like
orientation into account, and also passes in the zoom factor.
(WebCore::ImageDocument::updateDuringParsing): Moved the body of the
ImageDocumentParser::appendBytes function into this function. Since it's a
member of ImageDocument, it has better access to appropriate private members,
and we don't have to expose as many functions to the public. Also changed to
not use the frame so much. Also merged in the code that creates the document
instead of having it be a side effect in the cachedImage helper function; all
the other call sites were checking for null before calling cachedImage.
(WebCore::ImageDocument::finishedParsing): Moved the body of the
ImageDocumentParser::finish function here. Added a call to updateStyleIfNeeded
before using the renderer to get the image size.
(WebCore::ImageDocumentParser::document): Made this return a reference. It's
just a convenience function used in the two functions below.
(WebCore::ImageDocumentParser::appendBytes): Just call updateDuringParsing.
(WebCore::ImageDocumentParser::finish): Just call finishedParsing.
(WebCore::ImageDocument::ImageDocument): Take a reference for the argument,
use nullptr, and also initialize m_shouldShrinkImage directly instead of using
a shouldShrinkToFit() helper function to do it.
(WebCore::ImageDocument::createDocumentStructure): Removed unneeded check of
null for the frame, since the caller does it. Removed some unneeded
IGNORE_EXCEPTON and a stray semicolon. Use m_shouldShrinkImage instead of
calling shouldShrinkToFit since at this early point they will be identical.
(WebCore::ImageDocument::scale): Make non-const so we can call the new
imageSize helper. Use Document::view instead of Frame::view. Improved the
conversion to floating point so it doesn't involve a static_cast and an extra
conversion from int to LayoutUnit.
(WebCore::ImageDocument::resizeImageToFit): Ditto.
(WebCore::ImageDocument::imageClicked): Ditto.
(WebCore::ImageDocument::imageUpdated): Ditto. Also use m_shouldShrinkImage
ibnstead of shouldShrinkToFit.
(WebCore::ImageDocument::restoreImageSize): Ditto.
(WebCore::ImageDocument::imageFitsInWindow): Ditto.
(WebCore::ImageDocument::windowSizeChanged): Ditto.
(WebCore::ImageDocument::cachedImage): Deleted. Moved logic into updateDuringParsing.
(WebCore::ImageDocument::shouldShrinkToFit): Deleted. Moved logic into constructor.
(WebCore::ImageEventListener::handleEvent): Updated for changes above.
(WebCore::ImageEventListener::operator==): Simplified. No reason this has to check
whether both listeners are in the same document.
(WebCore::ImageDocumentElement::didMoveToNewDocument): Use nullptr.

  • html/ImageDocument.h: Deleted some unused things, updated for changes above,

and made some memer functions private.

  • loader/FrameLoaderClient.h: Deleted the allowScriptFromSource, allowPlugins,

allowImage, and allowDisplayingInsecureContent functions. These were only used in
Chromium and are now unneeded complexity. We could bring them back if anyone wants them.

  • loader/MixedContentChecker.cpp:

(WebCore::MixedContentChecker::canDisplayInsecureContent): Removed call to
allowDisplayingInsecureContent, just use the setting directly.
(WebCore::MixedContentChecker::canRunInsecureContent): Removed call to
allowRunningInsecureContent, just use the setting directly.

  • loader/SubframeLoader.cpp:

(WebCore::SubframeLoader::allowPlugins): Removed call to allowPlugins, just
use the arePluginsEnabled setting directly.

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::canRequest): Removed call to allowScriptFromSource, just
use the isScriptEnabled setting directly.
(WebCore::CachedResourceLoader::clientDefersImage): Removed call to allowImage.

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167597 r167598  
     12014-04-21  Darin Adler  <darin@apple.com>
     2
     3        REGRESSION (r160908): Safari doesn't draw rotated images properly first time
     4        https://bugs.webkit.org/show_bug.cgi?id=131930
     5
     6        Reviewed by Anders Carlsson.
     7
     8        With render tree creation sufficiently lazy, we had to put some explicit
     9        calls to updateStyleIfNeeded into the ImageDocument class.
     10
     11        * dom/DOMImplementation.cpp:
     12        (WebCore::DOMImplementation::createDocument): Pass a Frame&.
     13
     14        * html/ImageDocument.cpp:
     15        (WebCore::ImageDocument::imageSize): Added this helper function. This updates
     16        style so we can use the renderer to compute an image size taking things like
     17        orientation into account, and also passes in the zoom factor.
     18        (WebCore::ImageDocument::updateDuringParsing): Moved the body of the
     19        ImageDocumentParser::appendBytes function into this function. Since it's a
     20        member of ImageDocument, it has better access to appropriate private members,
     21        and we don't have to expose as many functions to the public. Also changed to
     22        not use the frame so much. Also merged in the code that creates the document
     23        instead of having it be a side effect in the cachedImage helper function; all
     24        the other call sites were checking for null before calling cachedImage.
     25        (WebCore::ImageDocument::finishedParsing): Moved the body of the
     26        ImageDocumentParser::finish function here. Added a call to updateStyleIfNeeded
     27        before using the renderer to get the image size.
     28        (WebCore::ImageDocumentParser::document): Made this return a reference. It's
     29        just a convenience function used in the two functions below.
     30        (WebCore::ImageDocumentParser::appendBytes): Just call updateDuringParsing.
     31        (WebCore::ImageDocumentParser::finish): Just call finishedParsing.
     32        (WebCore::ImageDocument::ImageDocument): Take a reference for the argument,
     33        use nullptr, and also initialize m_shouldShrinkImage directly instead of using
     34        a shouldShrinkToFit() helper function to do it.
     35        (WebCore::ImageDocument::createDocumentStructure): Removed unneeded check of
     36        null for the frame, since the caller does it. Removed some unneeded
     37        IGNORE_EXCEPTON and a stray semicolon. Use m_shouldShrinkImage instead of
     38        calling shouldShrinkToFit since at this early point they will be identical.
     39        (WebCore::ImageDocument::scale): Make non-const so we can call the new
     40        imageSize helper. Use Document::view instead of Frame::view. Improved the
     41        conversion to floating point so it doesn't involve a static_cast and an extra
     42        conversion from int to LayoutUnit.
     43        (WebCore::ImageDocument::resizeImageToFit): Ditto.
     44        (WebCore::ImageDocument::imageClicked): Ditto.
     45        (WebCore::ImageDocument::imageUpdated): Ditto. Also use m_shouldShrinkImage
     46        ibnstead of shouldShrinkToFit.
     47        (WebCore::ImageDocument::restoreImageSize): Ditto.
     48        (WebCore::ImageDocument::imageFitsInWindow): Ditto.
     49        (WebCore::ImageDocument::windowSizeChanged): Ditto.
     50        (WebCore::ImageDocument::cachedImage): Deleted. Moved logic into updateDuringParsing.
     51        (WebCore::ImageDocument::shouldShrinkToFit): Deleted. Moved logic into constructor.
     52        (WebCore::ImageEventListener::handleEvent): Updated for changes above.
     53        (WebCore::ImageEventListener::operator==): Simplified. No reason this has to check
     54        whether both listeners are in the same document.
     55        (WebCore::ImageDocumentElement::didMoveToNewDocument): Use nullptr.
     56
     57        * html/ImageDocument.h: Deleted some unused things, updated for changes above,
     58        and made some memer functions private.
     59
     60        * loader/FrameLoaderClient.h: Deleted the allowScriptFromSource, allowPlugins,
     61        allowImage, and allowDisplayingInsecureContent functions. These were only used in
     62        Chromium and are now unneeded complexity. We could bring them back if anyone wants them.
     63
     64        * loader/MixedContentChecker.cpp:
     65        (WebCore::MixedContentChecker::canDisplayInsecureContent): Removed call to
     66        allowDisplayingInsecureContent, just use the setting directly.
     67        (WebCore::MixedContentChecker::canRunInsecureContent): Removed call to
     68        allowRunningInsecureContent, just use the setting directly.
     69
     70        * loader/SubframeLoader.cpp:
     71        (WebCore::SubframeLoader::allowPlugins): Removed call to allowPlugins, just
     72        use the arePluginsEnabled setting directly.
     73
     74        * loader/cache/CachedResourceLoader.cpp:
     75        (WebCore::CachedResourceLoader::canRequest): Removed call to allowScriptFromSource, just
     76        use the isScriptEnabled setting directly.
     77        (WebCore::CachedResourceLoader::clientDefersImage): Removed call to allowImage.
     78
    1792014-04-21  David Hyatt  <hyatt@apple.com>
    280
  • trunk/Source/WebCore/dom/DOMImplementation.cpp

    r165971 r167598  
    329329        return PluginDocument::create(frame, url);
    330330    if (Image::supportsType(type))
    331         return ImageDocument::create(frame, url);
     331        return ImageDocument::create(*frame, url);
    332332
    333333#if ENABLE(VIDEO)
  • trunk/Source/WebCore/html/ImageDocument.cpp

    r165676 r167598  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2010, 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5151using namespace HTMLNames;
    5252
    53 class ImageEventListener : public EventListener {
     53class ImageEventListener final : public EventListener {
    5454public:
    55     static PassRefPtr<ImageEventListener> create(ImageDocument* document) { return adoptRef(new ImageEventListener(document)); }
    56     static const ImageEventListener* cast(const EventListener* listener)
     55    static PassRefPtr<ImageEventListener> create(ImageDocument& document) { return adoptRef(new ImageEventListener(document)); }
     56
     57private:
     58    ImageEventListener(ImageDocument& document)
     59        : EventListener(ImageEventListenerType)
     60        , m_document(document)
    5761    {
    58         return listener->type() == ImageEventListenerType
    59             ? static_cast<const ImageEventListener*>(listener)
    60             : 0;
    61     }
    62 
    63     virtual bool operator==(const EventListener& other) override;
    64 
    65 private:
    66     ImageEventListener(ImageDocument* document)
    67         : EventListener(ImageEventListenerType)
    68         , m_doc(document)
    69     {
    70     }
    71 
     62    }
     63
     64    virtual bool operator==(const EventListener&) override;
    7265    virtual void handleEvent(ScriptExecutionContext*, Event*) override;
    7366
    74     ImageDocument* m_doc;
     67    ImageDocument& m_document;
    7568};
    7669   
     
    8275    }
    8376
    84     ImageDocument* document() const
    85     {
    86         return toImageDocument(RawDataDocumentParser::document());
    87     }
    88    
    8977private:
    9078    ImageDocumentParser(ImageDocument& document)
     
    9280    {
    9381    }
     82
     83    ImageDocument& document() const;
    9484
    9585    virtual void appendBytes(DocumentWriter&, const char*, size_t) override;
     
    121111// --------
    122112
    123 static float pageZoomFactor(const Document* document)
    124 {
    125     Frame* frame = document->frame();
    126     return frame ? frame->pageZoomFactor() : 1;
    127 }
    128 
    129 void ImageDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
    130 {
    131     Frame* frame = document()->frame();
    132     if (!frame->loader().client().allowImage(frame->settings().areImagesEnabled(), document()->url()))
    133         return;
    134 
    135     CachedImage* cachedImage = document()->cachedImage();
    136     RefPtr<ResourceBuffer> resourceData = frame->loader().documentLoader()->mainResourceData();
    137     cachedImage->addDataBuffer(resourceData.get());
    138 
    139     document()->imageUpdated();
    140 }
    141 
    142 void ImageDocumentParser::finish()
    143 {
    144     if (!isStopped() && document()->imageElement()) {
    145         CachedImage* cachedImage = document()->cachedImage();
    146         RefPtr<ResourceBuffer> data = document()->frame()->loader().documentLoader()->mainResourceData();
     113LayoutSize ImageDocument::imageSize()
     114{
     115    ASSERT(m_imageElement);
     116    updateStyleIfNeeded();
     117    return m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), frame() ? frame()->pageZoomFactor() : 1);
     118}
     119
     120void ImageDocument::updateDuringParsing()
     121{
     122    if (!frame()->settings().areImagesEnabled())
     123        return;
     124
     125    if (!m_imageElement)
     126        createDocumentStructure();
     127
     128    m_imageElement->cachedImage()->addDataBuffer(loader()->mainResourceData().get());
     129
     130    imageUpdated();
     131}
     132
     133void ImageDocument::finishedParsing()
     134{
     135    if (!parser()->isStopped() && m_imageElement) {
     136        CachedImage& cachedImage = *m_imageElement->cachedImage();
     137        RefPtr<ResourceBuffer> data = loader()->mainResourceData();
    147138
    148139        // If this is a multipart image, make a copy of the current part, since the resource data
    149140        // will be overwritten by the next part.
    150         if (document()->frame()->loader().documentLoader()->isLoadingMultipartContent())
     141        if (loader()->isLoadingMultipartContent())
    151142            data = data->copy();
    152143
    153         cachedImage->finishLoading(data.get());
    154         cachedImage->finish();
    155 
    156         cachedImage->setResponse(document()->frame()->loader().documentLoader()->response());
     144        cachedImage.finishLoading(data.get());
     145        cachedImage.finish();
     146
     147        cachedImage.setResponse(loader()->response());
    157148
    158149        // Report the natural image size in the page title, regardless of zoom level.
    159150        // At a zoom level of 1 the image is guaranteed to have an integer size.
    160         IntSize size = flooredIntSize(cachedImage->imageSizeForRenderer(document()->imageElement()->renderer(), 1.0f));
     151        updateStyleIfNeeded();
     152        IntSize size = flooredIntSize(cachedImage.imageSizeForRenderer(m_imageElement->renderer(), 1));
    161153        if (size.width()) {
    162             // Compute the title, we use the decoded filename of the resource, falling
    163             // back on the (decoded) hostname if there is no path.
    164             String fileName = decodeURLEscapeSequences(document()->url().lastPathComponent());
    165             if (fileName.isEmpty())
    166                 fileName = document()->url().host();
    167             document()->setTitle(imageTitle(fileName, size));
     154            // Compute the title. We use the decoded filename of the resource, falling
     155            // back on the hostname if there is no path.
     156            String name = decodeURLEscapeSequences(url().lastPathComponent());
     157            if (name.isEmpty())
     158                name = url().host();
     159            setTitle(imageTitle(name, size));
    168160        }
    169161
    170         document()->imageUpdated();
    171     }
    172 
    173     document()->finishedParsing();
    174 }
    175    
    176 // --------
    177 
    178 ImageDocument::ImageDocument(Frame* frame, const URL& url)
    179     : HTMLDocument(frame, url, ImageDocumentClass)
    180     , m_imageElement(0)
     162        imageUpdated();
     163    }
     164
     165    HTMLDocument::finishedParsing();
     166}
     167   
     168inline ImageDocument& ImageDocumentParser::document() const
     169{
     170    // Only used during parsing, so document is guaranteed to be non-null.
     171    ASSERT(RawDataDocumentParser::document());
     172    return toImageDocument(*RawDataDocumentParser::document());
     173}
     174
     175void ImageDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
     176{
     177    document().updateDuringParsing();
     178}
     179
     180void ImageDocumentParser::finish()
     181{
     182    document().finishedParsing();
     183}
     184
     185ImageDocument::ImageDocument(Frame& frame, const URL& url)
     186    : HTMLDocument(&frame, url, ImageDocumentClass)
     187    , m_imageElement(nullptr)
    181188    , m_imageSizeIsKnown(false)
    182189    , m_didShrinkImage(false)
    183     , m_shouldShrinkImage(shouldShrinkToFit())
     190    , m_shouldShrinkImage(frame.settings().shrinksStandaloneImagesToFit() && frame.isMainFrame())
    184191{
    185192    setCompatibilityMode(QuirksMode);
     
    195202{
    196203    RefPtr<Element> rootElement = Document::createElement(htmlTag, false);
    197     appendChild(rootElement, IGNORE_EXCEPTION);
     204    appendChild(rootElement);
    198205    toHTMLHtmlElement(rootElement.get())->insertedByParser();
    199206
    200     if (frame())
    201         frame()->injectUserScripts(InjectAtDocumentStart);
     207    frame()->injectUserScripts(InjectAtDocumentStart);
    202208
    203209    RefPtr<Element> body = Document::createElement(bodyTag, false);
    204     body->setAttribute(styleAttr, "margin: 0px;");
    205    
    206     rootElement->appendChild(body, IGNORE_EXCEPTION);
     210    body->setAttribute(styleAttr, "margin: 0px");
     211    rootElement->appendChild(body);
    207212   
    208213    RefPtr<ImageDocumentElement> imageElement = ImageDocumentElement::create(*this);
    209    
    210214    imageElement->setAttribute(styleAttr, "-webkit-user-select: none");       
    211215    imageElement->setLoadManually(true);
    212216    imageElement->setSrc(url().string());
    213    
    214     body->appendChild(imageElement, IGNORE_EXCEPTION);
    215    
    216     if (shouldShrinkToFit()) {
    217         // Add event listeners
    218         RefPtr<EventListener> listener = ImageEventListener::create(this);
    219         if (DOMWindow* domWindow = this->domWindow())
    220             domWindow->addEventListener("resize", listener, false);
     217    body->appendChild(imageElement);
     218   
     219    if (m_shouldShrinkImage) {
     220        RefPtr<EventListener> listener = ImageEventListener::create(*this);
     221        if (DOMWindow* window = this->domWindow())
     222            window->addEventListener("resize", listener, false);
    221223        imageElement->addEventListener("click", listener.release(), false);
     224
    222225#if PLATFORM(IOS)
    223226        // Set the viewport to be in device pixels (rather than the default of 980).
     
    229232}
    230233
    231 float ImageDocument::scale() const
     234float ImageDocument::scale()
    232235{
    233236#if PLATFORM(IOS)
     
    238241        return 1;
    239242
    240     FrameView* view = frame()->view();
     243    FrameView* view = this->view();
    241244    if (!view)
    242245        return 1;
    243246
    244     LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
    245     LayoutSize windowSize = LayoutSize(view->width(), view->height());
    246 
    247     float widthScale = static_cast<float>(windowSize.width()) / imageSize.width();
    248     float heightScale = static_cast<float>(windowSize.height()) / imageSize.height();
     247    LayoutSize imageSize = this->imageSize();
     248
     249    float widthScale = view->width() / imageSize.width().toFloat();
     250    float heightScale = view->height() / imageSize.height().toFloat();
    249251
    250252    return std::min(widthScale, heightScale);
     
    260262        return;
    261263
    262     LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
     264    LayoutSize imageSize = this->imageSize();
    263265
    264266    float scale = this->scale();
     
    282284    m_shouldShrinkImage = !m_shouldShrinkImage;
    283285
    284     if (m_shouldShrinkImage)
     286    if (m_shouldShrinkImage) {
     287        // Call windowSizeChanged for its side effect of sizing the image.
    285288        windowSizeChanged();
    286     else {
     289    } else {
    287290        restoreImageSize();
    288291
     
    291294        float scale = this->scale();
    292295
    293         int scrollX = static_cast<int>(x / scale - (float)frame()->view()->width() / 2);
    294         int scrollY = static_cast<int>(y / scale - (float)frame()->view()->height() / 2);
    295 
    296         frame()->view()->setScrollPosition(IntPoint(scrollX, scrollY));
     296        int scrollX = static_cast<int>(x / scale - view()->width() / 2.0f);
     297        int scrollY = static_cast<int>(y / scale - view()->height() / 2.0f);
     298
     299        view()->setScrollPosition(IntPoint(scrollX, scrollY));
    297300    }
    298301#endif
     
    306309        return;
    307310
    308     if (m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this)).isEmpty())
     311    if (imageSize().isEmpty())
    309312        return;
    310313   
    311314    m_imageSizeIsKnown = true;
    312    
    313     if (shouldShrinkToFit()) {
    314         // Force resizing of the image
     315
     316    if (m_shouldShrinkImage) {
     317        // Call windowSizeChanged for its side effect of sizing the image.
    315318        windowSizeChanged();
    316319    }
     
    321324    if (!m_imageElement || !m_imageSizeIsKnown)
    322325        return;
    323    
    324     LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
     326
     327    LayoutSize imageSize = this->imageSize();
    325328    m_imageElement->setWidth(imageSize.width());
    326329    m_imageElement->setHeight(imageSize.height());
    327    
     330
    328331    if (imageFitsInWindow())
    329332        m_imageElement->removeInlineStyleProperty(CSSPropertyCursor);
    330333    else
    331334        m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoomOut);
    332        
     335
    333336    m_didShrinkImage = false;
    334337}
    335338
    336 bool ImageDocument::imageFitsInWindow() const
     339bool ImageDocument::imageFitsInWindow()
    337340{
    338341    if (!m_imageElement)
    339342        return true;
    340343
    341     FrameView* view = frame()->view();
     344    FrameView* view = this->view();
    342345    if (!view)
    343346        return true;
    344347
    345     LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
     348    LayoutSize imageSize = this->imageSize();
    346349#if PLATFORM(IOS)
    347350    LayoutSize windowSize = view->contentsToScreen(view->visibleContentRect()).size();
     
    363366        return;
    364367
    365     LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
    366     LayoutRect visibleScreenSize = frame()->view()->contentsToScreen(frame()->view()->visibleContentRect());
     368    LayoutSize imageSize = this->imageSize();
     369    LayoutRect visibleScreenSize = view()->contentsToScreen(view()->visibleContentRect());
    367370
    368371    float widthScale = static_cast<float>(visibleScreenSize.width()) / imageSize.width();
     
    384387
    385388    if (m_didShrinkImage) {
    386         // If the window has been resized so that the image fits, restore the image size
     389        // If the window has been resized so that the image fits, restore the image size,
    387390        // otherwise update the restored image size.
    388391        if (fitsInWindow)
     
    400403}
    401404
    402 CachedImage* ImageDocument::cachedImage()
    403 {
    404     if (!m_imageElement)
    405         createDocumentStructure();
    406    
    407     return m_imageElement->cachedImage();
    408 }
    409 
    410 bool ImageDocument::shouldShrinkToFit() const
    411 {
    412     return frame()->settings().shrinksStandaloneImagesToFit() && frame()->isMainFrame();
    413 }
    414 
    415405void ImageEventListener::handleEvent(ScriptExecutionContext*, Event* event)
    416406{
    417407    if (event->type() == eventNames().resizeEvent)
    418         m_doc->windowSizeChanged();
     408        m_document.windowSizeChanged();
    419409    else if (event->type() == eventNames().clickEvent && event->isMouseEvent()) {
    420         MouseEvent* mouseEvent = toMouseEvent(event);
    421         m_doc->imageClicked(mouseEvent->x(), mouseEvent->y());
    422     }
    423 }
    424 
    425 bool ImageEventListener::operator==(const EventListener& listener)
    426 {
    427     if (const ImageEventListener* imageEventListener = ImageEventListener::cast(&listener))
    428         return m_doc == imageEventListener->m_doc;
    429     return false;
     410        MouseEvent& mouseEvent = toMouseEvent(*event);
     411        m_document.imageClicked(mouseEvent.x(), mouseEvent.y());
     412    }
     413}
     414
     415bool ImageEventListener::operator==(const EventListener& other)
     416{
     417    // All ImageEventListener objects compare as equal; OK since there is only one per document.
     418    return other.type() == ImageEventListenerType;
    430419}
    431420
     
    442431    if (m_imageDocument) {
    443432        m_imageDocument->disconnectImageElement();
    444         m_imageDocument = 0;
     433        m_imageDocument = nullptr;
    445434    }
    446435    HTMLImageElement::didMoveToNewDocument(oldDocument);
  • trunk/Source/WebCore/html/ImageDocument.h

    r165676 r167598  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2009, 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030namespace WebCore {
    3131
    32 class CachedImage;
    3332class ImageDocumentElement;
    3433
    3534class ImageDocument final : public HTMLDocument {
    3635public:
    37     static PassRefPtr<ImageDocument> create(Frame* frame, const URL& url)
     36    static PassRefPtr<ImageDocument> create(Frame& frame, const URL& url)
    3837    {
    3938        return adoptRef(new ImageDocument(frame, url));
    4039    }
    4140
    42     CachedImage* cachedImage();
    43     ImageDocumentElement* imageElement() const { return m_imageElement; }
    44     void disconnectImageElement() { m_imageElement = 0; }
    45    
     41    void updateDuringParsing();
     42    void finishedParsing();
     43
     44    void disconnectImageElement() { m_imageElement = nullptr; }
     45
    4646    void windowSizeChanged();
    47     void imageUpdated();
    4847    void imageClicked(int x, int y);
    4948
    5049private:
    51     ImageDocument(Frame*, const URL&);
     50    ImageDocument(Frame&, const URL&);
    5251
    5352    virtual PassRefPtr<DocumentParser> createParser() override;
    54    
     53
     54    LayoutSize imageSize();
     55
    5556    void createDocumentStructure();
    5657    void resizeImageToFit();
    5758    void restoreImageSize();
    58     bool imageFitsInWindow() const;
    59     bool shouldShrinkToFit() const;
    60     float scale() const;
    61    
     59    bool imageFitsInWindow();
     60    float scale();
     61
     62    void imageUpdated();
     63
    6264    ImageDocumentElement* m_imageElement;
    63    
    64     // Whether enough of the image has been loaded to determine its size
     65
     66    // Whether enough of the image has been loaded to determine its size.
    6567    bool m_imageSizeIsKnown;
    66    
    67     // Whether the image is shrunk to fit or not
     68
     69    // Whether the image is shrunk to fit or not.
    6870    bool m_didShrinkImage;
    69    
    70     // Whether the image should be shrunk or not
     71
     72    // Whether the image should be shrunk or not.
    7173    bool m_shouldShrinkImage;
    7274};
  • trunk/Source/WebCore/loader/FrameLoaderClient.h

    r167207 r167598  
    304304
    305305        virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; }
    306         virtual bool allowScriptFromSource(bool enabledPerSettings, const URL&) { return enabledPerSettings; }
    307         virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; }
    308         virtual bool allowImage(bool enabledPerSettings, const URL&) { return enabledPerSettings; }
    309         virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, SecurityOrigin*, const URL&) { return enabledPerSettings; }
    310         virtual bool allowRunningInsecureContent(bool enabledPerSettings, SecurityOrigin*, const URL&) { return enabledPerSettings; }
    311306
    312307        // Clients that generally disallow universal access can make exceptions for particular URLs.
  • trunk/Source/WebCore/loader/MixedContentChecker.cpp

    r165676 r167598  
    6666        return true;
    6767
    68     bool allowed = client().allowDisplayingInsecureContent(m_frame.settings().allowDisplayOfInsecureContent(), securityOrigin, url);
     68    bool allowed = m_frame.settings().allowDisplayOfInsecureContent();
    6969    logWarning(allowed, "displayed", url);
    7070
     
    8080        return true;
    8181
    82     bool allowed = client().allowRunningInsecureContent(m_frame.settings().allowRunningOfInsecureContent(), securityOrigin, url);
     82    bool allowed = m_frame.settings().allowRunningOfInsecureContent();
    8383    logWarning(allowed, "ran", url);
    8484
  • trunk/Source/WebCore/loader/SubframeLoader.cpp

    r166684 r167598  
    398398bool SubframeLoader::allowPlugins(ReasonForCallingAllowPlugins)
    399399{
    400     return m_frame.loader().client().allowPlugins(m_frame.settings().arePluginsEnabled());
     400    return m_frame.settings().arePluginsEnabled();
    401401}
    402402
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r166992 r167598  
    348348        if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowScriptFromSource(url))
    349349            return false;
    350 
    351         if (frame()) {
    352             if (!frame()->loader().client().allowScriptFromSource(frame()->settings().isScriptEnabled(), url))
    353                 return false;
    354         }
     350        if (frame() && !frame()->settings().isScriptEnabled())
     351            return false;
    355352        break;
    356353    case CachedResource::CSSStyleSheet:
     
    679676}
    680677
    681 bool CachedResourceLoader::clientDefersImage(const URL& url) const
    682 {
    683     return frame() && !frame()->loader().client().allowImage(m_imagesEnabled, url);
     678bool CachedResourceLoader::clientDefersImage(const URL&) const
     679{
     680    return !m_imagesEnabled;
    684681}
    685682
Note: See TracChangeset for help on using the changeset viewer.