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

Side by Side Diff: Source/core/frame/FrameView.cpp

Issue 625073002: Merge RenderWidget into single subclass, RenderPart (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: s/widget/part wherever it made sense Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "core/paint/ScrollbarPainter.h" 59 #include "core/paint/ScrollbarPainter.h"
60 #include "core/rendering/RenderCounter.h" 60 #include "core/rendering/RenderCounter.h"
61 #include "core/rendering/RenderEmbeddedObject.h" 61 #include "core/rendering/RenderEmbeddedObject.h"
62 #include "core/rendering/RenderLayer.h" 62 #include "core/rendering/RenderLayer.h"
63 #include "core/rendering/RenderListBox.h" 63 #include "core/rendering/RenderListBox.h"
64 #include "core/rendering/RenderPart.h" 64 #include "core/rendering/RenderPart.h"
65 #include "core/rendering/RenderScrollbar.h" 65 #include "core/rendering/RenderScrollbar.h"
66 #include "core/rendering/RenderScrollbarPart.h" 66 #include "core/rendering/RenderScrollbarPart.h"
67 #include "core/rendering/RenderTheme.h" 67 #include "core/rendering/RenderTheme.h"
68 #include "core/rendering/RenderView.h" 68 #include "core/rendering/RenderView.h"
69 #include "core/rendering/RenderWidget.h"
70 #include "core/rendering/TextAutosizer.h" 69 #include "core/rendering/TextAutosizer.h"
71 #include "core/rendering/compositing/CompositedLayerMapping.h" 70 #include "core/rendering/compositing/CompositedLayerMapping.h"
72 #include "core/rendering/compositing/CompositedSelectionBound.h" 71 #include "core/rendering/compositing/CompositedSelectionBound.h"
73 #include "core/rendering/compositing/RenderLayerCompositor.h" 72 #include "core/rendering/compositing/RenderLayerCompositor.h"
74 #include "core/rendering/style/RenderStyle.h" 73 #include "core/rendering/style/RenderStyle.h"
75 #include "core/rendering/svg/RenderSVGRoot.h" 74 #include "core/rendering/svg/RenderSVGRoot.h"
76 #include "core/svg/SVGDocumentExtensions.h" 75 #include "core/svg/SVGDocumentExtensions.h"
77 #include "core/svg/SVGSVGElement.h" 76 #include "core/svg/SVGSVGElement.h"
78 #include "platform/RuntimeEnabledFeatures.h" 77 #include "platform/RuntimeEnabledFeatures.h"
79 #include "platform/ScriptForbiddenScope.h" 78 #include "platform/ScriptForbiddenScope.h"
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 return 0; 1032 return 0;
1034 1033
1035 // Curently only embedded SVG documents participate in the size-negotiation logic. 1034 // Curently only embedded SVG documents participate in the size-negotiation logic.
1036 if (firstChild->isSVGRoot()) 1035 if (firstChild->isSVGRoot())
1037 return toRenderBox(firstChild); 1036 return toRenderBox(firstChild);
1038 1037
1039 return 0; 1038 return 0;
1040 } 1039 }
1041 1040
1042 1041
1043 void FrameView::addWidget(RenderWidget* object) 1042 void FrameView::addPart(RenderPart* object)
1044 { 1043 {
1045 m_widgets.add(object); 1044 m_parts.add(object);
1046 } 1045 }
1047 1046
1048 void FrameView::removeWidget(RenderWidget* object) 1047 void FrameView::removePart(RenderPart* object)
1049 { 1048 {
1050 m_widgets.remove(object); 1049 m_parts.remove(object);
1051 } 1050 }
1052 1051
1053 void FrameView::updateWidgetPositions() 1052 void FrameView::updateWidgetPositions()
1054 { 1053 {
1055 WillBeHeapVector<RefPtrWillBeMember<RenderWidget> > widgets; 1054 WillBeHeapVector<RefPtrWillBeMember<RenderPart> > parts;
1056 copyToVector(m_widgets, widgets); 1055 copyToVector(m_parts, parts);
1057 1056
1058 // Script or plugins could detach the frame so abort processing if that happ ens. 1057 // Script or plugins could detach the frame so abort processing if that happ ens.
1059 1058
1060 for (size_t i = 0; i < widgets.size() && renderView(); ++i) 1059 for (size_t i = 0; i < parts.size() && renderView(); ++i)
1061 widgets[i]->updateWidgetPosition(); 1060 parts[i]->updateWidgetPosition();
1062 1061
1063 for (size_t i = 0; i < widgets.size() && renderView(); ++i) 1062 for (size_t i = 0; i < parts.size() && renderView(); ++i)
1064 widgets[i]->widgetPositionsUpdated(); 1063 parts[i]->widgetPositionsUpdated();
1065 } 1064 }
1066 1065
1067 void FrameView::addWidgetToUpdate(RenderEmbeddedObject& object) 1066 void FrameView::addPartToUpdate(RenderEmbeddedObject& object)
1068 { 1067 {
1069 ASSERT(isInPerformLayout()); 1068 ASSERT(isInPerformLayout());
1070 // Tell the DOM element that it needs a widget update. 1069 // Tell the DOM element that it needs a widget update.
1071 Node* node = object.node(); 1070 Node* node = object.node();
1072 ASSERT(node); 1071 ASSERT(node);
1073 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node)) 1072 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node))
1074 toHTMLPlugInElement(node)->setNeedsWidgetUpdate(true); 1073 toHTMLPlugInElement(node)->setNeedsWidgetUpdate(true);
1075 1074
1076 m_widgetUpdateSet.add(&object); 1075 m_partUpdateSet.add(&object);
1077 } 1076 }
1078 1077
1079 void FrameView::setMediaType(const AtomicString& mediaType) 1078 void FrameView::setMediaType(const AtomicString& mediaType)
1080 { 1079 {
1081 ASSERT(m_frame->document()); 1080 ASSERT(m_frame->document());
1082 m_frame->document()->mediaQueryAffectingValueChanged(); 1081 m_frame->document()->mediaQueryAffectingValueChanged();
1083 m_mediaType = mediaType; 1082 m_mediaType = mediaType;
1084 } 1083 }
1085 1084
1086 AtomicString FrameView::mediaType() const 1085 AtomicString FrameView::mediaType() const
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 1838
1840 // scrollRectToVisible can call into setScrollPosition(), which resets m_mai ntainScrollPositionAnchor. 1839 // scrollRectToVisible can call into setScrollPosition(), which resets m_mai ntainScrollPositionAnchor.
1841 m_maintainScrollPositionAnchor = anchorNode; 1840 m_maintainScrollPositionAnchor = anchorNode;
1842 } 1841 }
1843 1842
1844 bool FrameView::updateWidgets() 1843 bool FrameView::updateWidgets()
1845 { 1844 {
1846 // This is always called from updateWidgetsTimerFired. 1845 // This is always called from updateWidgetsTimerFired.
1847 // m_updateWidgetsTimer should only be scheduled if we have widgets to updat e. 1846 // m_updateWidgetsTimer should only be scheduled if we have widgets to updat e.
1848 // Thus I believe we can stop checking isEmpty here, and just ASSERT isEmpty : 1847 // Thus I believe we can stop checking isEmpty here, and just ASSERT isEmpty :
1849 ASSERT(!m_widgetUpdateSet.isEmpty()); 1848 ASSERT(!m_partUpdateSet.isEmpty());
1850 if (m_nestedLayoutCount > 1 || m_widgetUpdateSet.isEmpty()) 1849 if (m_nestedLayoutCount > 1 || m_partUpdateSet.isEmpty())
1851 return true; 1850 return true;
1852 1851
1853 // Need to swap because script will run inside the below loop and invalidate the iterator. 1852 // Need to swap because script will run inside the below loop and invalidate the iterator.
1854 EmbeddedObjectSet objects; 1853 EmbeddedObjectSet objects;
1855 objects.swap(m_widgetUpdateSet); 1854 objects.swap(m_partUpdateSet);
1856 1855
1857 for (EmbeddedObjectSet::iterator it = objects.begin(); it != objects.end(); ++it) { 1856 for (EmbeddedObjectSet::iterator it = objects.begin(); it != objects.end(); ++it) {
1858 RenderEmbeddedObject& object = **it; 1857 RenderEmbeddedObject& object = **it;
1859 HTMLPlugInElement* element = toHTMLPlugInElement(object.node()); 1858 HTMLPlugInElement* element = toHTMLPlugInElement(object.node());
1860 1859
1861 // The object may have already been destroyed (thus node cleared), 1860 // The object may have already been destroyed (thus node cleared),
1862 // but FrameView holds a manual ref, so it won't have been deleted. 1861 // but FrameView holds a manual ref, so it won't have been deleted.
1863 if (!element) 1862 if (!element)
1864 continue; 1863 continue;
1865 1864
1866 // No need to update if it's already crashed or known to be missing. 1865 // No need to update if it's already crashed or known to be missing.
1867 if (object.showsUnavailablePluginIndicator()) 1866 if (object.showsUnavailablePluginIndicator())
1868 continue; 1867 continue;
1869 1868
1870 if (element->needsWidgetUpdate()) 1869 if (element->needsWidgetUpdate())
1871 element->updateWidget(); 1870 element->updateWidget();
1872 object.updateWidgetPosition(); 1871 object.updateWidgetPosition();
1873 1872
1874 // Prevent plugins from causing infinite updates of themselves. 1873 // Prevent plugins from causing infinite updates of themselves.
1875 // FIXME: Do we really need to prevent this? 1874 // FIXME: Do we really need to prevent this?
1876 m_widgetUpdateSet.remove(&object); 1875 m_partUpdateSet.remove(&object);
1877 } 1876 }
1878 1877
1879 return m_widgetUpdateSet.isEmpty(); 1878 return m_partUpdateSet.isEmpty();
1880 } 1879 }
1881 1880
1882 void FrameView::updateWidgetsTimerFired(Timer<FrameView>*) 1881 void FrameView::updateWidgetsTimerFired(Timer<FrameView>*)
1883 { 1882 {
1884 ASSERT(!isInPerformLayout()); 1883 ASSERT(!isInPerformLayout());
1885 RefPtr<FrameView> protect(this); 1884 RefPtr<FrameView> protect(this);
1886 m_updateWidgetsTimer.stop(); 1885 m_updateWidgetsTimer.stop();
1887 for (unsigned i = 0; i < maxUpdateWidgetsIterations; ++i) { 1886 for (unsigned i = 0; i < maxUpdateWidgetsIterations; ++i) {
1888 if (updateWidgets()) 1887 if (updateWidgets())
1889 return; 1888 return;
1890 } 1889 }
1891 } 1890 }
1892 1891
1893 void FrameView::flushAnyPendingPostLayoutTasks() 1892 void FrameView::flushAnyPendingPostLayoutTasks()
1894 { 1893 {
1895 ASSERT(!isInPerformLayout()); 1894 ASSERT(!isInPerformLayout());
1896 if (m_postLayoutTasksTimer.isActive()) 1895 if (m_postLayoutTasksTimer.isActive())
1897 performPostLayoutTasks(); 1896 performPostLayoutTasks();
1898 if (m_updateWidgetsTimer.isActive()) 1897 if (m_updateWidgetsTimer.isActive())
1899 updateWidgetsTimerFired(0); 1898 updateWidgetsTimerFired(0);
1900 } 1899 }
1901 1900
1902 void FrameView::scheduleUpdateWidgetsIfNecessary() 1901 void FrameView::scheduleUpdateWidgetsIfNecessary()
1903 { 1902 {
1904 ASSERT(!isInPerformLayout()); 1903 ASSERT(!isInPerformLayout());
1905 if (m_updateWidgetsTimer.isActive() || m_widgetUpdateSet.isEmpty()) 1904 if (m_updateWidgetsTimer.isActive() || m_partUpdateSet.isEmpty())
1906 return; 1905 return;
1907 m_updateWidgetsTimer.startOneShot(0, FROM_HERE); 1906 m_updateWidgetsTimer.startOneShot(0, FROM_HERE);
1908 } 1907 }
1909 1908
1910 void FrameView::performPostLayoutTasks() 1909 void FrameView::performPostLayoutTasks()
1911 { 1910 {
1912 // FIXME: We can reach here, even when the page is not active! 1911 // FIXME: We can reach here, even when the page is not active!
1913 // http/tests/inspector/elements/html-link-import.html and many other 1912 // http/tests/inspector/elements/html-link-import.html and many other
1914 // tests hit that case. 1913 // tests hit that case.
1915 // We should ASSERT(isActive()); or at least return early if we can! 1914 // We should ASSERT(isActive()); or at least return early if we can!
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 IntSize visibleSize = expandedIntSize(visibleContentSizeF); 3035 IntSize visibleSize = expandedIntSize(visibleContentSizeF);
3037 3036
3038 IntPoint maximumOffset( 3037 IntPoint maximumOffset(
3039 contentsWidth() - visibleSize.width() - scrollOrigin().x(), 3038 contentsWidth() - visibleSize.width() - scrollOrigin().x(),
3040 contentsHeight() - visibleSize.height() - scrollOrigin().y()); 3039 contentsHeight() - visibleSize.height() - scrollOrigin().y());
3041 maximumOffset.clampNegativeToZero(); 3040 maximumOffset.clampNegativeToZero();
3042 return maximumOffset; 3041 return maximumOffset;
3043 } 3042 }
3044 3043
3045 } // namespace blink 3044 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698