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

Side by Side Diff: third_party/WebKit/Source/core/layout/HitTestResult.cpp

Issue 2391893004: Reformat comments in core/layout up until LayoutBox (Closed)
Patch Set: Rebase w/HEAD (again) Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 return false; 231 return false;
232 232
233 if (LocalFrame* frame = m_innerNode->document().frame()) 233 if (LocalFrame* frame = m_innerNode->document().frame())
234 return frame->selection().contains(m_hitTestLocation.point()); 234 return frame->selection().contains(m_hitTestLocation.point());
235 return false; 235 return false;
236 } 236 }
237 237
238 String HitTestResult::title(TextDirection& dir) const { 238 String HitTestResult::title(TextDirection& dir) const {
239 dir = LTR; 239 dir = LTR;
240 // Find the title in the nearest enclosing DOM node. 240 // Find the title in the nearest enclosing DOM node.
241 // For <area> tags in image maps, walk the tree for the <area>, not the <img> using it. 241 // For <area> tags in image maps, walk the tree for the <area>, not the <img>
242 // using it.
242 if (m_innerNode.get()) 243 if (m_innerNode.get())
243 m_innerNode->updateDistribution(); 244 m_innerNode->updateDistribution();
244 for (Node* titleNode = m_innerNode.get(); titleNode; 245 for (Node* titleNode = m_innerNode.get(); titleNode;
245 titleNode = FlatTreeTraversal::parent(*titleNode)) { 246 titleNode = FlatTreeTraversal::parent(*titleNode)) {
246 if (titleNode->isElementNode()) { 247 if (titleNode->isElementNode()) {
247 String title = toElement(titleNode)->title(); 248 String title = toElement(titleNode)->title();
248 if (!title.isNull()) { 249 if (!title.isNull()) {
249 if (LayoutObject* layoutObject = titleNode->layoutObject()) 250 if (LayoutObject* layoutObject = titleNode->layoutObject())
250 dir = layoutObject->style()->direction(); 251 dir = layoutObject->style()->direction();
251 return title; 252 return title;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 ->absoluteContentQuad() 297 ->absoluteContentQuad()
297 .enclosingBoundingBox(); 298 .enclosingBoundingBox();
298 } 299 }
299 300
300 KURL HitTestResult::absoluteImageURL() const { 301 KURL HitTestResult::absoluteImageURL() const {
301 Node* innerNodeOrImageMapImage = this->innerNodeOrImageMapImage(); 302 Node* innerNodeOrImageMapImage = this->innerNodeOrImageMapImage();
302 if (!innerNodeOrImageMapImage) 303 if (!innerNodeOrImageMapImage)
303 return KURL(); 304 return KURL();
304 305
305 AtomicString urlString; 306 AtomicString urlString;
306 // Always return a url for image elements and input elements with type=image, even if they 307 // Always return a url for image elements and input elements with type=image,
307 // don't have a LayoutImage (e.g. because the image didn't load and we are usi ng an alt container). 308 // even if they don't have a LayoutImage (e.g. because the image didn't load
308 // For other elements we don't create alt containers so ensure they contain a loaded image. 309 // and we are using an alt container). For other elements we don't create alt
310 // containers so ensure they contain a loaded image.
309 if (isHTMLImageElement(*innerNodeOrImageMapImage) || 311 if (isHTMLImageElement(*innerNodeOrImageMapImage) ||
310 (isHTMLInputElement(*innerNodeOrImageMapImage) && 312 (isHTMLInputElement(*innerNodeOrImageMapImage) &&
311 toHTMLInputElement(innerNodeOrImageMapImage)->type() == 313 toHTMLInputElement(innerNodeOrImageMapImage)->type() ==
312 InputTypeNames::image)) 314 InputTypeNames::image))
313 urlString = toElement(*innerNodeOrImageMapImage).imageSourceURL(); 315 urlString = toElement(*innerNodeOrImageMapImage).imageSourceURL();
314 else if ((innerNodeOrImageMapImage->layoutObject() && 316 else if ((innerNodeOrImageMapImage->layoutObject() &&
315 innerNodeOrImageMapImage->layoutObject()->isImage()) && 317 innerNodeOrImageMapImage->layoutObject()->isImage()) &&
316 (isHTMLEmbedElement(*innerNodeOrImageMapImage) || 318 (isHTMLEmbedElement(*innerNodeOrImageMapImage) ||
317 isHTMLObjectElement(*innerNodeOrImageMapImage) || 319 isHTMLObjectElement(*innerNodeOrImageMapImage) ||
318 isSVGImageElement(*innerNodeOrImageMapImage))) 320 isSVGImageElement(*innerNodeOrImageMapImage)))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 bool HitTestResult::isOverLink() const { 357 bool HitTestResult::isOverLink() const {
356 return m_innerURLElement && m_innerURLElement->isLink(); 358 return m_innerURLElement && m_innerURLElement->isLink();
357 } 359 }
358 360
359 String HitTestResult::textContent() const { 361 String HitTestResult::textContent() const {
360 if (!m_innerURLElement) 362 if (!m_innerURLElement)
361 return String(); 363 return String();
362 return m_innerURLElement->textContent(); 364 return m_innerURLElement->textContent();
363 } 365 }
364 366
365 // FIXME: This function needs a better name and may belong in a different class. It's not 367 // FIXME: This function needs a better name and may belong in a different class.
366 // really isContentEditable(); it's more like needsEditingContextMenu(). In many ways, this 368 // It's not really isContentEditable(); it's more like needsEditingContextMenu.
367 // function would make more sense in the ContextMenu class, except that WebEleme ntDictionary 369 // In many ways, this function would make more sense in the ContextMenu class,
368 // hooks into it. Anyway, we should architect this better. 370 // except that WebElementDictionary hooks into it. Anyway, we should architect
371 // this better.
369 bool HitTestResult::isContentEditable() const { 372 bool HitTestResult::isContentEditable() const {
370 if (!m_innerNode) 373 if (!m_innerNode)
371 return false; 374 return false;
372 375
373 if (isHTMLTextAreaElement(*m_innerNode)) 376 if (isHTMLTextAreaElement(*m_innerNode))
374 return !toHTMLTextAreaElement(*m_innerNode).isDisabledOrReadOnly(); 377 return !toHTMLTextAreaElement(*m_innerNode).isDisabledOrReadOnly();
375 378
376 if (isHTMLInputElement(*m_innerNode)) { 379 if (isHTMLInputElement(*m_innerNode)) {
377 HTMLInputElement& inputElement = toHTMLInputElement(*m_innerNode); 380 HTMLInputElement& inputElement = toHTMLInputElement(*m_innerNode);
378 return !inputElement.isDisabledOrReadOnly() && inputElement.isTextField(); 381 return !inputElement.isDisabledOrReadOnly() && inputElement.isTextField();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 Node* resolvedInnerNode, 465 Node* resolvedInnerNode,
463 const LayoutPoint& resolvedPointInMainFrame) { 466 const LayoutPoint& resolvedPointInMainFrame) {
464 ASSERT(isRectBasedTest()); 467 ASSERT(isRectBasedTest());
465 ASSERT(m_hitTestLocation.containsPoint(FloatPoint(resolvedPointInMainFrame))); 468 ASSERT(m_hitTestLocation.containsPoint(FloatPoint(resolvedPointInMainFrame)));
466 m_hitTestLocation = HitTestLocation(resolvedPointInMainFrame); 469 m_hitTestLocation = HitTestLocation(resolvedPointInMainFrame);
467 m_pointInInnerNodeFrame = resolvedPointInMainFrame; 470 m_pointInInnerNodeFrame = resolvedPointInMainFrame;
468 m_innerNode = nullptr; 471 m_innerNode = nullptr;
469 m_innerPossiblyPseudoNode = nullptr; 472 m_innerPossiblyPseudoNode = nullptr;
470 m_listBasedTestResult = nullptr; 473 m_listBasedTestResult = nullptr;
471 474
472 // Update the HitTestResult as if the supplied node had been hit in normal poi nt-based hit-test. 475 // Update the HitTestResult as if the supplied node had been hit in normal
473 // Note that we don't know the local point after a rect-based hit-test, but we never use 476 // point-based hit-test.
474 // it so shouldn't bother with the cost of computing it. 477 // Note that we don't know the local point after a rect-based hit-test, but we
475 resolvedInnerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint()); 478 // never use it so shouldn't bother with the cost of computing it. resolvedIn nerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint());
476 ASSERT(!isRectBasedTest()); 479 ASSERT(!isRectBasedTest());
477 } 480 }
478 481
479 Element* HitTestResult::innerElement() const { 482 Element* HitTestResult::innerElement() const {
480 for (Node* node = m_innerNode.get(); node; 483 for (Node* node = m_innerNode.get(); node;
481 node = FlatTreeTraversal::parent(*node)) { 484 node = FlatTreeTraversal::parent(*node)) {
482 if (node->isElementNode()) 485 if (node->isElementNode())
483 return toElement(node); 486 return toElement(node);
484 } 487 }
485 488
(...skipping 10 matching lines...) Expand all
496 else if (isHTMLMapElement(m_innerNode)) 499 else if (isHTMLMapElement(m_innerNode))
497 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); 500 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement();
498 501
499 if (!imageMapImageElement) 502 if (!imageMapImageElement)
500 return m_innerNode.get(); 503 return m_innerNode.get();
501 504
502 return imageMapImageElement; 505 return imageMapImageElement;
503 } 506 }
504 507
505 } // namespace blink 508 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698