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

Side by Side Diff: Source/core/layout/LayoutMenuList.cpp

Issue 1267113002: PopupMenuImpl should get menu items via PopupMenuClient. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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/core/layout/LayoutMenuList.h ('k') | Source/web/ExternalPopupMenuTest.cpp » ('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 * This file is part of the select element layoutObject in WebCore. 2 * This file is part of the select element layoutObject in WebCore.
3 * 3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // We don't use absoluteBoundingBoxRect() because it can return an IntRect 393 // We don't use absoluteBoundingBoxRect() because it can return an IntRect
394 // larger the actual size by 1px. 394 // larger the actual size by 1px.
395 return selectElement()->document().view()->contentsToViewport(roundedIntRect (absoluteBoundingBoxFloatRect())); 395 return selectElement()->document().view()->contentsToViewport(roundedIntRect (absoluteBoundingBoxFloatRect()));
396 } 396 }
397 397
398 Element& LayoutMenuList::ownerElement() const 398 Element& LayoutMenuList::ownerElement() const
399 { 399 {
400 return *selectElement(); 400 return *selectElement();
401 } 401 }
402 402
403 const ComputedStyle* LayoutMenuList::computedStyleForItem(Element& element) cons t
404 {
405 return element.computedStyle() ? element.computedStyle() : element.ensureCom putedStyle();
406 }
407
408 const ComputedStyle* LayoutMenuList::computedStyleForItem(unsigned listIndex) co nst 403 const ComputedStyle* LayoutMenuList::computedStyleForItem(unsigned listIndex) co nst
409 { 404 {
410 Element& element = *selectElement()->listItems()[listIndex]; 405 Element& element = *selectElement()->listItems()[listIndex];
411 return element.computedStyle() ? element.computedStyle() : element.ensureCom putedStyle(); 406 return element.computedStyle() ? element.computedStyle() : element.ensureCom putedStyle();
412 } 407 }
413 408
414 void LayoutMenuList::didSetSelectedIndex(int listIndex) 409 void LayoutMenuList::didSetSelectedIndex(int listIndex)
415 { 410 {
416 didUpdateActiveOption(selectElement()->listToOptionIndex(listIndex)); 411 didUpdateActiveOption(selectElement()->listToOptionIndex(listIndex));
417 } 412 }
(...skipping 15 matching lines...) Expand all
433 // We skip sending accessiblity notifications for the very first option, oth erwise 428 // We skip sending accessiblity notifications for the very first option, oth erwise
434 // we get extra focus and select events that are undesired. 429 // we get extra focus and select events that are undesired.
435 if (!m_hasUpdatedActiveOption) { 430 if (!m_hasUpdatedActiveOption) {
436 m_hasUpdatedActiveOption = true; 431 m_hasUpdatedActiveOption = true;
437 return; 432 return;
438 } 433 }
439 434
440 document().existingAXObjectCache()->handleUpdateActiveMenuOption(this, optio nIndex); 435 document().existingAXObjectCache()->handleUpdateActiveMenuOption(this, optio nIndex);
441 } 436 }
442 437
438 Element& LayoutMenuList::itemElement(unsigned listIndex) const
439 {
440 return *selectElement()->listItems()[listIndex];
441 }
442
443 String LayoutMenuList::itemText(unsigned listIndex) const 443 String LayoutMenuList::itemText(unsigned listIndex) const
444 { 444 {
445 HTMLSelectElement* select = selectElement(); 445 HTMLSelectElement* select = selectElement();
446 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = select- >listItems(); 446 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = select- >listItems();
447 if (listIndex >= listItems.size()) 447 if (listIndex >= listItems.size())
448 return String(); 448 return String();
449 449
450 String itemString; 450 String itemString;
451 Element* element = listItems[listIndex]; 451 Element* element = listItems[listIndex];
452 if (isHTMLOptGroupElement(*element)) 452 if (isHTMLOptGroupElement(*element))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 return false; 493 return false;
494 494
495 return !element->isDisabledFormControl(); 495 return !element->isDisabledFormControl();
496 } 496 }
497 497
498 bool LayoutMenuList::itemIsDisplayNone(unsigned listIndex) const 498 bool LayoutMenuList::itemIsDisplayNone(unsigned listIndex) const
499 { 499 {
500 Element& element = *selectElement()->listItems()[listIndex]; 500 Element& element = *selectElement()->listItems()[listIndex];
501 if (isHTMLOptionElement(element)) 501 if (isHTMLOptionElement(element))
502 return toHTMLOptionElement(element).isDisplayNone(); 502 return toHTMLOptionElement(element).isDisplayNone();
503 if (const ComputedStyle* style = computedStyleForItem(element)) 503 if (const ComputedStyle* style = computedStyleForItem(listIndex))
504 return style->display() == NONE; 504 return style->display() == NONE;
505 return false; 505 return false;
506 } 506 }
507 507
508 LayoutUnit LayoutMenuList::clientPaddingLeft() const 508 LayoutUnit LayoutMenuList::clientPaddingLeft() const
509 { 509 {
510 return paddingLeft() + m_innerBlock->paddingLeft(); 510 return paddingLeft() + m_innerBlock->paddingLeft();
511 } 511 }
512 512
513 const int endOfLinePadding = 2; 513 const int endOfLinePadding = 2;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 HTMLElement* element = listItems[listIndex]; 570 HTMLElement* element = listItems[listIndex];
571 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select ed(); 571 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select ed();
572 } 572 }
573 573
574 void LayoutMenuList::provisionalSelectionChanged(unsigned listIndex) 574 void LayoutMenuList::provisionalSelectionChanged(unsigned listIndex)
575 { 575 {
576 setIndexToSelectOnCancel(listIndex); 576 setIndexToSelectOnCancel(listIndex);
577 } 577 }
578 578
579 } // namespace blink 579 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutMenuList.h ('k') | Source/web/ExternalPopupMenuTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698