Changeset 225446 in webkit


Ignore:
Timestamp:
Dec 2, 2017 12:47:19 AM (6 years ago)
Author:
Wenson Hsieh
Message:

Make some minor adjustments to TouchBarMenuData and TouchBarMenuItemData
https://bugs.webkit.org/show_bug.cgi?id=180305

Reviewed by Joseph Pecoraro.

Mark some methods and parameters as const, use the default constructor in more places, and also remove a few
extraneous imported headers.

  • Shared/TouchBarMenuData.cpp:

(WebKit::TouchBarMenuData::TouchBarMenuData):

Add a FIXME regarding the use of the 'id' attribute.

(WebKit::TouchBarMenuData::decode):

  • Shared/TouchBarMenuData.h:

(WebKit::TouchBarMenuData::items const):
(WebKit::TouchBarMenuData::setID):
(WebKit::TouchBarMenuData::isPageCustomized const):
(WebKit::TouchBarMenuData::items): Deleted.
(WebKit::TouchBarMenuData::isPageCustomized): Deleted.

  • Shared/TouchBarMenuItemData.cpp:

(WebKit::getItemType):

Change a helper method from a static class function to a static function in the implementation file.

(WebKit::TouchBarMenuItemData::TouchBarMenuItemData):
(WebKit::TouchBarMenuItemData::encode const):
(WebKit::TouchBarMenuItemData::decode):
(WebKit::TouchBarMenuItemData::getItemType): Deleted.

  • Shared/TouchBarMenuItemData.h:

(WebKit::operator==):

