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

Side by Side Diff: webkit/glue/webframe_impl.cc

Issue 255042: Reverting 27711. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | « webkit/glue/mimetype_unittest.cc ('k') | webkit/glue/webpreferences.cc » ('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 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) { 368 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) {
369 return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : NULL; 369 return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : NULL;
370 } 370 }
371 371
372 // WebFrame ------------------------------------------------------------------- 372 // WebFrame -------------------------------------------------------------------
373 373
374 // static 374 // static
375 WebFrame* WebFrame::frameForEnteredContext() { 375 WebFrame* WebFrame::frameForEnteredContext() {
376 Frame* frame = 376 Frame* frame =
377 WebCore::ScriptController::retrieveFrameForEnteredContext(); 377 WebCore::ScriptController::retrieveFrameForEnteredContext();
378 if (frame) 378 return WebFrameImpl::FromFrame(frame);
379 return WebFrameImpl::FromFrame(frame);
380 else
381 return NULL;
382 } 379 }
383 380
384 // static 381 // static
385 WebFrame* WebFrame::frameForCurrentContext() { 382 WebFrame* WebFrame::frameForCurrentContext() {
386 Frame* frame = 383 Frame* frame =
387 WebCore::ScriptController::retrieveFrameForCurrentContext(); 384 WebCore::ScriptController::retrieveFrameForCurrentContext();
388 if (frame) 385 return WebFrameImpl::FromFrame(frame);
389 return WebFrameImpl::FromFrame(frame);
390 else
391 return NULL;
392 } 386 }
393 387
394 WebString WebFrameImpl::name() const { 388 WebString WebFrameImpl::name() const {
395 return webkit_glue::StringToWebString(frame_->tree()->name()); 389 return webkit_glue::StringToWebString(frame_->tree()->name());
396 } 390 }
397 391
398 WebURL WebFrameImpl::url() const { 392 WebURL WebFrameImpl::url() const {
399 const WebDataSource* ds = dataSource(); 393 const WebDataSource* ds = dataSource();
400 if (!ds) 394 if (!ds)
401 return WebURL(); 395 return WebURL();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 bool WebFrameImpl::hasVisibleContent() const { 455 bool WebFrameImpl::hasVisibleContent() const {
462 return frame()->view()->visibleWidth() > 0 && 456 return frame()->view()->visibleWidth() > 0 &&
463 frame()->view()->visibleHeight() > 0; 457 frame()->view()->visibleHeight() > 0;
464 } 458 }
465 459
466 WebView* WebFrameImpl::view() const { 460 WebView* WebFrameImpl::view() const {
467 return GetWebViewImpl(); 461 return GetWebViewImpl();
468 } 462 }
469 463
470 WebFrame* WebFrameImpl::opener() const { 464 WebFrame* WebFrameImpl::opener() const {
471 if (frame_) { 465 Frame* opener = NULL;
472 Frame* opener = frame_->loader()->opener(); 466 if (frame_)
473 if (opener) 467 opener = frame_->loader()->opener();
474 return FromFrame(opener); 468 return FromFrame(opener);
475 }
476 return NULL;
477 } 469 }
478 470
479 WebFrame* WebFrameImpl::parent() const { 471 WebFrame* WebFrameImpl::parent() const {
480 if (frame_) { 472 Frame *parent = NULL;
481 Frame *parent = frame_->tree()->parent(); 473 if (frame_)
482 if (parent) 474 parent = frame_->tree()->parent();
483 return FromFrame(parent); 475 return FromFrame(parent);
484 }
485 return NULL;
486 } 476 }
487 477
488 WebFrame* WebFrameImpl::top() const { 478 WebFrame* WebFrameImpl::top() const {
489 if (frame_) 479 if (frame_)
490 return FromFrame(frame_->tree()->top()); 480 return FromFrame(frame_->tree()->top());
491 481
492 return NULL; 482 return NULL;
493 } 483 }
494 484
495 WebFrame* WebFrameImpl::firstChild() const { 485 WebFrame* WebFrameImpl::firstChild() const {
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 RefPtr<WebCore::FrameView> view; 1626 RefPtr<WebCore::FrameView> view;
1637 if (is_main_frame) { 1627 if (is_main_frame) {
1638 IntSize size = webkit_glue::WebSizeToIntSize(web_view->size()); 1628 IntSize size = webkit_glue::WebSizeToIntSize(web_view->size());
1639 view = FrameView::create(frame_, size); 1629 view = FrameView::create(frame_, size);
1640 } else { 1630 } else {
1641 view = FrameView::create(frame_); 1631 view = FrameView::create(frame_);
1642 } 1632 }
1643 1633
1644 frame_->setView(view); 1634 frame_->setView(view);
1645 1635
1646 if (web_view->GetIsTransparent()) 1636 if (web_view->isTransparent())
1647 view->setTransparent(true); 1637 view->setTransparent(true);
1648 1638
1649 // TODO(darin): The Mac code has a comment about this possibly being 1639 // TODO(darin): The Mac code has a comment about this possibly being
1650 // unnecessary. See installInFrame in WebCoreFrameBridge.mm 1640 // unnecessary. See installInFrame in WebCoreFrameBridge.mm
1651 if (frame_->ownerRenderer()) 1641 if (frame_->ownerRenderer())
1652 frame_->ownerRenderer()->setWidget(view.get()); 1642 frame_->ownerRenderer()->setWidget(view.get());
1653 1643
1654 if (HTMLFrameOwnerElement* owner = frame_->ownerElement()) { 1644 if (HTMLFrameOwnerElement* owner = frame_->ownerElement()) {
1655 view->setCanHaveScrollbars( 1645 view->setCanHaveScrollbars(
1656 owner->scrollingMode() != WebCore::ScrollbarAlwaysOff); 1646 owner->scrollingMode() != WebCore::ScrollbarAlwaysOff);
1657 } 1647 }
1658 1648
1659 if (is_main_frame) 1649 if (is_main_frame)
1660 view->setParentVisible(true); 1650 view->setParentVisible(true);
1661 } 1651 }
1662 1652
1663 // static 1653 // static
1664 WebFrameImpl* WebFrameImpl::FromFrame(WebCore::Frame* frame) { 1654 WebFrameImpl* WebFrameImpl::FromFrame(WebCore::Frame* frame) {
1655 if (!frame)
1656 return NULL;
1665 return static_cast<WebFrameLoaderClient*>( 1657 return static_cast<WebFrameLoaderClient*>(
1666 frame->loader()->client())->webframe(); 1658 frame->loader()->client())->webframe();
1667 } 1659 }
1668 1660
1669 WebViewImpl* WebFrameImpl::GetWebViewImpl() const { 1661 WebViewImpl* WebFrameImpl::GetWebViewImpl() const {
1670 if (!frame_ || !frame_->page()) 1662 if (!frame_ || !frame_->page())
1671 return NULL; 1663 return NULL;
1672 1664
1673 // There are cases where a Frame may outlive its associated Page. Get the 1665 // There are cases where a Frame may outlive its associated Page. Get the
1674 // WebViewImpl by accessing it indirectly through the Frame's Page so that we 1666 // WebViewImpl by accessing it indirectly through the Frame's Page so that we
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 1812
1821 void WebFrameImpl::SetMarkerActive(WebCore::Range* range, bool active) { 1813 void WebFrameImpl::SetMarkerActive(WebCore::Range* range, bool active) {
1822 if (!range) 1814 if (!range)
1823 return; 1815 return;
1824 1816
1825 frame()->document()->setMarkersActive(range, active); 1817 frame()->document()->setMarkersActive(range, active);
1826 } 1818 }
1827 1819
1828 int WebFrameImpl::OrdinalOfFirstMatchForFrame(WebFrameImpl* frame) const { 1820 int WebFrameImpl::OrdinalOfFirstMatchForFrame(WebFrameImpl* frame) const {
1829 int ordinal = 0; 1821 int ordinal = 0;
1830 WebViewImpl* web_view = GetWebViewImpl(); 1822 WebFrameImpl* main_frame_impl = GetWebViewImpl()->main_frame();
1831 WebFrameImpl* const main_frame_impl = GetWebViewImpl()->main_frame();
1832 // Iterate from the main frame up to (but not including) |frame| and 1823 // Iterate from the main frame up to (but not including) |frame| and
1833 // add up the number of matches found so far. 1824 // add up the number of matches found so far.
1834 for (WebFrameImpl* it = main_frame_impl; 1825 for (WebFrameImpl* it = main_frame_impl;
1835 it != frame; 1826 it != frame;
1836 it = static_cast<WebFrameImpl*>( 1827 it = static_cast<WebFrameImpl*>(it->traverseNext(true))) {
1837 web_view->GetNextFrameAfter(it, true))) {
1838 if (it->last_match_count_ > 0) 1828 if (it->last_match_count_ > 0)
1839 ordinal += it->last_match_count_; 1829 ordinal += it->last_match_count_;
1840 } 1830 }
1841 1831
1842 return ordinal; 1832 return ordinal;
1843 } 1833 }
1844 1834
1845 bool WebFrameImpl::ShouldScopeMatches(const string16& search_text) { 1835 bool WebFrameImpl::ShouldScopeMatches(const string16& search_text) {
1846 // Don't scope if we can't find a frame or if the frame is not visible. 1836 // Don't scope if we can't find a frame or if the frame is not visible.
1847 // The user may have closed the tab/application, so abort. 1837 // The user may have closed the tab/application, so abort.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 1904
1915 SecurityOrigin* security_origin = frame_->document()->securityOrigin(); 1905 SecurityOrigin* security_origin = frame_->document()->securityOrigin();
1916 1906
1917 if (!frame_->loader()->isScheduledLocationChangePending()) { 1907 if (!frame_->loader()->isScheduledLocationChangePending()) {
1918 frame_->loader()->stopAllLoaders(); 1908 frame_->loader()->stopAllLoaders();
1919 frame_->loader()->begin(frame_->loader()->url(), true, security_origin); 1909 frame_->loader()->begin(frame_->loader()->url(), true, security_origin);
1920 frame_->loader()->write(script_result); 1910 frame_->loader()->write(script_result);
1921 frame_->loader()->end(); 1911 frame_->loader()->end();
1922 } 1912 }
1923 } 1913 }
OLDNEW
« no previous file with comments | « webkit/glue/mimetype_unittest.cc ('k') | webkit/glue/webpreferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698