- Revision
- 167598
- Author
- [email protected]
- Date
- 2014-04-21 11:08:49 -0700 (Mon, 21 Apr 2014)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (167597 => 167598)
--- trunk/Source/WebCore/ChangeLog 2014-04-21 18:07:15 UTC (rev 167597)
+++ trunk/Source/WebCore/ChangeLog 2014-04-21 18:08:49 UTC (rev 167598)
@@ -1,3 +1,81 @@
+2014-04-21 Darin Adler <[email protected]>
+
+ 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.
+
2014-04-21 David Hyatt <[email protected]>
[New Multicolumn] Pagination mode messed up with non-inline axis and reversed direction.
Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (167597 => 167598)
--- trunk/Source/WebCore/dom/DOMImplementation.cpp 2014-04-21 18:07:15 UTC (rev 167597)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp 2014-04-21 18:08:49 UTC (rev 167598)
@@ -328,7 +328,7 @@
if ((MIMETypeRegistry::isPDFOrPostScriptMIMEType(type)) && pluginData && pluginData->supportsMimeType(type, allowedPluginTypes))
return PluginDocument::create(frame, url);
if (Image::supportsType(type))
- return ImageDocument::create(frame, url);
+ return ImageDocument::create(*frame, url);
#if ENABLE(VIDEO)
Modified: trunk/Source/WebCore/html/ImageDocument.cpp (167597 => 167598)
--- trunk/Source/WebCore/html/ImageDocument.cpp 2014-04-21 18:07:15 UTC (rev 167597)
+++ trunk/Source/WebCore/html/ImageDocument.cpp 2014-04-21 18:08:49 UTC (rev 167598)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2010, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -50,28 +50,21 @@
using namespace HTMLNames;
-class ImageEventListener : public EventListener {
+class ImageEventListener final : public EventListener {
public:
- static PassRefPtr<ImageEventListener> create(ImageDocument* document) { return adoptRef(new ImageEventListener(document)); }
- static const ImageEventListener* cast(const EventListener* listener)
- {
- return listener->type() == ImageEventListenerType
- ? static_cast<const ImageEventListener*>(listener)
- : 0;
- }
+ static PassRefPtr<ImageEventListener> create(ImageDocument& document) { return adoptRef(new ImageEventListener(document)); }
- virtual bool operator==(const EventListener& other) override;
-
private:
- ImageEventListener(ImageDocument* document)
+ ImageEventListener(ImageDocument& document)
: EventListener(ImageEventListenerType)
- , m_doc(document)
+ , m_document(document)
{
}
+ virtual bool operator==(const EventListener&) override;
virtual void handleEvent(ScriptExecutionContext*, Event*) override;
- ImageDocument* m_doc;
+ ImageDocument& m_document;
};
class ImageDocumentParser final : public RawDataDocumentParser {
@@ -81,17 +74,14 @@
return adoptRef(new ImageDocumentParser(document));
}
- ImageDocument* document() const
- {
- return toImageDocument(RawDataDocumentParser::document());
- }
-
private:
ImageDocumentParser(ImageDocument& document)
: RawDataDocumentParser(document)
{
}
+ ImageDocument& document() const;
+
virtual void appendBytes(DocumentWriter&, const char*, size_t) override;
virtual void finish() override;
};
@@ -120,67 +110,84 @@
// --------
-static float pageZoomFactor(const Document* document)
+LayoutSize ImageDocument::imageSize()
{
- Frame* frame = document->frame();
- return frame ? frame->pageZoomFactor() : 1;
+ ASSERT(m_imageElement);
+ updateStyleIfNeeded();
+ return m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), frame() ? frame()->pageZoomFactor() : 1);
}
-void ImageDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
+void ImageDocument::updateDuringParsing()
{
- Frame* frame = document()->frame();
- if (!frame->loader().client().allowImage(frame->settings().areImagesEnabled(), document()->url()))
+ if (!frame()->settings().areImagesEnabled())
return;
- CachedImage* cachedImage = document()->cachedImage();
- RefPtr<ResourceBuffer> resourceData = frame->loader().documentLoader()->mainResourceData();
- cachedImage->addDataBuffer(resourceData.get());
+ if (!m_imageElement)
+ createDocumentStructure();
- document()->imageUpdated();
+ m_imageElement->cachedImage()->addDataBuffer(loader()->mainResourceData().get());
+
+ imageUpdated();
}
-void ImageDocumentParser::finish()
+void ImageDocument::finishedParsing()
{
- if (!isStopped() && document()->imageElement()) {
- CachedImage* cachedImage = document()->cachedImage();
- RefPtr<ResourceBuffer> data = ""
+ if (!parser()->isStopped() && m_imageElement) {
+ CachedImage& cachedImage = *m_imageElement->cachedImage();
+ RefPtr<ResourceBuffer> data = ""
// If this is a multipart image, make a copy of the current part, since the resource data
// will be overwritten by the next part.
- if (document()->frame()->loader().documentLoader()->isLoadingMultipartContent())
+ if (loader()->isLoadingMultipartContent())
data = ""
- cachedImage->finishLoading(data.get());
- cachedImage->finish();
+ cachedImage.finishLoading(data.get());
+ cachedImage.finish();
- cachedImage->setResponse(document()->frame()->loader().documentLoader()->response());
+ cachedImage.setResponse(loader()->response());
// Report the natural image size in the page title, regardless of zoom level.
// At a zoom level of 1 the image is guaranteed to have an integer size.
- IntSize size = flooredIntSize(cachedImage->imageSizeForRenderer(document()->imageElement()->renderer(), 1.0f));
+ updateStyleIfNeeded();
+ IntSize size = flooredIntSize(cachedImage.imageSizeForRenderer(m_imageElement->renderer(), 1));
if (size.width()) {
- // Compute the title, we use the decoded filename of the resource, falling
- // back on the (decoded) hostname if there is no path.
- String fileName = decodeURLEscapeSequences(document()->url().lastPathComponent());
- if (fileName.isEmpty())
- fileName = document()->url().host();
- document()->setTitle(imageTitle(fileName, size));
+ // Compute the title. We use the decoded filename of the resource, falling
+ // back on the hostname if there is no path.
+ String name = decodeURLEscapeSequences(url().lastPathComponent());
+ if (name.isEmpty())
+ name = url().host();
+ setTitle(imageTitle(name, size));
}
- document()->imageUpdated();
+ imageUpdated();
}
- document()->finishedParsing();
+ HTMLDocument::finishedParsing();
}
-// --------
+inline ImageDocument& ImageDocumentParser::document() const
+{
+ // Only used during parsing, so document is guaranteed to be non-null.
+ ASSERT(RawDataDocumentParser::document());
+ return toImageDocument(*RawDataDocumentParser::document());
+}
-ImageDocument::ImageDocument(Frame* frame, const URL& url)
- : HTMLDocument(frame, url, ImageDocumentClass)
- , m_imageElement(0)
+void ImageDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
+{
+ document().updateDuringParsing();
+}
+
+void ImageDocumentParser::finish()
+{
+ document().finishedParsing();
+}
+
+ImageDocument::ImageDocument(Frame& frame, const URL& url)
+ : HTMLDocument(&frame, url, ImageDocumentClass)
+ , m_imageElement(nullptr)
, m_imageSizeIsKnown(false)
, m_didShrinkImage(false)
- , m_shouldShrinkImage(shouldShrinkToFit())
+ , m_shouldShrinkImage(frame.settings().shrinksStandaloneImagesToFit() && frame.isMainFrame())
{
setCompatibilityMode(QuirksMode);
lockCompatibilityMode();
@@ -194,31 +201,27 @@
void ImageDocument::createDocumentStructure()
{
RefPtr<Element> rootElement = Document::createElement(htmlTag, false);
- appendChild(rootElement, IGNORE_EXCEPTION);
+ appendChild(rootElement);
toHTMLHtmlElement(rootElement.get())->insertedByParser();
- if (frame())
- frame()->injectUserScripts(InjectAtDocumentStart);
+ frame()->injectUserScripts(InjectAtDocumentStart);
RefPtr<Element> body = Document::createElement(bodyTag, false);
- body->setAttribute(styleAttr, "margin: 0px;");
+ body->setAttribute(styleAttr, "margin: 0px");
+ rootElement->appendChild(body);
- rootElement->appendChild(body, IGNORE_EXCEPTION);
-
RefPtr<ImageDocumentElement> imageElement = ImageDocumentElement::create(*this);
-
imageElement->setAttribute(styleAttr, "-webkit-user-select: none");
imageElement->setLoadManually(true);
imageElement->setSrc(url().string());
+ body->appendChild(imageElement);
- body->appendChild(imageElement, IGNORE_EXCEPTION);
-
- if (shouldShrinkToFit()) {
- // Add event listeners
- RefPtr<EventListener> listener = ImageEventListener::create(this);
- if (DOMWindow* domWindow = this->domWindow())
- domWindow->addEventListener("resize", listener, false);
+ if (m_shouldShrinkImage) {
+ RefPtr<EventListener> listener = ImageEventListener::create(*this);
+ if (DOMWindow* window = this->domWindow())
+ window->addEventListener("resize", listener, false);
imageElement->addEventListener("click", listener.release(), false);
+
#if PLATFORM(IOS)
// Set the viewport to be in device pixels (rather than the default of 980).
processViewport(ASCIILiteral("width=device-width"), ViewportArguments::ImageDocument);
@@ -228,7 +231,7 @@
m_imageElement = imageElement.get();
}
-float ImageDocument::scale() const
+float ImageDocument::scale()
{
#if PLATFORM(IOS)
// On iOS big images are subsampled to make them smaller. So, don't resize them.
@@ -237,15 +240,14 @@
if (!m_imageElement)
return 1;
- FrameView* view = frame()->view();
+ FrameView* view = this->view();
if (!view)
return 1;
- LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
- LayoutSize windowSize = LayoutSize(view->width(), view->height());
+ LayoutSize imageSize = this->imageSize();
- float widthScale = static_cast<float>(windowSize.width()) / imageSize.width();
- float heightScale = static_cast<float>(windowSize.height()) / imageSize.height();
+ float widthScale = view->width() / imageSize.width().toFloat();
+ float heightScale = view->height() / imageSize.height().toFloat();
return std::min(widthScale, heightScale);
#endif
@@ -259,7 +261,7 @@
if (!m_imageElement)
return;
- LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
+ LayoutSize imageSize = this->imageSize();
float scale = this->scale();
m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));
@@ -281,19 +283,20 @@
m_shouldShrinkImage = !m_shouldShrinkImage;
- if (m_shouldShrinkImage)
+ if (m_shouldShrinkImage) {
+ // Call windowSizeChanged for its side effect of sizing the image.
windowSizeChanged();
- else {
+ } else {
restoreImageSize();
updateLayout();
float scale = this->scale();
- int scrollX = static_cast<int>(x / scale - (float)frame()->view()->width() / 2);
- int scrollY = static_cast<int>(y / scale - (float)frame()->view()->height() / 2);
+ int scrollX = static_cast<int>(x / scale - view()->width() / 2.0f);
+ int scrollY = static_cast<int>(y / scale - view()->height() / 2.0f);
- frame()->view()->setScrollPosition(IntPoint(scrollX, scrollY));
+ view()->setScrollPosition(IntPoint(scrollX, scrollY));
}
#endif
}
@@ -305,13 +308,13 @@
if (m_imageSizeIsKnown)
return;
- if (m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this)).isEmpty())
+ if (imageSize().isEmpty())
return;
m_imageSizeIsKnown = true;
-
- if (shouldShrinkToFit()) {
- // Force resizing of the image
+
+ if (m_shouldShrinkImage) {
+ // Call windowSizeChanged for its side effect of sizing the image.
windowSizeChanged();
}
}
@@ -320,29 +323,29 @@
{
if (!m_imageElement || !m_imageSizeIsKnown)
return;
-
- LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
+
+ LayoutSize imageSize = this->imageSize();
m_imageElement->setWidth(imageSize.width());
m_imageElement->setHeight(imageSize.height());
-
+
if (imageFitsInWindow())
m_imageElement->removeInlineStyleProperty(CSSPropertyCursor);
else
m_imageElement->setInlineStyleProperty(CSSPropertyCursor, CSSValueWebkitZoomOut);
-
+
m_didShrinkImage = false;
}
-bool ImageDocument::imageFitsInWindow() const
+bool ImageDocument::imageFitsInWindow()
{
if (!m_imageElement)
return true;
- FrameView* view = frame()->view();
+ FrameView* view = this->view();
if (!view)
return true;
- LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
+ LayoutSize imageSize = this->imageSize();
#if PLATFORM(IOS)
LayoutSize windowSize = view->contentsToScreen(view->visibleContentRect()).size();
#else
@@ -362,8 +365,8 @@
if (fitsInWindow)
return;
- LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForRenderer(m_imageElement->renderer(), pageZoomFactor(this));
- LayoutRect visibleScreenSize = frame()->view()->contentsToScreen(frame()->view()->visibleContentRect());
+ LayoutSize imageSize = this->imageSize();
+ LayoutRect visibleScreenSize = view()->contentsToScreen(view()->visibleContentRect());
float widthScale = static_cast<float>(visibleScreenSize.width()) / imageSize.width();
float heightScale = static_cast<float>(visibleScreenSize.height()) / imageSize.height();
@@ -383,7 +386,7 @@
}
if (m_didShrinkImage) {
- // If the window has been resized so that the image fits, restore the image size
+ // If the window has been resized so that the image fits, restore the image size,
// otherwise update the restored image size.
if (fitsInWindow)
restoreImageSize();
@@ -399,34 +402,20 @@
#endif
}
-CachedImage* ImageDocument::cachedImage()
-{
- if (!m_imageElement)
- createDocumentStructure();
-
- return m_imageElement->cachedImage();
-}
-
-bool ImageDocument::shouldShrinkToFit() const
-{
- return frame()->settings().shrinksStandaloneImagesToFit() && frame()->isMainFrame();
-}
-
void ImageEventListener::handleEvent(ScriptExecutionContext*, Event* event)
{
if (event->type() == eventNames().resizeEvent)
- m_doc->windowSizeChanged();
+ m_document.windowSizeChanged();
else if (event->type() == eventNames().clickEvent && event->isMouseEvent()) {
- MouseEvent* mouseEvent = toMouseEvent(event);
- m_doc->imageClicked(mouseEvent->x(), mouseEvent->y());
+ MouseEvent& mouseEvent = toMouseEvent(*event);
+ m_document.imageClicked(mouseEvent.x(), mouseEvent.y());
}
}
-bool ImageEventListener::operator==(const EventListener& listener)
+bool ImageEventListener::operator==(const EventListener& other)
{
- if (const ImageEventListener* imageEventListener = ImageEventListener::cast(&listener))
- return m_doc == imageEventListener->m_doc;
- return false;
+ // All ImageEventListener objects compare as equal; OK since there is only one per document.
+ return other.type() == ImageEventListenerType;
}
// --------
@@ -441,7 +430,7 @@
{
if (m_imageDocument) {
m_imageDocument->disconnectImageElement();
- m_imageDocument = 0;
+ m_imageDocument = nullptr;
}
HTMLImageElement::didMoveToNewDocument(oldDocument);
}
Modified: trunk/Source/WebCore/html/ImageDocument.h (167597 => 167598)
--- trunk/Source/WebCore/html/ImageDocument.h 2014-04-21 18:07:15 UTC (rev 167597)
+++ trunk/Source/WebCore/html/ImageDocument.h 2014-04-21 18:08:49 UTC (rev 167598)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,45 +29,47 @@
namespace WebCore {
-class CachedImage;
class ImageDocumentElement;
class ImageDocument final : public HTMLDocument {
public:
- static PassRefPtr<ImageDocument> create(Frame* frame, const URL& url)
+ static PassRefPtr<ImageDocument> create(Frame& frame, const URL& url)
{
return adoptRef(new ImageDocument(frame, url));
}
- CachedImage* cachedImage();
- ImageDocumentElement* imageElement() const { return m_imageElement; }
- void disconnectImageElement() { m_imageElement = 0; }
-
+ void updateDuringParsing();
+ void finishedParsing();
+
+ void disconnectImageElement() { m_imageElement = nullptr; }
+
void windowSizeChanged();
- void imageUpdated();
void imageClicked(int x, int y);
private:
- ImageDocument(Frame*, const URL&);
+ ImageDocument(Frame&, const URL&);
virtual PassRefPtr<DocumentParser> createParser() override;
-
+
+ LayoutSize imageSize();
+
void createDocumentStructure();
void resizeImageToFit();
void restoreImageSize();
- bool imageFitsInWindow() const;
- bool shouldShrinkToFit() const;
- float scale() const;
-
+ bool imageFitsInWindow();
+ float scale();
+
+ void imageUpdated();
+
ImageDocumentElement* m_imageElement;
-
- // Whether enough of the image has been loaded to determine its size
+
+ // Whether enough of the image has been loaded to determine its size.
bool m_imageSizeIsKnown;
-
- // Whether the image is shrunk to fit or not
+
+ // Whether the image is shrunk to fit or not.
bool m_didShrinkImage;
-
- // Whether the image should be shrunk or not
+
+ // Whether the image should be shrunk or not.
bool m_shouldShrinkImage;
};
Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (167597 => 167598)
--- trunk/Source/WebCore/loader/FrameLoaderClient.h 2014-04-21 18:07:15 UTC (rev 167597)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h 2014-04-21 18:08:49 UTC (rev 167598)
@@ -303,11 +303,6 @@
virtual void didChangeScrollOffset() { }
virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; }
- virtual bool allowScriptFromSource(bool enabledPerSettings, const URL&) { return enabledPerSettings; }
- virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; }
- virtual bool allowImage(bool enabledPerSettings, const URL&) { return enabledPerSettings; }
- virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, SecurityOrigin*, const URL&) { return enabledPerSettings; }
- virtual bool allowRunningInsecureContent(bool enabledPerSettings, SecurityOrigin*, const URL&) { return enabledPerSettings; }
// Clients that generally disallow universal access can make exceptions for particular URLs.
virtual bool shouldForceUniversalAccessFromLocalURL(const URL&) { return false; }
Modified: trunk/Source/WebCore/loader/MixedContentChecker.cpp (167597 => 167598)
--- trunk/Source/WebCore/loader/MixedContentChecker.cpp 2014-04-21 18:07:15 UTC (rev 167597)
+++ trunk/Source/WebCore/loader/MixedContentChecker.cpp 2014-04-21 18:08:49 UTC (rev 167598)
@@ -65,7 +65,7 @@
if (!isMixedContent(securityOrigin, url))
return true;
- bool allowed = client().allowDisplayingInsecureContent(m_frame.settings().allowDisplayOfInsecureContent(), securityOrigin, url);
+ bool allowed = m_frame.settings().allowDisplayOfInsecureContent();
logWarning(allowed, "displayed", url);
if (allowed)
@@ -79,7 +79,7 @@
if (!isMixedContent(securityOrigin, url))
return true;
- bool allowed = client().allowRunningInsecureContent(m_frame.settings().allowRunningOfInsecureContent(), securityOrigin, url);
+ bool allowed = m_frame.settings().allowRunningOfInsecureContent();
logWarning(allowed, "ran", url);
if (allowed)
Modified: trunk/Source/WebCore/loader/SubframeLoader.cpp (167597 => 167598)
--- trunk/Source/WebCore/loader/SubframeLoader.cpp 2014-04-21 18:07:15 UTC (rev 167597)
+++ trunk/Source/WebCore/loader/SubframeLoader.cpp 2014-04-21 18:08:49 UTC (rev 167598)
@@ -397,7 +397,7 @@
bool SubframeLoader::allowPlugins(ReasonForCallingAllowPlugins)
{
- return m_frame.loader().client().allowPlugins(m_frame.settings().arePluginsEnabled());
+ return m_frame.settings().arePluginsEnabled();
}
bool SubframeLoader::shouldUsePlugin(const URL& url, const String& mimeType, bool shouldPreferPlugInsForImages, bool hasFallback, bool& useFallback)
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (167597 => 167598)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2014-04-21 18:07:15 UTC (rev 167597)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2014-04-21 18:08:49 UTC (rev 167598)
@@ -347,11 +347,8 @@
case CachedResource::Script:
if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowScriptFromSource(url))
return false;
-
- if (frame()) {
- if (!frame()->loader().client().allowScriptFromSource(frame()->settings().isScriptEnabled(), url))
- return false;
- }
+ if (frame() && !frame()->settings().isScriptEnabled())
+ return false;
break;
case CachedResource::CSSStyleSheet:
if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowStyleFromSource(url))
@@ -678,9 +675,9 @@
reloadImagesIfNotDeferred();
}
-bool CachedResourceLoader::clientDefersImage(const URL& url) const
+bool CachedResourceLoader::clientDefersImage(const URL&) const
{
- return frame() && !frame()->loader().client().allowImage(m_imagesEnabled, url);
+ return !m_imagesEnabled;
}
bool CachedResourceLoader::shouldDeferImageLoad(const URL& url) const