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

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

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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/WebSearchableFormData.cpp ('k') | no next file » | 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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 return; 572 return;
573 573
574 m_page->contextMenuController().clearContextMenu(); 574 m_page->contextMenuController().clearContextMenu();
575 575
576 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); 576 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event);
577 577
578 // Find the right target frame. See issue 1186900. 578 // Find the right target frame. See issue 1186900.
579 HitTestResult result = hitTestResultForWindowPos(pme.position()); 579 HitTestResult result = hitTestResultForWindowPos(pme.position());
580 Frame* targetFrame; 580 Frame* targetFrame;
581 if (result.innerNonSharedNode()) 581 if (result.innerNonSharedNode())
582 targetFrame = result.innerNonSharedNode()->document()->frame(); 582 targetFrame = result.innerNonSharedNode()->document().frame();
583 else 583 else
584 targetFrame = m_page->focusController().focusedOrMainFrame(); 584 targetFrame = m_page->focusController().focusedOrMainFrame();
585 585
586 #if OS(WINDOWS) 586 #if OS(WINDOWS)
587 targetFrame->view()->setCursor(pointerCursor()); 587 targetFrame->view()->setCursor(pointerCursor());
588 #endif 588 #endif
589 589
590 m_contextMenuAllowed = true; 590 m_contextMenuAllowed = true;
591 targetFrame->eventHandler()->sendContextMenuEvent(pme); 591 targetFrame->eventHandler()->sendContextMenuEvent(pme);
592 m_contextMenuAllowed = false; 592 m_contextMenuAllowed = false;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 if (!node) 1079 if (!node)
1080 return WebRect(); 1080 return WebRect();
1081 1081
1082 // Find the block type node based on the hit node. 1082 // Find the block type node based on the hit node.
1083 while (node && (!node->renderer() || node->renderer()->isInline())) 1083 while (node && (!node->renderer() || node->renderer()->isInline()))
1084 node = node->parentNode(); 1084 node = node->parentNode();
1085 1085
1086 // Return the bounding box in the window coordinate system. 1086 // Return the bounding box in the window coordinate system.
1087 if (node) { 1087 if (node) {
1088 IntRect rect = node->Node::pixelSnappedBoundingBox(); 1088 IntRect rect = node->Node::pixelSnappedBoundingBox();
1089 Frame* frame = node->document()->frame(); 1089 Frame* frame = node->document().frame();
1090 return frame->view()->contentsToWindow(rect); 1090 return frame->view()->contentsToWindow(rect);
1091 } 1091 }
1092 return WebRect(); 1092 return WebRect();
1093 } 1093 }
1094 1094
1095 WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target Margin, int minimumMargin) 1095 WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target Margin, int minimumMargin)
1096 { 1096 {
1097 WebSize maxSize; 1097 WebSize maxSize;
1098 if (mainFrame()) 1098 if (mainFrame())
1099 maxSize = mainFrame()->contentsSize(); 1099 maxSize = mainFrame()->contentsSize();
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 if (!selection) 2281 if (!selection)
2282 return false; 2282 return false;
2283 2283
2284 if (selection->isCaret()) 2284 if (selection->isCaret())
2285 anchor = focus = selection->absoluteCaretBounds(); 2285 anchor = focus = selection->absoluteCaretBounds();
2286 else { 2286 else {
2287 RefPtr<Range> selectedRange = frame->selection()->toNormalizedRange(); 2287 RefPtr<Range> selectedRange = frame->selection()->toNormalizedRange();
2288 if (!selectedRange) 2288 if (!selectedRange)
2289 return false; 2289 return false;
2290 2290
2291 RefPtr<Range> range(Range::create(selectedRange->startContainer()->docum ent(), 2291 RefPtr<Range> range(Range::create(&selectedRange->startContainer()->docu ment(),
2292 selectedRange->startContainer(), 2292 selectedRange->startContainer(),
2293 selectedRange->startOffset(), 2293 selectedRange->startOffset(),
2294 selectedRange->startContainer(), 2294 selectedRange->startContainer(),
2295 selectedRange->startOffset())); 2295 selectedRange->startOffset()));
2296 anchor = frame->editor().firstRectForRange(range.get()); 2296 anchor = frame->editor().firstRectForRange(range.get());
2297 2297
2298 range = Range::create(selectedRange->endContainer()->document(), 2298 range = Range::create(&selectedRange->endContainer()->document(),
2299 selectedRange->endContainer(), 2299 selectedRange->endContainer(),
2300 selectedRange->endOffset(), 2300 selectedRange->endOffset(),
2301 selectedRange->endContainer(), 2301 selectedRange->endContainer(),
2302 selectedRange->endOffset()); 2302 selectedRange->endOffset());
2303 focus = frame->editor().firstRectForRange(range.get()); 2303 focus = frame->editor().firstRectForRange(range.get());
2304 } 2304 }
2305 2305
2306 IntRect scaledAnchor(frame->view()->contentsToWindow(anchor)); 2306 IntRect scaledAnchor(frame->view()->contentsToWindow(anchor));
2307 IntRect scaledFocus(frame->view()->contentsToWindow(focus)); 2307 IntRect scaledFocus(frame->view()->contentsToWindow(focus));
2308 scaledAnchor.scale(pageScaleFactor()); 2308 scaledAnchor.scale(pageScaleFactor());
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 float scale; 2664 float scale;
2665 IntPoint scroll; 2665 IntPoint scroll;
2666 bool needAnimation; 2666 bool needAnimation;
2667 computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation); 2667 computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation);
2668 if (needAnimation) 2668 if (needAnimation)
2669 startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnimationDur ationInSeconds); 2669 startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnimationDur ationInSeconds);
2670 } 2670 }
2671 2671
2672 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float& newScale, IntPoint& newScroll, bool& needAnimation) 2672 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float& newScale, IntPoint& newScroll, bool& needAnimation)
2673 { 2673 {
2674 focusedNode->document()->updateLayoutIgnorePendingStylesheets(); 2674 focusedNode->document().updateLayoutIgnorePendingStylesheets();
2675 2675
2676 // 'caret' is rect encompassing the blinking cursor. 2676 // 'caret' is rect encompassing the blinking cursor.
2677 IntRect textboxRect = focusedNode->document()->view()->contentsToWindow(pixe lSnappedIntRect(focusedNode->Node::boundingBox())); 2677 IntRect textboxRect = focusedNode->document().view()->contentsToWindow(pixel SnappedIntRect(focusedNode->Node::boundingBox()));
2678 WebRect caret, unusedEnd; 2678 WebRect caret, unusedEnd;
2679 selectionBounds(caret, unusedEnd); 2679 selectionBounds(caret, unusedEnd);
2680 IntRect unscaledCaret = caret; 2680 IntRect unscaledCaret = caret;
2681 unscaledCaret.scale(1 / pageScaleFactor()); 2681 unscaledCaret.scale(1 / pageScaleFactor());
2682 caret = unscaledCaret; 2682 caret = unscaledCaret;
2683 2683
2684 // Pick a scale which is reasonably readable. This is the scale at which 2684 // Pick a scale which is reasonably readable. This is the scale at which
2685 // the caret height will become minReadableCaretHeight (adjusted for dpi 2685 // the caret height will become minReadableCaretHeight (adjusted for dpi
2686 // and font scale factor). 2686 // and font scale factor).
2687 float targetScale = 1; 2687 float targetScale = 1;
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 } 4127 }
4128 4128
4129 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4129 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4130 { 4130 {
4131 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4131 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4132 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4132 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4133 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4133 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4134 } 4134 }
4135 4135
4136 } // namespace WebKit 4136 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/web/WebSearchableFormData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698