Changeset 142400 in webkit
- Timestamp:
- Feb 10, 2013 6:24:46 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142398 r142400 1 2013-02-10 Kent Tamura <tkent@chromium.org> 2 3 Unreviewed, rolling out r142343. 4 http://trac.webkit.org/changeset/142343 5 https://bugs.webkit.org/show_bug.cgi?id=108284 6 7 It might make inspector/profiler/selector-profiler-url.html 8 crashy. 9 10 * WebCore.exp.in: 11 * css/plugIns.css: 12 (p): 13 * html/HTMLPlugInElement.cpp: 14 (WebCore::HTMLPlugInElement::defaultEventHandler): 15 * html/HTMLPlugInImageElement.cpp: 16 (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): 17 (WebCore::HTMLPlugInImageElement::createRenderer): 18 (WebCore::HTMLPlugInImageElement::willRecalcStyle): 19 (WebCore::HTMLPlugInImageElement::updateSnapshot): 20 (WebCore::HTMLPlugInImageElement::userDidClickSnapshot): 21 (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): 22 * html/HTMLPlugInImageElement.h: 23 (WebCore): 24 (HTMLPlugInImageElement): 25 * page/ChromeClient.h: 26 (WebCore::ChromeClient::plugInStartLabelImage): 27 * platform/LocalizedStrings.cpp: 28 * platform/LocalizedStrings.h: 29 * platform/blackberry/LocalizedStringsBlackBerry.cpp: 30 * platform/chromium/LocalizedStringsChromium.cpp: 31 * platform/efl/LocalizedStringsEfl.cpp: 32 (WebCore): 33 * platform/gtk/LocalizedStringsGtk.cpp: 34 (WebCore): 35 * platform/qt/LocalizedStringsQt.cpp: 36 * rendering/RenderSnapshottedPlugIn.cpp: 37 (WebCore): 38 (WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): 39 (WebCore::RenderSnapshottedPlugIn::paint): 40 (WebCore::RenderSnapshottedPlugIn::paintReplaced): 41 (WebCore::RenderSnapshottedPlugIn::paintSnapshot): 42 (WebCore::RenderSnapshottedPlugIn::paintReplacedSnapshot): 43 (WebCore::RenderSnapshottedPlugIn::startLabelImage): 44 (WebCore::RenderSnapshottedPlugIn::paintReplacedSnapshotWithLabel): 45 (WebCore::RenderSnapshottedPlugIn::getCursor): 46 (WebCore::RenderSnapshottedPlugIn::handleEvent): 47 (WebCore::RenderSnapshottedPlugIn::tryToFitStartLabel): 48 * rendering/RenderSnapshottedPlugIn.h: 49 1 50 2013-02-10 Andreas Kling <akling@apple.com> 2 51 -
trunk/Source/WebCore/WebCore.exp.in
r142381 r142400 140 140 __ZN7WebCore11HistoryItemC1Ev 141 141 __ZN7WebCore11HistoryItemD1Ev 142 __ZNK7WebCore9InlineBox14caretMaxOffsetEv143 __ZN7WebCore9InlineBox14selectionStateEv144 __ZN7WebCore9InlineBox14dirtyLineBoxesEv145 __ZNK7WebCore9InlineBox22canAccommodateEllipsisEbii146 __ZN7WebCore9InlineBox11extractLineEv147 __ZN7WebCore9InlineBox14adjustPositionEff148 __ZN7WebCore9InlineBoxdlEPvm149 __ZN7WebCore9InlineBox5paintERNS_9PaintInfoERKNS_11LayoutPointENS_10LayoutUnitES6_150 __ZN7WebCore9InlineBox10attachLineEv151 __ZNK7WebCore9InlineBox16baselinePositionENS_12FontBaselineE152 __ZN7WebCore9InlineBox11nodeAtPointERKNS_14HitTestRequestERNS_13HitTestResultERKNS_15HitTestLocationERKNS_11LayoutPointENS_10LayoutUnitESC_153 __ZN7WebCore9InlineBox10deleteLineEPNS_11RenderArenaE154 __ZN7WebCore9InlineBox7destroyEPNS_11RenderArenaE155 __ZN7WebCore9InlineBox16placeEllipsisBoxEbfffRfRb156 __ZNK7WebCore9InlineBox17reportMemoryUsageEPN3WTF16MemoryObjectInfoE157 __ZNK7WebCore9InlineBox14caretMinOffsetEv158 __ZNK7WebCore9InlineBox10lineHeightEv159 142 __ZN7WebCore11JSDOMWindow6s_infoE 160 143 __ZN7WebCore11MemoryCache11setDisabledEb -
trunk/Source/WebCore/css/plugIns.css
r142343 r142400 23 23 */ 24 24 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 } 25 /* plug-ins */ 26 p{} /*Needed by Windows because it doesn't like empty files*/ -
trunk/Source/WebCore/html/HTMLPlugInElement.cpp
r142343 r142400 202 202 return; 203 203 } 204 } else if (r &&r->isSnapshottedPlugIn() && displayState() < PlayingWithPendingMouseClick) {205 toRenderSnapshottedPlugIn(r)->handleEvent(event);206 HTMLFrameOwnerElement::defaultEventHandler(event);207 return;204 if (r->isSnapshottedPlugIn() && displayState() < PlayingWithPendingMouseClick) { 205 toRenderSnapshottedPlugIn(r)->handleEvent(event); 206 return; 207 } 208 208 } 209 209 -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r142343 r142400 22 22 #include "HTMLPlugInImageElement.h" 23 23 24 #include "Chrome.h"25 #include "ChromeClient.h"26 24 #include "Frame.h" 27 25 #include "FrameLoader.h" 28 26 #include "FrameLoaderClient.h" 29 27 #include "FrameView.h" 30 #include "HTMLDivElement.h"31 28 #include "HTMLImageLoader.h" 29 #include "HTMLNames.h" 32 30 #include "Image.h" 33 #include "LocalizedStrings.h"34 31 #include "Logging.h" 35 32 #include "MouseEvent.h" 36 33 #include "NodeRenderStyle.h" 37 #include "NodeRenderingContext.h"38 34 #include "Page.h" 39 35 #include "PlugInClient.h" … … 46 42 #include "SecurityOrigin.h" 47 43 #include "Settings.h" 48 #include "ShadowRoot.h"49 44 #include "StyleResolver.h" 50 #include "Text.h"51 45 52 46 namespace WebCore { 53 54 using namespace HTMLNames;55 47 56 48 static const int autoStartPlugInSizeThresholdWidth = 1; … … 70 62 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages) 71 63 , m_needsDocumentActivationCallbacks(false) 72 , m_shouldShowSnapshotLabelAutomatically(false)73 64 , m_simulatedMouseClickTimer(this, &HTMLPlugInImageElement::simulatedMouseClickTimerFired, simulatedMouseClickTimerDelay) 74 , m_swapRendererTimer(this, &HTMLPlugInImageElement::swapRendererTimerFired)75 65 { 76 66 setHasCustomCallbacks(); … … 143 133 document()->registerForPageCacheSuspensionCallbacks(this); 144 134 } 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 135 154 136 // Fallback content breaks the DOM->Renderer class relationship of this 155 137 // class and all superclasses because createObject won't necessarily … … 157 139 if (useFallbackContent()) 158 140 return RenderObject::createObject(this, style); 159 160 141 if (isImageType()) { 161 142 RenderImage* image = new (arena) RenderImage(this); … … 164 145 } 165 146 147 if (document()->page() && document()->page()->settings()->plugInSnapshottingEnabled()) 148 return new (arena) RenderSnapshottedPlugIn(this); 166 149 return new (arena) RenderEmbeddedObject(this); 167 150 } … … 170 153 { 171 154 // FIXME: Why is this necessary? Manual re-attach is almost always wrong. 172 if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType() && (displayState() != DisplayingSnapshot))155 if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType()) 173 156 reattach(); 174 157 return true; … … 276 259 void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image) 277 260 { 278 if (displayState() > DisplayingSnapshot) 279 return; 280 281 m_snapshotImage = image; 282 if (renderer()->isSnapshottedPlugIn()) { 283 toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image); 284 return; 285 } 286 261 if (displayState() > DisplayingSnapshot || !renderer()->isSnapshottedPlugIn()) 262 return; 263 264 toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image); 287 265 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 container342 // and reattach, thus making a new Renderer.343 ensureUserAgentShadowRoot();344 266 } 345 267 … … 349 271 if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame()->document()->baseURL().protocol())) 350 272 document()->page()->plugInClient()->addAutoStartOrigin(document()->page()->mainFrame()->document()->baseURL().host(), m_plugInOriginHash); 351 352 reattach();353 273 } 354 274 … … 400 320 } 401 321 322 if (!renderer()->isSnapshottedPlugIn()) { 323 LOG(Plugins, "%p Renderer is not snapshotted plugin, set to play", this); 324 return; 325 } 402 326 if (ScriptController::processingUserGesture()) { 403 327 LOG(Plugins, "%p Script is processing user gesture, set to play", this); … … 405 329 } 406 330 407 LayoutRect rect = toRender EmbeddedObject(renderer())->contentBoxRect();331 LayoutRect rect = toRenderSnapshottedPlugIn(renderer())->contentBoxRect(); 408 332 int width = rect.width(); 409 333 int height = rect.height(); … … 428 352 429 353 if (shouldPlugInShowLabelAutomatically(document()->page()->mainFrame()->view()->contentsSize(), this)) 430 setShouldShowSnapshotLabelAutomatically();354 toRenderSnapshottedPlugIn(renderer())->setShouldShowLabelAutomatically(); 431 355 432 356 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); 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); 357 setDisplayState(WaitingForSnapshot); 437 358 } 438 359 -
trunk/Source/WebCore/html/HTMLPlugInImageElement.h
r142343 r142400 26 26 #include "RenderStyle.h" 27 27 #include <wtf/OwnPtr.h> 28 #include <wtf/RefPtr.h>29 28 30 29 namespace WebCore { … … 32 31 class HTMLImageLoader; 33 32 class FrameLoader; 34 class Image;35 33 class MouseEvent; 36 34 class Widget; … … 40 38 CreateOnlyNonNetscapePlugins, 41 39 }; 42 40 43 41 enum PreferPlugInsForImagesOption { 44 42 ShouldPreferPlugInsForImages, … … 95 93 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 96 94 virtual bool willRecalcStyle(StyleChange); 97 98 void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE; 99 95 100 96 virtual void finishParsingChildren(); 101 97 102 98 void updateWidgetIfNecessary(); 103 99 virtual bool useFallbackContent() const { return false; } 104 100 105 101 virtual void updateSnapshot(PassRefPtr<Image>) OVERRIDE; 106 102 virtual void dispatchPendingMouseClick() OVERRIDE; 107 103 void simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>*); 108 104 109 void swapRendererTimerFired(Timer<HTMLPlugInImageElement>*);110 111 void setShouldShowSnapshotLabelAutomatically() { m_shouldShowSnapshotLabelAutomatically = true; }112 113 105 bool m_needsWidgetUpdate; 114 106 bool m_shouldPreferPlugInsForImages; 115 107 bool m_needsDocumentActivationCallbacks; 116 bool m_shouldShowSnapshotLabelAutomatically;117 108 RefPtr<RenderStyle> m_customStyleForPageCache; 118 109 RefPtr<MouseEvent> m_pendingClickEventFromSnapshot; 119 110 DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer; 120 Timer<HTMLPlugInImageElement> m_swapRendererTimer;121 RefPtr<Image> m_snapshotImage;122 111 }; 123 112 -
trunk/Source/WebCore/page/ChromeClient.h
r142343 r142400 374 374 virtual bool isEmptyChromeClient() const { return false; } 375 375 376 virtual PassRefPtr<Image> plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize) const { return 0; } 376 377 virtual String plugInStartLabelTitle() const { return String(); } 377 378 virtual String plugInStartLabelSubtitle() const { return String(); } -
trunk/Source/WebCore/platform/LocalizedStrings.cpp
r142343 r142400 1 1 /* 2 * Copyright (C) 2003, 2006, 2009, 2010, 2012 , 2013Apple Inc. All rights reserved.2 * Copyright (C) 2003, 2006, 2009, 2010, 2012 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2010 Igalia S.L 4 4 * -
trunk/Source/WebCore/platform/LocalizedStrings.h
r142343 r142400 1 1 /* 2 * Copyright (C) 2003, 2006, 2009, 2011 , 2012, 2013Apple Inc. All rights reserved.2 * Copyright (C) 2003, 2006, 2009, 2011 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2010 Igalia S.L 4 4 * -
trunk/Source/WebCore/platform/blackberry/LocalizedStringsBlackBerry.cpp
r142343 r142400 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 632 620 } // namespace WebCore -
trunk/Source/WebCore/platform/chromium/LocalizedStringsChromium.cpp
r142343 r142400 417 417 String contextMenuItemTagMediaPause() { return String(); } 418 418 String contextMenuItemTagMediaMute() { return String(); } 419 String snapshottedPlugInLabelTitle() { return String(); }420 String snapshottedPlugInLabelSubtitle() { return String(); }421 419 422 420 #if ENABLE(VIDEO_TRACK) -
trunk/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp
r142343 r142400 611 611 #endif 612 612 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 } 613 } -
trunk/Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp
r142343 r142400 775 775 #endif 776 776 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 } 777 } -
trunk/Source/WebCore/platform/qt/LocalizedStringsQt.cpp
r142343 r142400 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 738 726 String localizedString(const char* key) 739 727 { -
trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
r142343 r142400 41 41 #include "PaintInfo.h" 42 42 #include "Path.h" 43 #include "RenderView.h"44 43 #include "SourceGraphic.h" 45 44 … … 48 47 static const int autoStartPlugInSizeThresholdWidth = 1; 49 48 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. 50 51 static const double showLabelAfterMouseOverDelay = 1; 51 52 static const double showLabelAutomaticallyDelay = 3; … … 100 101 101 102 RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement* element) 102 : Render Block(element)103 : RenderEmbeddedObject(element) 103 104 , m_snapshotResource(RenderImageResource::create()) 104 105 , m_shouldShowLabel(false) … … 145 146 void RenderSnapshottedPlugIn::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 146 147 { 147 if (paintInfo.phase == PaintPhaseBlockBackground && plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) { 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) { 148 159 if (m_shouldShowLabel) 149 paint SnapshotWithLabel(paintInfo, paintOffset);160 paintReplacedSnapshotWithLabel(paintInfo, paintOffset); 150 161 else 151 paintSnapshot(paintInfo, paintOffset); 152 } 153 154 RenderBlock::paint(paintInfo, paintOffset); 155 } 156 157 void RenderSnapshottedPlugIn::paintSnapshotImage(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset) 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) 158 170 { 159 171 LayoutUnit cWidth = contentWidth(); … … 169 181 170 182 LayoutSize contentSize(cWidth, cHeight); 171 LayoutPoint contentLocation = location() +paintOffset;183 LayoutPoint contentLocation = paintOffset; 172 184 contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); 173 185 … … 181 193 } 182 194 183 void RenderSnapshottedPlugIn::paint Snapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)195 void RenderSnapshottedPlugIn::paintReplacedSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 184 196 { 185 197 RefPtr<Image> image = m_snapshotResource->image(); … … 187 199 return; 188 200 189 paintSnapshotImage(image.get(), paintInfo, paintOffset); 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]; 190 220 } 191 221 … … 209 239 #endif 210 240 211 void RenderSnapshottedPlugIn::paint SnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)241 void RenderSnapshottedPlugIn::paintReplacedSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 212 242 { 213 243 if (contentBoxRect().isEmpty()) … … 218 248 219 249 m_showedLabelOnce = true; 220 LayoutRect labelRect; 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; 221 266 222 267 RefPtr<Image> snapshotImage = m_snapshotResource->image(); … … 225 270 226 271 #if ENABLE(FILTERS) 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 } 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; 237 278 #endif 238 279 239 paintSnapshotImage(snapshotImage.get(), paintInfo, paintOffset); 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()); 240 287 } 241 288 … … 263 310 return SetCursor; 264 311 } 265 return Render Block::getCursor(point, overrideCursor);312 return RenderEmbeddedObject::getCursor(point, overrideCursor); 266 313 } 267 314 … … 279 326 plugInImageElement()->setDisplayState(HTMLPlugInElement::PlayingWithPendingMouseClick); 280 327 plugInImageElement()->userDidClickSnapshot(mouseEvent); 328 329 if (widget()) { 330 if (Frame* frame = document()->frame()) 331 frame->loader()->client()->recreatePlugin(widget()); 332 repaint(); 333 } 281 334 event->setDefaultHandled(); 282 335 } else if (event->type() == eventNames().mousedownEvent) { … … 306 359 } 307 360 361 LayoutRect RenderSnapshottedPlugIn::tryToFitStartLabel(LabelSize size, const LayoutRect& contentBox) const 362 { 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 308 382 void RenderSnapshottedPlugIn::resetDelayTimer(ShowReason reason) 309 383 { -
trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h
r142343 r142400 28 28 29 29 #include "RenderBlock.h" 30 #include "RenderEmbeddedObject.h" 30 31 #include "RenderImageResource.h" 31 32 #include "Timer.h" … … 35 36 class HTMLPlugInImageElement; 36 37 37 class RenderSnapshottedPlugIn : public Render Block{38 class RenderSnapshottedPlugIn : public RenderEmbeddedObject { 38 39 public: 39 40 explicit RenderSnapshottedPlugIn(HTMLPlugInImageElement*); 40 41 virtual ~RenderSnapshottedPlugIn(); 42 43 enum LabelSize { 44 LabelSizeSmall, 45 LabelSizeLarge, 46 NoLabel, 47 }; 41 48 42 49 void updateSnapshot(PassRefPtr<Image>); … … 54 61 virtual bool isSnapshottedPlugIn() const OVERRIDE { return true; } 55 62 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE; 63 virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE; 56 64 57 void paint Snapshot(PaintInfo&, const LayoutPoint&);58 void paint SnapshotWithLabel(PaintInfo&, const LayoutPoint&);59 void paintSnapshot Image(Image*, PaintInfo&, const LayoutPoint&);65 void paintReplacedSnapshot(PaintInfo&, const LayoutPoint&); 66 void paintReplacedSnapshotWithLabel(PaintInfo&, const LayoutPoint&); 67 void paintSnapshot(Image*, PaintInfo&, const LayoutPoint&); 60 68 void repaintLabel(); 69 70 LayoutRect tryToFitStartLabel(LabelSize, const LayoutRect& contentBox) const; 71 Image* startLabelImage(LabelSize) const; 61 72 62 73 enum ShowReason { -
trunk/Source/WebKit2/ChangeLog
r142393 r142400 1 2013-02-10 Kent Tamura <tkent@chromium.org> 2 3 Unreviewed, rolling out r142343. 4 http://trac.webkit.org/changeset/142343 5 https://bugs.webkit.org/show_bug.cgi?id=108284 6 7 It might make inspector/profiler/selector-profiler-url.html 8 crashy. 9 10 * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp: 11 (WebKit::InjectedBundlePageUIClient::plugInStartLabelImage): 12 (WebKit): 13 * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h: 14 (InjectedBundlePageUIClient): 15 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 16 (WebKit::WebChromeClient::plugInStartLabelImage): 17 (WebKit): 18 * WebProcess/WebCoreSupport/WebChromeClient.h: 19 (WebChromeClient): 20 1 21 2013-02-10 Zan Dobersek <zdobersek@igalia.com> 2 22 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp
r142347 r142400 164 164 } 165 165 166 PassRefPtr<WebImage> InjectedBundlePageUIClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const 167 { 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 166 186 String InjectedBundlePageUIClient::plugInStartLabelTitle() const 167 187 { -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h
r142343 r142400 30 30 #include "WKBundlePage.h" 31 31 #include "WebEvent.h" 32 #include "WebImage.h" 32 33 #include <WebCore/RenderSnapshottedPlugIn.h> 33 34 #include <wtf/Forward.h> … … 71 72 uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes); 72 73 74 PassRefPtr<WebImage> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const; 73 75 String plugInStartLabelTitle() const; 74 76 String plugInStartLabelSubtitle() const; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r142343 r142400 799 799 } 800 800 801 PassRefPtr<Image> WebChromeClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const 802 { 803 return m_page->injectedBundleUIClient().plugInStartLabelImage(size)->bitmap()->createImage(); 804 } 805 801 806 String WebChromeClient::plugInStartLabelTitle() const 802 807 { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
r142343 r142400 29 29 30 30 #include <WebCore/ChromeClient.h> 31 #include <WebCore/Image.h> 31 32 #include <WebCore/ViewportArguments.h> 32 33 #include <wtf/text/WTFString.h> … … 218 219 virtual void logDiagnosticMessage(const String& message, const String& description, const String& success) OVERRIDE; 219 220 221 virtual PassRefPtr<WebCore::Image> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const OVERRIDE; 220 222 virtual String plugInStartLabelTitle() const OVERRIDE; 221 223 virtual String plugInStartLabelSubtitle() const OVERRIDE;
Note: See TracChangeset
for help on using the changeset viewer.