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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 348833005: [DO NOT COMMIT] Random hacks to unblock work on replication. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More random hacks, including also dcheng's https://codereview.chromium.org/346403002 Created 6 years, 5 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/web/WebViewImpl.h ('k') | Source/wtf/Assertions.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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/editing/FrameSelection.h" 42 #include "core/editing/FrameSelection.h"
43 #include "core/editing/InputMethodController.h" 43 #include "core/editing/InputMethodController.h"
44 #include "core/editing/TextIterator.h" 44 #include "core/editing/TextIterator.h"
45 #include "core/events/KeyboardEvent.h" 45 #include "core/events/KeyboardEvent.h"
46 #include "core/events/WheelEvent.h" 46 #include "core/events/WheelEvent.h"
47 #include "core/frame/EventHandlerRegistry.h" 47 #include "core/frame/EventHandlerRegistry.h"
48 #include "core/frame/FrameHost.h" 48 #include "core/frame/FrameHost.h"
49 #include "core/frame/FrameView.h" 49 #include "core/frame/FrameView.h"
50 #include "core/frame/LocalFrame.h" 50 #include "core/frame/LocalFrame.h"
51 #include "core/frame/PinchViewport.h" 51 #include "core/frame/PinchViewport.h"
52 #include "core/frame/RemoteFrame.h"
52 #include "core/frame/Settings.h" 53 #include "core/frame/Settings.h"
53 #include "core/frame/SmartClip.h" 54 #include "core/frame/SmartClip.h"
54 #include "core/html/HTMLInputElement.h" 55 #include "core/html/HTMLInputElement.h"
55 #include "core/html/HTMLMediaElement.h" 56 #include "core/html/HTMLMediaElement.h"
56 #include "core/html/HTMLPlugInElement.h" 57 #include "core/html/HTMLPlugInElement.h"
57 #include "core/html/HTMLTextAreaElement.h" 58 #include "core/html/HTMLTextAreaElement.h"
58 #include "core/html/ime/InputMethodContext.h" 59 #include "core/html/ime/InputMethodContext.h"
59 #include "core/inspector/InspectorController.h" 60 #include "core/inspector/InspectorController.h"
60 #include "core/loader/DocumentLoader.h" 61 #include "core/loader/DocumentLoader.h"
61 #include "core/loader/FrameLoader.h" 62 #include "core/loader/FrameLoader.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 { 310 {
310 ASSERT(pageLoadDeferrerStack().size()); 311 ASSERT(pageLoadDeferrerStack().size());
311 312
312 delete pageLoadDeferrerStack().last(); 313 delete pageLoadDeferrerStack().last();
313 pageLoadDeferrerStack().removeLast(); 314 pageLoadDeferrerStack().removeLast();
314 } 315 }
315 316
316 void WebViewImpl::setMainFrame(WebFrame* frame) 317 void WebViewImpl::setMainFrame(WebFrame* frame)
317 { 318 {
318 if (frame->isWebLocalFrame()) 319 if (frame->isWebLocalFrame())
319 toWebLocalFrameImpl(frame)->initializeAsMainFrame(page()); 320 toWebLocalFrameImpl(frame)->initializeWebCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom);
320 else 321 else {
321 toWebRemoteFrameImpl(frame)->initializeAsMainFrame(page()); 322 m_baseBackgroundColor = Color::darkGray;
323 toWebRemoteFrameImpl(frame)->initializeWebCoreFrame(&page()->frameHost() , 0, nullAtom);
324 }
322 } 325 }
323 326
324 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) 327 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient)
325 { 328 {
326 m_autofillClient = autofillClient; 329 m_autofillClient = autofillClient;
327 } 330 }
328 331
329 void WebViewImpl::setDevToolsAgentClient(WebDevToolsAgentClient* devToolsClient) 332 void WebViewImpl::setDevToolsAgentClient(WebDevToolsAgentClient* devToolsClient)
330 { 333 {
331 if (devToolsClient) 334 if (devToolsClient)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 WebViewImpl::~WebViewImpl() 442 WebViewImpl::~WebViewImpl()
440 { 443 {
441 ASSERT(!m_page); 444 ASSERT(!m_page);
442 } 445 }
443 446
444 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() 447 WebLocalFrameImpl* WebViewImpl::mainFrameImpl()
445 { 448 {
446 return m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0; 449 return m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0;
447 } 450 }
448 451
452 WebLocalFrameImpl* WebViewImpl::localRootFrame()
453 {
454 for (WebCore::Frame* frame = page()->mainFrame()->tree().top(); frame; frame = frame->tree().traverseNext()) {
455 if (frame->isLocalRoot()) {
456 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame));
457 }
458 }
459 return 0;
460 }
461
449 bool WebViewImpl::tabKeyCyclesThroughElements() const 462 bool WebViewImpl::tabKeyCyclesThroughElements() const
450 { 463 {
451 ASSERT(m_page); 464 ASSERT(m_page);
452 return m_page->tabKeyCyclesThroughElements(); 465 return m_page->tabKeyCyclesThroughElements();
453 } 466 }
454 467
455 void WebViewImpl::setTabKeyCyclesThroughElements(bool value) 468 void WebViewImpl::setTabKeyCyclesThroughElements(bool value)
456 { 469 {
457 if (m_page) 470 if (m_page)
458 m_page->setTabKeyCyclesThroughElements(value); 471 m_page->setTabKeyCyclesThroughElements(value);
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 return false; 1036 return false;
1024 1037
1025 if (!suppress && !handler.keyEvent(evt)) 1038 if (!suppress && !handler.keyEvent(evt))
1026 return keyEventDefault(event); 1039 return keyEventDefault(event);
1027 1040
1028 return true; 1041 return true;
1029 } 1042 }
1030 1043
1031 WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, bool ignoreClipping ) 1044 WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, bool ignoreClipping )
1032 { 1045 {
1033 if (!mainFrameImpl()) 1046 if (!mainFrameImpl()) {
1047 printf("WVI::computeBlockBounds: null mainFrameImpl\n");
1034 return WebRect(); 1048 return WebRect();
1049 }
1035 1050
1036 // Use the rect-based hit test to find the node. 1051 // Use the rect-based hit test to find the node.
1037 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec t.x, rect.y)); 1052 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec t.x, rect.y));
1038 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); 1053 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0);
1039 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul tAtPoint(point, hitType, IntSize(rect.width, rect.height)); 1054 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul tAtPoint(point, hitType, IntSize(rect.width, rect.height));
1040 1055
1041 Node* node = result.innerNonSharedNode(); 1056 Node* node = result.innerNonSharedNode();
1042 if (!node) 1057 if (!node)
1043 return WebRect(); 1058 return WebRect();
1044 1059
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 void WebViewImpl::resizePinchViewport(const WebSize& newSize) 1589 void WebViewImpl::resizePinchViewport(const WebSize& newSize)
1575 { 1590 {
1576 if (!pinchVirtualViewportEnabled()) 1591 if (!pinchVirtualViewportEnabled())
1577 return; 1592 return;
1578 1593
1579 page()->frameHost().pinchViewport().setSize(newSize); 1594 page()->frameHost().pinchViewport().setSize(newSize);
1580 } 1595 }
1581 1596
1582 void WebViewImpl::resize(const WebSize& newSize) 1597 void WebViewImpl::resize(const WebSize& newSize)
1583 { 1598 {
1584 if (m_shouldAutoResize || m_size == newSize) 1599 printf("WebViewImpl::resize: %dx%d\n", newSize.width, newSize.height);
1600 if (m_shouldAutoResize || m_size == newSize) {
1601 printf("WebViewImpl::resize: auto or same\n");
1585 return; 1602 return;
1603 }
1586 1604
1587 FrameView* view = mainFrameImpl()->frameView(); 1605 /*
1588 if (!view) 1606 if (!mainFrameImpl()) {
1607 printf("WCI::resize: null mainFrameImpl\n");
1589 return; 1608 return;
1609 }
1610 */
1611 WebLocalFrameImpl* mainFrameImpl = localRootFrame();
1612
1613 FrameView* view = mainFrameImpl->frameView();
1614 if (!view) {
1615 printf("WebViewImpl::resize: no view\n");
1616 return;
1617 }
1590 1618
1591 WebSize oldSize = m_size; 1619 WebSize oldSize = m_size;
1592 float oldPageScaleFactor = pageScaleFactor(); 1620 float oldPageScaleFactor = pageScaleFactor();
1593 int oldContentsWidth = contentsSize().width(); 1621 int oldContentsWidth = contentsSize().width();
1594 1622
1595 m_size = newSize; 1623 m_size = newSize;
1596 1624
1597 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges() 1625 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges()
1598 && oldSize.width && oldContentsWidth && newSize.width != oldSize.width & & !m_fullscreenController->isFullscreen(); 1626 && oldSize.width && oldContentsWidth && newSize.width != oldSize.width & & !m_fullscreenController->isFullscreen();
1599 1627
1600 ViewportAnchor viewportAnchor(&mainFrameImpl()->frame()->eventHandler()); 1628 ViewportAnchor viewportAnchor(&mainFrameImpl->frame()->eventHandler());
1601 if (shouldAnchorAndRescaleViewport) { 1629 if (shouldAnchorAndRescaleViewport) {
1602 viewportAnchor.setAnchor(view->visibleContentRect(), 1630 viewportAnchor.setAnchor(view->visibleContentRect(),
1603 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); 1631 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord));
1604 } 1632 }
1605 1633
1606 { 1634 {
1607 // Avoids unnecessary invalidations while various bits of state in FastT extAutosizer are updated. 1635 // Avoids unnecessary invalidations while various bits of state in FastT extAutosizer are updated.
1608 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); 1636 //FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page());
1609 1637
1610 m_pageScaleConstraintsSet.didChangeViewSize(m_size); 1638 m_pageScaleConstraintsSet.didChangeViewSize(m_size);
1611 1639
1612 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document( )->viewportDescription()); 1640 updatePageDefinedViewportConstraints(mainFrameImpl->frame()->document()- >viewportDescription());
1613 updateMainFrameLayoutSize(); 1641 updateMainFrameLayoutSize();
1614 1642
1615 // If the virtual viewport pinch mode is enabled, the main frame will be resized 1643 // If the virtual viewport pinch mode is enabled, the main frame will be resized
1616 // after layout so it can be sized to the contentsSize. 1644 // after layout so it can be sized to the contentsSize.
1617 if (!pinchVirtualViewportEnabled() && mainFrameImpl()->frameView()) 1645 if (!pinchVirtualViewportEnabled() && mainFrameImpl->frameView())
1618 mainFrameImpl()->frameView()->resize(m_size); 1646 mainFrameImpl->frameView()->resize(m_size);
1619 1647
1620 if (pinchVirtualViewportEnabled()) 1648 if (pinchVirtualViewportEnabled())
1621 page()->frameHost().pinchViewport().setSize(m_size); 1649 page()->frameHost().pinchViewport().setSize(m_size);
1622 1650
1623 // When device emulation is enabled, device size values may change - the y are 1651 // When device emulation is enabled, device size values may change - the y are
1624 // usually set equal to the view size. These values are not considered v iewport-dependent 1652 // usually set equal to the view size. These values are not considered v iewport-dependent
1625 // (see MediaQueryExp::isViewportDependent), since they are only viewpor t-dependent in emulation mode, 1653 // (see MediaQueryExp::isViewportDependent), since they are only viewpor t-dependent in emulation mode,
1626 // and thus will not be invalidated in |FrameView::performPreLayoutTasks |. 1654 // and thus will not be invalidated in |FrameView::performPreLayoutTasks |.
1627 // Therefore we should force explicit media queries invalidation here. 1655 // Therefore we should force explicit media queries invalidation here.
1628 if (page()->inspectorController().deviceEmulationEnabled()) { 1656 if (page()->inspectorController().deviceEmulationEnabled()) {
1629 if (Document* document = mainFrameImpl()->frame()->document()) 1657 if (Document* document = mainFrameImpl->frame()->document())
1630 document->mediaQueryAffectingValueChanged(); 1658 document->mediaQueryAffectingValueChanged();
1631 } 1659 }
1632 } 1660 }
1633 1661
1634 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { 1662 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) {
1635 // Relayout immediately to recalculate the minimum scale limit. 1663 // Relayout immediately to recalculate the minimum scale limit.
1636 if (view->needsLayout()) 1664 if (view->needsLayout())
1637 view->layout(); 1665 view->layout();
1638 1666
1639 if (shouldAnchorAndRescaleViewport) { 1667 if (shouldAnchorAndRescaleViewport) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 return false; 2127 return false;
2100 *location = plainTextRange.start(); 2128 *location = plainTextRange.start();
2101 *length = plainTextRange.length(); 2129 *length = plainTextRange.length();
2102 return true; 2130 return true;
2103 } 2131 }
2104 2132
2105 WebTextInputInfo WebViewImpl::textInputInfo() 2133 WebTextInputInfo WebViewImpl::textInputInfo()
2106 { 2134 {
2107 WebTextInputInfo info; 2135 WebTextInputInfo info;
2108 2136
2109 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2137 Frame* focusedFrame = focusedWebCoreFrame();
2138 if (focusedFrame->isRemoteFrame())
2139 return info;
2140
2141 LocalFrame* focused = toLocalFrame(focusedFrame);
2110 if (!focused) 2142 if (!focused)
2111 return info; 2143 return info;
2112 2144
2113 FrameSelection& selection = focused->selection(); 2145 FrameSelection& selection = focused->selection();
2114 Node* node = selection.selection().rootEditableElement(); 2146 Node* node = selection.selection().rootEditableElement();
2115 if (!node) 2147 if (!node)
2116 return info; 2148 return info;
2117 2149
2118 info.inputMode = inputModeOfFocusedElement(); 2150 info.inputMode = inputModeOfFocusedElement();
2119 2151
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 if (isHTMLTextAreaElement(*element)) { 2257 if (isHTMLTextAreaElement(*element)) {
2226 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element); 2258 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element);
2227 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); 2259 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower();
2228 } 2260 }
2229 2261
2230 return WebString(); 2262 return WebString();
2231 } 2263 }
2232 2264
2233 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const 2265 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
2234 { 2266 {
2235 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); 2267 const Frame* local_frame = focusedWebCoreFrame();
2268 if (local_frame && local_frame->isRemoteFrame())
2269 return false;
2270
2271 const LocalFrame* frame = toLocalFrame(local_frame);
2236 if (!frame) 2272 if (!frame)
2237 return false; 2273 return false;
2238 FrameSelection& selection = frame->selection(); 2274 FrameSelection& selection = frame->selection();
2239 2275
2240 if (selection.isCaret()) { 2276 if (selection.isCaret()) {
2241 anchor = focus = selection.absoluteCaretBounds(); 2277 anchor = focus = selection.absoluteCaretBounds();
2242 } else { 2278 } else {
2243 RefPtrWillBeRawPtr<Range> selectedRange = selection.toNormalizedRange(); 2279 RefPtrWillBeRawPtr<Range> selectedRange = selection.toNormalizedRange();
2244 if (!selectedRange) 2280 if (!selectedRange)
2245 return false; 2281 return false;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 relativeToFrame = mainFrame(); 2550 relativeToFrame = mainFrame();
2515 Frame* frame = toWebLocalFrameImpl(relativeToFrame)->frame(); 2551 Frame* frame = toWebLocalFrameImpl(relativeToFrame)->frame();
2516 frame = frame->tree().find(name); 2552 frame = frame->tree().find(name);
2517 if (!frame || !frame->isLocalFrame()) 2553 if (!frame || !frame->isLocalFrame())
2518 return 0; 2554 return 0;
2519 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame)); 2555 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame));
2520 } 2556 }
2521 2557
2522 WebFrame* WebViewImpl::focusedFrame() 2558 WebFrame* WebViewImpl::focusedFrame()
2523 { 2559 {
2524 return WebLocalFrameImpl::fromFrame(toLocalFrame(focusedWebCoreFrame())); 2560 Frame* frame = focusedWebCoreFrame();
2561 if (frame->isRemoteFrame())
2562 return WebRemoteFrameImpl::fromFrame(toRemoteFrame(*frame));
2563 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame));
2525 } 2564 }
2526 2565
2527 void WebViewImpl::setFocusedFrame(WebFrame* frame) 2566 void WebViewImpl::setFocusedFrame(WebFrame* frame)
2528 { 2567 {
2529 if (!frame) { 2568 if (!frame) {
2530 // Clears the focused frame if any. 2569 // Clears the focused frame if any.
2531 Frame* focusedFrame = focusedWebCoreFrame(); 2570 Frame* focusedFrame = focusedWebCoreFrame();
2532 if (focusedFrame && focusedFrame->isLocalFrame()) 2571 if (focusedFrame && focusedFrame->isLocalFrame())
2533 toLocalFrame(focusedFrame)->selection().setFocused(false); 2572 toLocalFrame(focusedFrame)->selection().setFocused(false);
2534 return; 2573 return;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2862 configureAutoResizeMode(); 2901 configureAutoResizeMode();
2863 } 2902 }
2864 2903
2865 void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst raints) 2904 void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst raints)
2866 { 2905 {
2867 if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints()) 2906 if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints())
2868 return; 2907 return;
2869 2908
2870 m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints); 2909 m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints);
2871 2910
2872 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 2911 WebLocalFrameImpl* mainFrameImpl = localRootFrame();
2912 if (!mainFrameImpl || !mainFrameImpl->frameView()) {
2913 printf("WCI::setUserAgentPageScaleConstraints: %p\n", mainFrameImpl);
2873 return; 2914 return;
2915 }
2874 2916
2875 mainFrameImpl()->frameView()->setNeedsLayout(); 2917 mainFrameImpl->frameView()->setNeedsLayout();
2876 } 2918 }
2877 2919
2878 void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri de) 2920 void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri de)
2879 { 2921 {
2880 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr aints(); 2922 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr aints();
2881 constraints.initialScale = initialPageScaleFactorOverride; 2923 constraints.initialScale = initialPageScaleFactorOverride;
2882 2924
2883 if (constraints == m_pageScaleConstraintsSet.userAgentConstraints()) 2925 if (constraints == m_pageScaleConstraintsSet.userAgentConstraints())
2884 return; 2926 return;
2885 2927
(...skipping 17 matching lines...) Expand all
2903 constraints.maximumScale = m_pageScaleConstraintsSet.defaultConstraints( ).maximumScale; 2945 constraints.maximumScale = m_pageScaleConstraintsSet.defaultConstraints( ).maximumScale;
2904 } else { 2946 } else {
2905 constraints.minimumScale = -1; 2947 constraints.minimumScale = -1;
2906 constraints.maximumScale = -1; 2948 constraints.maximumScale = -1;
2907 } 2949 }
2908 setUserAgentPageScaleConstraints(constraints); 2950 setUserAgentPageScaleConstraints(constraints);
2909 } 2951 }
2910 2952
2911 void WebViewImpl::refreshPageScaleFactorAfterLayout() 2953 void WebViewImpl::refreshPageScaleFactorAfterLayout()
2912 { 2954 {
2913 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >isLocalFrame() || !page()->deprecatedLocalMainFrame()->view()) 2955 /*
2956 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >isLocalFrame() || !page()->deprecatedLocalMainFrame()->view()) {
2957 printf("WebViewImpl::refreshPageScaleFactorAfterLayout: returning due to framing\n");
2914 return; 2958 return;
2915 FrameView* view = page()->deprecatedLocalMainFrame()->view(); 2959 }
2960 */
2961 WebLocalFrameImpl* mainFrameImpl = localRootFrame();
2962 if (!mainFrameImpl->frameView()) {
2963 printf("WebViewImpl::refreshPageScaleFactorAfterLayout: returning no vie w\n");
2964 return;
2965 }
2966 FrameView* view = mainFrameImpl->frameView();
2916 2967
2917 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription()); 2968 updatePageDefinedViewportConstraints(mainFrameImpl->frame()->document()->vie wportDescription());
2918 m_pageScaleConstraintsSet.computeFinalConstraints(); 2969 m_pageScaleConstraintsSet.computeFinalConstraints();
2919 2970
2920 if (settings()->shrinksViewportContentToFit() && !m_fixedLayoutSizeLock) { 2971 if (settings()->shrinksViewportContentToFit() && !m_fixedLayoutSizeLock) {
2921 int verticalScrollbarWidth = 0; 2972 int verticalScrollbarWidth = 0;
2922 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlaySc rollbar()) 2973 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlaySc rollbar())
2923 verticalScrollbarWidth = view->verticalScrollbar()->width(); 2974 verticalScrollbarWidth = view->verticalScrollbar()->width();
2924 m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(contentsS ize(), verticalScrollbarWidth); 2975 m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(contentsS ize(), verticalScrollbarWidth);
2925 } 2976 }
2926 2977
2927 if (pinchVirtualViewportEnabled()) 2978 if (pinchVirtualViewportEnabled())
2928 mainFrameImpl()->frameView()->resize(m_pageScaleConstraintsSet.mainFrame Size(contentsSize())); 2979 mainFrameImpl->frameView()->resize(m_pageScaleConstraintsSet.mainFrameSi ze(contentsSize()));
2929 2980
2930 float newPageScaleFactor = pageScaleFactor(); 2981 float newPageScaleFactor = pageScaleFactor();
2931 if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.fina lConstraints().initialScale != -1) { 2982 if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.fina lConstraints().initialScale != -1) {
2932 newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initia lScale; 2983 newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initia lScale;
2933 m_pageScaleConstraintsSet.setNeedsReset(false); 2984 m_pageScaleConstraintsSet.setNeedsReset(false);
2934 } 2985 }
2935 setPageScaleFactor(newPageScaleFactor); 2986 setPageScaleFactor(newPageScaleFactor);
2936 2987
2937 updateLayerTreeViewport(); 2988 updateLayerTreeViewport();
2938 2989
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 updateMainFrameLayoutSize(); 3053 updateMainFrameLayoutSize();
3003 3054
3004 if (LocalFrame* frame = page()->deprecatedLocalMainFrame()) { 3055 if (LocalFrame* frame = page()->deprecatedLocalMainFrame()) {
3005 if (FastTextAutosizer* textAutosizer = frame->document()->fastTextAutosi zer()) 3056 if (FastTextAutosizer* textAutosizer = frame->document()->fastTextAutosi zer())
3006 textAutosizer->updatePageInfoInAllFrames(); 3057 textAutosizer->updatePageInfoInAllFrames();
3007 } 3058 }
3008 } 3059 }
3009 3060
3010 void WebViewImpl::updateMainFrameLayoutSize() 3061 void WebViewImpl::updateMainFrameLayoutSize()
3011 { 3062 {
3012 if (m_fixedLayoutSizeLock || m_shouldAutoResize || !mainFrameImpl()) 3063 WebLocalFrameImpl* mainFrameImpl = localRootFrame();
3064
3065 if (m_fixedLayoutSizeLock || m_shouldAutoResize || !mainFrameImpl) {
3066 printf("WCI::updateMainFrameLayoutSize: null mainFrameImpl\n");
3013 return; 3067 return;
3068 }
3014 3069
3015 RefPtr<FrameView> view = mainFrameImpl()->frameView(); 3070 RefPtr<FrameView> view = mainFrameImpl->frameView();
3016 if (!view) 3071 if (!view)
3017 return; 3072 return;
3018 3073
3019 WebSize layoutSize = m_size; 3074 WebSize layoutSize = m_size;
3020 3075
3021 if (settings()->viewportEnabled()) { 3076 if (settings()->viewportEnabled()) {
3022 layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedConstra ints().layoutSize); 3077 layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedConstra ints().layoutSize);
3023 3078
3024 bool textAutosizingEnabled = page()->settings().textAutosizingEnabled(); 3079 bool textAutosizingEnabled = page()->settings().textAutosizingEnabled();
3025 if (textAutosizingEnabled && layoutSize.width != view->layoutSize().widt h()) { 3080 if (textAutosizingEnabled && layoutSize.width != view->layoutSize().widt h()) {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 if (!(dropEffect & dragData.draggingSourceOperationMask())) 3403 if (!(dropEffect & dragData.draggingSourceOperationMask()))
3349 dropEffect = DragOperationNone; 3404 dropEffect = DragOperationNone;
3350 3405
3351 m_dragOperation = static_cast<WebDragOperation>(dropEffect); 3406 m_dragOperation = static_cast<WebDragOperation>(dropEffect);
3352 3407
3353 return m_dragOperation; 3408 return m_dragOperation;
3354 } 3409 }
3355 3410
3356 void WebViewImpl::sendResizeEventAndRepaint() 3411 void WebViewImpl::sendResizeEventAndRepaint()
3357 { 3412 {
3413 WebLocalFrameImpl* mainFrameImpl = localRootFrame();
3358 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent 3414 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent
3359 // as part of layout. Layout is also responsible for sending invalidations 3415 // as part of layout. Layout is also responsible for sending invalidations
3360 // to the embedder. This method and all callers may be wrong. -- eseidel. 3416 // to the embedder. This method and all callers may be wrong. -- eseidel.
3361 if (mainFrameImpl()->frameView()) { 3417 if (mainFrameImpl->frameView()) {
3362 // Enqueues the resize event. 3418 // Enqueues the resize event.
3363 mainFrameImpl()->frame()->document()->enqueueResizeEvent(); 3419 mainFrameImpl->frame()->document()->enqueueResizeEvent();
3364 } 3420 }
3365 3421
3366 if (m_client) { 3422 if (m_client) {
3367 if (isAcceleratedCompositingActive()) { 3423 if (isAcceleratedCompositingActive()) {
3368 updateLayerTreeViewport(); 3424 updateLayerTreeViewport();
3369 } else { 3425 } else {
3370 WebRect damagedRect(0, 0, m_size.width, m_size.height); 3426 WebRect damagedRect(0, 0, m_size.width, m_size.height);
3371 m_client->didInvalidateRect(damagedRect); 3427 m_client->didInvalidateRect(damagedRect);
3372 } 3428 }
3373 } 3429 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3605 m_pageScaleConstraintsSet.setNeedsReset(true); 3661 m_pageScaleConstraintsSet.setNeedsReset(true);
3606 3662
3607 // Make sure link highlight from previous page is cleared. 3663 // Make sure link highlight from previous page is cleared.
3608 m_linkHighlights.clear(); 3664 m_linkHighlights.clear();
3609 endActiveFlingAnimation(); 3665 endActiveFlingAnimation();
3610 m_userGestureObserved = false; 3666 m_userGestureObserved = false;
3611 } 3667 }
3612 3668
3613 void WebViewImpl::willInsertBody(WebLocalFrameImpl* webframe) 3669 void WebViewImpl::willInsertBody(WebLocalFrameImpl* webframe)
3614 { 3670 {
3615 if (webframe != mainFrameImpl()) 3671 /*
3672 if (webframe != mainFrameImpl()) {
3673 printf("WCI::willInsertBody: frame != mainFrameImpl\n");
3616 return; 3674 return;
3675 }
3617 3676
3618 if (!m_page->mainFrame()->isLocalFrame()) 3677 if (!m_page->mainFrame()->isLocalFrame()) {
3678 printf("WCI::willInsertBody: mainFrame not local\n");
3619 return; 3679 return;
3680 }
3681 */
3620 3682
3621 // If we get to the <body> tag and we have no pending stylesheet and import load, we 3683 // If we get to the <body> tag and we have no pending stylesheet and import load, we
3622 // can be fairly confident we'll have something sensible to paint soon and 3684 // can be fairly confident we'll have something sensible to paint soon and
3623 // can turn off deferred commits. 3685 // can turn off deferred commits.
3624 if (m_page->deprecatedLocalMainFrame()->document()->isRenderingReady()) 3686 if (webframe->frame()->document()->isRenderingReady())
3625 resumeTreeViewCommits(); 3687 resumeTreeViewCommits();
3626 } 3688 }
3627 3689
3628 void WebViewImpl::resumeTreeViewCommits() 3690 void WebViewImpl::resumeTreeViewCommits()
3629 { 3691 {
3630 if (m_layerTreeViewCommitsDeferred) { 3692 if (m_layerTreeViewCommitsDeferred) {
3631 if (m_layerTreeView) 3693 if (m_layerTreeView)
3632 m_layerTreeView->setDeferCommits(false); 3694 m_layerTreeView->setDeferCommits(false);
3633 m_layerTreeViewCommitsDeferred = false; 3695 m_layerTreeViewCommitsDeferred = false;
3634 } 3696 }
3635 } 3697 }
3636 3698
3637 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe) 3699 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe)
3638 { 3700 {
3639 if (!m_client || webframe != mainFrameImpl()) 3701 if (!m_client || !webframe->frame()->isLocalRoot())
3640 return; 3702 return;
3641 3703
3642 // If we finished a layout while in deferred commit mode, 3704 // If we finished a layout while in deferred commit mode,
3643 // that means it's time to start producing frames again so un-defer. 3705 // that means it's time to start producing frames again so un-defer.
3644 resumeTreeViewCommits(); 3706 resumeTreeViewCommits();
3645 3707
3646 if (m_shouldAutoResize && mainFrameImpl()->frame() && mainFrameImpl()->frame ()->view()) { 3708 if (m_shouldAutoResize && webframe->frame() && webframe->frame()->view()) {
3647 WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size() ; 3709 WebSize frameSize = webframe->frame()->view()->frameRect().size();
3648 if (frameSize != m_size) { 3710 if (frameSize != m_size) {
3649 m_size = frameSize; 3711 m_size = frameSize;
3650 3712
3651 page()->frameHost().pinchViewport().setSize(m_size); 3713 page()->frameHost().pinchViewport().setSize(m_size);
3652 m_pageScaleConstraintsSet.didChangeViewSize(m_size); 3714 m_pageScaleConstraintsSet.didChangeViewSize(m_size);
3653 3715
3654 m_client->didAutoResize(m_size); 3716 m_client->didAutoResize(m_size);
3655 sendResizeEventAndRepaint(); 3717 sendResizeEventAndRepaint();
3656 } 3718 }
3657 } 3719 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 m_client->didInvalidateRect(rect); 3915 m_client->didInvalidateRect(rect);
3854 } 3916 }
3855 3917
3856 WebCore::GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const 3918 WebCore::GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const
3857 { 3919 {
3858 return m_graphicsLayerFactory.get(); 3920 return m_graphicsLayerFactory.get();
3859 } 3921 }
3860 3922
3861 WebCore::RenderLayerCompositor* WebViewImpl::compositor() const 3923 WebCore::RenderLayerCompositor* WebViewImpl::compositor() const
3862 { 3924 {
3925 for (Frame* frame = page()->mainFrame()->tree().top(); frame; frame = frame- >tree().traverseNext()) {
3926 if (frame->isLocalRoot())
3927 return toLocalFrame(frame)->document()->renderView()->compositor();
3928 }
3929
3863 if (!page() 3930 if (!page()
3864 || !page()->mainFrame() 3931 || !page()->mainFrame()
3865 || !page()->mainFrame()->isLocalFrame() 3932 || !page()->mainFrame()->isLocalFrame()
3866 || !page()->deprecatedLocalMainFrame()->document() 3933 || !page()->deprecatedLocalMainFrame()->document()
3867 || !page()->deprecatedLocalMainFrame()->document()->renderView()) 3934 || !page()->deprecatedLocalMainFrame()->document()->renderView())
3868 return 0; 3935 return 0;
3869 return page()->deprecatedLocalMainFrame()->document()->renderView()->composi tor(); 3936 return page()->deprecatedLocalMainFrame()->document()->renderView()->composi tor();
3870 } 3937 }
3871 3938
3872 void WebViewImpl::registerForAnimations(WebLayer* layer) 3939 void WebViewImpl::registerForAnimations(WebLayer* layer)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3974 return; 4041 return;
3975 4042
3976 bool oldProgrammaticScroll = frameView->inProgrammaticScroll(); 4043 bool oldProgrammaticScroll = frameView->inProgrammaticScroll();
3977 frameView->setInProgrammaticScroll(programmaticScroll); 4044 frameView->setInProgrammaticScroll(programmaticScroll);
3978 frameView->notifyScrollPositionChanged(scrollPosition); 4045 frameView->notifyScrollPositionChanged(scrollPosition);
3979 frameView->setInProgrammaticScroll(oldProgrammaticScroll); 4046 frameView->setInProgrammaticScroll(oldProgrammaticScroll);
3980 } 4047 }
3981 4048
3982 void WebViewImpl::applyScrollAndScale(const WebSize& scrollDelta, float pageScal eDelta) 4049 void WebViewImpl::applyScrollAndScale(const WebSize& scrollDelta, float pageScal eDelta)
3983 { 4050 {
3984 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4051 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) {
4052 printf("WCI::applyScrollAndScale: null mainFrameImpl\n");
3985 return; 4053 return;
4054 }
3986 4055
3987 if (pinchVirtualViewportEnabled()) { 4056 if (pinchVirtualViewportEnabled()) {
3988 if (pageScaleDelta != 1) { 4057 if (pageScaleDelta != 1) {
3989 // When the virtual viewport is enabled, offsets are already set for us. 4058 // When the virtual viewport is enabled, offsets are already set for us.
3990 setPageScaleFactor(pageScaleFactor() * pageScaleDelta); 4059 setPageScaleFactor(pageScaleFactor() * pageScaleDelta);
3991 m_doubleTapZoomPending = false; 4060 m_doubleTapZoomPending = false;
3992 } 4061 }
3993 4062
3994 return; 4063 return;
3995 } 4064 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
4153 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4222 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4154 4223
4155 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4224 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4156 return false; 4225 return false;
4157 4226
4158 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4227 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4159 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4228 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4160 } 4229 }
4161 4230
4162 } // namespace blink 4231 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/wtf/Assertions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698