Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: Source/core/layout/LayoutEmbeddedObject.cpp

Issue 930183002: Move and rename RenderEmbeddedObject and RenderIFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename properly to LayoutIFrame in test expectations. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/layout/LayoutEmbeddedObject.h ('k') | Source/core/layout/LayoutIFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Simon Hausmann <hausmann@kde.org> 3 * (C) 2000 Simon Hausmann <hausmann@kde.org>
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 * 21 *
22 */ 22 */
23 23
24 #include "config.h" 24 #include "config.h"
25 #include "core/rendering/RenderEmbeddedObject.h" 25 #include "core/layout/LayoutEmbeddedObject.h"
26 26
27 #include "core/CSSValueKeywords.h" 27 #include "core/CSSValueKeywords.h"
28 #include "core/HTMLNames.h" 28 #include "core/HTMLNames.h"
29 #include "core/frame/LocalFrame.h" 29 #include "core/frame/LocalFrame.h"
30 #include "core/frame/Settings.h" 30 #include "core/frame/Settings.h"
31 #include "core/html/HTMLIFrameElement.h" 31 #include "core/html/HTMLIFrameElement.h"
32 #include "core/html/HTMLPlugInElement.h" 32 #include "core/html/HTMLPlugInElement.h"
33 #include "core/layout/LayoutTheme.h" 33 #include "core/layout/LayoutTheme.h"
34 #include "core/layout/PaintInfo.h" 34 #include "core/layout/PaintInfo.h"
35 #include "core/page/Page.h" 35 #include "core/page/Page.h"
36 #include "core/plugins/PluginView.h" 36 #include "core/plugins/PluginView.h"
37 #include "core/rendering/RenderView.h" 37 #include "core/rendering/RenderView.h"
38 #include "platform/fonts/Font.h" 38 #include "platform/fonts/Font.h"
39 #include "platform/fonts/FontSelector.h" 39 #include "platform/fonts/FontSelector.h"
40 #include "platform/graphics/GraphicsContextStateSaver.h" 40 #include "platform/graphics/GraphicsContextStateSaver.h"
41 #include "platform/graphics/Path.h" 41 #include "platform/graphics/Path.h"
42 #include "platform/text/PlatformLocale.h" 42 #include "platform/text/PlatformLocale.h"
43 #include "platform/text/TextRun.h" 43 #include "platform/text/TextRun.h"
44 44
45 namespace blink { 45 namespace blink {
46 46
47 using namespace HTMLNames; 47 using namespace HTMLNames;
48 48
49 static const float replacementTextRoundedRectHeight = 18; 49 static const float replacementTextRoundedRectHeight = 18;
50 static const float replacementTextRoundedRectLeftRightTextMargin = 6; 50 static const float replacementTextRoundedRectLeftRightTextMargin = 6;
51 static const float replacementTextRoundedRectOpacity = 0.20f; 51 static const float replacementTextRoundedRectOpacity = 0.20f;
52 static const float replacementTextRoundedRectRadius = 5; 52 static const float replacementTextRoundedRectRadius = 5;
53 static const float replacementTextTextOpacity = 0.55f; 53 static const float replacementTextTextOpacity = 0.55f;
54 54
55 RenderEmbeddedObject::RenderEmbeddedObject(Element* element) 55 LayoutEmbeddedObject::LayoutEmbeddedObject(Element* element)
56 : LayoutPart(element) 56 : LayoutPart(element)
57 , m_showsUnavailablePluginIndicator(false) 57 , m_showsUnavailablePluginIndicator(false)
58 { 58 {
59 view()->frameView()->setIsVisuallyNonEmpty(); 59 view()->frameView()->setIsVisuallyNonEmpty();
60 } 60 }
61 61
62 RenderEmbeddedObject::~RenderEmbeddedObject() 62 LayoutEmbeddedObject::~LayoutEmbeddedObject()
63 { 63 {
64 } 64 }
65 65
66 LayerType RenderEmbeddedObject::layerTypeRequired() const 66 LayerType LayoutEmbeddedObject::layerTypeRequired() const
67 { 67 {
68 // This can't just use LayoutPart::layerTypeRequired, because LayerComposito r 68 // This can't just use LayoutPart::layerTypeRequired, because LayerComposito r
69 // doesn't loop through RenderEmbeddedObjects the way it does frames in orde r 69 // doesn't loop through LayoutEmbeddedObjects the way it does frames in orde r
70 // to update the self painting bit on their Layer. 70 // to update the self painting bit on their Layer.
71 // Also, unlike iframes, embeds don't used the usesCompositing bit on Render View 71 // Also, unlike iframes, embeds don't used the usesCompositing bit on Render View
72 // in requiresAcceleratedCompositing. 72 // in requiresAcceleratedCompositing.
73 if (requiresAcceleratedCompositing()) 73 if (requiresAcceleratedCompositing())
74 return NormalLayer; 74 return NormalLayer;
75 return LayoutPart::layerTypeRequired(); 75 return LayoutPart::layerTypeRequired();
76 } 76 }
77 77
78 static String unavailablePluginReplacementText(Node* node, RenderEmbeddedObject: :PluginUnavailabilityReason pluginUnavailabilityReason) 78 static String unavailablePluginReplacementText(Node* node, LayoutEmbeddedObject: :PluginUnavailabilityReason pluginUnavailabilityReason)
79 { 79 {
80 Locale& locale = node ? toElement(node)->locale() : Locale::defaultLocale(); 80 Locale& locale = node ? toElement(node)->locale() : Locale::defaultLocale();
81 switch (pluginUnavailabilityReason) { 81 switch (pluginUnavailabilityReason) {
82 case RenderEmbeddedObject::PluginMissing: 82 case LayoutEmbeddedObject::PluginMissing:
83 return locale.queryString(WebLocalizedString::MissingPluginText); 83 return locale.queryString(WebLocalizedString::MissingPluginText);
84 case RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy: 84 case LayoutEmbeddedObject::PluginBlockedByContentSecurityPolicy:
85 return locale.queryString(WebLocalizedString::BlockedPluginText); 85 return locale.queryString(WebLocalizedString::BlockedPluginText);
86 } 86 }
87 87
88 ASSERT_NOT_REACHED(); 88 ASSERT_NOT_REACHED();
89 return String(); 89 return String();
90 } 90 }
91 91
92 void RenderEmbeddedObject::setPluginUnavailabilityReason(PluginUnavailabilityRea son pluginUnavailabilityReason) 92 void LayoutEmbeddedObject::setPluginUnavailabilityReason(PluginUnavailabilityRea son pluginUnavailabilityReason)
93 { 93 {
94 ASSERT(!m_showsUnavailablePluginIndicator); 94 ASSERT(!m_showsUnavailablePluginIndicator);
95 m_showsUnavailablePluginIndicator = true; 95 m_showsUnavailablePluginIndicator = true;
96 m_pluginUnavailabilityReason = pluginUnavailabilityReason; 96 m_pluginUnavailabilityReason = pluginUnavailabilityReason;
97 97
98 m_unavailablePluginReplacementText = unavailablePluginReplacementText(node() , pluginUnavailabilityReason); 98 m_unavailablePluginReplacementText = unavailablePluginReplacementText(node() , pluginUnavailabilityReason);
99 } 99 }
100 100
101 bool RenderEmbeddedObject::showsUnavailablePluginIndicator() const 101 bool LayoutEmbeddedObject::showsUnavailablePluginIndicator() const
102 { 102 {
103 return m_showsUnavailablePluginIndicator; 103 return m_showsUnavailablePluginIndicator;
104 } 104 }
105 105
106 void RenderEmbeddedObject::paintContents(const PaintInfo& paintInfo, const Layou tPoint& paintOffset) 106 void LayoutEmbeddedObject::paintContents(const PaintInfo& paintInfo, const Layou tPoint& paintOffset)
107 { 107 {
108 Element* element = toElement(node()); 108 Element* element = toElement(node());
109 if (!isHTMLPlugInElement(element)) 109 if (!isHTMLPlugInElement(element))
110 return; 110 return;
111 111
112 LayoutPart::paintContents(paintInfo, paintOffset); 112 LayoutPart::paintContents(paintInfo, paintOffset);
113 } 113 }
114 114
115 void RenderEmbeddedObject::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 115 void LayoutEmbeddedObject::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
116 { 116 {
117 if (showsUnavailablePluginIndicator()) { 117 if (showsUnavailablePluginIndicator()) {
118 LayoutReplaced::paint(paintInfo, paintOffset); 118 LayoutReplaced::paint(paintInfo, paintOffset);
119 return; 119 return;
120 } 120 }
121 121
122 LayoutPart::paint(paintInfo, paintOffset); 122 LayoutPart::paint(paintInfo, paintOffset);
123 } 123 }
124 124
125 void RenderEmbeddedObject::paintReplaced(const PaintInfo& paintInfo, const Layou tPoint& paintOffset) 125 void LayoutEmbeddedObject::paintReplaced(const PaintInfo& paintInfo, const Layou tPoint& paintOffset)
126 { 126 {
127 if (!showsUnavailablePluginIndicator()) 127 if (!showsUnavailablePluginIndicator())
128 return; 128 return;
129 129
130 if (paintInfo.phase == PaintPhaseSelection) 130 if (paintInfo.phase == PaintPhaseSelection)
131 return; 131 return;
132 132
133 FloatRect contentRect; 133 FloatRect contentRect;
134 Path path; 134 Path path;
135 FloatRect replacementTextRect; 135 FloatRect replacementTextRect;
(...skipping 11 matching lines...) Expand all
147 147
148 const FontMetrics& fontMetrics = font.fontMetrics(); 148 const FontMetrics& fontMetrics = font.fontMetrics();
149 float labelX = roundf(replacementTextRect.location().x() + (replacementTextR ect.size().width() - textWidth) / 2); 149 float labelX = roundf(replacementTextRect.location().x() + (replacementTextR ect.size().width() - textWidth) / 2);
150 float labelY = roundf(replacementTextRect.location().y() + (replacementTextR ect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent()); 150 float labelY = roundf(replacementTextRect.location().y() + (replacementTextR ect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent());
151 TextRunPaintInfo runInfo(run); 151 TextRunPaintInfo runInfo(run);
152 runInfo.bounds = replacementTextRect; 152 runInfo.bounds = replacementTextRect;
153 context->setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity)); 153 context->setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity));
154 context->drawBidiText(font, runInfo, FloatPoint(labelX, labelY)); 154 context->drawBidiText(font, runInfo, FloatPoint(labelX, labelY));
155 } 155 }
156 156
157 bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumul atedOffset, FloatRect& contentRect, Path& path, FloatRect& replacementTextRect, Font& font, TextRun& run, float& textWidth) const 157 bool LayoutEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumul atedOffset, FloatRect& contentRect, Path& path, FloatRect& replacementTextRect, Font& font, TextRun& run, float& textWidth) const
158 { 158 {
159 contentRect = contentBoxRect(); 159 contentRect = contentBoxRect();
160 contentRect.moveBy(roundedIntPoint(accumulatedOffset)); 160 contentRect.moveBy(roundedIntPoint(accumulatedOffset));
161 161
162 FontDescription fontDescription; 162 FontDescription fontDescription;
163 LayoutTheme::theme().systemFont(CSSValueWebkitSmallControl, fontDescription) ; 163 LayoutTheme::theme().systemFont(CSSValueWebkitSmallControl, fontDescription) ;
164 fontDescription.setWeight(FontWeightBold); 164 fontDescription.setWeight(FontWeightBold);
165 Settings* settings = document().settings(); 165 Settings* settings = document().settings();
166 ASSERT(settings); 166 ASSERT(settings);
167 if (!settings) 167 if (!settings)
168 return false; 168 return false;
169 fontDescription.setComputedSize(fontDescription.specifiedSize()); 169 fontDescription.setComputedSize(fontDescription.specifiedSize());
170 font = Font(fontDescription); 170 font = Font(fontDescription);
171 font.update(nullptr); 171 font.update(nullptr);
172 172
173 run = TextRun(m_unavailablePluginReplacementText); 173 run = TextRun(m_unavailablePluginReplacementText);
174 textWidth = font.width(run); 174 textWidth = font.width(run);
175 175
176 replacementTextRect.setSize(FloatSize(textWidth + replacementTextRoundedRect LeftRightTextMargin * 2, replacementTextRoundedRectHeight)); 176 replacementTextRect.setSize(FloatSize(textWidth + replacementTextRoundedRect LeftRightTextMargin * 2, replacementTextRoundedRectHeight));
177 float x = (contentRect.size().width() / 2 - replacementTextRect.size().width () / 2) + contentRect.location().x(); 177 float x = (contentRect.size().width() / 2 - replacementTextRect.size().width () / 2) + contentRect.location().x();
178 float y = (contentRect.size().height() / 2 - replacementTextRect.size().heig ht() / 2) + contentRect.location().y(); 178 float y = (contentRect.size().height() / 2 - replacementTextRect.size().heig ht() / 2) + contentRect.location().y();
179 replacementTextRect.setLocation(FloatPoint(x, y)); 179 replacementTextRect.setLocation(FloatPoint(x, y));
180 180
181 path.addRoundedRect(replacementTextRect, FloatSize(replacementTextRoundedRec tRadius, replacementTextRoundedRectRadius)); 181 path.addRoundedRect(replacementTextRect, FloatSize(replacementTextRoundedRec tRadius, replacementTextRoundedRectRadius));
182 182
183 return true; 183 return true;
184 } 184 }
185 185
186 void RenderEmbeddedObject::layout() 186 void LayoutEmbeddedObject::layout()
187 { 187 {
188 ASSERT(needsLayout()); 188 ASSERT(needsLayout());
189 189
190 updateLogicalWidth(); 190 updateLogicalWidth();
191 updateLogicalHeight(); 191 updateLogicalHeight();
192 192
193 m_overflow.clear(); 193 m_overflow.clear();
194 addVisualEffectOverflow(); 194 addVisualEffectOverflow();
195 195
196 updateLayerTransformAfterLayout(); 196 updateLayerTransformAfterLayout();
197 197
198 if (!widget() && frameView()) 198 if (!widget() && frameView())
199 frameView()->addPartToUpdate(*this); 199 frameView()->addPartToUpdate(*this);
200 200
201 clearNeedsLayout(); 201 clearNeedsLayout();
202 } 202 }
203 203
204 bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity g ranularity, float) 204 bool LayoutEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity g ranularity, float)
205 { 205 {
206 return false; 206 return false;
207 } 207 }
208 208
209 CompositingReasons RenderEmbeddedObject::additionalCompositingReasons() const 209 CompositingReasons LayoutEmbeddedObject::additionalCompositingReasons() const
210 { 210 {
211 if (requiresAcceleratedCompositing()) 211 if (requiresAcceleratedCompositing())
212 return CompositingReasonPlugin; 212 return CompositingReasonPlugin;
213 return CompositingReasonNone; 213 return CompositingReasonNone;
214 } 214 }
215 215
216 RenderBox* RenderEmbeddedObject::embeddedContentBox() const 216 RenderBox* LayoutEmbeddedObject::embeddedContentBox() const
217 { 217 {
218 if (!node() || !widget() || !widget()->isFrameView()) 218 if (!node() || !widget() || !widget()->isFrameView())
219 return 0; 219 return 0;
220 return toFrameView(widget())->embeddedContentBox(); 220 return toFrameView(widget())->embeddedContentBox();
221 } 221 }
222 222
223 } // namespace blink 223 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutEmbeddedObject.h ('k') | Source/core/layout/LayoutIFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698