Changeset 142343 in webkit
- Timestamp:
- Feb 8, 2013 7:29:20 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142341 r142343 1 2013-02-08 Dean Jackson <dino@apple.com> 2 3 Snapshotted plug-in should use shadow root 4 https://bugs.webkit.org/show_bug.cgi?id=108284 5 6 Reviewed by Simon Fraser. 7 8 Take two! This time with updated exports file. 9 10 A snapshotted plugin needs to indicate to the user that it can be clicked 11 to be restarted. Previously this was done with an image that had embedded 12 text. Instead, we now use an internal shadow root to embed some markup that 13 will display instructions that can be localised. 14 15 The UA stylesheet for plug-ins provides a default styling for the label, which 16 can be overridden by ports. 17 18 In the process, RenderSnapshottedPlugIn no longer inherits from RenderEmbeddedObject, 19 since it is only responsible for drawing a paused plug-in. The snapshot creation 20 can work with the default renderer, but a shadow root requires something like 21 RenderBlock in order to draw its children. We swap from one renderer to another when 22 necessary either by creating the shadow root or by explicitly detaching and attaching 23 the plugin element. 24 25 Unfortunately this is difficult to test, because the snapshotting requires 26 time to execute, and also a PluginView to be instantiated. 27 28 * WebCore.exp.in: Export the InlineBox interface. 29 30 * css/plugIns.css: 31 (object::-webkit-snapshotted-plugin-content): New rules for a default label style. 32 33 * platform/LocalizedStrings.cpp: Make sure all ports have plugin strings, now it is called. 34 * platform/LocalizedStrings.h: 35 * platform/blackberry/LocalizedStringsBlackBerry.cpp: 36 * platform/chromium/LocalizedStringsChromium.cpp: 37 * platform/efl/LocalizedStringsEfl.cpp: 38 * platform/gtk/LocalizedStringsGtk.cpp: 39 * platform/qt/LocalizedStringsQt.cpp: 40 41 * html/HTMLPlugInElement.cpp: 42 (WebCore::HTMLPlugInElement::defaultEventHandler): Take into account the fact 43 that RenderSnapshottedPlugIn no longer is an embedded object. 44 45 * html/HTMLPlugInImageElement.cpp: 46 (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): New default values in constructor. 47 (WebCore::HTMLPlugInElement::defaultEventHandler): Make sure to call base class. 48 (WebCore::HTMLPlugInElement::willRecalcStyle): No need to reattach if we're a snapshot. 49 (WebCore::HTMLPlugInImageElement::createRenderer): If we're showing a snapshot, create such 50 a renderer, otherwise use the typical plug-in path. 51 (WebCore::HTMLPlugInImageElement::updateSnapshot): Keep a record of the snapshot, since we'll 52 need to give it to the renderer. 53 (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Build a subtree that will display a label. 54 * html/HTMLPlugInImageElement.h: 55 (HTMLPlugInImageElement): New member variable to record the snapshot image and whether the label 56 should show immediately. 57 (WebCore::HTMLPlugInImageElement::swapRendererTimerFired): The callback function triggered when we need 58 to swap to the Shadow Root. 59 (WebCore::HTMLPlugInImageElement::userDidClickSnapshot): The user has tapped on the snapshot so the plugin 60 in being recreated. Make sure we reattach so that a plugin renderer will be created. 61 (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Make sure we set the right 62 displayState for snapshots. 63 * html/HTMLPlugInImageElement.h: 64 (HTMLPlugInImageElement): The new methods listed above. 65 (WebCore::HTMLPlugInImageElement::setShouldShowSnapshotLabelAutomatically): Indicates whether or not 66 a snapshot should be immediately labeled. 67 68 * page/ChromeClient.h: No need for plugInStartLabelImage any more. 69 70 * rendering/RenderSnapshottedPlugIn.cpp: 71 (WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): New inheritance. 72 (WebCore::RenderSnapshottedPlugIn::paint): If we're in the background paint phase, render the snapshot image. 73 (WebCore::RenderSnapshottedPlugIn::paintSnapshotImage): Rename. 74 (WebCore::RenderSnapshottedPlugIn::paintSnapshot): Rename. 75 (WebCore::RenderSnapshottedPlugIn::paintSnapshotWithLabel): Rename. No need for label sizes. 76 (WebCore::RenderSnapshottedPlugIn::getCursor): 77 (WebCore::RenderSnapshottedPlugIn::handleEvent): The renderer doesn't restart the plug-in any more. Tell the element and it will do it. 78 * rendering/RenderSnapshottedPlugIn.h: 79 (RenderSnapshottedPlugIn): New inheritance. Some method renaming. 80 1 81 2013-02-08 Dean Jackson <dino@apple.com> 2 82 -
trunk/Source/WebCore/WebCore.exp.in
r142327 r142343 140 140 __ZN7WebCore11HistoryItemC1Ev 141 141 __ZN7WebCore11HistoryItemD1Ev 142 __ZNK7WebCore9InlineBox14caretMaxOffsetEv 143 __ZN7WebCore9InlineBox14selectionStateEv 144 __ZN7WebCore9InlineBox14dirtyLineBoxesEv 145 __ZNK7WebCore9InlineBox22canAccommodateEllipsisEbii 146 __ZN7WebCore9InlineBox11extractLineEv 147 __ZN7WebCore9InlineBox14adjustPositionEff 148 __ZN7WebCore9InlineBoxdlEPvm 149 __ZN7WebCore9InlineBox5paintERNS_9PaintInfoERKNS_11LayoutPointENS_10LayoutUnitES6_ 150 __ZN7WebCore9InlineBox10attachLineEv 151 __ZNK7WebCore9InlineBox16baselinePositionENS_12FontBaselineE 152 __ZN7WebCore9InlineBox11nodeAtPointERKNS_14HitTestRequestERNS_13HitTestResultERKNS_15HitTestLocationERKNS_11LayoutPointENS_10LayoutUnitESC_ 153 __ZN7WebCore9InlineBox10deleteLineEPNS_11RenderArenaE 154 __ZN7WebCore9InlineBox7destroyEPNS_11RenderArenaE 155 __ZN7WebCore9InlineBox16placeEllipsisBoxEbfffRfRb 156 __ZNK7WebCore9InlineBox17reportMemoryUsageEPN3WTF16MemoryObjectInfoE 157 __ZNK7WebCore9InlineBox14caretMinOffsetEv 158 __ZNK7WebCore9InlineBox10lineHeightEv 142 159 __ZN7WebCore11JSDOMWindow6s_infoE 143 160 __ZN7WebCore11MemoryCache11setDisabledEb -
trunk/Source/WebCore/css/plugIns.css
r142341 r142343 23 23 */ 24 24 25 /* plug-ins */ 26 p{} /*Needed by Windows because it doesn't like empty files*/ 25 /* 26 * This is the UA StyleSheet for <object> and <embed> elements. 27 * 28 * Such elements, when snapshotted (paused), will contain a ShadowRoot 29 * with the following structure: 30 * 31 * <object> 32 * #ShadowRoot 33 * <div class="snapshot-container"> 34 * <div class="snapshot-overlay"></div> <!-- e.g. for dimming content --> 35 * <div class="snapshot-label"> 36 * <div class="snapshot-title">Snapshotted Plug-In</div> 37 * <div class="snapshot-subtitle">Click to restart</div> 38 * </div> 39 * </div> 40 * </div> 41 * 42 */ 43 44 object::-webkit-snapshotted-plugin-content, 45 embed::-webkit-snapshotted-plugin-content 46 { 47 position: relative; 48 display: inline-block; 49 width: 100%; 50 height: 100%; 51 } 52 53 object::-webkit-snapshotted-plugin-content *, 54 embed::-webkit-snapshotted-plugin-content * 55 { 56 -webkit-user-select: none; 57 } 58 59 object::-webkit-snapshotted-plugin-content .snapshot-container, 60 embed::-webkit-snapshotted-plugin-content .snapshot-container 61 { 62 position: absolute; 63 width: 100%; 64 height: 100%; 65 } 66 67 object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-overlay, 68 embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-overlay 69 { 70 display: none; 71 } 72 73 object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label, 74 embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label 75 { 76 position: absolute; 77 background-color: white; 78 color: black; 79 margin: 1em; 80 padding: 0.25em 2em; 81 text-align: center; 82 } 83 84 object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-title, 85 embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-title 86 { 87 font-weight: bold; 88 } 89 90 object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-subtitle, 91 embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-subtitle 92 { 93 font-style: italic; 94 color: #444; 95 } -
trunk/Source/WebCore/html/HTMLPlugInElement.cpp
r142341 r142343 202 202 return; 203 203 } 204 if (r->isSnapshottedPlugIn() && displayState() < PlayingWithPendingMouseClick) {205 206 return;207 }204 } else if (r && r->isSnapshottedPlugIn() && displayState() < PlayingWithPendingMouseClick) { 205 toRenderSnapshottedPlugIn(r)->handleEvent(event); 206 HTMLFrameOwnerElement::defaultEventHandler(event); 207 return; 208 208 } 209 209 -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r142341 r142343 22 22 #include "HTMLPlugInImageElement.h" 23 23 24 #include "Chrome.h" 25 #include "ChromeClient.h" 24 26 #include "Frame.h" 25 27 #include "FrameLoader.h" 26 28 #include "FrameLoaderClient.h" 27 29 #include "FrameView.h" 30 #include "HTMLDivElement.h" 28 31 #include "HTMLImageLoader.h" 29 #include "HTMLNames.h"30 32 #include "Image.h" 33 #include "LocalizedStrings.h" 31 34 #include "Logging.h" 32 35 #include "MouseEvent.h" 33 36 #include "NodeRenderStyle.h" 37 #include "NodeRenderingContext.h" 34 38 #include "Page.h" 35 39 #include "PlugInClient.h" … … 42 46 #include "SecurityOrigin.h" 43 47 #include "Settings.h" 48 #include "ShadowRoot.h" 44 49 #include "StyleResolver.h" 50 #include "Text.h" 45 51 46 52 namespace WebCore { 53 54 using namespace HTMLNames; 47 55 48 56 static const int autoStartPlugInSizeThresholdWidth = 1; … … 62 70 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages) 63 71 , m_needsDocumentActivationCallbacks(false) 72 , m_shouldShowSnapshotLabelAutomatically(false) 64 73 , m_simulatedMouseClickTimer(this, &HTMLPlugInImageElement::simulatedMouseClickTimerFired, simulatedMouseClickTimerDelay) 74 , m_swapRendererTimer(this, &HTMLPlugInImageElement::swapRendererTimerFired) 65 75 { 66 76 setHasCustomCallbacks(); … … 133 143 document()->registerForPageCacheSuspensionCallbacks(this); 134 144 } 135 145 146 if (displayState() == DisplayingSnapshot) { 147 RenderSnapshottedPlugIn* renderSnapshottedPlugIn = new (arena) RenderSnapshottedPlugIn(this); 148 renderSnapshottedPlugIn->updateSnapshot(m_snapshotImage); 149 if (m_shouldShowSnapshotLabelAutomatically) 150 renderSnapshottedPlugIn->setShouldShowLabelAutomatically(); 151 return renderSnapshottedPlugIn; 152 } 153 136 154 // Fallback content breaks the DOM->Renderer class relationship of this 137 155 // class and all superclasses because createObject won't necessarily … … 139 157 if (useFallbackContent()) 140 158 return RenderObject::createObject(this, style); 159 141 160 if (isImageType()) { 142 161 RenderImage* image = new (arena) RenderImage(this); … … 145 164 } 146 165 147 if (document()->page() && document()->page()->settings()->plugInSnapshottingEnabled())148 return new (arena) RenderSnapshottedPlugIn(this);149 166 return new (arena) RenderEmbeddedObject(this); 150 167 } … … 153 170 { 154 171 // FIXME: Why is this necessary? Manual re-attach is almost always wrong. 155 if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType() )172 if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType() && (displayState() != DisplayingSnapshot)) 156 173 reattach(); 157 174 return true; … … 259 276 void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image) 260 277 { 261 if (displayState() > DisplayingSnapshot || !renderer()->isSnapshottedPlugIn()) 262 return; 263 264 toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image); 278 if (displayState() > DisplayingSnapshot) 279 return; 280 281 m_snapshotImage = image; 282 if (renderer()->isSnapshottedPlugIn()) { 283 toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image); 284 return; 285 } 286 265 287 setDisplayState(DisplayingSnapshot); 288 m_swapRendererTimer.startOneShot(0); 289 } 290 291 void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root) 292 { 293 Document* doc = document(); 294 295 RefPtr<Element> shadowContainer = HTMLDivElement::create(doc); 296 shadowContainer->setPseudo(AtomicString("-webkit-snapshotted-plugin-content", AtomicString::ConstructFromLiteral)); 297 298 RefPtr<Element> container = HTMLDivElement::create(doc); 299 container->setAttribute(classAttr, AtomicString("snapshot-container", AtomicString::ConstructFromLiteral)); 300 301 RefPtr<Element> overlay = HTMLDivElement::create(doc); 302 overlay->setAttribute(classAttr, AtomicString("snapshot-overlay", AtomicString::ConstructFromLiteral)); 303 container->appendChild(overlay, ASSERT_NO_EXCEPTION); 304 305 RefPtr<Element> label = HTMLDivElement::create(doc); 306 label->setAttribute(classAttr, AtomicString("snapshot-label", AtomicString::ConstructFromLiteral)); 307 308 String titleText = snapshottedPlugInLabelTitle(); 309 String subtitleText = snapshottedPlugInLabelSubtitle(); 310 if (document()->page()) { 311 String clientTitleText = document()->page()->chrome()->client()->plugInStartLabelTitle(); 312 if (!clientTitleText.isEmpty()) 313 titleText = clientTitleText; 314 String clientSubtitleText = document()->page()->chrome()->client()->plugInStartLabelSubtitle(); 315 if (!clientSubtitleText.isEmpty()) 316 subtitleText = clientSubtitleText; 317 } 318 319 RefPtr<Element> title = HTMLDivElement::create(doc); 320 title->setAttribute(classAttr, AtomicString("snapshot-title", AtomicString::ConstructFromLiteral)); 321 title->appendChild(doc->createTextNode(titleText), ASSERT_NO_EXCEPTION); 322 label->appendChild(title, ASSERT_NO_EXCEPTION); 323 324 RefPtr<Element> subTitle = HTMLDivElement::create(doc); 325 subTitle->setAttribute(classAttr, AtomicString("snapshot-subtitle", AtomicString::ConstructFromLiteral)); 326 subTitle->appendChild(doc->createTextNode(subtitleText), ASSERT_NO_EXCEPTION); 327 label->appendChild(subTitle, ASSERT_NO_EXCEPTION); 328 329 container->appendChild(label, ASSERT_NO_EXCEPTION); 330 331 shadowContainer->appendChild(container, ASSERT_NO_EXCEPTION); 332 root->appendChild(shadowContainer, ASSERT_NO_EXCEPTION); 333 } 334 335 void HTMLPlugInImageElement::swapRendererTimerFired(Timer<HTMLPlugInImageElement>*) 336 { 337 ASSERT(displayState() == DisplayingSnapshot); 338 if (userAgentShadowRoot()) 339 return; 340 341 // Create a shadow root, which will trigger the code to add a snapshot container 342 // and reattach, thus making a new Renderer. 343 ensureUserAgentShadowRoot(); 266 344 } 267 345 … … 271 349 if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame()->document()->baseURL().protocol())) 272 350 document()->page()->plugInClient()->addAutoStartOrigin(document()->page()->mainFrame()->document()->baseURL().host(), m_plugInOriginHash); 351 352 reattach(); 273 353 } 274 354 … … 320 400 } 321 401 322 if (!renderer()->isSnapshottedPlugIn()) {323 LOG(Plugins, "%p Renderer is not snapshotted plugin, set to play", this);324 return;325 }326 402 if (ScriptController::processingUserGesture()) { 327 403 LOG(Plugins, "%p Script is processing user gesture, set to play", this); … … 329 405 } 330 406 331 LayoutRect rect = toRender SnapshottedPlugIn(renderer())->contentBoxRect();407 LayoutRect rect = toRenderEmbeddedObject(renderer())->contentBoxRect(); 332 408 int width = rect.width(); 333 409 int height = rect.height(); … … 352 428 353 429 if (shouldPlugInShowLabelAutomatically(document()->page()->mainFrame()->view()->contentsSize(), this)) 354 toRenderSnapshottedPlugIn(renderer())->setShouldShowLabelAutomatically();430 setShouldShowSnapshotLabelAutomatically(); 355 431 356 432 LOG(Plugins, "%p Plug-in hash %x is %dx%d, origin is not auto-start, set to wait for snapshot", this, m_plugInOriginHash, width, height); 357 setDisplayState(WaitingForSnapshot); 433 // We may have got to this point by restarting a snapshotted plug-in, in which case we don't want to 434 // reset the display state. 435 if (displayState() != PlayingWithPendingMouseClick) 436 setDisplayState(WaitingForSnapshot); 358 437 } 359 438 -
trunk/Source/WebCore/html/HTMLPlugInImageElement.h
r142341 r142343 26 26 #include "RenderStyle.h" 27 27 #include <wtf/OwnPtr.h> 28 #include <wtf/RefPtr.h> 28 29 29 30 namespace WebCore { … … 31 32 class HTMLImageLoader; 32 33 class FrameLoader; 34 class Image; 33 35 class MouseEvent; 34 36 class Widget; … … 38 40 CreateOnlyNonNetscapePlugins, 39 41 }; 40 42 41 43 enum PreferPlugInsForImagesOption { 42 44 ShouldPreferPlugInsForImages, … … 93 95 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 94 96 virtual bool willRecalcStyle(StyleChange); 95 97 98 void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE; 99 96 100 virtual void finishParsingChildren(); 97 101 98 102 void updateWidgetIfNecessary(); 99 103 virtual bool useFallbackContent() const { return false; } 100 104 101 105 virtual void updateSnapshot(PassRefPtr<Image>) OVERRIDE; 102 106 virtual void dispatchPendingMouseClick() OVERRIDE; 103 107 void simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>*); 104 108 109 void swapRendererTimerFired(Timer<HTMLPlugInImageElement>*); 110 111 void setShouldShowSnapshotLabelAutomatically() { m_shouldShowSnapshotLabelAutomatically = true; } 112 105 113 bool m_needsWidgetUpdate; 106 114 bool m_shouldPreferPlugInsForImages; 107 115 bool m_needsDocumentActivationCallbacks; 116 bool m_shouldShowSnapshotLabelAutomatically; 108 117 RefPtr<RenderStyle> m_customStyleForPageCache; 109 118 RefPtr<MouseEvent> m_pendingClickEventFromSnapshot; 110 119 DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer; 120 Timer<HTMLPlugInImageElement> m_swapRendererTimer; 121 RefPtr<Image> m_snapshotImage; 111 122 }; 112 123 -
trunk/Source/WebCore/page/ChromeClient.h
r142341 r142343 374 374 virtual bool isEmptyChromeClient() const { return false; } 375 375 376 virtual PassRefPtr<Image> plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize) const { return 0; }377 376 virtual String plugInStartLabelTitle() const { return String(); } 378 377 virtual String plugInStartLabelSubtitle() const { return String(); } -
trunk/Source/WebCore/platform/LocalizedStrings.cpp
r142341 r142343 1 1 /* 2 * Copyright (C) 2003, 2006, 2009, 2010, 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2003, 2006, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2010 Igalia S.L 4 4 * -
trunk/Source/WebCore/platform/LocalizedStrings.h
r142341 r142343 1 1 /* 2 * Copyright (C) 2003, 2006, 2009, 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2003, 2006, 2009, 2011, 2012, 2013 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2010 Igalia S.L 4 4 * -
trunk/Source/WebCore/platform/blackberry/LocalizedStringsBlackBerry.cpp
r142341 r142343 618 618 } 619 619 620 String snapshottedPlugInLabelTitle() 621 { 622 notImplemented(); 623 return String(); 624 } 625 626 String snapshottedPlugInLabelSubtitle() 627 { 628 notImplemented(); 629 return String(); 630 } 631 620 632 } // namespace WebCore -
trunk/Source/WebCore/platform/chromium/LocalizedStringsChromium.cpp
r142341 r142343 417 417 String contextMenuItemTagMediaPause() { return String(); } 418 418 String contextMenuItemTagMediaMute() { return String(); } 419 String snapshottedPlugInLabelTitle() { return String(); } 420 String snapshottedPlugInLabelSubtitle() { return String(); } 419 421 420 422 #if ENABLE(VIDEO_TRACK) -
trunk/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp
r142341 r142343 611 611 #endif 612 612 613 } 613 String snapshottedPlugInLabelTitle() 614 { 615 return String("Snapshotted Plug-In"); 616 } 617 618 String snapshottedPlugInLabelSubtitle() 619 { 620 return String("Click to restart"); 621 } 622 623 624 } -
trunk/Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp
r142341 r142343 775 775 #endif 776 776 777 } 777 String snapshottedPlugInLabelTitle() 778 { 779 return String::fromUTF8(C_("Snapshotted Plug-In", "Title of the label to show on a snapshotted plug-in")); 780 } 781 782 String snapshottedPlugInLabelSubtitle() 783 { 784 return String::fromUTF8(C_("Click to restart", "Subtitle of the label to show on a snapshotted plug-in")); 785 } 786 787 } -
trunk/Source/WebCore/platform/qt/LocalizedStringsQt.cpp
r142341 r142343 724 724 } 725 725 726 String snapshottedPlugInLabelTitle() 727 { 728 notImplemented(); 729 return String(); 730 } 731 732 String snapshottedPlugInLabelSubtitle() 733 { 734 notImplemented(); 735 return String(); 736 } 737 726 738 String localizedString(const char* key) 727 739 { -
trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
r142341 r142343 41 41 #include "PaintInfo.h" 42 42 #include "Path.h" 43 #include "RenderView.h" 43 44 #include "SourceGraphic.h" 44 45 … … 47 48 static const int autoStartPlugInSizeThresholdWidth = 1; 48 49 static const int autoStartPlugInSizeThresholdHeight = 1; 49 static const int startLabelPadding = 10; // Label should be 10px from edge of box.50 static const int startLabelInset = 20; // But the label is inset from its box also. FIXME: This will be removed when we go to a ShadowDOM approach.51 50 static const double showLabelAfterMouseOverDelay = 1; 52 51 static const double showLabelAutomaticallyDelay = 3; … … 101 100 102 101 RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement* element) 103 : Render EmbeddedObject(element)102 : RenderBlock(element) 104 103 , m_snapshotResource(RenderImageResource::create()) 105 104 , m_shouldShowLabel(false) … … 146 145 void RenderSnapshottedPlugIn::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 147 146 { 148 if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) { 149 RenderReplaced::paint(paintInfo, paintOffset); 150 return; 151 } 152 153 RenderEmbeddedObject::paint(paintInfo, paintOffset); 154 } 155 156 void RenderSnapshottedPlugIn::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 157 { 158 if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) { 147 if (paintInfo.phase == PaintPhaseBlockBackground && plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) { 159 148 if (m_shouldShowLabel) 160 paint ReplacedSnapshotWithLabel(paintInfo, paintOffset);149 paintSnapshotWithLabel(paintInfo, paintOffset); 161 150 else 162 paintReplacedSnapshot(paintInfo, paintOffset); 163 return; 164 } 165 166 RenderEmbeddedObject::paintReplaced(paintInfo, paintOffset); 167 } 168 169 void RenderSnapshottedPlugIn::paintSnapshot(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset) 151 paintSnapshot(paintInfo, paintOffset); 152 } 153 154 RenderBlock::paint(paintInfo, paintOffset); 155 } 156 157 void RenderSnapshottedPlugIn::paintSnapshotImage(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset) 170 158 { 171 159 LayoutUnit cWidth = contentWidth(); … … 181 169 182 170 LayoutSize contentSize(cWidth, cHeight); 183 LayoutPoint contentLocation = paintOffset;171 LayoutPoint contentLocation = location() + paintOffset; 184 172 contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); 185 173 … … 193 181 } 194 182 195 void RenderSnapshottedPlugIn::paint ReplacedSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)183 void RenderSnapshottedPlugIn::paintSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 196 184 { 197 185 RefPtr<Image> image = m_snapshotResource->image(); … … 199 187 return; 200 188 201 paintSnapshot(image.get(), paintInfo, paintOffset); 202 } 203 204 Image* RenderSnapshottedPlugIn::startLabelImage(LabelSize size) const 205 { 206 static Image* labelImages[2] = { 0, 0 }; 207 static bool initializedImages[2] = { false, false }; 208 209 int arrayIndex = static_cast<int>(size); 210 if (labelImages[arrayIndex]) 211 return labelImages[arrayIndex]; 212 if (initializedImages[arrayIndex]) 213 return 0; 214 215 if (document()->page()) { 216 labelImages[arrayIndex] = document()->page()->chrome()->client()->plugInStartLabelImage(size).leakRef(); 217 initializedImages[arrayIndex] = true; 218 } 219 return labelImages[arrayIndex]; 189 paintSnapshotImage(image.get(), paintInfo, paintOffset); 220 190 } 221 191 … … 239 209 #endif 240 210 241 void RenderSnapshottedPlugIn::paint ReplacedSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)211 void RenderSnapshottedPlugIn::paintSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 242 212 { 243 213 if (contentBoxRect().isEmpty()) … … 248 218 249 219 m_showedLabelOnce = true; 250 LayoutRect rect = contentBoxRect(); 251 LayoutRect labelRect = tryToFitStartLabel(LabelSizeLarge, rect); 252 LabelSize size = NoLabel; 253 if (!labelRect.isEmpty()) 254 size = LabelSizeLarge; 255 else { 256 labelRect = tryToFitStartLabel(LabelSizeSmall, rect); 257 if (!labelRect.isEmpty()) 258 size = LabelSizeSmall; 259 else 260 return; 261 } 262 263 Image* labelImage = startLabelImage(size); 264 if (!labelImage) 265 return; 220 LayoutRect labelRect; 266 221 267 222 RefPtr<Image> snapshotImage = m_snapshotResource->image(); … … 270 225 271 226 #if ENABLE(FILTERS) 272 RefPtr<Image> blurredSnapshotImage = m_snapshotResourceForLabel->image(); 273 if (!blurredSnapshotImage || blurredSnapshotImage->isNull()) { 274 blurredSnapshotImage = snapshottedPluginImageForLabelDisplay(snapshotImage, labelRect); 275 m_snapshotResourceForLabel->setCachedImage(new CachedImage(blurredSnapshotImage.get())); 276 } 277 snapshotImage = blurredSnapshotImage; 227 // FIXME: Temporarily disabling the blur behind the label. 228 // https://bugs.webkit.org/show_bug.cgi?id=108368 229 if (!labelRect.isEmpty()) { 230 RefPtr<Image> blurredSnapshotImage = m_snapshotResourceForLabel->image(); 231 if (!blurredSnapshotImage || blurredSnapshotImage->isNull()) { 232 blurredSnapshotImage = snapshottedPluginImageForLabelDisplay(snapshotImage, labelRect); 233 m_snapshotResourceForLabel->setCachedImage(new CachedImage(blurredSnapshotImage.get())); 234 } 235 snapshotImage = blurredSnapshotImage; 236 } 278 237 #endif 279 238 280 paintSnapshot(snapshotImage.get(), paintInfo, paintOffset); 281 282 // Remember that the labelRect includes the label inset, so we need to adjust for it. 283 paintInfo.context->drawImage(labelImage, ColorSpaceDeviceRGB, 284 IntRect(roundedIntPoint(paintOffset + labelRect.location() - IntSize(startLabelInset, startLabelInset)), 285 roundedIntSize(labelRect.size() + IntSize(2 * startLabelInset, 2 * startLabelInset))), 286 labelImage->rect()); 239 paintSnapshotImage(snapshotImage.get(), paintInfo, paintOffset); 287 240 } 288 241 … … 310 263 return SetCursor; 311 264 } 312 return Render EmbeddedObject::getCursor(point, overrideCursor);265 return RenderBlock::getCursor(point, overrideCursor); 313 266 } 314 267 … … 326 279 plugInImageElement()->setDisplayState(HTMLPlugInElement::PlayingWithPendingMouseClick); 327 280 plugInImageElement()->userDidClickSnapshot(mouseEvent); 328 329 if (widget()) {330 if (Frame* frame = document()->frame())331 frame->loader()->client()->recreatePlugin(widget());332 repaint();333 }334 281 event->setDefaultHandled(); 335 282 } else if (event->type() == eventNames().mousedownEvent) { … … 359 306 } 360 307 361 LayoutRect RenderSnapshottedPlugIn::tryToFitStartLabel(LabelSize size, const LayoutRect& contentBox) const362 {363 Image* labelImage = startLabelImage(size);364 if (!labelImage)365 return LayoutRect();366 367 // Assume that the labelImage has been provided to match our device scale.368 float scaleFactor = 1;369 if (document()->page())370 scaleFactor = document()->page()->deviceScaleFactor();371 IntSize labelImageSize = labelImage->size();372 labelImageSize.scale(1 / (scaleFactor ? scaleFactor : 1));373 374 LayoutSize labelSize = labelImageSize - LayoutSize(2 * startLabelInset, 2 * startLabelInset);375 LayoutRect candidateRect(contentBox.maxXMinYCorner() + LayoutSize(-startLabelPadding, startLabelPadding) + LayoutSize(-labelSize.width(), 0), labelSize);376 // The minimum allowed content box size is the label image placed in the center of the box, surrounded by startLabelPadding.377 if (candidateRect.x() < startLabelPadding || candidateRect.maxY() > contentBox.height() - startLabelPadding)378 return LayoutRect();379 return candidateRect;380 }381 382 308 void RenderSnapshottedPlugIn::resetDelayTimer(ShowReason reason) 383 309 { -
trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h
r142341 r142343 28 28 29 29 #include "RenderBlock.h" 30 #include "RenderEmbeddedObject.h"31 30 #include "RenderImageResource.h" 32 31 #include "Timer.h" … … 36 35 class HTMLPlugInImageElement; 37 36 38 class RenderSnapshottedPlugIn : public Render EmbeddedObject{37 class RenderSnapshottedPlugIn : public RenderBlock { 39 38 public: 40 39 explicit RenderSnapshottedPlugIn(HTMLPlugInImageElement*); 41 40 virtual ~RenderSnapshottedPlugIn(); 42 43 enum LabelSize {44 LabelSizeSmall,45 LabelSizeLarge,46 NoLabel,47 };48 41 49 42 void updateSnapshot(PassRefPtr<Image>); … … 61 54 virtual bool isSnapshottedPlugIn() const OVERRIDE { return true; } 62 55 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE; 63 virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;64 56 65 void paint ReplacedSnapshot(PaintInfo&, const LayoutPoint&);66 void paint ReplacedSnapshotWithLabel(PaintInfo&, const LayoutPoint&);67 void paintSnapshot (Image*, PaintInfo&, const LayoutPoint&);57 void paintSnapshot(PaintInfo&, const LayoutPoint&); 58 void paintSnapshotWithLabel(PaintInfo&, const LayoutPoint&); 59 void paintSnapshotImage(Image*, PaintInfo&, const LayoutPoint&); 68 60 void repaintLabel(); 69 70 LayoutRect tryToFitStartLabel(LabelSize, const LayoutRect& contentBox) const;71 Image* startLabelImage(LabelSize) const;72 61 73 62 enum ShowReason { -
trunk/Source/WebKit2/ChangeLog
r142341 r142343 1 2013-02-08 Dean Jackson <dino@apple.com> 2 3 Snapshotted plug-in should use shadow root 4 https://bugs.webkit.org/show_bug.cgi?id=108284 5 6 Reviewed by Simon Fraser. 7 8 Take two of this commit! We no longer have any need for plugInStartLabelImage. 9 10 * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp: Remove plugInStartLabelImage. 11 * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h: Ditto. 12 * WebProcess/WebCoreSupport/WebChromeClient.cpp: Ditto. 13 * WebProcess/WebCoreSupport/WebChromeClient.h: Ditto. 14 1 15 2013-02-08 Dean Jackson <dino@apple.com> 2 16 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp
r142341 r142343 164 164 } 165 165 166 PassRefPtr<WebImage> InjectedBundlePageUIClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const167 {168 if (!m_client.plugInStartLabelImage)169 return 0;170 171 WKBundlePageLabelSize wkSize;172 switch (size) {173 case RenderSnapshottedPlugIn::LabelSizeSmall:174 wkSize = WKBundlePageLabelSizeSmall;175 break;176 case RenderSnapshottedPlugIn::LabelSizeLarge:177 wkSize = WKBundlePageLabelSizeLarge;178 break;179 default:180 return 0;181 }182 183 return adoptRef(toImpl(m_client.plugInStartLabelImage(wkSize, m_client.clientInfo)));184 }185 186 166 String InjectedBundlePageUIClient::plugInStartLabelTitle() const 187 167 { -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h
r142341 r142343 30 30 #include "WKBundlePage.h" 31 31 #include "WebEvent.h" 32 #include "WebImage.h"33 32 #include <WebCore/RenderSnapshottedPlugIn.h> 34 33 #include <wtf/Forward.h> … … 72 71 uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes); 73 72 74 PassRefPtr<WebImage> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const;75 73 String plugInStartLabelTitle() const; 76 74 String plugInStartLabelSubtitle() const; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r142341 r142343 799 799 } 800 800 801 PassRefPtr<Image> WebChromeClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const802 {803 return m_page->injectedBundleUIClient().plugInStartLabelImage(size)->bitmap()->createImage();804 }805 806 801 String WebChromeClient::plugInStartLabelTitle() const 807 802 { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
r142341 r142343 29 29 30 30 #include <WebCore/ChromeClient.h> 31 #include <WebCore/Image.h>32 31 #include <WebCore/ViewportArguments.h> 33 32 #include <wtf/text/WTFString.h> … … 219 218 virtual void logDiagnosticMessage(const String& message, const String& description, const String& success) OVERRIDE; 220 219 221 virtual PassRefPtr<WebCore::Image> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const OVERRIDE;222 220 virtual String plugInStartLabelTitle() const OVERRIDE; 223 221 virtual String plugInStartLabelSubtitle() const OVERRIDE;
Note: See TracChangeset
for help on using the changeset viewer.