Changeset 166853 in webkit
- Timestamp:
- Apr 6, 2014, 1:27:07 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r166840 r166853 1 2014-03-23 Darin Adler <darin@apple.com> 2 3 Refactor post-attach and HTMLObjectElement-related code 4 https://bugs.webkit.org/show_bug.cgi?id=131282 5 6 Reviewed by Antti Koivisto. 7 8 * svg/custom/object-no-size-attributes-expected.txt: Removed expectation of an empty text 9 renderer from the render tree. 10 * svg/custom/object-no-size-attributes.xhtml: Restructured the source so there is no text 11 to render. Without this, we were seeing two text renderers due to the loading timing change. 12 1 13 2014-04-05 Dirk Schulze <krit@webkit.org> 2 14 -
trunk/LayoutTests/svg/custom/object-no-size-attributes-expected.txt
r166680 r166853 10 10 RenderSVGRoot {svg} at (0,0) size 100x100 11 11 RenderSVGRect {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00] 12 RenderText {#text} at (0,0) size 0x0 -
trunk/LayoutTests/svg/custom/object-no-size-attributes.xhtml
r166680 r166853 2 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 3 3 <body> 4 <object type="image/svg+xml" data="data:image/svg+xml;charset=utf-8,%3Csvg%20width%3D%22100px%22%20height%3D%22100px%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect%20fill%3D%22green%22%20width%3D%22100px%22%20height%3D%22100px%22%20%2F%3E%3C%2Fsvg%3E" style='background: red'></object> 5 6 <!-- 4 <object type="image/svg+xml" data="data:image/svg+xml;charset=utf-8,%3Csvg%20width%3D%22100px%22%20height%3D%22100px%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect%20fill%3D%22green%22%20width%3D%22100px%22%20height%3D%22100px%22%20%2F%3E%3C%2Fsvg%3E" style='background: red'></object><!-- 7 5 100px x 100px SVG 8 6 … … 14 12 15 13 You should see a 100 x 100 green square above. No red should be visible. <object> tags should treat the width/height attributes on an embeded SVG as the intrinsic size and not default to the CSS default of 300 x 150. 16 --> 17 18 </body> 14 --></body> 19 15 </html> -
trunk/Source/WebCore/ChangeLog
r166851 r166853 1 2014-03-23 Darin Adler <darin@apple.com> 2 3 Refactor post-attach and HTMLObjectElement-related code 4 https://bugs.webkit.org/show_bug.cgi?id=131282 5 6 Reviewed by Antti Koivisto. 7 8 * dom/ContainerNode.cpp: Moved the post-attach callback code from here to 9 StyleResolveTree.h/cpp. 10 * dom/ContainerNode.h: Ditto. 11 12 * dom/Document.cpp: 13 (WebCore::Document::recalcStyle): Use Style::PostResolutionCallbackDisabler instead of 14 PostAttachCallbackDisabler. 15 16 * dom/Element.h: Moved the post-attach callback code from here to StyleResolveTree.h/cpp. 17 18 * html/HTMLEmbedElement.cpp: 19 (WebCore::HTMLEmbedElement::parseAttribute): Simplified the code for typeAttr, turning 20 it into a 1-liner. Added a FIXME in codeAttr about the fact that it does not have the 21 code to trigger image loads. 22 23 * html/HTMLFormControlElement.cpp: 24 (WebCore::HTMLFormControlElement::didAttachRenderers): Updated to use 25 Style::queuePostResolutionCallback and use a lambda instead of a function. 26 (WebCore::HTMLFormControlElement::didRecalcStyle): Ditto. Also added RefPtr instead 27 of just using wishful thinking to keep the object alive. 28 * html/HTMLFrameOwnerElement.cpp: 29 (WebCore::HTMLFrameOwnerElement::scheduleSetNeedsStyleRecalc): Ditto. 30 31 * html/HTMLObjectElement.cpp: 32 (WebCore::HTMLObjectElement::parseAttribute):: Simplified the code for typeAttr, turning 33 it into a 1-liner. Made dataAttr call setNeedsWidgetUpdate(true) unconditionally after 34 checking carefully to see that's harmless if there is no renderer. Changed classidAttr 35 to call setNeedsWidgetUpdate(true) unconditionally and not set m_classId. 36 (WebCore::HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk): Use fastGetAttribute 37 instead of classId and descendantsOfType instead of getElementsByTagName. 38 (WebCore::HTMLObjectElement::hasValidClassId): Use fastGetAttribute instead of classId. 39 (WebCore::HTMLObjectElement::renderFallbackContent): Use imageLoader instead of m_imageLoader. 40 41 * html/HTMLObjectElement.h: Removed classId, since there is no reason to cache that 42 attribute in a data member. Rearranged header, making more private, and fixing some typos, 43 and doing a "using" instead of a function to disambiguate the inherited form functions. 44 45 * html/HTMLPlugInImageElement.cpp: 46 (WebCore::HTMLPlugInImageElement::createElementRenderer): Fixed some code that assumed the 47 first child of the shadow root is guaranteed to be an element. 48 (WebCore::HTMLPlugInImageElement::didMoveToNewDocument): Removed null check on oldDocument, 49 since m_needsDocumentActivationCallbacks can't be true if the old document was null. 50 (WebCore::is100Percent): Added helper to make function below more readable. 51 (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Restructured the code a 52 bit. The part that attracted my attention was the local variable of type RenderBox, which 53 was named renderEmbeddedObject. Turns out the caller guarantees to only call this if there 54 is a renderer of type RenderEmbeddedObject, so depend on that. 55 56 * html/HTMLPlugInImageElement.h: Trimmed includes a bit. Made more members private. 57 Marked more function members final. Made a protected imageLoader function so that 58 m_imageLoader can be private eventually. Made m_imageLoader be std::unique_ptr. 59 60 * style/StyleResolveTree.cpp: 61 (WebCore::Style::needsPseudoElement): Fixed spelling error in the name of this function. 62 (WebCore::Style::attachBeforeOrAfterPseudoElementIfNeeded): Updated for name change. 63 (WebCore::Style::attachRenderTree): Update for new name of PostResolutionCallbackDisabler. 64 (WebCore::Style::updateBeforeOrAfterPseudoElement): Updated for name change. 65 (WebCore::Style::postResolutionCallbackQueue): Added. 66 (WebCore::Style::queuePostResolutionCallback): Added. 67 (WebCore::Style::suspendMemoryCacheClientCalls): Added. This is a side effect of the original 68 PostAttachCallbackDisabler that is now done in a cleaner way, using the callback queue, instead 69 of as a special case. It should not work for multiple documents across multiple pages instead of 70 only the outermost one. 71 (WebCore::Style::PostResolutionCallbackDisabler::PostResolutionCallbackDisabler): Added. 72 Calls suspendMemoryCacheClientCalls, but a FIXME tries to point out why that isn't so great. 73 (WebCore::Style::PostResolutionCallbackDisabler::~PostResolutionCallbackDisabler): Added. 74 (WebCore::Style::postResolutionCallbacksAreSuspended): Added. 75 76 * style/StyleResolveTree.h: Added queuePostResolutionCallback and 77 postResolutionCallbacksAreSuspended. Also added PostResolutionCallbackDisabler, which should 78 eventually become a private implementation detail. 79 1 80 2014-04-04 Brian J. Burg <burg@cs.washington.edu> 2 81 -
trunk/Source/WebCore/dom/ContainerNode.cpp
r166680 r166853 38 38 #include "JSNode.h" 39 39 #include "LabelsNodeList.h" 40 #include "LoaderStrategy.h"41 #include "MemoryCache.h"42 40 #include "MutationEvent.h" 43 41 #include "NameNodeList.h" 44 42 #include "NodeRareData.h" 45 43 #include "NodeRenderStyle.h" 46 #include "PlatformStrategies.h"47 44 #include "RadioNodeList.h" 48 45 #include "RenderBox.h" … … 63 60 static void dispatchChildInsertionEvents(Node&); 64 61 static void dispatchChildRemovalEvents(Node&); 65 66 typedef std::pair<RefPtr<Node>, unsigned> CallbackParameters;67 typedef std::pair<NodeCallback, CallbackParameters> CallbackInfo;68 typedef Vector<CallbackInfo> NodeCallbackQueue;69 70 static NodeCallbackQueue* s_postAttachCallbackQueue;71 72 static size_t s_attachDepth;73 static bool s_shouldReEnableMemoryCacheCallsAfterAttach;74 62 75 63 ChildNodesLazySnapshot* ChildNodesLazySnapshot::latestSnapshot = 0; … … 757 745 758 746 newChild->setNeedsStyleRecalc(ReconstructRenderTree); 759 }760 761 void ContainerNode::suspendPostAttachCallbacks(Document& document)762 {763 if (!s_attachDepth) {764 ASSERT(!s_shouldReEnableMemoryCacheCallsAfterAttach);765 if (Page* page = document.page()) {766 // FIXME: How can this call be specific to one Page, while the767 // s_attachDepth is a global? Doesn't make sense.768 if (page->areMemoryCacheClientCallsEnabled()) {769 page->setMemoryCacheClientCallsEnabled(false);770 s_shouldReEnableMemoryCacheCallsAfterAttach = true;771 }772 }773 platformStrategies()->loaderStrategy()->resourceLoadScheduler()->suspendPendingRequests();774 }775 ++s_attachDepth;776 }777 778 void ContainerNode::resumePostAttachCallbacks(Document& document)779 {780 if (s_attachDepth == 1) {781 Ref<Document> protect(document);782 783 if (s_postAttachCallbackQueue)784 dispatchPostAttachCallbacks();785 if (s_shouldReEnableMemoryCacheCallsAfterAttach) {786 s_shouldReEnableMemoryCacheCallsAfterAttach = false;787 if (Page* page = document.page())788 page->setMemoryCacheClientCallsEnabled(true);789 }790 platformStrategies()->loaderStrategy()->resourceLoadScheduler()->resumePendingRequests();791 }792 --s_attachDepth;793 }794 795 void ContainerNode::queuePostAttachCallback(NodeCallback callback, Node& node, unsigned callbackData)796 {797 if (!s_postAttachCallbackQueue)798 s_postAttachCallbackQueue = new NodeCallbackQueue;799 800 s_postAttachCallbackQueue->append(CallbackInfo(callback, CallbackParameters(&node, callbackData)));801 }802 803 bool ContainerNode::postAttachCallbacksAreSuspended()804 {805 return s_attachDepth;806 }807 808 void ContainerNode::dispatchPostAttachCallbacks()809 {810 // We recalculate size() each time through the loop because a callback811 // can add more callbacks to the end of the queue.812 for (size_t i = 0; i < s_postAttachCallbackQueue->size(); ++i) {813 const CallbackInfo& info = (*s_postAttachCallbackQueue)[i];814 NodeCallback callback = info.first;815 CallbackParameters params = info.second;816 817 callback(*params.first, params.second);818 }819 s_postAttachCallbackQueue->clear();820 747 } 821 748 -
trunk/Source/WebCore/dom/ContainerNode.h
r166680 r166853 80 80 81 81 class ContainerNode : public Node { 82 friend class PostAttachCallbackDisabler;83 82 public: 84 83 virtual ~ContainerNode(); … … 141 140 explicit ContainerNode(Document&, ConstructionType = CreateContainer); 142 141 143 static void queuePostAttachCallback(NodeCallback, Node&, unsigned = 0);144 static bool postAttachCallbacksAreSuspended();145 146 142 template<class GenericNode, class GenericNodeContainer> 147 143 friend void appendChildToContainer(GenericNode* child, GenericNodeContainer&); … … 157 153 void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild); 158 154 void insertBeforeCommon(Node& nextChild, Node& oldChild); 159 160 static void dispatchPostAttachCallbacks();161 static void suspendPostAttachCallbacks(Document&);162 static void resumePostAttachCallbacks(Document&);163 155 164 156 bool getUpperLeftCorner(FloatPoint&) const; -
trunk/Source/WebCore/dom/Document.cpp
r166740 r166853 1755 1755 m_inStyleRecalc = true; 1756 1756 { 1757 PostAttachCallbackDisabler disabler(*this);1757 Style::PostResolutionCallbackDisabler disabler(*this); 1758 1758 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 1759 1759 -
trunk/Source/WebCore/dom/Element.h
r166680 r166853 797 797 } 798 798 799 class PostAttachCallbackDisabler {800 public:801 explicit PostAttachCallbackDisabler(Document& document)802 : m_document(document)803 {804 Element::suspendPostAttachCallbacks(m_document);805 }806 807 ~PostAttachCallbackDisabler()808 {809 Element::resumePostAttachCallbacks(m_document);810 }811 812 private:813 Document& m_document;814 };815 816 799 } // namespace WebCore 817 800 -
trunk/Source/WebCore/html/HTMLEmbedElement.cpp
r166680 r166853 98 98 { 99 99 if (name == typeAttr) { 100 m_serviceType = value.string().l ower();101 size_t pos = m_serviceType.find(";");102 if (pos != notFound)103 m_serviceType = m_serviceType.left(pos);104 } else if (name == codeAttr) 100 m_serviceType = value.string().left(value.find(";")).lower(); 101 // FIXME: The only difference between this and HTMLObjectElement's corresponding 102 // code is that HTMLObjectElement does setNeedsWidgetUpdate(true). Consider moving 103 // this up to the HTMLPlugInImageElement to be shared. 104 } else if (name == codeAttr) { 105 105 m_url = stripLeadingAndTrailingHTMLSpaces(value); 106 else if (name == srcAttr) { 106 // FIXME: Why no call to the image loader? 107 // FIXME: If both code and src attributes are specified, last one parsed/changed wins. That can't be right! 108 } else if (name == srcAttr) { 107 109 m_url = stripLeadingAndTrailingHTMLSpaces(value); 108 110 document().updateStyleIfNeeded(); 109 111 if (renderer() && isImageType()) { 110 112 if (!m_imageLoader) 111 m_imageLoader = adoptPtr(new HTMLImageLoader(*this));113 m_imageLoader = std::make_unique<HTMLImageLoader>(*this); 112 114 m_imageLoader->updateFromElementIgnoringPreviousError(); 113 115 } 116 // FIXME: If both code and src attributes are specified, last one parsed/changed wins. That can't be right! 114 117 } else 115 118 HTMLPlugInImageElement::parseAttribute(name, value); -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r166680 r166853 209 209 } 210 210 211 static void focusPostAttach(Node& element, unsigned)212 {213 toElement(element).focus();214 element.deref();215 }216 217 211 void HTMLFormControlElement::didAttachRenderers() 218 212 { … … 225 219 if (shouldAutofocus(this)) { 226 220 setAutofocused(); 227 ref(); 228 queuePostAttachCallback(focusPostAttach, *this); 221 222 RefPtr<HTMLFormControlElement> element = this; 223 Style::queuePostResolutionCallback([element] { 224 element->focus(); 225 }); 229 226 } 230 227 } … … 289 286 } 290 287 291 static void updateFromElementCallback(Node& node, unsigned)292 {293 if (auto renderer = toHTMLFormControlElement(node).renderer())294 renderer->updateFromElement();295 }296 297 288 void HTMLFormControlElement::didRecalcStyle(Style::Change) 298 289 { 299 290 // updateFromElement() can cause the selection to change, and in turn 300 291 // trigger synchronous layout, so it must not be called during style recalc. 301 if (renderer()) 302 queuePostAttachCallback(updateFromElementCallback, *this); 292 if (renderer()) { 293 RefPtr<HTMLFormControlElement> element = this; 294 Style::queuePostResolutionCallback([element]{ 295 if (auto* renderer = element->renderer()) 296 renderer->updateFromElement(); 297 }); 298 } 303 299 } 304 300 -
trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp
r166680 r166853 122 122 } 123 123 124 static void needsStyleRecalcCallback(Node& node, unsigned data)125 {126 node.setNeedsStyleRecalc(static_cast<StyleChangeType>(data));127 }128 129 124 void HTMLFrameOwnerElement::scheduleSetNeedsStyleRecalc(StyleChangeType changeType) 130 125 { 131 if (postAttachCallbacksAreSuspended()) 132 queuePostAttachCallback(needsStyleRecalcCallback, *this, static_cast<unsigned>(changeType)); 133 else 126 if (Style::postResolutionCallbacksAreSuspended()) { 127 RefPtr<HTMLFrameOwnerElement> element = this; 128 Style::queuePostResolutionCallback([element, changeType]{ 129 element->setNeedsStyleRecalc(changeType); 130 }); 131 } else 134 132 setNeedsStyleRecalc(changeType); 135 133 } -
trunk/Source/WebCore/html/HTMLObjectElement.cpp
r166680 r166853 108 108 formAttributeChanged(); 109 109 else if (name == typeAttr) { 110 m_serviceType = value.lower(); 111 size_t pos = m_serviceType.find(";"); 112 if (pos != notFound) 113 m_serviceType = m_serviceType.left(pos); 114 if (renderer()) 115 setNeedsWidgetUpdate(true); 110 m_serviceType = value.string().left(value.find(';')).lower(); 111 setNeedsWidgetUpdate(true); 116 112 } else if (name == dataAttr) { 117 113 m_url = stripLeadingAndTrailingHTMLSpaces(value); 114 setNeedsWidgetUpdate(true); 118 115 document().updateStyleIfNeeded(); 119 116 if (renderer()) { 120 setNeedsWidgetUpdate(true);121 117 if (isImageType()) { 122 118 if (!m_imageLoader) 123 m_imageLoader = adoptPtr(new HTMLImageLoader(*this));119 m_imageLoader = std::make_unique<HTMLImageLoader>(*this); 124 120 m_imageLoader->updateFromElementIgnoringPreviousError(); 125 121 } 126 122 } 127 } else if (name == classidAttr) { 128 m_classId = value; 129 if (renderer()) 130 setNeedsWidgetUpdate(true); 131 } else if (name == onbeforeloadAttr) 123 } else if (name == classidAttr) 124 setNeedsWidgetUpdate(true); 125 else if (name == onbeforeloadAttr) 132 126 setAttributeEventListener(eventNames().beforeloadEvent, name, value); 133 127 else … … 252 246 // fallback content, which ensures the quirk will disable itself if Wiki 253 247 // Server is updated to generate an alternate embed tag as fallback content. 248 254 249 if (!document().page() 255 250 || !document().page()->settings().needsSiteSpecificQuirks() 256 251 || hasFallbackContent() 257 || !equalIgnoringCase( classId(), "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"))252 || !equalIgnoringCase(fastGetAttribute(classidAttr), "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B")) 258 253 return false; 259 254 260 RefPtr<NodeList> metaElements = document().getElementsByTagName(HTMLNames::metaTag.localName()); 261 unsigned length = metaElements->length(); 262 for (unsigned i = 0; i < length; ++i) { 263 HTMLMetaElement& metaElement = toHTMLMetaElement(*metaElements->item(i)); 255 for (auto& metaElement : descendantsOfType<HTMLMetaElement>(document())) { 264 256 if (equalIgnoringCase(metaElement.name(), "generator") && metaElement.content().startsWith("Mac OS X Server Web Services Server", false)) 265 257 return true; 266 258 } 267 259 268 260 return false; 269 261 } … … 271 263 bool HTMLObjectElement::hasValidClassId() 272 264 { 273 if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType()) && classId().startsWith("java:", false))265 if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType()) && fastGetAttribute(classidAttr).startsWith("java:", false)) 274 266 return true; 275 267 … … 279 271 // HTML5 says that fallback content should be rendered if a non-empty 280 272 // classid is specified for which the UA can't find a suitable plug-in. 281 return classId().isEmpty();273 return fastGetAttribute(classidAttr).isEmpty(); 282 274 } 283 275 … … 376 368 377 369 // Before we give up and use fallback content, check to see if this is a MIME type issue. 378 if (m_imageLoader && m_imageLoader->image() && m_imageLoader->image()->status() != CachedResource::LoadError) { 379 m_serviceType = m_imageLoader->image()->response().mimeType(); 370 auto* loader = imageLoader(); 371 if (loader && loader->image() && loader->image()->status() != CachedResource::LoadError) { 372 m_serviceType = loader->image()->response().mimeType(); 380 373 if (!isImageType()) { 381 374 // If we don't think we have an image type anymore, then clear the image from the loader. 382 m_imageLoader->setImage(0);375 loader->setImage(nullptr); 383 376 return; 384 377 } … … 387 380 m_useFallbackContent = true; 388 381 389 // This is here mainly to keep acid2 non-flaky. A style recalc is required to make fallback resources to load. Without forcing 390 // this may happen after all the other resources have been loaded and the document is already considered complete. 391 // FIXME: Disentangle fallback content handling from style recalcs. 382 // This was added to keep Acid 2 non-flaky. A style recalc is required to make fallback resources load. 383 // Without forcing, this may happen after all the other resources have been loaded and the document is already 384 // considered complete. FIXME: Would be better to address this with incrementLoadEventDelayCount instead 385 // or disentangle loading from style entirely. 392 386 document().updateStyleIfNeeded(); 393 387 } -
trunk/Source/WebCore/html/HTMLObjectElement.h
r166680 r166853 37 37 38 38 bool isDocNamedItem() const { return m_docNamedItem; } 39 40 const String& classId() const { return m_classId; }41 42 39 bool containsJavaApplet() const; 43 40 41 bool hasFallbackContent() const; 44 42 virtual bool useFallbackContent() const override { return m_useFallbackContent; } 45 43 void renderFallbackContent(); 46 44 47 // Implementations of FormAssociatedElement 48 HTMLFormElement* form() const { return FormAssociatedElement::form(); } 45 // Implementation of constraint validation API. 46 // Note that the object elements are always barred from constraint validation. 47 static bool checkValidity() { return true; } 48 virtual void setCustomValidity(const String&) override { } 49 virtual String validationMessage() const override { return String(); } 49 50 50 virtual bool isFormControlElement() const override { return false; } 51 using HTMLPlugInImageElement::ref; 52 using HTMLPlugInImageElement::deref; 51 53 52 virtual bool isEnumeratable() const override { return true; } 53 virtual bool appendFormData(FormDataList&, bool) override; 54 55 // Implementations of constraint validation API. 56 // Note that the object elements are always barred from constraint validation. 57 virtual String validationMessage() const override { return String(); } 58 bool checkValidity() { return true; } 59 virtual void setCustomValidity(const String&) override { } 60 61 using Node::ref; 62 using Node::deref; 63 64 virtual bool canContainRangeEndPoint() const override { return useFallbackContent(); } 65 66 bool hasFallbackContent() const; 54 using FormAssociatedElement::form; 67 55 68 56 private: … … 105 93 virtual const HTMLObjectElement& asHTMLElement() const override final { return *this; } 106 94 107 String m_classId; 95 virtual bool isFormControlElement() const override { return false; } 96 97 virtual bool isEnumeratable() const override { return true; } 98 virtual bool appendFormData(FormDataList&, bool) override; 99 100 virtual bool canContainRangeEndPoint() const override { return useFallbackContent(); } 101 108 102 bool m_docNamedItem : 1; 109 103 bool m_useFallbackContent : 1; -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r166680 r166853 1 1 /* 2 * Copyright (C) 2008, 2011, 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2011, 2012, 2014 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 228 228 #if PLATFORM(IOS) 229 229 if (ShadowRoot* shadowRoot = this->shadowRoot()) { 230 Element* shadowElement = toElement(shadowRoot->firstChild());231 if (shadow Element && shadowElement->shadowPseudoId() == "-apple-youtube-shadow-iframe")230 Node* shadowNode = shadowRoot->firstChild(); 231 if (shadowNode && shadowNode->isElementNode() && toElement(*shadowNode).shadowPseudoId() == "-apple-youtube-shadow-iframe") 232 232 return createRenderer<RenderBlockFlow>(*this, std::move(style)); 233 233 } 234 234 #endif 235 235 236 return HTMLPlugInElement::createElementRenderer(std::move(style)); 236 237 } … … 248 249 { 249 250 if (!isImageType()) { 250 queuePostAttachCallback(&HTMLPlugInImageElement::updateWidgetCallback, *this); 251 RefPtr<HTMLPlugInImageElement> element = this; 252 Style::queuePostResolutionCallback([element]{ 253 element->updateWidgetIfNecessary(); 254 }); 251 255 return; 252 256 } … … 254 258 return; 255 259 256 // Image load might complete synchronously and cause us to re-enter attach. 257 queuePostAttachCallback(&HTMLPlugInImageElement::startLoadingImageCallback, *this); 260 // Image load might complete synchronously and cause us to re-enter. 261 RefPtr<HTMLPlugInImageElement> element = this; 262 Style::queuePostResolutionCallback([element]{ 263 element->startLoadingImage(); 264 }); 258 265 } 259 266 … … 262 269 // FIXME: Because of the insanity that is HTMLPlugInImageElement::willRecalcStyle, 263 270 // we can end up detaching during an attach() call, before we even have a 264 // renderer. 271 // renderer. In that case, don't mark the widget for update. 265 272 if (renderer() && !useFallbackContent()) { 266 273 // Update the widget the next time we attach (detaching destroys the plugin). 267 274 setNeedsWidgetUpdate(true); 268 275 } 276 269 277 HTMLPlugInElement::willDetachRenderers(); 270 278 } … … 297 305 { 298 306 if (m_needsDocumentActivationCallbacks) { 299 if (oldDocument) 300 oldDocument->unregisterForPageCacheSuspensionCallbacks(this); 307 oldDocument->unregisterForPageCacheSuspensionCallbacks(this); 301 308 document().registerForPageCacheSuspensionCallbacks(this); 302 309 } … … 304 311 if (m_imageLoader) 305 312 m_imageLoader->elementDidMoveToNewDocument(); 313 306 314 HTMLPlugInElement::didMoveToNewDocument(oldDocument); 307 315 } … … 322 330 } 323 331 324 void HTMLPlugInImageElement::updateWidgetCallback(Node& node, unsigned)325 {326 toHTMLPlugInImageElement(node).updateWidgetIfNecessary();327 }328 329 332 void HTMLPlugInImageElement::startLoadingImage() 330 333 { 331 334 if (!m_imageLoader) 332 m_imageLoader = adoptPtr(new HTMLImageLoader(*this));335 m_imageLoader = std::make_unique<HTMLImageLoader>(*this); 333 336 m_imageLoader->updateFromElement(); 334 }335 336 void HTMLPlugInImageElement::startLoadingImageCallback(Node& node, unsigned)337 {338 toHTMLPlugInImageElement(node).startLoadingImage();339 337 } 340 338 … … 438 436 root.appendChild(shadowElement, ASSERT_NO_EXCEPTION); 439 437 440 RefPtr<HTMLIFrameElement> iframeElement = HTMLIFrameElement::create( HTMLNames::iframeTag, document());441 if (hasAttribute( HTMLNames::widthAttr))442 iframeElement->setAttribute( HTMLNames::widthAttr, AtomicString("100%", AtomicString::ConstructFromLiteral));443 if (hasAttribute( HTMLNames::heightAttr)) {444 iframeElement->setAttribute( HTMLNames::styleAttr, AtomicString("max-height: 100%", AtomicString::ConstructFromLiteral));445 iframeElement->setAttribute( HTMLNames::heightAttr, getAttribute(HTMLNames::heightAttr));446 } 447 iframeElement->setAttribute( HTMLNames::srcAttr, src);448 iframeElement->setAttribute( HTMLNames::frameborderAttr, AtomicString("0", AtomicString::ConstructFromLiteral));438 RefPtr<HTMLIFrameElement> iframeElement = HTMLIFrameElement::create(iframeTag, document()); 439 if (hasAttribute(widthAttr)) 440 iframeElement->setAttribute(widthAttr, AtomicString("100%", AtomicString::ConstructFromLiteral)); 441 if (hasAttribute(heightAttr)) { 442 iframeElement->setAttribute(styleAttr, AtomicString("max-height: 100%", AtomicString::ConstructFromLiteral)); 443 iframeElement->setAttribute(heightAttr, getAttribute(heightAttr)); 444 } 445 iframeElement->setAttribute(srcAttr, src); 446 iframeElement->setAttribute(frameborderAttr, AtomicString("0", AtomicString::ConstructFromLiteral)); 449 447 450 448 // Disable frame flattening for this iframe. 451 iframeElement->setAttribute( HTMLNames::scrollingAttr, AtomicString("no", AtomicString::ConstructFromLiteral));449 iframeElement->setAttribute(scrollingAttr, AtomicString("no", AtomicString::ConstructFromLiteral)); 452 450 shadowElement->appendChild(iframeElement, ASSERT_NO_EXCEPTION); 453 451 } … … 611 609 } 612 610 611 static inline bool is100Percent(Length length) 612 { 613 return length.isPercent() && length.percent() == 100; 614 } 615 613 616 void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const URL& url) 614 617 { … … 695 698 } 696 699 697 RenderBox* renderEmbeddedObject = toRenderBox(renderer());698 L ength styleWidth = renderEmbeddedObject->style().width();699 Length styleHeight = renderEmbeddedObject->style().height();700 LayoutRect contentBoxRect = renderEmbeddedObject->contentBoxRect();701 int contentWidth = contentBoxRect.width(); 702 i nt contentHeight = contentBoxRect.height();703 int contentArea = contentWidth * contentHeight;704 IntSize visibleViewSize = document().frame()->view()->visibleSize();705 int visibleArea = visibleViewSize.width() * visibleViewSize.height();706 707 if (inMainFrame && styleWidth.isPercent() && (styleWidth.percent() == 100)708 && styleHeight.isPercent() && (styleHeight.percent() == 100)709 && (static_cast<float>(contentArea) / visibleArea > sizingFullPageAreaRatioThreshold)) {710 LOG(Plugins, "%p Plug-in is top level full page, set to play", this);711 m_snapshotDecision = NeverSnapshot;712 return;700 auto& renderer = toRenderEmbeddedObject(*this->renderer()); 701 LayoutRect contentRect = renderer.contentBoxRect(); 702 int contentWidth = contentRect.width(); 703 int contentHeight = contentRect.height(); 704 705 if (inMainFrame) { 706 auto& style = renderer.style(); 707 bool isFullPage = is100Percent(style.width()) && is100Percent(style.height()); 708 IntSize visibleViewSize = document().frame()->view()->visibleSize(); 709 float contentArea = contentWidth * contentHeight; 710 float visibleArea = visibleViewSize.width() * visibleViewSize.height(); 711 if (isFullPage && contentArea > visibleArea * sizingFullPageAreaRatioThreshold) { 712 LOG(Plugins, "%p Plug-in is top level full page, set to play", this); 713 m_snapshotDecision = NeverSnapshot; 714 return; 715 } 713 716 } 714 717 715 718 if (contentWidth <= sizingTinyDimensionThreshold || contentHeight <= sizingTinyDimensionThreshold) { 716 719 LOG(Plugins, "%p Plug-in is very small %dx%d, set to play", this, contentWidth, contentHeight); 717 m_sizeWhenSnapshotted = IntSize(content BoxRect.width().toInt(), contentBoxRect.height().toInt());720 m_sizeWhenSnapshotted = IntSize(contentWidth, contentHeight); 718 721 m_snapshotDecision = MaySnapshotWhenResized; 719 722 return; … … 727 730 } 728 731 729 LOG(Plugins, "%p Plug-in from (%s, %s) is not auto-start, sized at %dx%d, set to wait for snapshot", this, document(). page()->mainFrame().document()->baseURL().host().utf8().data(), url.host().utf8().data(), contentWidth, contentHeight);732 LOG(Plugins, "%p Plug-in from (%s, %s) is not auto-start, sized at %dx%d, set to wait for snapshot", this, document().topDocument().baseURL().host().utf8().data(), url.host().utf8().data(), contentWidth, contentHeight); 730 733 m_snapshotDecision = Snapshotted; 731 734 setDisplayState(WaitingForSnapshot); -
trunk/Source/WebCore/html/HTMLPlugInImageElement.h
r166680 r166853 1 1 /* 2 * Copyright (C) 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2009, 2011, 2012, 2014 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 24 24 #include "HTMLPlugInElement.h" 25 25 26 #include "RenderStyle.h"27 #include <wtf/OwnPtr.h>28 29 26 namespace WebCore { 30 27 31 28 class HTMLImageLoader; 32 class HTMLVideoElement;33 29 class FrameLoader; 34 30 class Image; 35 31 class MouseEvent; 32 class RenderStyle; 36 33 class Widget; 37 34 … … 41 38 }; 42 39 43 enum PreferPlugInsForImagesOption { 44 ShouldPreferPlugInsForImages, 45 ShouldNotPreferPlugInsForImages 46 }; 47 48 // Base class for HTMLObjectElement and HTMLEmbedElement 40 // Base class for HTMLAppletElement, HTMLEmbedElement, and HTMLObjectElement. 41 // FIXME: Should HTMLAppletElement inherit from HTMLPlugInElement directly instead? 49 42 class HTMLPlugInImageElement : public HTMLPlugInElement { 50 43 public: … … 105 98 106 99 protected: 100 enum PreferPlugInsForImagesOption { ShouldPreferPlugInsForImages, ShouldNotPreferPlugInsForImages }; 107 101 HTMLPlugInImageElement(const QualifiedName& tagName, Document&, bool createdByParser, PreferPlugInsForImagesOption); 108 102 103 virtual void didMoveToNewDocument(Document* oldDocument) override; 104 virtual bool requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) override final; 105 109 106 bool isImageType(); 110 111 OwnPtr<HTMLImageLoader> m_imageLoader; 112 String m_serviceType; 113 String m_url; 114 URL m_loadedUrl; 115 116 static void updateWidgetCallback(Node&, unsigned); 117 static void startLoadingImageCallback(Node&, unsigned); 118 119 virtual void didAttachRenderers() override; 120 virtual void willDetachRenderers() override; 107 HTMLImageLoader* imageLoader() { return m_imageLoader.get(); } 121 108 122 109 bool allowedToLoadFrameURL(const String& url); 123 110 bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType); 124 111 125 virtual void didMoveToNewDocument(Document* oldDocument) override; 112 String m_serviceType; 113 String m_url; 126 114 127 virtual void documentWillSuspendForPageCache() override; 128 virtual void documentDidResumeFromPageCache() override; 129 130 virtual bool isRestartedPlugin() const override { return m_isRestartedPlugin; } 131 virtual bool requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) override; 115 std::unique_ptr<HTMLImageLoader> m_imageLoader; 132 116 133 117 private: 118 virtual bool isPlugInImageElement() const override final { return true; } 119 virtual bool isRestartedPlugin() const override final { return m_isRestartedPlugin; } 120 121 virtual void finishParsingChildren() override final; 122 virtual void didAddUserAgentShadowRoot(ShadowRoot*) override final; 123 134 124 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 135 virtual bool willRecalcStyle(Style::Change) override; 125 virtual bool willRecalcStyle(Style::Change) override final; 126 virtual void didAttachRenderers() override final; 127 virtual void willDetachRenderers() override final; 136 128 137 virtual void didAddUserAgentShadowRoot(ShadowRoot*) override; 129 virtual void documentWillSuspendForPageCache() override final; 130 virtual void documentDidResumeFromPageCache() override final; 138 131 139 virtual void finishParsingChildren() override; 132 virtual void defaultEventHandler(Event*) override final; 133 virtual void dispatchPendingMouseClick() override final; 140 134 135 virtual void updateSnapshot(PassRefPtr<Image>) override final; 136 137 void startLoadingImage(); 141 138 void updateWidgetIfNecessary(); 142 void startLoadingImage();143 139 144 virtual void updateSnapshot(PassRefPtr<Image>) override;145 virtual void dispatchPendingMouseClick() override;146 140 void simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>&); 147 141 148 142 void restartSimilarPlugIns(); 149 150 virtual bool isPlugInImageElement() const override { return true; }151 152 143 void removeSnapshotTimerFired(Timer<HTMLPlugInImageElement>&); 153 144 154 virtual void defaultEventHandler(Event*) override; 155 145 private: 146 URL m_loadedUrl; 156 147 bool m_needsWidgetUpdate; 157 148 bool m_shouldPreferPlugInsForImages; -
trunk/Source/WebCore/style/StyleResolveTree.cpp
r166706 r166853 30 30 #include "AnimationController.h" 31 31 #include "CSSFontSelector.h" 32 #include "Element.h"33 32 #include "ElementIterator.h" 34 33 #include "ElementRareData.h" 35 34 #include "FlowThreadController.h" 36 35 #include "InsertionPoint.h" 36 #include "LoaderStrategy.h" 37 37 #include "NodeRenderStyle.h" 38 38 #include "NodeRenderingTraversal.h" 39 39 #include "NodeTraversal.h" 40 #include " RenderElement.h"40 #include "PlatformStrategies.h" 41 41 #include "RenderFullScreen.h" 42 42 #include "RenderNamedFlowThread.h" … … 44 44 #include "RenderView.h" 45 45 #include "RenderWidget.h" 46 #include "ResourceLoadScheduler.h" 46 47 #include "Settings.h" 47 48 #include "ShadowRoot.h" … … 576 577 static void attachRenderTree(Element& current, ContainerNode& renderingParentNode, RenderTreePosition& renderTreePosition, PassRefPtr<RenderStyle> resolvedStyle) 577 578 { 578 Post AttachCallbackDisabler callbackDisabler(current.document());579 PostResolutionCallbackDisabler callbackDisabler(current.document()); 579 580 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 580 581 … … 968 969 } 969 970 970 } 971 } 971 static Vector<std::function<void ()>>& postResolutionCallbackQueue() 972 { 973 static NeverDestroyed<Vector<std::function<void ()>>> vector; 974 return vector; 975 } 976 977 void queuePostResolutionCallback(std::function<void ()> callback) 978 { 979 postResolutionCallbackQueue().append(callback); 980 } 981 982 static void suspendMemoryCacheClientCalls(Document& document) 983 { 984 Page* page = document.page(); 985 if (!page || !page->areMemoryCacheClientCallsEnabled()) 986 return; 987 988 page->setMemoryCacheClientCallsEnabled(false); 989 990 RefPtr<Document> protectedDocument = &document; 991 postResolutionCallbackQueue().append([protectedDocument]{ 992 // FIXME: If the document becomes unassociated with the page during style resolution 993 // then this won't work and the memory cache client calls will be permanently disabled. 994 if (Page* page = protectedDocument->page()) 995 page->setMemoryCacheClientCallsEnabled(true); 996 }); 997 } 998 999 static unsigned resolutionNestingDepth; 1000 1001 PostResolutionCallbackDisabler::PostResolutionCallbackDisabler(Document& document) 1002 { 1003 ++resolutionNestingDepth; 1004 1005 if (resolutionNestingDepth == 1) 1006 platformStrategies()->loaderStrategy()->resourceLoadScheduler()->suspendPendingRequests(); 1007 1008 // FIXME: It's strange to build this into the disabler. 1009 suspendMemoryCacheClientCalls(document); 1010 } 1011 1012 PostResolutionCallbackDisabler::~PostResolutionCallbackDisabler() 1013 { 1014 if (resolutionNestingDepth == 1) { 1015 // Get size each time through the loop because a callback can add more callbacks to the end of the queue. 1016 auto& queue = postResolutionCallbackQueue(); 1017 for (size_t i = 0; i < queue.size(); ++i) 1018 queue[i](); 1019 queue.clear(); 1020 1021 platformStrategies()->loaderStrategy()->resourceLoadScheduler()->resumePendingRequests(); 1022 } 1023 1024 --resolutionNestingDepth; 1025 } 1026 1027 bool postResolutionCallbacksAreSuspended() 1028 { 1029 return resolutionNestingDepth; 1030 } 1031 1032 } 1033 } -
trunk/Source/WebCore/style/StyleResolveTree.h
r166680 r166853 27 27 #define StyleResolveTree_h 28 28 29 #include <functional> 30 29 31 namespace WebCore { 30 32 … … 48 50 Change determineChange(const RenderStyle*, const RenderStyle*); 49 51 52 void queuePostResolutionCallback(std::function<void ()>); 53 bool postResolutionCallbacksAreSuspended(); 54 55 class PostResolutionCallbackDisabler { 56 public: 57 explicit PostResolutionCallbackDisabler(Document&); 58 ~PostResolutionCallbackDisabler(); 59 }; 60 50 61 } 51 62 -
trunk/Source/WebKit/mac/ChangeLog
r166851 r166853 1 2014-03-23 Darin Adler <darin@apple.com> 2 3 Refactor post-attach and HTMLObjectElement-related code 4 https://bugs.webkit.org/show_bug.cgi?id=131282 5 6 Reviewed by Antti Koivisto. 7 8 * WebCoreSupport/WebFrameLoaderClient.mm: Call toHTMLPlugInImageElement instead of 9 doing a static_cast. 10 1 11 2014-04-04 Brian J. Burg <burg@cs.washington.edu> 2 12 -
trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
r166680 r166853 2101 2101 if (element->hasTagName(HTMLNames::embedTag) || element->hasTagName(HTMLNames::objectTag)) { 2102 2102 // Create a shadow subtree for the plugin element, the iframe player is injected in the shadow tree. 2103 HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element); 2104 pluginElement->createShadowIFrameSubtree(embedSrc); 2103 toHTMLPlugInImageElement(*element).createShadowIFrameSubtree(embedSrc); 2105 2104 return nullptr; 2106 2105 }
Note:
See TracChangeset
for help on using the changeset viewer.