Remove the commandName member variable, since it doesn't make sense to propagate an event handler
attribute from WebCore to the client layer.

  • UIProcess/WebPageProxy.messages.in:
Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r225445 r225446  
     12017-12-02  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Make some minor adjustments to TouchBarMenuData and TouchBarMenuItemData
     4        https://bugs.webkit.org/show_bug.cgi?id=180305
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Mark some methods and parameters as const, use the default constructor in more places, and also remove a few
     9        extraneous imported headers.
     10
     11        * Shared/TouchBarMenuData.cpp:
     12        (WebKit::TouchBarMenuData::TouchBarMenuData):
     13
     14        Add a FIXME regarding the use of the 'id' attribute.
     15
     16        (WebKit::TouchBarMenuData::decode):
     17        * Shared/TouchBarMenuData.h:
     18        (WebKit::TouchBarMenuData::items const):
     19        (WebKit::TouchBarMenuData::setID):
     20        (WebKit::TouchBarMenuData::isPageCustomized const):
     21        (WebKit::TouchBarMenuData::items): Deleted.
     22        (WebKit::TouchBarMenuData::isPageCustomized): Deleted.
     23        * Shared/TouchBarMenuItemData.cpp:
     24        (WebKit::getItemType):
     25
     26        Change a helper method from a static class function to a static function in the implementation file.
     27
     28        (WebKit::TouchBarMenuItemData::TouchBarMenuItemData):
     29        (WebKit::TouchBarMenuItemData::encode const):
     30        (WebKit::TouchBarMenuItemData::decode):
     31        (WebKit::TouchBarMenuItemData::getItemType): Deleted.
     32        * Shared/TouchBarMenuItemData.h:
     33        (WebKit::operator==):
     34
     35        Remove the commandName member variable, since it doesn't make sense to propagate an event handler
     36        attribute from WebCore to the client layer.
     37
     38        * UIProcess/WebPageProxy.messages.in:
     39
    1402017-12-01  Zan Dobersek  <zdobersek@igalia.com>
    241
  • trunk/Source/WebKit/Shared/TouchBarMenuData.cpp

    r225438 r225446  
    3131#include "TouchBarMenuItemData.h"
    3232#include "WebCoreArgumentCoders.h"
    33 #include <WebCore/HTMLElement.h>
    3433#include <WebCore/HTMLMenuElement.h>
    3534#include <WebCore/HTMLNames.h>
    36 #include <WebCore/Node.h>
    3735
    3836namespace WebKit {
    3937   
    40 TouchBarMenuData::TouchBarMenuData()
    41 {
    42 }
    43    
    44 TouchBarMenuData::TouchBarMenuData(WebCore::HTMLMenuElement& element)
     38TouchBarMenuData::TouchBarMenuData(const WebCore::HTMLMenuElement& element)
    4539{
    4640    if (!element.isTouchBarMenu())
    4741        return;
     42
     43    // FIXME: We can't rely on using the 'id' attribute of the element here to distinguish
     44    // between different menu items. For instance, a menuitem may have the same 'id' as
     45    // another, or have no 'id' at all.
    4846    m_id = element.attributeWithoutSynchronization(WebCore::HTMLNames::idAttr);
    4947    m_isPageCustomized = true;
    50 }
    51    
    52 TouchBarMenuData::TouchBarMenuData(const TouchBarMenuData& touchBarMenuData)
    53     : m_items(touchBarMenuData.m_items)
    54     , m_id(touchBarMenuData.m_id)
    55     , m_isPageCustomized(touchBarMenuData.m_isPageCustomized)
    56 {
    5748}
    5849   
     
    7465bool TouchBarMenuData::decode(IPC::Decoder& decoder, TouchBarMenuData& data)
    7566{
    76     if (!decoder.decode(data.m_items))
    77         return false;
    78    
    79     return true;
     67    return decoder.decode(data.m_items);
    8068}
    8169   
  • trunk/Source/WebKit/Shared/TouchBarMenuData.h

    r225438 r225446  
    2727#include "ArgumentCoders.h"
    2828#include "TouchBarMenuItemData.h"
    29 #include <WebCore/HTMLMenuElement.h>
    3029#include <wtf/text/WTFString.h>
    3130
     
    3534}
    3635
     36namespace WebCore {
     37class HTMLMenuElement;
     38}
     39
    3740namespace WebKit {
    3841
    3942class TouchBarMenuData {
    4043public:
    41     explicit TouchBarMenuData();
    42     explicit TouchBarMenuData(WebCore::HTMLMenuElement&);
    43     explicit TouchBarMenuData(const TouchBarMenuData&);
     44    explicit TouchBarMenuData() = default;
     45    explicit TouchBarMenuData(const WebCore::HTMLMenuElement&);
     46    explicit TouchBarMenuData(const TouchBarMenuData&) = default;
    4447
    4548    void addMenuItem(const TouchBarMenuItemData&);
    4649    void removeMenuItem(const TouchBarMenuItemData&);
    4750   
    48     const Vector<TouchBarMenuItemData>& items() { return m_items; }
     51    const Vector<TouchBarMenuItemData>& items() const { return m_items; }
    4952   
    5053    void encode(IPC::Encoder&) const;
    5154    static bool decode(IPC::Decoder&, TouchBarMenuData&);
    5255   
    53     void setID(String);
    54     bool isPageCustomized() { return m_isPageCustomized; }
     56    void setID(const String& identifier) { m_id = identifier; }
     57    bool isPageCustomized() const { return m_isPageCustomized; }
    5558    void setIsPageCustomized(bool customized) { m_isPageCustomized = customized; }
    5659   
  • trunk/Source/WebKit/Shared/TouchBarMenuItemData.cpp

    r225438 r225446  
    2929#include "Encoder.h"
    3030#include "WebCoreArgumentCoders.h"
    31 #include <WebCore/HTMLElement.h>
    3231#include <WebCore/HTMLMenuItemElement.h>
    3332#include <WebCore/HTMLNames.h>
    34 #include <WebCore/Node.h>
    35 #include <vector>
    3633
    3734namespace WebKit {
    3835
    39 ItemType TouchBarMenuItemData::getItemType(String value)
     36static ItemType getItemType(const String&)
    4037{
    4138    return ItemType::Button;
    4239}
    4340
    44 TouchBarMenuItemData::TouchBarMenuItemData()
    45 {
    46 }
    47 
    48 TouchBarMenuItemData::TouchBarMenuItemData(WebCore::HTMLMenuItemElement& element)
     41TouchBarMenuItemData::TouchBarMenuItemData(const WebCore::HTMLMenuItemElement& element)
    4942{
    5043    itemType = getItemType(element.attributeWithoutSynchronization(WebCore::HTMLNames::typeAttr));
    5144    identifier = element.attributeWithoutSynchronization(WebCore::HTMLNames::idAttr);
    52     commandName = element.attributeWithoutSynchronization(WebCore::HTMLNames::onclickAttr);
    5345    priority = element.attributeWithoutSynchronization(WebCore::HTMLNames::valueAttr).toFloat();
    54 }
    55    
    56 TouchBarMenuItemData::TouchBarMenuItemData(const TouchBarMenuItemData& other)
    57     : itemType(other.itemType)
    58     , identifier(other.identifier)
    59     , commandName(other.commandName)
    60     , priority(other.priority)
    61 {
    6246}
    6347
     
    6751   
    6852    encoder << identifier;
    69     encoder << commandName;
    7053    encoder << priority;
    7154}
     
    8063        return std::nullopt;
    8164   
    82     if (!decoder.decode(result.commandName))
    83         return std::nullopt;
    84    
    8565    if (!decoder.decode(result.priority))
    8666        return std::nullopt;
  • trunk/Source/WebKit/Shared/TouchBarMenuItemData.h

    r225438 r225446  
    2626#pragma once
    2727#include "ArgumentCoders.h"
    28 #include <WebCore/HTMLMenuItemElement.h>
    2928#include <wtf/text/WTFString.h>
    3029
     
    3231class Decoder;
    3332class Encoder;
     33}
     34
     35namespace WebCore {
     36class HTMLMenuItemElement;
    3437}
    3538
     
    4245
    4346struct TouchBarMenuItemData {
    44     explicit TouchBarMenuItemData();
    45     explicit TouchBarMenuItemData(WebCore::HTMLMenuItemElement&);
    46     explicit TouchBarMenuItemData(const TouchBarMenuItemData&);
     47    explicit TouchBarMenuItemData() = default;
     48    explicit TouchBarMenuItemData(const WebCore::HTMLMenuItemElement&);
     49    explicit TouchBarMenuItemData(const TouchBarMenuItemData&) = default;
    4750   
    4851    void encode(IPC::Encoder&) const;
    4952    static std::optional<TouchBarMenuItemData> decode(IPC::Decoder&);
    50     static ItemType getItemType(String);
    51    
    52     bool validTouchBarDisplay { true };
    5353   
    5454    ItemType itemType { ItemType::Button };
    5555    String identifier;
    56     String commandName;
    5756    float priority { 0.0 };
     57    bool validTouchBarDisplay { true };
    5858};
    5959   
     
    8383    return lhs.itemType == rhs.itemType
    8484    && lhs.identifier == rhs.identifier
    85     && lhs.commandName == rhs.commandName
    8685    && lhs.priority == rhs.priority;
    8786}
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r225438 r225446  
    315315#endif
    316316
    317 
    318317#if ENABLE(DATA_INTERACTION)
    319318    DidPerformDataInteractionControllerOperation(bool handled)
Note: See TracChangeset for help on using the changeset viewer.