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

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

Issue 33353003: Have Frame::tree() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 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
« no previous file with comments | « Source/core/fetch/ResourceFetcher.cpp ('k') | Source/core/frame/Frame.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) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 int DOMWindow::innerHeight() const 1006 int DOMWindow::innerHeight() const
1007 { 1007 {
1008 if (!m_frame) 1008 if (!m_frame)
1009 return 0; 1009 return 0;
1010 1010
1011 FrameView* view = m_frame->view(); 1011 FrameView* view = m_frame->view();
1012 if (!view) 1012 if (!view)
1013 return 0; 1013 return 0;
1014 1014
1015 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. 1015 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer.
1016 if (Frame* parent = m_frame->tree()->parent()) 1016 if (Frame* parent = m_frame->tree().parent())
1017 parent->document()->updateLayoutIgnorePendingStylesheets(); 1017 parent->document()->updateLayoutIgnorePendingStylesheets();
1018 1018
1019 return view->mapFromLayoutToCSSUnits(static_cast<int>(view->visibleContentRe ct(ScrollableArea::IncludeScrollbars).height())); 1019 return view->mapFromLayoutToCSSUnits(static_cast<int>(view->visibleContentRe ct(ScrollableArea::IncludeScrollbars).height()));
1020 } 1020 }
1021 1021
1022 int DOMWindow::innerWidth() const 1022 int DOMWindow::innerWidth() const
1023 { 1023 {
1024 if (!m_frame) 1024 if (!m_frame)
1025 return 0; 1025 return 0;
1026 1026
1027 FrameView* view = m_frame->view(); 1027 FrameView* view = m_frame->view();
1028 if (!view) 1028 if (!view)
1029 return 0; 1029 return 0;
1030 1030
1031 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. 1031 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer.
1032 if (Frame* parent = m_frame->tree()->parent()) 1032 if (Frame* parent = m_frame->tree().parent())
1033 parent->document()->updateLayoutIgnorePendingStylesheets(); 1033 parent->document()->updateLayoutIgnorePendingStylesheets();
1034 1034
1035 return view->mapFromLayoutToCSSUnits(static_cast<int>(view->visibleContentRe ct(ScrollableArea::IncludeScrollbars).width())); 1035 return view->mapFromLayoutToCSSUnits(static_cast<int>(view->visibleContentRe ct(ScrollableArea::IncludeScrollbars).width()));
1036 } 1036 }
1037 1037
1038 int DOMWindow::screenX() const 1038 int DOMWindow::screenX() const
1039 { 1039 {
1040 if (!m_frame) 1040 if (!m_frame)
1041 return 0; 1041 return 0;
1042 1042
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 bool DOMWindow::closed() const 1094 bool DOMWindow::closed() const
1095 { 1095 {
1096 return !m_frame; 1096 return !m_frame;
1097 } 1097 }
1098 1098
1099 unsigned DOMWindow::length() const 1099 unsigned DOMWindow::length() const
1100 { 1100 {
1101 if (!isCurrentlyDisplayedInFrame()) 1101 if (!isCurrentlyDisplayedInFrame())
1102 return 0; 1102 return 0;
1103 1103
1104 return m_frame->tree()->scopedChildCount(); 1104 return m_frame->tree().scopedChildCount();
1105 } 1105 }
1106 1106
1107 String DOMWindow::name() const 1107 String DOMWindow::name() const
1108 { 1108 {
1109 if (!m_frame) 1109 if (!m_frame)
1110 return String(); 1110 return String();
1111 1111
1112 return m_frame->tree()->name(); 1112 return m_frame->tree().name();
1113 } 1113 }
1114 1114
1115 void DOMWindow::setName(const String& string) 1115 void DOMWindow::setName(const String& string)
1116 { 1116 {
1117 if (!m_frame) 1117 if (!m_frame)
1118 return; 1118 return;
1119 1119
1120 m_frame->tree()->setName(string); 1120 m_frame->tree().setName(string);
1121 m_frame->loader()->client()->didChangeName(string); 1121 m_frame->loader()->client()->didChangeName(string);
1122 } 1122 }
1123 1123
1124 void DOMWindow::setStatus(const String& string) 1124 void DOMWindow::setStatus(const String& string)
1125 { 1125 {
1126 m_status = string; 1126 m_status = string;
1127 1127
1128 if (!m_frame) 1128 if (!m_frame)
1129 return; 1129 return;
1130 1130
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 return 0; 1169 return 0;
1170 1170
1171 return opener->domWindow(); 1171 return opener->domWindow();
1172 } 1172 }
1173 1173
1174 DOMWindow* DOMWindow::parent() const 1174 DOMWindow* DOMWindow::parent() const
1175 { 1175 {
1176 if (!m_frame) 1176 if (!m_frame)
1177 return 0; 1177 return 0;
1178 1178
1179 Frame* parent = m_frame->tree()->parent(); 1179 Frame* parent = m_frame->tree().parent();
1180 if (parent) 1180 if (parent)
1181 return parent->domWindow(); 1181 return parent->domWindow();
1182 1182
1183 return m_frame->domWindow(); 1183 return m_frame->domWindow();
1184 } 1184 }
1185 1185
1186 DOMWindow* DOMWindow::top() const 1186 DOMWindow* DOMWindow::top() const
1187 { 1187 {
1188 if (!m_frame) 1188 if (!m_frame)
1189 return 0; 1189 return 0;
1190 1190
1191 Page* page = m_frame->page(); 1191 Page* page = m_frame->page();
1192 if (!page) 1192 if (!page)
1193 return 0; 1193 return 0;
1194 1194
1195 return m_frame->tree()->top()->domWindow(); 1195 return m_frame->tree().top()->domWindow();
1196 } 1196 }
1197 1197
1198 Document* DOMWindow::document() const 1198 Document* DOMWindow::document() const
1199 { 1199 {
1200 return m_document.get(); 1200 return m_document.get();
1201 } 1201 }
1202 1202
1203 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const 1203 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const
1204 { 1204 {
1205 if (!isCurrentlyDisplayedInFrame()) 1205 if (!isCurrentlyDisplayedInFrame())
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 Document* activeDocument = activeWindow->document(); 1676 Document* activeDocument = activeWindow->document();
1677 if (!activeDocument) 1677 if (!activeDocument)
1678 return 0; 1678 return 0;
1679 Frame* firstFrame = firstWindow->frame(); 1679 Frame* firstFrame = firstWindow->frame();
1680 if (!firstFrame) 1680 if (!firstFrame)
1681 return 0; 1681 return 0;
1682 1682
1683 if (!firstWindow->allowPopUp()) { 1683 if (!firstWindow->allowPopUp()) {
1684 // Because FrameTree::find() returns true for empty strings, we must che ck for empty frame names. 1684 // Because FrameTree::find() returns true for empty strings, we must che ck for empty frame names.
1685 // Otherwise, illegitimate window.open() calls with no name will pass ri ght through the popup blocker. 1685 // Otherwise, illegitimate window.open() calls with no name will pass ri ght through the popup blocker.
1686 if (frameName.isEmpty() || !m_frame->tree()->find(frameName)) 1686 if (frameName.isEmpty() || !m_frame->tree().find(frameName))
1687 return 0; 1687 return 0;
1688 } 1688 }
1689 1689
1690 // Get the target frame for the special cases of _top and _parent. 1690 // Get the target frame for the special cases of _top and _parent.
1691 // In those cases, we schedule a location change right now and return early. 1691 // In those cases, we schedule a location change right now and return early.
1692 Frame* targetFrame = 0; 1692 Frame* targetFrame = 0;
1693 if (frameName == "_top") 1693 if (frameName == "_top")
1694 targetFrame = m_frame->tree()->top(); 1694 targetFrame = m_frame->tree().top();
1695 else if (frameName == "_parent") { 1695 else if (frameName == "_parent") {
1696 if (Frame* parent = m_frame->tree()->parent()) 1696 if (Frame* parent = m_frame->tree().parent())
1697 targetFrame = parent; 1697 targetFrame = parent;
1698 else 1698 else
1699 targetFrame = m_frame; 1699 targetFrame = m_frame;
1700 } 1700 }
1701 if (targetFrame) { 1701 if (targetFrame) {
1702 if (!activeDocument->canNavigate(targetFrame)) 1702 if (!activeDocument->canNavigate(targetFrame))
1703 return 0; 1703 return 0;
1704 1704
1705 KURL completedURL = firstFrame->document()->completeURL(urlString); 1705 KURL completedURL = firstFrame->document()->completeURL(urlString);
1706 1706
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 UserGestureIndicatorDisabler disabler; 1748 UserGestureIndicatorDisabler disabler;
1749 dialogFrame->page()->chrome().runModal(); 1749 dialogFrame->page()->chrome().runModal();
1750 } 1750 }
1751 1751
1752 DOMWindow* DOMWindow::anonymousIndexedGetter(uint32_t index) 1752 DOMWindow* DOMWindow::anonymousIndexedGetter(uint32_t index)
1753 { 1753 {
1754 Frame* frame = this->frame(); 1754 Frame* frame = this->frame();
1755 if (!frame) 1755 if (!frame)
1756 return 0; 1756 return 0;
1757 1757
1758 Frame* child = frame->tree()->scopedChild(index); 1758 Frame* child = frame->tree().scopedChild(index);
1759 if (child) 1759 if (child)
1760 return child->domWindow(); 1760 return child->domWindow();
1761 1761
1762 return 0; 1762 return 0;
1763 } 1763 }
1764 1764
1765 DOMWindowLifecycleNotifier* DOMWindow::lifecycleNotifier() 1765 DOMWindowLifecycleNotifier* DOMWindow::lifecycleNotifier()
1766 { 1766 {
1767 return static_cast<DOMWindowLifecycleNotifier*>(LifecycleContext::lifecycleN otifier()); 1767 return static_cast<DOMWindowLifecycleNotifier*>(LifecycleContext::lifecycleN otifier());
1768 } 1768 }
1769 1769
1770 PassOwnPtr<LifecycleNotifier> DOMWindow::createLifecycleNotifier() 1770 PassOwnPtr<LifecycleNotifier> DOMWindow::createLifecycleNotifier()
1771 { 1771 {
1772 return DOMWindowLifecycleNotifier::create(this); 1772 return DOMWindowLifecycleNotifier::create(this);
1773 } 1773 }
1774 1774
1775 1775
1776 } // namespace WebCore 1776 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceFetcher.cpp ('k') | Source/core/frame/Frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698