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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayerStackingNode.cpp

Issue 1158673008: Moving HitTest function to DeprecatedPaintLayerStackingNode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move HitTest to StackingNode Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 26 matching lines...) Expand all
37 * version of this file under the LGPL, indicate your decision by 37 * version of this file under the LGPL, indicate your decision by
38 * deletingthe provisions above and replace them with the notice and 38 * deletingthe provisions above and replace them with the notice and
39 * other provisions required by the MPL or the GPL, as the case may be. 39 * other provisions required by the MPL or the GPL, as the case may be.
40 * If you do not delete the provisions above, a recipient may use your 40 * If you do not delete the provisions above, a recipient may use your
41 * version of this file under any of the LGPL, the MPL or the GPL. 41 * version of this file under any of the LGPL, the MPL or the GPL.
42 */ 42 */
43 43
44 #include "config.h" 44 #include "config.h"
45 #include "core/paint/DeprecatedPaintLayerStackingNode.h" 45 #include "core/paint/DeprecatedPaintLayerStackingNode.h"
46 46
47 #include "core/layout/HitTestLocation.h"
48 #include "core/layout/HitTestRequest.h"
49 #include "core/layout/HitTestResult.h"
47 #include "core/layout/LayoutView.h" 50 #include "core/layout/LayoutView.h"
48 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 51 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
49 #include "core/paint/DeprecatedPaintLayer.h" 52 #include "core/paint/DeprecatedPaintLayer.h"
50 #include "public/platform/Platform.h" 53 #include "public/platform/Platform.h"
51 54
52 namespace blink { 55 namespace blink {
53 56
54 // FIXME: This should not require DeprecatedPaintLayer. There is currently a cyc le where 57 // FIXME: This should not require DeprecatedPaintLayer. There is currently a cyc le where
55 // in order to determine if we shoulBeNormalFlowOnly() we have to ask the paint 58 // in order to determine if we shoulBeNormalFlowOnly() we have to ask the paint
56 // layer about some of its state. 59 // layer about some of its state.
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNode::ancestorStac kingContextNode() const 317 DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNode::ancestorStac kingContextNode() const
315 { 318 {
316 for (DeprecatedPaintLayer* ancestor = layer()->parent(); ancestor; ancestor = ancestor->parent()) { 319 for (DeprecatedPaintLayer* ancestor = layer()->parent(); ancestor; ancestor = ancestor->parent()) {
317 DeprecatedPaintLayerStackingNode* stackingNode = ancestor->stackingNode( ); 320 DeprecatedPaintLayerStackingNode* stackingNode = ancestor->stackingNode( );
318 if (stackingNode->isStackingContext()) 321 if (stackingNode->isStackingContext())
319 return stackingNode; 322 return stackingNode;
320 } 323 }
321 return 0; 324 return 0;
322 } 325 }
323 326
327 static inline LayoutRect frameVisibleRect(LayoutObject* layoutObject)
328 {
329 FrameView* frameView = layoutObject->document().view();
330 if (!frameView)
331 return LayoutRect();
332
333 return LayoutRect(frameView->visibleContentRect());
334 }
335
324 LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const 336 LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const
325 { 337 {
326 return m_layer->layoutObject(); 338 return m_layer->layoutObject();
327 } 339 }
328 340
341 // I do believe it would be better to have one function here that just returned a vector
dsinclair 2015/06/04 18:21:22 Can you make this a TODO(chadarmstrong) and link t
chadarmstrong 2015/06/04 18:43:38 Acknowledged.
342 // with the whole tree's stacking contexts in order. This would keep the concept of hit testing
343 // and painting abstracted from this class.
dsinclair 2015/06/04 18:21:22 What's stopping us from doing this approach? Is it
chadarmstrong 2015/06/04 18:43:38 Julien believes that allocating an extra array and
Julien - ping for review 2015/06/05 00:46:54 I strongly believe that this will lead to worse ru
344 bool DeprecatedPaintLayerStackingNode::hitTest(HitTestResult& result)
345 {
346 return hitTest(result.hitTestRequest(), result.hitTestLocation(), result);
347 }
348
349 bool DeprecatedPaintLayerStackingNode::hitTest(const HitTestRequest& request, co nst HitTestLocation& hitTestLocation, HitTestResult& result)
350 {
351 ASSERT(layer()->isSelfPaintingLayer() || layer()->hasSelfPaintingLayerDescen dant());
352
353 // LayoutView should make sure to update layout before entering hit testing
354 ASSERT(!layoutObject()->frame()->view()->layoutPending());
355 ASSERT(!layoutObject()->document().layoutView()->needsLayout());
356
357 // Start with frameVisibleRect to ensure we include the scrollbars.
358 LayoutRect hitTestArea = frameVisibleRect(layoutObject());
359 if (request.ignoreClipping())
360 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect()));
361
362 DeprecatedPaintLayer* insideLayer = layer()->hitTestLayer(layer(), 0, result , hitTestArea, hitTestLocation, false);
363 if (!insideLayer) {
364 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down,
365 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has
366 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document.
367 // In addtion, it is possible for the mouse to stay in the document but there is no element.
368 // At that time, the events of the mouse should be fired.
369 LayoutPoint hitPoint = hitTestLocation.point();
370 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && layer()->isRootLayer()) {
371 layoutObject()->updateHitTestResult(result, toLayoutView(layoutObjec t())->flipForWritingMode(hitTestLocation.point()));
372 insideLayer = layer();
373 }
374 }
375
376 // Now determine if the result is inside an anchor - if the urlElement isn't already set.
377 Node* node = result.innerNode();
378 if (node && !result.URLElement())
379 result.setURLElement(node->enclosingLinkEventParentOrSelf());
380
381 // Now return whether we were inside this layer (this will always be true fo r the root
382 // layer).
383 return insideLayer;
384 }
385
329 } // namespace blink 386 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698