diff options
Diffstat (limited to 'webkit')
67 files changed, 12 insertions, 14110 deletions
diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc index 3fe37c7..72501e4 100644 --- a/webkit/support/test_webkit_platform_support.cc +++ b/webkit/support/test_webkit_platform_support.cc @@ -60,7 +60,6 @@ #if defined(OS_WIN) #include "third_party/WebKit/Source/Platform/chromium/public/win/WebThemeEngine.h" -#include "webkit/tools/test_shell/test_shell_webthemeengine.h" #elif defined(OS_MACOSX) #include "base/mac/mac_util.h" #endif diff --git a/webkit/tools/test_shell/accessibility_ui_element.cc b/webkit/tools/test_shell/accessibility_ui_element.cc deleted file mode 100644 index 0f173e3..0000000 --- a/webkit/tools/test_shell/accessibility_ui_element.cc +++ /dev/null @@ -1,633 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/logging.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" -#include "webkit/tools/test_shell/accessibility_ui_element.h" - -using WebKit::WebCString; -using WebKit::WebString; -using WebKit::WebAccessibilityObject; -using WebKit::WebAccessibilityRole; -using webkit_glue::CppArgumentList; -using webkit_glue::CppVariant; - -namespace { - -// Map role value to string, matching Safari/Mac platform implementation to -// avoid rebaselining layout tests. -static std::string RoleToString(WebAccessibilityRole role) { - std::string result = "AXRole: AX"; - switch (role) { - case WebKit::WebAccessibilityRoleButton: - return result.append("Button"); - case WebKit::WebAccessibilityRoleRadioButton: - return result.append("RadioButton"); - case WebKit::WebAccessibilityRoleCheckBox: - return result.append("CheckBox"); - case WebKit::WebAccessibilityRoleSlider: - return result.append("Slider"); - case WebKit::WebAccessibilityRoleTabGroup: - return result.append("TabGroup"); - case WebKit::WebAccessibilityRoleTextField: - return result.append("TextField"); - case WebKit::WebAccessibilityRoleStaticText: - return result.append("StaticText"); - case WebKit::WebAccessibilityRoleTextArea: - return result.append("TextArea"); - case WebKit::WebAccessibilityRoleScrollArea: - return result.append("ScrollArea"); - case WebKit::WebAccessibilityRolePopUpButton: - return result.append("PopUpButton"); - case WebKit::WebAccessibilityRoleMenuButton: - return result.append("MenuButton"); - case WebKit::WebAccessibilityRoleTable: - return result.append("Table"); - case WebKit::WebAccessibilityRoleApplication: - return result.append("Application"); - case WebKit::WebAccessibilityRoleGroup: - return result.append("Group"); - case WebKit::WebAccessibilityRoleRadioGroup: - return result.append("RadioGroup"); - case WebKit::WebAccessibilityRoleList: - return result.append("List"); - case WebKit::WebAccessibilityRoleScrollBar: - return result.append("ScrollBar"); - case WebKit::WebAccessibilityRoleValueIndicator: - return result.append("ValueIndicator"); - case WebKit::WebAccessibilityRoleImage: - return result.append("Image"); - case WebKit::WebAccessibilityRoleMenuBar: - return result.append("MenuBar"); - case WebKit::WebAccessibilityRoleMenu: - return result.append("Menu"); - case WebKit::WebAccessibilityRoleMenuItem: - return result.append("MenuItem"); - case WebKit::WebAccessibilityRoleColumn: - return result.append("Column"); - case WebKit::WebAccessibilityRoleRow: - return result.append("Row"); - case WebKit::WebAccessibilityRoleToolbar: - return result.append("Toolbar"); - case WebKit::WebAccessibilityRoleBusyIndicator: - return result.append("BusyIndicator"); - case WebKit::WebAccessibilityRoleProgressIndicator: - return result.append("ProgressIndicator"); - case WebKit::WebAccessibilityRoleWindow: - return result.append("Window"); - case WebKit::WebAccessibilityRoleDrawer: - return result.append("Drawer"); - case WebKit::WebAccessibilityRoleSystemWide: - return result.append("SystemWide"); - case WebKit::WebAccessibilityRoleOutline: - return result.append("Outline"); - case WebKit::WebAccessibilityRoleIncrementor: - return result.append("Incrementor"); - case WebKit::WebAccessibilityRoleBrowser: - return result.append("Browser"); - case WebKit::WebAccessibilityRoleComboBox: - return result.append("ComboBox"); - case WebKit::WebAccessibilityRoleSplitGroup: - return result.append("SplitGroup"); - case WebKit::WebAccessibilityRoleSplitter: - return result.append("Splitter"); - case WebKit::WebAccessibilityRoleColorWell: - return result.append("ColorWell"); - case WebKit::WebAccessibilityRoleGrowArea: - return result.append("GrowArea"); - case WebKit::WebAccessibilityRoleSheet: - return result.append("Sheet"); - case WebKit::WebAccessibilityRoleHelpTag: - return result.append("HelpTag"); - case WebKit::WebAccessibilityRoleMatte: - return result.append("Matte"); - case WebKit::WebAccessibilityRoleRuler: - return result.append("Ruler"); - case WebKit::WebAccessibilityRoleRulerMarker: - return result.append("RulerMarker"); - case WebKit::WebAccessibilityRoleLink: - return result.append("Link"); - case WebKit::WebAccessibilityRoleDisclosureTriangle: - return result.append("DisclosureTriangle"); - case WebKit::WebAccessibilityRoleGrid: - return result.append("Grid"); - case WebKit::WebAccessibilityRoleCell: - return result.append("Cell"); - case WebKit::WebAccessibilityRoleColumnHeader: - return result.append("ColumnHeader"); - case WebKit::WebAccessibilityRoleRowHeader: - return result.append("RowHeader"); - case WebKit::WebAccessibilityRoleWebCoreLink: - // Maps to Link role. - return result.append("Link"); - case WebKit::WebAccessibilityRoleImageMapLink: - return result.append("ImageMapLink"); - case WebKit::WebAccessibilityRoleImageMap: - return result.append("ImageMap"); - case WebKit::WebAccessibilityRoleListMarker: - return result.append("ListMarker"); - case WebKit::WebAccessibilityRoleWebArea: - return result.append("WebArea"); - case WebKit::WebAccessibilityRoleHeading: - return result.append("Heading"); - case WebKit::WebAccessibilityRoleListBox: - return result.append("ListBox"); - case WebKit::WebAccessibilityRoleListBoxOption: - return result.append("ListBoxOption"); - case WebKit::WebAccessibilityRoleTableHeaderContainer: - return result.append("TableHeaderContainer"); - //case WebKit::WebAccessibilityRoleDefinitionListTerm: - // return result.append("DefinitionListTerm"); - //case WebKit::WebAccessibilityRoleDefinitionListDefinition: - // return result.append("DefinitionListDefinition"); - case WebKit::WebAccessibilityRoleAnnotation: - return result.append("Annotation"); - case WebKit::WebAccessibilityRoleSliderThumb: - return result.append("SliderThumb"); - case WebKit::WebAccessibilityRoleLandmarkApplication: - return result.append("LandmarkApplication"); - case WebKit::WebAccessibilityRoleLandmarkBanner: - return result.append("LandmarkBanner"); - case WebKit::WebAccessibilityRoleLandmarkComplementary: - return result.append("LandmarkComplementary"); - case WebKit::WebAccessibilityRoleLandmarkContentInfo: - return result.append("LandmarkContentInfo"); - case WebKit::WebAccessibilityRoleLandmarkMain: - return result.append("LandmarkMain"); - case WebKit::WebAccessibilityRoleLandmarkNavigation: - return result.append("LandmarkNavigation"); - case WebKit::WebAccessibilityRoleLandmarkSearch: - return result.append("LandmarkSearch"); - case WebKit::WebAccessibilityRoleApplicationLog: - return result.append("ApplicationLog"); - case WebKit::WebAccessibilityRoleApplicationMarquee: - return result.append("ApplicationMarquee"); - case WebKit::WebAccessibilityRoleApplicationStatus: - return result.append("ApplicationStatus"); - case WebKit::WebAccessibilityRoleApplicationTimer: - return result.append("ApplicationTimer"); - case WebKit::WebAccessibilityRoleDocument: - return result.append("Document"); - case WebKit::WebAccessibilityRoleDocumentArticle: - return result.append("DocumentArticle"); - case WebKit::WebAccessibilityRoleDocumentNote: - return result.append("DocumentNote"); - case WebKit::WebAccessibilityRoleDocumentRegion: - return result.append("DocumentRegion"); - case WebKit::WebAccessibilityRoleUserInterfaceTooltip: - return result.append("UserInterfaceTooltip"); - default: - // Also matches WebAccessibilityRoleUnknown. - return result.append("Unknown"); - } -} - -std::string GetDescription(const WebAccessibilityObject& object) { - std::string description = object.accessibilityDescription().utf8(); - return description.insert(0, "AXDescription: "); -} - -std::string GetRole(const WebAccessibilityObject& object) { - return RoleToString(object.roleValue()); -} - -std::string GetTitle(const WebAccessibilityObject& object) { - std::string title = object.title().utf8(); - return title.insert(0, "AXTitle: "); -} - -std::string GetAttributes(const WebAccessibilityObject& object) { - // TODO(dglazkov): Concatenate all attributes of the AccessibilityObject. - std::string attributes(GetTitle(object)); - attributes.append("\n"); - attributes.append(GetRole(object)); - attributes.append("\n"); - attributes.append(GetDescription(object)); - return attributes; -} - - -// Collects attributes into a string, delimited by dashes. Used by all methods -// that output lists of attributes: AttributesOfLinkedUIElementsCallback, -// AttributesOfChildrenCallback, etc. -class AttributesCollector { - public: - void CollectAttributes(const WebAccessibilityObject& object) { - attributes_.append("\n------------\n"); - attributes_.append(GetAttributes(object)); - } - std::string attributes() const { return attributes_; } - -private: - std::string attributes_; -}; - -} // namespace - -AccessibilityUIElement::AccessibilityUIElement( - const WebKit::WebAccessibilityObject& object, - Factory* factory) - : accessibility_object_(object), - factory_(factory) { - - DCHECK(factory); - - BindCallback("allAttributes", - base::Bind(&AccessibilityUIElement::AllAttributesCallback, - base::Unretained(this))); - BindCallback( - "attributesOfLinkedUIElements", - base::Bind(&AccessibilityUIElement::AttributesOfLinkedUIElementsCallback, - base::Unretained(this))); - BindCallback( - "attributesOfDocumentLinks", - base::Bind(&AccessibilityUIElement::AttributesOfDocumentLinksCallback, - base::Unretained(this))); - BindCallback( - "attributesOfChildren", - base::Bind(&AccessibilityUIElement::AttributesOfChildrenCallback, - base::Unretained(this))); - BindCallback( - "parameterizedAttributeNames", - base::Bind(&AccessibilityUIElement::ParametrizedAttributeNamesCallback, - base::Unretained(this))); - BindCallback("lineForIndex", - base::Bind(&AccessibilityUIElement::LineForIndexCallback, - base::Unretained(this))); - BindCallback("boundsForRange", - base::Bind(&AccessibilityUIElement::BoundsForRangeCallback, - base::Unretained(this))); - BindCallback("stringForRange", - base::Bind(&AccessibilityUIElement::StringForRangeCallback, - base::Unretained(this))); - BindCallback("childAtIndex", - base::Bind(&AccessibilityUIElement::ChildAtIndexCallback, - base::Unretained(this))); - BindCallback("elementAtPoint", - base::Bind(&AccessibilityUIElement::ElementAtPointCallback, - base::Unretained(this))); - BindCallback( - "attributesOfColumnHeaders", - base::Bind(&AccessibilityUIElement::AttributesOfColumnHeadersCallback, - base::Unretained(this))); - BindCallback( - "attributesOfRowHeaders", - base::Bind(&AccessibilityUIElement::AttributesOfRowHeadersCallback, - base::Unretained(this))); - BindCallback("attributesOfColumns", - base::Bind(&AccessibilityUIElement::AttributesOfColumnsCallback, - base::Unretained(this))); - BindCallback("attributesOfRows", - base::Bind(&AccessibilityUIElement::AttributesOfRowsCallback, - base::Unretained(this))); - BindCallback( - "attributesOfVisibleCells", - base::Bind(&AccessibilityUIElement::AttributesOfVisibleCellsCallback, - base::Unretained(this))); - BindCallback("attributesOfHeader", - base::Bind(&AccessibilityUIElement::AttributesOfHeaderCallback, - base::Unretained(this))); - BindCallback("indexInTable", - base::Bind(&AccessibilityUIElement::IndexInTableCallback, - base::Unretained(this))); - BindCallback("rowIndexRange", - base::Bind(&AccessibilityUIElement::RowIndexRangeCallback, - base::Unretained(this))); - BindCallback("columnIndexRange", - base::Bind(&AccessibilityUIElement::ColumnIndexRangeCallback, - base::Unretained(this))); - BindCallback("cellForColumnAndRow", - base::Bind(&AccessibilityUIElement::CellForColumnAndRowCallback, - base::Unretained(this))); - BindCallback("titleUIElement", - base::Bind(&AccessibilityUIElement::TitleUIElementCallback, - base::Unretained(this))); - BindCallback("setSelectedTextRange", - base::Bind(&AccessibilityUIElement::SetSelectedTextRangeCallback, - base::Unretained(this))); - BindCallback("attributeValue", - base::Bind(&AccessibilityUIElement::AttributeValueCallback, - base::Unretained(this))); - BindCallback("isAttributeSettable", - base::Bind(&AccessibilityUIElement::IsAttributeSettableCallback, - base::Unretained(this))); - BindCallback("isActionSupported", - base::Bind(&AccessibilityUIElement::IsActionSupportedCallback, - base::Unretained(this))); - BindCallback("parentElement", - base::Bind(&AccessibilityUIElement::ParentElementCallback, - base::Unretained(this))); - BindCallback("increment", - base::Bind(&AccessibilityUIElement::IncrementCallback, - base::Unretained(this))); - BindCallback("decrement", - base::Bind(&AccessibilityUIElement::DecrementCallback, - base::Unretained(this))); - - BindGetterCallback("role", - base::Bind(&AccessibilityUIElement::RoleGetterCallback, - base::Unretained(this))); - BindProperty("subrole", &subrole_); - BindGetterCallback("title", - base::Bind(&AccessibilityUIElement::TitleGetterCallback, - base::Unretained(this))); - BindGetterCallback( - "description", - base::Bind(&AccessibilityUIElement::DescriptionGetterCallback, - base::Unretained(this))); - BindProperty("language", &language_); - BindProperty("x", &x_); - BindProperty("y", &y_); - BindProperty("width", &width_); - BindProperty("height", &height_); - BindProperty("clickPointX", &click_point_x_); - BindProperty("clickPointY", &click_point_y_); - BindProperty("intValue", &int_value_); - BindProperty("minValue", &min_value_); - BindProperty("maxValue", &max_value_); - BindGetterCallback( - "childrenCount", - base::Bind(&AccessibilityUIElement::ChildrenCountGetterCallback, - base::Unretained(this))); - BindProperty("insertionPointLineNumber", &insertion_point_line_number_); - BindProperty("selectedTextRange", &selected_text_range); - BindGetterCallback( - "isEnabled", - base::Bind(&AccessibilityUIElement::IsEnabledGetterCallback, - base::Unretained(this))); - BindProperty("isRequired", &is_required_); - BindGetterCallback( - "isSelected", - base::Bind(&AccessibilityUIElement::IsSelectedGetterCallback, - base::Unretained(this))); - BindProperty("valueDescription", &value_description_); - - BindFallbackCallback(base::Bind(&AccessibilityUIElement::FallbackCallback, - base::Unretained(this))); -} - -AccessibilityUIElement::~AccessibilityUIElement() {} - -AccessibilityUIElement* AccessibilityUIElement::GetChildAtIndex( - unsigned index) { - return factory_->Create(accessibility_object().childAt(index)); -} - -bool AccessibilityUIElement::IsRoot() const { - return false; -} - -void AccessibilityUIElement::AllAttributesCallback( - const CppArgumentList& args, CppVariant* result) { - result->Set(GetAttributes(accessibility_object())); -} - -void AccessibilityUIElement::AttributesOfLinkedUIElementsCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributesOfDocumentLinksCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributesOfChildrenCallback( - const CppArgumentList& args, CppVariant* result) { - AttributesCollector collector; - unsigned size = accessibility_object().childCount(); - for(unsigned i = 0; i < size; ++i) { - collector.CollectAttributes(accessibility_object().childAt(i)); - } - result->Set(collector.attributes()); -} - -void AccessibilityUIElement::ParametrizedAttributeNamesCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::LineForIndexCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::BoundsForRangeCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::StringForRangeCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::ChildAtIndexCallback( - const CppArgumentList& args, CppVariant* result) { - if (args.empty() || !args[0].isNumber()) { - result->SetNull(); - return; - } - - AccessibilityUIElement* child = GetChildAtIndex(args[0].ToInt32()); - if (!child) { - result->SetNull(); - return; - } - - result->Set(*(child->GetAsCppVariant())); -} - -void AccessibilityUIElement::ElementAtPointCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributesOfColumnHeadersCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributesOfRowHeadersCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributesOfColumnsCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributesOfRowsCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributesOfVisibleCellsCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributesOfHeaderCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::IndexInTableCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::RowIndexRangeCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::ColumnIndexRangeCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::CellForColumnAndRowCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::TitleUIElementCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::SetSelectedTextRangeCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::AttributeValueCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::IsAttributeSettableCallback( - const CppArgumentList& args, CppVariant* result) { - if (args.size() < 1 && !args[0].isString()) { - result->SetNull(); - return; - } - - std::string attribute = args[0].ToString(); - bool settable = false; - if (attribute == "AXValue") { - settable = accessibility_object().canSetValueAttribute(); - } - result->Set(settable); -} - -void AccessibilityUIElement::IsActionSupportedCallback( - const CppArgumentList& args, CppVariant* result) { - // This one may be really hard to implement. - // Not exposed by AccessibilityObject. - result->SetNull(); -} - -void AccessibilityUIElement::ParentElementCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::IncrementCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::DecrementCallback( - const CppArgumentList& args, CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::FallbackCallback(const CppArgumentList &args, - CppVariant *result) { - // TODO(dglazkov): Implement this. - result->SetNull(); -} - -void AccessibilityUIElement::ChildrenCountGetterCallback(CppVariant* result) { - int count = 1; // Root object always has only one child, the WebView. - if (!IsRoot()) - count = accessibility_object().childCount(); - result->Set(count); -} - -void AccessibilityUIElement::DescriptionGetterCallback(CppVariant *result) { - result->Set(GetDescription(accessibility_object())); -} - -void AccessibilityUIElement::IsEnabledGetterCallback(CppVariant* result) { - result->Set(accessibility_object().isEnabled()); -} - -void AccessibilityUIElement::IsSelectedGetterCallback(CppVariant* result) { - result->SetNull(); -} - -void AccessibilityUIElement::RoleGetterCallback(CppVariant* result) { - result->Set(GetRole(accessibility_object())); -} - -void AccessibilityUIElement::TitleGetterCallback(CppVariant* result) { - result->Set(GetTitle(accessibility_object())); -} - -RootAccessibilityUIElement::RootAccessibilityUIElement( - const WebKit::WebAccessibilityObject &object, - Factory *factory) - : AccessibilityUIElement(object, factory) {} - -RootAccessibilityUIElement::~RootAccessibilityUIElement() {} - -AccessibilityUIElement* RootAccessibilityUIElement::GetChildAtIndex( - unsigned index) { - if (index != 0) - return NULL; - - return factory()->Create(accessibility_object()); -} - -bool RootAccessibilityUIElement::IsRoot() const { - return true; -} - -AccessibilityUIElementList::AccessibilityUIElementList() {} - -AccessibilityUIElementList::~AccessibilityUIElementList() { - Clear(); -} - -void AccessibilityUIElementList::Clear() { - for (ElementList::iterator i = elements_.begin(); i != elements_.end(); ++i) - delete (*i); - elements_.clear(); -} - -AccessibilityUIElement* AccessibilityUIElementList::Create( - const WebAccessibilityObject& object) { - if (object.isNull()) - return NULL; - - AccessibilityUIElement* element = new AccessibilityUIElement(object, this); - elements_.push_back(element); - return element; -} - -AccessibilityUIElement* AccessibilityUIElementList::CreateRoot( - const WebAccessibilityObject& object) { - AccessibilityUIElement* element = - new RootAccessibilityUIElement(object, this); - elements_.push_back(element); - return element; -} diff --git a/webkit/tools/test_shell/accessibility_ui_element.h b/webkit/tools/test_shell/accessibility_ui_element.h deleted file mode 100644 index d930177..0000000 --- a/webkit/tools/test_shell/accessibility_ui_element.h +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_ACCESSIBILITY_UI_ELEMENT_H_ -#define WEBKIT_TOOLS_TEST_SHELL_ACCESSIBILITY_UI_ELEMENT_H_ - -#include "webkit/glue/cpp_bound_class.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" - -class AccessibilityUIElement : public webkit_glue::CppBoundClass { - public: - class Factory { - public: - virtual ~Factory() { } - virtual AccessibilityUIElement* Create( - const WebKit::WebAccessibilityObject& object) = 0; - }; - - AccessibilityUIElement( - const WebKit::WebAccessibilityObject& accessibility_object, - Factory* factory); - virtual ~AccessibilityUIElement(); - - virtual AccessibilityUIElement* GetChildAtIndex(unsigned index); - virtual bool IsRoot() const; - - protected: - const WebKit::WebAccessibilityObject& accessibility_object() const { - return accessibility_object_; - } - Factory* factory() const { return factory_; } - - private: - // Bound methods and properties. - void AllAttributesCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfLinkedUIElementsCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfDocumentLinksCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfChildrenCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void ParametrizedAttributeNamesCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void LineForIndexCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void BoundsForRangeCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void StringForRangeCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void ChildAtIndexCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void ElementAtPointCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfColumnHeadersCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfRowHeadersCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfColumnsCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfRowsCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfVisibleCellsCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributesOfHeaderCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void IndexInTableCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void RowIndexRangeCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void ColumnIndexRangeCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void CellForColumnAndRowCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void TitleUIElementCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void SetSelectedTextRangeCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void AttributeValueCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void IsAttributeSettableCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void IsActionSupportedCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void ParentElementCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void IncrementCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void DecrementCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - void FallbackCallback( - const webkit_glue::CppArgumentList& args, - webkit_glue::CppVariant* result); - - void ChildrenCountGetterCallback(webkit_glue::CppVariant* result); - void DescriptionGetterCallback(webkit_glue::CppVariant* result); - void IsEnabledGetterCallback(webkit_glue::CppVariant* result); - void IsSelectedGetterCallback(webkit_glue::CppVariant* result); - void RoleGetterCallback(webkit_glue::CppVariant* result); - void TitleGetterCallback(webkit_glue::CppVariant* result); - - webkit_glue::CppVariant subrole_; - webkit_glue::CppVariant language_; - webkit_glue::CppVariant x_; - webkit_glue::CppVariant y_; - webkit_glue::CppVariant width_; - webkit_glue::CppVariant height_; - webkit_glue::CppVariant click_point_x_; - webkit_glue::CppVariant click_point_y_; - webkit_glue::CppVariant int_value_; - webkit_glue::CppVariant min_value_; - webkit_glue::CppVariant max_value_; - webkit_glue::CppVariant children_count_; - webkit_glue::CppVariant insertion_point_line_number_; - webkit_glue::CppVariant selected_text_range; - webkit_glue::CppVariant is_required_; - webkit_glue::CppVariant value_description_; - - WebKit::WebAccessibilityObject accessibility_object_; - Factory* factory_; -}; - - -class RootAccessibilityUIElement : public AccessibilityUIElement { - public: - RootAccessibilityUIElement( - const WebKit::WebAccessibilityObject& accessibility_object, - Factory* factory); - virtual ~RootAccessibilityUIElement(); - - virtual AccessibilityUIElement* GetChildAtIndex(unsigned index) OVERRIDE; - virtual bool IsRoot() const OVERRIDE; -}; - - -// Provides simple lifetime management of the AccessibilityUIElement instances: -// all AccessibilityUIElements ever created from the controller are stored in -// a list and cleared explicitly. -class AccessibilityUIElementList : public AccessibilityUIElement::Factory { - public: - AccessibilityUIElementList(); - virtual ~AccessibilityUIElementList(); - - void Clear(); - virtual AccessibilityUIElement* Create( - const WebKit::WebAccessibilityObject& object) OVERRIDE; - AccessibilityUIElement* CreateRoot( - const WebKit::WebAccessibilityObject& object); - - private: - typedef std::vector<AccessibilityUIElement*> ElementList; - ElementList elements_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_ACCESSIBILITY_UI_ELEMENT_H_ diff --git a/webkit/tools/test_shell/drop_delegate.cc b/webkit/tools/test_shell/drop_delegate.cc deleted file mode 100644 index 069ea41..0000000 --- a/webkit/tools/test_shell/drop_delegate.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/drop_delegate.h" - -#include "third_party/WebKit/Source/Platform/chromium/public/WebDragData.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "webkit/glue/webdropdata.h" - -using WebKit::WebDragOperation; -using WebKit::WebDragOperationCopy; -using WebKit::WebPoint; -using WebKit::WebView; - -TestDropDelegate::TestDropDelegate(HWND source_hwnd, WebKit::WebView* webview) - : ui::DropTargetWin(source_hwnd), - webview_(webview) { -} - -DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object, - DWORD key_state, - POINT cursor_position, - DWORD effect) { - WebDropData drop_data; - WebDropData::PopulateWebDropData(data_object, &drop_data); - - POINT client_pt = cursor_position; - ScreenToClient(GetHWND(), &client_pt); - WebDragOperation op = webview_->dragTargetDragEnter( - drop_data.ToDragData(), - WebPoint(client_pt.x, client_pt.y), - WebPoint(cursor_position.x, cursor_position.y), - WebDragOperationCopy, - 0); - // TODO(snej): Pass the real drag operation instead - return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; - // TODO(snej): Return the real drop effect constant matching 'op' -} - -DWORD TestDropDelegate::OnDragOver(IDataObject* data_object, - DWORD key_state, - POINT cursor_position, - DWORD effect) { - POINT client_pt = cursor_position; - ScreenToClient(GetHWND(), &client_pt); - WebDragOperation op = webview_->dragTargetDragOver( - WebPoint(client_pt.x, client_pt.y), - WebPoint(cursor_position.x, cursor_position.y), - WebDragOperationCopy, - 0); - // TODO(snej): Pass the real drag operation instead - return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; - // TODO(snej): Return the real drop effect constant matching 'op' -} - -void TestDropDelegate::OnDragLeave(IDataObject* data_object) { - webview_->dragTargetDragLeave(); -} - -DWORD TestDropDelegate::OnDrop(IDataObject* data_object, - DWORD key_state, - POINT cursor_position, - DWORD effect) { - POINT client_pt = cursor_position; - ScreenToClient(GetHWND(), &client_pt); - webview_->dragTargetDrop( - WebPoint(client_pt.x, client_pt.y), - WebPoint(cursor_position.x, cursor_position.y), - 0); - - // webkit win port always returns DROPEFFECT_NONE - return DROPEFFECT_NONE; -} diff --git a/webkit/tools/test_shell/drop_delegate.h b/webkit/tools/test_shell/drop_delegate.h deleted file mode 100644 index ac35f1b..0000000 --- a/webkit/tools/test_shell/drop_delegate.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// A class that implements BaseDropTarget for the test shell webview delegate. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_DROP_DELEGATE_H_ -#define WEBKIT_TOOLS_TEST_SHELL_DROP_DELEGATE_H_ - -#include "ui/base/dragdrop/drop_target_win.h" - -namespace WebKit { -class WebView; -} - -class TestDropDelegate : public ui::DropTargetWin { - public: - TestDropDelegate(HWND source_hwnd, WebKit::WebView* webview); - - protected: - // BaseDropTarget methods - virtual DWORD OnDragEnter(IDataObject* data_object, - DWORD key_state, - POINT cursor_position, - DWORD effect); - virtual DWORD OnDragOver(IDataObject* data_object, - DWORD key_state, - POINT cursor_position, - DWORD effect); - virtual void OnDragLeave(IDataObject* data_object); - virtual DWORD OnDrop(IDataObject* data_object, - DWORD key_state, - POINT cursor_position, - DWORD effect); - - private: - WebKit::WebView* webview_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_DROP_DELEGATE_H_ diff --git a/webkit/tools/test_shell/mac/English.lproj/InfoPlist.strings b/webkit/tools/test_shell/mac/English.lproj/InfoPlist.strings deleted file mode 100644 index 08ec43b..0000000 --- a/webkit/tools/test_shell/mac/English.lproj/InfoPlist.strings +++ /dev/null @@ -1,3 +0,0 @@ -/* Localized versions of Info.plist keys */ - -NSHumanReadableCopyright = "© Google Inc, 2008"; diff --git a/webkit/tools/test_shell/mac/English.lproj/MainMenu.xib b/webkit/tools/test_shell/mac/English.lproj/MainMenu.xib deleted file mode 100644 index 99ca9dd..0000000 --- a/webkit/tools/test_shell/mac/English.lproj/MainMenu.xib +++ /dev/null @@ -1,2072 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> - <data> - <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9L31a</string> - <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.54</string> - <string key="IBDocument.HIToolboxVersion">353.00</string> - <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> - <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="57"/> - </object> - <object class="NSArray" key="IBDocument.PluginDependencies"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - </object> - <object class="NSMutableDictionary" key="IBDocument.Metadata"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - </object> - <object class="NSMutableArray" key="IBDocument.RootObjects" id="1048"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSCustomObject" id="1021"> - <string key="NSClassName">NSApplication</string> - </object> - <object class="NSCustomObject" id="1014"> - <string key="NSClassName">FirstResponder</string> - </object> - <object class="NSCustomObject" id="1050"> - <string key="NSClassName">NSApplication</string> - </object> - <object class="NSMenu" id="649796088"> - <string key="NSTitle">AMainMenu</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="694149608"> - <reference key="NSMenu" ref="649796088"/> - <string key="NSTitle">TestShell</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <object class="NSCustomResource" key="NSOnImage" id="293900348"> - <string key="NSClassName">NSImage</string> - <string key="NSResourceName">NSMenuCheckmark</string> - </object> - <object class="NSCustomResource" key="NSMixedImage" id="169361956"> - <string key="NSClassName">NSImage</string> - <string key="NSResourceName">NSMenuMixedState</string> - </object> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="110575045"> - <string key="NSTitle">TestShell</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="238522557"> - <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">About TestShell</string> - <string key="NSKeyEquiv"/> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="304266470"> - <reference key="NSMenu" ref="110575045"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="609285721"> - <reference key="NSMenu" ref="110575045"/> - <string type="base64-UTF8" key="NSTitle">UHJlZmVyZW5jZXPigKY</string> - <string key="NSKeyEquiv">,</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="481834944"> - <reference key="NSMenu" ref="110575045"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="1046388886"> - <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">Services</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="752062318"> - <string key="NSTitle">Services</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <string key="NSName">_NSServicesMenu</string> - </object> - </object> - <object class="NSMenuItem" id="646227648"> - <reference key="NSMenu" ref="110575045"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="755159360"> - <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">Hide TestShell</string> - <string key="NSKeyEquiv">h</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="342932134"> - <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">Hide Others</string> - <string key="NSKeyEquiv">h</string> - <int key="NSKeyEquivModMask">1572864</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="908899353"> - <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">Show All</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="1056857174"> - <reference key="NSMenu" ref="110575045"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="632727374"> - <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">Quit TestShell</string> - <string key="NSKeyEquiv">q</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - <string key="NSName">_NSAppleMenu</string> - </object> - </object> - <object class="NSMenuItem" id="379814623"> - <reference key="NSMenu" ref="649796088"/> - <string key="NSTitle">File</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="720053764"> - <string key="NSTitle">File</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="705341025"> - <reference key="NSMenu" ref="720053764"/> - <string key="NSTitle">New</string> - <string key="NSKeyEquiv">n</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="722745758"> - <reference key="NSMenu" ref="720053764"/> - <string type="base64-UTF8" key="NSTitle">T3BlbuKApg</string> - <string key="NSKeyEquiv">o</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="1025936716"> - <reference key="NSMenu" ref="720053764"/> - <string key="NSTitle">Open Recent</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="1065607017"> - <string key="NSTitle">Open Recent</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="759406840"> - <reference key="NSMenu" ref="1065607017"/> - <string key="NSTitle">Clear Menu</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - <string key="NSName">_NSRecentDocumentsMenu</string> - </object> - </object> - <object class="NSMenuItem" id="425164168"> - <reference key="NSMenu" ref="720053764"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="776162233"> - <reference key="NSMenu" ref="720053764"/> - <string key="NSTitle">Close</string> - <string key="NSKeyEquiv">w</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="1023925487"> - <reference key="NSMenu" ref="720053764"/> - <string key="NSTitle">Save</string> - <string key="NSKeyEquiv">s</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="117038363"> - <reference key="NSMenu" ref="720053764"/> - <string type="base64-UTF8" key="NSTitle">U2F2ZSBBc+KApg</string> - <string key="NSKeyEquiv">S</string> - <int key="NSKeyEquivModMask">1179648</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="579971712"> - <reference key="NSMenu" ref="720053764"/> - <string key="NSTitle">Revert to Saved</string> - <string key="NSKeyEquiv"/> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="1010469920"> - <reference key="NSMenu" ref="720053764"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="294629803"> - <reference key="NSMenu" ref="720053764"/> - <string key="NSTitle">Page Setup...</string> - <string key="NSKeyEquiv">P</string> - <int key="NSKeyEquivModMask">1179648</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSToolTip"/> - </object> - <object class="NSMenuItem" id="49223823"> - <reference key="NSMenu" ref="720053764"/> - <string type="base64-UTF8" key="NSTitle">UHJpbnTigKY</string> - <string key="NSKeyEquiv">p</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - </object> - </object> - <object class="NSMenuItem" id="952259628"> - <reference key="NSMenu" ref="649796088"/> - <string key="NSTitle">Edit</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="789758025"> - <string key="NSTitle">Edit</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="1058277027"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Undo</string> - <string key="NSKeyEquiv">z</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="790794224"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Redo</string> - <string key="NSKeyEquiv">Z</string> - <int key="NSKeyEquivModMask">1179648</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="1040322652"> - <reference key="NSMenu" ref="789758025"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="296257095"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Cut</string> - <string key="NSKeyEquiv">x</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="860595796"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Copy</string> - <string key="NSKeyEquiv">c</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="29853731"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Paste</string> - <string key="NSKeyEquiv">v</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="437104165"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Delete</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="583158037"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Select All</string> - <string key="NSKeyEquiv">a</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="212016141"> - <reference key="NSMenu" ref="789758025"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="892235320"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Find</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="963351320"> - <string key="NSTitle">Find</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="447796847"> - <reference key="NSMenu" ref="963351320"/> - <string type="base64-UTF8" key="NSTitle">RmluZOKApg</string> - <string key="NSKeyEquiv">f</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <int key="NSTag">1</int> - </object> - <object class="NSMenuItem" id="326711663"> - <reference key="NSMenu" ref="963351320"/> - <string key="NSTitle">Find Next</string> - <string key="NSKeyEquiv">g</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <int key="NSTag">2</int> - </object> - <object class="NSMenuItem" id="270902937"> - <reference key="NSMenu" ref="963351320"/> - <string key="NSTitle">Find Previous</string> - <string key="NSKeyEquiv">G</string> - <int key="NSKeyEquivModMask">1179648</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <int key="NSTag">3</int> - </object> - <object class="NSMenuItem" id="159080638"> - <reference key="NSMenu" ref="963351320"/> - <string key="NSTitle">Use Selection for Find</string> - <string key="NSKeyEquiv">e</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <int key="NSTag">7</int> - </object> - <object class="NSMenuItem" id="88285865"> - <reference key="NSMenu" ref="963351320"/> - <string key="NSTitle">Jump to Selection</string> - <string key="NSKeyEquiv">j</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - </object> - </object> - <object class="NSMenuItem" id="972420730"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Spelling and Grammar</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="769623530"> - <string key="NSTitle">Spelling and Grammar</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="679648819"> - <reference key="NSMenu" ref="769623530"/> - <string type="base64-UTF8" key="NSTitle">U2hvdyBTcGVsbGluZ+KApg</string> - <string key="NSKeyEquiv">:</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="96193923"> - <reference key="NSMenu" ref="769623530"/> - <string key="NSTitle">Check Spelling</string> - <string key="NSKeyEquiv">;</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="948374510"> - <reference key="NSMenu" ref="769623530"/> - <string key="NSTitle">Check Spelling While Typing</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="967646866"> - <reference key="NSMenu" ref="769623530"/> - <string key="NSTitle">Check Grammar With Spelling</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - </object> - </object> - <object class="NSMenuItem" id="507821607"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Substitutions</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="698887838"> - <string key="NSTitle">Substitutions</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="605118523"> - <reference key="NSMenu" ref="698887838"/> - <string key="NSTitle">Smart Copy/Paste</string> - <string key="NSKeyEquiv">f</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <int key="NSTag">1</int> - </object> - <object class="NSMenuItem" id="197661976"> - <reference key="NSMenu" ref="698887838"/> - <string key="NSTitle">Smart Quotes</string> - <string key="NSKeyEquiv">g</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <int key="NSTag">2</int> - </object> - <object class="NSMenuItem" id="708854459"> - <reference key="NSMenu" ref="698887838"/> - <string key="NSTitle">Smart Links</string> - <string key="NSKeyEquiv">G</string> - <int key="NSKeyEquivModMask">1179648</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <int key="NSTag">3</int> - </object> - </object> - </object> - </object> - <object class="NSMenuItem" id="676164635"> - <reference key="NSMenu" ref="789758025"/> - <string key="NSTitle">Speech</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="785027613"> - <string key="NSTitle">Speech</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="731782645"> - <reference key="NSMenu" ref="785027613"/> - <string key="NSTitle">Start Speaking</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="680220178"> - <reference key="NSMenu" ref="785027613"/> - <string key="NSTitle">Stop Speaking</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - </object> - </object> - </object> - </object> - </object> - <object class="NSMenuItem" id="626404410"> - <reference key="NSMenu" ref="649796088"/> - <string key="NSTitle">Format</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="502084290"> - <string key="NSTitle">Format</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="519768076"> - <reference key="NSMenu" ref="502084290"/> - <string key="NSTitle">Show Fonts</string> - <string key="NSKeyEquiv">t</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="1028416764"> - <reference key="NSMenu" ref="502084290"/> - <string key="NSTitle">Show Colors</string> - <string key="NSKeyEquiv">C</string> - <int key="NSKeyEquivModMask">1179648</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - </object> - </object> - <object class="NSMenuItem" id="586577488"> - <reference key="NSMenu" ref="649796088"/> - <string key="NSTitle">View</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="466310130"> - <string key="NSTitle">View</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="102151532"> - <reference key="NSMenu" ref="466310130"/> - <string key="NSTitle">Show Toolbar</string> - <string key="NSKeyEquiv">t</string> - <int key="NSKeyEquivModMask">1572864</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="237841660"> - <reference key="NSMenu" ref="466310130"/> - <string type="base64-UTF8" key="NSTitle">Q3VzdG9taXplIFRvb2xiYXLigKY</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - </object> - </object> - <object class="NSMenuItem" id="713487014"> - <reference key="NSMenu" ref="649796088"/> - <string key="NSTitle">Window</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="835318025"> - <string key="NSTitle">Window</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="1011231497"> - <reference key="NSMenu" ref="835318025"/> - <string key="NSTitle">Minimize</string> - <string key="NSKeyEquiv">m</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="575023229"> - <reference key="NSMenu" ref="835318025"/> - <string key="NSTitle">Zoom</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="299356726"> - <reference key="NSMenu" ref="835318025"/> - <bool key="NSIsDisabled">YES</bool> - <bool key="NSIsSeparator">YES</bool> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - <object class="NSMenuItem" id="625202149"> - <reference key="NSMenu" ref="835318025"/> - <string key="NSTitle">Bring All to Front</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - <string key="NSName">_NSWindowsMenu</string> - </object> - </object> - <object class="NSMenuItem" id="391199113"> - <reference key="NSMenu" ref="649796088"/> - <string key="NSTitle">Help</string> - <string key="NSKeyEquiv"/> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - <string key="NSAction">submenuAction:</string> - <object class="NSMenu" key="NSSubmenu" id="374024848"> - <string key="NSTitle">Help</string> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="238773614"> - <reference key="NSMenu" ref="374024848"/> - <string key="NSTitle">TestShell Help</string> - <string key="NSKeyEquiv">?</string> - <int key="NSKeyEquivModMask">1048576</int> - <int key="NSMnemonicLoc">2147483647</int> - <reference key="NSOnImage" ref="293900348"/> - <reference key="NSMixedImage" ref="169361956"/> - </object> - </object> - </object> - </object> - </object> - <string key="NSName">_NSMainMenu</string> - </object> - <object class="NSUserDefaultsController" id="143541711"> - <bool key="NSSharedInstance">YES</bool> - </object> - </object> - <object class="IBObjectContainer" key="IBDocument.Objects"> - <object class="NSMutableArray" key="connectionRecords"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">performMiniaturize:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="1011231497"/> - </object> - <int key="connectionID">37</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">arrangeInFront:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="625202149"/> - </object> - <int key="connectionID">39</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">print:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="49223823"/> - </object> - <int key="connectionID">86</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">runPageLayout:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="294629803"/> - </object> - <int key="connectionID">87</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">clearRecentDocuments:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="759406840"/> - </object> - <int key="connectionID">127</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">orderFrontStandardAboutPanel:</string> - <reference key="source" ref="1021"/> - <reference key="destination" ref="238522557"/> - </object> - <int key="connectionID">142</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">performClose:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="776162233"/> - </object> - <int key="connectionID">193</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">toggleContinuousSpellChecking:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="948374510"/> - </object> - <int key="connectionID">222</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">undo:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="1058277027"/> - </object> - <int key="connectionID">223</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">copy:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="860595796"/> - </object> - <int key="connectionID">224</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">checkSpelling:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="96193923"/> - </object> - <int key="connectionID">225</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">paste:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="29853731"/> - </object> - <int key="connectionID">226</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">stopSpeaking:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="680220178"/> - </object> - <int key="connectionID">227</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">cut:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="296257095"/> - </object> - <int key="connectionID">228</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">showGuessPanel:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="679648819"/> - </object> - <int key="connectionID">230</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">redo:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="790794224"/> - </object> - <int key="connectionID">231</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">selectAll:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="583158037"/> - </object> - <int key="connectionID">232</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">startSpeaking:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="731782645"/> - </object> - <int key="connectionID">233</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">delete:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="437104165"/> - </object> - <int key="connectionID">235</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">performZoom:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="575023229"/> - </object> - <int key="connectionID">240</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">performFindPanelAction:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="447796847"/> - </object> - <int key="connectionID">241</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">centerSelectionInVisibleArea:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="88285865"/> - </object> - <int key="connectionID">245</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">toggleGrammarChecking:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="967646866"/> - </object> - <int key="connectionID">347</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">toggleSmartInsertDelete:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="605118523"/> - </object> - <int key="connectionID">355</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">toggleAutomaticQuoteSubstitution:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="197661976"/> - </object> - <int key="connectionID">356</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">toggleAutomaticLinkDetection:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="708854459"/> - </object> - <int key="connectionID">357</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">showHelp:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="238773614"/> - </object> - <int key="connectionID">360</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">orderFrontColorPanel:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="1028416764"/> - </object> - <int key="connectionID">361</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">saveDocument:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="1023925487"/> - </object> - <int key="connectionID">362</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">saveDocumentAs:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="117038363"/> - </object> - <int key="connectionID">363</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">revertDocumentToSaved:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="579971712"/> - </object> - <int key="connectionID">364</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">runToolbarCustomizationPalette:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="237841660"/> - </object> - <int key="connectionID">365</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">toggleToolbarShown:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="102151532"/> - </object> - <int key="connectionID">366</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">hide:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="755159360"/> - </object> - <int key="connectionID">367</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">hideOtherApplications:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="342932134"/> - </object> - <int key="connectionID">368</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">terminate:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="632727374"/> - </object> - <int key="connectionID">369</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">unhideAllApplications:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="908899353"/> - </object> - <int key="connectionID">370</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">newDocument:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="705341025"/> - </object> - <int key="connectionID">373</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">openDocument:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="722745758"/> - </object> - <int key="connectionID">374</int> - </object> - </object> - <object class="IBMutableOrderedSet" key="objectRecords"> - <object class="NSArray" key="orderedObjects"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBObjectRecord"> - <int key="objectID">0</int> - <object class="NSArray" key="object" id="755588897"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <reference key="children" ref="1048"/> - <nil key="parent"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">-2</int> - <reference key="object" ref="1021"/> - <reference key="parent" ref="755588897"/> - <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">-1</int> - <reference key="object" ref="1014"/> - <reference key="parent" ref="755588897"/> - <string key="objectName">First Responder</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">-3</int> - <reference key="object" ref="1050"/> - <reference key="parent" ref="755588897"/> - <string key="objectName">Application</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">29</int> - <reference key="object" ref="649796088"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="713487014"/> - <reference ref="694149608"/> - <reference ref="391199113"/> - <reference ref="952259628"/> - <reference ref="379814623"/> - <reference ref="586577488"/> - <reference ref="626404410"/> - </object> - <reference key="parent" ref="755588897"/> - <string key="objectName">MainMenu</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">19</int> - <reference key="object" ref="713487014"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="835318025"/> - </object> - <reference key="parent" ref="649796088"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">56</int> - <reference key="object" ref="694149608"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="110575045"/> - </object> - <reference key="parent" ref="649796088"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">103</int> - <reference key="object" ref="391199113"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="374024848"/> - </object> - <reference key="parent" ref="649796088"/> - <string key="objectName">1</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">217</int> - <reference key="object" ref="952259628"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="789758025"/> - </object> - <reference key="parent" ref="649796088"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">83</int> - <reference key="object" ref="379814623"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="720053764"/> - </object> - <reference key="parent" ref="649796088"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">81</int> - <reference key="object" ref="720053764"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="1023925487"/> - <reference ref="117038363"/> - <reference ref="49223823"/> - <reference ref="722745758"/> - <reference ref="705341025"/> - <reference ref="1025936716"/> - <reference ref="294629803"/> - <reference ref="776162233"/> - <reference ref="425164168"/> - <reference ref="579971712"/> - <reference ref="1010469920"/> - </object> - <reference key="parent" ref="379814623"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">75</int> - <reference key="object" ref="1023925487"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">3</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">80</int> - <reference key="object" ref="117038363"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">8</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">78</int> - <reference key="object" ref="49223823"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">6</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">72</int> - <reference key="object" ref="722745758"/> - <reference key="parent" ref="720053764"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">82</int> - <reference key="object" ref="705341025"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">9</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">124</int> - <reference key="object" ref="1025936716"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="1065607017"/> - </object> - <reference key="parent" ref="720053764"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">77</int> - <reference key="object" ref="294629803"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">5</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">73</int> - <reference key="object" ref="776162233"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">1</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">79</int> - <reference key="object" ref="425164168"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">7</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">112</int> - <reference key="object" ref="579971712"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">10</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">74</int> - <reference key="object" ref="1010469920"/> - <reference key="parent" ref="720053764"/> - <string key="objectName">2</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">125</int> - <reference key="object" ref="1065607017"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="759406840"/> - </object> - <reference key="parent" ref="1025936716"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">126</int> - <reference key="object" ref="759406840"/> - <reference key="parent" ref="1065607017"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">205</int> - <reference key="object" ref="789758025"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="437104165"/> - <reference ref="583158037"/> - <reference ref="1058277027"/> - <reference ref="212016141"/> - <reference ref="296257095"/> - <reference ref="29853731"/> - <reference ref="860595796"/> - <reference ref="1040322652"/> - <reference ref="790794224"/> - <reference ref="892235320"/> - <reference ref="972420730"/> - <reference ref="676164635"/> - <reference ref="507821607"/> - </object> - <reference key="parent" ref="952259628"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">202</int> - <reference key="object" ref="437104165"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">198</int> - <reference key="object" ref="583158037"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">207</int> - <reference key="object" ref="1058277027"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">214</int> - <reference key="object" ref="212016141"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">199</int> - <reference key="object" ref="296257095"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">203</int> - <reference key="object" ref="29853731"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">197</int> - <reference key="object" ref="860595796"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">206</int> - <reference key="object" ref="1040322652"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">215</int> - <reference key="object" ref="790794224"/> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">218</int> - <reference key="object" ref="892235320"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="963351320"/> - </object> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">216</int> - <reference key="object" ref="972420730"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="769623530"/> - </object> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">200</int> - <reference key="object" ref="769623530"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="948374510"/> - <reference ref="96193923"/> - <reference ref="679648819"/> - <reference ref="967646866"/> - </object> - <reference key="parent" ref="972420730"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">219</int> - <reference key="object" ref="948374510"/> - <reference key="parent" ref="769623530"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">201</int> - <reference key="object" ref="96193923"/> - <reference key="parent" ref="769623530"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">204</int> - <reference key="object" ref="679648819"/> - <reference key="parent" ref="769623530"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">220</int> - <reference key="object" ref="963351320"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="270902937"/> - <reference ref="88285865"/> - <reference ref="159080638"/> - <reference ref="326711663"/> - <reference ref="447796847"/> - </object> - <reference key="parent" ref="892235320"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">213</int> - <reference key="object" ref="270902937"/> - <reference key="parent" ref="963351320"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">210</int> - <reference key="object" ref="88285865"/> - <reference key="parent" ref="963351320"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">221</int> - <reference key="object" ref="159080638"/> - <reference key="parent" ref="963351320"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">208</int> - <reference key="object" ref="326711663"/> - <reference key="parent" ref="963351320"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">209</int> - <reference key="object" ref="447796847"/> - <reference key="parent" ref="963351320"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">106</int> - <reference key="object" ref="374024848"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="238773614"/> - </object> - <reference key="parent" ref="391199113"/> - <string key="objectName">2</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">111</int> - <reference key="object" ref="238773614"/> - <reference key="parent" ref="374024848"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">57</int> - <reference key="object" ref="110575045"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="238522557"/> - <reference ref="755159360"/> - <reference ref="908899353"/> - <reference ref="632727374"/> - <reference ref="646227648"/> - <reference ref="609285721"/> - <reference ref="481834944"/> - <reference ref="304266470"/> - <reference ref="1046388886"/> - <reference ref="1056857174"/> - <reference ref="342932134"/> - </object> - <reference key="parent" ref="694149608"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">58</int> - <reference key="object" ref="238522557"/> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">134</int> - <reference key="object" ref="755159360"/> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">150</int> - <reference key="object" ref="908899353"/> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">136</int> - <reference key="object" ref="632727374"/> - <reference key="parent" ref="110575045"/> - <string key="objectName">1111</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">144</int> - <reference key="object" ref="646227648"/> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">129</int> - <reference key="object" ref="609285721"/> - <reference key="parent" ref="110575045"/> - <string key="objectName">121</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">143</int> - <reference key="object" ref="481834944"/> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">236</int> - <reference key="object" ref="304266470"/> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">131</int> - <reference key="object" ref="1046388886"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="752062318"/> - </object> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">149</int> - <reference key="object" ref="1056857174"/> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">145</int> - <reference key="object" ref="342932134"/> - <reference key="parent" ref="110575045"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">130</int> - <reference key="object" ref="752062318"/> - <reference key="parent" ref="1046388886"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">24</int> - <reference key="object" ref="835318025"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="299356726"/> - <reference ref="625202149"/> - <reference ref="575023229"/> - <reference ref="1011231497"/> - </object> - <reference key="parent" ref="713487014"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">92</int> - <reference key="object" ref="299356726"/> - <reference key="parent" ref="835318025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">5</int> - <reference key="object" ref="625202149"/> - <reference key="parent" ref="835318025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">239</int> - <reference key="object" ref="575023229"/> - <reference key="parent" ref="835318025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">23</int> - <reference key="object" ref="1011231497"/> - <reference key="parent" ref="835318025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">295</int> - <reference key="object" ref="586577488"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="466310130"/> - </object> - <reference key="parent" ref="649796088"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">296</int> - <reference key="object" ref="466310130"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="102151532"/> - <reference ref="237841660"/> - </object> - <reference key="parent" ref="586577488"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">297</int> - <reference key="object" ref="102151532"/> - <reference key="parent" ref="466310130"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">298</int> - <reference key="object" ref="237841660"/> - <reference key="parent" ref="466310130"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">299</int> - <reference key="object" ref="626404410"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="502084290"/> - </object> - <reference key="parent" ref="649796088"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">300</int> - <reference key="object" ref="502084290"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="519768076"/> - <reference ref="1028416764"/> - </object> - <reference key="parent" ref="626404410"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">344</int> - <reference key="object" ref="519768076"/> - <reference key="parent" ref="502084290"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">345</int> - <reference key="object" ref="1028416764"/> - <reference key="parent" ref="502084290"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">211</int> - <reference key="object" ref="676164635"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="785027613"/> - </object> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">212</int> - <reference key="object" ref="785027613"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="680220178"/> - <reference ref="731782645"/> - </object> - <reference key="parent" ref="676164635"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">195</int> - <reference key="object" ref="680220178"/> - <reference key="parent" ref="785027613"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">196</int> - <reference key="object" ref="731782645"/> - <reference key="parent" ref="785027613"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">346</int> - <reference key="object" ref="967646866"/> - <reference key="parent" ref="769623530"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">348</int> - <reference key="object" ref="507821607"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="698887838"/> - </object> - <reference key="parent" ref="789758025"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">349</int> - <reference key="object" ref="698887838"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="605118523"/> - <reference ref="197661976"/> - <reference ref="708854459"/> - </object> - <reference key="parent" ref="507821607"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">350</int> - <reference key="object" ref="605118523"/> - <reference key="parent" ref="698887838"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">351</int> - <reference key="object" ref="197661976"/> - <reference key="parent" ref="698887838"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">354</int> - <reference key="object" ref="708854459"/> - <reference key="parent" ref="698887838"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">389</int> - <reference key="object" ref="143541711"/> - <reference key="parent" ref="755588897"/> - </object> - </object> - </object> - <object class="NSMutableDictionary" key="flattenedProperties"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>-1.IBPluginDependency</string> - <string>-2.IBPluginDependency</string> - <string>-3.IBPluginDependency</string> - <string>103.IBPluginDependency</string> - <string>103.ImportedFromIB2</string> - <string>106.IBPluginDependency</string> - <string>106.ImportedFromIB2</string> - <string>106.editorWindowContentRectSynchronizationRect</string> - <string>111.IBPluginDependency</string> - <string>111.ImportedFromIB2</string> - <string>112.IBPluginDependency</string> - <string>112.ImportedFromIB2</string> - <string>124.IBPluginDependency</string> - <string>124.ImportedFromIB2</string> - <string>125.IBPluginDependency</string> - <string>125.ImportedFromIB2</string> - <string>125.editorWindowContentRectSynchronizationRect</string> - <string>126.IBPluginDependency</string> - <string>126.ImportedFromIB2</string> - <string>129.IBPluginDependency</string> - <string>129.ImportedFromIB2</string> - <string>130.IBPluginDependency</string> - <string>130.ImportedFromIB2</string> - <string>130.editorWindowContentRectSynchronizationRect</string> - <string>131.IBPluginDependency</string> - <string>131.ImportedFromIB2</string> - <string>134.IBPluginDependency</string> - <string>134.ImportedFromIB2</string> - <string>136.IBPluginDependency</string> - <string>136.ImportedFromIB2</string> - <string>143.IBPluginDependency</string> - <string>143.ImportedFromIB2</string> - <string>144.IBPluginDependency</string> - <string>144.ImportedFromIB2</string> - <string>145.IBPluginDependency</string> - <string>145.ImportedFromIB2</string> - <string>149.IBPluginDependency</string> - <string>149.ImportedFromIB2</string> - <string>150.IBPluginDependency</string> - <string>150.ImportedFromIB2</string> - <string>19.IBPluginDependency</string> - <string>19.ImportedFromIB2</string> - <string>195.IBPluginDependency</string> - <string>195.ImportedFromIB2</string> - <string>196.IBPluginDependency</string> - <string>196.ImportedFromIB2</string> - <string>197.IBPluginDependency</string> - <string>197.ImportedFromIB2</string> - <string>198.IBPluginDependency</string> - <string>198.ImportedFromIB2</string> - <string>199.IBPluginDependency</string> - <string>199.ImportedFromIB2</string> - <string>200.IBPluginDependency</string> - <string>200.ImportedFromIB2</string> - <string>200.editorWindowContentRectSynchronizationRect</string> - <string>201.IBPluginDependency</string> - <string>201.ImportedFromIB2</string> - <string>202.IBPluginDependency</string> - <string>202.ImportedFromIB2</string> - <string>203.IBPluginDependency</string> - <string>203.ImportedFromIB2</string> - <string>204.IBPluginDependency</string> - <string>204.ImportedFromIB2</string> - <string>205.IBPluginDependency</string> - <string>205.ImportedFromIB2</string> - <string>205.editorWindowContentRectSynchronizationRect</string> - <string>206.IBPluginDependency</string> - <string>206.ImportedFromIB2</string> - <string>207.IBPluginDependency</string> - <string>207.ImportedFromIB2</string> - <string>208.IBPluginDependency</string> - <string>208.ImportedFromIB2</string> - <string>209.IBPluginDependency</string> - <string>209.ImportedFromIB2</string> - <string>210.IBPluginDependency</string> - <string>210.ImportedFromIB2</string> - <string>211.IBPluginDependency</string> - <string>211.ImportedFromIB2</string> - <string>212.IBPluginDependency</string> - <string>212.ImportedFromIB2</string> - <string>212.editorWindowContentRectSynchronizationRect</string> - <string>213.IBPluginDependency</string> - <string>213.ImportedFromIB2</string> - <string>214.IBPluginDependency</string> - <string>214.ImportedFromIB2</string> - <string>215.IBPluginDependency</string> - <string>215.ImportedFromIB2</string> - <string>216.IBPluginDependency</string> - <string>216.ImportedFromIB2</string> - <string>217.IBPluginDependency</string> - <string>217.ImportedFromIB2</string> - <string>218.IBPluginDependency</string> - <string>218.ImportedFromIB2</string> - <string>219.IBPluginDependency</string> - <string>219.ImportedFromIB2</string> - <string>220.IBPluginDependency</string> - <string>220.ImportedFromIB2</string> - <string>220.editorWindowContentRectSynchronizationRect</string> - <string>221.IBPluginDependency</string> - <string>221.ImportedFromIB2</string> - <string>23.IBPluginDependency</string> - <string>23.ImportedFromIB2</string> - <string>236.IBPluginDependency</string> - <string>236.ImportedFromIB2</string> - <string>239.IBPluginDependency</string> - <string>239.ImportedFromIB2</string> - <string>24.IBPluginDependency</string> - <string>24.ImportedFromIB2</string> - <string>24.editorWindowContentRectSynchronizationRect</string> - <string>29.IBEditorWindowLastContentRect</string> - <string>29.IBPluginDependency</string> - <string>29.ImportedFromIB2</string> - <string>29.WindowOrigin</string> - <string>29.editorWindowContentRectSynchronizationRect</string> - <string>295.IBPluginDependency</string> - <string>296.IBPluginDependency</string> - <string>296.editorWindowContentRectSynchronizationRect</string> - <string>297.IBPluginDependency</string> - <string>298.IBPluginDependency</string> - <string>299.IBPluginDependency</string> - <string>300.IBPluginDependency</string> - <string>300.editorWindowContentRectSynchronizationRect</string> - <string>344.IBPluginDependency</string> - <string>345.IBPluginDependency</string> - <string>346.IBPluginDependency</string> - <string>346.ImportedFromIB2</string> - <string>348.IBPluginDependency</string> - <string>348.ImportedFromIB2</string> - <string>349.IBPluginDependency</string> - <string>349.ImportedFromIB2</string> - <string>349.editorWindowContentRectSynchronizationRect</string> - <string>350.IBPluginDependency</string> - <string>350.ImportedFromIB2</string> - <string>351.IBPluginDependency</string> - <string>351.ImportedFromIB2</string> - <string>354.IBPluginDependency</string> - <string>354.ImportedFromIB2</string> - <string>389.IBPluginDependency</string> - <string>5.IBPluginDependency</string> - <string>5.ImportedFromIB2</string> - <string>56.IBPluginDependency</string> - <string>56.ImportedFromIB2</string> - <string>57.IBEditorWindowLastContentRect</string> - <string>57.IBPluginDependency</string> - <string>57.ImportedFromIB2</string> - <string>57.editorWindowContentRectSynchronizationRect</string> - <string>58.IBPluginDependency</string> - <string>58.ImportedFromIB2</string> - <string>72.IBPluginDependency</string> - <string>72.ImportedFromIB2</string> - <string>73.IBPluginDependency</string> - <string>73.ImportedFromIB2</string> - <string>74.IBPluginDependency</string> - <string>74.ImportedFromIB2</string> - <string>75.IBPluginDependency</string> - <string>75.ImportedFromIB2</string> - <string>77.IBPluginDependency</string> - <string>77.ImportedFromIB2</string> - <string>78.IBPluginDependency</string> - <string>78.ImportedFromIB2</string> - <string>79.IBPluginDependency</string> - <string>79.ImportedFromIB2</string> - <string>80.IBPluginDependency</string> - <string>80.ImportedFromIB2</string> - <string>81.IBPluginDependency</string> - <string>81.ImportedFromIB2</string> - <string>81.editorWindowContentRectSynchronizationRect</string> - <string>82.IBPluginDependency</string> - <string>82.ImportedFromIB2</string> - <string>83.IBPluginDependency</string> - <string>83.ImportedFromIB2</string> - <string>92.IBPluginDependency</string> - <string>92.ImportedFromIB2</string> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <integer value="1" id="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{375, 955}, {171, 23}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{522, 812}, {146, 23}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{436, 809}, {64, 6}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{608, 612}, {275, 83}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{144, 735}, {243, 243}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{608, 612}, {167, 43}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{608, 612}, {241, 103}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{304, 905}, {197, 73}}</string> - <string>{{541, 739}, {430, 20}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{74, 862}</string> - <string>{{6, 836}, {430, 20}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{254, 935}, {234, 43}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{188, 935}, {176, 43}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{608, 612}, {215, 63}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{553, 556}, {200, 183}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{18, 653}, {200, 183}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>{{102, 775}, {199, 203}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="9"/> - </object> - </object> - <object class="NSMutableDictionary" key="unlocalizedProperties"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - </object> - <nil key="activeLocalization"/> - <object class="NSMutableDictionary" key="localizations"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - </object> - <nil key="sourceID"/> - <int key="maxID">439</int> - </object> - <object class="IBClassDescriber" key="IBDocument.Classes"/> - <int key="IBDocument.localizationMode">0</int> - <string key="IBDocument.LastKnownRelativeProjectPath">../TestShell.xcodeproj</string> - <int key="IBDocument.defaultPropertyAccessControl">3</int> - </data> -</archive> diff --git a/webkit/tools/test_shell/mac/Info.plist b/webkit/tools/test_shell/mac/Info.plist deleted file mode 100644 index 43b98ba..0000000 --- a/webkit/tools/test_shell/mac/Info.plist +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>CFBundleDevelopmentRegion</key> - <string>English</string> - <key>CFBundleExecutable</key> - <string>${EXECUTABLE_NAME}</string> - <key>CFBundleIconFile</key> - <string>test_shell.icns</string> - <key>CFBundleIdentifier</key> - <string>org.chromium.TestShell</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundleName</key> - <string>${PRODUCT_NAME}</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleSignature</key> - <string>????</string> - <key>CFBundleVersion</key> - <string>1.0</string> - <key>NSMainNibFile</key> - <string>MainMenu</string> - <key>NSPrincipalClass</key> - <string>NSApplication</string> -</dict> -</plist> diff --git a/webkit/tools/test_shell/mac/TestShell_Prefix.pch b/webkit/tools/test_shell/mac/TestShell_Prefix.pch deleted file mode 100644 index 98fca90..0000000 --- a/webkit/tools/test_shell/mac/TestShell_Prefix.pch +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifdef __OBJC__ -#import <Cocoa/Cocoa.h> -#endif diff --git a/webkit/tools/test_shell/mac/test_shell.icns b/webkit/tools/test_shell/mac/test_shell.icns Binary files differdeleted file mode 100644 index e28fdc8..0000000 --- a/webkit/tools/test_shell/mac/test_shell.icns +++ /dev/null diff --git a/webkit/tools/test_shell/mac/test_shell_webview.h b/webkit/tools/test_shell/mac/test_shell_webview.h deleted file mode 100644 index 02feb21..0000000 --- a/webkit/tools/test_shell/mac/test_shell_webview.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import <Cocoa/Cocoa.h> - -class TestShell; - -// A view to wrap the WebCore view and help it live in a Cocoa world. The -// (rough) equivalent of Apple's WebView. - -@interface TestShellWebView : NSView { - @private - TestShell *shell_; // weak - NSTrackingArea *trackingArea_; -} - -- (IBAction)goBack:(id)sender; -- (IBAction)goForward:(id)sender; -- (IBAction)reload:(id)sender; -- (IBAction)stopLoading:(id)sender; -- (IBAction)takeURLStringValueFrom:(NSTextField *)sender; - -- (void)mouseDown:(NSEvent *)theEvent; -- (void)rightMouseDown:(NSEvent *)theEvent; -- (void)otherMouseDown:(NSEvent *)theEvent; -- (void)mouseUp:(NSEvent *)theEvent; -- (void)rightMouseUp:(NSEvent *)theEvent; -- (void)otherMouseUp:(NSEvent *)theEvent; -- (void)mouseMoved:(NSEvent *)theEvent; -- (void)mouseDragged:(NSEvent *)theEvent; -- (void)scrollWheel:(NSEvent *)theEvent; -- (void)rightMouseDragged:(NSEvent *)theEvent; -- (void)otherMouseDragged:(NSEvent *)theEvent; -- (void)mouseEntered:(NSEvent *)theEvent; -- (void)mouseExited:(NSEvent *)theEvent; -- (void)keyDown:(NSEvent *)theEvent; -- (void)keyUp:(NSEvent *)theEvent; -- (BOOL)isOpaque; -- (void)setFrame:(NSRect)frameRect; -- (void)setIsActive:(BOOL)active; - -@property (nonatomic, assign) TestShell *shell; - -@end diff --git a/webkit/tools/test_shell/mac/test_shell_webview.mm b/webkit/tools/test_shell/mac/test_shell_webview.mm deleted file mode 100644 index c93caa7..0000000 --- a/webkit/tools/test_shell/mac/test_shell_webview.mm +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import "test_shell_webview.h" - -#import <Cocoa/Cocoa.h> - -#include "base/memory/scoped_ptr.h" -#include "base/string_util.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/gfx/rect.h" -#include "webkit/tools/test_shell/test_shell.h" -#include "webkit/tools/test_shell/webwidget_host.h" - -@implementation TestShellWebView - -@synthesize shell = shell_; - -- (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - if (self) { - trackingArea_ = - [[NSTrackingArea alloc] initWithRect:frame - options:NSTrackingMouseMoved | - NSTrackingActiveInActiveApp | - NSTrackingInVisibleRect - owner:self - userInfo:nil]; - [self addTrackingArea:trackingArea_]; - } - return self; -} - -- (void) dealloc { - [self removeTrackingArea:trackingArea_]; - [trackingArea_ release]; - - [super dealloc]; -} - -- (void)drawRect:(NSRect)rect { - CGContextRef context = - reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] - graphicsPort]); - - // start by filling the rect with magenta, so that we can see what's drawn - CGContextSetRGBFillColor (context, 1, 0, 1, 1); - CGContextFillRect(context, NSRectToCGRect(rect)); - - if (shell_ && shell_->webView()) { - gfx::Rect client_rect(NSRectToCGRect(rect)); - // flip from cocoa coordinates - client_rect.set_y([self frame].size.height - - client_rect.height() - client_rect.y()); - - shell_->webViewHost()->UpdatePaintRect(client_rect); - shell_->webViewHost()->Paint(); - } -} - -- (IBAction)goBack:(id)sender { - if (shell_) - shell_->GoBackOrForward(-1); -} - -- (IBAction)goForward:(id)sender { - if (shell_) - shell_->GoBackOrForward(1); -} - -- (IBAction)reload:(id)sender { - if (shell_) - shell_->Reload(); -} - -- (IBAction)stopLoading:(id)sender { - if (shell_ && shell_->webView()) - shell_->webView()->mainFrame()->stopLoading(); -} - -- (IBAction)takeURLStringValueFrom:(NSTextField *)sender { - NSString *url = [sender stringValue]; - - // if it doesn't already have a prefix, add http. If we can't parse it, - // just don't bother rather than making things worse. - NSURL* tempUrl = [NSURL URLWithString:url]; - if (tempUrl && ![tempUrl scheme]) - url = [@"http://" stringByAppendingString:url]; - shell_->LoadURL(GURL(std::string([url UTF8String]))); -} - -- (void)mouseDown:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)rightMouseDown:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)otherMouseDown:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)mouseUp:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)rightMouseUp:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)otherMouseUp:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)mouseMoved:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)mouseDragged:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)scrollWheel:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->WheelEvent(theEvent); -} - -- (void)rightMouseDragged:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)otherMouseDragged:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)mouseEntered:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)mouseExited:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->MouseEvent(theEvent); -} - -- (void)keyDown:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->KeyEvent(theEvent); -} - -- (void)keyUp:(NSEvent *)theEvent { - if (shell_ && shell_->webView()) - shell_->webViewHost()->KeyEvent(theEvent); -} - -- (BOOL)isOpaque { - return YES; -} - -- (BOOL)canBecomeKeyView { - return shell_ && shell_->webView(); -} - -- (BOOL)acceptsFirstResponder { - return shell_ && shell_->webView(); -} - -- (BOOL)becomeFirstResponder { - if (shell_ && shell_->webView()) { - shell_->webViewHost()->SetFocus(YES); - return YES; - } - - return NO; -} - -- (BOOL)resignFirstResponder { - if (shell_ && shell_->webView()) { - shell_->webViewHost()->SetFocus(NO); - return YES; - } - - return NO; -} - -- (void)setIsActive:(BOOL)active { - if (shell_ && shell_->webView()) - shell_->webViewHost()->SetIsActive(active ? true : false); -} - -- (void)setFrame:(NSRect)frameRect { - [super setFrame:frameRect]; - if (shell_ && shell_->webView()) - shell_->webViewHost()->Resize(gfx::Rect(NSRectToCGRect(frameRect))); - [self setNeedsDisplay:YES]; -} - -@end diff --git a/webkit/tools/test_shell/mock_spellcheck.cc b/webkit/tools/test_shell/mock_spellcheck.cc deleted file mode 100644 index fac0dfb..0000000 --- a/webkit/tools/test_shell/mock_spellcheck.cc +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/mock_spellcheck.h" - -#include <map> -#include <utility> - -#include "base/logging.h" -#include "base/string16.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" - -MockSpellCheck::MockSpellCheck() - : initialized_(false) { -} - -MockSpellCheck::~MockSpellCheck() { -} - -bool MockSpellCheck::SpellCheckWord(const base::string16& text, - int* misspelledOffset, - int* misspelledLength) { - DCHECK(misspelledOffset && misspelledLength); - - // Initialize this spellchecker. - InitializeIfNeeded(); - - // Reset the result values as our spellchecker does. - *misspelledOffset = 0; - *misspelledLength = 0; - - // Extract the first possible English word from the given string. - // The given string may include non-ASCII characters or numbers. So, we - // should filter out such characters before start looking up our - // misspelled-word table. - // (This is a simple version of our SpellCheckWordIterator class.) - // If the given string doesn't include any ASCII characters, we can treat the - // string as valid one. - // Unfortunately, This implementation splits a contraction, i.e. "isn't" is - // split into two pieces "isn" and "t". This is OK because webkit tests - // don't have misspelled contractions. - static const char* kWordCharacters = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - base::string16 word_characters(ASCIIToUTF16(kWordCharacters)); - - size_t word_offset = text.find_first_of(word_characters); - if (word_offset == std::string::npos) - return true; - - size_t word_end = text.find_first_not_of(word_characters, word_offset); - size_t word_length = word_end == std::string::npos ? - text.length() - word_offset : word_end - word_offset; - - // Look up our misspelled-word table to check if the extracted word is a - // known misspelled word, and return the offset and the length of the - // extracted word if this word is a known misspelled word. - // (See the comment in MockSpellCheck::InitializeIfNeeded() why we use a - // misspelled-word table.) - base::string16 word(text, word_offset, word_length); - std::map<base::string16, bool>::iterator it = misspelled_words_.find(word); - if (it == misspelled_words_.end()) - return true; - - *misspelledOffset = static_cast<int>(word_offset); - *misspelledLength = static_cast<int>(word_length); - return false; -} - -bool MockSpellCheck::InitializeIfNeeded() { - // Exit if we have already initialized this object. - if (initialized_) - return false; - - // Create a table that consists of misspelled words used in WebKit layout - // tests. - // Since WebKit layout tests don't have so many misspelled words as - // well-spelled words, it is easier to compare the given word with misspelled - // ones than to compare with well-spelled ones. - static const char* kMisspelledWords[] = { - // These words are known misspelled words in webkit tests. - // If there are other misspelled words in webkit tests, please add them in - // this array. - "foo", - "Foo", - "baz", - "fo", - "LibertyF", - "chello", - "xxxtestxxx", - "XXxxx", - "Textx", - "blockquoted", - "asd", - "Lorem", - "Nunc", - "Curabitur", - "eu", - "adlj", - "adaasj", - "sdklj", - "jlkds", - "jsaada", - "jlda", - "zz", - "contentEditable", - // The following words are used by unit tests. - "ifmmp", - "qwertyuiopasd", - "qwertyuiopasdf", - }; - - misspelled_words_.clear(); - for (size_t i = 0; i < arraysize(kMisspelledWords); ++i) { - misspelled_words_.insert(std::make_pair<base::string16, bool>( - ASCIIToUTF16(kMisspelledWords[i]), false)); - } - - // Mark as initialized to prevent this object from being initialized twice - // or more. - initialized_ = true; - - // Since this MockSpellCheck class doesn't download dictionaries, this - // function always returns false. - return false; -} - -void MockSpellCheck::FillSuggestions(const base::string16& word, - std::vector<base::string16>* suggestions) { - if (word == ASCIIToUTF16("wellcome")) - suggestions->push_back(ASCIIToUTF16("welcome")); -} diff --git a/webkit/tools/test_shell/mock_spellcheck.h b/webkit/tools/test_shell/mock_spellcheck.h deleted file mode 100644 index 8f7c395..0000000 --- a/webkit/tools/test_shell/mock_spellcheck.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_ -#define WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_ - -#include <map> -#include <vector> - -#include "base/string16.h" - -// A mock implementation of a spell-checker used for WebKit tests. -// This class only implements the minimal functionarities required by WebKit -// tests, i.e. this class just compares the given string with known misspelled -// words in webkit tests and mark them as missspelled. -// Even though this is sufficent for webkit tests, this class is not suitable -// for any other usages. -class MockSpellCheck { - public: - MockSpellCheck(); - ~MockSpellCheck(); - - // Checks the spellings of the specified text. - // This function returns true if the text consists of valid words, and - // returns false if it includes invalid words. - // When the given text includes invalid words, this function sets the - // position of the first invalid word to misspelledOffset, and the length of - // the first invalid word to misspelledLength, respectively. - // For example, when the given text is " zz zz", this function sets 3 to - // misspelledOffset and 2 to misspelledLength, respectively. - bool SpellCheckWord(const base::string16& text, - int* misspelledOffset, - int* misspelledLength); - - // Emulates suggestions for misspelled words. - // The suggestions are pushed to |suggestions| parameters. - void FillSuggestions(const base::string16& word, - std::vector<base::string16>* suggestions); - private: - // Initialize the internal resources if we need to initialize it. - // Initializing this object may take long time. To prevent from hurting - // the performance of test_shell, we initialize this object when - // SpellCheckWord() is called for the first time. - // To be compliant with SpellCheck:InitializeIfNeeded(), this function - // returns true if this object is downloading a dictionary, otherwise - // it returns false. - bool InitializeIfNeeded(); - - // A table that consists of misspelled words. - std::map<base::string16, bool> misspelled_words_; - - // A flag representing whether or not this object is initialized. - bool initialized_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_MOCK_SPELLCHECK_H_ diff --git a/webkit/tools/test_shell/notification_presenter.cc b/webkit/tools/test_shell/notification_presenter.cc deleted file mode 100644 index f106922..0000000 --- a/webkit/tools/test_shell/notification_presenter.cc +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/notification_presenter.h" - -#include "base/bind.h" -#include "base/message_loop.h" -#include "googleurl/src/gurl.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotification.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPermissionCallback.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" - -using WebKit::WebNotification; -using WebKit::WebNotificationPresenter; -using WebKit::WebNotificationPermissionCallback; -using WebKit::WebSecurityOrigin; -using WebKit::WebString; -using WebKit::WebTextDirectionRightToLeft; -using WebKit::WebURL; - -namespace { -void DeferredDisplayDispatch(WebNotification notification) { - notification.dispatchDisplayEvent(); -} -} - -TestNotificationPresenter::TestNotificationPresenter(TestShell* shell) { -} - -TestNotificationPresenter::~TestNotificationPresenter() {} - -void TestNotificationPresenter::Reset() { - allowed_origins_.clear(); -} - -void TestNotificationPresenter::grantPermission(const std::string& origin) { - allowed_origins_.insert(origin); -} - -// The output from all these methods matches what DumpRenderTree produces. -bool TestNotificationPresenter::show(const WebNotification& notification) { - if (!notification.replaceId().isEmpty()) { - std::string replace_id(notification.replaceId().utf8()); - if (replacements_.find(replace_id) != replacements_.end()) - printf("REPLACING NOTIFICATION %s\n", - replacements_.find(replace_id)->second.c_str()); - - WebString identifier = notification.isHTML() ? - notification.url().spec().utf16() : notification.title(); - replacements_[replace_id] = identifier.utf8(); - } - - if (notification.isHTML()) { - printf("DESKTOP NOTIFICATION: contents at %s\n", - notification.url().spec().data()); - } else { - printf("DESKTOP NOTIFICATION:%s icon %s, title %s, text %s\n", - notification.direction() == WebTextDirectionRightToLeft ? "(RTL)" : - "", - notification.iconURL().isEmpty() ? "" : - notification.iconURL().spec().data(), - notification.title().isEmpty() ? "" : - notification.title().utf8().data(), - notification.body().isEmpty() ? "" : - notification.body().utf8().data()); - } - - - WebNotification event_target(notification); - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&DeferredDisplayDispatch, event_target)); - return true; -} - -void TestNotificationPresenter::cancel(const WebNotification& notification) { - WebString identifier; - if (notification.isHTML()) - identifier = notification.url().spec().utf16(); - else - identifier = notification.title(); - - printf("DESKTOP NOTIFICATION CLOSED: %s\n", identifier.utf8().data()); - WebNotification event_target(notification); - event_target.dispatchCloseEvent(false); -} - -void TestNotificationPresenter::objectDestroyed( - const WebKit::WebNotification& notification) { - // Nothing to do. Not storing the objects. -} - -WebNotificationPresenter::Permission TestNotificationPresenter::checkPermission( - const WebSecurityOrigin& origin) { - // Check with the layout test controller - bool allowed = allowed_origins_.find(origin.toString().utf8().data()) - != allowed_origins_.end(); - return allowed ? WebNotificationPresenter::PermissionAllowed - : WebNotificationPresenter::PermissionDenied; -} - -void TestNotificationPresenter::requestPermission( - const WebSecurityOrigin& origin, - WebNotificationPermissionCallback* callback) { - printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", - origin.toString().utf8().data()); - callback->permissionRequestComplete(); -} diff --git a/webkit/tools/test_shell/notification_presenter.h b/webkit/tools/test_shell/notification_presenter.h deleted file mode 100644 index 85ddef5..0000000 --- a/webkit/tools/test_shell/notification_presenter.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_NOTIFICATION_PRESENTER_H_ -#define WEBKIT_TOOLS_TEST_SHELL_NOTIFICATION_PRESENTER_H_ - -#include <map> -#include <set> -#include <string> - -#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresenter.h" -#include "webkit/tools/test_shell/test_shell.h" - -// A class that implements NotificationPresenter for the test shell. -class TestNotificationPresenter : public WebKit::WebNotificationPresenter { - public: - explicit TestNotificationPresenter(TestShell* shell); - virtual ~TestNotificationPresenter(); - - void Reset(); - - // Called by the testRunner to simulate a user granting - // permission. - void grantPermission(const std::string& origin); - - // WebKit::WebNotificationPresenter interface - virtual bool show(const WebKit::WebNotification&); - virtual void cancel(const WebKit::WebNotification&); - virtual void objectDestroyed(const WebKit::WebNotification&); - virtual Permission checkPermission(const WebKit::WebSecurityOrigin& origin); - virtual void requestPermission(const WebKit::WebSecurityOrigin& origin, - WebKit::WebNotificationPermissionCallback* callback); - - private: - // List of allowed origins. - std::set<std::string> allowed_origins_; - - // Map of active replacement IDs to the titles of those notifications - std::map<std::string, std::string> replacements_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_NOTIFICATION_PRESENTER_H_ diff --git a/webkit/tools/test_shell/resource.h b/webkit/tools/test_shell/resource.h deleted file mode 100644 index 3b51310..0000000 --- a/webkit/tools/test_shell/resource.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by test_shell.rc -// - -#define IDS_APP_TITLE 103 - -#define IDR_MAINFRAME 128 -#define IDD_TESTSHELL_DIALOG 102 -#define IDD_ABOUTBOX 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 -#define IDM_DUMP_BODY_TEXT 110 -#define IDM_DUMP_RENDER_TREE 111 -#define IDM_ENABLE_IMAGES 114 -#define IDM_ENABLE_PLUGINS 115 -#define IDM_ENABLE_SCRIPTS 116 -#define IDM_SHOW_DEV_TOOLS 112 -#define IDI_TESTSHELL 107 -#define IDI_SMALL 108 -#define IDC_TESTSHELL 109 -#define IDR_AHEM_FONT 113 -#define IDC_MYICON 2 -#define IDC_NAV_BACK 1001 -#define IDC_NAV_FORWARD 1002 -#define IDC_NAV_RELOAD 1003 -#define IDC_NAV_STOP 1004 -#ifndef IDC_STATIC -#define IDC_STATIC -1 -#endif -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS - -#define _APS_NO_MFC 130 -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 117 -#endif -#endif diff --git a/webkit/tools/test_shell/resources/small.ico b/webkit/tools/test_shell/resources/small.ico Binary files differdeleted file mode 100644 index d551aa3..0000000 --- a/webkit/tools/test_shell/resources/small.ico +++ /dev/null diff --git a/webkit/tools/test_shell/resources/test_shell.ico b/webkit/tools/test_shell/resources/test_shell.ico Binary files differdeleted file mode 100644 index d551aa3..0000000 --- a/webkit/tools/test_shell/resources/test_shell.ico +++ /dev/null diff --git a/webkit/tools/test_shell/resources/test_shell.rc b/webkit/tools/test_shell/resources/test_shell.rc deleted file mode 100644 index ce26e59..0000000 --- a/webkit/tools/test_shell/resources/test_shell.rc +++ /dev/null @@ -1,140 +0,0 @@ -//Microsoft Visual C++ generated resource script. -// -#include "tools/test_shell/resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. - -IDI_TESTSHELL ICON "test_shell.ico" -IDI_SMALL ICON "small.ico" - -IDR_AHEM_FONT BINDATA "AHEM____.TTF" - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDC_TESTSHELL MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "E&xit", IDM_EXIT - END - POPUP "&Debug" - BEGIN - MENUITEM "Dump body text...", IDM_DUMP_BODY_TEXT - MENUITEM "Dump render tree...", IDM_DUMP_RENDER_TREE - MENUITEM SEPARATOR - MENUITEM "Enable images", IDM_ENABLE_IMAGES, CHECKED - MENUITEM "Enable plugins", IDM_ENABLE_PLUGINS, CHECKED - MENUITEM "Enable scripts", IDM_ENABLE_SCRIPTS, CHECKED - MENUITEM SEPARATOR - MENUITEM "Show developer tools...", IDM_SHOW_DEV_TOOLS - END - POPUP "&Help" - BEGIN - MENUITEM "&About ...", IDM_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDC_TESTSHELL ACCELERATORS -BEGIN - "?", IDM_ABOUT, ASCII, ALT - "/", IDM_ABOUT, ASCII, ALT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG 22, 17, 230, 75 -STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -CAPTION "About" -FONT 8, "System" -BEGIN - ICON IDI_TESTSHELL,IDC_MYICON,14,9,16,16 - LTEXT "TestShell Version 1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX - LTEXT "Copyright (C) 2006",IDC_STATIC,49,20,119,8 - DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP -END - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDC_TESTSHELL "TESTSHELL" - IDS_APP_TITLE "TestShell" -END - -#endif -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED diff --git a/webkit/tools/test_shell/test_navigation_controller.cc b/webkit/tools/test_shell/test_navigation_controller.cc deleted file mode 100644 index 9d80f58..0000000 --- a/webkit/tools/test_shell/test_navigation_controller.cc +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_navigation_controller.h" - -#include "base/logging.h" -#include "webkit/tools/test_shell/test_shell.h" - -// ---------------------------------------------------------------------------- -// TestNavigationEntry - -TestNavigationEntry::TestNavigationEntry() - : page_id_(-1) { -} - -TestNavigationEntry::TestNavigationEntry(int page_id, - const GURL& url, - const base::string16& target_frame) - : page_id_(page_id), - url_(url), - target_frame_(target_frame) { -} - -TestNavigationEntry::~TestNavigationEntry() { -} - -void TestNavigationEntry::SetContentState(const std::string& state) { - state_ = state; -} - -// ---------------------------------------------------------------------------- -// TestNavigationController - -TestNavigationController::TestNavigationController(TestShell* shell) - : pending_entry_(NULL), - last_committed_entry_index_(-1), - pending_entry_index_(-1), - shell_(shell), - max_page_id_(-1) { -} - -TestNavigationController::~TestNavigationController() { - DiscardPendingEntry(); -} - -void TestNavigationController::Reset() { - entries_.clear(); - DiscardPendingEntry(); - - last_committed_entry_index_ = -1; -} - -void TestNavigationController::Reload() { - // Base the navigation on where we are now... - int current_index = GetCurrentEntryIndex(); - - // If we are no where, then we can't reload. TODO(darin): We should add a - // CanReload method. - if (current_index == -1) - return; - - DiscardPendingEntry(); - - pending_entry_index_ = current_index; - NavigateToPendingEntry(true); -} - -void TestNavigationController::GoToOffset(int offset) { - int index = last_committed_entry_index_ + offset; - if (index < 0 || index >= GetEntryCount()) - return; - - GoToIndex(index); -} - -void TestNavigationController::GoToIndex(int index) { - DCHECK(index >= 0); - DCHECK(index < static_cast<int>(entries_.size())); - - DiscardPendingEntry(); - - pending_entry_index_ = index; - NavigateToPendingEntry(false); -} - -void TestNavigationController::LoadEntry(TestNavigationEntry* entry) { - // When navigating to a new page, we don't know for sure if we will actually - // end up leaving the current page. The new page load could for example - // result in a download or a 'no content' response (e.g., a mailto: URL). - DiscardPendingEntry(); - pending_entry_ = entry; - NavigateToPendingEntry(false); -} - - -TestNavigationEntry* TestNavigationController::GetLastCommittedEntry() const { - if (last_committed_entry_index_ == -1) - return NULL; - return entries_[last_committed_entry_index_].get(); -} - -TestNavigationEntry* TestNavigationController::GetActiveEntry() const { - TestNavigationEntry* entry = pending_entry_; - if (!entry) - entry = GetLastCommittedEntry(); - return entry; -} - -int TestNavigationController::GetCurrentEntryIndex() const { - if (pending_entry_index_ != -1) - return pending_entry_index_; - return last_committed_entry_index_; -} - - -TestNavigationEntry* TestNavigationController::GetEntryAtIndex( - int index) const { - if (index < 0 || index >= GetEntryCount()) - return NULL; - - return entries_[index].get(); -} - -TestNavigationEntry* TestNavigationController::GetEntryWithPageID( - int32 page_id) const { - int index = GetEntryIndexWithPageID(page_id); - return (index != -1) ? entries_[index].get() : NULL; -} - -void TestNavigationController::DidNavigateToEntry(TestNavigationEntry* entry) { - // If the entry is that of a page with PageID larger than any this Tab has - // seen before, then consider it a new navigation. - if (entry->GetPageID() > GetMaxPageID()) { - InsertEntry(entry); - return; - } - - // Otherwise, we just need to update an existing entry with matching PageID. - // If the existing entry corresponds to the entry which is pending, then we - // must update the current entry index accordingly. When navigating to the - // same URL, a new PageID is not created. - - int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID()); - TestNavigationEntry* existing_entry = (existing_entry_index != -1) ? - entries_[existing_entry_index].get() : NULL; - if (!existing_entry) { - // No existing entry, then simply ignore this navigation! - DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID(); - } else if (existing_entry == pending_entry_) { - // The given entry might provide a new URL... e.g., navigating back to a - // page in session history could have resulted in a new client redirect. - existing_entry->SetURL(entry->GetURL()); - existing_entry->SetContentState(entry->GetContentState()); - last_committed_entry_index_ = pending_entry_index_; - pending_entry_index_ = -1; - pending_entry_ = NULL; - } else if (pending_entry_ && pending_entry_->GetPageID() == -1 && - pending_entry_->GetURL() == existing_entry->GetURL()) { - // Not a new navigation - DiscardPendingEntry(); - } else { - // The given entry might provide a new URL... e.g., navigating to a page - // might result in a client redirect, which should override the URL of the - // existing entry. - existing_entry->SetURL(entry->GetURL()); - existing_entry->SetContentState(entry->GetContentState()); - - // The navigation could have been issued by the renderer, so be sure that - // we update our current index. - last_committed_entry_index_ = existing_entry_index; - } - - delete entry; - UpdateMaxPageID(); -} - -void TestNavigationController::DiscardPendingEntry() { - if (pending_entry_index_ == -1) - delete pending_entry_; - pending_entry_ = NULL; - pending_entry_index_ = -1; -} - -void TestNavigationController::InsertEntry(TestNavigationEntry* entry) { - DiscardPendingEntry(); - - // Prune any entry which are in front of the current entry - int current_size = static_cast<int>(entries_.size()); - if (current_size > 0) { - while (last_committed_entry_index_ < (current_size - 1)) { - entries_.pop_back(); - current_size--; - } - } - - entries_.push_back(linked_ptr<TestNavigationEntry>(entry)); - last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; - UpdateMaxPageID(); -} - -int TestNavigationController::GetEntryIndexWithPageID(int32 page_id) const { - for (int i = static_cast<int>(entries_.size())-1; i >= 0; --i) { - if (entries_[i]->GetPageID() == page_id) - return i; - } - return -1; -} - -void TestNavigationController::NavigateToPendingEntry(bool reload) { - // For session history navigations only the pending_entry_index_ is set. - if (!pending_entry_) { - DCHECK(pending_entry_index_ != -1); - pending_entry_ = entries_[pending_entry_index_].get(); - } - - if (shell_->Navigate(*pending_entry_, reload)) { - // Note: this is redundant if navigation completed synchronously because - // DidNavigateToEntry call this as well. - UpdateMaxPageID(); - } else { - DiscardPendingEntry(); - } -} - -void TestNavigationController::UpdateMaxPageID() { - TestNavigationEntry* entry = GetActiveEntry(); - if (entry) - max_page_id_ = std::max(max_page_id_, entry->GetPageID()); -} diff --git a/webkit/tools/test_shell/test_navigation_controller.h b/webkit/tools/test_shell/test_navigation_controller.h deleted file mode 100644 index d1edd6c..0000000 --- a/webkit/tools/test_shell/test_navigation_controller.h +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ - -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/memory/linked_ptr.h" -#include "base/memory/ref_counted.h" -#include "base/string16.h" -#include "googleurl/src/gurl.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" - -class GURL; -class TestShell; - -// Associated with browser-initated navigations to hold tracking data. -class TestShellExtraData : public WebKit::WebDataSource::ExtraData { - public: - TestShellExtraData(int32 pending_page_id) - : pending_page_id(pending_page_id), - request_committed(false) { - } - - // Contains the page_id for this navigation or -1 if there is none yet. - int32 pending_page_id; - - // True if we have already processed the "DidCommitLoad" event for this - // request. Used by session history. - bool request_committed; -}; - -// Stores one back/forward navigation state for the test shell. -class TestNavigationEntry { - public: - TestNavigationEntry(); - TestNavigationEntry(int page_id, - const GURL& url, - const base::string16& target_frame); - - // Virtual to allow test_shell to extend the class. - ~TestNavigationEntry(); - - // Set / Get the URI - void SetURL(const GURL& url) { url_ = url; } - const GURL& GetURL() const { return url_; } - - // Set / Get opaque state. - // WARNING: This state is saved to the database and used to restore previous - // states. If you use write a custom TabContents and provide your own - // state make sure you have the ability to modify the format in the future - // while being able to deal with older versions. - void SetContentState(const std::string& state); - const std::string& GetContentState() const { return state_; } - - // Get the page id corresponding to the tab's state. - void SetPageID(int page_id) { page_id_ = page_id; } - int32 GetPageID() const { return page_id_; } - - const base::string16& GetTargetFrame() const { return target_frame_; } - - private: - // Describes the current page that the tab represents. This is not relevant - // for all tab contents types. - int32 page_id_; - - GURL url_; - std::string state_; - - base::string16 target_frame_; - - DISALLOW_COPY_AND_ASSIGN(TestNavigationEntry); -}; - -// Test shell's NavigationController. The goal is to be as close to the Chrome -// version as possible. -class TestNavigationController { - public: - TestNavigationController(TestShell* shell); - ~TestNavigationController(); - - void Reset(); - - // Causes the controller to reload the current (or pending) entry. - void Reload(); - - // Causes the controller to go to the specified offset from current. Does - // nothing if out of bounds. - void GoToOffset(int offset); - - // Causes the controller to go to the specified index. - void GoToIndex(int index); - - // Causes the controller to load the specified entry. The controller - // assumes ownership of the entry. - // NOTE: Do not pass an entry that the controller already owns! - void LoadEntry(TestNavigationEntry* entry); - - // Returns the last committed entry, which may be null if there are no - // committed entries. - TestNavigationEntry* GetLastCommittedEntry() const; - - // Returns the number of entries in the NavigationControllerBase, excluding - // the pending entry if there is one. - int GetEntryCount() const { - return static_cast<int>(entries_.size()); - } - - // Returns the active entry, which is the pending entry if a navigation is in - // progress or the last committed entry otherwise. NOTE: This can be NULL!! - // - // If you are trying to get the current state of the NavigationControllerBase, - // this is the method you will typically want to call. - TestNavigationEntry* GetActiveEntry() const; - - // Returns the index from which we would go back/forward or reload. This is - // the last_committed_entry_index_ if pending_entry_index_ is -1. Otherwise, - // it is the pending_entry_index_. - int GetCurrentEntryIndex() const; - - // Returns the entry at the specified index. Returns NULL if out of - // bounds. - TestNavigationEntry* GetEntryAtIndex(int index) const; - - // Return the entry with the corresponding type and page_id, or NULL if - // not found. - TestNavigationEntry* GetEntryWithPageID(int32 page_id) const; - - // Returns the index of the last committed entry. - int GetLastCommittedEntryIndex() const { - return last_committed_entry_index_; - } - - // Used to inform us of a navigation being committed for a tab. We will take - // ownership of the entry. Any entry located forward to the current entry will - // be deleted. The new entry becomes the current entry. - void DidNavigateToEntry(TestNavigationEntry* entry); - - // Used to inform us to discard its pending entry. - void DiscardPendingEntry(); - - private: - // Inserts an entry after the current position, removing all entries after it. - // The new entry will become the active one. - void InsertEntry(TestNavigationEntry* entry); - - int GetMaxPageID() const { return max_page_id_; } - void NavigateToPendingEntry(bool reload); - - // Return the index of the entry with the corresponding type and page_id, - // or -1 if not found. - int GetEntryIndexWithPageID(int32 page_id) const; - - // Updates the max page ID with that of the given entry, if is larger. - void UpdateMaxPageID(); - - // List of NavigationEntry for this tab - typedef std::vector< linked_ptr<TestNavigationEntry> > NavigationEntryList; - typedef NavigationEntryList::iterator NavigationEntryListIterator; - NavigationEntryList entries_; - - // An entry we haven't gotten a response for yet. This will be discarded - // when we navigate again. It's used only so we know what the currently - // displayed tab is. - TestNavigationEntry* pending_entry_; - - // currently visible entry - int last_committed_entry_index_; - - // index of pending entry if it is in entries_, or -1 if pending_entry_ is a - // new entry (created by LoadURL). - int pending_entry_index_; - - TestShell* shell_; - int max_page_id_; - - DISALLOW_COPY_AND_ASSIGN(TestNavigationController); -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc deleted file mode 100644 index 457ac85..0000000 --- a/webkit/tools/test_shell/test_shell.cc +++ /dev/null @@ -1,615 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#undef LOG - -#include "webkit/tools/test_shell/test_shell.h" - -#include "base/base_paths.h" -#include "base/command_line.h" -#include "base/debug/debug_on_start_win.h" -#include "base/file_util.h" -#include "base/files/file_path.h" -#include "base/md5.h" -#include "base/message_loop.h" -#include "base/metrics/stats_table.h" -#include "base/path_service.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "build/build_config.h" -#include "googleurl/src/url_util.h" -#include "grit/webkit_strings.h" -#include "net/base/mime_util.h" -#include "net/base/net_util.h" -#include "net/url_request/url_request.h" -#include "net/url_request/url_request_file_job.h" -#include "net/url_request/url_request_filter.h" -#include "skia/ext/bitmap_platform_device.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientationClientMock.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationClientMock.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/gfx/codec/png_codec.h" -#include "ui/gfx/size.h" -#include "webkit/glue/glue_serialize.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/tools/test_shell/notification_presenter.h" -#include "webkit/tools/test_shell/simple_resource_loader_bridge.h" -#include "webkit/tools/test_shell/test_navigation_controller.h" -#include "webkit/tools/test_shell/test_shell_devtools_agent.h" -#include "webkit/tools/test_shell/test_shell_devtools_client.h" -#include "webkit/tools/test_shell/test_shell_request_context.h" -#include "webkit/tools/test_shell/test_shell_switches.h" -#include "webkit/tools/test_shell/test_webview_delegate.h" -#include "webkit/user_agent/user_agent.h" -#include "webkit/user_agent/user_agent_util.h" - -using WebKit::WebCanvas; -using WebKit::WebFrame; -using WebKit::WebNavigationPolicy; -using WebKit::WebRect; -using WebKit::WebScriptController; -using WebKit::WebSize; -using WebKit::WebURLRequest; -using WebKit::WebView; - -namespace { - -// Default timeout in ms for file page loads when in layout test mode. -const int kDefaultFileTestTimeoutMillisecs = 10 * 1000; - -// Content area size for newly created windows. -const int kTestWindowWidth = 800; -const int kTestWindowHeight = 600; - -// The W3C SVG layout tests use a different size than the other layout -// tests. -const int kSVGTestWindowWidth = 480; -const int kSVGTestWindowHeight = 360; - -// URLRequestTestShellFileJob is used to serve the inspector -class URLRequestTestShellFileJob : public net::URLRequestFileJob { - public: - static net::URLRequestJob* InspectorFactory( - net::URLRequest* request, - net::NetworkDelegate* network_delegate, - const std::string& scheme) { - base::FilePath path; - PathService::Get(base::DIR_EXE, &path); - path = path.AppendASCII("resources"); - path = path.AppendASCII("inspector"); - path = path.AppendASCII(request->url().path().substr(1)); - return new URLRequestTestShellFileJob(request, network_delegate, path); - } - - private: - URLRequestTestShellFileJob(net::URLRequest* request, - net::NetworkDelegate* network_delegate, - const base::FilePath& path) - : net::URLRequestFileJob(request, network_delegate, path) { - } - virtual ~URLRequestTestShellFileJob() { } - - DISALLOW_COPY_AND_ASSIGN(URLRequestTestShellFileJob); -}; - - -} // namespace - -// Initialize static member variable -WindowList* TestShell::window_list_; -WebPreferences* TestShell::web_prefs_ = NULL; -bool TestShell::layout_test_mode_ = false; -bool TestShell::allow_external_pages_ = false; -std::vector<std::string> TestShell::js_flags_; -bool TestShell::accelerated_2d_canvas_enabled_ = false; -bool TestShell::accelerated_compositing_enabled_ = false; - -TestShell::TestParams::TestParams() - : dump_tree(true), - dump_pixels(false) { -} - -TestShell::TestShell() - : m_mainWnd(NULL), - m_editWnd(NULL), - m_webViewHost(NULL), - m_popupHost(NULL), - m_focusedWidgetHost(NULL), -#if defined(OS_WIN) - default_edit_wnd_proc_(0), -#endif - test_params_(NULL), - is_modal_(false), - is_loading_(false), - allow_images_(true), - allow_plugins_(true), - allow_scripts_(true), - dump_stats_table_on_exit_(false) { - delegate_.reset(new TestWebViewDelegate(this)); - popup_delegate_.reset(new TestWebViewDelegate(this)); - navigation_controller_.reset(new TestNavigationController(this)); - notification_presenter_.reset(new TestNotificationPresenter(this)); - - net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); - filter->AddHostnameHandler("test-shell-resource", "inspector", - &URLRequestTestShellFileJob::InspectorFactory); - url_util::AddStandardScheme("test-shell-resource"); - webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( - "TestShell/0.0.0.0"), false); -} - -TestShell::~TestShell() { - delegate_->RevokeDragDrop(); - - // DevTools frontend page is supposed to be navigated only once and - // loading another URL in that Page is an error. - if (!dev_tools_client_) { - // Navigate to an empty page to fire all the destruction logic for the - // current page. - LoadURL(GURL("about:blank")); - } - - net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); - filter->RemoveHostnameHandler("test-shell-resource", "inspector"); - - // Call GC twice to clean up garbage. - CallJSGC(); - CallJSGC(); - - // Destroy the WebView before the TestWebViewDelegate. - m_webViewHost.reset(); - - CloseDevTools(); - - PlatformCleanUp(); - - base::StatsTable *table = base::StatsTable::current(); - if (dump_stats_table_on_exit_) { - // Dump the stats table. - printf("<stats>\n"); - if (table != NULL) { - int counter_max = table->GetMaxCounters(); - for (int index = 0; index < counter_max; index++) { - std::string name(table->GetRowName(index)); - if (name.length() > 0) { - int value = table->GetRowValue(index); - printf("%s:\t%d\n", name.c_str(), value); - } - } - } - printf("</stats>\n"); - } -} - -void TestShell::UpdateNavigationControls() { - int current_index = navigation_controller()->GetCurrentEntryIndex(); - int max_index = navigation_controller()->GetEntryCount() - 1; - - EnableUIControl(BACK_BUTTON, current_index > 0); - EnableUIControl(FORWARD_BUTTON, current_index < max_index); - EnableUIControl(STOP_BUTTON, is_loading_); -} - -bool TestShell::CreateNewWindow(const GURL& starting_url, - TestShell** result) { - TestShell* shell = new TestShell(); - bool rv = shell->Initialize(starting_url); - if (rv) { - if (result) - *result = shell; - TestShell::windowList()->push_back(shell->m_mainWnd); - } - return rv; -} - -void TestShell::ShutdownTestShell() { - PlatformShutdown(); - SimpleResourceLoaderBridge::Shutdown(); - delete window_list_; - delete TestShell::web_prefs_; -} - -// All fatal log messages (e.g. DCHECK failures) imply unit test failures -static void UnitTestAssertHandler(const std::string& str) { - FAIL() << str; -} - -// static -void TestShell::InitLogging(bool suppress_error_dialogs, - bool layout_test_mode, - bool enable_gp_fault_error_box) { - if (suppress_error_dialogs) - logging::SetLogAssertHandler(UnitTestAssertHandler); - -#if defined(OS_WIN) - if (!IsDebuggerPresent()) { - UINT new_flags = SEM_FAILCRITICALERRORS | - SEM_NOOPENFILEERRORBOX; - if (!enable_gp_fault_error_box) - new_flags |= SEM_NOGPFAULTERRORBOX; - - // Preserve existing error mode, as discussed at - // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx - UINT existing_flags = SetErrorMode(new_flags); - SetErrorMode(existing_flags | new_flags); - } -#endif - - // Only log to a file if we're running layout tests. This prevents debugging - // output from disrupting whether or not we pass. - logging::LoggingDestination destination = - logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG; - if (layout_test_mode) - destination = logging::LOG_ONLY_TO_FILE; - - // We might have multiple test_shell processes going at once - base::FilePath log_filename; - PathService::Get(base::DIR_EXE, &log_filename); - log_filename = log_filename.AppendASCII("test_shell.log"); - logging::InitLogging( - log_filename.value().c_str(), - destination, - logging::LOCK_LOG_FILE, - logging::DELETE_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); - - // we want process and thread IDs because we may have multiple processes - logging::SetLogItems(true, true, false, true); - - // Turn on logging of notImplemented()s inside WebKit, but only if we're - // not running layout tests (because otherwise they'd corrupt the test - // output). - if (!layout_test_mode) - webkit_glue::EnableWebCoreLogChannels("NotYetImplemented"); -} - -// static -void TestShell::CleanupLogging() { - logging::CloseLogFile(); -} - -// static -void TestShell::SetAllowScriptsToCloseWindows() { - if (web_prefs_) - web_prefs_->allow_scripts_to_close_windows = true; -} - -// static -void TestShell::SetAccelerated2dCanvasEnabled(bool enabled) { - accelerated_2d_canvas_enabled_ = enabled; -} - -// static -void TestShell::SetAcceleratedCompositingEnabled(bool enabled) { - accelerated_compositing_enabled_ = enabled; -} - -// static -void TestShell::ResetWebPreferences() { - DCHECK(web_prefs_); - - // Match the settings used by Mac DumpRenderTree, with the exception of - // fonts. - if (web_prefs_) { - *web_prefs_ = WebPreferences(); - -#if defined(OS_MACOSX) - web_prefs_->serif_font_family_map[webkit_glue::kCommonScript] = - ASCIIToUTF16("Times"); - web_prefs_->cursive_font_family_map[webkit_glue::kCommonScript] = - ASCIIToUTF16("Apple Chancery"); - web_prefs_->fantasy_font_family_map[webkit_glue::kCommonScript] = - ASCIIToUTF16("Papyrus"); -#else - // NOTE: case matters here, this must be 'times new roman', else - // some layout tests fail. - web_prefs_->serif_font_family_map[webkit_glue::kCommonScript] = - ASCIIToUTF16("times new roman"); - - // These two fonts are picked from the intersection of - // Win XP font list and Vista font list : - // http://www.microsoft.com/typography/fonts/winxp.htm - // http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx - // Some of them are installed only with CJK and complex script - // support enabled on Windows XP and are out of consideration here. - // (although we enabled both on our buildbots.) - // They (especially Impact for fantasy) are not typical cursive - // and fantasy fonts, but it should not matter for layout tests - // as long as they're available. - web_prefs_->cursive_font_family_map[webkit_glue::kCommonScript] = - ASCIIToUTF16("Comic Sans MS"); - web_prefs_->fantasy_font_family_map[webkit_glue::kCommonScript] = - ASCIIToUTF16("Impact"); -#endif - web_prefs_->standard_font_family_map[webkit_glue::kCommonScript] = - web_prefs_->serif_font_family_map[webkit_glue::kCommonScript]; - web_prefs_->fixed_font_family_map[webkit_glue::kCommonScript] = - ASCIIToUTF16("Courier"); - web_prefs_->sans_serif_font_family_map[webkit_glue::kCommonScript] = - ASCIIToUTF16("Helvetica"); - - web_prefs_->default_encoding = "ISO-8859-1"; - web_prefs_->default_font_size = 16; - web_prefs_->default_fixed_font_size = 13; - web_prefs_->minimum_font_size = 0; - web_prefs_->minimum_logical_font_size = 9; - web_prefs_->javascript_can_open_windows_automatically = true; - web_prefs_->dom_paste_enabled = true; - web_prefs_->site_specific_quirks_enabled = true; - web_prefs_->shrinks_standalone_images_to_fit = false; - web_prefs_->uses_universal_detector = false; - web_prefs_->java_enabled = false; - web_prefs_->allow_scripts_to_close_windows = false; - web_prefs_->javascript_can_access_clipboard = true; - web_prefs_->xss_auditor_enabled = false; - // It's off by default for Chrome, but we don't want to - // lose the coverage of dynamic font tests in webkit test. - web_prefs_->remote_fonts_enabled = true; - web_prefs_->local_storage_enabled = true; - web_prefs_->application_cache_enabled = true; - web_prefs_->databases_enabled = true; - web_prefs_->allow_file_access_from_file_urls = true; - // LayoutTests were written with Safari Mac in mind which does not allow - // tabbing to links by default. - web_prefs_->tabs_to_links = false; - web_prefs_->accelerated_2d_canvas_enabled = - accelerated_2d_canvas_enabled_; - web_prefs_->accelerated_compositing_enabled = - accelerated_compositing_enabled_; - // Allow those layout tests running as local files, i.e. under - // LayoutTests/http/tests/local, to access http server. - if (layout_test_mode_) - web_prefs_->allow_universal_access_from_file_urls = true; - web_prefs_->visual_word_movement_enabled = false; - } -} - -// static -WebPreferences* TestShell::GetWebPreferences() { - DCHECK(web_prefs_); - return web_prefs_; -} - -// static -bool TestShell::RemoveWindowFromList(gfx::NativeWindow window) { - WindowList::iterator entry = - std::find(TestShell::windowList()->begin(), - TestShell::windowList()->end(), - window); - if (entry != TestShell::windowList()->end()) { - TestShell::windowList()->erase(entry); - return true; - } - - return false; -} - -void TestShell::Show(WebNavigationPolicy policy) { - delegate_->show(policy); -} - -void TestShell::DumpBackForwardEntry(int index, base::string16* result) { - int current_index = navigation_controller_->GetLastCommittedEntryIndex(); - - std::string content_state = - navigation_controller_->GetEntryAtIndex(index)->GetContentState(); - if (content_state.empty()) { - content_state = webkit_glue::CreateHistoryStateForURL( - navigation_controller_->GetEntryAtIndex(index)->GetURL()); - } - - result->append( - webkit_glue::DumpHistoryState(content_state, 8, index == current_index)); -} - -void TestShell::DumpBackForwardList(base::string16* result) { - result->append(ASCIIToUTF16( - "\n============== Back Forward List ==============\n")); - - for (int i = 0; i < navigation_controller_->GetEntryCount(); ++i) - DumpBackForwardEntry(i, result); - - result->append(ASCIIToUTF16( - "===============================================\n")); -} - -void TestShell::CallJSGC() { - webView()->mainFrame()->collectGarbage(); -} - -WebView* TestShell::CreateWebView() { - // If we're running layout tests, only open a new window if the test has - // called testRunner.setCanOpenWindows() - if (layout_test_mode_) - return NULL; - - TestShell* new_win; - if (!CreateNewWindow(GURL(), &new_win)) - return NULL; - - return new_win->webView(); -} - -void TestShell::ShowDevTools() { - if (!devtools_shell_) { - base::FilePath dir_exe; - PathService::Get(base::DIR_EXE, &dir_exe); - base::FilePath devtools_path = - dir_exe.AppendASCII("resources/inspector/devtools.html"); - TestShell* devtools_shell; - TestShell::CreateNewWindow(GURL(devtools_path.value()), - &devtools_shell); - devtools_shell_ = devtools_shell->AsWeakPtr(); - devtools_shell_->CreateDevToolsClient(dev_tools_agent_.get()); - } - DCHECK(devtools_shell_); - devtools_shell_->Show(WebKit::WebNavigationPolicyNewWindow); -} - -void TestShell::CloseDevTools() { - if (devtools_shell_) - devtools_shell_->DestroyWindow(devtools_shell_->mainWnd()); -} - -void TestShell::CreateDevToolsClient(TestShellDevToolsAgent *agent) { - dev_tools_client_.reset(new TestShellDevToolsClient(agent, - webView())); -} - -bool TestShell::IsSVGTestURL(const GURL& url) { - return url.is_valid() && url.spec().find("W3C-SVG-1.1") != std::string::npos; -} - -void TestShell::SizeToSVG() { - SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); -} - -void TestShell::SizeToDefault() { - SizeTo(kTestWindowWidth, kTestWindowHeight); -} - -void TestShell::ResetTestController() { - notification_presenter_->Reset(); - delegate_->Reset(); - if (geolocation_client_mock_) - geolocation_client_mock_->resetMock(); -} - -void TestShell::LoadFile(const base::FilePath& file) { - LoadURLForFrame(net::FilePathToFileURL(file), base::string16()); -} - -void TestShell::LoadURL(const GURL& url) { - LoadURLForFrame(url, base::string16()); -} - -bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { - // Get the right target frame for the entry. - WebFrame* frame = webView()->mainFrame(); - if (!entry.GetTargetFrame().empty()) - frame = webView()->findFrameByName(entry.GetTargetFrame()); - - // TODO(mpcomplete): should we clear the target frame, or should - // back/forward navigations maintain the target frame? - - // A navigation resulting from loading a javascript URL should not be - // treated as a browser initiated event. Instead, we want it to look as if - // the page initiated any load resulting from JS execution. - if (!entry.GetURL().SchemeIs("javascript")) { - delegate_->set_pending_extra_data( - new TestShellExtraData(entry.GetPageID())); - } - - // If we are reloading, then WebKit will use the state of the current page. - // Otherwise, we give it the state to navigate to. - if (reload) { - frame->reload(false); - } else if (!entry.GetContentState().empty()) { - DCHECK_NE(entry.GetPageID(), -1); - frame->loadHistoryItem( - webkit_glue::HistoryItemFromString(entry.GetContentState())); - } else { - DCHECK_EQ(entry.GetPageID(), -1); - frame->loadRequest(WebURLRequest(entry.GetURL())); - } - - // In case LoadRequest failed before DidCreateDataSource was called. - delegate_->set_pending_extra_data(NULL); - - // Restore focus to the main frame prior to loading new request. - // This makes sure that we don't have a focused iframe. Otherwise, that - // iframe would keep focus when the SetFocus called immediately after - // LoadRequest, thus making some tests fail (see http://b/issue?id=845337 - // for more details). - webView()->setFocusedFrame(frame); - SetFocus(webViewHost(), true); - - return true; -} - -void TestShell::GoBackOrForward(int offset) { - navigation_controller_->GoToOffset(offset); -} - -void TestShell::DumpDocumentText() { - base::FilePath file_path; - if (!PromptForSaveFile(L"Dump document text", &file_path)) - return; - - const std::string data = - UTF16ToUTF8(webkit_glue::DumpDocumentText(webView()->mainFrame())); - file_util::WriteFile(file_path, data.c_str(), data.length()); -} - -void TestShell::DumpRenderTree() { - base::FilePath file_path; - if (!PromptForSaveFile(L"Dump render tree", &file_path)) - return; - - const std::string data = - UTF16ToUTF8(webkit_glue::DumpRenderer(webView()->mainFrame())); - file_util::WriteFile(file_path, data.c_str(), data.length()); -} - -base::string16 TestShell::GetDocumentText() { - return webkit_glue::DumpDocumentText(webView()->mainFrame()); -} - -void TestShell::Reload() { - navigation_controller_->Reload(); -} - -void TestShell::SetFocus(WebWidgetHost* host, bool enable) { - if (!layout_test_mode_) { - InteractiveSetFocus(host, enable); - } else { - // Simulate the effects of InteractiveSetFocus(), which includes calling - // both setFocus() and setIsActive(). - if (enable) { - if (m_focusedWidgetHost != host) { - if (m_focusedWidgetHost) - m_focusedWidgetHost->webwidget()->setFocus(false); - webView()->setIsActive(enable); - host->webwidget()->setFocus(enable); - m_focusedWidgetHost = host; - } - } else { - if (m_focusedWidgetHost == host) { - host->webwidget()->setFocus(enable); - webView()->setIsActive(enable); - m_focusedWidgetHost = NULL; - } - } - } -} - -WebKit::WebDeviceOrientationClientMock* -TestShell::device_orientation_client_mock() { - if (!device_orientation_client_mock_) { - device_orientation_client_mock_.reset( - WebKit::WebDeviceOrientationClientMock::create()); - } - return device_orientation_client_mock_.get(); -} - -WebKit::WebGeolocationClientMock* TestShell::geolocation_client_mock() { - if (!geolocation_client_mock_) { - geolocation_client_mock_.reset( - WebKit::WebGeolocationClientMock::create()); - } - return geolocation_client_mock_.get(); -} diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index d8b744b..0c8e3d3 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -3,23 +3,6 @@ # found in the LICENSE file. { - 'variables': { - 'test_shell_windows_resource_files': [ - 'resources/test_shell.rc', - '../../../ui/resources/cursors/pan_east.cur', - '../../../ui/resources/cursors/pan_middle.cur', - '../../../ui/resources/cursors/pan_north.cur', - '../../../ui/resources/cursors/pan_north_east.cur', - '../../../ui/resources/cursors/pan_north_west.cur', - '../../../ui/resources/cursors/pan_south.cur', - '../../../ui/resources/cursors/pan_south_east.cur', - '../../../ui/resources/cursors/pan_south_west.cur', - '../../../ui/resources/cursors/pan_west.cur', - 'resources/small.ico', - 'resources/test_shell.ico', - 'resource.h', - ], - }, 'targets': [ { 'target_name': 'pull_in_copy_TestNetscapePlugIn', @@ -47,314 +30,15 @@ ['OS=="win" or OS=="mac" or toolkit_uses_gtk==1', { 'targets': [ { - 'target_name': 'test_shell_common', - 'type': 'static_library', - 'variables': { - 'chromium_code': 1, - }, - 'dependencies': [ - '../build/temp_gyp/googleurl.gyp:googleurl', - '<(DEPTH)/base/base.gyp:base', - '<(DEPTH)/base/base.gyp:base_i18n', - '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', - '<(DEPTH)/gpu/gpu.gyp:gles2_c_lib', - '<(DEPTH)/media/media.gyp:media', - '<(DEPTH)/net/net.gyp:net', - '<(DEPTH)/skia/skia.gyp:skia', - '<(DEPTH)/testing/gmock.gyp:gmock', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(DEPTH)/third_party/WebKit/Source/devtools/devtools.gyp:devtools_frontend_resources', - '<(DEPTH)/third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit', - '<(DEPTH)/ui/native_theme/native_theme.gyp:native_theme', - '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', - '<(DEPTH)/webkit/gpu/webkit_gpu.gyp:webkit_gpu', - '<(DEPTH)/webkit/support/webkit_support.gyp:glue', - '<(DEPTH)/webkit/support/webkit_support.gyp:user_agent', - '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_base', - '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_media', - '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_resources', - '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_storage', - '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_support_common', - ], - 'sources': [ - 'mac/test_shell_webview.h', - 'mac/test_shell_webview.mm', - 'accessibility_ui_element.cc', - 'accessibility_ui_element.h', - 'drop_delegate.cc', - 'drop_delegate.h', - 'mock_spellcheck.cc', - 'mock_spellcheck.h', - 'notification_presenter.cc', - 'notification_presenter.h', - 'resource.h', - 'test_navigation_controller.cc', - 'test_navigation_controller.h', - 'test_shell.cc', - 'test_shell.h', - 'test_shell_devtools_agent.cc', - 'test_shell_devtools_agent.h', - 'test_shell_devtools_callargs.cc', - 'test_shell_devtools_callargs.h', - 'test_shell_devtools_client.cc', - 'test_shell_devtools_client.h', - 'test_shell_gtk.cc', - 'test_shell_x11.cc', - 'test_shell_mac.mm', - 'test_shell_platform_delegate.h', - 'test_shell_platform_delegate_gtk.cc', - 'test_shell_platform_delegate_mac.mm', - 'test_shell_platform_delegate_win.cc', - 'test_shell_switches.cc', - 'test_shell_switches.h', - 'test_shell_win.cc', - 'test_shell_webkit_init.cc', - 'test_shell_webkit_init.h', - 'test_shell_webthemecontrol.h', - 'test_shell_webthemecontrol.cc', - 'test_shell_webthemeengine.h', - 'test_shell_webthemeengine.cc', - 'test_webview_delegate.cc', - 'test_webview_delegate.h', - 'test_webview_delegate_mac.mm', - 'test_webview_delegate_gtk.cc', - 'test_webview_delegate_win.cc', - 'webview_host.h', - 'webview_host_gtk.cc', - 'webview_host_mac.mm', - 'webview_host_win.cc', - 'webwidget_host.h', - 'webwidget_host.cc', - 'webwidget_host_gtk.cc', - 'webwidget_host_mac.mm', - 'webwidget_host_win.cc', - ], - 'export_dependent_settings': [ - '<(DEPTH)/base/base.gyp:base', - '<(DEPTH)/net/net.gyp:net', - '<(DEPTH)/third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit', - '<(DEPTH)/webkit/support/webkit_support.gyp:glue', - '<(DEPTH)/webkit/support/webkit_support.gyp:user_agent', - ], - 'conditions': [ - ['OS!="android" and OS!="ios"', { - # npapi test plugin doesn't build on android or ios - 'dependencies': [ - 'copy_npapi_test_plugin', - ], - }], - ['use_x11==1', { - 'dependencies': [ - '<(DEPTH)/tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck', - ], - }], - ['toolkit_uses_gtk == 1', { - 'dependencies': [ - 'test_shell_resources', - '<(DEPTH)/build/linux/system.gyp:gtk', - ], - # for: test_shell_gtk.cc - 'cflags': ['-Wno-multichar'], - }], - ['OS=="win"', { - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4800, 4267 ], - 'link_settings': { - 'libraries': [ - '-lcomctl32.lib', - ], - }, - 'include_dirs': [ - '<(DEPTH)/third_party/wtl/include', - '.', - ], - 'dependencies': [ - '<(DEPTH)/breakpad/breakpad.gyp:breakpad_handler', - ], - }, { # else: OS!=win - 'sources/': [ - ['exclude', '_webtheme(control|engine)\.(cc|h)$'], - ], - 'sources!': [ - 'drop_delegate.cc', - ], - }], - ], - }, - { - 'target_name': 'test_shell_pak', - 'type': 'none', - 'variables': { - 'repack_path': '../../../tools/grit/grit/format/repack.py', - 'pak_path': '<(INTERMEDIATE_DIR)/repack/test_shell.pak', - }, - 'conditions': [ - ['os_posix == 1 and OS != "mac"', { - 'actions': [ - { - 'action_name': 'test_shell_repack', - 'variables': { - 'pak_inputs': [ - '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/test_shell/test_shell_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources_100_percent.pak', - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources_100_percent.pak', - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.pak', - ], - }, - 'inputs': [ - '<(repack_path)', - '<@(pak_inputs)', - ], - 'outputs': [ - '<(pak_path)', - ], - 'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'], - }, - ], - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)', - 'files': ['<(pak_path)'], - }, - ], - }], - ], - }, - { + # TODO(darin): Delete this dummy target once the build masters stop + # trying to build it. 'target_name': 'test_shell', - 'type': 'executable', - 'variables': { - 'chromium_code': 1, - }, - 'mac_bundle': 1, - 'dependencies': [ - 'test_shell_common', - '<(DEPTH)/net/net.gyp:net_test_support', - '<(DEPTH)/skia/skia.gyp:skia', - '<(DEPTH)/third_party/mesa/mesa.gyp:osmesa', - 'pull_in_copy_TestNetscapePlugIn', - '<(DEPTH)/tools/imagediff/image_diff.gyp:image_diff', - '<(DEPTH)/ui/gl/gl.gyp:gl', - ], - 'defines': [ - # Technically not a unit test but require functions available only to - # unit tests. - 'UNIT_TEST' - ], + 'type': 'static_library', 'sources': [ - 'test_shell_main.cc', - ], - 'mac_bundle_resources': [ - '../../data/test_shell/', - 'mac/English.lproj/InfoPlist.strings', - 'mac/English.lproj/MainMenu.xib', - 'mac/Info.plist', - 'mac/test_shell.icns', - 'resources/AHEM____.TTF', - ], - 'mac_bundle_resources!': [ - # TODO(mark): Come up with a fancier way to do this (mac_info_plist?) - # that automatically sets the correct INFOPLIST_FILE setting and adds - # the file to a source group. - 'mac/Info.plist', - ], - 'xcode_settings': { - 'INFOPLIST_FILE': '<(DEPTH)/webkit/tools/test_shell/mac/Info.plist', - }, - 'conditions': [ - ['OS=="win"', { - 'resource_include_dirs': [ - '<(SHARED_INTERMEDIATE_DIR)/webkit', - ], - 'sources': [ - '<@(test_shell_windows_resource_files)', - # TODO: It would be nice to have these pulled in - # automatically from direct_dependent_settings in - # their various targets (net.gyp:net_resources, etc.), - # but that causes errors in other targets when - # resulting .res files get referenced multiple times. - '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_unscaled_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.rc', - ], - 'configurations': { - 'Debug_Base': { - 'msvs_settings': { - 'VCLinkerTool': { - 'LinkIncremental': '<(msvs_large_module_debug_link_mode)', - }, - }, - }, - }, - }], - ['toolkit_uses_gtk == 1', { - 'conditions': [ - ['linux_use_tcmalloc==1', { - 'dependencies': [ - '<(DEPTH)/base/allocator/allocator.gyp:allocator', - ], - }], - ], - 'dependencies': [ - '<(DEPTH)/build/linux/system.gyp:gtk', - 'test_shell_resources', - 'test_shell_pak', - ], - }], - ['OS=="mac"', { - 'product_name': 'TestShell', - 'dependencies': [ - '<(DEPTH)/third_party/mesa/mesa.gyp:osmesa', - ], - 'variables': { - 'repack_path': '../../../tools/grit/grit/format/repack.py', - }, - 'actions': [ - { - # TODO(mark): Make this work with more languages than the - # hardcoded en-US. - 'action_name': 'repack_locale', - 'variables': { - 'pak_inputs': [ - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.pak', - '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources_100_percent.pak', - ], - }, - 'inputs': [ - '<(repack_path)', - '<@(pak_inputs)', - ], - 'outputs': [ - '<(INTERMEDIATE_DIR)/repack/test_shell.pak', - ], - 'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'], - 'process_outputs_as_mac_bundle_resources': 1, - }, - ], - 'copies': [ - { - # Copy FFmpeg binaries for audio/video support. - 'destination': '<(PRODUCT_DIR)/TestShell.app/Contents/MacOS/', - 'files': [ - '<(PRODUCT_DIR)/ffmpegsumo.so', - ], - }, - ], - }, { # OS != "mac" - 'dependencies': [ - '<(DEPTH)/net/net.gyp:net_resources', - '<(DEPTH)/ui/ui.gyp:ui_resources', - '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_resources', - '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_strings', - ] - }], + 'test_shell_dummy.cc', ], }, - ], + ], }], ['OS!="android" and OS!="ios"', { # npapi test plugin doesn't build on android or ios @@ -510,24 +194,5 @@ }, ], }], - ['os_posix == 1 and OS != "mac"', { - 'targets': [ - { - 'target_name': 'test_shell_resources', - 'type': 'none', - 'variables': { - 'grit_grd_file': './test_shell_resources.grd', - 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/test_shell', - }, - 'actions': [ - { - 'action_name': 'test_shell_resources', - 'includes': [ '../../../build/grit_action.gypi' ], - }, - ], - 'includes': [ '../../../build/grit_target.gypi' ], - }, - ], - }], ], } diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h deleted file mode 100644 index d6db56c..0000000 --- a/webkit/tools/test_shell/test_shell.h +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ - - -#include <list> -#include <map> -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/files/file_path.h" -#include "base/files/scoped_temp_dir.h" -#include "base/lazy_instance.h" -#include "base/memory/ref_counted.h" -#include "base/memory/weak_ptr.h" -#include "base/strings/string_piece.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationPolicy.h" -#include "ui/gfx/native_widget_types.h" -#include "webkit/tools/test_shell/webview_host.h" -#include "webkit/tools/test_shell/webwidget_host.h" - -typedef std::list<gfx::NativeWindow> WindowList; - -#if defined(OS_WIN) -namespace ui { -class ScopedOleInitializer; -} -#endif - -class GURL; -class TestNavigationEntry; -class TestNavigationController; -class TestNotificationPresenter; -class TestShellDevToolsAgent; -class TestShellDevToolsClient; -class TestWebViewDelegate; -struct WebPreferences; - -namespace WebKit { -class WebDeviceOrientationClientMock; -class WebGeolocationClientMock; -} - -class TestShell : public base::SupportsWeakPtr<TestShell> { -public: - struct TestParams { - // Load the test defaults. - TestParams(); - - // The kind of output we want from this test. - bool dump_tree; - bool dump_pixels; - - // Filename we dump pixels to (when pixel testing is enabled). - base::FilePath pixel_file_name; - // The md5 hash of the bitmap dump (when pixel testing is enabled). - std::string pixel_hash; - // URL of the test. - std::string test_url; - }; - - TestShell(); - virtual ~TestShell(); - - // Initialization and clean up of logging. - static void InitLogging(bool suppress_error_dialogs, - bool running_layout_tests, - bool enable_gp_fault_error_box); - static void CleanupLogging(); - - // Initialization and clean up of a static member variable. - static void InitializeTestShell(bool layout_test_mode, - bool allow_external_pages); - static void ShutdownTestShell(); - - static bool layout_test_mode() { return layout_test_mode_; } - static bool allow_external_pages() { return allow_external_pages_; } - - // Called from the destructor to let each platform do any necessary - // cleanup. - void PlatformCleanUp(); - - WebKit::WebView* webView() { - return m_webViewHost.get() ? m_webViewHost->webview() : NULL; - } - WebViewHost* webViewHost() { return m_webViewHost.get(); } - WebKit::WebWidget* popup() { - return m_popupHost ? m_popupHost->webwidget() : NULL; - } - WebWidgetHost* popupHost() { return m_popupHost; } - - bool is_loading() const { return is_loading_; } - void set_is_loading(bool is_loading) { is_loading_ = is_loading; } - - bool allow_images() const { return allow_images_; } - void set_allow_images(bool allow) { allow_images_ = allow; } - - bool allow_plugins() const { return allow_plugins_; } - void set_allow_plugins(bool allow) { allow_plugins_ = allow; } - - bool allow_scripts() const { return allow_scripts_; } - void set_allow_scripts(bool allow) { allow_scripts_ = allow; } - - void UpdateNavigationControls(); - - // A new TestShell window will be opened with devtools url. - // DevTools window can be opened manually via menu or automatically when - // inspector's layout test url is passed from command line or console. - void ShowDevTools(); - void CloseDevTools(); - - void Show(WebKit::WebNavigationPolicy policy); - - // We use this to avoid relying on Windows focus during layout test mode. - void SetFocus(WebWidgetHost* host, bool enable); - - TestWebViewDelegate* delegate() { return delegate_.get(); } - TestWebViewDelegate* popup_delegate() { return popup_delegate_.get(); } - TestNavigationController* navigation_controller() { - return navigation_controller_.get(); - } - TestNotificationPresenter* notification_presenter() { - return notification_presenter_.get(); - } - - // Resets TestWebViewDelegate. Should be called before loading a page, - // since some end-editing event notifications may arrive after the previous - // page has finished dumping its text and therefore end up in the next - // test's results if the messages are still enabled. - void ResetTestController(); - - bool AcceptsEditing() { - return true; - } - - void LoadFile(const base::FilePath& file); - void LoadURL(const GURL& url); - void LoadURLForFrame(const GURL& url, const base::string16& frame_name); - void GoBackOrForward(int offset); - void Reload(); - bool Navigate(const TestNavigationEntry& entry, bool reload); - - bool PromptForSaveFile(const wchar_t* prompt_title, base::FilePath* result); - base::string16 GetDocumentText(); - void DumpDocumentText(); - void DumpRenderTree(); - - gfx::NativeWindow mainWnd() const { return m_mainWnd; } - gfx::NativeView webViewWnd() const { return m_webViewHost->view_handle(); } - gfx::NativeEditView editWnd() const { return m_editWnd; } - gfx::NativeView popupWnd() const { return m_popupHost->view_handle(); } - - static WindowList* windowList() { return window_list_; } - - // If shell is non-null, then *shell is assigned upon successful return - static bool CreateNewWindow(const GURL& starting_url, - TestShell** shell = NULL); - - static void DestroyWindow(gfx::NativeWindow windowHandle); - - // Remove the given window from window_list_, return true if it was in the - // list and was removed and false otherwise. - static bool RemoveWindowFromList(gfx::NativeWindow window); - - // Implements CreateWebView for TestWebViewDelegate, which in turn - // is called as a WebViewDelegate. - WebKit::WebView* CreateWebView(); - WebKit::WebWidget* CreatePopupWidget(); - void ClosePopup(); - -#if defined(OS_WIN) - static ATOM RegisterWindowClass(); -#endif - - // Writes the back-forward list data for every open window into result. - // Should call DumpBackForwardListOfWindow on each TestShell window. - static void DumpAllBackForwardLists(base::string16* result); - - // Writes the single back-forward entry into result. - void DumpBackForwardEntry(int index, base::string16* result); - - // Writes the back-forward list data for this test shell into result. - void DumpBackForwardList(base::string16* result); - - static void ResetWebPreferences(); - - static void SetAllowScriptsToCloseWindows(); - - static void SetAccelerated2dCanvasEnabled(bool enabled); - static void SetAcceleratedCompositingEnabled(bool enabled); - - static WebPreferences* GetWebPreferences(); - - // Some layout tests hardcode a file:///tmp/LayoutTests URL. We get around - // this by substituting "tmp" with the path to the LayoutTests parent dir. - static std::string RewriteLocalUrl(const std::string& url); - - // Set the JavaScript flags to use. This is a vector as when multiple loads - // are specified each load can have different flags passed. - static void SetJavaScriptFlags(std::vector<std::string> js_flags) { - js_flags_ = js_flags; - } - - // Get the JavaScript flags for a specific load - static std::string GetJSFlagsForLoad(size_t load) { - if (load >= js_flags_.size()) - return std::string(); - return js_flags_[load]; - } - - // Have the shell print the StatsTable to stdout on teardown. - void DumpStatsTableOnExit() { dump_stats_table_on_exit_ = true; } - - void CallJSGC(); - - void set_is_modal(bool value) { is_modal_ = value; } - bool is_modal() const { return is_modal_; } - - const TestParams* test_params() { return test_params_; } - void set_test_params(const TestParams* test_params) { - test_params_ = test_params; - } - -#if defined(OS_MACOSX) - // handle cleaning up a shell given the associated window - static void DestroyAssociatedShell(gfx::NativeWindow handle); -#endif - - // Show the "attach to me" dialog, for debugging test shell startup. - static void ShowStartupDebuggingDialog(); - - // This is called indirectly by the modules that need access resources. - static base::StringPiece ResourceProvider(int key); - - TestShellDevToolsAgent* dev_tools_agent() { - return dev_tools_agent_.get(); - } - - WebKit::WebDeviceOrientationClientMock* device_orientation_client_mock(); - - WebKit::WebGeolocationClientMock* geolocation_client_mock(); - -protected: - void CreateDevToolsClient(TestShellDevToolsAgent* agent); - bool Initialize(const GURL& starting_url); - bool IsSVGTestURL(const GURL& url); - void SizeToSVG(); - void SizeToDefault(); - void SizeTo(int width, int height); - void ResizeSubViews(); - - // Set the focus in interactive mode (pass through to relevant system call). - void InteractiveSetFocus(WebWidgetHost* host, bool enable); - - enum UIControl { - BACK_BUTTON, - FORWARD_BUTTON, - STOP_BUTTON - }; - - void EnableUIControl(UIControl control, bool is_enabled); - -#if defined(OS_WIN) - static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); - static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM); -#endif - - static void PlatformShutdown(); - - gfx::NativeWindow m_mainWnd; - gfx::NativeEditView m_editWnd; - scoped_ptr<WebViewHost> m_webViewHost; - WebWidgetHost* m_popupHost; -#if defined(OS_WIN) - WNDPROC default_edit_wnd_proc_; -#endif - - // Primitive focus controller for layout test mode. - WebWidgetHost* m_focusedWidgetHost; - -private: - // A set of all our windows. - static WindowList* window_list_; -#if defined(OS_MACOSX) - typedef std::map<gfx::NativeWindow, TestShell *> WindowMap; - static base::LazyInstance<WindowMap> window_map_; -#endif - -#if defined(OS_WIN) - static HINSTANCE instance_handle_; - - static ui::ScopedOleInitializer* ole_initializer_; -#endif - - // True when the app is being run using the --layout-tests switch. - static bool layout_test_mode_; - - // True when we wish to allow test shell to load external pages like - // www.google.com even when in --layout-test mode (used for QA to - // produce images of the rendered page) - static bool allow_external_pages_; - - scoped_ptr<TestNavigationController> navigation_controller_; - scoped_ptr<TestNotificationPresenter> notification_presenter_; - - scoped_ptr<TestWebViewDelegate> delegate_; - scoped_ptr<TestWebViewDelegate> popup_delegate_; - - base::WeakPtr<TestShell> devtools_shell_; - scoped_ptr<TestShellDevToolsAgent> dev_tools_agent_; - scoped_ptr<TestShellDevToolsClient> dev_tools_client_; - scoped_ptr<WebKit::WebDeviceOrientationClientMock> - device_orientation_client_mock_; - scoped_ptr<WebKit::WebGeolocationClientMock> geolocation_client_mock_; - - const TestParams* test_params_; - - // JavaScript flags. Each element in the vector contains a set of flags as - // a string (e.g. "--xxx --yyy"). Each flag set is used for separate loads - // of each URL. - static std::vector<std::string> js_flags_; - - // True if we're testing the accelerated canvas 2d path. - static bool accelerated_2d_canvas_enabled_; - - // True if we're testing the accelerated compositing. - static bool accelerated_compositing_enabled_; - - // True if driven from a nested message loop. - bool is_modal_; - - // True if the page is loading. - bool is_loading_; - - bool allow_images_; - bool allow_plugins_; - bool allow_scripts_; - - // The preferences for the test shell. - static WebPreferences* web_prefs_; - - // Dump the stats table counters on exit. - bool dump_stats_table_on_exit_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ diff --git a/webkit/tools/test_shell/test_shell_devtools_agent.cc b/webkit/tools/test_shell/test_shell_devtools_agent.cc deleted file mode 100644 index 640926d..0000000 --- a/webkit/tools/test_shell/test_shell_devtools_agent.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_shell_devtools_agent.h" - -#include "base/bind.h" -#include "base/message_loop.h" -#include "grit/webkit_chromium_resources.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "webkit/tools/test_shell/test_shell_devtools_callargs.h" -#include "webkit/tools/test_shell/test_shell_devtools_client.h" -#include "webkit/glue/webkit_glue.h" - -using WebKit::WebCString; -using WebKit::WebDevToolsAgent; -using WebKit::WebDevToolsMessageData; -using WebKit::WebString; -using WebKit::WebView; - -namespace { - -class WebKitClientMessageLoopImpl - : public WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop { - public: - WebKitClientMessageLoopImpl() : message_loop_(base::MessageLoop::current()) {} - virtual ~WebKitClientMessageLoopImpl() { message_loop_ = NULL; } - virtual void run() { - base::MessageLoop::ScopedNestableTaskAllower allow(message_loop_); - message_loop_->Run(); - } - virtual void quitNow() { - message_loop_->QuitNow(); - } - private: - base::MessageLoop* message_loop_; -}; - -} // namespace - -TestShellDevToolsAgent::TestShellDevToolsAgent() - : weak_factory_(this), - dev_tools_client_(NULL) { - static int dev_tools_agent_counter; - routing_id_ = ++dev_tools_agent_counter; -} - -TestShellDevToolsAgent::~TestShellDevToolsAgent() { -} - -void TestShellDevToolsAgent::SetWebView(WebKit::WebView* web_view) { - web_view_ = web_view; -} - -void TestShellDevToolsAgent::sendMessageToInspectorFrontend( - const WebString& data) { - if (dev_tools_client_) - dev_tools_client_->AsyncCall(TestShellDevToolsCallArgs(data)); -} - -int TestShellDevToolsAgent::hostIdentifier() { - return routing_id_; -} - -void TestShellDevToolsAgent::runtimePropertyChanged( - const WebKit::WebString& name, - const WebKit::WebString& value) { - // TODO: Implement. -} - -WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* - TestShellDevToolsAgent::createClientMessageLoop() { - return new WebKitClientMessageLoopImpl(); -} - -void TestShellDevToolsAgent::AsyncCall(const TestShellDevToolsCallArgs &args) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&TestShellDevToolsAgent::Call, weak_factory_.GetWeakPtr(), - args)); -} - -void TestShellDevToolsAgent::Call(const TestShellDevToolsCallArgs &args) { - WebDevToolsAgent* web_agent = GetWebAgent(); - if (web_agent) - web_agent->dispatchOnInspectorBackend(args.data_); - if (TestShellDevToolsCallArgs::calls_count() == 1 && dev_tools_client_) - dev_tools_client_->all_messages_processed(); -} - -WebDevToolsAgent* TestShellDevToolsAgent::GetWebAgent() { - if (!web_view_) - return NULL; - return web_view_->devToolsAgent(); -} - -void TestShellDevToolsAgent::attach(TestShellDevToolsClient* client) { - DCHECK(!dev_tools_client_); - dev_tools_client_ = client; - WebDevToolsAgent *web_agent = GetWebAgent(); - if (web_agent) - web_agent->attach(); -} - -void TestShellDevToolsAgent::detach() { - DCHECK(dev_tools_client_); - WebDevToolsAgent* web_agent = GetWebAgent(); - if (web_agent) - web_agent->detach(); - dev_tools_client_ = NULL; -} - -bool TestShellDevToolsAgent::evaluateInWebInspector( - long call_id, - const std::string& script) { - WebDevToolsAgent* agent = GetWebAgent(); - if (!agent) - return false; - agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); - return true; -} diff --git a/webkit/tools/test_shell/test_shell_devtools_agent.h b/webkit/tools/test_shell/test_shell_devtools_agent.h deleted file mode 100644 index f562752..0000000 --- a/webkit/tools/test_shell/test_shell_devtools_agent.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_AGENT_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_AGENT_H_ - -#include <string> - -#include "base/memory/weak_ptr.h" - -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgentClient.h" - -namespace WebKit { - -class WebDevToolsAgent; -class WebView; - -} // namespace WebKit - -class TestShellDevToolsCallArgs; -class TestShellDevToolsClient; - -class TestShellDevToolsAgent : public WebKit::WebDevToolsAgentClient { - public: - TestShellDevToolsAgent(); - virtual ~TestShellDevToolsAgent(); - - void SetWebView(WebKit::WebView* web_view); - - // WebDevToolsAgentClient implementation. - virtual void sendMessageToInspectorFrontend( - const WebKit::WebString& data); - virtual int hostIdentifier(); - virtual void runtimePropertyChanged(const WebKit::WebString& name, - const WebKit::WebString& value); - - virtual WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* - createClientMessageLoop(); - - void AsyncCall(const TestShellDevToolsCallArgs& args); - - void attach(TestShellDevToolsClient* client); - void detach(); - - bool evaluateInWebInspector(long call_id, const std::string& script); - - private: - void Call(const TestShellDevToolsCallArgs& args); - WebKit::WebDevToolsAgent* GetWebAgent(); - - base::WeakPtrFactory<TestShellDevToolsAgent> weak_factory_; - TestShellDevToolsClient* dev_tools_client_; - int routing_id_; - WebKit::WebDevToolsAgent* web_dev_tools_agent_; - WebKit::WebView* web_view_; - - DISALLOW_COPY_AND_ASSIGN(TestShellDevToolsAgent); -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_AGENT_H_ diff --git a/webkit/tools/test_shell/test_shell_devtools_callargs.cc b/webkit/tools/test_shell/test_shell_devtools_callargs.cc deleted file mode 100644 index bcdf4b5..0000000 --- a/webkit/tools/test_shell/test_shell_devtools_callargs.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_shell_devtools_callargs.h" - -#include "base/logging.h" - -// static -int TestShellDevToolsCallArgs::calls_count_ = 0; - -TestShellDevToolsCallArgs::TestShellDevToolsCallArgs( - const WebKit::WebString& data) - : data_(data) { - ++calls_count_; -} - -TestShellDevToolsCallArgs::TestShellDevToolsCallArgs( - const TestShellDevToolsCallArgs& args) - : data_(args.data_) { - ++calls_count_; -} - -TestShellDevToolsCallArgs::~TestShellDevToolsCallArgs() { - --calls_count_; - DCHECK(calls_count_ >= 0); -} diff --git a/webkit/tools/test_shell/test_shell_devtools_callargs.h b/webkit/tools/test_shell/test_shell_devtools_callargs.h deleted file mode 100644 index 29e22f2..0000000 --- a/webkit/tools/test_shell/test_shell_devtools_callargs.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_CALLARGS_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_CALLARGS_H_ - -#include "base/basictypes.h" - -#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" - -class TestShellDevToolsCallArgs { - public: - explicit TestShellDevToolsCallArgs(const WebKit::WebString& data); - - TestShellDevToolsCallArgs(const TestShellDevToolsCallArgs& args); - - ~TestShellDevToolsCallArgs(); - - static int calls_count() { return calls_count_; } - - WebKit::WebString data_; - - private: - static int calls_count_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_CALLARGS_H_ diff --git a/webkit/tools/test_shell/test_shell_devtools_client.cc b/webkit/tools/test_shell/test_shell_devtools_client.cc deleted file mode 100644 index a2c661b..0000000 --- a/webkit/tools/test_shell/test_shell_devtools_client.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsFrontend.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" - -#undef LOG -#include "webkit/tools/test_shell/test_shell_devtools_agent.h" -#include "webkit/tools/test_shell/test_shell_devtools_callargs.h" -#include "webkit/tools/test_shell/test_shell_devtools_client.h" - -#include "base/bind.h" -#include "base/command_line.h" -#include "base/message_loop.h" - -using WebKit::WebDevToolsAgent; -using WebKit::WebDevToolsFrontend; -using WebKit::WebDevToolsMessageData; -using WebKit::WebString; -using WebKit::WebView; - -TestShellDevToolsClient::TestShellDevToolsClient(TestShellDevToolsAgent *agent, - WebView* web_view) - : weak_factory_(this), - dev_tools_agent_(agent), - web_view_(web_view) { - web_tools_frontend_.reset(WebDevToolsFrontend::create(web_view_, this, - WebString::fromUTF8("en-US"))); - dev_tools_agent_->attach(this); -} - -TestShellDevToolsClient::~TestShellDevToolsClient() { - // It is a chance that page will be destroyed at detach step of - // dev_tools_agent_ and we should clean pending requests a bit earlier. - weak_factory_.InvalidateWeakPtrs(); - if (dev_tools_agent_) - dev_tools_agent_->detach(); -} - -void TestShellDevToolsClient::sendMessageToBackend( - const WebString& data) { - if (dev_tools_agent_) - dev_tools_agent_->AsyncCall(TestShellDevToolsCallArgs(data)); -} - -void TestShellDevToolsClient::activateWindow() { - NOTIMPLEMENTED(); -} - -void TestShellDevToolsClient::closeWindow() { - NOTIMPLEMENTED(); -} - -void TestShellDevToolsClient::dockWindow() { - NOTIMPLEMENTED(); -} - -void TestShellDevToolsClient::undockWindow() { - NOTIMPLEMENTED(); -} - -void TestShellDevToolsClient::AsyncCall(const TestShellDevToolsCallArgs &args) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&TestShellDevToolsClient::Call, weak_factory_.GetWeakPtr(), - args)); -} - -void TestShellDevToolsClient::Call(const TestShellDevToolsCallArgs &args) { - web_tools_frontend_->dispatchOnInspectorFrontend(args.data_); - if (TestShellDevToolsCallArgs::calls_count() == 1) - all_messages_processed(); -} - -void TestShellDevToolsClient::all_messages_processed() { - web_view_->mainFrame()->executeScript(WebKit::WebScriptSource( - WebString::fromUTF8("if (window.WebInspector && " - "WebInspector.queuesAreEmpty) WebInspector.queuesAreEmpty();"))); -} diff --git a/webkit/tools/test_shell/test_shell_devtools_client.h b/webkit/tools/test_shell/test_shell_devtools_client.h deleted file mode 100644 index a20fe06..0000000 --- a/webkit/tools/test_shell/test_shell_devtools_client.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_CLIENT_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_CLIENT_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" - -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsFrontendClient.h" - -namespace WebKit { - -class WebDevToolsFrontend; - -} // namespace WebKit - -class TestShellDevToolsCallArgs; -class TestShellDevToolsAgent; - -class TestShellDevToolsClient: public WebKit::WebDevToolsFrontendClient { - public: - TestShellDevToolsClient(TestShellDevToolsAgent* agent, - WebKit::WebView* web_view); - virtual ~TestShellDevToolsClient(); - - // WebDevToolsFrontendClient implementation - virtual void sendMessageToBackend(const WebKit::WebString& data); - - virtual void activateWindow(); - virtual void closeWindow(); - virtual void dockWindow(); - virtual void undockWindow(); - - void AsyncCall(const TestShellDevToolsCallArgs& args); - - void all_messages_processed(); - - private: - void Call(const TestShellDevToolsCallArgs& args); - - base::WeakPtrFactory<TestShellDevToolsClient> weak_factory_; - TestShellDevToolsAgent* dev_tools_agent_; - WebKit::WebView* web_view_; - scoped_ptr<WebKit::WebDevToolsFrontend> web_tools_frontend_; - - DISALLOW_COPY_AND_ASSIGN(TestShellDevToolsClient); -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_DEVTOOLS_CLIENT_H_ diff --git a/webkit/tools/test_shell/test_shell_dummy.cc b/webkit/tools/test_shell/test_shell_dummy.cc new file mode 100644 index 0000000..e1a88a9 --- /dev/null +++ b/webkit/tools/test_shell/test_shell_dummy.cc @@ -0,0 +1,7 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TODO(darin): Delete this once the build masters stop referencing test_shell. +void Dummy() { +} diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc deleted file mode 100644 index b62ae17..0000000 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ /dev/null @@ -1,549 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_shell.h" - -#include <errno.h> -#include <fcntl.h> -#include <fontconfig/fontconfig.h> -#include <gtk/gtk.h> -#include <signal.h> -#include <unistd.h> - -#include "base/file_util.h" -#include "base/files/file_path.h" -#include "base/message_loop.h" -#include "base/path_service.h" -#include "base/string16.h" -#include "base/strings/string_piece.h" -#include "base/utf_string_conversions.h" -#include "grit/test_shell_resources.h" -#include "grit/webkit_resources.h" -#include "net/base/mime_util.h" -#include "net/base/net_util.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/base/gtk/gtk_compat.h" -#include "ui/base/layout.h" -#include "ui/base/resource/resource_bundle.h" -#include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/tools/test_shell/test_navigation_controller.h" -#include "webkit/tools/test_shell/test_shell_webkit_init.h" -#include "webkit/tools/test_shell/test_webview_delegate.h" - -using WebKit::WebPoint; -using WebKit::WebWidget; - -namespace { - -// Convert a base::FilePath into an FcChar* (used by fontconfig). -// The pointer only lives for the duration for the expression. -const FcChar8* FilePathAsFcChar(const base::FilePath& path) { - return reinterpret_cast<const FcChar8*>(path.value().c_str()); -} - -void TerminationSignalHandler(int signatl) { - TestShell::ShutdownTestShell(); - exit(0); -} - -// GTK callbacks ------------------------------------------------------ - -// Callback for when the main window is destroyed. -gboolean MainWindowDestroyed(GtkWindow* window, TestShell* shell) { - TestShell::RemoveWindowFromList(window); - - if (TestShell::windowList()->empty() || shell->is_modal()) { - base::MessageLoop::current()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); - } - - delete shell; - - return FALSE; // Don't stop this message. -} - -gboolean MainWindowLostFocus(GtkWidget* widget, GdkEventFocus* event, - TestShell* shell) { - shell->ClosePopup(); - return FALSE; -} - -// Callback for when you click the back button. -void BackButtonClicked(GtkButton* button, TestShell* shell) { - shell->GoBackOrForward(-1); -} - -// Callback for when you click the forward button. -void ForwardButtonClicked(GtkButton* button, TestShell* shell) { - shell->GoBackOrForward(1); -} - -// Callback for when you click the stop button. -void StopButtonClicked(GtkButton* button, TestShell* shell) { - shell->webView()->mainFrame()->stopLoading(); -} - -// Callback for when you click the reload button. -void ReloadButtonClicked(GtkButton* button, TestShell* shell) { - shell->Reload(); -} - -// Callback for when you press enter in the URL box. -void URLEntryActivate(GtkEntry* entry, TestShell* shell) { - const gchar* url = gtk_entry_get_text(entry); - shell->LoadURL(GURL(url)); -} - -// Callback for Debug > Dump body text... menu item. -gboolean DumpBodyTextActivated(GtkWidget* widget, TestShell* shell) { - shell->DumpDocumentText(); - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Dump render tree... menu item. -gboolean DumpRenderTreeActivated(GtkWidget* widget, TestShell* shell) { - shell->DumpRenderTree(); - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Show web inspector... menu item. -gboolean ShowWebInspectorActivated(GtkWidget* widget, TestShell* shell) { - shell->webView()->inspectElementAt(WebPoint()); - return FALSE; // Don't stop this message. -} - -// GTK utility functions ---------------------------------------------- - -GtkWidget* AddMenuEntry(GtkWidget* menu_widget, const char* text, - GCallback callback, TestShell* shell) { - GtkWidget* entry = gtk_menu_item_new_with_label(text); - g_signal_connect(entry, "activate", callback, shell); - gtk_menu_shell_append(GTK_MENU_SHELL(menu_widget), entry); - return entry; -} - -GtkWidget* CreateMenu(GtkWidget* menu_bar, const char* text) { - GtkWidget* menu_widget = gtk_menu_new(); - GtkWidget* menu_header = gtk_menu_item_new_with_label(text); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_header), menu_widget); - gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), menu_header); - return menu_widget; -} - -GtkWidget* CreateMenuBar(TestShell* shell) { - GtkWidget* menu_bar = gtk_menu_bar_new(); - GtkWidget* debug_menu = CreateMenu(menu_bar, "Debug"); - AddMenuEntry(debug_menu, "Dump body text...", - G_CALLBACK(DumpBodyTextActivated), shell); - AddMenuEntry(debug_menu, "Dump render tree...", - G_CALLBACK(DumpRenderTreeActivated), shell); - AddMenuEntry(debug_menu, "Show web inspector...", - G_CALLBACK(ShowWebInspectorActivated), shell); - return menu_bar; -} - -} // namespace - -// static -void TestShell::InitializeTestShell(bool layout_test_mode, - bool allow_external_pages) { - window_list_ = new WindowList; - layout_test_mode_ = layout_test_mode; - allow_external_pages_ = allow_external_pages; - - web_prefs_ = new WebPreferences; - - base::FilePath data_path; - PathService::Get(base::DIR_EXE, &data_path); - data_path = data_path.Append("test_shell.pak"); - ResourceBundle::InitSharedInstanceWithPakPath(data_path); - - base::FilePath resources_dir; - PathService::Get(base::DIR_SOURCE_ROOT, &resources_dir); - resources_dir = resources_dir.Append("webkit/tools/test_shell/resources"); - - ResetWebPreferences(); - - // We wish to make the layout tests reproducable with respect to fonts. Skia - // uses fontconfig to resolve font family names from WebKit into actual font - // files found on the current system. This means that fonts vary based on the - // system and also on the fontconfig configuration. - // - // To avoid this we initialise fontconfig here and install a configuration - // which only knows about a few, select, fonts. - - // We have fontconfig parse a config file from our resources file. This - // sets a number of aliases ("sans"->"Arial" etc), but doesn't include any - // font directories. - if (layout_test_mode) { - FcInit(); - - FcConfig* fontcfg = FcConfigCreate(); - base::FilePath fontconfig_path = resources_dir.Append("fonts.conf"); - if (!FcConfigParseAndLoad(fontcfg, FilePathAsFcChar(fontconfig_path), - true)) { - LOG(FATAL) << "Failed to parse fontconfig config file"; - } - - // This is the list of fonts that fontconfig will know about. It - // will try its best to match based only on the fonts here in. The - // paths are where these fonts are found on our Ubuntu boxes. - static const char *const fonts[] = { - "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf", - "/usr/share/fonts/truetype/kochi/kochi-mincho.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Georgia.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Georgia_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Georgia_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Georgia_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Impact.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Verdana.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf", - // The DejaVuSans font is used by the css2.1 tests. - "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf", - "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf", - "/usr/share/fonts/truetype/ttf-indic-fonts-core/MuktiNarrow.ttf", - }; - for (size_t i = 0; i < arraysize(fonts); ++i) { - if (access(fonts[i], R_OK)) { - LOG(FATAL) << "You are missing " << fonts[i] << ". " - << "Try installing msttcorefonts. Also see " - << "http://code.google.com/p/chromium/wiki/" - << "LinuxBuildInstructions"; - } - if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) fonts[i])) - LOG(FATAL) << "Failed to load font " << fonts[i]; - } - - // We special case these fonts because they're only needed in a - // few layout tests. - static const char* const optional_fonts[] = { - "/usr/share/fonts/truetype/ttf-lucida/LucidaSansRegular.ttf", - - // This font changed paths across Ubuntu releases. - "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf", - "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf", - }; - for (size_t i = 0; i < arraysize(optional_fonts); ++i) { - const char* font = optional_fonts[i]; - if (access(font, R_OK) < 0) { - LOG(WARNING) << "You are missing " << font << ". " - << "Without this, some layout tests will fail. " - << "See http://code.google.com/p/chromium/wiki/" - << "LinuxBuildInstructionsPrerequisites for more."; - } else { - if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) font)) - LOG(FATAL) << "Failed to load font " << font; - } - } - - // Also load the layout-test-specific "Ahem" font. - base::FilePath ahem_path = resources_dir.Append("AHEM____.TTF"); - if (!FcConfigAppFontAddFile(fontcfg, FilePathAsFcChar(ahem_path))) { - LOG(FATAL) << "Failed to load font " << ahem_path.value().c_str(); - } - - if (!FcConfigSetCurrent(fontcfg)) - LOG(FATAL) << "Failed to set the default font configuration"; - } - - // Install an signal handler so we clean up after ourselves. - signal(SIGINT, TerminationSignalHandler); - signal(SIGTERM, TerminationSignalHandler); -} - -void TestShell::PlatformShutdown() { - ResourceBundle::CleanupSharedInstance(); -} - -void TestShell::PlatformCleanUp() { - if (m_mainWnd) { - // Disconnect our MainWindowDestroyed handler so that we don't go through - // the shutdown process more than once. - g_signal_handlers_disconnect_by_func(m_mainWnd, - reinterpret_cast<gpointer>(MainWindowDestroyed), this); - gtk_widget_destroy(GTK_WIDGET(m_mainWnd)); - } -} - -void TestShell::EnableUIControl(UIControl control, bool is_enabled) { - // TODO(darin): Implement me. -} - -bool TestShell::Initialize(const GURL& starting_url) { - m_mainWnd = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); - gtk_window_set_title(m_mainWnd, "Test Shell"); - // Null out m_mainWnd when it is destroyed so we don't destroy it twice. - g_signal_connect(G_OBJECT(m_mainWnd), "destroy", - G_CALLBACK(gtk_widget_destroyed), &m_mainWnd); - g_signal_connect(G_OBJECT(m_mainWnd), "destroy", - G_CALLBACK(MainWindowDestroyed), this); - g_signal_connect(G_OBJECT(m_mainWnd), "focus-out-event", - G_CALLBACK(MainWindowLostFocus), this); - g_object_set_data(G_OBJECT(m_mainWnd), "test-shell", this); - - GtkWidget* vbox = gtk_vbox_new(FALSE, 0); - - GtkWidget* menu_bar = CreateMenuBar(this); - - gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 0); - - GtkWidget* toolbar = gtk_toolbar_new(); - // Turn off the labels on the toolbar buttons. - gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); - - GtkToolItem* back = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK); - g_signal_connect(back, "clicked", - G_CALLBACK(BackButtonClicked), this); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back, -1 /* append */); - - GtkToolItem* forward = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD); - g_signal_connect(forward, "clicked", - G_CALLBACK(ForwardButtonClicked), this); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), forward, -1 /* append */); - - GtkToolItem* reload = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH); - g_signal_connect(reload, "clicked", - G_CALLBACK(ReloadButtonClicked), this); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), reload, -1 /* append */); - - GtkToolItem* stop = gtk_tool_button_new_from_stock(GTK_STOCK_STOP); - g_signal_connect(stop, "clicked", - G_CALLBACK(StopButtonClicked), this); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), stop, -1 /* append */); - - m_editWnd = gtk_entry_new(); - g_signal_connect(G_OBJECT(m_editWnd), "activate", - G_CALLBACK(URLEntryActivate), this); - gtk_entry_set_text(GTK_ENTRY(m_editWnd), starting_url.spec().c_str()); - - GtkToolItem* tool_item = gtk_tool_item_new(); - gtk_container_add(GTK_CONTAINER(tool_item), m_editWnd); - gtk_tool_item_set_expand(tool_item, TRUE); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, -1 /* append */); - - gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); - m_webViewHost.reset( - WebViewHost::Create(vbox, delegate_.get(), 0, *TestShell::web_prefs_)); - - gtk_container_add(GTK_CONTAINER(m_mainWnd), vbox); - gtk_widget_show_all(GTK_WIDGET(m_mainWnd)); - - // LoadURL will do a resize, so make sure we don't call LoadURL - // until we've completed all of our GTK setup. - if (starting_url.is_valid()) - LoadURL(starting_url); - - if (IsSVGTestURL(starting_url)) - SizeToSVG(); - else - SizeToDefault(); - - return true; -} - -void TestShell::SizeTo(int width, int height) { - GtkWidget* widget = m_webViewHost->view_handle(); - - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - if (allocation.width == width && allocation.height == height) { - // Nothing to do. - return; - } - - gtk_widget_set_size_request(widget, width, height); - if (allocation.width > width || allocation.height > height) { - // We've been sized smaller. Shrink the window so it snaps back to the - // appropriate size. - gtk_window_resize(GTK_WINDOW(m_mainWnd), 1, 1); - } - - // We've been asked to size the content area to a particular size. - // GTK works asynchronously: you request a size and then it - // eventually becomes that size. But layout tests need to be sure - // the resize has gone into WebKit by the time SizeTo() returns. - // Force the webkit resize to happen now. - m_webViewHost->Resize(gfx::Size(width, height)); -} - -void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) { - GtkWidget* widget = GTK_WIDGET(host->view_handle()); - - if (enable) { - gtk_widget_grab_focus(widget); - } else if (gtk_widget_is_focus(widget)) { - GtkWidget *toplevel = gtk_widget_get_toplevel(widget); - if (gtk_widget_is_toplevel(toplevel)) - gtk_window_set_focus(GTK_WINDOW(toplevel), NULL); - } -} - -void TestShell::DestroyWindow(gfx::NativeWindow windowHandle) { - RemoveWindowFromList(windowHandle); - gtk_widget_destroy(GTK_WIDGET(windowHandle)); -} - -WebWidget* TestShell::CreatePopupWidget() { - GtkWidget* popupwindow = gtk_window_new(GTK_WINDOW_POPUP); - GtkWidget* vbox = gtk_vbox_new(FALSE, 0); - WebWidgetHost* host = WebWidgetHost::Create(vbox, popup_delegate_.get()); - gtk_container_add(GTK_CONTAINER(popupwindow), vbox); - m_popupHost = host; - - // Grab all input to the test shell and funnel it to the popup. - // The popup will detect if mouseclicks are outside its bounds and destroy - // itself if so. Clicks that are outside the test_shell window will destroy - // the popup by taking focus away from the main window. - gtk_grab_add(host->view_handle()); - - return host->webwidget(); -} - -void TestShell::ClosePopup() { - if (!m_popupHost) - return; - GtkWidget* drawing_area = m_popupHost->view_handle(); - // gtk_widget_destroy will recursively call ClosePopup, so to avoid GTK - // warnings set m_popupHost to null here before making the call. - m_popupHost = NULL; - GtkWidget* window = - gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); - gtk_widget_destroy(window); -} - -void TestShell::ResizeSubViews() { - // This function is used on Windows to re-layout the window on a resize. - // GTK manages layout for us so we do nothing. -} - -/* static */ void TestShell::DumpAllBackForwardLists(base::string16* result) { - result->clear(); - for (WindowList::iterator iter = TestShell::windowList()->begin(); - iter != TestShell::windowList()->end(); iter++) { - GtkWindow* window = *iter; - TestShell* shell = - static_cast<TestShell*>(g_object_get_data(G_OBJECT(window), - "test-shell")); - shell->DumpBackForwardList(result); - } -} - -void TestShell::LoadURLForFrame(const GURL& url, - const base::string16& frame_name) { - if (!url.is_valid()) - return; - - if (IsSVGTestURL(url)) { - SizeToSVG(); - } else { - // only resize back to the default when running tests - if (layout_test_mode()) - SizeToDefault(); - } - - navigation_controller_->LoadEntry( - new TestNavigationEntry(-1, url, frame_name)); -} - -bool TestShell::PromptForSaveFile(const wchar_t* prompt_title, - base::FilePath* result) { - GtkWidget* dialog; - dialog = gtk_file_chooser_dialog_new(WideToUTF8(prompt_title).c_str(), - GTK_WINDOW(m_mainWnd), - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); // Terminate (button, id) pairs. - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), - TRUE); - int dialog_result = gtk_dialog_run(GTK_DIALOG(dialog)); - if (dialog_result != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(dialog); - return false; - } - char* path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - gtk_widget_destroy(dialog); - *result = base::FilePath(path); - g_free(path); - return true; -} - -// static -std::string TestShell::RewriteLocalUrl(const std::string& url) { - // Convert file:///tmp/LayoutTests urls to the actual location on disk. - const char kPrefix[] = "file:///tmp/LayoutTests/"; - const int kPrefixLen = arraysize(kPrefix) - 1; - - std::string new_url(url); - if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { - base::FilePath replace_path; - PathService::Get(base::DIR_SOURCE_ROOT, &replace_path); - replace_path = replace_path.Append( - "third_party/WebKit/LayoutTests/"); - new_url = std::string("file://") + replace_path.value() + - url.substr(kPrefixLen); - } - - return new_url; -} - -// static -void TestShell::ShowStartupDebuggingDialog() { - GtkWidget* dialog = gtk_message_dialog_new( - NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "attach to me?"); - gtk_window_set_title(GTK_WINDOW(dialog), "test_shell"); - gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. - gtk_widget_destroy(dialog); -} - -// static -base::StringPiece TestShell::ResourceProvider(int key) { - return ResourceBundle::GetSharedInstance().GetRawDataResource(key); -} - -//----------------------------------------------------------------------------- - -base::string16 TestShellWebKitInit::GetLocalizedString(int message_id) { - return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); -} - -base::StringPiece TestShellWebKitInit::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { - switch (resource_id) { - case IDR_BROKENIMAGE: - resource_id = IDR_BROKENIMAGE_TESTSHELL; - break; - case IDR_TEXTAREA_RESIZER: - resource_id = IDR_TEXTAREA_RESIZER_TESTSHELL; - break; - } - // TODO(flackr): Pass scale_factor. - return TestShell::ResourceProvider(resource_id); -} diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm deleted file mode 100644 index 26ffce6..0000000 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ /dev/null @@ -1,592 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <ApplicationServices/ApplicationServices.h> -#import <Cocoa/Cocoa.h> -#import <objc/objc-runtime.h> -#include <sys/stat.h> - -#include "webkit/tools/test_shell/test_shell.h" - -#include "base/base_paths.h" -#include "base/basictypes.h" -#include "base/debug/debugger.h" -#include "base/file_util.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/mac/bundle_locations.h" -#include "base/mac/mac_util.h" -#include "base/mac/scoped_nsautorelease_pool.h" -#include "base/message_loop.h" -#include "base/path_service.h" -#include "base/string16.h" -#include "base/strings/string_piece.h" -#include "base/utf_string_conversions.h" -#include "grit/webkit_resources.h" -#include "net/base/mime_util.h" -#include "skia/ext/bitmap_platform_device.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/base/resource/data_pack.h" -#include "ui/gfx/size.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/tools/test_shell/mac/test_shell_webview.h" -#include "webkit/tools/test_shell/resource.h" -#include "webkit/tools/test_shell/simple_resource_loader_bridge.h" -#include "webkit/tools/test_shell/test_navigation_controller.h" -#include "webkit/tools/test_shell/test_shell_webkit_init.h" -#include "webkit/tools/test_shell/test_webview_delegate.h" - -#include "third_party/skia/include/core/SkBitmap.h" - -#import "mac/DumpRenderTreePasteboard.h" - -using WebKit::WebWidget; - -#define MAX_LOADSTRING 100 - -// Sizes for URL bar layout -#define BUTTON_HEIGHT 22 -#define BUTTON_WIDTH 72 -#define BUTTON_MARGIN 8 -#define URLBAR_HEIGHT 32 - -// Global Variables: - -// Content area size for newly created windows. -const int kTestWindowWidth = 800; -const int kTestWindowHeight = 600; - -// The W3C SVG layout tests use a different size than the other layout tests -const int kSVGTestWindowWidth = 480; -const int kSVGTestWindowHeight = 360; - -// Hide the window offscreen when in layout test mode. Mac OS X limits -// window positions to +/- 16000. -const int kTestWindowXLocation = -14000; -const int kTestWindowYLocation = -14000; - -// Data pack resource. This is a pointer to the mmapped resources file. -static ui::DataPack* g_resource_data_pack = NULL; - -// Define static member variables -base::LazyInstance <std::map<gfx::NativeWindow, TestShell *> > - TestShell::window_map_ = LAZY_INSTANCE_INITIALIZER; - -// Helper method for getting the path to the test shell resources directory. -base::FilePath GetResourcesFilePath() { - base::FilePath path; - // We need to know if we're bundled or not to know which path to use. - if (base::mac::AmIBundled()) { - PathService::Get(base::DIR_EXE, &path); - path = path.Append(base::FilePath::kParentDirectory); - return path.AppendASCII("Resources"); - } else { - PathService::Get(base::DIR_SOURCE_ROOT, &path); - path = path.AppendASCII("webkit"); - path = path.AppendASCII("tools"); - path = path.AppendASCII("test_shell"); - return path.AppendASCII("resources"); - } -} - -// Receives notification that the window is closing so that it can start the -// tear-down process. Is responsible for deleting itself when done. -@interface WindowDelegate : NSObject<NSWindowDelegate> { - @private - TestShellWebView* m_webView; -} -- (id)initWithWebView:(TestShellWebView*)view; -@end - -@implementation WindowDelegate - -- (id)initWithWebView:(TestShellWebView*)view { - if ((self = [super init])) { - m_webView = view; - } - return self; -} - -- (void)windowDidBecomeKey:(NSNotification*)notification { - [m_webView setIsActive:YES]; -} - -- (void)windowDidResignKey:(NSNotification*)notification { - [m_webView setIsActive:NO]; -} - -// Called when the window is about to close. Perform the self-destruction -// sequence by getting rid of the shell and removing it and the window from -// the various global lists. Instead of doing it here, however, we fire off -// a delayed call to |-cleanup:| to allow everything to get off the stack -// before we go deleting objects. By returning YES, we allow the window to be -// removed from the screen. -- (BOOL)windowShouldClose:(id)window { - m_webView = nil; - - // Try to make the window go away, but it may not when running layout - // tests due to the quirkyness of autorelease pools and having no main loop. - [window autorelease]; - - // clean ourselves up and do the work after clearing the stack of anything - // that might have the shell on it. - [self performSelectorOnMainThread:@selector(cleanup:) - withObject:window - waitUntilDone:NO]; - - return YES; -} - -// does the work of removing the window from our various bookkeeping lists -// and gets rid of the shell. -- (void)cleanup:(id)window { - TestShell::RemoveWindowFromList(window); - TestShell::DestroyAssociatedShell(window); - - [self release]; -} - -@end - -// Mac-specific stuff to do when the dtor is called. Nothing to do in our -// case. -void TestShell::PlatformCleanUp() { -} - -void TestShell::EnableUIControl(UIControl control, bool is_enabled) { - // TODO(darin): Implement me. -} - -// static -void TestShell::DestroyAssociatedShell(gfx::NativeWindow handle) { - WindowMap::iterator it = window_map_.Get().find(handle); - if (it != window_map_.Get().end()) { - // Break the view's association with its shell before deleting the shell. - TestShellWebView* web_view = - static_cast<TestShellWebView*>(it->second->m_webViewHost->view_handle()); - if ([web_view isKindOfClass:[TestShellWebView class]]) { - [web_view setShell:NULL]; - } - - delete it->second; - window_map_.Get().erase(it); - } else { - LOG(ERROR) << "Failed to find shell for window during destroy"; - } -} - -// static -void TestShell::PlatformShutdown() { - // for each window in the window list, release it and destroy its shell - for (WindowList::iterator it = TestShell::windowList()->begin(); - it != TestShell::windowList()->end(); - ++it) { - DestroyAssociatedShell(*it); - [*it release]; - } - // assert if we have anything left over, that would be bad. - DCHECK(window_map_.Get().empty()); - - // Dump the pasteboards we built up. - [DumpRenderTreePasteboard releaseLocalPasteboards]; -} - -// static -void TestShell::InitializeTestShell(bool layout_test_mode, - bool allow_external_pages) { - // This should move to a per-process platform-specific initialization function - // when one exists. - - window_list_ = new WindowList; - layout_test_mode_ = layout_test_mode; - allow_external_pages_ = allow_external_pages; - - web_prefs_ = new WebPreferences; - - // mmap the data pack which holds strings used by WebCore. This is only - // a fatal error if we're bundled, which means we might be running layout - // tests. This is a harmless failure for test_shell_tests. - g_resource_data_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); - NSString *resource_path = - [base::mac::FrameworkBundle() pathForResource:@"test_shell" - ofType:@"pak"]; - base::FilePath resources_pak_path([resource_path fileSystemRepresentation]); - if (!g_resource_data_pack->LoadFromPath(resources_pak_path)) { - LOG(FATAL) << "failed to load test_shell.pak"; - } - - ResetWebPreferences(); - - // Load the Ahem font, which is used by layout tests. - NSString* ahem_path = [[base::mac::FrameworkBundle() resourcePath] - stringByAppendingPathComponent:@"AHEM____.TTF"]; - NSURL* ahem_path_url = [NSURL fileURLWithPath:ahem_path]; - CFErrorRef error; - if (!CTFontManagerRegisterFontsForURL((CFURLRef)ahem_path_url, - kCTFontManagerScopeProcess, &error)) { - DLOG(FATAL) << "CTFontManagerRegisterFontsForURL " - << [ahem_path fileSystemRepresentation] - << [[(NSError*)error description] UTF8String]; - } - - // Add <app bundle's parent dir>/plugins to the plugin path so we can load - // test plugins. - base::FilePath plugins_dir; - PathService::Get(base::DIR_EXE, &plugins_dir); - if (base::mac::AmIBundled()) { - plugins_dir = plugins_dir.AppendASCII("../../../plugins"); - } else { - plugins_dir = plugins_dir.AppendASCII("plugins"); - } - webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(plugins_dir); -} - -NSButton* MakeTestButton(NSRect* rect, NSString* title, NSView* parent) { - NSButton* button = [[[NSButton alloc] initWithFrame:*rect] autorelease]; - [button setTitle:title]; - [button setBezelStyle:NSSmallSquareBezelStyle]; - [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; - [parent addSubview:button]; - rect->origin.x += BUTTON_WIDTH; - return button; -} - -bool TestShell::Initialize(const GURL& starting_url) { - // Perform application initialization: - // send message to app controller? need to work this out - - // TODO(awalker): this is a straight recreation of windows test_shell.cc's - // window creation code--we should really pull this from the nib and grab - // references to the already-created subviews that way. - NSRect screen_rect = [[NSScreen mainScreen] visibleFrame]; - NSRect window_rect = { {0, screen_rect.size.height - kTestWindowHeight}, - {kTestWindowWidth, kTestWindowHeight} }; - m_mainWnd = [[NSWindow alloc] - initWithContentRect:window_rect - styleMask:(NSTitledWindowMask | - NSClosableWindowMask | - NSMiniaturizableWindowMask | - NSResizableWindowMask ) - backing:NSBackingStoreBuffered - defer:NO]; - [m_mainWnd setTitle:@"TestShell"]; - - // Add to our map - window_map_.Get()[m_mainWnd] = this; - - // Rely on the window delegate to clean us up rather than immediately - // releasing when the window gets closed. We use the delegate to do - // everything from the autorelease pool so the shell isn't on the stack - // during cleanup (ie, a window close from javascript). - [m_mainWnd setReleasedWhenClosed:NO]; - - // Create a webview. Note that |web_view| takes ownership of this shell so we - // will get cleaned up when it gets destroyed. - m_webViewHost.reset( - WebViewHost::Create([m_mainWnd contentView], - delegate_.get(), - 0, - *TestShell::web_prefs_)); - delegate_->RegisterDragDrop(); - TestShellWebView* web_view = - static_cast<TestShellWebView*>(m_webViewHost->view_handle()); - [web_view setShell:this]; - - // Create a window delegate to watch for when it's asked to go away. It will - // clean itself up so we don't need to hold a reference. - [m_mainWnd setDelegate:[[WindowDelegate alloc] initWithWebView:web_view]]; - - // create buttons - NSRect button_rect = [[m_mainWnd contentView] bounds]; - button_rect.origin.y = window_rect.size.height - URLBAR_HEIGHT + - (URLBAR_HEIGHT - BUTTON_HEIGHT) / 2; - button_rect.size.height = BUTTON_HEIGHT; - button_rect.origin.x += BUTTON_MARGIN; - button_rect.size.width = BUTTON_WIDTH; - - NSView* content = [m_mainWnd contentView]; - - NSButton* button = MakeTestButton(&button_rect, @"Back", content); - [button setTarget:web_view]; - [button setAction:@selector(goBack:)]; - - button = MakeTestButton(&button_rect, @"Forward", content); - [button setTarget:web_view]; - [button setAction:@selector(goForward:)]; - - // reload button - button = MakeTestButton(&button_rect, @"Reload", content); - [button setTarget:web_view]; - [button setAction:@selector(reload:)]; - - // stop button - button = MakeTestButton(&button_rect, @"Stop", content); - [button setTarget:web_view]; - [button setAction:@selector(stopLoading:)]; - - // text field for URL - button_rect.origin.x += BUTTON_MARGIN; - button_rect.size.width = [[m_mainWnd contentView] bounds].size.width - - button_rect.origin.x - BUTTON_MARGIN; - m_editWnd = [[NSTextField alloc] initWithFrame:button_rect]; - [[m_mainWnd contentView] addSubview:m_editWnd]; - [m_editWnd setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; - [m_editWnd setTarget:web_view]; - [m_editWnd setAction:@selector(takeURLStringValueFrom:)]; - [[m_editWnd cell] setWraps:NO]; - [[m_editWnd cell] setScrollable:YES]; - - // show the window - [m_mainWnd makeKeyAndOrderFront: nil]; - - // Load our initial content. - if (starting_url.is_valid()) - LoadURL(starting_url); - - if (IsSVGTestURL(starting_url)) { - SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); - } else { - SizeToDefault(); - } - - return true; -} - -void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) { - if (enable) { - [[host->view_handle() window] makeKeyAndOrderFront:nil]; - } else { - // There is no way to resign key window status in Cocoa. Fake it by - // ordering the window out (transferring key status to another window) and - // then ordering the window back in, but without making it key. - [[host->view_handle() window] orderOut:nil]; - [[host->view_handle() window] orderFront:nil]; - } -} - -// static -void TestShell::DestroyWindow(gfx::NativeWindow windowHandle) { - // This code is like -cleanup: on our window delegate. This call needs to be - // able to force down a window for tests, so it closes down the window making - // sure it cleans up the window delegate and the test shells list of windows - // and map of windows to shells. - - TestShell::RemoveWindowFromList(windowHandle); - TestShell::DestroyAssociatedShell(windowHandle); - - id windowDelegate = [windowHandle delegate]; - DCHECK(windowDelegate); - [windowHandle setDelegate:nil]; - [windowDelegate release]; - - [windowHandle close]; - [windowHandle autorelease]; -} - -WebWidget* TestShell::CreatePopupWidget() { - DCHECK(!m_popupHost); - m_popupHost = WebWidgetHost::Create(webViewWnd(), popup_delegate_.get()); - - return m_popupHost->webwidget(); -} - -void TestShell::ClosePopup() { - // PostMessage(popupWnd(), WM_CLOSE, 0, 0); - m_popupHost = NULL; -} - -void TestShell::SizeTo(int width, int height) { - // WebViewHost::Create() sets the HTML content rect to start 32 pixels below - // the top of the window to account for the "toolbar". We need to match that - // here otherwise the HTML content area will be too short. - NSRect r = [m_mainWnd contentRectForFrameRect:[m_mainWnd frame]]; - r.size.width = width; - r.size.height = height + URLBAR_HEIGHT; - [m_mainWnd setFrame:[m_mainWnd frameRectForContentRect:r] display:YES]; -} - -void TestShell::ResizeSubViews() { - // handled by Cocoa for us -} - -/* static */ void TestShell::DumpAllBackForwardLists(base::string16* result) { - result->clear(); - for (WindowList::iterator iter = TestShell::windowList()->begin(); - iter != TestShell::windowList()->end(); iter++) { - NSWindow* window = *iter; - WindowMap::iterator it = window_map_.Get().find(window); - if (it != window_map_.Get().end()) - it->second->DumpBackForwardList(result); - else - LOG(ERROR) << "Failed to find shell for window during dump"; - } -} - -void TestShell::LoadURLForFrame(const GURL& url, - const base::string16& frame_name) { - if (!url.is_valid()) - return; - - if (IsSVGTestURL(url)) { - SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); - } else { - // only resize back to the default when running tests - if (layout_test_mode()) - SizeToDefault(); - } - - navigation_controller_->LoadEntry( - new TestNavigationEntry(-1, url, frame_name)); -} - -bool TestShell::PromptForSaveFile(const wchar_t* prompt_title, - base::FilePath* result) -{ - NSSavePanel* save_panel = [NSSavePanel savePanel]; - - /* set up new attributes */ - [save_panel setAllowedFileTypes:@[@"txt"]]; - [save_panel setMessage: - [NSString stringWithUTF8String:WideToUTF8(prompt_title).c_str()]]; - - /* display the NSSavePanel */ - [save_panel setDirectoryURL:[NSURL fileURLWithPath:NSHomeDirectory()]]; - [save_panel setNameFieldStringValue:@""]; - if ([save_panel runModal] == NSFileHandlingPanelOKButton) { - *result = base::FilePath([[[save_panel URL] path] fileSystemRepresentation]); - return true; - } - return false; -} - -// static -std::string TestShell::RewriteLocalUrl(const std::string& url) { - // Convert file:///tmp/LayoutTests urls to the actual location on disk. - const char kPrefix[] = "file:///tmp/LayoutTests/"; - const int kPrefixLen = arraysize(kPrefix) - 1; - - std::string new_url(url); - if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { - base::FilePath replace_path; - PathService::Get(base::DIR_SOURCE_ROOT, &replace_path); - replace_path = replace_path.Append( - "third_party/WebKit/LayoutTests/"); - new_url = std::string("file://") + replace_path.value() + - url.substr(kPrefixLen); - } - - return new_url; -} - -// static -void TestShell::ShowStartupDebuggingDialog() { - NSAlert* alert = [[[NSAlert alloc] init] autorelease]; - alert.messageText = @"Attach to me?"; - alert.informativeText = @"This would probably be a good time to attach your " - "debugger."; - [alert addButtonWithTitle:@"OK"]; - - [alert runModal]; -} - -base::StringPiece TestShell::ResourceProvider(int key) { - base::StringPiece res; - g_resource_data_pack->GetStringPiece(key, &res); - return res; -} - -//----------------------------------------------------------------------------- - -base::string16 TestShellWebKitInit::GetLocalizedString(int message_id) { - base::StringPiece res; - if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { - LOG(FATAL) << "failed to load webkit string with id " << message_id; - } - - // Data packs hold strings as either UTF8 or UTF16. - base::string16 msg; - switch (g_resource_data_pack->GetTextEncodingType()) { - case ui::DataPack::UTF8: - msg = UTF8ToUTF16(res); - break; - case ui::DataPack::UTF16: - msg = base::string16(reinterpret_cast<const char16*>(res.data()), - res.length() / 2); - break; - case ui::DataPack::BINARY: - NOTREACHED(); - break; - } - - return msg; -} - -base::StringPiece TestShellWebKitInit::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { - switch (resource_id) { - case IDR_BROKENIMAGE: { - // Use webkit's broken image icon (16x16) - static std::string broken_image_data; - if (broken_image_data.empty()) { - base::FilePath path = GetResourcesFilePath(); - // In order to match WebKit's colors for the missing image, we have to - // use a PNG. The GIF doesn't have the color range needed to correctly - // match the TIFF they use in Safari. - path = path.AppendASCII("missingImage.png"); - bool success = file_util::ReadFileToString(path, &broken_image_data); - if (!success) { - LOG(FATAL) << "Failed reading: " << path.value(); - } - } - return broken_image_data; - } - case IDR_TEXTAREA_RESIZER: { - // Use webkit's text area resizer image. - static std::string resize_corner_data; - if (resize_corner_data.empty()) { - base::FilePath path = GetResourcesFilePath(); - path = path.AppendASCII("textAreaResizeCorner.png"); - bool success = file_util::ReadFileToString(path, &resize_corner_data); - if (!success) { - LOG(FATAL) << "Failed reading: " << path.value(); - } - } - return resize_corner_data; - } - - case IDR_SEARCH_CANCEL: - case IDR_SEARCH_CANCEL_PRESSED: - case IDR_SEARCH_MAGNIFIER: - case IDR_SEARCH_MAGNIFIER_RESULTS: - case IDR_INPUT_SPEECH: - case IDR_INPUT_SPEECH_RECORDING: - case IDR_INPUT_SPEECH_WAITING: - // TODO(flackr): Pass scale_factor to ResourceProvider. - return TestShell::ResourceProvider(resource_id); - - default: - break; - } - - return base::StringPiece(); -} - -namespace webkit_glue { - -bool DownloadUrl(const std::string& url, NSWindow* caller_window) { - return false; -} - -void DidLoadPlugin(const std::string& filename) { -} - -void DidUnloadPlugin(const std::string& filename) { -} - -} // namespace webkit_glue diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc deleted file mode 100644 index 7f53d48..0000000 --- a/webkit/tools/test_shell/test_shell_main.cc +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/at_exit.h" -#include "base/basictypes.h" -#include "base/command_line.h" -#include "base/debug/stack_trace.h" -#include "base/debug/trace_event.h" -#include "base/environment.h" -#include "base/event_recorder.h" -#include "base/file_util.h" -#include "base/files/file_path.h" -#include "base/i18n/icu_util.h" -#include "base/message_loop.h" -#include "base/metrics/stats_table.h" -#include "base/path_service.h" -#include "base/process_util.h" -#include "base/rand_util.h" -#include "base/strings/string_number_conversions.h" -#include "base/sys_info.h" -#include "base/utf_string_conversions.h" -#include "net/base/net_module.h" -#include "net/base/net_util.h" -#include "net/cookies/cookie_monster.h" -#include "net/http/http_cache.h" -#include "net/http/http_util.h" -#include "net/test/spawned_test_server/spawned_test_server.h" -#include "net/url_request/url_request_context.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h" -#include "ui/base/window_open_disposition.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_switches.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/tools/test_shell/simple_resource_loader_bridge.h" -#include "webkit/tools/test_shell/test_shell.h" -#include "webkit/tools/test_shell/test_shell_platform_delegate.h" -#include "webkit/tools/test_shell/test_shell_request_context.h" -#include "webkit/tools/test_shell/test_shell_switches.h" -#include "webkit/tools/test_shell/test_shell_webkit_init.h" - -#if defined(OS_WIN) -#pragma warning(disable: 4996) -#endif - -static const size_t kPathBufSize = 2048; - -using WebKit::WebScriptController; - -namespace { - -// StatsTable initialization parameters. -const char* const kStatsFilePrefix = "testshell_"; -int kStatsFileThreads = 20; -int kStatsFileCounters = 200; - -void RemoveSharedMemoryFile(std::string& filename) { - // Stats uses SharedMemory under the hood. On posix, this results in a file - // on disk. -#if defined(OS_POSIX) - base::SharedMemory memory; - memory.Delete(filename); -#endif -} - -} // namespace - -int main(int argc, char* argv[]) { - base::debug::EnableInProcessStackDumping(); - base::EnableTerminationOnHeapCorruption(); - - // Some tests may use base::Singleton<>, thus we need to instanciate - // the AtExitManager or else we will leak objects. - base::AtExitManager at_exit_manager; - - TestShellPlatformDelegate::PreflightArgs(&argc, &argv); - CommandLine::Init(argc, argv); - const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); - - TestShellPlatformDelegate platform(parsed_command_line); - - if (parsed_command_line.HasSwitch(test_shell::kStartupDialog)) - TestShell::ShowStartupDebuggingDialog(); - - if (parsed_command_line.HasSwitch(test_shell::kCheckLayoutTestSystemDeps)) { - exit(platform.CheckLayoutTestSystemDependencies() ? 0 : 1); - } - - // Allocate a message loop for this thread. Although it is not used - // directly, its constructor sets up some necessary state. - base::MessageLoopForUI main_message_loop; - - scoped_ptr<base::Environment> env(base::Environment::Create()); - bool suppress_error_dialogs = ( - env->HasVar("CHROME_HEADLESS") || - parsed_command_line.HasSwitch(test_shell::kNoErrorDialogs)); - bool ux_theme = parsed_command_line.HasSwitch(test_shell::kUxTheme); -#if defined(OS_MACOSX) - // The "classic theme" flag is meaningless on OS X. But there is a bunch - // of code that sets up the environment for running pixel tests that only - // runs if it's set to true. - bool classic_theme = true; -#else - bool classic_theme = - parsed_command_line.HasSwitch(test_shell::kClassicTheme); -#endif // !OS_MACOSX -#if defined(OS_WIN) - bool generic_theme = parsed_command_line.HasSwitch(test_shell::kGenericTheme); -#else - // Stop compiler warnings about unused variables. - static_cast<void>(ux_theme); -#endif - - bool enable_gp_fault_error_box = false; - enable_gp_fault_error_box = - parsed_command_line.HasSwitch(test_shell::kGPFaultErrorBox); - - bool allow_external_pages = - parsed_command_line.HasSwitch(test_shell::kAllowExternalPages); - - if (parsed_command_line.HasSwitch(test_shell::kEnableAccel2DCanvas)) - TestShell::SetAccelerated2dCanvasEnabled(true); - if (parsed_command_line.HasSwitch(test_shell::kEnableAccelCompositing)) - TestShell::SetAcceleratedCompositingEnabled(true); - - bool layout_test_mode = false; - TestShell::InitLogging(suppress_error_dialogs, - layout_test_mode, - enable_gp_fault_error_box); - - // Initialize WebKit for this scope. - TestShellWebKitInit test_shell_webkit_init(layout_test_mode); - - // Suppress abort message in v8 library in debugging mode (but not - // actually under a debugger). V8 calls abort() when it hits - // assertion errors. - if (suppress_error_dialogs) { - platform.SuppressErrorReporting(); - } - - net::HttpCache::Mode cache_mode = net::HttpCache::NORMAL; - - if (parsed_command_line.HasSwitch(test_shell::kEnableFileCookies)) - net::CookieMonster::EnableFileScheme(); - - base::FilePath cache_path = - parsed_command_line.GetSwitchValuePath(test_shell::kCacheDir); - if (cache_path.empty()) { - PathService::Get(base::DIR_EXE, &cache_path); - cache_path = cache_path.AppendASCII("cache"); - } - - // Initializing with a default context, which means no on-disk cookie DB, - // and no support for directory listings. - SimpleResourceLoaderBridge::Init(cache_path, cache_mode, layout_test_mode); - - // Load ICU data tables - icu_util::Initialize(); - - // Config the modules that need access to a limited set of resources. - net::NetModule::SetResourceProvider(TestShell::ResourceProvider); - - platform.InitializeGUI(); - - TestShell::InitializeTestShell(layout_test_mode, allow_external_pages); - - if (parsed_command_line.HasSwitch(test_shell::kAllowScriptsToCloseWindows)) - TestShell::SetAllowScriptsToCloseWindows(); - - if (parsed_command_line.HasSwitch(test_shell::kEnableSmoothScrolling)) - TestShell::GetWebPreferences()->enable_scroll_animator = true; - - // Disable user themes for layout tests so pixel tests are consistent. -#if defined(OS_WIN) - TestShellWebTheme::Engine engine; -#endif - if (classic_theme) - platform.SelectUnifiedTheme(); -#if defined(OS_WIN) - if (generic_theme) - test_shell_webkit_init.SetThemeEngine(&engine); -#endif - - // Unless specifically requested otherwise, default to OSMesa for GL. - if (!parsed_command_line.HasSwitch(switches::kUseGL)) - gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); - - // Treat the first argument as the initial URL to open. - GURL starting_url; - - base::FilePath path; - PathService::Get(base::DIR_SOURCE_ROOT, &path); - path = path.AppendASCII("webkit").AppendASCII("data") - .AppendASCII("test_shell").AppendASCII("index.html"); - starting_url = net::FilePathToFileURL(path); - - const CommandLine::StringVector& args = parsed_command_line.GetArgs(); - if (!args.empty()) { - GURL url(args[0]); - if (url.is_valid()) { - starting_url = url; - } else { - // Treat as a relative file path. - base::FilePath path = base::MakeAbsoluteFilePath(base::FilePath(args[0])); - starting_url = net::FilePathToFileURL(path); - } - } - - // Get the JavaScript flags. The test runner might send a quoted string which - // needs to be unquoted before further processing. - std::string js_flags = - parsed_command_line.GetSwitchValueASCII(test_shell::kJavaScriptFlags); - js_flags = net::HttpUtil::Unquote(js_flags); - // Split the JavaScript flags into a list. - std::vector<std::string> js_flags_list; - size_t start = 0; - while (true) { - size_t comma_pos = js_flags.find_first_of(',', start); - std::string flags; - if (comma_pos == std::string::npos) { - flags = js_flags.substr(start, js_flags.length() - start); - } else { - flags = js_flags.substr(start, comma_pos - start); - start = comma_pos + 1; - } - js_flags_list.push_back(flags); - if (comma_pos == std::string::npos) - break; - } - TestShell::SetJavaScriptFlags(js_flags_list); - - // Test shell always exposes the GC. - webkit_glue::SetJavaScriptFlags("--expose-gc"); - - // Load and initialize the stats table. Attempt to construct a somewhat - // unique name to isolate separate instances from each other. - - // truncate the random # to 32 bits for the benefit of Mac OS X, to - // avoid tripping over its maximum shared memory segment name length - std::string stats_filename = kStatsFilePrefix + - base::Uint64ToString(base::RandUint64() & 0xFFFFFFFFL); - RemoveSharedMemoryFile(stats_filename); - base::StatsTable *table = new base::StatsTable(stats_filename, - kStatsFileThreads, - kStatsFileCounters); - base::StatsTable::set_current(table); - - TestShell* shell; - if (TestShell::CreateNewWindow(starting_url, &shell)) { - shell->Show(WebKit::WebNavigationPolicyNewWindow); - - if (parsed_command_line.HasSwitch(test_shell::kDumpStatsTable)) - shell->DumpStatsTableOnExit(); - - webkit_glue::SetJavaScriptFlags(TestShell::GetJSFlagsForLoad(0)); - base::MessageLoop::current()->Run(); - } - - TestShell::ShutdownTestShell(); - TestShell::CleanupLogging(); - - // Tear down shared StatsTable; prevents unit_tests from leaking it. - base::StatsTable::set_current(NULL); - delete table; - RemoveSharedMemoryFile(stats_filename); - - return 0; -} diff --git a/webkit/tools/test_shell/test_shell_platform_delegate.h b/webkit/tools/test_shell/test_shell_platform_delegate.h deleted file mode 100644 index e2d419a..0000000 --- a/webkit/tools/test_shell/test_shell_platform_delegate.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// TestShellPlatformDelegate isolates a variety of platform-specific -// functions so that code can invoke them by purpose without resorting to -// ifdefs or runtime platform checks. Each platform should define an -// implementation of this class. In many cases, implementation of methods -// in this class will be stubs on platforms where those functions are -// unnecessary. - -class TestShellPlatformDelegate { - public: - // The TestShellPlatformDelegate object is scoped to main(), and so - // its constructor is a good place to put per-application initialization - // (as opposed to per-test code, which should go into the TestShell class). - TestShellPlatformDelegate(const CommandLine& command_line); - ~TestShellPlatformDelegate(); - - // CheckLayoutTestSystemDependencies: check for any system dependencies that - // can't be easily overridden from within an application (for example, UI or - // display settings). Returns false if any dependencies are not met. - bool CheckLayoutTestSystemDependencies(); - - // PreflightArgs: give the platform first crack at the arguments to main() - // before we parse the command line. For example, some UI toolkits have - // runtime flags that they can pre-filter. - static void PreflightArgs(int* argc, char*** argv); - - // SuppressErrorReporting: if possible, turn off platform error reporting - // dialogs, crash dumps, etc. - void SuppressErrorReporting(); - - // InitializeGUI: do any special initialization that the UI needs before - // we start the main message loop - void InitializeGUI(); - - // SelectUnifiedTheme: override user preferences so that the UI theme matches - // what's in the baseline files. Whenever possible, override user settings - // here rather than testing them in CheckLayoutTestSystemDependencies. - void SelectUnifiedTheme(); - - // AboutToExit: give the platform delegate a last chance to restore platform - // settings. Normally called by the destructor, but also called before - // abort() (example: test timeouts). - void AboutToExit(); - - // SetWindowPositionForRecording: if the platform's implementation of - // EventRecorder requires the window to be in a particular absolute position, - // make it so. This is called by TestShell after it creates the window. - void SetWindowPositionForRecording(TestShell *shell); - private: - const CommandLine& command_line_; -}; diff --git a/webkit/tools/test_shell/test_shell_platform_delegate_gtk.cc b/webkit/tools/test_shell/test_shell_platform_delegate_gtk.cc deleted file mode 100644 index 4947b01..0000000 --- a/webkit/tools/test_shell/test_shell_platform_delegate_gtk.cc +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <stdlib.h> // required by _set_abort_behavior -#include <gtk/gtk.h> - -#include "base/command_line.h" -#include "webkit/tools/test_shell/test_shell.h" -#include "webkit/tools/test_shell/test_shell_platform_delegate.h" - -// Hooks Gtk's logs so that we can ignore harmless warnings. -static void GtkLogHandler(const gchar* log_domain, - GLogLevelFlags log_level, - const gchar* message, - gpointer userdata) { - if (strstr(message, "Loading IM context type") || - strstr(message, "wrong ELF class: ELFCLASS64")) { - // GTK outputs some warnings when it attempts to load 64bit shared - // objects from 32bit binaries. Suppress them as they are not - // actual errors. The warning messages are like - // - // (test_shell:2476): Gtk-WARNING **: - // /usr/lib/gtk-2.0/2.10.0/immodules/im-uim.so: wrong ELF class: ELFCLASS64 - // - // (test_shell:2476): Gtk-WARNING **: Loading IM context type 'uim' failed - // - // Related bug: http://crbug.com/9643 - } else { - g_log_default_handler(log_domain, log_level, message, userdata); - } -} - -static void SetUpGtkLogHandler() { - g_log_set_handler("Gtk", G_LOG_LEVEL_WARNING, GtkLogHandler, NULL); -} - -void TestShellPlatformDelegate::PreflightArgs(int *argc, char ***argv) { - gtk_init(argc, argv); - SetUpGtkLogHandler(); -} - -void TestShellPlatformDelegate::SelectUnifiedTheme() { - // Stop custom gtkrc files from messing with the theme. - gchar* default_gtkrc_files[] = { NULL }; - gtk_rc_set_default_files(default_gtkrc_files); - gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE); - - // Pick a theme that uses Cairo for drawing, since we: - // 1) currently don't support GTK themes that use the GDK drawing APIs, and - // 2) need to use a unified theme for layout tests anyway. - g_object_set(gtk_settings_get_default(), - "gtk-theme-name", "Mist", - NULL); -} - -TestShellPlatformDelegate::TestShellPlatformDelegate( - const CommandLine& command_line) - : command_line_(command_line) { -} - -bool TestShellPlatformDelegate::CheckLayoutTestSystemDependencies() { - return true; -} - -void TestShellPlatformDelegate::SuppressErrorReporting() { -} - -void TestShellPlatformDelegate::InitializeGUI() { -} - -void TestShellPlatformDelegate::SetWindowPositionForRecording(TestShell *) { -} - -TestShellPlatformDelegate::~TestShellPlatformDelegate() { -} diff --git a/webkit/tools/test_shell/test_shell_platform_delegate_mac.mm b/webkit/tools/test_shell/test_shell_platform_delegate_mac.mm deleted file mode 100644 index dc1b221..0000000 --- a/webkit/tools/test_shell/test_shell_platform_delegate_mac.mm +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "build/build_config.h" - -#include <Carbon/Carbon.h> -// #include <ApplicationServices/ApplicationServices.h> -#import <Cocoa/Cocoa.h> -#import <objc/objc-runtime.h> -#include <mach/task.h> - -#include "base/command_line.h" -#include "base/logging.h" -#include "base/message_pump_mac.h" -#import "base/test/mock_chrome_application_mac.h" -#include "webkit/tools/test_shell/test_shell.h" -#include "webkit/tools/test_shell/test_shell_platform_delegate.h" -#include "webkit/tools/test_shell/test_shell_switches.h" - -static NSAutoreleasePool *gTestShellAutoreleasePool = nil; - -static void SetDefaultsToLayoutTestValues(void) { - // So we can match the WebKit layout tests, we want to force a bunch of - // preferences that control appearance to match. - // (We want to do this as early as possible in application startup so - // the settings are in before any higher layers could cache values.) - - // This is inspired by resetDefaultsToConsistentValues() in - // WebKit/Tools/DumpRenderTree/mac/DumpRenderTree.mm . - - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - const NSInteger kMinFontSizeCGSmoothes = 4; - const NSInteger kNoFontSmoothing = 0; - const NSInteger kBlueTintedAppearance = 1; - [defaults setInteger:kMinFontSizeCGSmoothes - forKey:@"AppleAntiAliasingThreshold"]; - [defaults setInteger:kNoFontSmoothing - forKey:@"AppleFontSmoothing"]; - [defaults setInteger:kBlueTintedAppearance - forKey:@"AppleAquaColorVariant"]; - [defaults setObject:@"0.709800 0.835300 1.000000" - forKey:@"AppleHighlightColor"]; - [defaults setObject:@"0.500000 0.500000 0.500000" - forKey:@"AppleOtherHighlightColor"]; - [defaults setObject:[NSArray arrayWithObject:@"en"] - forKey:@"AppleLanguages"]; - - // AppKit pulls scrollbar style from NSUserDefaults. HIToolbox uses - // CFPreferences, but AnyApplication, so we set it, force it to load, and - // then reset the pref to what it was (HIToolbox will cache what it loaded). - [defaults setObject:@"DoubleMax" forKey:@"AppleScrollBarVariant"]; - CFTypeRef initialValue = - CFPreferencesCopyValue(CFSTR("AppleScrollBarVariant"), - kCFPreferencesAnyApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFPreferencesSetValue(CFSTR("AppleScrollBarVariant"), - CFSTR("DoubleMax"), - kCFPreferencesAnyApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); -#ifndef __LP64__ - // Make HIToolbox read from CFPreferences. - // HIToolbox is not available in 64-bit. DumpRenderTree comments out this - // call with a note to rdar://6347388 . No clue, sorry. - ThemeScrollBarArrowStyle style; - GetThemeScrollBarArrowStyle(&style); -#endif // __LP64__ - if (initialValue) { - // Reset the preference to what it was - CFPreferencesSetValue(CFSTR("AppleScrollBarVariant"), - initialValue, - kCFPreferencesAnyApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFRelease(initialValue); - } -} - -static void ClearAnyDefaultsForLayoutTests(void) { - // Not running a test, clear the keys so the TestShell looks right to the - // running user. - - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - [defaults removeObjectForKey:@"AppleAntiAliasingThreshold"]; - [defaults removeObjectForKey:@"AppleFontSmoothing"]; - [defaults removeObjectForKey:@"AppleAquaColorVariant"]; - [defaults removeObjectForKey:@"AppleHighlightColor"]; - [defaults removeObjectForKey:@"AppleOtherHighlightColor"]; - [defaults removeObjectForKey:@"AppleLanguages"]; - [defaults removeObjectForKey:@"AppleScrollBarVariant"]; -} - -#if OBJC_API_VERSION == 2 -static void SwizzleAllMethods(Class imposter, Class original) { - unsigned int imposterMethodCount = 0; - Method* imposterMethods = - class_copyMethodList(imposter, &imposterMethodCount); - - unsigned int originalMethodCount = 0; - Method* originalMethods = - class_copyMethodList(original, &originalMethodCount); - - for (unsigned int i = 0; i < imposterMethodCount; i++) { - SEL imposterMethodName = method_getName(imposterMethods[i]); - - // Attempt to add the method to the original class. If it fails, the method - // already exists and we should instead exchange the implementations. - if (class_addMethod(original, - imposterMethodName, - method_getImplementation(originalMethods[i]), - method_getTypeEncoding(originalMethods[i]))) { - continue; - } - - unsigned int j = 0; - for (; j < originalMethodCount; j++) { - SEL originalMethodName = method_getName(originalMethods[j]); - if (sel_isEqual(imposterMethodName, originalMethodName)) { - break; - } - } - - // If class_addMethod failed above then the method must exist on the - // original class. - DCHECK(j < originalMethodCount) << "method wasn't found?"; - method_exchangeImplementations(imposterMethods[i], originalMethods[j]); - } - - if (imposterMethods) { - free(imposterMethods); - } - if (originalMethods) { - free(originalMethods); - } -} -#endif - -static void SwizzleNSPasteboard(void) { - // We replace NSPaseboard w/ the shim (from WebKit) that avoids having - // sideeffects w/ whatever the user does at the same time. - - Class imposterClass = objc_getClass("DumpRenderTreePasteboard"); - Class originalClass = objc_getClass("NSPasteboard"); -#if OBJC_API_VERSION == 0 - class_poseAs(imposterClass, originalClass); -#else - // Swizzle instance methods... - SwizzleAllMethods(imposterClass, originalClass); - // and then class methods. - SwizzleAllMethods(object_getClass(imposterClass), - object_getClass(originalClass)); -#endif -} - -TestShellPlatformDelegate::TestShellPlatformDelegate( - const CommandLine &command_line) - : command_line_(command_line) { - gTestShellAutoreleasePool = [[NSAutoreleasePool alloc] init]; - // Force AppKit to init itself, but don't start the runloop yet - [MockCrApp sharedApplication]; - [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; -} - -TestShellPlatformDelegate::~TestShellPlatformDelegate() { - [gTestShellAutoreleasePool drain]; -} - -bool TestShellPlatformDelegate::CheckLayoutTestSystemDependencies() { - return true; -} - -void TestShellPlatformDelegate::InitializeGUI() { - // Make sure any settings from a previous layout run are cleared - ClearAnyDefaultsForLayoutTests(); -} - -void TestShellPlatformDelegate::PreflightArgs(int *argc, char ***argv) { -} - -void TestShellPlatformDelegate::SetWindowPositionForRecording(TestShell *) { -} - -void TestShellPlatformDelegate::SelectUnifiedTheme() { - SetDefaultsToLayoutTestValues(); - SwizzleNSPasteboard(); -} - -void TestShellPlatformDelegate::SuppressErrorReporting() { - const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); - - // If we die during tests, we don't want to be spamming the user's crash - // reporter. Set our exception port to null and add signal handlers. - // Both of these are necessary to avoid the crash reporter. Although, we do - // still seem to be missing some cases. - if (!parsed_command_line.HasSwitch(test_shell::kGDB)) { - task_set_exception_ports(mach_task_self(), EXC_MASK_ALL, MACH_PORT_NULL, - EXCEPTION_DEFAULT, THREAD_STATE_NONE); - } -} diff --git a/webkit/tools/test_shell/test_shell_platform_delegate_win.cc b/webkit/tools/test_shell/test_shell_platform_delegate_win.cc deleted file mode 100644 index c01bd32..0000000 --- a/webkit/tools/test_shell/test_shell_platform_delegate_win.cc +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <string> -#include <list> -#include <windows.h> -#include <commctrl.h> - -#include "base/command_line.h" -#include "base/event_recorder.h" -#include "base/win/win_util.h" -#include "ui/base/win/foreground_helper.h" -#include "ui/native_theme/native_theme_win.h" -#include "webkit/tools/test_shell/test_shell.h" -#include "webkit/tools/test_shell/test_shell_platform_delegate.h" - -TestShellPlatformDelegate::TestShellPlatformDelegate( - const CommandLine& command_line) - : command_line_(command_line) { -#ifdef _CRTDBG_MAP_ALLOC - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); -#endif -} - -TestShellPlatformDelegate::~TestShellPlatformDelegate() { -#ifdef _CRTDBG_MAP_ALLOC - _CrtDumpMemoryLeaks(); -#endif -} - -void TestShellPlatformDelegate::PreflightArgs(int *argc, char ***argv) { -} - - - -// This test approximates whether you are running the default themes for -// your platform by inspecting a couple of metrics. -// It does not catch all cases, but it does pick up on classic vs xp, -// and normal vs large fonts. Something it misses is changes to the color -// scheme (which will infact cause pixel test failures). -bool TestShellPlatformDelegate::CheckLayoutTestSystemDependencies() { - std::list<std::string> errors; - - OSVERSIONINFOEX osvi; - ::ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - ::GetVersionEx((OSVERSIONINFO *)&osvi); - - // Default to XP metrics, override if on Vista or win 7. - int requiredVScrollSize = 17; - int requiredFontSize = -11; // 8 pt - const wchar_t* requiredFont = L"Tahoma"; - bool isVista = false; - bool isWin7 = false; - if (osvi.dwMajorVersion == 6 - && osvi.dwMinorVersion == 1 - && osvi.wProductType == VER_NT_WORKSTATION) { - requiredFont = L"Segoe UI"; - requiredFontSize = -12; - isWin7 = true; - } else if (osvi.dwMajorVersion == 6 - && osvi.dwMinorVersion == 0 - && osvi.wProductType == VER_NT_WORKSTATION) { - requiredFont = L"Segoe UI"; - requiredFontSize = -12; // 9 pt - isVista = true; - } else if (!(osvi.dwMajorVersion == 5 - && osvi.dwMinorVersion == 1 - && osvi.wProductType == VER_NT_WORKSTATION)) { - // The above check is for XP, so that means ... - errors.push_back("Unsupported Operating System version " - "(must use XP, Vista, or Windows 7)."); - } - - // This metric will be 17 when font size is "Normal". - // The size of drop-down menus depends on it. - int vScrollSize = ::GetSystemMetrics(SM_CXVSCROLL); - if (vScrollSize != requiredVScrollSize) { - errors.push_back("Must use normal size fonts (96 dpi)."); - } - - // ClearType must be disabled, because the rendering is unpredictable. - BOOL bFontSmoothing; - SystemParametersInfo(SPI_GETFONTSMOOTHING, (UINT)0, - (PVOID)&bFontSmoothing, (UINT)0); - int fontSmoothingType; - SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, (UINT)0, - (PVOID)&fontSmoothingType, (UINT)0); - if (bFontSmoothing && (fontSmoothingType == FE_FONTSMOOTHINGCLEARTYPE)) { - errors.push_back("ClearType must be disabled."); - } - - // Check that we're using the default system fonts - NONCLIENTMETRICS metrics; - base::win::GetNonClientMetrics(&metrics); - LOGFONTW* system_fonts[] = - { &metrics.lfStatusFont, &metrics.lfMenuFont, &metrics.lfSmCaptionFont }; - - for (size_t i = 0; i < arraysize(system_fonts); ++i) { - if (system_fonts[i]->lfHeight != requiredFontSize || - wcscmp(requiredFont, system_fonts[i]->lfFaceName)) { - if (isVista || isWin7) - errors.push_back("Must use either the Aero or Basic theme."); - else - errors.push_back("Must use the default XP theme (Luna)."); - break; - } - } - - if (!errors.empty()) { - fprintf(stderr, "%s", - "##################################################################\n" - "## Layout test system dependencies check failed.\n" - "##\n"); - for (std::list<std::string>::iterator it = errors.begin(); - it != errors.end(); - ++it) { - fprintf(stderr, "## %s\n", it->c_str()); - } - fprintf(stderr, "%s", - "##\n" - "##################################################################\n"); - } - return errors.empty(); -} - -void TestShellPlatformDelegate::SuppressErrorReporting() { - _set_abort_behavior(0, _WRITE_ABORT_MSG); -} - -void TestShellPlatformDelegate::InitializeGUI() { - INITCOMMONCONTROLSEX InitCtrlEx; - - InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); - InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; - InitCommonControlsEx(&InitCtrlEx); - TestShell::RegisterWindowClass(); -} - -void TestShellPlatformDelegate::SelectUnifiedTheme() { - ui::NativeThemeWin::instance()->DisableTheming(); -} - -void TestShellPlatformDelegate::SetWindowPositionForRecording( - TestShell *shell) { - // Move the window to the upper left corner for consistent - // record/playback mode. For automation, we want this to work - // on build systems where the script invoking us is a background - // process. So for this case, make our window the topmost window - // as well. - CHECK(ui::ForegroundHelper::SetForeground(shell->mainWnd()) == S_OK); - ::SetWindowPos(shell->mainWnd(), HWND_TOP, 0, 0, 600, 800, 0); -} diff --git a/webkit/tools/test_shell/test_shell_resources.grd b/webkit/tools/test_shell/test_shell_resources.grd deleted file mode 100644 index 09e9b34..0000000 --- a/webkit/tools/test_shell/test_shell_resources.grd +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<grit latest_public_release="0" current_release="1"> - <outputs> - <output filename="grit/test_shell_resources.h" type="rc_header"> - <emit emit_type='prepend'></emit> - </output> - <output filename="test_shell_resources.pak" type="data_package" /> - </outputs> - <release seq="1"> - <includes> - <include name="IDR_AHEM_FONT" file="resources\AHEM____.TTF" type="BINDATA" /> - <include name="IDR_BROKENIMAGE_TESTSHELL" file="resources\missingImage.gif" type="BINDATA" /> - <include name="IDR_TEXTAREA_RESIZER_TESTSHELL" file="resources\textAreaResizeCorner.png" type="BINDATA" /> - </includes> - </release> -</grit> diff --git a/webkit/tools/test_shell/test_shell_switches.cc b/webkit/tools/test_shell/test_shell_switches.cc deleted file mode 100644 index 3dd2140..0000000 --- a/webkit/tools/test_shell/test_shell_switches.cc +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_shell_switches.h" - -namespace test_shell { - -// Suppresses all error dialogs when present. -const char kNoErrorDialogs[] = "noerrdialogs"; - -const char kCrashDumps[] = "crash-dumps"; // Enable crash dumps -// Dumps the full-heap instead of only stack. Used with kCrashDumps. -const char kCrashDumpsFulldump[] = "crash-dumps-fulldump"; - -// Causes the test_shell to run with a generic theme (part of layout_tests). -const char kGenericTheme[] = "generic-theme"; - -// This causes the test_shell to run with the classic theme. -// Passing --layout-tests enables this by default. -const char kClassicTheme[] = "classic-theme"; - -// This causes the test_shell to run with the new windows theming engine -// enabled. This is the default unless --layout-tests is specified. -const char kUxTheme[] = "ux-theme"; - -const char kStartupDialog[] = "testshell-startup-dialog"; - -// Enable the Windows dialogs for GP faults in the test shell. This allows makes -// it possible to attach a crashed test shell to a debugger. -const char kGPFaultErrorBox[] = "gp-fault-error-box"; - -// JavaScript flags passed to engine. If multiple loads has been specified this -// can be a list separated by commas. Each set of flags are passed to the engine -// in the corresponding load. -const char kJavaScriptFlags[] = "js-flags"; - -// Dump stats table on exit. -const char kDumpStatsTable[] = "stats"; - -// Use a specified cache directory. -const char kCacheDir[] = "cache-dir"; - -// Enable cookies on the file:// scheme. --layout-tests also enables this. -const char kEnableFileCookies[] = "enable-file-cookies"; - -// Allow scripts to close windows in all cases. -const char kAllowScriptsToCloseWindows[] = "allow-scripts-to-close-windows"; - -// Test the system dependencies (themes, fonts, ...). When this flag is -// specified, the test shell will exit immediately with either 0 (success) or -// 1 (failure). Combining with other flags has no effect. -const char kCheckLayoutTestSystemDeps[] = "check-layout-test-sys-deps"; - -// If set, we are running under GDB so allow a certain class of errors -// to happen even if in layout test mode. -const char kGDB[] = "gdb"; - -const char kAllowExternalPages[] = "allow-external-pages"; - -const char kEnableAccel2DCanvas[] = "enable-accelerated-2d-canvas"; - -const char kEnableAccelCompositing[] = "enable-accelerated-compositing"; - -const char kEnableSmoothScrolling[] = "enable-smooth-scrolling"; - -} // namespace test_shell diff --git a/webkit/tools/test_shell/test_shell_switches.h b/webkit/tools/test_shell/test_shell_switches.h deleted file mode 100644 index b8843d1..0000000 --- a/webkit/tools/test_shell/test_shell_switches.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Defines all the command-line switches used by Chrome. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_SWITCHES_H__ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_SWITCHES_H__ - -namespace test_shell { - -extern const char kCrashDumps[]; -extern const char kCrashDumpsFulldump[]; -extern const char kGenericTheme[]; -extern const char kClassicTheme[]; -extern const char kUxTheme[]; -extern const char kNoErrorDialogs[]; -extern const char kStartupDialog[]; -extern const char kGPFaultErrorBox[]; -extern const char kJavaScriptFlags[]; -extern const char kDumpStatsTable[]; -extern const char kCacheDir[]; -extern const char kEnableFileCookies[]; -extern const char kAllowScriptsToCloseWindows[]; -extern const char kCheckLayoutTestSystemDeps[]; -extern const char kGDB[]; -extern const char kAllowExternalPages[]; -extern const char kEnableAccel2DCanvas[]; -extern const char kEnableAccelCompositing[]; -extern const char kEnableSmoothScrolling[]; - -} // namespace test_shell - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_SWITCHES_H__ diff --git a/webkit/tools/test_shell/test_shell_test.cc b/webkit/tools/test_shell/test_shell_test.cc deleted file mode 100644 index dc503ed..0000000 --- a/webkit/tools/test_shell/test_shell_test.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_shell_test.h" - -#include <string> - -#include "base/basictypes.h" -#include "base/file_util.h" -#include "base/files/file_path.h" -#include "base/message_loop.h" -#include "base/path_service.h" -#include "base/string_util.h" -#include "googleurl/src/gurl.h" -#include "net/base/net_util.h" -#include "webkit/user_agent/user_agent.h" -#include "webkit/user_agent/user_agent_util.h" - -GURL TestShellTest::GetTestURL(const base::FilePath& test_case_path, - const std::string& test_case) { - return net::FilePathToFileURL(test_case_path.AppendASCII(test_case)); -} - -void TestShellTest::SetUp() { - // Make a test shell for use by the test. - CreateEmptyWindow(); - test_shell_->Show(WebKit::WebNavigationPolicyNewWindow); - webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( - "TestShell/0.0.0.0"), false); - - // Point data_dir_ to the root of the test case dir - ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir_)); - data_dir_ = data_dir_.Append(FILE_PATH_LITERAL("webkit")); - data_dir_ = data_dir_.Append(FILE_PATH_LITERAL("data")); - ASSERT_TRUE(file_util::PathExists(data_dir_)); -} - -void TestShellTest::TearDown() { - // Loading a blank url clears the memory in the current page. - test_shell_->LoadURL(GURL("about:blank")); - test_shell_->DestroyWindow(test_shell_->mainWnd()); - - // Flush the MessageLoop of any residual tasks. - base::MessageLoop::current()->RunUntilIdle(); -} - -void TestShellTest::CreateEmptyWindow() { - TestShell::CreateNewWindow(GURL("about:blank"), &test_shell_); -} diff --git a/webkit/tools/test_shell/test_shell_test.h b/webkit/tools/test_shell/test_shell_test.h deleted file mode 100644 index b6c7f17..0000000 --- a/webkit/tools/test_shell/test_shell_test.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * Base test class used by all test shell tests. Provides boiler plate - * code to create and destroy a new test shell for each gTest test. - */ - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_TEST_H__ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_TEST_H__ - -#include <string> - -#include "base/files/file_path.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/window_open_disposition.h" -#include "webkit/tools/test_shell/test_shell.h" - -class TestShellTest : public testing::Test { - protected: - // Returns the path "test_case_path/test_case". - GURL GetTestURL(const base::FilePath& test_case_path, - const std::string& test_case); - - virtual void SetUp() OVERRIDE; - virtual void TearDown() OVERRIDE; - - // Don't refactor away; some unittests override this! - virtual void CreateEmptyWindow(); - - protected: - // Location of SOURCE_ROOT/webkit/data/ - base::FilePath data_dir_; - - TestShell* test_shell_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_TEST_H__ diff --git a/webkit/tools/test_shell/test_shell_webkit_init.cc b/webkit/tools/test_shell/test_shell_webkit_init.cc deleted file mode 100644 index 2dcbb6c..0000000 --- a/webkit/tools/test_shell/test_shell_webkit_init.cc +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_shell_webkit_init.h" - -#include "base/metrics/stats_counters.h" -#include "base/path_service.h" -#include "media/base/media.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" -#include "ui/gl/gl_bindings_skia_in_process.h" -#include "v8/include/v8.h" -#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/plugins/webplugininfo.h" -#include "webkit/tools/test_shell/simple_socket_stream_bridge.h" -#include "webkit/tools/test_shell/test_shell.h" - -#if defined(OS_WIN) -#include "webkit/tools/test_shell/test_shell_webthemeengine.h" -#endif - -TestShellWebKitInit::TestShellWebKitInit(bool layout_test_mode) - : real_clipboard_(&clipboard_client_) { - v8::V8::SetCounterFunction(base::StatsTable::FindLocation); - - WebKit::initialize(this); - WebKit::setLayoutTestMode(layout_test_mode); - WebKit::WebSecurityPolicy::registerURLSchemeAsLocal( - WebKit::WebString::fromUTF8("test-shell-resource")); - WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess( - WebKit::WebString::fromUTF8("test-shell-resource")); - WebKit::WebScriptController::enableV8SingleThreadMode(); - WebKit::WebRuntimeFeatures::enableApplicationCache(true); - WebKit::WebRuntimeFeatures::enableDatabase(true); - WebKit::WebRuntimeFeatures::enableNotifications(true); - WebKit::WebRuntimeFeatures::enableTouch(true); - WebKit::WebRuntimeFeatures::enableIndexedDatabase(true); - WebKit::WebRuntimeFeatures::enableSpeechInput(true); - WebKit::WebRuntimeFeatures::enableFileSystem(true); - - // TODO(hwennborg): Enable this once the implementation supports it. - WebKit::WebRuntimeFeatures::enableDeviceMotion(false); - WebKit::WebRuntimeFeatures::enableDeviceOrientation(true); - - // Enable experimental I18N API for testing. - WebKit::WebRuntimeFeatures::enableJavaScriptI18NAPI(true); - - // Load libraries for media and enable the media player. - base::FilePath module_path; - WebKit::WebRuntimeFeatures::enableMediaPlayer( - PathService::Get(base::DIR_MODULE, &module_path) && - media::InitializeMediaLibrary(module_path)); - - WebKit::WebRuntimeFeatures::enableGeolocation(true); - - // Construct and initialize an appcache system for this scope. - // A new empty temp directory is created to house any cached - // content during the run. Upon exit that directory is deleted. - // If we can't create a tempdir, we'll use in-memory storage. - if (!appcache_dir_.CreateUniqueTempDir()) { - LOG(WARNING) << "Failed to create a temp dir for the appcache, " - "using in-memory storage."; - DCHECK(appcache_dir_.path().empty()); - } - SimpleAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); - - WebKit::WebDatabase::setObserver(&database_system_); - - blob_registry_ = new TestShellWebBlobRegistryImpl(); - - file_utilities_.set_sandbox_enabled(false); - - // Restrict the supported media types when running in layout test mode. - if (layout_test_mode) - mime_registry_.reset(new TestShellWebMimeRegistryImpl()); - else - mime_registry_.reset(new webkit_glue::SimpleWebMimeRegistryImpl()); - -#if defined(OS_WIN) - // Ensure we pick up the default theme engine. - SetThemeEngine(NULL); -#endif -} - -TestShellWebKitInit::~TestShellWebKitInit() { - if (RunningOnValgrind()) - WebKit::WebCache::clear(); - WebKit::shutdown(); -} - -WebKit::WebMimeRegistry* TestShellWebKitInit::mimeRegistry() { - return mime_registry_.get(); -} - -WebKit::WebClipboard* TestShellWebKitInit::clipboard() { - // Mock out clipboard calls in layout test mode so that tests don't mess - // with each other's copies/pastes when running in parallel. - if (TestShell::layout_test_mode()) { - return &mock_clipboard_; - } else { - return &real_clipboard_; - } -} - -WebKit::WebFileUtilities* TestShellWebKitInit::fileUtilities() { - return &file_utilities_; -} - -WebKit::WebSandboxSupport* TestShellWebKitInit::sandboxSupport() { - return NULL; -} - -WebKit::WebCookieJar* TestShellWebKitInit::cookieJar() { - return &cookie_jar_; -} - -WebKit::WebBlobRegistry* TestShellWebKitInit::blobRegistry() { - return blob_registry_.get(); -} - -WebKit::WebFileSystem* TestShellWebKitInit::fileSystem() { - return &file_system_; -} - -bool TestShellWebKitInit::sandboxEnabled() { - return true; -} - -WebKit::Platform::FileHandle -TestShellWebKitInit::databaseOpenFile( - const WebKit::WebString& vfs_file_name, int desired_flags) { - return SimpleDatabaseSystem::GetInstance()->OpenFile( - vfs_file_name, desired_flags); -} - -int TestShellWebKitInit::databaseDeleteFile( - const WebKit::WebString& vfs_file_name, - bool sync_dir) { - return SimpleDatabaseSystem::GetInstance()->DeleteFile( - vfs_file_name, sync_dir); -} - -long TestShellWebKitInit::databaseGetFileAttributes( - const WebKit::WebString& vfs_file_name) { - return SimpleDatabaseSystem::GetInstance()->GetFileAttributes( - vfs_file_name); -} - -long long TestShellWebKitInit::databaseGetFileSize( - const WebKit::WebString& vfs_file_name) { - return SimpleDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name); -} - -long long TestShellWebKitInit::databaseGetSpaceAvailableForOrigin( - const WebKit::WebString& origin_identifier) { - return SimpleDatabaseSystem::GetInstance()->GetSpaceAvailable( - origin_identifier); -} - -unsigned long long TestShellWebKitInit::visitedLinkHash( - const char* canonicalURL, - size_t length) { - return 0; -} - -bool TestShellWebKitInit::isLinkVisited(unsigned long long linkHash) { - return false; -} - -WebKit::WebMessagePortChannel* TestShellWebKitInit::createMessagePortChannel() { - return NULL; -} - -void TestShellWebKitInit::prefetchHostName(const WebKit::WebString&) { -} - -WebKit::WebData TestShellWebKitInit::loadResource(const char* name) { - if (!strcmp(name, "deleteButton")) { - // Create a red 30x30 square. - const char red_square[] = - "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" - "\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3" - "\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00" - "\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80" - "\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff" - "\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00" - "\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a" - "\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a" - "\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d" - "\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60" - "\x82"; - return WebKit::WebData(red_square, arraysize(red_square)); - } - return webkit_glue::WebKitPlatformSupportImpl::loadResource(name); -} - -WebKit::WebString TestShellWebKitInit::queryLocalizedString( - WebKit::WebLocalizedString::Name name) { - switch (name) { - case WebKit::WebLocalizedString::ValidationValueMissing: - case WebKit::WebLocalizedString::ValidationValueMissingForCheckbox: - case WebKit::WebLocalizedString::ValidationValueMissingForFile: - case WebKit::WebLocalizedString::ValidationValueMissingForMultipleFile: - case WebKit::WebLocalizedString::ValidationValueMissingForRadio: - case WebKit::WebLocalizedString::ValidationValueMissingForSelect: - return ASCIIToUTF16("value missing"); - case WebKit::WebLocalizedString::ValidationTypeMismatch: - case WebKit::WebLocalizedString::ValidationTypeMismatchForEmail: - case WebKit::WebLocalizedString::ValidationTypeMismatchForMultipleEmail: - case WebKit::WebLocalizedString::ValidationTypeMismatchForURL: - return ASCIIToUTF16("type mismatch"); - case WebKit::WebLocalizedString::ValidationPatternMismatch: - return ASCIIToUTF16("pattern mismatch"); - case WebKit::WebLocalizedString::ValidationTooLong: - return ASCIIToUTF16("too long"); - case WebKit::WebLocalizedString::ValidationRangeUnderflow: - return ASCIIToUTF16("range underflow"); - case WebKit::WebLocalizedString::ValidationRangeOverflow: - return ASCIIToUTF16("range overflow"); - case WebKit::WebLocalizedString::ValidationStepMismatch: - return ASCIIToUTF16("step mismatch"); - default: - return WebKitPlatformSupportImpl::queryLocalizedString(name); - } -} - -WebKit::WebString TestShellWebKitInit::queryLocalizedString( - WebKit::WebLocalizedString::Name name, const WebKit::WebString& value) { - if (name == WebKit::WebLocalizedString::ValidationRangeUnderflow) - return ASCIIToUTF16("range underflow"); - if (name == WebKit::WebLocalizedString::ValidationRangeOverflow) - return ASCIIToUTF16("range overflow"); - return WebKitPlatformSupportImpl::queryLocalizedString(name, value); -} - -WebKit::WebString TestShellWebKitInit::queryLocalizedString( - WebKit::WebLocalizedString::Name name, - const WebKit::WebString& value1, - const WebKit::WebString& value2) { - if (name == WebKit::WebLocalizedString::ValidationTooLong) - return ASCIIToUTF16("too long"); - if (name == WebKit::WebLocalizedString::ValidationStepMismatch) - return ASCIIToUTF16("step mismatch"); - return WebKitPlatformSupportImpl::queryLocalizedString(name, value1, value2); -} - -WebKit::WebString TestShellWebKitInit::defaultLocale() { - return ASCIIToUTF16("en-US"); -} - -WebKit::WebStorageNamespace* TestShellWebKitInit::createLocalStorageNamespace( - const WebKit::WebString& path, unsigned quota) { - return dom_storage_system_.CreateLocalStorageNamespace(); -} - -WebKit::WebIDBFactory* TestShellWebKitInit::idbFactory() { - return WebKit::WebIDBFactory::create(); -} - -WebKit::WebGraphicsContext3D* -TestShellWebKitInit::createOffscreenGraphicsContext3D( - const WebKit::WebGraphicsContext3D::Attributes& attributes) { - using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; - return WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( - attributes); -} - -void TestShellWebKitInit::GetPlugins( - bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { - if (refresh) - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); - webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); -} - -webkit_glue::ResourceLoaderBridge* -TestShellWebKitInit::CreateResourceLoader( - const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { - return SimpleResourceLoaderBridge::Create(request_info); -} - -webkit_glue::WebSocketStreamHandleBridge* -TestShellWebKitInit::CreateWebSocketBridge( - WebKit::WebSocketStreamHandle* handle, - webkit_glue::WebSocketStreamHandleDelegate* delegate) { - return SimpleSocketStreamBridge::Create(handle, delegate); -} diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h deleted file mode 100644 index 0204f2f..0000000 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ - -#include "base/compiler_specific.h" -#include "base/utf_string_conversions.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebIDBFactory.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebStorageNamespace.h" -#include "webkit/glue/webclipboard_impl.h" -#include "webkit/glue/webfileutilities_impl.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webkitplatformsupport_impl.h" -#include "webkit/support/simple_database_system.h" -#include "webkit/tools/test_shell/mock_webclipboard_impl.h" -#include "webkit/tools/test_shell/simple_appcache_system.h" -#include "webkit/tools/test_shell/simple_clipboard_impl.h" -#include "webkit/tools/test_shell/simple_dom_storage_system.h" -#include "webkit/tools/test_shell/simple_file_system.h" -#include "webkit/tools/test_shell/simple_resource_loader_bridge.h" -#include "webkit/tools/test_shell/simple_webcookiejar_impl.h" -#include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" -#include "webkit/tools/test_shell/test_shell_webmimeregistry_impl.h" - -#if defined(OS_WIN) -#include "webkit/tools/test_shell/test_shell_webthemeengine.h" -#endif - -class TestShellWebKitInit : public webkit_glue::WebKitPlatformSupportImpl { - public: - explicit TestShellWebKitInit(bool layout_test_mode); - virtual ~TestShellWebKitInit(); - - virtual WebKit::WebMimeRegistry* mimeRegistry() OVERRIDE; - virtual WebKit::WebClipboard* clipboard() OVERRIDE; - virtual WebKit::WebFileUtilities* fileUtilities() OVERRIDE; - virtual WebKit::WebSandboxSupport* sandboxSupport() OVERRIDE; - virtual WebKit::WebCookieJar* cookieJar() OVERRIDE; - virtual WebKit::WebBlobRegistry* blobRegistry() OVERRIDE; - virtual WebKit::WebFileSystem* fileSystem() OVERRIDE; - virtual bool sandboxEnabled() OVERRIDE; - virtual WebKit::Platform::FileHandle databaseOpenFile( - const WebKit::WebString& vfs_file_name, int desired_flags) OVERRIDE; - virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, - bool sync_dir) OVERRIDE; - virtual long databaseGetFileAttributes( - const WebKit::WebString& vfs_file_name) OVERRIDE; - virtual long long databaseGetFileSize( - const WebKit::WebString& vfs_file_name) OVERRIDE; - virtual long long databaseGetSpaceAvailableForOrigin( - const WebKit::WebString& origin_identifier) OVERRIDE; - virtual unsigned long long visitedLinkHash(const char* canonicalURL, - size_t length) OVERRIDE; - virtual bool isLinkVisited(unsigned long long linkHash) OVERRIDE; - virtual WebKit::WebMessagePortChannel* createMessagePortChannel() OVERRIDE; - virtual void prefetchHostName(const WebKit::WebString&) OVERRIDE; - virtual WebKit::WebData loadResource(const char* name) OVERRIDE; - virtual WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name) OVERRIDE; - virtual WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name, - const WebKit::WebString& value) OVERRIDE; - virtual WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name, - const WebKit::WebString& value1, - const WebKit::WebString& value2) OVERRIDE; - - virtual WebKit::WebString defaultLocale() OVERRIDE; - - virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( - const WebKit::WebString& path, unsigned quota) OVERRIDE; - - virtual WebKit::WebIDBFactory* idbFactory(); - -#if defined(OS_WIN) - void SetThemeEngine(WebKit::WebThemeEngine* engine) { - active_theme_engine_ = engine ? - engine : WebKitPlatformSupportImpl::themeEngine(); - } - - virtual WebKit::WebThemeEngine *themeEngine() OVERRIDE { - return active_theme_engine_; - } -#endif - - virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D( - const WebKit::WebGraphicsContext3D::Attributes& attributes); - - virtual base::string16 GetLocalizedString(int message_id) OVERRIDE; - virtual base::StringPiece GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) OVERRIDE; - virtual void GetPlugins(bool refresh, - std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; - virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader( - const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) - OVERRIDE; - virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketBridge( - WebKit::WebSocketStreamHandle* handle, - webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE; - - private: - scoped_ptr<webkit_glue::SimpleWebMimeRegistryImpl> mime_registry_; - MockWebClipboardImpl mock_clipboard_; - SimpleClipboardClient clipboard_client_; - webkit_glue::WebClipboardImpl real_clipboard_; - webkit_glue::WebFileUtilitiesImpl file_utilities_; - base::ScopedTempDir appcache_dir_; - SimpleAppCacheSystem appcache_system_; - SimpleDatabaseSystem database_system_; - SimpleDomStorageSystem dom_storage_system_; - SimpleWebCookieJarImpl cookie_jar_; - scoped_refptr<TestShellWebBlobRegistryImpl> blob_registry_; - SimpleFileSystem file_system_; - -#if defined(OS_WIN) - WebKit::WebThemeEngine* active_theme_engine_; -#endif -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ diff --git a/webkit/tools/test_shell/test_shell_webthemecontrol.cc b/webkit/tools/test_shell/test_shell_webthemecontrol.cc deleted file mode 100644 index 25cd94f..0000000 --- a/webkit/tools/test_shell/test_shell_webthemecontrol.cc +++ /dev/null @@ -1,438 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file implements a simple generic version of the WebKitThemeEngine, -// which is used to draw all the native controls on a web page. We use this -// file when running in layout test mode in order to remove any -// platform-specific rendering differences due to themes, colors, etc. -// - -#include "webkit/tools/test_shell/test_shell_webthemecontrol.h" - -#include "base/logging.h" -#include "skia/ext/platform_canvas.h" -#include "skia/ext/skia_utils_win.h" -#include "third_party/skia/include/core/SkPaint.h" -#include "third_party/skia/include/core/SkPath.h" - -namespace TestShellWebTheme { - -const SkColor kEdgeColor = SK_ColorBLACK; -const SkColor kReadOnlyColor = SkColorSetRGB(0xe9, 0xc2, 0xa6); -const SkColor kFgColor = SK_ColorBLACK; - -const SkColor kBgColors[] = { - SK_ColorBLACK, // Unknown - SkColorSetRGB(0xc9, 0xc9, 0xc9), // Disabled - SkColorSetRGB(0xf3, 0xe0, 0xd0), // Readonly - SkColorSetRGB(0x89, 0xc4, 0xff), // Normal - SkColorSetRGB(0x43, 0xf9, 0xff), // Hot - SkColorSetRGB(0x20, 0xf6, 0xcc), // Focused - SkColorSetRGB(0x00, 0xf3, 0xac), // Hover - SkColorSetRGB(0xa9, 0xff, 0x12), // Pressed - SkColorSetRGB(0xcc, 0xcc, 0xcc) // Indeterminate -}; - -SkIRect Validate(const SkIRect& rect, Control::Type ctype) { - SkIRect retval = rect; - if (ctype == Control::kUncheckedBox_Type || - ctype == Control::kCheckedBox_Type || - ctype == Control::kUncheckedRadio_Type || - ctype == Control::kCheckedRadio_Type) { - // The maximum width and height is 13. Center the square in the passed - // rectangle. - const int kMaxControlSize = 13; - int control_size = std::min(rect.width(), rect.height()); - control_size = std::min(control_size, kMaxControlSize); - - retval.fLeft = rect.fLeft + (rect.width() / 2) - (control_size / 2); - retval.fRight = retval.fLeft + control_size - 1; - retval.fTop = rect.fTop + (rect.height() / 2) - (control_size / 2); - retval.fBottom = retval.fTop + control_size - 1; - } - return retval; -} - -Control::Control(SkCanvas* canvas, const SkIRect& irect, - Type ctype, State cstate) - : canvas_(canvas), - irect_(Validate(irect, ctype)), - type_(ctype), - state_(cstate), - left_(irect_.fLeft), - right_(irect_.fRight), - top_(irect_.fTop), - bottom_(irect_.fBottom), - height_(irect_.height()), - width_(irect_.width()), - edge_color_(kEdgeColor), - bg_color_(kBgColors[cstate]), - fg_color_(kFgColor) { -} - -Control::~Control() { -} - -void Control::box(const SkIRect& rect, SkColor fill_color) { - SkPaint paint; - - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(fill_color); - canvas_->drawIRect(rect, paint); - - paint.setColor(edge_color_); - paint.setStyle(SkPaint::kStroke_Style); - canvas_->drawIRect(rect, paint); -} - -void Control::line(int x0, int y0, int x1, int y1, SkColor color) { - SkPaint paint; - paint.setColor(color); - canvas_->drawLine(SkIntToScalar(x0), SkIntToScalar(y0), - SkIntToScalar(x1), SkIntToScalar(y1), - paint); -} - -void Control::triangle(int x0, int y0, - int x1, int y1, - int x2, int y2, - SkColor color) { - SkPath path; - SkPaint paint; - - paint.setColor(color); - paint.setStyle(SkPaint::kFill_Style); - path.incReserve(4); - path.moveTo(SkIntToScalar(x0), SkIntToScalar(y0)); - path.lineTo(SkIntToScalar(x1), SkIntToScalar(y1)); - path.lineTo(SkIntToScalar(x2), SkIntToScalar(y2)); - path.close(); - canvas_->drawPath(path, paint); - - paint.setColor(edge_color_); - paint.setStyle(SkPaint::kStroke_Style); - canvas_->drawPath(path, paint); -} - -void Control::roundRect(SkColor color) { - SkRect rect; - SkScalar radius = SkIntToScalar(5); - SkPaint paint; - - rect.set(irect_); - paint.setColor(color); - paint.setStyle(SkPaint::kFill_Style); - canvas_->drawRoundRect(rect, radius, radius, paint); - - paint.setColor(edge_color_); - paint.setStyle(SkPaint::kStroke_Style); - canvas_->drawRoundRect(rect, radius, radius, paint); -} - -void Control::oval(SkColor color) { - SkRect rect; - SkPaint paint; - - rect.set(irect_); - paint.setColor(color); - paint.setStyle(SkPaint::kFill_Style); - canvas_->drawOval(rect, paint); - - paint.setColor(edge_color_); - paint.setStyle(SkPaint::kStroke_Style); - canvas_->drawOval(rect, paint); -} - -void Control::circle(SkScalar radius, SkColor color) { - SkScalar cy = SkIntToScalar(top_ + height_ / 2); - SkScalar cx = SkIntToScalar(left_ + width_ / 2); - SkPaint paint; - - paint.setColor(color); - paint.setStyle(SkPaint::kFill_Style); - canvas_->drawCircle(cx, cy, radius, paint); - - paint.setColor(edge_color_); - paint.setStyle(SkPaint::kStroke_Style); - canvas_->drawCircle(cx, cy, radius, paint); -} - -void Control::nested_boxes(int indent_left, int indent_top, - int indent_right, int indent_bottom, - SkColor outer_color, SkColor inner_color) { - SkIRect lirect; - box(irect_, outer_color); - lirect.set(irect_.fLeft + indent_left, irect_.fTop + indent_top, - irect_.fRight - indent_right, irect_.fBottom - indent_bottom); - box(lirect, inner_color); -} - - -void Control::markState() { - // The horizontal lines in a read only control are spaced by this amount. - const int kReadOnlyLineOffset = 5; - - // The length of a triangle side for the corner marks. - const int kTriangleSize = 5; - - switch (state_) { - case kUnknown_State: // FALLTHROUGH - case kDisabled_State: // FALLTHROUGH - case kNormal_State: - // Don't visually mark these states (color is enough). - break; - case kReadOnly_State: - // Drawing lines across the control. - for (int i = top_ + kReadOnlyLineOffset; i < bottom_ ; - i += kReadOnlyLineOffset) { - line(left_ + 1, i, right_ - 1, i, kReadOnlyColor); - } - break; - case kHot_State: - // Draw a triangle in the upper left corner of the control. - triangle(left_, top_, - left_ + kTriangleSize, top_, - left_, top_ + kTriangleSize, edge_color_); - break; - case kHover_State: - // Draw a triangle in the upper right corner of the control. - triangle(right_, top_, - right_, top_ + kTriangleSize, - right_ - kTriangleSize, top_, edge_color_); - break; - case kFocused_State: - // Draw a triangle in the bottom right corner of the control. - triangle(right_, bottom_, - right_ - kTriangleSize, bottom_, - right_, bottom_ - kTriangleSize, edge_color_); - break; - case kPressed_State: - // Draw a triangle in the bottom left corner of the control. - triangle(left_, bottom_, - left_, bottom_ - kTriangleSize, - left_ + kTriangleSize, bottom_, edge_color_); - break; - default: - NOTREACHED(); - break; - } -} - -void Control::draw() { - int half_width = width_ / 2; - int half_height = height_ / 2; - int quarter_width = width_ / 4; - int quarter_height = height_ / 4; - - // Indent amounts for the check in a checkbox or radio button. - const int kCheckIndent = 3; - - // Indent amounts for short and long sides of the scrollbar notches. - const int kNotchLongOffset = 1; - const int kNotchShortOffset = 4; - const int kNoOffset = 0; - int short_offset; - int long_offset; - - // Indent amounts for the short and long sides of a scroll thumb box. - const int kThumbLongIndent = 0; - const int kThumbShortIndent = 2; - - // Indents for the crosshatch on a scroll grip. - const int kGripLongIndent = 3; - const int kGripShortIndent = 5; - - // Indents for the the slider track. - const int kSliderIndent = 2; - - skia::ScopedPlatformPaint scoped_platform_paint(canvas_); - switch (type_) { - case kUnknown_Type: - NOTREACHED(); - break; - case kTextField_Type: - // We render this by hand outside of this function. - NOTREACHED(); - break; - case kPushButton_Type: - // push buttons render as a rounded rectangle - roundRect(bg_color_); - break; - case kUncheckedBox_Type: - // Unchecked boxes are simply plain boxes. - box(irect_, bg_color_); - break; - case kCheckedBox_Type: - nested_boxes(kCheckIndent, kCheckIndent, kCheckIndent, kCheckIndent, - bg_color_, fg_color_); - break; - case kIndeterminateCheckBox_Type: - // Indeterminate checkbox is a box containing '-'. - nested_boxes(kCheckIndent, height_ / 2, kCheckIndent, height_ / 2, - bg_color_, fg_color_); - break; - case kUncheckedRadio_Type: - circle(SkIntToScalar(half_height), bg_color_); - break; - case kCheckedRadio_Type: - circle(SkIntToScalar(half_height), bg_color_); - circle(SkIntToScalar(half_height - kCheckIndent), fg_color_); - break; - case kHorizontalScrollTrackBack_Type: - // Draw a box with a notch at the left. - long_offset = half_height - kNotchLongOffset; - short_offset = width_ - kNotchShortOffset; - nested_boxes(kNoOffset, long_offset, short_offset, long_offset, - bg_color_, edge_color_); - break; - case kHorizontalScrollTrackForward_Type: - // Draw a box with a notch at the right. - long_offset = half_height - kNotchLongOffset; - short_offset = width_ - kNotchShortOffset; - nested_boxes(short_offset, long_offset, kNoOffset, long_offset, - bg_color_, fg_color_); - break; - case kVerticalScrollTrackBack_Type: - // Draw a box with a notch at the top. - long_offset = half_width - kNotchLongOffset; - short_offset = height_ - kNotchShortOffset; - nested_boxes(long_offset, kNoOffset, long_offset, short_offset, - bg_color_, fg_color_); - break; - case kVerticalScrollTrackForward_Type: - // Draw a box with a notch at the bottom. - long_offset = half_width - kNotchLongOffset; - short_offset = height_ - kNotchShortOffset; - nested_boxes(long_offset, short_offset, long_offset, kNoOffset, - bg_color_, fg_color_); - break; - case kHorizontalScrollThumb_Type: - // Draw a narrower box on top of the outside box. - nested_boxes(kThumbLongIndent, kThumbShortIndent, kThumbLongIndent, - kThumbShortIndent, bg_color_, bg_color_); - break; - case kVerticalScrollThumb_Type: - // Draw a shorter box on top of the outside box. - nested_boxes(kThumbShortIndent, kThumbLongIndent, kThumbShortIndent, - kThumbLongIndent, bg_color_, bg_color_); - break; - case kHorizontalSliderThumb_Type: - // Slider thumbs are ovals. - oval(bg_color_); - break; - case kHorizontalScrollGrip_Type: - // Draw a horizontal crosshatch for the grip. - long_offset = half_width - kGripLongIndent; - line(left_ + kGripLongIndent, top_ + half_height, - right_ - kGripLongIndent, top_ + half_height, fg_color_); - line(left_ + long_offset, top_ + kGripShortIndent, - left_ + long_offset, bottom_ - kGripShortIndent, fg_color_); - line(right_ - long_offset, top_ + kGripShortIndent, - right_ - long_offset, bottom_ - kGripShortIndent, fg_color_); - break; - case kVerticalScrollGrip_Type: - // Draw a vertical crosshatch for the grip. - long_offset = half_height - kGripLongIndent; - line(left_ + half_width, top_ + kGripLongIndent, - left_ + half_width, bottom_ - kGripLongIndent, fg_color_); - line(left_ + kGripShortIndent, top_ + long_offset, - right_ - kGripShortIndent, top_ + long_offset, fg_color_); - line(left_ + kGripShortIndent, bottom_ - long_offset, - right_ - kGripShortIndent, bottom_ - long_offset, fg_color_); - break; - case kLeftArrow_Type: - // Draw a left arrow inside a box. - box(irect_, bg_color_); - triangle(right_ - quarter_width, top_ + quarter_height, - right_ - quarter_width, bottom_ - quarter_height, - left_ + quarter_width, top_ + half_height, fg_color_); - break; - case kRightArrow_Type: - // Draw a left arrow inside a box. - box(irect_, bg_color_); - triangle(left_ + quarter_width, top_ + quarter_height, - right_ - quarter_width, top_ + half_height, - left_ + quarter_width, bottom_ - quarter_height, fg_color_); - break; - case kUpArrow_Type: - // Draw an up arrow inside a box. - box(irect_, bg_color_); - triangle(left_ + quarter_width, bottom_ - quarter_height, - left_ + half_width, top_ + quarter_height, - right_ - quarter_width, bottom_ - quarter_height, fg_color_); - break; - case kDownArrow_Type: - // Draw a down arrow inside a box. - box(irect_, bg_color_); - triangle(left_ + quarter_width, top_ + quarter_height, - right_ - quarter_width, top_ + quarter_height, - left_ + half_width, bottom_ - quarter_height, fg_color_); - break; - case kHorizontalSliderTrack_Type: - // Draw a narrow rect for the track plus box hatches on the ends. - SkIRect lirect; - lirect = irect_; - lirect.inset(kNoOffset, half_height - kSliderIndent); - box(lirect, bg_color_); - line(left_, top_, left_, bottom_, edge_color_); - line(right_, top_, right_, bottom_, edge_color_); - break; - case kDropDownButton_Type: - // Draw a box with a big down arrow on top. - box(irect_, bg_color_); - triangle(left_ + quarter_width, top_, - right_ - quarter_width, top_, - left_ + half_width, bottom_, fg_color_); - break; - default: - NOTREACHED(); - break; - } - - markState(); -} - -// Because rendering a text field is dependent on input -// parameters the other controls don't have, we render it directly -// rather than trying to overcomplicate draw() further. -void Control::drawTextField(bool draw_edges, bool fill_content_area, - SkColor color) { - SkPaint paint; - - skia::ScopedPlatformPaint scoped_platform_paint(canvas_); - if (fill_content_area) { - paint.setColor(color); - paint.setStyle(SkPaint::kFill_Style); - canvas_->drawIRect(irect_, paint); - } - if (draw_edges) { - paint.setColor(edge_color_); - paint.setStyle(SkPaint::kStroke_Style); - canvas_->drawIRect(irect_, paint); - } - - markState(); -} - -void -Control::drawProgressBar(const SkIRect& fill_rect) { - SkPaint paint; - - skia::ScopedPlatformPaint scoped_platform_paint(canvas_); - paint.setColor(bg_color_); - paint.setStyle(SkPaint::kFill_Style); - canvas_->drawIRect(irect_, paint); - - // Emulate clipping - SkIRect tofill; - tofill.intersect(irect_, fill_rect); - paint.setColor(fg_color_); - paint.setStyle(SkPaint::kFill_Style); - canvas_->drawIRect(tofill, paint); - - markState(); -} - -} // namespace TestShellWebTheme - diff --git a/webkit/tools/test_shell/test_shell_webthemecontrol.h b/webkit/tools/test_shell/test_shell_webthemecontrol.h deleted file mode 100644 index b439f81..0000000 --- a/webkit/tools/test_shell/test_shell_webthemecontrol.h +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// TestShellWebTheme::Control implements the generic rendering of controls -// needed by TestShellWebTheme::Engine. See the comments in that class -// header file for why this class is needed and used. -// -// This class implements a generic set of widgets using Skia. The widgets -// are optimized for testability, not a pleasing appearance. -// - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMECONTROL_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMECONTROL_H_ - -#include "base/basictypes.h" -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkRect.h" - -class SkCanvas; - -namespace TestShellWebTheme { - -class Control { - public: - // This list of states mostly mirrors the list in - // third_party/WebKit/WebCore/platform/ThemeTypes.h but is maintained - // separately since that isn't public and also to minimize dependencies. - // Note that the WebKit ThemeTypes seem to imply that a control can be - // in multiple states simultaneously but WebThemeEngine only allows for - // a single state at a time. - // - // Some definitions for the various states: - // Disabled - indicates that a control can't be modified or selected - // (corresponds to HTML 'disabled' attribute) - // ReadOnly - indicates that a control can't be modified but can be - // selected - // Normal - the normal state of control on the page when it isn't - // focused or otherwise active - // Hot - when the mouse is hovering over a part of the control, - // all the other parts are considered "hot" - // Hover - when the mouse is directly over a control (the CSS - // :hover pseudo-class) - // Focused - when the control has the keyboard focus - // Pressed - when the control is being triggered (by a mousedown or - // a key event). - // Indeterminate - when set to indeterminate (only for progress bar) - enum State { - kUnknown_State = 0, - kDisabled_State, - kReadOnly_State, - kNormal_State, - kHot_State, - kHover_State, - kFocused_State, - kPressed_State, - kIndeterminate_State - }; - - // This list of types mostly mirrors the list in - // third_party/WebKit/WebCore/platform/ThemeTypes.h but is maintained - // separately since that isn't public and also to minimize dependencies. - // - // Note that what the user might think of as a single control can be - // made up of multiple parts. For example, a single scroll bar contains - // six clickable parts - two arrows, the "thumb" indicating the current - // position on the bar, the other two parts of the bar (before and after - // the thumb) and the "gripper" on the thumb itself. - // - enum Type { - kUnknown_Type = 0, - kTextField_Type, - kPushButton_Type, - kUncheckedBox_Type, - kCheckedBox_Type, - kIndeterminateCheckBox_Type, - kUncheckedRadio_Type, - kCheckedRadio_Type, - kHorizontalScrollTrackBack_Type, - kHorizontalScrollTrackForward_Type, - kHorizontalScrollThumb_Type, - kHorizontalScrollGrip_Type, - kVerticalScrollTrackBack_Type, - kVerticalScrollTrackForward_Type, - kVerticalScrollThumb_Type, - kVerticalScrollGrip_Type, - kLeftArrow_Type, - kRightArrow_Type, - kUpArrow_Type, - kDownArrow_Type, - kHorizontalSliderTrack_Type, - kHorizontalSliderThumb_Type, - kDropDownButton_Type, - kProgressBar_Type - }; - - // canvas is the canvas to draw onto, and rect gives the size of the - // control. ctype and cstate specify the type and state of the control. - Control(SkCanvas* canvas, const SkIRect& rect, - Type ctype, State cstate); - ~Control(); - - // Draws the control. - void draw(); - - // Use this for TextField controls instead, because the logic - // for drawing them is dependent on what WebKit tells us to do. - // If draw_edges is true, draw an edge around the control. If - // fill_content_area is true, fill the content area with the given color. - void drawTextField(bool draw_edges, bool fill_content_area, SkColor color); - - // Use this for drawing ProgressBar controls instead, since we - // need to know the rect to fill inside the bar. - void drawProgressBar(const SkIRect& fill_rect); - - private: - // Draws a box of size specified by irect, filled with the given color. - // The box will have a border drawn in the default edge color. - void box(const SkIRect& irect, SkColor color); - - - // Draws a triangle of size specified by the three pairs of coordinates, - // filled with the given color. The box will have an edge drawn in the - // default edge color. - void triangle(int x0, int y0, int x1, int y1, int x2, int y2, - SkColor color); - - // Draws a rectangle the size of the control with rounded corners, filled - // with the specified color (and with a border in the default edge color). - void roundRect(SkColor color); - - // Draws an oval the size of the control, filled with the specified color - // and with a border in the default edge color. - void oval(SkColor color); - - // Draws a circle centered in the control with the specified radius, - // filled with the specified color, and with a border draw in the - // default edge color. - void circle(SkScalar radius, SkColor color); - - // Draws a box the size of the control, filled with the outer_color and - // with a border in the default edge color, and then draws another box - // indented on all four sides by the specified amounts, filled with the - // inner color and with a border in the default edge color. - void nested_boxes(int indent_left, int indent_top, - int indent_right, int indent_bottom, - SkColor outer_color, SkColor inner_color); - - // Draws a line between the two points in the given color. - void line(int x0, int y0, int x1, int y1, SkColor color); - - // Draws a distinctive mark on the control for each state, so that the - // state of the control can be determined without needing to know which - // color is which. - void markState(); - - SkCanvas* canvas_; - const SkIRect irect_; - const Type type_; - const State state_; - const SkColor edge_color_; - const SkColor bg_color_; - const SkColor fg_color_; - - // The following are convenience accessors for irect_. - const int left_; - const int right_; - const int top_; - const int bottom_; - const int width_; - const int height_; - - DISALLOW_COPY_AND_ASSIGN(Control); -}; - -} // namespace TestShellWebTheme - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMECONTROL_H_ diff --git a/webkit/tools/test_shell/test_shell_webthemeengine.cc b/webkit/tools/test_shell/test_shell_webthemeengine.cc deleted file mode 100644 index c5ecdf0..0000000 --- a/webkit/tools/test_shell/test_shell_webthemeengine.cc +++ /dev/null @@ -1,576 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file implements a simple generic version of the WebKitThemeEngine, -// Since WebThemeEngine is unfortunately defined in terms of the Windows -// Theme parameters and values, we need to translate all the values into -// generic equivalents that we can more easily understand. This file does -// that translation (acting as a Facade design pattern) and then uses -// TestShellWebTheme::Control for the actual rendering of the widgets. -// - -#include "webkit/tools/test_shell/test_shell_webthemeengine.h" - -// Although all this code is generic, we include these headers -// to pull in the Windows #defines for the parts and states of -// the controls. -#include <vsstyle.h> -#include <windows.h> - -#include "base/logging.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebCanvas.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" -#include "third_party/skia/include/core/SkRect.h" -#include "webkit/tools/test_shell/test_shell_webthemecontrol.h" - -// We define this for clarity, although there really should be a DFCS_NORMAL -// in winuser.h. -namespace { - const int kDFCSNormal = 0x0000; -} - -using WebKit::WebCanvas; -using WebKit::WebColor; -using WebKit::WebRect; - -namespace TestShellWebTheme { - -SkIRect webRectToSkIRect(const WebRect& web_rect) { - SkIRect irect; - irect.set(web_rect.x, web_rect.y, web_rect.x + web_rect.width, - web_rect.y + web_rect.height); - return irect; -} - -void drawControl(WebCanvas* canvas, const WebRect& rect, Control::Type ctype, - Control::State cstate) { - Control control(canvas, webRectToSkIRect(rect), ctype, cstate); - control.draw(); -} - -void drawTextField(WebCanvas* canvas, const WebRect& rect, - Control::Type ctype, Control::State cstate, - bool draw_edges, bool fill_content_area, WebColor color) { - Control control(canvas, webRectToSkIRect(rect), ctype, cstate); - control.drawTextField(draw_edges, fill_content_area, color); -} - -void drawProgressBar(WebCanvas* canvas, - Control::Type ctype, Control::State cstate, - const WebRect& bar_rect, const WebRect& fill_rect) { - Control control(canvas, webRectToSkIRect(bar_rect), ctype, cstate); - control.drawProgressBar(webRectToSkIRect(fill_rect)); -} - -void Engine::paintButton(WebCanvas* canvas, int part, int state, - int classic_state, const WebRect& rect) { - Control::Type ctype = Control::kUnknown_Type; - Control::State cstate = Control::kUnknown_State; - - if (part == BP_CHECKBOX) { - switch (state) { - case CBS_UNCHECKEDNORMAL: - CHECK_EQ(classic_state, kDFCSNormal); - ctype = Control::kUncheckedBox_Type; - cstate = Control::kNormal_State; - break; - case CBS_UNCHECKEDHOT: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_HOT); - ctype = Control::kUncheckedBox_Type; - cstate = Control::kHot_State; - break; - case CBS_UNCHECKEDPRESSED: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_PUSHED); - ctype = Control::kUncheckedBox_Type; - cstate = Control::kPressed_State; - break; - case CBS_UNCHECKEDDISABLED: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_INACTIVE); - ctype = Control::kUncheckedBox_Type; - cstate = Control::kDisabled_State; - break; - case CBS_CHECKEDNORMAL: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_CHECKED); - ctype = Control::kCheckedBox_Type; - cstate = Control::kNormal_State; - break; - case CBS_CHECKEDHOT: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_HOT); - ctype = Control::kCheckedBox_Type; - cstate = Control::kHot_State; - break; - case CBS_CHECKEDPRESSED: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_PUSHED); - ctype = Control::kCheckedBox_Type; - cstate = Control::kPressed_State; - break; - case CBS_CHECKEDDISABLED: - CHECK_EQ(classic_state, - DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE); - ctype = Control::kCheckedBox_Type; - cstate = Control::kDisabled_State; - break; - case CBS_MIXEDNORMAL: - // Classic theme can't represent mixed state checkbox. We assume - // it's equivalent to unchecked. - CHECK_EQ(classic_state, DFCS_BUTTONCHECK); - ctype = Control::kIndeterminateCheckBox_Type; - cstate = Control::kNormal_State; - break; - case CBS_MIXEDHOT: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_HOT); - ctype = Control::kIndeterminateCheckBox_Type; - cstate = Control::kHot_State; - break; - case CBS_MIXEDPRESSED: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_PUSHED); - ctype = Control::kIndeterminateCheckBox_Type; - cstate = Control::kPressed_State; - break; - case CBS_MIXEDDISABLED: - CHECK_EQ(classic_state, DFCS_BUTTONCHECK | DFCS_INACTIVE); - ctype = Control::kIndeterminateCheckBox_Type; - cstate = Control::kDisabled_State; - break; - default: - NOTREACHED(); - break; - } - } else if (BP_RADIOBUTTON == part) { - switch (state) { - case RBS_UNCHECKEDNORMAL: - CHECK_EQ(classic_state, DFCS_BUTTONRADIO); - ctype = Control::kUncheckedRadio_Type; - cstate = Control::kNormal_State; - break; - case RBS_UNCHECKEDHOT: - CHECK_EQ(classic_state, DFCS_BUTTONRADIO | DFCS_HOT); - ctype = Control::kUncheckedRadio_Type; - cstate = Control::kHot_State; - break; - case RBS_UNCHECKEDPRESSED: - CHECK_EQ(classic_state, DFCS_BUTTONRADIO | DFCS_PUSHED); - ctype = Control::kUncheckedRadio_Type; - cstate = Control::kPressed_State; - break; - case RBS_UNCHECKEDDISABLED: - CHECK_EQ(classic_state, DFCS_BUTTONRADIO | DFCS_INACTIVE); - ctype = Control::kUncheckedRadio_Type; - cstate = Control::kDisabled_State; - break; - case RBS_CHECKEDNORMAL: - CHECK_EQ(classic_state, DFCS_BUTTONRADIO | DFCS_CHECKED); - ctype = Control::kCheckedRadio_Type; - cstate = Control::kNormal_State; - break; - case RBS_CHECKEDHOT: - CHECK_EQ(classic_state, DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_HOT); - ctype = Control::kCheckedRadio_Type; - cstate = Control::kHot_State; - break; - case RBS_CHECKEDPRESSED: - CHECK_EQ(classic_state, DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_PUSHED); - ctype = Control::kCheckedRadio_Type; - cstate = Control::kPressed_State; - break; - case RBS_CHECKEDDISABLED: - CHECK_EQ(classic_state, - DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_INACTIVE); - ctype = Control::kCheckedRadio_Type; - cstate = Control::kDisabled_State; - break; - default: - NOTREACHED(); - break; - } - } else if (BP_PUSHBUTTON == part) { - switch (state) { - case PBS_NORMAL: - CHECK_EQ(classic_state, DFCS_BUTTONPUSH); - ctype = Control::kPushButton_Type; - cstate = Control::kNormal_State; - break; - case PBS_HOT: - CHECK_EQ(classic_state, DFCS_BUTTONPUSH | DFCS_HOT); - ctype = Control::kPushButton_Type; - cstate = Control::kHot_State; - break; - case PBS_PRESSED: - CHECK_EQ(classic_state, DFCS_BUTTONPUSH | DFCS_PUSHED); - ctype = Control::kPushButton_Type; - cstate = Control::kPressed_State; - break; - case PBS_DISABLED: - CHECK_EQ(classic_state, DFCS_BUTTONPUSH | DFCS_INACTIVE); - ctype = Control::kPushButton_Type; - cstate = Control::kDisabled_State; - break; - case PBS_DEFAULTED: - CHECK_EQ(classic_state, DFCS_BUTTONPUSH); - ctype = Control::kPushButton_Type; - cstate = Control::kFocused_State; - break; - default: - NOTREACHED(); - break; - } - } else { - NOTREACHED(); - } - - drawControl(canvas, rect, ctype, cstate); -} - - -void Engine::paintMenuList(WebCanvas* canvas, int part, int state, - int classic_state, const WebRect& rect) { - Control::Type ctype = Control::kUnknown_Type; - Control::State cstate = Control::kUnknown_State; - - if (CP_DROPDOWNBUTTON == part) { - ctype = Control::kDropDownButton_Type; - switch (state) { - case CBXS_NORMAL: - CHECK_EQ(classic_state, DFCS_MENUARROW); - cstate = Control::kNormal_State; - break; - case CBXS_HOT: - CHECK_EQ(classic_state, DFCS_MENUARROW | DFCS_HOT); - cstate = Control::kHover_State; - break; - case CBXS_PRESSED: - CHECK_EQ(classic_state, DFCS_MENUARROW | DFCS_PUSHED); - cstate = Control::kPressed_State; - break; - case CBXS_DISABLED: - CHECK_EQ(classic_state, DFCS_MENUARROW | DFCS_INACTIVE); - cstate = Control::kDisabled_State; - break; - default: - CHECK(false); - break; - } - } else { - CHECK(false); - } - - drawControl(canvas, rect, ctype, cstate); -} - -void Engine::paintScrollbarArrow(WebCanvas* canvas, int state, - int classic_state, const WebRect& rect) { - Control::Type ctype = Control::kUnknown_Type; - Control::State cstate = Control::kUnknown_State; - - switch (state) { - case ABS_UPNORMAL: - CHECK_EQ(classic_state, DFCS_SCROLLUP); - ctype = Control::kUpArrow_Type; - cstate = Control::kNormal_State; - break; - case ABS_DOWNNORMAL: - CHECK_EQ(classic_state, DFCS_SCROLLDOWN); - ctype = Control::kDownArrow_Type; - cstate = Control::kNormal_State; - break; - case ABS_LEFTNORMAL: - CHECK_EQ(classic_state, DFCS_SCROLLLEFT); - ctype = Control::kLeftArrow_Type; - cstate = Control::kNormal_State; - break; - case ABS_RIGHTNORMAL: - CHECK_EQ(classic_state, DFCS_SCROLLRIGHT); - ctype = Control::kRightArrow_Type; - cstate = Control::kNormal_State; - break; - case ABS_UPHOT: - CHECK_EQ(classic_state, DFCS_SCROLLUP | DFCS_HOT); - ctype = Control::kUpArrow_Type; - cstate = Control::kHot_State; - break; - case ABS_DOWNHOT: - CHECK_EQ(classic_state, DFCS_SCROLLDOWN | DFCS_HOT); - ctype = Control::kDownArrow_Type; - cstate = Control::kHot_State; - break; - case ABS_LEFTHOT: - CHECK_EQ(classic_state, DFCS_SCROLLLEFT | DFCS_HOT); - ctype = Control::kLeftArrow_Type; - cstate = Control::kHot_State; - break; - case ABS_RIGHTHOT: - CHECK_EQ(classic_state, DFCS_SCROLLRIGHT | DFCS_HOT); - ctype = Control::kRightArrow_Type; - cstate = Control::kHot_State; - break; - case ABS_UPHOVER: - CHECK_EQ(classic_state, DFCS_SCROLLUP); - ctype = Control::kUpArrow_Type; - cstate = Control::kHover_State; - break; - case ABS_DOWNHOVER: - CHECK_EQ(classic_state, DFCS_SCROLLDOWN); - ctype = Control::kDownArrow_Type; - cstate = Control::kHover_State; - break; - case ABS_LEFTHOVER: - CHECK_EQ(classic_state, DFCS_SCROLLLEFT); - ctype = Control::kLeftArrow_Type; - cstate = Control::kHover_State; - break; - case ABS_RIGHTHOVER: - CHECK_EQ(classic_state, DFCS_SCROLLRIGHT); - ctype = Control::kRightArrow_Type; - cstate = Control::kHover_State; - break; - case ABS_UPPRESSED: - CHECK_EQ(classic_state, DFCS_SCROLLUP | DFCS_PUSHED | DFCS_FLAT); - ctype = Control::kUpArrow_Type; - cstate = Control::kPressed_State; - break; - case ABS_DOWNPRESSED: - CHECK_EQ(classic_state, DFCS_SCROLLDOWN | DFCS_PUSHED | DFCS_FLAT); - ctype = Control::kDownArrow_Type; - cstate = Control::kPressed_State; - break; - case ABS_LEFTPRESSED: - CHECK_EQ(classic_state, DFCS_SCROLLLEFT | DFCS_PUSHED | DFCS_FLAT); - ctype = Control::kLeftArrow_Type; - cstate = Control::kPressed_State; - break; - case ABS_RIGHTPRESSED: - CHECK_EQ(classic_state, DFCS_SCROLLRIGHT | DFCS_PUSHED | DFCS_FLAT); - ctype = Control::kRightArrow_Type; - cstate = Control::kPressed_State; - break; - case ABS_UPDISABLED: - CHECK_EQ(classic_state, DFCS_SCROLLUP | DFCS_INACTIVE); - ctype = Control::kUpArrow_Type; - cstate = Control::kDisabled_State; - break; - case ABS_DOWNDISABLED: - CHECK_EQ(classic_state, DFCS_SCROLLDOWN | DFCS_INACTIVE); - ctype = Control::kDownArrow_Type; - cstate = Control::kDisabled_State; - break; - case ABS_LEFTDISABLED: - CHECK_EQ(classic_state, DFCS_SCROLLLEFT | DFCS_INACTIVE); - ctype = Control::kLeftArrow_Type; - cstate = Control::kDisabled_State; - break; - case ABS_RIGHTDISABLED: - CHECK_EQ(classic_state, DFCS_SCROLLRIGHT | DFCS_INACTIVE); - ctype = Control::kRightArrow_Type; - cstate = Control::kDisabled_State; - break; - default: - NOTREACHED(); - break; - } - - drawControl(canvas, rect, ctype, cstate); -} - -void Engine::paintScrollbarThumb(WebCanvas* canvas, int part, int state, - int classic_state, const WebRect& rect) { - Control::Type ctype = Control::kUnknown_Type; - Control::State cstate = Control::kUnknown_State; - - switch (part) { - case SBP_THUMBBTNHORZ: - ctype = Control::kHorizontalScrollThumb_Type; - break; - case SBP_THUMBBTNVERT: - ctype = Control::kVerticalScrollThumb_Type; - break; - case SBP_GRIPPERHORZ: - ctype = Control::kHorizontalScrollGrip_Type; - break; - case SBP_GRIPPERVERT: - ctype = Control::kVerticalScrollGrip_Type; - break; - default: - NOTREACHED(); - break; - } - - switch (state) { - case SCRBS_NORMAL: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kNormal_State; - break; - case SCRBS_HOT: - CHECK_EQ(classic_state, DFCS_HOT); - cstate = Control::kHot_State; - break; - case SCRBS_HOVER: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kHover_State; - break; - case SCRBS_PRESSED: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kPressed_State; - break; - case SCRBS_DISABLED: - NOTREACHED(); // This should never happen in practice. - break; - default: - NOTREACHED(); - break; - } - - drawControl(canvas, rect, ctype, cstate); -} - -void Engine::paintScrollbarTrack(WebCanvas* canvas, int part, int state, - int classic_state, const WebRect& rect, - const WebRect& align_rect) { - Control::Type ctype = Control::kUnknown_Type; - Control::State cstate = Control::kUnknown_State; - - switch (part) { - case SBP_UPPERTRACKHORZ: - ctype = Control::kHorizontalScrollTrackBack_Type; - break; - case SBP_LOWERTRACKHORZ: - ctype = Control::kHorizontalScrollTrackForward_Type; - break; - case SBP_UPPERTRACKVERT: - ctype = Control::kVerticalScrollTrackBack_Type; - break; - case SBP_LOWERTRACKVERT: - ctype = Control::kVerticalScrollTrackForward_Type; - break; - default: - NOTREACHED(); - break; - } - - switch (state) { - case SCRBS_NORMAL: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kNormal_State; - break; - case SCRBS_HOT: - NOTREACHED(); // This should never happen in practice. - break; - case SCRBS_HOVER: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kHover_State; - break; - case SCRBS_PRESSED: - NOTREACHED(); // This should never happen in practice. - break; - case SCRBS_DISABLED: - CHECK_EQ(classic_state, DFCS_INACTIVE); - cstate = Control::kDisabled_State; - break; - default: - CHECK(false); - break; - } - - drawControl(canvas, rect, ctype, cstate); -} - -void Engine::paintTextField(WebCanvas* canvas, int part, int state, - int classic_state, const WebRect& rect, - WebColor color, bool fill_content_area, - bool draw_edges) { - Control::Type ctype = Control::kUnknown_Type; - Control::State cstate = Control::kUnknown_State; - - CHECK_EQ(EP_EDITTEXT, part); - ctype = Control::kTextField_Type; - - switch (state) { - case ETS_NORMAL: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kNormal_State; - break; - case ETS_HOT: - CHECK_EQ(classic_state, DFCS_HOT); - cstate = Control::kHot_State; - break; - case ETS_DISABLED: - CHECK_EQ(classic_state, DFCS_INACTIVE); - cstate = Control::kDisabled_State; - break; - case ETS_SELECTED: - CHECK_EQ(classic_state, DFCS_PUSHED); - cstate = Control::kPressed_State; - break; - case ETS_FOCUSED: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kFocused_State; - break; - case ETS_READONLY: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kReadOnly_State; - break; - default: - NOTREACHED(); - break; - } - - drawTextField(canvas, rect, ctype, cstate, draw_edges, fill_content_area, - color); -} - -void Engine::paintTrackbar(WebCanvas* canvas, int part, int state, - int classic_state, const WebRect& rect) { - Control::Type ctype = Control::kUnknown_Type; - Control::State cstate = Control::kUnknown_State; - - if (TKP_THUMBBOTTOM == part) { - ctype = Control::kHorizontalSliderThumb_Type; - switch (state) { - case TUS_NORMAL: - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kNormal_State; - break; - case TUS_HOT: - CHECK_EQ(classic_state, DFCS_HOT); - cstate = Control::kHot_State; - break; - case TUS_DISABLED: - CHECK_EQ(classic_state, DFCS_INACTIVE); - cstate = Control::kDisabled_State; - break; - case TUS_PRESSED: - CHECK_EQ(classic_state, DFCS_PUSHED); - cstate = Control::kPressed_State; - break; - default: - NOTREACHED(); - break; - } - } else if (TKP_TRACK == part) { - ctype = Control::kHorizontalSliderTrack_Type; - CHECK_EQ(part, TUS_NORMAL); - CHECK_EQ(classic_state, kDFCSNormal); - cstate = Control::kNormal_State; - } else { - NOTREACHED(); - } - - drawControl(canvas, rect, ctype, cstate); -} - - -void Engine::paintProgressBar(WebKit::WebCanvas* canvas, - const WebKit::WebRect& barRect, - const WebKit::WebRect& valueRect, - bool determinate, double) { - Control::Type ctype = Control::kProgressBar_Type; - Control::State cstate = - determinate ? Control::kNormal_State : Control::kIndeterminate_State; - drawProgressBar(canvas, ctype, cstate, barRect, valueRect); -} - -WebKit::WebSize Engine::getSize(int part) { - return WebKit::WebSize(); -} - -} // namespace TestShellWebTheme diff --git a/webkit/tools/test_shell/test_shell_webthemeengine.h b/webkit/tools/test_shell/test_shell_webthemeengine.h deleted file mode 100644 index 3d1adfe..0000000 --- a/webkit/tools/test_shell/test_shell_webthemeengine.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// TestShellWebTheme::Engine implements the WebThemeEngine -// API used by the Windows version of Chromium to render native form -// controls like checkboxes, radio buttons, and scroll bars. The normal -// implementation (native_theme) renders the controls using either the -// UXTheme theming engine present in XP, Vista, and Win 7, or the "classic" -// theme used if that theme is selected in the Desktop settings. -// Unfortunately, both of these themes render controls differently on the -// different versions of Windows. -// -// In order to ensure maximum consistency of baselines across the different -// Windows versions, we provide a simple implementation for test_shell here -// instead. These controls are actually platform-independent (they're rendered -// using Skia) and could be used on Linux and the Mac as well, should we -// choose to do so at some point. -// - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMEENGINE_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMEENGINE_H_ - -#include "base/basictypes.h" -#include "third_party/WebKit/Source/Platform/chromium/public/win/WebThemeEngine.h" - -namespace TestShellWebTheme { - -class Engine : public WebKit::WebThemeEngine { - public: - Engine() {} - - // WebThemeEngine methods: - virtual void paintButton( - WebKit::WebCanvas*, int part, int state, int classic_state, - const WebKit::WebRect&); - virtual void paintMenuList( - WebKit::WebCanvas*, int part, int state, int classic_state, - const WebKit::WebRect&); - virtual void paintScrollbarArrow( - WebKit::WebCanvas*, int state, int classic_state, - const WebKit::WebRect&); - virtual void paintScrollbarThumb( - WebKit::WebCanvas*, int part, int state, int classic_state, - const WebKit::WebRect&); - virtual void paintScrollbarTrack( - WebKit::WebCanvas*, int part, int state, int classic_state, - const WebKit::WebRect&, const WebKit::WebRect& align_rect); - virtual void paintTextField( - WebKit::WebCanvas*, int part, int state, int classic_state, - const WebKit::WebRect&, WebKit::WebColor, bool fill_content_area, - bool draw_edges); - virtual void paintTrackbar( - WebKit::WebCanvas*, int part, int state, int classic_state, - const WebKit::WebRect&); - virtual void paintProgressBar( - WebKit::WebCanvas*, const WebKit::WebRect& barRect, - const WebKit::WebRect& valueRect, - bool determinate, double time); - virtual WebKit::WebSize getSize(int part); - - private: - DISALLOW_COPY_AND_ASSIGN(Engine); -}; - -} // namespace TestShellWebTheme - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMEENGINE_H_ - diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc deleted file mode 100644 index d2cdb10..0000000 --- a/webkit/tools/test_shell/test_shell_win.cc +++ /dev/null @@ -1,676 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_shell.h" - -#include <windows.h> -#include <commdlg.h> -#include <objbase.h> -#include <process.h> -#include <shlwapi.h> - -#include "base/command_line.h" -#include "base/containers/stack_container.h" -#include "base/debug/trace_event.h" -#include "base/file_util.h" -#include "base/message_loop.h" -#include "base/path_service.h" -#include "base/string_util.h" -#include "base/strings/string_piece.h" -#include "base/utf_string_conversions.h" -#include "base/win/resource_util.h" -#include "breakpad/src/client/windows/handler/exception_handler.h" -#include "grit/webkit_chromium_resources.h" -#include "grit/webkit_resources.h" -#include "net/base/net_module.h" -#include "net/url_request/url_request_file_job.h" -#include "skia/ext/bitmap_platform_device.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/base/win/hwnd_util.h" -#include "ui/base/win/scoped_ole_initializer.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/tools/test_shell/resource.h" -#include "webkit/tools/test_shell/test_navigation_controller.h" -#include "webkit/tools/test_shell/test_shell_devtools_agent.h" -#include "webkit/tools/test_shell/test_shell_switches.h" -#include "webkit/tools/test_shell/test_shell_webkit_init.h" -#include "webkit/tools/test_shell/test_webview_delegate.h" - -using WebKit::WebWidget; - -#define MAX_LOADSTRING 100 - -#define BUTTON_WIDTH 72 -#define URLBAR_HEIGHT 24 - -// Global Variables: -static wchar_t g_windowTitle[MAX_LOADSTRING]; // The title bar text -static wchar_t g_windowClass[MAX_LOADSTRING]; // The main window class name - -// This is only set for layout tests. It is used to determine the name of a -// minidump file. -static const size_t kPathBufSize = 2048; -static wchar_t g_currentTestName[kPathBufSize]; - -// Forward declarations of functions included in this code module: -static INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); - -// Hide the window offscreen when in layout test mode. -// This would correspond with a minimized window position if x = y = -32000. -// However we shift the x to 0 to pass test cross-frame-access-put.html -// which expects screenX/screenLeft to be 0 (http://b/issue?id=1227945). -// TODO(ericroman): x should be defined as 0 rather than -4. There is -// probably a frameborder not being accounted for in the setting/getting. -const int kTestWindowXLocation = -4; -const int kTestWindowYLocation = -32000; - -namespace { - -// This method is used to keep track of the current test name so when we write -// a minidump file, we have the test name in the minidump filename. -void SetCurrentTestName(const char* path) { - const char* lastSlash = strrchr(path, '/'); - if (lastSlash) { - ++lastSlash; - } else { - lastSlash = path; - } - - base::wcslcpy(g_currentTestName, - UTF8ToWide(lastSlash).c_str(), - arraysize(g_currentTestName)); -} - -bool MinidumpCallback(const wchar_t *dumpPath, - const wchar_t *minidumpID, - void *context, - EXCEPTION_POINTERS *exinfo, - MDRawAssertionInfo *assertion, - bool succeeded) { - // Warning: Don't use the heap in this function. It may be corrupted. - if (!g_currentTestName[0]) - return false; - - // Try to rename the minidump file to include the crashed test's name. - // StackString uses the stack but overflows onto the heap. But we don't - // care too much about being completely correct here, since most crashes - // will be happening on developers' machines where they have debuggers. - base::StackString16<kPathBufSize * 2> origPath; - origPath->append(dumpPath); - origPath->push_back(base::FilePath::kSeparators[0]); - origPath->append(minidumpID); - origPath->append(L".dmp"); - - base::StackString16<kPathBufSize * 2> newPath; - newPath->append(dumpPath); - newPath->push_back(base::FilePath::kSeparators[0]); - newPath->append(g_currentTestName); - newPath->append(L"-"); - newPath->append(minidumpID); - newPath->append(L".dmp"); - - // May use the heap, but oh well. If this fails, we'll just have the - // original dump file lying around. - _wrename(origPath->c_str(), newPath->c_str()); - - return false; -} - -// Helper method for getting the path to the test shell resources directory. -base::FilePath GetResourcesFilePath() { - base::FilePath path; - PathService::Get(base::DIR_SOURCE_ROOT, &path); - path = path.AppendASCII("webkit"); - path = path.AppendASCII("tools"); - path = path.AppendASCII("test_shell"); - return path.AppendASCII("resources"); -} - -static base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { - void* data_ptr; - size_t data_size; - return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr, - &data_size) - ? base::StringPiece(static_cast<char*>(data_ptr), data_size) - : base::StringPiece(); -} - -} // namespace - -// static -HINSTANCE TestShell::instance_handle_; -ui::ScopedOleInitializer* TestShell::ole_initializer_; - -///////////////////////////////////////////////////////////////////////////// -// static methods on TestShell - -const MINIDUMP_TYPE kFullDumpType = static_cast<MINIDUMP_TYPE>( - MiniDumpWithFullMemory | // Full memory from process. - MiniDumpWithProcessThreadData | // Get PEB and TEB. - MiniDumpWithHandleData); // Get all handle information. - -void TestShell::InitializeTestShell(bool layout_test_mode, - bool allow_external_pages) { - ole_initializer_ = new ui::ScopedOleInitializer(); - - window_list_ = new WindowList; - instance_handle_ = ::GetModuleHandle(NULL); - layout_test_mode_ = layout_test_mode; - allow_external_pages_ = allow_external_pages; - - web_prefs_ = new WebPreferences; - - ResetWebPreferences(); - - // Register the Ahem font used by layout tests. - DWORD num_fonts = 1; - void* font_ptr; - size_t font_size; - if (base::win::GetDataResourceFromModule(::GetModuleHandle(NULL), - IDR_AHEM_FONT, &font_ptr, &font_size)) { - HANDLE rc = AddFontMemResourceEx(font_ptr, font_size, 0, &num_fonts); - DCHECK(rc != 0); - } - - const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); - if (parsed_command_line.HasSwitch(test_shell::kCrashDumps)) { - base::string16 dir( - parsed_command_line.GetSwitchValueNative(test_shell::kCrashDumps)); - if (parsed_command_line.HasSwitch(test_shell::kCrashDumpsFulldump)) { - new google_breakpad::ExceptionHandler( - dir, // dump_path - NULL, // filter - &MinidumpCallback, // callback - NULL, // callback_context - google_breakpad::ExceptionHandler::HANDLER_ALL, // handler_types - kFullDumpType, // dump_type - static_cast<const wchar_t*>(NULL), // pipe_name - NULL); // custom_info - } else { - new google_breakpad::ExceptionHandler( - dir, // dump_path - NULL, // filter - &MinidumpCallback, // callback - NULL, // callback_context - google_breakpad::ExceptionHandler::HANDLER_ALL); // handler_tpes - } - } -} - -void TestShell::DestroyWindow(gfx::NativeWindow windowHandle) { - // Do we want to tear down some of the machinery behind the scenes too? - RemoveWindowFromList(windowHandle); - ::DestroyWindow(windowHandle); -} - -void TestShell::PlatformShutdown() { - delete ole_initializer_; - ole_initializer_ = NULL; -} - -ATOM TestShell::RegisterWindowClass() { - LoadString(instance_handle_, IDS_APP_TITLE, g_windowTitle, MAX_LOADSTRING); - LoadString(instance_handle_, IDC_TESTSHELL, g_windowClass, MAX_LOADSTRING); - - WNDCLASSEX wcex = { - sizeof(WNDCLASSEX), - CS_HREDRAW | CS_VREDRAW, - TestShell::WndProc, - 0, - 0, - instance_handle_, - LoadIcon(instance_handle_, MAKEINTRESOURCE(IDI_TESTSHELL)), - LoadCursor(NULL, IDC_ARROW), - 0, - MAKEINTRESOURCE(IDC_TESTSHELL), - g_windowClass, - LoadIcon(instance_handle_, MAKEINTRESOURCE(IDI_SMALL)), - }; - return RegisterClassEx(&wcex); -} - -void TestShell::DumpAllBackForwardLists(base::string16* result) { - result->clear(); - for (WindowList::iterator iter = TestShell::windowList()->begin(); - iter != TestShell::windowList()->end(); iter++) { - HWND hwnd = *iter; - TestShell* shell = - static_cast<TestShell*>(ui::GetWindowUserData(hwnd)); - shell->DumpBackForwardList(result); - } -} - -std::string TestShell::RewriteLocalUrl(const std::string& url) { - // Convert file:///tmp/LayoutTests urls to the actual location on disk. - const char kPrefix[] = "file:///tmp/LayoutTests/"; - const int kPrefixLen = arraysize(kPrefix) - 1; - - std::string new_url(url); - if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { - base::FilePath replace_url; - PathService::Get(base::DIR_EXE, &replace_url); - replace_url = replace_url.DirName(); - replace_url = replace_url.DirName(); - replace_url = replace_url.AppendASCII("third_party"); - replace_url = replace_url.AppendASCII("WebKit"); - replace_url = replace_url.AppendASCII("LayoutTests"); - base::string16 replace_url_str = replace_url.value(); - replace_url_str.push_back(L'/'); - new_url = std::string("file:///") + - UTF16ToUTF8(replace_url_str).append(url.substr(kPrefixLen)); - } - return new_url; -} - - - -///////////////////////////////////////////////////////////////////////////// -// TestShell implementation - -void TestShell::PlatformCleanUp() { - // When the window is destroyed, tell the Edit field to forget about us, - // otherwise we will crash. - ui::SetWindowProc(m_editWnd, default_edit_wnd_proc_); - ui::SetWindowUserData(m_editWnd, NULL); -} - -void TestShell::EnableUIControl(UIControl control, bool is_enabled) { - int id; - switch (control) { - case BACK_BUTTON: - id = IDC_NAV_BACK; - break; - case FORWARD_BUTTON: - id = IDC_NAV_FORWARD; - break; - case STOP_BUTTON: - id = IDC_NAV_STOP; - break; - default: - NOTREACHED() << "Unknown UI control"; - return; - } - EnableWindow(GetDlgItem(m_mainWnd, id), is_enabled); -} - -bool TestShell::Initialize(const GURL& starting_url) { - // Perform application initialization: - m_mainWnd = CreateWindow(g_windowClass, g_windowTitle, - WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, - NULL, NULL, instance_handle_, NULL); - ui::SetWindowUserData(m_mainWnd, this); - - HWND hwnd; - int x = 0; - - hwnd = CreateWindow(L"BUTTON", L"Back", - WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , - x, 0, BUTTON_WIDTH, URLBAR_HEIGHT, - m_mainWnd, (HMENU) IDC_NAV_BACK, instance_handle_, 0); - x += BUTTON_WIDTH; - - hwnd = CreateWindow(L"BUTTON", L"Forward", - WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , - x, 0, BUTTON_WIDTH, URLBAR_HEIGHT, - m_mainWnd, (HMENU) IDC_NAV_FORWARD, instance_handle_, 0); - x += BUTTON_WIDTH; - - hwnd = CreateWindow(L"BUTTON", L"Reload", - WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , - x, 0, BUTTON_WIDTH, URLBAR_HEIGHT, - m_mainWnd, (HMENU) IDC_NAV_RELOAD, instance_handle_, 0); - x += BUTTON_WIDTH; - - hwnd = CreateWindow(L"BUTTON", L"Stop", - WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , - x, 0, BUTTON_WIDTH, URLBAR_HEIGHT, - m_mainWnd, (HMENU) IDC_NAV_STOP, instance_handle_, 0); - x += BUTTON_WIDTH; - - // this control is positioned by ResizeSubViews - m_editWnd = CreateWindow(L"EDIT", 0, - WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | - ES_AUTOVSCROLL | ES_AUTOHSCROLL, - x, 0, 0, 0, m_mainWnd, 0, instance_handle_, 0); - - default_edit_wnd_proc_ = ui::SetWindowProc(m_editWnd, TestShell::EditWndProc); - ui::SetWindowUserData(m_editWnd, this); - - dev_tools_agent_.reset(new TestShellDevToolsAgent()); - - // create webview - m_webViewHost.reset( - WebViewHost::Create(m_mainWnd, - delegate_.get(), - dev_tools_agent_.get(), - *TestShell::web_prefs_)); - dev_tools_agent_->SetWebView(m_webViewHost->webview()); - delegate_->RegisterDragDrop(); - - // Load our initial content. - if (starting_url.is_valid()) - LoadURL(starting_url); - - ShowWindow(webViewWnd(), SW_SHOW); - - if (IsSVGTestURL(starting_url)) { - SizeToSVG(); - } else { - SizeToDefault(); - } - - return true; -} - -void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) { - if (!enable && ::GetFocus() == host->view_handle()) - ::SetFocus(NULL); -} - -WebWidget* TestShell::CreatePopupWidget() { - DCHECK(!m_popupHost); - m_popupHost = WebWidgetHost::Create(NULL, popup_delegate_.get()); - ShowWindow(popupWnd(), SW_SHOW); - - return m_popupHost->webwidget(); -} - -void TestShell::ClosePopup() { - PostMessage(popupWnd(), WM_CLOSE, 0, 0); - m_popupHost = NULL; -} - -void TestShell::SizeTo(int width, int height) { - RECT rc, rw; - GetClientRect(m_mainWnd, &rc); - GetWindowRect(m_mainWnd, &rw); - - int client_width = rc.right - rc.left; - int window_width = rw.right - rw.left; - window_width = (window_width - client_width) + width; - - int client_height = rc.bottom - rc.top; - int window_height = rw.bottom - rw.top; - window_height = (window_height - client_height) + height; - - // add space for the url bar: - window_height += URLBAR_HEIGHT; - - SetWindowPos(m_mainWnd, NULL, 0, 0, window_width, window_height, - SWP_NOMOVE | SWP_NOZORDER); -} - -void TestShell::ResizeSubViews() { - RECT rc; - GetClientRect(m_mainWnd, &rc); - - int x = BUTTON_WIDTH * 4; - MoveWindow(m_editWnd, x, 0, rc.right - x, URLBAR_HEIGHT, TRUE); - - MoveWindow(webViewWnd(), 0, URLBAR_HEIGHT, rc.right, - rc.bottom - URLBAR_HEIGHT, TRUE); -} - -void TestShell::LoadURLForFrame(const GURL& url, - const base::string16& frame_name) { - if (!url.is_valid()) - return; - - TRACE_EVENT_BEGIN_ETW("url.load", this, url.spec()); - - if (IsSVGTestURL(url)) { - SizeToSVG(); - } else { - // only resize back to the default when running tests - if (layout_test_mode()) - SizeToDefault(); - } - - navigation_controller_->LoadEntry( - new TestNavigationEntry(-1, url, frame_name)); -} - -LRESULT CALLBACK TestShell::WndProc(HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam) { - TestShell* shell = static_cast<TestShell*>(ui::GetWindowUserData(hwnd)); - - switch (message) { - case WM_COMMAND: - { - int wmId = LOWORD(wParam); - int wmEvent = HIWORD(wParam); - - switch (wmId) { - case IDM_ABOUT: - DialogBox(shell->instance_handle_, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, - About); - break; - case IDM_EXIT: - DestroyWindow(hwnd); - break; - case IDC_NAV_BACK: - shell->GoBackOrForward(-1); - break; - case IDC_NAV_FORWARD: - shell->GoBackOrForward(1); - break; - case IDC_NAV_RELOAD: - case IDC_NAV_STOP: - { - if (wmId == IDC_NAV_RELOAD) { - shell->Reload(); - } else { - shell->webView()->mainFrame()->stopLoading(); - } - } - break; - case IDM_DUMP_BODY_TEXT: - shell->DumpDocumentText(); - break; - case IDM_DUMP_RENDER_TREE: - shell->DumpRenderTree(); - break; - case IDM_ENABLE_IMAGES: - case IDM_ENABLE_PLUGINS: - case IDM_ENABLE_SCRIPTS: { - HMENU menu = GetSubMenu(GetMenu(hwnd), 1); - bool was_checked = - (GetMenuState(menu, wmId, MF_BYCOMMAND) & MF_CHECKED) != 0; - CheckMenuItem(menu, wmId, - MF_BYCOMMAND | (was_checked ? MF_UNCHECKED : MF_CHECKED)); - switch (wmId) { - case IDM_ENABLE_IMAGES: - shell->set_allow_images(!was_checked); - break; - case IDM_ENABLE_PLUGINS: - shell->set_allow_plugins(!was_checked); - break; - case IDM_ENABLE_SCRIPTS: - shell->set_allow_scripts(!was_checked); - break; - } - break; - } - case IDM_SHOW_DEV_TOOLS: - shell->ShowDevTools(); - break; - } - } - break; - - case WM_DESTROY: - { - - RemoveWindowFromList(hwnd); - - if (TestShell::windowList()->empty() || shell->is_modal()) { - base::MessageLoop::current()->PostTask( - FROM_HERE, base::MessageLoop::QuitClosure()); - } - delete shell; - } - return 0; - - case WM_SIZE: - if (shell->webView()) - shell->ResizeSubViews(); - return 0; - } - - return DefWindowProc(hwnd, message, wParam, lParam); -} - - -#define MAX_URL_LENGTH 1024 - -LRESULT CALLBACK TestShell::EditWndProc(HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam) { - TestShell* shell = - static_cast<TestShell*>(ui::GetWindowUserData(hwnd)); - - switch (message) { - case WM_CHAR: - if (wParam == VK_RETURN) { - wchar_t str[MAX_URL_LENGTH + 1]; // Leave room for adding a NULL; - *((LPWORD)str) = MAX_URL_LENGTH; - LRESULT str_len = SendMessage(hwnd, EM_GETLINE, 0, (LPARAM)str); - if (str_len > 0) { - str[str_len] = 0; // EM_GETLINE doesn't NULL terminate. - shell->LoadURL(GURL(str)); - } - - return 0; - } - } - - return (LRESULT) CallWindowProc(shell->default_edit_wnd_proc_, hwnd, - message, wParam, lParam); -} - - -// Message handler for about box. -INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - UNREFERENCED_PARAMETER(lParam); - switch (message) { - case WM_INITDIALOG: - return (INT_PTR)TRUE; - - case WM_COMMAND: - if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { - EndDialog(hDlg, LOWORD(wParam)); - return (INT_PTR)TRUE; - } - break; - } - return (INT_PTR)FALSE; -} - -bool TestShell::PromptForSaveFile(const wchar_t* prompt_title, - base::FilePath* result) { - wchar_t path_buf[MAX_PATH] = L"data.txt"; - - OPENFILENAME info = {0}; - info.lStructSize = sizeof(info); - info.hwndOwner = m_mainWnd; - info.hInstance = instance_handle_; - info.lpstrFilter = L"*.txt\0"; - info.lpstrFile = path_buf; - info.nMaxFile = arraysize(path_buf); - info.lpstrTitle = prompt_title; - if (!GetSaveFileName(&info)) - return false; - - *result = base::FilePath(info.lpstrFile); - return true; -} - -// static -void TestShell::ShowStartupDebuggingDialog() { - MessageBox(NULL, L"attach to me?", L"test_shell", MB_OK); -} - -// static -base::StringPiece TestShell::ResourceProvider(int key) { - return GetRawDataResource(::GetModuleHandle(NULL), key); -} - - -base::string16 TestShellWebKitInit::GetLocalizedString(int message_id) { - wchar_t localized[MAX_LOADSTRING]; - int length = LoadString(GetModuleHandle(NULL), message_id, - localized, MAX_LOADSTRING); - if (!length && GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND) { - NOTREACHED(); - return L"No string for this identifier!"; - } - return base::string16(localized, length); -} - -// TODO(tc): Convert this to using resources from test_shell.rc. -base::StringPiece TestShellWebKitInit::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) { - switch (resource_id) { - case IDR_BROKENIMAGE: { - // Use webkit's broken image icon (16x16) - static std::string broken_image_data; - if (broken_image_data.empty()) { - base::FilePath path = GetResourcesFilePath(); - path = path.AppendASCII("missingImage.gif"); - bool success = file_util::ReadFileToString(path, &broken_image_data); - if (!success) { - LOG(FATAL) << "Failed reading: " << path.value(); - } - } - return broken_image_data; - } - case IDR_TEXTAREA_RESIZER: { - // Use webkit's text area resizer image. - static std::string resize_corner_data; - if (resize_corner_data.empty()) { - base::FilePath path = GetResourcesFilePath(); - path = path.AppendASCII("textAreaResizeCorner.png"); - bool success = file_util::ReadFileToString(path, &resize_corner_data); - if (!success) { - LOG(FATAL) << "Failed reading: " << path.value(); - } - } - return resize_corner_data; - } - - case IDR_SEARCH_CANCEL: - case IDR_SEARCH_CANCEL_PRESSED: - case IDR_SEARCH_MAGNIFIER: - case IDR_SEARCH_MAGNIFIER_RESULTS: - case IDR_INPUT_SPEECH: - case IDR_INPUT_SPEECH_RECORDING: - case IDR_INPUT_SPEECH_WAITING: - //TODO(flackr): Pass scale_factor. - return TestShell::ResourceProvider(resource_id); - - default: - break; - } - - return base::StringPiece(); -} - -///////////////////////////////////////////////////////////////////////////// -// WebKit glue functions - -namespace webkit_glue { - -bool EnsureFontLoaded(HFONT font) { - return true; -} - -bool DownloadUrl(const std::string& url, HWND caller_window) { - return false; -} - -} // namespace webkit_glue diff --git a/webkit/tools/test_shell/test_shell_x11.cc b/webkit/tools/test_shell/test_shell_x11.cc deleted file mode 100644 index 73f4ca3..0000000 --- a/webkit/tools/test_shell/test_shell_x11.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <gtk/gtk.h> -#include <gdk/gdkx.h> - -#include "webkit/tools/test_shell/test_shell_x11.h" - -namespace test_shell_x11 { - -Display* GtkWidgetGetDisplay(GtkWidget* widget) { - GdkDisplay* gdk_display = gtk_widget_get_display(widget); - return gdk_x11_display_get_xdisplay(gdk_display); -} - -int GtkWidgetGetScreenNum(GtkWidget* widget) { - GdkDisplay* gdk_display = gtk_widget_get_display(widget); - GdkScreen* gdk_screen = gdk_display_get_default_screen(gdk_display); - return gdk_x11_screen_get_screen_number(gdk_screen); -} - -} // namespace test_shell_x11 diff --git a/webkit/tools/test_shell/test_shell_x11.h b/webkit/tools/test_shell/test_shell_x11.h deleted file mode 100644 index d3e41dd..0000000 --- a/webkit/tools/test_shell/test_shell_x11.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_X11_H -#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_X11_H - -// This header is required because one cannot include both Xlib headers and -// WebKit headers in the same source file. - -typedef struct _XDisplay Display; - -namespace test_shell_x11 { - -// Return an Xlib Display pointer for the given widget -Display* GtkWidgetGetDisplay(GtkWidget* widget); -// Return the screen number for the given widget -int GtkWidgetGetScreenNum(GtkWidget* widget); - -} // namespace test_shell_x11 - -#endif // !WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_X11_H diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc deleted file mode 100644 index afba3a7..0000000 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ /dev/null @@ -1,989 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file contains the implementation of TestWebViewDelegate, which serves -// as the WebViewDelegate for the TestShellWebHost. The host is expected to -// have initialized a MessageLoop before these methods are called. - -#include "webkit/tools/test_shell/test_webview_delegate.h" - -#include "base/debug/trace_event.h" -#include "base/file_util.h" -#include "base/message_loop.h" -#include "base/process_util.h" -#include "base/string_util.h" -#include "base/stringprintf.h" -#include "base/strings/string_number_conversions.h" -#include "base/utf_string_conversions.h" -#include "media/base/filter_collection.h" -#include "media/base/media_log.h" -#include "net/base/net_errors.h" -#include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebDragData.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebStorageNamespace.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientationClientMock.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationClientMock.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresenter.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" -#include "ui/base/window_open_disposition.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/point.h" -#include "webkit/appcache/web_application_cache_host_impl.h" -#include "webkit/glue/glue_serialize.h" -#include "webkit/glue/webdropdata.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/glue/weburlrequest_extradata_impl.h" -#include "webkit/media/webmediaplayer_impl.h" -#include "webkit/media/webmediaplayer_params.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/plugins/npapi/webplugin_delegate_impl.h" -#include "webkit/plugins/npapi/webplugin_impl.h" -#include "webkit/tools/test_shell/mock_spellcheck.h" -#include "webkit/tools/test_shell/notification_presenter.h" -#include "webkit/tools/test_shell/simple_appcache_system.h" -#include "webkit/tools/test_shell/simple_dom_storage_system.h" -#include "webkit/tools/test_shell/simple_file_system.h" -#include "webkit/tools/test_shell/test_navigation_controller.h" -#include "webkit/tools/test_shell/test_shell.h" - -#if defined(OS_WIN) -// TODO(port): make these files work everywhere. -#include "webkit/tools/test_shell/drop_delegate.h" -#endif - -#if defined(OS_MACOSX) -#include "webkit/plugins/plugin_constants.h" -#endif - -using appcache::WebApplicationCacheHostImpl; -using WebKit::WebAccessibilityObject; -using WebKit::WebApplicationCacheHost; -using WebKit::WebApplicationCacheHostClient; -using WebKit::WebConsoleMessage; -using WebKit::WebContextMenuData; -using WebKit::WebCookieJar; -using WebKit::WebData; -using WebKit::WebDataSource; -using WebKit::WebDragData; -using WebKit::WebDragOperationsMask; -using WebKit::WebEditingAction; -using WebKit::WebFileSystem; -using WebKit::WebFileSystemCallbacks; -using WebKit::WebFormElement; -using WebKit::WebFrame; -using WebKit::WebGraphicsContext3D; -using WebKit::WebHistoryItem; -using WebKit::WebImage; -using WebKit::WebMediaPlayer; -using WebKit::WebMediaPlayerClient; -using WebKit::WebNavigationType; -using WebKit::WebNavigationPolicy; -using WebKit::WebNode; -using WebKit::WebNotificationPresenter; -using WebKit::WebPlugin; -using WebKit::WebPluginParams; -using WebKit::WebPoint; -using WebKit::WebPopupMenu; -using WebKit::WebPopupType; -using WebKit::WebRange; -using WebKit::WebRect; -using WebKit::WebScreenInfo; -using WebKit::WebSecurityOrigin; -using WebKit::WebSize; -using WebKit::WebStorageNamespace; -using WebKit::WebString; -using WebKit::WebTextAffinity; -using WebKit::WebTextDirection; -using WebKit::WebURL; -using WebKit::WebURLError; -using WebKit::WebURLRequest; -using WebKit::WebURLResponse; -using WebKit::WebWidget; -using WebKit::WebWindowFeatures; -using WebKit::WebWorker; -using WebKit::WebVector; -using WebKit::WebView; - -namespace { - -// WebNavigationType debugging strings taken from PolicyDelegate.mm. -const char* kLinkClickedString = "link clicked"; -const char* kFormSubmittedString = "form submitted"; -const char* kBackForwardString = "back/forward"; -const char* kReloadString = "reload"; -const char* kFormResubmittedString = "form resubmitted"; -const char* kOtherString = "other"; -const char* kIllegalString = "illegal value"; - -int next_page_id_ = 1; - -// Used to write a platform neutral file:/// URL by taking the -// filename and its directory. (e.g., converts -// "file:///tmp/foo/bar.txt" to just "bar.txt"). -// Get a debugging string from a WebNavigationType. -const char* WebNavigationTypeToString(WebNavigationType type) { - switch (type) { - case WebKit::WebNavigationTypeLinkClicked: - return kLinkClickedString; - case WebKit::WebNavigationTypeFormSubmitted: - return kFormSubmittedString; - case WebKit::WebNavigationTypeBackForward: - return kBackForwardString; - case WebKit::WebNavigationTypeReload: - return kReloadString; - case WebKit::WebNavigationTypeFormResubmitted: - return kFormResubmittedString; - case WebKit::WebNavigationTypeOther: - return kOtherString; - } - return kIllegalString; -} - -std::string GetURLDescription(const GURL& url) { - if (url.SchemeIs("file")) - return url.ExtractFileName(); - - return url.possibly_invalid_spec(); -} - -std::string GetNodeDescription(const WebNode& node, int exception) { - if (exception) - return "ERROR"; - if (node.isNull()) - return "(null)"; - std::string str = node.nodeName().utf8(); - const WebNode& parent = node.parentNode(); - if (!parent.isNull()) { - str.append(" > "); - str.append(GetNodeDescription(parent, 0)); - } - return str; -} - -} // namespace - -// WebViewDelegate ----------------------------------------------------------- - -std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { - ResourceMap::iterator it = resource_identifier_map_.find(identifier); - return it != resource_identifier_map_.end() ? it->second : "<unknown>"; -} - -void TestWebViewDelegate::SetUserStyleSheetEnabled(bool is_enabled) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->user_style_sheet_enabled = is_enabled; - webkit_glue::ApplyWebPreferences(*prefs, shell_->webView()); -} - -void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->user_style_sheet_enabled = true; - prefs->user_style_sheet_location = location; - webkit_glue::ApplyWebPreferences(*prefs, shell_->webView()); -} - -void TestWebViewDelegate::SetAuthorAndUserStylesEnabled(bool is_enabled) { - WebPreferences* prefs = shell_->GetWebPreferences(); - prefs->author_and_user_styles_enabled = is_enabled; - webkit_glue::ApplyWebPreferences(*prefs, shell_->webView()); -} - -// WebViewClient ------------------------------------------------------------- -WebView* TestWebViewDelegate::createView( - WebFrame* creator, - const WebURLRequest& request, - const WebWindowFeatures& window_features, - const WebString& frame_name, - WebNavigationPolicy policy) { - return shell_->CreateWebView(); -} - -WebWidget* TestWebViewDelegate::createPopupMenu(WebPopupType popup_type) { - // TODO(darin): Should we take into account |popup_type| (for activation - // purpose)? - return shell_->CreatePopupWidget(); -} - -WebStorageNamespace* TestWebViewDelegate::createSessionStorageNamespace( - unsigned quota) { - return SimpleDomStorageSystem::instance().CreateSessionStorageNamespace(); -} - -void TestWebViewDelegate::didAddMessageToConsole( - const WebConsoleMessage& message, const WebString& source_name, - unsigned source_line) { - logging::LogMessage("CONSOLE", 0).stream() << "\"" - << message.text.utf8().data() - << ",\" source: " - << source_name.utf8().data() - << "(" - << source_line - << ")"; -} - -void TestWebViewDelegate::didStartLoading() { - shell_->set_is_loading(true); - shell_->UpdateNavigationControls(); -} - -void TestWebViewDelegate::didStopLoading() { - shell_->set_is_loading(false); - shell_->UpdateNavigationControls(); -} - -// The output from these methods in layout test mode should match that -// expected by the layout tests. See EditingDelegate.m in DumpRenderTree. - -bool TestWebViewDelegate::shouldBeginEditing(const WebRange& range) { - return shell_->AcceptsEditing(); -} - -bool TestWebViewDelegate::shouldEndEditing(const WebRange& range) { - return shell_->AcceptsEditing(); -} - -bool TestWebViewDelegate::shouldInsertNode(const WebNode& node, - const WebRange& range, - WebEditingAction action) { - return shell_->AcceptsEditing(); -} - -bool TestWebViewDelegate::shouldInsertText(const WebString& text, - const WebRange& range, - WebEditingAction action) { - return shell_->AcceptsEditing(); -} - -bool TestWebViewDelegate::shouldChangeSelectedRange(const WebRange& from_range, - const WebRange& to_range, - WebTextAffinity affinity, - bool still_selecting) { - return shell_->AcceptsEditing(); -} - -bool TestWebViewDelegate::shouldDeleteRange(const WebRange& range) { - return shell_->AcceptsEditing(); -} - -bool TestWebViewDelegate::shouldApplyStyle(const WebString& style, - const WebRange& range) { - return shell_->AcceptsEditing(); -} - -void TestWebViewDelegate::didBeginEditing() { -} - -void TestWebViewDelegate::didChangeSelection(bool is_empty_selection) { - UpdateSelectionClipboard(is_empty_selection); -} - -void TestWebViewDelegate::didChangeContents() { -} - -void TestWebViewDelegate::didEndEditing() { -} - -bool TestWebViewDelegate::handleCurrentKeyboardEvent() { - if (edit_command_name_.empty()) - return false; - - WebFrame* frame = shell_->webView()->focusedFrame(); - if (!frame) - return false; - - return frame->executeCommand(WebString::fromUTF8(edit_command_name_), - WebString::fromUTF8(edit_command_value_)); -} - -void TestWebViewDelegate::spellCheck(const WebString& text, - int& misspelledOffset, - int& misspelledLength) { -#if defined(OS_MACOSX) - // Check the spelling of the given text. - // TODO(hbono): rebaseline layout-test results of Windows and Linux so we - // can enable this mock spellchecker on them. - base::string16 word(text); - mock_spellcheck_.SpellCheckWord(word, &misspelledOffset, &misspelledLength); -#endif -} - -WebString TestWebViewDelegate::autoCorrectWord(const WebString& word) { - // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm') - // does. (If this function returns a non-empty string, WebKit replaces the - // given misspelled string with the result one. This process executes some - // editor commands and causes layout-test failures.) - return WebString(); -} - -void TestWebViewDelegate::runModalAlertDialog( - WebFrame* frame, const WebString& message) { - if (!shell_->layout_test_mode()) { - ShowJavaScriptAlert(message); - } else { - printf("ALERT: %s\n", message.utf8().data()); - } -} - -bool TestWebViewDelegate::runModalConfirmDialog( - WebFrame* frame, const WebString& message) { - if (shell_->layout_test_mode()) { - // When running tests, write to stdout. - printf("CONFIRM: %s\n", message.utf8().data()); - return true; - } - return false; -} - -bool TestWebViewDelegate::runModalPromptDialog( - WebFrame* frame, const WebString& message, const WebString& default_value, - WebString* actual_value) { - if (shell_->layout_test_mode()) { - // When running tests, write to stdout. - printf("PROMPT: %s, default text: %s\n", - message.utf8().data(), - default_value.utf8().data()); - return true; - } - return false; -} - -bool TestWebViewDelegate::runModalBeforeUnloadDialog( - WebFrame* frame, const WebString& message) { - return true; // Allow window closure. -} - - - - -void TestWebViewDelegate::setStatusText(const WebString& text) { -} - -void TestWebViewDelegate::startDragging( - WebFrame* frame, - const WebDragData& data, - WebDragOperationsMask mask, - const WebImage& image, - const WebPoint& image_offset) { - shell_->webView()->dragSourceSystemDragEnded(); -} - -void TestWebViewDelegate::navigateBackForwardSoon(int offset) { - shell_->navigation_controller()->GoToOffset(offset); -} - -int TestWebViewDelegate::historyBackListCount() { - int current_index = - shell_->navigation_controller()->GetLastCommittedEntryIndex(); - return current_index; -} - -int TestWebViewDelegate::historyForwardListCount() { - int current_index = - shell_->navigation_controller()->GetLastCommittedEntryIndex(); - return shell_->navigation_controller()->GetEntryCount() - current_index - 1; -} - -WebNotificationPresenter* TestWebViewDelegate::notificationPresenter() { - return shell_->notification_presenter(); -} - -WebKit::WebGeolocationClient* TestWebViewDelegate::geolocationClient() { - return shell_->geolocation_client_mock(); -} - -WebKit::WebDeviceOrientationClient* -TestWebViewDelegate::deviceOrientationClient() { - return shell_->device_orientation_client_mock(); -} - -WebKit::WebSpeechInputController* TestWebViewDelegate::speechInputController( - WebKit::WebSpeechInputListener* listener) { - return 0; -} - -// WebWidgetClient ----------------------------------------------------------- - -void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) { - if (WebWidgetHost* host = GetWidgetHost()) - host->DidInvalidateRect(rect); -} - -void TestWebViewDelegate::didScrollRect(int dx, int dy, - const WebRect& clip_rect) { - if (WebWidgetHost* host = GetWidgetHost()) - host->DidScrollRect(dx, dy, clip_rect); -} - -void TestWebViewDelegate::scheduleComposite() { - if (WebWidgetHost* host = GetWidgetHost()) - host->ScheduleComposite(); -} - -void TestWebViewDelegate::scheduleAnimation() { - if (WebWidgetHost* host = GetWidgetHost()) - host->ScheduleAnimation(); -} - -void TestWebViewDelegate::didFocus() { - if (WebWidgetHost* host = GetWidgetHost()) - shell_->SetFocus(host, true); -} - -void TestWebViewDelegate::didBlur() { - if (WebWidgetHost* host = GetWidgetHost()) - shell_->SetFocus(host, false); -} - -WebScreenInfo TestWebViewDelegate::screenInfo() { - if (WebWidgetHost* host = GetWidgetHost()) - return host->GetScreenInfo(); - - return WebScreenInfo(); -} - -// WebFrameClient ------------------------------------------------------------ - -WebPlugin* TestWebViewDelegate::createPlugin(WebFrame* frame, - const WebPluginParams& params) { - bool allow_wildcard = true; - std::vector<webkit::WebPluginInfo> plugins; - std::vector<std::string> mime_types; - webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( - params.url, params.mimeType.utf8(), allow_wildcard, - NULL, &plugins, &mime_types); - if (plugins.empty()) - return NULL; - - WebPluginParams params_copy = params; - params_copy.mimeType = WebString::fromUTF8(mime_types.front()); - -#if defined(OS_MACOSX) - if (!shell_->layout_test_mode()) { - bool flash = LowerCaseEqualsASCII(params_copy.mimeType.utf8(), - kFlashPluginSwfMimeType); - if (flash) { - // Mac does not support windowed plugins. Force Flash plugins to use - // windowless mode by setting the wmode="opaque" attribute. - DCHECK(params_copy.attributeNames.size() == - params_copy.attributeValues.size()); - size_t size = params_copy.attributeNames.size(); - - WebVector<WebString> new_names(size+1), new_values(size+1); - - for (size_t i = 0; i < size; ++i) { - new_names[i] = params_copy.attributeNames[i]; - new_values[i] = params_copy.attributeValues[i]; - } - - new_names[size] = "wmode"; - new_values[size] = "opaque"; - - params_copy.attributeNames.swap(new_names); - params_copy.attributeValues.swap(new_values); - - return new webkit::npapi::WebPluginImpl( - frame, params_copy, plugins.front().path, AsWeakPtr()); - } - } -#endif // defined (OS_MACOSX) - - return new webkit::npapi::WebPluginImpl( - frame, params, plugins.front().path, AsWeakPtr()); -} - -WebMediaPlayer* TestWebViewDelegate::createMediaPlayer( - WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { - webkit_media::WebMediaPlayerParams params( - NULL, NULL, new media::MediaLog()); - return new webkit_media::WebMediaPlayerImpl( - frame, - client, - base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), - params); -} - -WebApplicationCacheHost* TestWebViewDelegate::createApplicationCacheHost( - WebFrame* frame, WebApplicationCacheHostClient* client) { - return SimpleAppCacheSystem::CreateApplicationCacheHost(client); -} - -bool TestWebViewDelegate::allowPlugins(WebFrame* frame, - bool enabled_per_settings) { - return enabled_per_settings && shell_->allow_plugins(); -} - -bool TestWebViewDelegate::allowImage(WebFrame* frame, - bool enabled_per_settings, - const WebURL& image_url) { - return enabled_per_settings && shell_->allow_images(); -} - -void TestWebViewDelegate::loadURLExternally( - WebFrame* frame, const WebURLRequest& request, - WebNavigationPolicy policy) { - DCHECK_NE(policy, WebKit::WebNavigationPolicyCurrentTab); - TestShell* shell = NULL; - if (TestShell::CreateNewWindow(request.url(), &shell)) - shell->Show(policy); -} - -WebNavigationPolicy TestWebViewDelegate::decidePolicyForNavigation( - WebFrame* frame, WebDataSource::ExtraData* extraData, - const WebURLRequest& request, WebNavigationType type, - WebNavigationPolicy default_policy, bool is_redirect) { - WebNavigationPolicy result; - if (policy_delegate_enabled_) { - printf("Policy delegate: attempt to load %s with navigation type '%s'\n", - GetURLDescription(request.url()).c_str(), - WebNavigationTypeToString(type)); - if (policy_delegate_is_permissive_) { - result = WebKit::WebNavigationPolicyCurrentTab; - } else { - result = WebKit::WebNavigationPolicyIgnore; - } - } else { - result = default_policy; - } - return result; -} - -WebNavigationPolicy TestWebViewDelegate::decidePolicyForNavigation( - WebFrame* frame, const WebURLRequest& request, - WebNavigationType type, WebNavigationPolicy default_policy, - bool is_redirect) { - return decidePolicyForNavigation(frame, 0, request, type, - default_policy, is_redirect); -} - -bool TestWebViewDelegate::canHandleRequest( - WebFrame* frame, const WebURLRequest& request) { - GURL url = request.url(); - // Just reject the scheme used in - // LayoutTests/http/tests/misc/redirect-to-external-url.html - return !url.SchemeIs("spaceballs"); -} - -WebURLError TestWebViewDelegate::cannotHandleRequestError( - WebFrame* frame, const WebURLRequest& request) { - WebURLError error; - // A WebKit layout test expects the following values. - // unableToImplementPolicyWithError() below prints them. - error.domain = WebString::fromUTF8("WebKitErrorDomain"); - error.reason = 101; - error.unreachableURL = request.url(); - return error; -} - -WebURLError TestWebViewDelegate::cancelledError( - WebFrame* frame, const WebURLRequest& request) { - WebURLError error; - error.domain = WebString::fromUTF8(net::kErrorDomain); - error.reason = net::ERR_ABORTED; - error.unreachableURL = request.url(); - return error; -} - -void TestWebViewDelegate::unableToImplementPolicyWithError( - WebFrame* frame, const WebURLError& error) { - std::string domain = error.domain.utf8(); - printf("Policy delegate: unable to implement policy with error domain '%s', " - "error code %d, in frame '%s'\n", - domain.data(), error.reason, frame->uniqueName().utf8().data()); -} - -void TestWebViewDelegate::willPerformClientRedirect( - WebFrame* frame, const WebURL& from, const WebURL& to, - double interval, double fire_time) { -} - -void TestWebViewDelegate::didCancelClientRedirect(WebFrame* frame) { -} - -void TestWebViewDelegate::didCreateDataSource( - WebFrame* frame, WebDataSource* ds) { - ds->setExtraData(pending_extra_data_.release()); -} - -void TestWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) { - UpdateAddressBar(frame->view()); -} - -void TestWebViewDelegate::didReceiveServerRedirectForProvisionalLoad( - WebFrame* frame) { - UpdateAddressBar(frame->view()); -} - -void TestWebViewDelegate::didFailProvisionalLoad( - WebFrame* frame, const WebURLError& error) { - // Don't display an error page if we're running layout tests, because - // DumpRenderTree doesn't. - if (shell_->layout_test_mode()) - return; - - // Don't display an error page if this is simply a cancelled load. Aside - // from being dumb, WebCore doesn't expect it and it will cause a crash. - if (error.reason == net::ERR_ABORTED) - return; - - const WebDataSource* failed_ds = frame->provisionalDataSource(); - - TestShellExtraData* extra_data = - static_cast<TestShellExtraData*>(failed_ds->extraData()); - bool replace = extra_data && extra_data->pending_page_id != -1; - - // Ensure the error page ends up with the same page ID if we are replacing. - if (replace) - set_pending_extra_data(new TestShellExtraData(extra_data->pending_page_id)); - - const std::string& error_text = - base::StringPrintf("Error %d when loading url %s", error.reason, - failed_ds->request().url().spec().data()); - - // Make sure we never show errors in view source mode. - frame->enableViewSourceMode(false); - - frame->loadHTMLString( - error_text, GURL("testshell-error:"), error.unreachableURL, replace); - - // In case the load failed before DidCreateDataSource was called. - if (replace) - set_pending_extra_data(NULL); -} - -void TestWebViewDelegate::didCommitProvisionalLoad( - WebFrame* frame, bool is_new_navigation) { - UpdateForCommittedLoad(frame, is_new_navigation); -} - -void TestWebViewDelegate::didReceiveTitle( - WebFrame* frame, const WebString& title, WebTextDirection direction) { - SetPageTitle(title); -} - -void TestWebViewDelegate::didFinishDocumentLoad(WebFrame* frame) { - unsigned pending_unload_events = frame->unloadListenerCount(); - if (pending_unload_events) { - printf("%s - has %u onunload handler(s)\n", - UTF16ToUTF8(GetFrameDescription(frame)).c_str(), pending_unload_events); - } -} - -void TestWebViewDelegate::didHandleOnloadEvents(WebFrame* frame) { -} - -void TestWebViewDelegate::didFinishLoad(WebFrame* frame) { - TRACE_EVENT_END_ETW("frame.load", this, frame->document().url().spec()); - UpdateAddressBar(frame->view()); -} - -void TestWebViewDelegate::didNavigateWithinPage( - WebFrame* frame, bool is_new_navigation) { - frame->dataSource()->setExtraData(pending_extra_data_.release()); - - UpdateForCommittedLoad(frame, is_new_navigation); -} - -void TestWebViewDelegate::didChangeLocationWithinPage(WebFrame* frame) { -} - -void TestWebViewDelegate::assignIdentifierToRequest( - WebFrame* frame, unsigned identifier, const WebURLRequest& request) { -} - -void TestWebViewDelegate::willSendRequest( - WebFrame* frame, unsigned identifier, WebURLRequest& request, - const WebURLResponse& redirect_response) { - GURL url = request.url(); - std::string request_url = url.possibly_invalid_spec(); - - request.setExtraData( - new webkit_glue::WebURLRequestExtraDataImpl( - frame->document().referrerPolicy(), WebString())); - - if (!redirect_response.isNull() && block_redirects_) { - printf("Returning null for this redirect\n"); - - // To block the request, we set its URL to an empty one. - request.setURL(WebURL()); - return; - } - - if (request_return_null_) { - // To block the request, we set its URL to an empty one. - request.setURL(WebURL()); - return; - } - - std::string host = url.host(); - if (TestShell::layout_test_mode() && !host.empty() && - (url.SchemeIs("http") || url.SchemeIs("https")) && - host != "127.0.0.1" && - host != "255.255.255.255" && // Used in some tests that expect to get - // back an error. - host != "localhost" && - !TestShell::allow_external_pages()) { - printf("Blocked access to external URL %s\n", request_url.c_str()); - - // To block the request, we set its URL to an empty one. - request.setURL(WebURL()); - return; - } - - for (std::set<std::string>::const_iterator header = clear_headers_.begin(); - header != clear_headers_.end(); ++header) - request.clearHTTPHeaderField(WebString::fromUTF8(*header)); - - TRACE_EVENT_BEGIN_ETW("url.load", identifier, request_url); - // Set the new substituted URL. - request.setURL(GURL(TestShell::RewriteLocalUrl(request_url))); -} - -void TestWebViewDelegate::didReceiveResponse( - WebFrame* frame, unsigned identifier, const WebURLResponse& response) { -} - -void TestWebViewDelegate::didFinishResourceLoad( - WebFrame* frame, unsigned identifier) { - TRACE_EVENT_END_ETW("url.load", identifier, ""); - resource_identifier_map_.erase(identifier); -} - -void TestWebViewDelegate::didFailResourceLoad( - WebFrame* frame, unsigned identifier, const WebURLError& error) { - resource_identifier_map_.erase(identifier); -} - -void TestWebViewDelegate::didDisplayInsecureContent(WebFrame* frame) { -} - -void TestWebViewDelegate::didRunInsecureContent( - WebFrame* frame, const WebSecurityOrigin& origin, const WebURL& target) { -} - -bool TestWebViewDelegate::allowScript(WebFrame* frame, - bool enabled_per_settings) { - return enabled_per_settings && shell_->allow_scripts(); -} - -void TestWebViewDelegate::openFileSystem( - WebFrame* frame, - WebKit::WebFileSystemType type, - long long size, bool create, - WebFileSystemCallbacks* callbacks) { - SimpleFileSystem* fileSystem = static_cast<SimpleFileSystem*>( - WebKit::Platform::current()->fileSystem()); - fileSystem->OpenFileSystem(frame, type, size, create, callbacks); -} - -// WebPluginPageDelegate ----------------------------------------------------- - -WebKit::WebPlugin* TestWebViewDelegate::CreatePluginReplacement( - const base::FilePath& file_path) { - return NULL; -} - -WebCookieJar* TestWebViewDelegate::GetCookieJar() { - return WebKit::Platform::current()->cookieJar(); -} - -// Public methods ------------------------------------------------------------ - -TestWebViewDelegate::TestWebViewDelegate(TestShell* shell) - : policy_delegate_enabled_(false), - policy_delegate_is_permissive_(false), - policy_delegate_should_notify_done_(false), - shell_(shell), - page_id_(-1), - last_page_id_updated_(-1), - using_fake_rect_(false), -#if defined(TOOLKIT_GTK) - cursor_type_(GDK_X_CURSOR), -#endif - block_redirects_(false), - request_return_null_(false) { -} - -TestWebViewDelegate::~TestWebViewDelegate() { -} - -void TestWebViewDelegate::Reset() { - // Do a little placement new dance... - TestShell* shell = shell_; - this->~TestWebViewDelegate(); - new (this) TestWebViewDelegate(shell); -} - -void TestWebViewDelegate::RegisterDragDrop() { -#if defined(OS_WIN) - // TODO(port): add me once drag and drop works. - DCHECK(!drop_delegate_); - drop_delegate_ = new TestDropDelegate(shell_->webViewWnd(), - shell_->webView()); -#endif -} - -void TestWebViewDelegate::RevokeDragDrop() { -#if defined(OS_WIN) - ::RevokeDragDrop(shell_->webViewWnd()); -#endif -} - -void TestWebViewDelegate::SetCustomPolicyDelegate(bool is_custom, - bool is_permissive) { - policy_delegate_enabled_ = is_custom; - policy_delegate_is_permissive_ = is_permissive; -} - -void TestWebViewDelegate::WaitForPolicyDelegate() { - policy_delegate_enabled_ = true; - policy_delegate_should_notify_done_ = true; -} - -// Private methods ----------------------------------------------------------- - -void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { - WebFrame* main_frame = webView->mainFrame(); - - WebDataSource* data_source = main_frame->dataSource(); - if (!data_source) - data_source = main_frame->provisionalDataSource(); - if (!data_source) - return; - - SetAddressBarURL(data_source->request().url()); -} - -WebWidgetHost* TestWebViewDelegate::GetWidgetHost() { - if (this == shell_->delegate()) - return shell_->webViewHost(); - if (this == shell_->popup_delegate()) - return shell_->popupHost(); - return NULL; -} - -void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, - bool is_new_navigation) { - // Code duplicated from RenderView::DidCommitLoadForFrame. - TestShellExtraData* extra_data = static_cast<TestShellExtraData*>( - frame->dataSource()->extraData()); - - if (is_new_navigation) { - // New navigation. - UpdateSessionHistory(frame); - page_id_ = next_page_id_++; - } else if (extra_data && extra_data->pending_page_id != -1 && - !extra_data->request_committed) { - // This is a successful session history navigation! - UpdateSessionHistory(frame); - page_id_ = extra_data->pending_page_id; - } - - // Don't update session history multiple times. - if (extra_data) - extra_data->request_committed = true; - - UpdateURL(frame); -} - -void TestWebViewDelegate::UpdateURL(WebFrame* frame) { - WebDataSource* ds = frame->dataSource(); - DCHECK(ds); - - const WebURLRequest& request = ds->request(); - - // Type is unused. - scoped_ptr<TestNavigationEntry> entry(new TestNavigationEntry); - - // Bug 654101: the referrer will be empty on https->http transitions. It - // would be nice if we could get the real referrer from somewhere. - entry->SetPageID(page_id_); - if (ds->hasUnreachableURL()) { - entry->SetURL(ds->unreachableURL()); - } else { - entry->SetURL(request.url()); - } - - const WebHistoryItem& history_item = frame->currentHistoryItem(); - if (!history_item.isNull()) - entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); - - shell_->navigation_controller()->DidNavigateToEntry(entry.release()); - shell_->UpdateNavigationControls(); - UpdateAddressBar(frame->view()); - - last_page_id_updated_ = std::max(last_page_id_updated_, page_id_); -} - -void TestWebViewDelegate::UpdateSessionHistory(WebFrame* frame) { - // If we have a valid page ID at this point, then it corresponds to the page - // we are navigating away from. Otherwise, this is the first navigation, so - // there is no past session history to record. - if (page_id_ == -1) - return; - - TestNavigationEntry* entry = static_cast<TestNavigationEntry*>( - shell_->navigation_controller()->GetEntryWithPageID(page_id_)); - if (!entry) - return; - - const WebHistoryItem& history_item = - shell_->webView()->mainFrame()->previousHistoryItem(); - if (history_item.isNull()) - return; - - entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); -} - -base::string16 TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { - std::string name = UTF16ToUTF8(webframe->uniqueName()); - - if (webframe == shell_->webView()->mainFrame()) { - if (name.length()) - name = "main frame \"" + name + "\""; - else - name = "main frame"; - } else { - if (name.length()) - name = "frame \"" + name + "\""; - else - name = "frame (anonymous)"; - } - return UTF8ToUTF16(name); -} - -void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { - fake_rect_ = rect; - using_fake_rect_ = true; -} - -WebRect TestWebViewDelegate::fake_window_rect() { - return fake_rect_; -} diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h deleted file mode 100644 index 334e2a3..0000000 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ /dev/null @@ -1,430 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// TestWebViewDelegate class: -// This class implements the WebViewDelegate methods for the test shell. One -// instance is owned by each TestShell. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ - -#include <map> -#include <set> -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "base/string16.h" -#include "build/build_config.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystemType.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" -#include "webkit/glue/webcursor.h" -#include "webkit/plugins/npapi/webplugin_page_delegate.h" -#include "webkit/tools/test_shell/mock_spellcheck.h" -#include "webkit/tools/test_shell/test_navigation_controller.h" - -#if defined(OS_MACOSX) -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" -#endif - -#if defined(OS_WIN) -#include <windows.h> - -#include "webkit/tools/test_shell/drop_delegate.h" -#endif - -#if defined(TOOLKIT_GTK) -#include <gdk/gdk.h> -#endif - -class GURL; -class TestShell; -class WebWidgetHost; - -namespace WebKit { -class WebDeviceOrientationClient; -class WebStorageNamespace; -struct WebWindowFeatures; -} - -class TestWebViewDelegate : public WebKit::WebViewClient, - public WebKit::WebFrameClient, - public webkit::npapi::WebPluginPageDelegate, - public base::SupportsWeakPtr<TestWebViewDelegate> { - public: - struct CapturedContextMenuEvent { - CapturedContextMenuEvent(int in_node_type, - int in_x, - int in_y) - : node_type(in_node_type), - x(in_x), - y(in_y) { - } - - int node_type; - int x; - int y; - }; - - typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; - - // WebKit::WebViewClient - virtual WebKit::WebView* createView( - WebKit::WebFrame* creator, - const WebKit::WebURLRequest& request, - const WebKit::WebWindowFeatures& features, - const WebKit::WebString& frame_name, - WebKit::WebNavigationPolicy policy); - virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type); - virtual WebKit::WebWidget* createPopupMenu( - const WebKit::WebPopupMenuInfo& info); - virtual WebKit::WebStorageNamespace* createSessionStorageNamespace( - unsigned quota); - virtual void didAddMessageToConsole( - const WebKit::WebConsoleMessage& message, - const WebKit::WebString& source_name, unsigned source_line); - virtual void didStartLoading(); - virtual void didStopLoading(); - virtual bool shouldBeginEditing(const WebKit::WebRange& range); - virtual bool shouldEndEditing(const WebKit::WebRange& range); - virtual bool shouldInsertNode( - const WebKit::WebNode& node, const WebKit::WebRange& range, - WebKit::WebEditingAction action); - virtual bool shouldInsertText( - const WebKit::WebString& text, const WebKit::WebRange& range, - WebKit::WebEditingAction action); - virtual bool shouldChangeSelectedRange( - const WebKit::WebRange& from, const WebKit::WebRange& to, - WebKit::WebTextAffinity affinity, bool still_selecting); - virtual bool shouldDeleteRange(const WebKit::WebRange& range); - virtual bool shouldApplyStyle( - const WebKit::WebString& style, const WebKit::WebRange& range); - virtual void didBeginEditing(); - virtual void didChangeSelection(bool is_selection_empty); - virtual void didChangeContents(); - virtual void didEndEditing(); - virtual bool handleCurrentKeyboardEvent(); - virtual void spellCheck( - const WebKit::WebString& text, int& misspelledOffset, - int& misspelledLength); - virtual WebKit::WebString autoCorrectWord( - const WebKit::WebString& misspelled_word); - virtual void runModalAlertDialog( - WebKit::WebFrame* frame, const WebKit::WebString& message); - virtual bool runModalConfirmDialog( - WebKit::WebFrame* frame, const WebKit::WebString& message); - virtual bool runModalPromptDialog( - WebKit::WebFrame* frame, const WebKit::WebString& message, - const WebKit::WebString& default_value, WebKit::WebString* actual_value); - virtual bool runModalBeforeUnloadDialog( - WebKit::WebFrame* frame, const WebKit::WebString& message); - virtual void setStatusText(const WebKit::WebString& text); - virtual void startDragging( - WebKit::WebFrame* frame, const WebKit::WebDragData& data, - WebKit::WebDragOperationsMask mask, const WebKit::WebImage& image, - const WebKit::WebPoint& offset); - virtual void navigateBackForwardSoon(int offset); - virtual int historyBackListCount(); - virtual int historyForwardListCount(); - virtual WebKit::WebNotificationPresenter* notificationPresenter(); - virtual WebKit::WebGeolocationClient* geolocationClient(); - virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient(); - virtual WebKit::WebSpeechInputController* speechInputController( - WebKit::WebSpeechInputListener*); - - // WebKit::WebWidgetClient - virtual void didInvalidateRect(const WebKit::WebRect& rect); - virtual void didScrollRect(int dx, int dy, - const WebKit::WebRect& clip_rect); - virtual void scheduleComposite(); - virtual void scheduleAnimation(); - virtual void didFocus(); - virtual void didBlur(); - virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor); - virtual void closeWidgetSoon(); - virtual void show(WebKit::WebNavigationPolicy policy); - virtual void runModal(); - virtual WebKit::WebRect windowRect(); - virtual void setWindowRect(const WebKit::WebRect& rect); - virtual WebKit::WebRect rootWindowRect(); - virtual WebKit::WebRect windowResizerRect(); - virtual WebKit::WebScreenInfo screenInfo(); - - // WebKit::WebFrameClient - virtual WebKit::WebPlugin* createPlugin( - WebKit::WebFrame*, const WebKit::WebPluginParams&); - virtual WebKit::WebMediaPlayer* createMediaPlayer( - WebKit::WebFrame*, const WebKit::WebURL&, WebKit::WebMediaPlayerClient*); - virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( - WebKit::WebFrame*, WebKit::WebApplicationCacheHostClient*); - virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings); - virtual bool allowImage(WebKit::WebFrame* frame, - bool enabled_per_settings, - const WebKit::WebURL& image_url); - virtual void loadURLExternally( - WebKit::WebFrame*, const WebKit::WebURLRequest&, - WebKit::WebNavigationPolicy); - virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( - WebKit::WebFrame*, WebKit::WebDataSource::ExtraData*, - const WebKit::WebURLRequest&, WebKit::WebNavigationType, - WebKit::WebNavigationPolicy default_policy, bool isRedirect); - // DEPRECATED - virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( - WebKit::WebFrame*, const WebKit::WebURLRequest&, - WebKit::WebNavigationType, WebKit::WebNavigationPolicy default_policy, - bool isRedirect); - virtual bool canHandleRequest( - WebKit::WebFrame*, const WebKit::WebURLRequest&); - virtual WebKit::WebURLError cannotHandleRequestError( - WebKit::WebFrame*, const WebKit::WebURLRequest& request); - virtual WebKit::WebURLError cancelledError( - WebKit::WebFrame*, const WebKit::WebURLRequest& request); - virtual void unableToImplementPolicyWithError( - WebKit::WebFrame*, const WebKit::WebURLError&); - virtual void willPerformClientRedirect( - WebKit::WebFrame*, const WebKit::WebURL& from, const WebKit::WebURL& to, - double interval, double fire_time); - virtual void didCancelClientRedirect(WebKit::WebFrame*); - virtual void didCreateDataSource( - WebKit::WebFrame*, WebKit::WebDataSource*); - virtual void didStartProvisionalLoad(WebKit::WebFrame*); - virtual void didReceiveServerRedirectForProvisionalLoad(WebKit::WebFrame*); - virtual void didFailProvisionalLoad( - WebKit::WebFrame*, const WebKit::WebURLError&); - virtual void didCommitProvisionalLoad( - WebKit::WebFrame*, bool is_new_navigation); - virtual void didReceiveTitle( - WebKit::WebFrame*, const WebKit::WebString& title, - WebKit::WebTextDirection direction); - virtual void didFinishDocumentLoad(WebKit::WebFrame*); - virtual void didHandleOnloadEvents(WebKit::WebFrame*); - virtual void didFinishLoad(WebKit::WebFrame*); - virtual void didNavigateWithinPage( - WebKit::WebFrame*, bool is_new_navigation); - virtual void didChangeLocationWithinPage( - WebKit::WebFrame*); - virtual void assignIdentifierToRequest( - WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest&); - virtual void willSendRequest( - WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, - const WebKit::WebURLResponse& redirectResponse); - virtual void didReceiveResponse( - WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&); - virtual void didFinishResourceLoad( - WebKit::WebFrame*, unsigned identifier); - virtual void didFailResourceLoad( - WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&); - virtual void didDisplayInsecureContent(WebKit::WebFrame* frame); - virtual void didRunInsecureContent( - WebKit::WebFrame* frame, - const WebKit::WebSecurityOrigin& origin, - const WebKit::WebURL& target_url); - virtual bool allowScript(WebKit::WebFrame* frame, bool enabled_per_settings); - virtual void openFileSystem( - WebKit::WebFrame* frame, - WebKit::WebFileSystemType type, - long long size, - bool create, - WebKit::WebFileSystemCallbacks* callbacks); - - // webkit::npapi::WebPluginPageDelegate - virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate( - const base::FilePath& url, - const std::string& mime_type) OVERRIDE; - virtual WebKit::WebPlugin* CreatePluginReplacement( - const base::FilePath& file_path) OVERRIDE; - virtual void CreatedPluginWindow( - gfx::PluginWindowHandle handle) OVERRIDE; - virtual void WillDestroyPluginWindow( - gfx::PluginWindowHandle handle) OVERRIDE; - virtual void DidMovePlugin( - const webkit::npapi::WebPluginGeometry& move) OVERRIDE; - virtual void DidStartLoadingForPlugin() OVERRIDE {} - virtual void DidStopLoadingForPlugin() OVERRIDE {} - virtual WebKit::WebCookieJar* GetCookieJar() OVERRIDE; - - explicit TestWebViewDelegate(TestShell* shell); - virtual ~TestWebViewDelegate(); - void Reset(); - - // Additional accessors -#if defined(OS_WIN) - IDropTarget* drop_delegate() { return drop_delegate_.get(); } -#endif - - void set_pending_extra_data(TestShellExtraData* extra_data) { - pending_extra_data_.reset(extra_data); - } - - // Methods for modifying WebPreferences - void SetUserStyleSheetEnabled(bool is_enabled); - void SetUserStyleSheetLocation(const GURL& location); - void SetAuthorAndUserStylesEnabled(bool is_enabled); - - // Sets the webview as a drop target. - void RegisterDragDrop(); - void RevokeDragDrop(); - - void ResetDragDrop(); - - void SetCustomPolicyDelegate(bool is_custom, bool is_permissive); - void WaitForPolicyDelegate(); - - void set_clear_header(const std::string& header) { - clear_headers_.insert(header); - } - const std::set<std::string>& clear_headers() { - return clear_headers_; - } - - void set_block_redirects(bool block_redirects) { - block_redirects_ = block_redirects; - } - bool block_redirects() const { - return block_redirects_; - } - - void set_request_return_null(bool request_return_null) { - request_return_null_ = request_return_null; - } - bool request_return_null() const { - return request_return_null_; - } - - void SetEditCommand(const std::string& name, const std::string& value) { - edit_command_name_ = name; - edit_command_value_ = value; - } - - void ClearEditCommand() { - edit_command_name_.clear(); - edit_command_value_.clear(); - } - - void ClearContextMenuData(); - - const WebKit::WebContextMenuData* last_context_menu_data() const { - return last_context_menu_data_.get(); - } - - MockSpellCheck* mock_spellcheck() { - return &mock_spellcheck_; - } - - private: - // Called the title of the page changes. - // Can be used to update the title of the window. - void SetPageTitle(const base::string16& title); - - // Called when the URL of the page changes. - // Extracts the URL and forwards on to SetAddressBarURL(). - void UpdateAddressBar(WebKit::WebView* webView); - - // Called when the URL of the page changes. - // Should be used to update the text of the URL bar. - void SetAddressBarURL(const GURL& url); - - // Show a JavaScript alert as a popup message. - // The caller should test whether we're in layout test mode and only - // call this function when we really want a message to pop up. - void ShowJavaScriptAlert(const base::string16& message); - - // Tests that require moving or resizing the main window (via resizeTo() or - // moveTo()) pass in Chrome even though Chrome disregards move requests for - // non-popup windows (see TabContents::RequestMove()). These functions allow - // the test shell to mimic its behavior. If setWindowRect() is called for - // the main window, the passed in WebRect is saved as fake_rect_ and we return - // it instead of the real window dimensions whenever rootWindowRect() is - // called. - WebKit::WebRect fake_window_rect(); - void set_fake_window_rect(const WebKit::WebRect&); - - WebWidgetHost* GetWidgetHost(); - - void UpdateForCommittedLoad(WebKit::WebFrame* frame, bool is_new_navigation); - void UpdateURL(WebKit::WebFrame* frame); - void UpdateSessionHistory(WebKit::WebFrame* frame); - void UpdateSelectionClipboard(bool is_empty_selection); - - // Get a string suitable for dumping a frame to the console. - base::string16 GetFrameDescription(WebKit::WebFrame* webframe); - - // Causes navigation actions just printout the intended navigation instead - // of taking you to the page. This is used for cases like mailto, where you - // don't actually want to open the mail program. - bool policy_delegate_enabled_; - - // Toggles the behavior of the policy delegate. If true, then navigations - // will be allowed. Otherwise, they will be ignored (dropped). - bool policy_delegate_is_permissive_; - - // If true, the policy delegate will signal layout test completion. - bool policy_delegate_should_notify_done_; - - // Non-owning pointer. The delegate is owned by the host. - TestShell* shell_; - - // For tracking session history. See RenderView. - int page_id_; - int last_page_id_updated_; - - scoped_ptr<TestShellExtraData> pending_extra_data_; - - // Maps resource identifiers to a descriptive string. - typedef std::map<uint32, std::string> ResourceMap; - ResourceMap resource_identifier_map_; - std::string GetResourceDescription(uint32 identifier); - - scoped_ptr<WebKit::WebContextMenuData> last_context_menu_data_; - - WebCursor current_cursor_; - - WebKit::WebRect fake_rect_; - bool using_fake_rect_; - -#if defined(OS_WIN) - // Classes needed by drag and drop. - scoped_refptr<TestDropDelegate> drop_delegate_; -#endif - -#if defined(TOOLKIT_GTK) - // The type of cursor the window is currently using. - // Used for judging whether a new SetCursor call is actually changing the - // cursor. - GdkCursorType cursor_type_; -#endif - -#if defined(OS_MACOSX) - scoped_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_; - WebKit::WebRect popup_bounds_; -#endif - - // Set of headers to clear in willSendRequest. - std::set<std::string> clear_headers_; - - // true if we should block any redirects - bool block_redirects_; - - // true if we should block (set an empty request for) any requests - bool request_return_null_; - - // Edit command associated to the current keyboard event. - std::string edit_command_name_; - std::string edit_command_value_; - - // The mock spellchecker used in TestWebViewDelegate::spellCheck(). - MockSpellCheck mock_spellcheck_; - - DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc deleted file mode 100644 index 715bfdf..0000000 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file was forked off the Mac port. - -#include "webkit/tools/test_shell/test_webview_delegate.h" - -#include <gdk/gdkx.h> -#include <gtk/gtk.h> - -#include "base/bind.h" -#include "base/message_loop.h" -#include "base/utf_string_conversions.h" -#include "net/base/net_errors.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/base/window_open_disposition.h" -#include "ui/gfx/gtk_util.h" -#include "ui/gfx/point.h" -#include "webkit/glue/webcursor.h" -#include "webkit/glue/webdropdata.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/plugins/npapi/gtk_plugin_container_manager.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/plugins/npapi/webplugin.h" -#include "webkit/plugins/npapi/webplugin_delegate_impl.h" -#include "webkit/tools/test_shell/test_navigation_controller.h" -#include "webkit/tools/test_shell/test_shell.h" - -using WebKit::WebCursorInfo; -using WebKit::WebFrame; -using WebKit::WebNavigationPolicy; -using WebKit::WebPopupMenuInfo; -using WebKit::WebRect; -using WebKit::WebWidget; -using WebKit::WebView; - -namespace { - -enum SelectionClipboardType { - TEXT_HTML, - PLAIN_TEXT, -}; - -GdkAtom GetTextHtmlAtom() { - GdkAtom kTextHtmlGdkAtom = gdk_atom_intern_static_string("text/html"); - return kTextHtmlGdkAtom; -} - -void SelectionClipboardGetContents(GtkClipboard* clipboard, - GtkSelectionData* selection_data, guint info, gpointer data) { - // Ignore formats that we don't know about. - if (info != TEXT_HTML && info != PLAIN_TEXT) - return; - - WebView* webview = static_cast<WebView*>(data); - WebFrame* frame = webview->focusedFrame(); - if (!frame) - frame = webview->mainFrame(); - DCHECK(frame); - - std::string selection; - if (TEXT_HTML == info) { - selection = frame->selectionAsMarkup().utf8(); - } else { - selection = frame->selectionAsText().utf8(); - } - if (TEXT_HTML == info) { - gtk_selection_data_set(selection_data, - GetTextHtmlAtom(), - 8 /* bits per data unit, ie, char */, - reinterpret_cast<const guchar*>(selection.data()), - selection.length()); - } else { - gtk_selection_data_set_text(selection_data, selection.data(), - selection.length()); - } -} - -} // namespace - -// WebViewClient -------------------------------------------------------------- - -WebWidget* TestWebViewDelegate::createPopupMenu( - const WebPopupMenuInfo& info) { - NOTREACHED(); - return NULL; -} - -// WebWidgetClient ------------------------------------------------------------ - -void TestWebViewDelegate::show(WebNavigationPolicy policy) { - WebWidgetHost* host = GetWidgetHost(); - GtkWidget* drawing_area = host->view_handle(); - GtkWidget* window = - gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); - gtk_widget_show_all(window); -} - -void TestWebViewDelegate::closeWidgetSoon() { - if (this == shell_->delegate()) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(>k_widget_destroy, GTK_WIDGET(shell_->mainWnd()))); - } else if (this == shell_->popup_delegate()) { - shell_->ClosePopup(); - } -} - -void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { - current_cursor_.InitFromCursorInfo(cursor_info); - GdkCursorType cursor_type = - static_cast<GdkCursorType>(current_cursor_.GetCursorType()); - GdkCursor* gdk_cursor; - if (cursor_type == GDK_CURSOR_IS_PIXMAP) { - // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is - // that calling gdk_window_set_cursor repeatedly is expensive. We should - // avoid it here where possible. - gdk_cursor = current_cursor_.GetCustomCursor(); - } else { - // Optimize the common case, where the cursor hasn't changed. - // However, we can switch between different pixmaps, so only on the - // non-pixmap branch. - if (cursor_type_ == cursor_type) - return; - if (cursor_type == GDK_LAST_CURSOR) - gdk_cursor = NULL; - else - gdk_cursor = gfx::GetCursor(cursor_type); - } - cursor_type_ = cursor_type; - gdk_window_set_cursor(shell_->webViewWnd()->window, gdk_cursor); -} - -WebRect TestWebViewDelegate::windowRect() { - WebWidgetHost* host = GetWidgetHost(); - GtkWidget* drawing_area = host->view_handle(); - GtkWidget* vbox = gtk_widget_get_parent(drawing_area); - GtkWidget* window = gtk_widget_get_parent(vbox); - - gint x, y; - gtk_window_get_position(GTK_WINDOW(window), &x, &y); - x += vbox->allocation.x + drawing_area->allocation.x; - y += vbox->allocation.y + drawing_area->allocation.y; - - return WebRect(x, y, - drawing_area->allocation.width, - drawing_area->allocation.height); -} - -void TestWebViewDelegate::setWindowRect(const WebRect& rect) { - if (this == shell_->delegate()) { - set_fake_window_rect(rect); - } else if (this == shell_->popup_delegate()) { - WebWidgetHost* host = GetWidgetHost(); - GtkWidget* drawing_area = host->view_handle(); - GtkWidget* window = - gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); - gtk_window_resize(GTK_WINDOW(window), rect.width, rect.height); - gtk_window_move(GTK_WINDOW(window), rect.x, rect.y); - } -} - -WebRect TestWebViewDelegate::rootWindowRect() { - if (using_fake_rect_) { - return fake_window_rect(); - } - if (WebWidgetHost* host = GetWidgetHost()) { - // We are being asked for the x/y and width/height of the entire browser - // window. This means the x/y is the distance from the corner of the - // screen, and the width/height is the size of the entire browser window. - // For example, this is used to implement window.screenX and window.screenY. - GtkWidget* drawing_area = host->view_handle(); - GtkWidget* window = - gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); - gint x, y, width, height; - gtk_window_get_position(GTK_WINDOW(window), &x, &y); - gtk_window_get_size(GTK_WINDOW(window), &width, &height); - return WebRect(x, y, width, height); - } - return WebRect(); -} - -WebRect TestWebViewDelegate::windowResizerRect() { - // Not necessary on Linux. - return WebRect(); -} - -void TestWebViewDelegate::runModal() { - NOTIMPLEMENTED(); -} - -// WebPluginPageDelegate ------------------------------------------------------ - -webkit::npapi::WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( - const base::FilePath& path, - const std::string& mime_type) { - return webkit::npapi::WebPluginDelegateImpl::Create(path, mime_type); -} - -void TestWebViewDelegate::CreatedPluginWindow( - gfx::PluginWindowHandle id) { - shell_->webViewHost()->CreatePluginContainer(id); -} - -void TestWebViewDelegate::WillDestroyPluginWindow( - gfx::PluginWindowHandle id) { - shell_->webViewHost()->DestroyPluginContainer(id); -} - -void TestWebViewDelegate::DidMovePlugin( - const webkit::npapi::WebPluginGeometry& move) { - WebWidgetHost* host = GetWidgetHost(); - webkit::npapi::GtkPluginContainerManager* plugin_container_manager = - static_cast<WebViewHost*>(host)->plugin_container_manager(); - plugin_container_manager->MovePluginContainer(move); -} - -// Public methods ------------------------------------------------------------- - -void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) { - if (is_empty_selection) - return; - - GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); - // Put data on the X clipboard. This doesn't actually grab the text from - // the HTML, it just registers a callback for when someone tries to paste. - GtkTargetList* target_list = gtk_target_list_new(NULL, 0); - gtk_target_list_add(target_list, GetTextHtmlAtom(), 0, TEXT_HTML); - gtk_target_list_add_text_targets(target_list, PLAIN_TEXT); - - gint num_targets = 0; - GtkTargetEntry* targets = gtk_target_table_new_from_list(target_list, - &num_targets); - gtk_clipboard_set_with_data(clipboard, targets, num_targets, - SelectionClipboardGetContents, NULL, - shell_->webView()); - gtk_target_list_unref(target_list); - gtk_target_table_free(targets, num_targets); -} - -// Private methods ------------------------------------------------------------ - -void TestWebViewDelegate::ShowJavaScriptAlert(const base::string16& message) { - GtkWidget* dialog = gtk_message_dialog_new( - shell_->mainWnd(), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, "%s", UTF16ToUTF8(message).c_str()); - gtk_window_set_title(GTK_WINDOW(dialog), "JavaScript Alert"); - gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. - gtk_widget_destroy(dialog); -} - -void TestWebViewDelegate::SetPageTitle(const base::string16& title) { - gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), - ("Test Shell - " + UTF16ToUTF8(title)).c_str()); -} - -void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { - gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); -} diff --git a/webkit/tools/test_shell/test_webview_delegate_mac.mm b/webkit/tools/test_shell/test_webview_delegate_mac.mm deleted file mode 100644 index f7f676b..0000000 --- a/webkit/tools/test_shell/test_webview_delegate_mac.mm +++ /dev/null @@ -1,284 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/test_webview_delegate.h" - -#import <Cocoa/Cocoa.h> -#include "base/strings/sys_string_conversions.h" -#include "base/utf_string_conversions.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "webkit/glue/webcursor.h" -#include "webkit/glue/webmenurunner_mac.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/plugins/npapi/webplugin_delegate_impl.h" -#include "webkit/tools/test_shell/test_shell.h" - -using webkit::npapi::WebPluginDelegateImpl; -using WebKit::WebCursorInfo; -using WebKit::WebNavigationPolicy; -using WebKit::WebPopupMenu; -using WebKit::WebPopupMenuInfo; -using WebKit::WebRect; -using WebKit::WebWidget; - -namespace { - -// Helper function for manufacturing input events to send to WebKit. -NSEvent* EventWithMenuAction(BOOL item_chosen, int window_num, - int item_height, int selected_index, - NSRect menu_bounds, NSRect view_bounds) { - NSEvent* event = nil; - double event_time = (double)(AbsoluteToDuration(UpTime())) / 1000.0; - - if (item_chosen) { - // Construct a mouse up event to simulate the selection of an appropriate - // menu item. - NSPoint click_pos; - click_pos.x = menu_bounds.size.width / 2; - - // This is going to be hard to calculate since the button is painted by - // WebKit, the menu by Cocoa, and we have to translate the selected_item - // index to a coordinate that WebKit's PopupMenu expects which uses a - // different font *and* expects to draw the menu below the button like we do - // on Windows. - // The WebKit popup menu thinks it will draw just below the button, so - // create the click at the offset based on the selected item's index and - // account for the different coordinate system used by NSView. - int item_offset = selected_index * item_height + item_height / 2; - click_pos.y = view_bounds.size.height - item_offset; - event = [NSEvent mouseEventWithType:NSLeftMouseUp - location:click_pos - modifierFlags:0 - timestamp:event_time - windowNumber:window_num - context:nil - eventNumber:0 - clickCount:1 - pressure:1.0]; - } else { - // Fake an ESC key event (keyCode = 0x1B, from webinputevent_mac.mm) and - // forward that to WebKit. - NSPoint key_pos; - key_pos.x = 0; - key_pos.y = 0; - NSString* escape_str = [NSString stringWithFormat:@"%c", 0x1B]; - event = [NSEvent keyEventWithType:NSKeyDown - location:key_pos - modifierFlags:0 - timestamp:event_time - windowNumber:window_num - context:nil - characters:@"" - charactersIgnoringModifiers:escape_str - isARepeat:NO - keyCode:0x1B]; - } - - return event; -} - -} // namespace - -// WebViewClient -------------------------------------------------------------- - -WebWidget* TestWebViewDelegate::createPopupMenu( - const WebPopupMenuInfo& info) { - WebWidget* webwidget = shell_->CreatePopupWidget(); - popup_menu_info_.reset(new WebPopupMenuInfo(info)); - return webwidget; -} - -// WebWidgetClient ------------------------------------------------------------ - -void TestWebViewDelegate::show(WebNavigationPolicy policy) { - if (!popup_menu_info_) - return; - if (this != shell_->popup_delegate()) - return; - // Display a HTML select menu. - - std::vector<WebMenuItem> items; - for (size_t i = 0; i < popup_menu_info_->items.size(); ++i) - items.push_back(popup_menu_info_->items[i]); - - int item_height = popup_menu_info_->itemHeight; - double font_size = popup_menu_info_->itemFontSize; - int selected_index = popup_menu_info_->selectedIndex; - bool right_aligned = popup_menu_info_->rightAligned; - popup_menu_info_.reset(); // No longer needed. - - const WebRect& bounds = popup_bounds_; - - // Set up the menu position. - NSView* web_view = shell_->webViewWnd(); - NSRect view_rect = [web_view bounds]; - int y_offset = bounds.y + bounds.height; - NSRect position = NSMakeRect(bounds.x, view_rect.size.height - y_offset, - bounds.width, bounds.height); - - // Display the menu. - scoped_nsobject<WebMenuRunner> menu_runner; - menu_runner.reset([[WebMenuRunner alloc] initWithItems:items - fontSize:font_size - rightAligned:right_aligned]); - - [menu_runner runMenuInView:shell_->webViewWnd() - withBounds:position - initialIndex:selected_index]; - - // Get the selected item and forward to WebKit. WebKit expects an input event - // (mouse down, keyboard activity) for this, so we calculate the proper - // position based on the selected index and provided bounds. - WebWidgetHost* popup = shell_->popupHost(); - int window_num = [shell_->mainWnd() windowNumber]; - NSEvent* event = EventWithMenuAction([menu_runner menuItemWasChosen], - window_num, item_height, - [menu_runner indexOfSelectedItem], - position, view_rect); - - if ([menu_runner menuItemWasChosen]) { - // Construct a mouse up event to simulate the selection of an appropriate - // menu item. - popup->MouseEvent(event); - } else { - // Fake an ESC key event (keyCode = 0x1B, from webinputevent_mac.mm) and - // forward that to WebKit. - popup->KeyEvent(event); - } -} - -void TestWebViewDelegate::closeWidgetSoon() { - if (this == shell_->delegate()) { - NSWindow *win = shell_->mainWnd(); - [win performSelector:@selector(performClose:) withObject:nil afterDelay:0]; - } else if (this == shell_->popup_delegate()) { - shell_->ClosePopup(); - } -} - -void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { - NSCursor* ns_cursor = WebCursor(cursor_info).GetNativeCursor(); - [ns_cursor set]; -} - -WebRect TestWebViewDelegate::windowRect() { - if (WebWidgetHost* host = GetWidgetHost()) { - NSView *view = host->view_handle(); - NSRect rect = [view frame]; - return gfx::Rect(NSRectToCGRect(rect)); - } - return WebRect(); -} - -void TestWebViewDelegate::setWindowRect(const WebRect& rect) { - if (this == shell_->delegate()) { - set_fake_window_rect(rect); - } else if (this == shell_->popup_delegate()) { - popup_bounds_ = rect; // The initial position of the popup. - } -} - -WebRect TestWebViewDelegate::rootWindowRect() { - if (using_fake_rect_) { - return fake_window_rect(); - } - if (WebWidgetHost* host = GetWidgetHost()) { - NSView *view = host->view_handle(); - NSRect rect = [[[view window] contentView] frame]; - return gfx::Rect(NSRectToCGRect(rect)); - } - return WebRect(); -} - -@interface NSWindow(OSInternals) -- (NSRect)_growBoxRect; -@end - -WebRect TestWebViewDelegate::windowResizerRect() { - NSRect resize_rect = NSMakeRect(0, 0, 0, 0); - WebWidgetHost* host = GetWidgetHost(); - // To match the WebKit screen shots, we need the resize area to overlap - // the scroll arrows, so in layout test mode, we don't return a real rect. - if (!(shell_->layout_test_mode()) && host) { - NSView *view = host->view_handle(); - NSWindow* window = [view window]; - resize_rect = [window _growBoxRect]; - // The scrollbar assumes that the resizer goes all the way down to the - // bottom corner, so we ignore any y offset to the rect itself and use the - // entire bottom corner. - resize_rect.origin.y = 0; - // Convert to view coordinates from window coordinates. - resize_rect = [view convertRect:resize_rect fromView:nil]; - // Flip the rect in view coordinates - resize_rect.origin.y = - [view frame].size.height - resize_rect.origin.y - - resize_rect.size.height; - } - return gfx::Rect(NSRectToCGRect(resize_rect)); -} - -void TestWebViewDelegate::runModal() { - NOTIMPLEMENTED(); -} - -// WebPluginPageDelegate ------------------------------------------------------ - -webkit::npapi::WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( - const base::FilePath& path, - const std::string& mime_type) { - WebWidgetHost *host = GetWidgetHost(); - if (!host) - return NULL; - - WebPluginDelegateImpl* delegate = - WebPluginDelegateImpl::Create(path, mime_type); - if (delegate) - delegate->SetNoBufferContext(); - return delegate; -} - -void TestWebViewDelegate::CreatedPluginWindow( - gfx::PluginWindowHandle handle) { -} - -void TestWebViewDelegate::WillDestroyPluginWindow( - gfx::PluginWindowHandle handle) { -} - -void TestWebViewDelegate::DidMovePlugin( - const webkit::npapi::WebPluginGeometry& move) { - // TODO(port): add me once plugins work. -} - -// Public methods ------------------------------------------------------------- - -void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) { - // No selection clipboard on mac, do nothing. -} - -// Private methods ------------------------------------------------------------ - -void TestWebViewDelegate::ShowJavaScriptAlert(const base::string16& message) { - NSString *text = - [NSString stringWithUTF8String:UTF16ToUTF8(message).c_str()]; - NSAlert *alert = [NSAlert alertWithMessageText:@"JavaScript Alert" - defaultButton:@"OK" - alternateButton:nil - otherButton:nil - informativeTextWithFormat:@"%@", text]; - [alert runModal]; -} - -void TestWebViewDelegate::SetPageTitle(const base::string16& title) { - [[shell_->webViewHost()->view_handle() window] - setTitle:[NSString stringWithUTF8String:UTF16ToUTF8(title).c_str()]]; -} - -void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { - const char* frameURL = url.spec().c_str(); - NSString *address = [NSString stringWithUTF8String:frameURL]; - [shell_->editWnd() setStringValue:address]; -} diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc deleted file mode 100644 index be9a672..0000000 --- a/webkit/tools/test_shell/test_webview_delegate_win.cc +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file contains the implementation of TestWebViewDelegate, which serves -// as the WebViewDelegate for the TestShellWebHost. The host is expected to -// have initialized a MessageLoop before these methods are called. - -#include "webkit/tools/test_shell/test_webview_delegate.h" - -#include <objidl.h> -#include <shlobj.h> -#include <shlwapi.h> - -#include "base/debug/trace_event.h" -#include "base/message_loop.h" -#include "base/utf_string_conversions.h" -#include "net/base/net_errors.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/base/window_open_disposition.h" -#include "ui/gfx/gdi_util.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/point.h" -#include "webkit/glue/webdropdata.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/plugins/npapi/webplugin.h" -#include "webkit/plugins/npapi/webplugin_delegate_impl.h" -#include "webkit/tools/test_shell/drop_delegate.h" -#include "webkit/tools/test_shell/test_navigation_controller.h" -#include "webkit/tools/test_shell/test_shell.h" - -using WebKit::WebCursorInfo; -using WebKit::WebNavigationPolicy; -using WebKit::WebPopupMenuInfo; -using WebKit::WebRect; -using WebKit::WebWidget; - -// WebViewClient -------------------------------------------------------------- - -WebWidget* TestWebViewDelegate::createPopupMenu( - const WebPopupMenuInfo& info) { - NOTREACHED(); - return NULL; -} - -// WebWidgetClient ------------------------------------------------------------ - -void TestWebViewDelegate::show(WebNavigationPolicy) { - if (WebWidgetHost* host = GetWidgetHost()) { - HWND root = GetAncestor(host->view_handle(), GA_ROOT); - ShowWindow(root, SW_SHOW); - UpdateWindow(root); - } -} - -void TestWebViewDelegate::closeWidgetSoon() { - if (this == shell_->delegate()) { - PostMessage(shell_->mainWnd(), WM_CLOSE, 0, 0); - } else if (this == shell_->popup_delegate()) { - shell_->ClosePopup(); - } -} - -void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { - if (WebWidgetHost* host = GetWidgetHost()) { - current_cursor_.InitFromCursorInfo(cursor_info); - HINSTANCE mod_handle = GetModuleHandle(NULL); - host->SetCursor(current_cursor_.GetCursor(mod_handle)); - } -} - -WebRect TestWebViewDelegate::windowRect() { - if (WebWidgetHost* host = GetWidgetHost()) { - RECT rect; - ::GetWindowRect(host->view_handle(), &rect); - return gfx::Rect(rect); - } - return WebRect(); -} - -void TestWebViewDelegate::setWindowRect(const WebRect& rect) { - if (this == shell_->delegate()) { - set_fake_window_rect(rect); - } else if (this == shell_->popup_delegate()) { - MoveWindow(shell_->popupWnd(), - rect.x, rect.y, rect.width, rect.height, FALSE); - } -} - -WebRect TestWebViewDelegate::rootWindowRect() { - if (using_fake_rect_) { - return fake_window_rect(); - } - if (WebWidgetHost* host = GetWidgetHost()) { - RECT rect; - HWND root_window = ::GetAncestor(host->view_handle(), GA_ROOT); - ::GetWindowRect(root_window, &rect); - return gfx::Rect(rect); - } - return WebRect(); -} - -WebRect TestWebViewDelegate::windowResizerRect() { - // Not necessary on Windows. - return WebRect(); -} - -void TestWebViewDelegate::runModal() { - WebWidgetHost* host = GetWidgetHost(); - if (!host) - return; - - show(WebKit::WebNavigationPolicyNewWindow); - - WindowList* wl = TestShell::windowList(); - for (WindowList::const_iterator i = wl->begin(); i != wl->end(); ++i) { - if (*i != shell_->mainWnd()) - EnableWindow(*i, FALSE); - } - - shell_->set_is_modal(true); - base::MessageLoop::current()->Run(); - - for (WindowList::const_iterator i = wl->begin(); i != wl->end(); ++i) - EnableWindow(*i, TRUE); -} - -// WebPluginPageDelegate ------------------------------------------------------ - -webkit::npapi::WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( - const base::FilePath& path, - const std::string& mime_type) { - HWND hwnd = shell_->webViewHost()->view_handle(); - if (!hwnd) - return NULL; - - return webkit::npapi::WebPluginDelegateImpl::Create(path, mime_type); -} - -void TestWebViewDelegate::CreatedPluginWindow( - gfx::PluginWindowHandle handle) { - // ignored -} - -void TestWebViewDelegate::WillDestroyPluginWindow( - gfx::PluginWindowHandle handle) { - // ignored -} - -void TestWebViewDelegate::DidMovePlugin( - const webkit::npapi::WebPluginGeometry& move) { - unsigned long flags = 0; - - if (move.rects_valid) { - HRGN hrgn = ::CreateRectRgn(move.clip_rect.x(), - move.clip_rect.y(), - move.clip_rect.right(), - move.clip_rect.bottom()); - gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects); - - // Note: System will own the hrgn after we call SetWindowRgn, - // so we don't need to call DeleteObject(hrgn) - ::SetWindowRgn(move.window, hrgn, FALSE); - } else { - flags |= (SWP_NOSIZE | SWP_NOMOVE); - } - - if (move.visible) - flags |= SWP_SHOWWINDOW; - else - flags |= SWP_HIDEWINDOW; - - ::SetWindowPos(move.window, - NULL, - move.window_rect.x(), - move.window_rect.y(), - move.window_rect.width(), - move.window_rect.height(), - flags); -} - -// Public methods ------------------------------------------------------------- - -void TestWebViewDelegate::UpdateSelectionClipboard(bool is_empty_selection) { - // No selection clipboard on windows, do nothing. -} - -// Private methods ------------------------------------------------------------ - -void TestWebViewDelegate::ShowJavaScriptAlert(const base::string16& message) { - MessageBox(NULL, message.c_str(), L"JavaScript Alert", MB_OK); -} - -void TestWebViewDelegate::SetPageTitle(const base::string16& title) { - // The Windows test shell, pre-refactoring, ignored this. *shrug* -} - -void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { - base::string16 url_string = UTF8ToUTF16(url.spec()); - SendMessage(shell_->editWnd(), WM_SETTEXT, 0, - reinterpret_cast<LPARAM>(url_string.c_str())); -} diff --git a/webkit/tools/test_shell/webview_host.h b/webkit/tools/test_shell/webview_host.h deleted file mode 100644 index 5f43a1c..0000000 --- a/webkit/tools/test_shell/webview_host.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ -#define WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ - -#include "base/basictypes.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/rect.h" -#include "webkit/tools/test_shell/webwidget_host.h" - -#if defined(TOOLKIT_GTK) -#include "webkit/plugins/npapi/gtk_plugin_container_manager.h" -#endif - -class TestWebViewDelegate; -struct WebPreferences; - -namespace WebKit { -class WebDevToolsAgentClient; -class WebView; -} - -// This class is a simple NativeView-based host for a WebView -class WebViewHost : public WebWidgetHost { - public: - // The new instance is deleted once the associated NativeView is destroyed. - // The newly created window should be resized after it is created, using the - // MoveWindow (or equivalent) function. - static WebViewHost* Create(gfx::NativeView parent_view, - TestWebViewDelegate* delegate, - WebKit::WebDevToolsAgentClient* devtools_client, - const WebPreferences& prefs); - - WebKit::WebView* webview() const; - -#if defined(TOOLKIT_GTK) - // Create a new plugin parent container for a given plugin XID. - void CreatePluginContainer(gfx::PluginWindowHandle id); - - // Destroy the plugin parent container when a plugin has been destroyed. - void DestroyPluginContainer(gfx::PluginWindowHandle id); - - webkit::npapi::GtkPluginContainerManager* plugin_container_manager() { - return &plugin_container_manager_; - } -#elif defined(OS_MACOSX) - void SetIsActive(bool active); -#endif - - protected: -#if defined(OS_WIN) - virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam) { - return false; - } -#endif - -#if defined(TOOLKIT_GTK) - // Helper class that creates and moves plugin containers. - webkit::npapi::GtkPluginContainerManager plugin_container_manager_; -#endif -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ diff --git a/webkit/tools/test_shell/webview_host_gtk.cc b/webkit/tools/test_shell/webview_host_gtk.cc deleted file mode 100644 index 8af556a..0000000 --- a/webkit/tools/test_shell/webview_host_gtk.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <gtk/gtk.h> - -#include "webkit/tools/test_shell/webview_host.h" - -#include "base/logging.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/plugins/npapi/gtk_plugin_container.h" -#include "webkit/tools/test_shell/test_webview_delegate.h" - -using WebKit::WebDevToolsAgentClient; -using WebKit::WebView; - -// static -WebViewHost* WebViewHost::Create(GtkWidget* parent_view, - TestWebViewDelegate* delegate, - WebDevToolsAgentClient* dev_tools_client, - const WebPreferences& prefs) { - WebViewHost* host = new WebViewHost(); - - host->view_ = WebWidgetHost::CreateWidget(parent_view, host); - host->plugin_container_manager_.set_host_widget(host->view_); - - host->webwidget_ = WebView::create(delegate); - host->webview()->setDevToolsAgentClient(dev_tools_client); - webkit_glue::ApplyWebPreferences(prefs, host->webview()); - host->webview()->settings()->setExperimentalCSSGridLayoutEnabled(true); - host->webview()->initializeMainFrame(delegate); - host->webwidget_->layout(); - - return host; -} - -WebView* WebViewHost::webview() const { - return static_cast<WebView*>(webwidget_); -} - -void WebViewHost::CreatePluginContainer(gfx::PluginWindowHandle id) { - plugin_container_manager_.CreatePluginContainer(id); -} - -void WebViewHost::DestroyPluginContainer(gfx::PluginWindowHandle id) { - plugin_container_manager_.DestroyPluginContainer(id); -} diff --git a/webkit/tools/test_shell/webview_host_mac.mm b/webkit/tools/test_shell/webview_host_mac.mm deleted file mode 100644 index 57bb1ca..0000000 --- a/webkit/tools/test_shell/webview_host_mac.mm +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import <Cocoa/Cocoa.h> - -#include "webkit/tools/test_shell/webview_host.h" -#include "webkit/tools/test_shell/mac/test_shell_webview.h" - -#include "skia/ext/platform_canvas.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/tools/test_shell/test_shell.h" -#include "webkit/tools/test_shell/test_webview_delegate.h" - -using WebKit::WebDevToolsAgentClient; -using WebKit::WebSize; -using WebKit::WebView; - -// static -WebViewHost* WebViewHost::Create(NSView* parent_view, - TestWebViewDelegate* delegate, - WebDevToolsAgentClient* dev_tools_client, - const WebPreferences& prefs) { - WebViewHost* host = new WebViewHost(); - - NSRect content_rect = [parent_view frame]; - // bump down the top of the view so that it doesn't overlap the buttons - // and URL field. 32 is an ad hoc constant. - // TODO(awalker): replace explicit view layout with a little nib file - // and use that for view geometry. - content_rect.size.height -= 32; - host->view_ = [[TestShellWebView alloc] initWithFrame:content_rect]; - // make the height and width track the window size. - [host->view_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [parent_view addSubview:host->view_]; - [host->view_ release]; - - host->webwidget_ = WebView::create(delegate); - host->webview()->setDevToolsAgentClient(dev_tools_client); - webkit_glue::ApplyWebPreferences(prefs, host->webview()); - host->webview()->settings()->setExperimentalCSSGridLayoutEnabled(true); - host->webview()->initializeMainFrame(delegate); - host->webwidget_->resize(WebSize(NSWidth(content_rect), - NSHeight(content_rect))); - - return host; -} - -WebView* WebViewHost::webview() const { - return static_cast<WebView*>(webwidget_); -} - -void WebViewHost::SetIsActive(bool active) { - // Ignore calls in layout test mode so that tests don't mess with each other - // when running in parallel. - if (!TestShell::layout_test_mode()) - webview()->setIsActive(active); -} diff --git a/webkit/tools/test_shell/webview_host_win.cc b/webkit/tools/test_shell/webview_host_win.cc deleted file mode 100644 index 85ea5fa..0000000 --- a/webkit/tools/test_shell/webview_host_win.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/webview_host.h" - -#include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/base/win/hwnd_util.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" -#include "webkit/glue/webpreferences.h" -#include "webkit/tools/test_shell/test_webview_delegate.h" - -using namespace WebKit; - -static const wchar_t kWindowClassName[] = L"WebViewHost"; - -/*static*/ -WebViewHost* WebViewHost::Create(HWND parent_view, - TestWebViewDelegate* delegate, - WebDevToolsAgentClient* dev_tools_client, - const WebPreferences& prefs) { - WebViewHost* host = new WebViewHost(); - - static bool registered_class = false; - if (!registered_class) { - WNDCLASSEX wcex = {0}; - wcex.cbSize = sizeof(wcex); - wcex.style = CS_DBLCLKS; - wcex.lpfnWndProc = WebWidgetHost::WndProc; - wcex.hInstance = GetModuleHandle(NULL); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.lpszClassName = kWindowClassName; - RegisterClassEx(&wcex); - registered_class = true; - } - - host->view_ = CreateWindow(kWindowClassName, NULL, - WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0, 0, - 0, 0, parent_view, NULL, - GetModuleHandle(NULL), NULL); - ui::SetWindowUserData(host->view_, host); - - host->webwidget_ = WebView::create(delegate); - host->webview()->setDevToolsAgentClient(dev_tools_client); - webkit_glue::ApplyWebPreferences(prefs, host->webview()); - host->webview()->settings()->setExperimentalCSSGridLayoutEnabled(true); - host->webview()->initializeMainFrame(delegate); - - return host; -} - -WebView* WebViewHost::webview() const { - return static_cast<WebView*>(webwidget_); -} diff --git a/webkit/tools/test_shell/webwidget_host.cc b/webkit/tools/test_shell/webwidget_host.cc deleted file mode 100644 index 676a5a6..0000000 --- a/webkit/tools/test_shell/webwidget_host.cc +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/webwidget_host.h" - -#include "base/bind.h" -#include "base/message_loop.h" - -void WebWidgetHost::ScheduleAnimation() { - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&WebWidgetHost::ScheduleComposite, weak_factory_.GetWeakPtr()), - base::TimeDelta::FromMilliseconds(10)); -} diff --git a/webkit/tools/test_shell/webwidget_host.h b/webkit/tools/test_shell/webwidget_host.h deleted file mode 100644 index 3dd430d..0000000 --- a/webkit/tools/test_shell/webwidget_host.h +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_ -#define WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_ - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "skia/ext/platform_canvas.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/rect.h" - -namespace gfx { -class Size; -} - -namespace WebKit { -class WebWidget; -class WebWidgetClient; -struct WebScreenInfo; -} - -#if defined(OS_MACOSX) -#ifdef __OBJC__ -@class NSEvent; -#else -class NSEvent; -#endif -#endif - -// This class is a simple NativeView-based host for a WebWidget -class WebWidgetHost { - public: - // The new instance is deleted once the associated NativeView is destroyed. - // The newly created window should be resized after it is created, using the - // MoveWindow (or equivalent) function. - static WebWidgetHost* Create(gfx::NativeView parent_view, - WebKit::WebWidgetClient* client); - -#if defined(OS_MACOSX) - static void HandleEvent(gfx::NativeView view, NSEvent* event); -#endif - - gfx::NativeView view_handle() const { return view_; } - WebKit::WebWidget* webwidget() const { return webwidget_; } - - void DidInvalidateRect(const gfx::Rect& rect); - void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect); - void ScheduleComposite(); - void ScheduleAnimation(); -#if defined(OS_WIN) - void SetCursor(HCURSOR cursor); -#endif - - void DiscardBackingStore(); - // Allow clients to update the paint rect. For example, if we get a gdk - // expose or WM_PAINT event, we need to update the paint rect. - void UpdatePaintRect(const gfx::Rect& rect); - void Paint(); - - skia::PlatformCanvas* canvas() const { return canvas_.get(); } - - WebKit::WebScreenInfo GetScreenInfo(); - - // Paints the entire canvas a semi-transparent black (grayish). This is used - // by the layout tests in fast/repaint. The alpha value matches upstream. - void DisplayRepaintMask() { - canvas()->drawARGB(167, 0, 0, 0); - } - - void PaintRect(const gfx::Rect& rect); - - protected: - WebWidgetHost(); - ~WebWidgetHost(); - -#if defined(OS_WIN) - // Per-class wndproc. Returns true if the event should be swallowed. - virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam); - - void Resize(LPARAM lparam); - void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam); - void WheelEvent(WPARAM wparam, LPARAM lparam); - void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam); - void CaptureLostEvent(); - void SetFocus(bool enable); - - static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -#elif defined(OS_MACOSX) - // These need to be called from a non-subclass, so they need to be public. - public: - void Resize(const gfx::Rect& rect); - void MouseEvent(NSEvent *); - void WheelEvent(NSEvent *); - void KeyEvent(NSEvent *); - void SetFocus(bool enable); - protected: -#elif defined(TOOLKIT_GTK) - public: - // --------------------------------------------------------------------------- - // This is needed on Linux because the GtkWidget creation is the same between - // both web view hosts and web widget hosts. The Windows code manages this by - // reusing the WndProc function (static, above). However, GTK doesn't use a - // single big callback function like that so we have a static function that - // sets up a GtkWidget correctly. - // parent: a GtkBox to pack the new widget at the end of - // host: a pointer to a WebWidgetHost (or subclass thereof) - // --------------------------------------------------------------------------- - static gfx::NativeView CreateWidget(gfx::NativeView parent_view, - WebWidgetHost* host); - void WindowDestroyed(); - void Resize(const gfx::Size& size); -#endif - -#if defined(OS_WIN) - void TrackMouseLeave(bool enable); -#endif - - void ResetScrollRect(); - - void set_painting(bool value) { -#ifndef NDEBUG - painting_ = value; -#endif - } - - gfx::NativeView view_; - WebKit::WebWidget* webwidget_; - scoped_ptr<skia::PlatformCanvas> canvas_; - - // specifies the portion of the webwidget that needs painting - gfx::Rect paint_rect_; - - // specifies the portion of the webwidget that needs scrolling - gfx::Rect scroll_rect_; - int scroll_dx_; - int scroll_dy_; - -#if defined(OS_WIN) - bool track_mouse_leave_; -#endif - -#if defined(TOOLKIT_GTK) - // Since GtkWindow resize is asynchronous, we have to stash the dimensions, - // so that the backing store doesn't have to wait for sizing to take place. - gfx::Size logical_size_; -#endif - -#ifndef NDEBUG - bool painting_; -#endif - - private: - base::WeakPtrFactory<WebWidgetHost> weak_factory_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_ diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc deleted file mode 100644 index 593f1d5..0000000 --- a/webkit/tools/test_shell/webwidget_host_gtk.cc +++ /dev/null @@ -1,436 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/webwidget_host.h" - -#include <cairo/cairo.h> -#include <gtk/gtk.h> - -#include "base/basictypes.h" -#include "base/logging.h" -#include "skia/ext/bitmap_platform_device.h" -#include "skia/ext/platform_canvas.h" -#include "skia/ext/platform_device.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFactory.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" -#include "webkit/tools/test_shell/test_shell.h" -#include "webkit/tools/test_shell/test_shell_x11.h" - -using WebKit::WebInputEventFactory; -using WebKit::WebKeyboardEvent; -using WebKit::WebMouseEvent; -using WebKit::WebMouseWheelEvent; -using WebKit::WebPopupMenu; -using WebKit::WebScreenInfo; -using WebKit::WebScreenInfoFactory; -using WebKit::WebSize; -using WebKit::WebWidgetClient; - -namespace { - -// Used to store a backpointer to WebWidgetHost from our GtkWidget. -const char kWebWidgetHostKey[] = "webwidgethost"; - -// In response to an invalidation, we call into WebKit to do layout. On -// Windows, WM_PAINT is a virtual message so any extra invalidates that come up -// while it's doing layout are implicitly swallowed as soon as we actually do -// drawing via BeginPaint. -// -// Though GTK does know how to collapse multiple paint requests, it won't erase -// paint requests from the future when we start drawing. To avoid an infinite -// cycle of repaints, we track whether we're currently handling a redraw, and -// during that if we get told by WebKit that a region has become invalid, we -// still add that region to the local dirty rect but *don't* enqueue yet -// another "do a paint" message. -bool g_handling_expose = false; - -// ----------------------------------------------------------------------------- -// Callback functions to proxy to host... - -// The web contents are completely drawn and handled by WebKit, except that -// windowed plugins are GtkSockets on top of it. We need to place the -// GtkSockets inside a GtkContainer. We use a GtkFixed container, and the -// GtkSocket objects override a little bit to manage their size (see the code -// in webplugin_delegate_impl_gtk.cc). We listen on a the events we're -// interested in and forward them on to the WebWidgetHost. This class is a -// collection of static methods, implementing the widget related code. -class WebWidgetHostGtkWidget { - public: - // This will create a new widget used for hosting the web contents. We use - // our GtkDrawingAreaContainer here, for the reasons mentioned above. - static GtkWidget* CreateNewWidget(GtkWidget* parent_view, - WebWidgetHost* host) { - GtkWidget* widget = gtk_fixed_new(); - gtk_fixed_set_has_window(GTK_FIXED(widget), true); - - gtk_box_pack_start(GTK_BOX(parent_view), widget, TRUE, TRUE, 0); - - gtk_widget_add_events(widget, GDK_EXPOSURE_MASK | - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_KEY_PRESS_MASK | - GDK_KEY_RELEASE_MASK); - gtk_widget_set_can_focus(widget, TRUE); - g_signal_connect(widget, "size-request", - G_CALLBACK(&HandleSizeRequest), host); - g_signal_connect(widget, "size-allocate", - G_CALLBACK(&HandleSizeAllocate), host); - g_signal_connect(widget, "configure-event", - G_CALLBACK(&HandleConfigure), host); - g_signal_connect(widget, "expose-event", - G_CALLBACK(&HandleExpose), host); - g_signal_connect(widget, "destroy", - G_CALLBACK(&HandleDestroy), host); - g_signal_connect(widget, "key-press-event", - G_CALLBACK(&HandleKeyPress), host); - g_signal_connect(widget, "key-release-event", - G_CALLBACK(&HandleKeyRelease), host); - g_signal_connect(widget, "focus", - G_CALLBACK(&HandleFocus), host); - g_signal_connect(widget, "focus-in-event", - G_CALLBACK(&HandleFocusIn), host); - g_signal_connect(widget, "focus-out-event", - G_CALLBACK(&HandleFocusOut), host); - g_signal_connect(widget, "button-press-event", - G_CALLBACK(&HandleButtonPress), host); - g_signal_connect(widget, "button-release-event", - G_CALLBACK(&HandleButtonRelease), host); - g_signal_connect(widget, "motion-notify-event", - G_CALLBACK(&HandleMotionNotify), host); - g_signal_connect(widget, "scroll-event", - G_CALLBACK(&HandleScroll), host); - - g_object_set_data(G_OBJECT(widget), kWebWidgetHostKey, host); - return widget; - } - - private: - // Our size was requested. We let the GtkFixed do its normal calculation, - // after which this callback is called. The GtkFixed will come up with a - // requisition based on its children, which include plugin windows. Since - // we don't want to prevent resizing smaller than a plugin window, we need to - // control the size ourself. - static void HandleSizeRequest(GtkWidget* widget, - GtkRequisition* req, - WebWidgetHost* host) { - // This is arbitrary, but the WebKit scrollbars try to shrink themselves - // if the browser window is too small. Give them some space. - static const int kMinWidthHeight = 64; - - req->width = kMinWidthHeight; - req->height = kMinWidthHeight; - } - - // Our size has changed. - static void HandleSizeAllocate(GtkWidget* widget, - GtkAllocation* allocation, - WebWidgetHost* host) { - host->Resize(WebSize(allocation->width, allocation->height)); - } - - // Size, position, or stacking of the GdkWindow changed. - static gboolean HandleConfigure(GtkWidget* widget, - GdkEventConfigure* config, - WebWidgetHost* host) { - host->Resize(WebSize(config->width, config->height)); - return FALSE; - } - - // A portion of the GdkWindow needs to be redraw. - static gboolean HandleExpose(GtkWidget* widget, - GdkEventExpose* expose, - WebWidgetHost* host) { - // See comments above about what g_handling_expose is for. - g_handling_expose = true; - gfx::Rect rect(expose->area); - host->UpdatePaintRect(rect); - host->Paint(); - g_handling_expose = false; - return FALSE; - } - - // The GdkWindow was destroyed. - static gboolean HandleDestroy(GtkWidget* widget, void* unused) { - // The associated WebWidgetHost instance may have already been destroyed. - WebWidgetHost* host = static_cast<WebWidgetHost*>( - g_object_get_data(G_OBJECT(widget), kWebWidgetHostKey)); - if (host) - host->WindowDestroyed(); - return FALSE; - } - - // Keyboard key pressed. - static gboolean HandleKeyPress(GtkWidget* widget, - GdkEventKey* event, - WebWidgetHost* host) { - host->webwidget()->handleInputEvent( - WebInputEventFactory::keyboardEvent(event)); - - // In the browser we do a ton of work with IMEs. This is some minimal - // code to make basic text work in test_shell, but doesn't cover IME. - // This is a copy of the logic in ProcessUnfilteredKeyPressEvent in - // render_widget_host_view_gtk.cc . - if (event->type == GDK_KEY_PRESS) { - WebKeyboardEvent wke = WebInputEventFactory::keyboardEvent(event); - if (wke.text[0]) { - wke.type = WebKit::WebInputEvent::Char; - host->webwidget()->handleInputEvent(wke); - } - } - - return FALSE; - } - - // Keyboard key released. - static gboolean HandleKeyRelease(GtkWidget* widget, - GdkEventKey* event, - WebWidgetHost* host) { - return HandleKeyPress(widget, event, host); - } - - // This signal is called when arrow keys or tab is pressed. If we return - // true, we prevent focus from being moved to another widget. If we want to - // allow focus to be moved outside of web contents, we need to implement - // WebViewDelegate::TakeFocus in the test webview delegate. - static gboolean HandleFocus(GtkWidget* widget, - GdkEventFocus* focus, - WebWidgetHost* host) { - return TRUE; - } - - // Keyboard focus entered. - static gboolean HandleFocusIn(GtkWidget* widget, - GdkEventFocus* focus, - WebWidgetHost* host) { - // Ignore focus calls in layout test mode so that tests don't mess with each - // other's focus when running in parallel. - if (!TestShell::layout_test_mode()) - host->webwidget()->setFocus(true); - return TRUE; - } - - // Keyboard focus left. - static gboolean HandleFocusOut(GtkWidget* widget, - GdkEventFocus* focus, - WebWidgetHost* host) { - // Ignore focus calls in layout test mode so that tests don't mess with each - // other's focus when running in parallel. - if (!TestShell::layout_test_mode()) - host->webwidget()->setFocus(false); - return TRUE; - } - - // Mouse button down. - static gboolean HandleButtonPress(GtkWidget* widget, - GdkEventButton* event, - WebWidgetHost* host) { - if (!(event->button == 1 || event->button == 2 || event->button == 3)) - return FALSE; // We do not forward any other buttons to the renderer. - if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) - return FALSE; - host->webwidget()->handleInputEvent( - WebInputEventFactory::mouseEvent(event)); - return FALSE; - } - - // Mouse button up. - static gboolean HandleButtonRelease(GtkWidget* widget, - GdkEventButton* event, - WebWidgetHost* host) { - return HandleButtonPress(widget, event, host); - } - - // Mouse pointer movements. - static gboolean HandleMotionNotify(GtkWidget* widget, - GdkEventMotion* event, - WebWidgetHost* host) { - host->webwidget()->handleInputEvent( - WebInputEventFactory::mouseEvent(event)); - return FALSE; - } - - // Mouse scroll wheel. - static gboolean HandleScroll(GtkWidget* widget, - GdkEventScroll* event, - WebWidgetHost* host) { - host->webwidget()->handleInputEvent( - WebInputEventFactory::mouseWheelEvent(event)); - return FALSE; - } - - DISALLOW_IMPLICIT_CONSTRUCTORS(WebWidgetHostGtkWidget); -}; - -} // namespace - -// This is provided so that the webview can reuse the custom GTK window code. -// static -gfx::NativeView WebWidgetHost::CreateWidget( - gfx::NativeView parent_view, WebWidgetHost* host) { - return WebWidgetHostGtkWidget::CreateNewWidget(parent_view, host); -} - -// static -WebWidgetHost* WebWidgetHost::Create(GtkWidget* parent_view, - WebWidgetClient* client) { - WebWidgetHost* host = new WebWidgetHost(); - host->view_ = CreateWidget(parent_view, host); - host->webwidget_ = WebPopupMenu::create(client); - // We manage our own double buffering because we need to be able to update - // the expose area in an ExposeEvent within the lifetime of the event handler. - gtk_widget_set_double_buffered(GTK_WIDGET(host->view_), false); - - return host; -} - -void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { - paint_rect_.Union(rect); -} - -void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { - DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting"; - - UpdatePaintRect(damaged_rect); - - if (!g_handling_expose) { - gtk_widget_queue_draw_area(GTK_WIDGET(view_), damaged_rect.x(), - damaged_rect.y(), damaged_rect.width(), damaged_rect.height()); - } -} - -void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { - // This is used for optimizing painting when the renderer is scrolled. We're - // currently not doing any optimizations so just invalidate the region. - DidInvalidateRect(clip_rect); -} - -void WebWidgetHost::ScheduleComposite() { - int width = logical_size_.width(); - int height = logical_size_.height(); - GdkRectangle grect = { - 0, - 0, - width, - height - }; - GdkWindow* window = view_->window; - gdk_window_invalidate_rect(window, &grect, 0); -} - -WebWidgetHost::WebWidgetHost() - : view_(NULL), - webwidget_(NULL), - scroll_dx_(0), - scroll_dy_(0), - weak_factory_(this) { - set_painting(false); -} - -WebWidgetHost::~WebWidgetHost() { - // We may be deleted before the view_. Clear out the signals so that we don't - // attempt to invoke something on a deleted object. - g_object_set_data(G_OBJECT(view_), kWebWidgetHostKey, NULL); - g_signal_handlers_disconnect_matched(view_, - G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, this); - webwidget_->close(); -} - -void WebWidgetHost::Resize(const gfx::Size &newsize) { - // The pixel buffer backing us is now the wrong size - canvas_.reset(); - logical_size_ = newsize; - webwidget_->resize(newsize); -} - -void WebWidgetHost::Paint() { - int width = logical_size_.width(); - int height = logical_size_.height(); - gfx::Rect client_rect(width, height); - - // Allocate a canvas if necessary - if (!canvas_) { - ResetScrollRect(); - paint_rect_ = client_rect; - canvas_.reset(skia::CreatePlatformCanvas(width, height, true, 0, - skia::RETURN_NULL_ON_FAILURE)); - if (!canvas_) { - // memory allocation failed, we can't paint. - LOG(ERROR) << "Failed to allocate memory for " << width << "x" << height; - return; - } - } - - webwidget_->animate(0.0); - - // This may result in more invalidation - webwidget_->layout(); - - // Paint the canvas if necessary. Allow painting to generate extra rects the - // first time we call it. This is necessary because some WebCore rendering - // objects update their layout only when painted. - // Store the total area painted in total_paint. Then tell the gdk window - // to update that area after we're done painting it. - gfx::Rect total_paint; - for (int i = 0; i < 2; ++i) { - paint_rect_.Intersect(client_rect); - if (!paint_rect_.IsEmpty()) { - gfx::Rect rect(paint_rect_); - paint_rect_ = gfx::Rect(); - - DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; - PaintRect(rect); - total_paint.Union(rect); - } - } - //DCHECK(paint_rect_.IsEmpty()); - - // Invalidate the paint region on the widget's underlying gdk window. Note - // that gdk_window_invalidate_* will generate extra expose events, which - // we wish to avoid. So instead we use calls to begin_paint/end_paint. - GdkRectangle grect = { - total_paint.x(), - total_paint.y(), - total_paint.width(), - total_paint.height(), - }; - GdkWindow* window = view_->window; - gdk_window_begin_paint_rect(window, &grect); - - // BitBlit to the gdk window. - skia::ScopedPlatformPaint scoped_platform_paint(canvas_.get()); - cairo_t* source_surface = scoped_platform_paint.GetPlatformSurface(); - cairo_t* cairo_drawable = gdk_cairo_create(window); - cairo_set_source_surface(cairo_drawable, cairo_get_target(source_surface), - 0, 0); - cairo_paint(cairo_drawable); - cairo_destroy(cairo_drawable); - - gdk_window_end_paint(window); -} - -WebScreenInfo WebWidgetHost::GetScreenInfo() { - Display* display = test_shell_x11::GtkWidgetGetDisplay(view_); - int screen_num = test_shell_x11::GtkWidgetGetScreenNum(view_); - return WebScreenInfoFactory::screenInfo(display, screen_num); -} - -void WebWidgetHost::ResetScrollRect() { - // This method is only needed for optimized scroll painting, which we don't - // care about in the test shell, yet. -} - -void WebWidgetHost::PaintRect(const gfx::Rect& rect) { - set_painting(true); - webwidget_->paint(canvas_.get(), rect); - set_painting(false); -} - -void WebWidgetHost::WindowDestroyed() { - delete this; -} diff --git a/webkit/tools/test_shell/webwidget_host_mac.mm b/webkit/tools/test_shell/webwidget_host_mac.mm deleted file mode 100644 index c7d4a54..0000000 --- a/webkit/tools/test_shell/webwidget_host_mac.mm +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import <Cocoa/Cocoa.h> - -#include "webkit/tools/test_shell/webwidget_host.h" - -#include "base/logging.h" -#include "skia/ext/platform_canvas.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFactory.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFactory.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/tools/test_shell/test_shell.h" - -using WebKit::WebInputEvent; -using WebKit::WebInputEventFactory; -using WebKit::WebKeyboardEvent; -using WebKit::WebMouseEvent; -using WebKit::WebMouseWheelEvent; -using WebKit::WebPopupMenu; -using WebKit::WebScreenInfo; -using WebKit::WebScreenInfoFactory; -using WebKit::WebSize; -using WebKit::WebWidgetClient; - -/*static*/ -WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, - WebWidgetClient* client) { - WebWidgetHost* host = new WebWidgetHost(); - - NSRect content_rect = [parent_view frame]; - content_rect.origin.y += 64; - content_rect.size.height -= 64; - host->view_ = [[NSView alloc] initWithFrame:content_rect]; - [parent_view addSubview:host->view_]; - - // ui::SetWindowUserData(host->hwnd_, host); - - host->webwidget_ = WebPopupMenu::create(client); - host->webwidget_->resize(WebSize(NSWidth(content_rect), - NSHeight(content_rect))); - return host; -} - -/*static*/ -void WebWidgetHost::HandleEvent(NSView* view, NSEvent* event) { - /* TODO(port): rig up a way to get to the host */ - WebWidgetHost* host = NULL; - if (host) { - switch ([event type]) { - case NSLeftMouseDown: - case NSLeftMouseUp: - case NSRightMouseDown: - case NSRightMouseUp: - case NSOtherMouseDown: - case NSOtherMouseUp: - case NSMouseEntered: - case NSMouseExited: - host->MouseEvent(event); - break; - - case NSScrollWheel: - host->WheelEvent(event); - break; - - case NSKeyDown: - case NSKeyUp: - host->KeyEvent(event); - break; - - case NSAppKitDefined: - switch ([event subtype]) { - case NSApplicationActivatedEventType: - host->SetFocus(true); - break; - case NSApplicationDeactivatedEventType: - host->SetFocus(false); - break; - } - break; - } - } -} - -void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { -#ifndef NDEBUG - DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting"; -#endif - - // If this invalidate overlaps with a pending scroll, then we have to - // downgrade to invalidating the scroll rect. - if (damaged_rect.Intersects(scroll_rect_)) { - paint_rect_.Union(scroll_rect_); - ResetScrollRect(); - } - paint_rect_.Union(damaged_rect); - - NSRect r = NSRectFromCGRect(damaged_rect.ToCGRect()); - // flip to cocoa coordinates - r.origin.y = [view_ frame].size.height - r.size.height - r.origin.y; - [view_ setNeedsDisplayInRect:r]; -} - -void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { - DCHECK(dx || dy); - - // If we already have a pending scroll operation or if this scroll operation - // intersects the existing paint region, then just failover to invalidating. - if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) { - paint_rect_.Union(scroll_rect_); - ResetScrollRect(); - paint_rect_.Union(clip_rect); - } - - // We will perform scrolling lazily, when requested to actually paint. - scroll_rect_ = clip_rect; - scroll_dx_ = dx; - scroll_dy_ = dy; - - NSRect r = NSRectFromCGRect(clip_rect.ToCGRect()); - // flip to cocoa coordinates - r.origin.y = [view_ frame].size.height - r.size.height - r.origin.y; - [view_ setNeedsDisplayInRect:r]; -} - -void WebWidgetHost::ScheduleComposite() { - if (!webwidget_) - return; - WebSize size = webwidget_->size(); - NSRect r = NSMakeRect(0, 0, size.width, size.height); - [view_ setNeedsDisplayInRect:r]; -} - -// void WebWidgetHost::SetCursor(HCURSOR cursor) { -// } - -void WebWidgetHost::DiscardBackingStore() { - canvas_.reset(); -} - -WebWidgetHost::WebWidgetHost() - : view_(NULL), - webwidget_(NULL), - scroll_dx_(0), - scroll_dy_(0), - weak_factory_(this) { - set_painting(false); -} - -WebWidgetHost::~WebWidgetHost() { - // ui::SetWindowUserData(hwnd_, 0); - - webwidget_->close(); -} - -void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { - paint_rect_.Union(rect); -} - -void WebWidgetHost::Paint() { - gfx::Rect client_rect(NSRectToCGRect([view_ frame])); - NSGraphicsContext* view_context = [NSGraphicsContext currentContext]; - CGContextRef context = static_cast<CGContextRef>([view_context graphicsPort]); - - // Allocate a canvas if necessary - if (!canvas_) { - ResetScrollRect(); - paint_rect_ = client_rect; - canvas_.reset(skia::CreatePlatformCanvas( - paint_rect_.width(), paint_rect_.height(), true)); - } - - // make sure webkit draws into our bitmap, not the window - CGContextRef bitmap_context = - skia::GetBitmapContext(skia::GetTopDevice(*canvas_)); - [NSGraphicsContext setCurrentContext: - [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context - flipped:YES]]; - - webwidget_->animate(0.0); - - // This may result in more invalidation - webwidget_->layout(); - - // Scroll the canvas if necessary - scroll_rect_.Intersect(client_rect); - if (!scroll_rect_.IsEmpty()) { - // add to invalidate rect, since there's no equivalent of ScrollDC. - paint_rect_.Union(scroll_rect_); - } - ResetScrollRect(); - - // Paint the canvas if necessary. Allow painting to generate extra rects the - // first time we call it. This is necessary because some WebCore rendering - // objects update their layout only when painted. - for (int i = 0; i < 2; ++i) { - paint_rect_.Intersect(client_rect); - if (!paint_rect_.IsEmpty()) { - gfx::Rect rect(paint_rect_); - paint_rect_ = gfx::Rect(); - -// DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; - PaintRect(rect); - } - } - DCHECK(paint_rect_.IsEmpty()); - - // set the context back to our window - [NSGraphicsContext setCurrentContext: view_context]; - - // Paint to the screen - if ([view_ lockFocusIfCanDraw]) { - int bitmap_height = CGBitmapContextGetHeight(bitmap_context); - int bitmap_width = CGBitmapContextGetWidth(bitmap_context); - CGRect bitmap_rect = { { 0, 0 }, - { bitmap_width, bitmap_height } }; - skia::DrawToNativeContext(canvas_.get(), context, 0, - client_rect.height() - bitmap_height, &bitmap_rect); - - [view_ unlockFocus]; - } -} - -WebScreenInfo WebWidgetHost::GetScreenInfo() { - return WebScreenInfoFactory::screenInfo(view_); -} - -void WebWidgetHost::Resize(const gfx::Rect& rect) { - // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. - DiscardBackingStore(); - webwidget_->resize(WebSize(rect.width(), rect.height())); -} - -void WebWidgetHost::MouseEvent(NSEvent *event) { - const WebMouseEvent& web_event = WebInputEventFactory::mouseEvent( - event, view_); - webwidget_->handleInputEvent(web_event); -} - -void WebWidgetHost::WheelEvent(NSEvent *event) { - webwidget_->handleInputEvent( - WebInputEventFactory::mouseWheelEvent(event, view_)); -} - -void WebWidgetHost::KeyEvent(NSEvent *event) { - WebKeyboardEvent keyboard_event(WebInputEventFactory::keyboardEvent(event)); - webwidget_->handleInputEvent(keyboard_event); - if ([event type] == NSKeyDown) { - // Send a Char event here to emulate the keyboard events. - // TODO(hbono): Bug 20852 <http://crbug.com/20852> implement the - // NSTextInput protocol and remove this code. - keyboard_event.type = WebInputEvent::Char; - webwidget_->handleInputEvent(keyboard_event); - } -} - -void WebWidgetHost::SetFocus(bool enable) { - // Ignore focus calls in layout test mode so that tests don't mess with each - // other's focus when running in parallel. - if (!TestShell::layout_test_mode()) - webwidget_->setFocus(enable); -} - -void WebWidgetHost::ResetScrollRect() { - scroll_rect_ = gfx::Rect(); - scroll_dx_ = 0; - scroll_dy_ = 0; -} - -void WebWidgetHost::PaintRect(const gfx::Rect& rect) { -#ifndef NDEBUG - DCHECK(!painting_); -#endif - DCHECK(canvas_.get()); - - set_painting(true); - webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); - set_painting(false); -} diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc deleted file mode 100644 index 25ca05b..0000000 --- a/webkit/tools/test_shell/webwidget_host_win.cc +++ /dev/null @@ -1,381 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/tools/test_shell/webwidget_host.h" - -#include "base/logging.h" -#include "skia/ext/platform_canvas.h" -#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFactory.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFactory.h" -#include "ui/base/win/hwnd_util.h" -#include "ui/gfx/rect.h" -#include "webkit/tools/test_shell/test_shell.h" - -using WebKit::WebInputEvent; -using WebKit::WebInputEventFactory; -using WebKit::WebKeyboardEvent; -using WebKit::WebMouseEvent; -using WebKit::WebMouseWheelEvent; -using WebKit::WebPopupMenu; -using WebKit::WebScreenInfo; -using WebKit::WebScreenInfoFactory; -using WebKit::WebSize; -using WebKit::WebWidget; -using WebKit::WebWidgetClient; - -static const wchar_t kWindowClassName[] = L"WebWidgetHost"; - -/*static*/ -WebWidgetHost* WebWidgetHost::Create(HWND parent_view, - WebWidgetClient* client) { - WebWidgetHost* host = new WebWidgetHost(); - - static bool registered_class = false; - if (!registered_class) { - WNDCLASSEX wcex = {0}; - wcex.cbSize = sizeof(wcex); - wcex.style = CS_DBLCLKS; - wcex.lpfnWndProc = WebWidgetHost::WndProc; - wcex.hInstance = GetModuleHandle(NULL); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.lpszClassName = kWindowClassName; - RegisterClassEx(&wcex); - registered_class = true; - } - - host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW, - kWindowClassName, kWindowClassName, WS_POPUP, - 0, 0, 0, 0, - parent_view, NULL, GetModuleHandle(NULL), NULL); - ui::SetWindowUserData(host->view_, host); - - host->webwidget_ = WebPopupMenu::create(client); - - return host; -} - -static WebWidgetHost* FromWindow(HWND view) { - return reinterpret_cast<WebWidgetHost*>(ui::GetWindowUserData(view)); -} - -/*static*/ -LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam, - LPARAM lparam) { - WebWidgetHost* host = FromWindow(hwnd); - if (host && !host->WndProc(message, wparam, lparam)) { - switch (message) { - case WM_DESTROY: - delete host; - break; - - case WM_PAINT: { - RECT rect; - if (GetUpdateRect(hwnd, &rect, FALSE)) { - host->UpdatePaintRect(gfx::Rect(rect)); - } - host->Paint(); - return 0; - } - - case WM_ERASEBKGND: - // Do nothing here to avoid flashing, the background will be erased - // during painting. - return 0; - - case WM_SIZE: - host->Resize(lparam); - return 0; - - case WM_MOUSEMOVE: - case WM_MOUSELEAVE: - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - case WM_LBUTTONDBLCLK: - case WM_MBUTTONDBLCLK: - case WM_RBUTTONDBLCLK: - host->MouseEvent(message, wparam, lparam); - break; - - case WM_MOUSEWHEEL: - host->WheelEvent(wparam, lparam); - break; - - case WM_CAPTURECHANGED: - case WM_CANCELMODE: - host->CaptureLostEvent(); - break; - - // TODO(darin): add WM_SYSKEY{DOWN/UP} to capture ALT key actions - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - case WM_CHAR: - case WM_SYSCHAR: - host->KeyEvent(message, wparam, lparam); - break; - - case WM_SETFOCUS: - host->SetFocus(true); - break; - - case WM_KILLFOCUS: - host->SetFocus(false); - break; - } - } - - return DefWindowProc(hwnd, message, wparam, lparam);; -} - -void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { - DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting"; - - // If this invalidate overlaps with a pending scroll, then we have to - // downgrade to invalidating the scroll rect. - if (damaged_rect.Intersects(scroll_rect_)) { - paint_rect_.Union(scroll_rect_); - ResetScrollRect(); - } - paint_rect_.Union(damaged_rect); - - RECT r = damaged_rect.ToRECT(); - InvalidateRect(view_, &r, FALSE); -} - -void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { - if (dx != 0 && dy != 0) { - // We only support uni-directional scroll - DidScrollRect(0, dy, clip_rect); - dy = 0; - } - - // If we already have a pending scroll operation or if this scroll operation - // intersects the existing paint region, then just failover to invalidating. - if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) { - paint_rect_.Union(scroll_rect_); - ResetScrollRect(); - paint_rect_.Union(clip_rect); - } - - // We will perform scrolling lazily, when requested to actually paint. - scroll_rect_ = clip_rect; - scroll_dx_ = dx; - scroll_dy_ = dy; - - RECT r = clip_rect.ToRECT(); - InvalidateRect(view_, &r, FALSE); -} - -void WebWidgetHost::ScheduleComposite() { - if (!webwidget_) - return; - WebSize size = webwidget_->size(); - gfx::Rect rect(0, 0, size.width, size.height); - RECT r = rect.ToRECT(); - InvalidateRect(view_, &r, FALSE); -} - -void WebWidgetHost::SetCursor(HCURSOR cursor) { - SetClassLongPtr(view_, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursor)); - ::SetCursor(cursor); -} - -void WebWidgetHost::DiscardBackingStore() { - canvas_.reset(); -} - -WebWidgetHost::WebWidgetHost() - : view_(NULL), - webwidget_(NULL), - track_mouse_leave_(false), - scroll_dx_(0), - scroll_dy_(0), - weak_factory_(this) { - set_painting(false); -} - -WebWidgetHost::~WebWidgetHost() { - ui::SetWindowUserData(view_, 0); - - TrackMouseLeave(false); - - webwidget_->close(); -} - -bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) { - switch (message) { - case WM_ACTIVATE: - if (wparam == WA_INACTIVE) { - PostMessage(view_, WM_CLOSE, 0, 0); - return true; - } - break; - } - - return false; -} - -void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { - paint_rect_.Union(rect); -} - -void WebWidgetHost::Paint() { - RECT r; - GetClientRect(view_, &r); - gfx::Rect client_rect(r); - - // Allocate a canvas if necessary - if (!canvas_) { - ResetScrollRect(); - paint_rect_ = client_rect; - canvas_.reset(skia::CreatePlatformCanvas( - paint_rect_.width(), paint_rect_.height(), true)); - } - - webwidget_->animate(0.0); - - // This may result in more invalidation - webwidget_->layout(); - - // Scroll the canvas if necessary - scroll_rect_.Intersect(client_rect); - if (!scroll_rect_.IsEmpty()) { - skia::ScopedPlatformPaint scoped_platform_paint(canvas_.get()); - HDC hdc = scoped_platform_paint.GetPlatformSurface(); - - RECT damaged_rect, r = scroll_rect_.ToRECT(); - ScrollDC(hdc, scroll_dx_, scroll_dy_, NULL, &r, NULL, &damaged_rect); - - PaintRect(gfx::Rect(damaged_rect)); - } - ResetScrollRect(); - - // Paint the canvas if necessary. Allow painting to generate extra rects the - // first time we call it. This is necessary because some WebCore rendering - // objects update their layout only when painted. - for (int i = 0; i < 2; ++i) { - paint_rect_.Intersect(client_rect); - if (!paint_rect_.IsEmpty()) { - gfx::Rect rect(paint_rect_); - paint_rect_ = gfx::Rect(); - - DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; - PaintRect(rect); - } - } - DCHECK(paint_rect_.IsEmpty()); - - // Paint to the screen - PAINTSTRUCT ps; - BeginPaint(view_, &ps); - skia::DrawToNativeContext(canvas_.get(), ps.hdc, ps.rcPaint.left, - ps.rcPaint.top, &ps.rcPaint); - EndPaint(view_, &ps); - - // Draw children - UpdateWindow(view_); -} - -WebScreenInfo WebWidgetHost::GetScreenInfo() { - return WebScreenInfoFactory::screenInfo(view_); -} - -void WebWidgetHost::Resize(LPARAM lparam) { - // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. - DiscardBackingStore(); - - webwidget_->resize(WebSize(LOWORD(lparam), HIWORD(lparam))); -} - -void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) { - const WebMouseEvent& event = WebInputEventFactory::mouseEvent( - view_, message, wparam, lparam); - webwidget_->handleInputEvent(event); - switch (event.type) { - case WebInputEvent::MouseMove: - TrackMouseLeave(true); - break; - case WebInputEvent::MouseLeave: - TrackMouseLeave(false); - break; - case WebInputEvent::MouseDown: - SetCapture(view_); - // This mimics a temporary workaround in RenderWidgetHostViewWin for bug - // 765011 to get focus when the mouse is clicked. This happens after the - // mouse down event is sent to the renderer because normally Windows does - // a WM_SETFOCUS after WM_LBUTTONDOWN. - ::SetFocus(view_); - break; - case WebInputEvent::MouseUp: - if (GetCapture() == view_) - ReleaseCapture(); - break; - } -} - -void WebWidgetHost::WheelEvent(WPARAM wparam, LPARAM lparam) { - const WebMouseWheelEvent& event = WebInputEventFactory::mouseWheelEvent( - view_, WM_MOUSEWHEEL, wparam, lparam); - webwidget_->handleInputEvent(event); -} - -void WebWidgetHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) { - const WebKeyboardEvent& event = WebInputEventFactory::keyboardEvent( - view_, message, wparam, lparam); - webwidget_->handleInputEvent(event); -} - -void WebWidgetHost::CaptureLostEvent() { - webwidget_->mouseCaptureLost(); -} - -void WebWidgetHost::SetFocus(bool enable) { - // Ignore focus calls in layout test mode so that tests don't mess with each - // other's focus when running in parallel. - if (!TestShell::layout_test_mode()) - webwidget_->setFocus(enable); -} - -void WebWidgetHost::TrackMouseLeave(bool track) { - if (track == track_mouse_leave_) - return; - track_mouse_leave_ = track; - - DCHECK(view_); - - TRACKMOUSEEVENT tme; - tme.cbSize = sizeof(TRACKMOUSEEVENT); - tme.dwFlags = TME_LEAVE; - if (!track_mouse_leave_) - tme.dwFlags |= TME_CANCEL; - tme.hwndTrack = view_; - - TrackMouseEvent(&tme); -} - -void WebWidgetHost::ResetScrollRect() { - scroll_rect_ = gfx::Rect(); - scroll_dx_ = 0; - scroll_dy_ = 0; -} - -void WebWidgetHost::PaintRect(const gfx::Rect& rect) { -#ifndef NDEBUG - DCHECK(!painting_); -#endif - DCHECK(canvas_.get()); - - set_painting(true); - webwidget_->paint(canvas_.get(), rect); - set_painting(false); -} |