Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

修改 Gaia 代码

现在您已经在桌面上运行 Gaia, 并且对源代码的工作方式有了一定程度的理解,下一步就应该准备好为项目做贡献了。本文则描述了如何修改代码以及如何在代码中找到 bug 出现的位置。 

Git 最佳实践

  1. 当对 Gaia 修改时, 首先需要从 master 上获取最新的代码:
    cd path/to/gaia
    git checkout master
    git pull 
  2. 下面切换到您解决问题的分支:
    git checkout -b my-code-fix
  3. 最后,到 gaia/apps 目录下,可以修改对应的文件了。

注意: 在 gaia/profile-debug/ 目录下,您会找到  webapps/, 但其中只包含需要运行的 app 的manifest 文件,而 app 是存在于  gaia/apps/ 目录下的。

简单的代码修改示例

您可以按照需求对代码作出修改,保存修改,在 Firefox 桌面中运行 Gaia 并刷新 tab 页以查看效果。  Let's do something simple like change the text colour of the clock on the lock screen:

Gaia lockscreen showing the clock display in white text

  1. The best way to find how this style is set is to use the developer tools. Ctrl/right + click on the clock in Firefox Desktop and select Inspect Element from the context menu.
  2. You can then work out which CSS file to edit — gaia/apps/system/style/lockscreen.css in this case — and then make your changes in the CSS styles on the right hand side of the display to get it to the state you want.
  3. When you are happy with the change, go and make the change in the file directly.
  4. Next, refresh the tab (or use the Reload application button) and the HTTP server serves the changes instantly:

Gaia lockscreen showing the clock display modified from white to red text


Limitations of Gaia Desktop Firefox rendering:

  • In the Desktop Firefox rendering, the apps are fairly accurate compared to how they work on a real phone, but you may notice some differences here and there.
  • Not all device APIs are supported in desktop Firefox; you can find a list of the ones that are enabled in preferences.js.

发现 bug 出现的地方

The best way to find Firefox OS bugs to work on is to consult Josh Matthews' Bugs Ahoy app — this pulls in bugs directly from Mozilla's Bugzilla and displays them in an easy to search and browse way. One you have found a bug that you want to work on, go to its Bugzilla page, enter yourself in the "assigned to" field, and start work, as indicated above.

有用的提示

  • When you work on mentored bugs, one of the Gaia core team will monitor your progress and provide help with the code and process. If you are a beginner to the Firefox OS contribution process, signing up for one of these can be helpful. These are indicated in Firefox OS Bugzilla pages by an entry in the "Mentors" field. Buys Ahoy lists mentored bugs.
  • If you are a completely new Bugzilla user, you may not be able to assign yourself to work on a bug. If you can’t, ask the mentor assigned to that bug to assign you if it has one, or just ask in the bug comments otherwise.
  • After you have a bit more experience, you should ask someone to give you permission to assign bugs to yourself.
  • Another good whiteboard entry to look out for is [good first bug], if you are a new contributor and want to start with something simple. You can list just good first bugs using https://www.joshmatthews.net/bugsahoy/?b2g=1&simple=1.
  • You should save a search for projects you want to contribute to. For example, the following would give you a Gaia Clock app bug search:

https://bugzilla.mozilla.org/buglist.cgi?columnlist=product%2Ccf_blocking_b2g%2Cbug_status%2Cresolution%2Cshort_desc&resolution=---&query_based_on=CLOCK&query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&component=Gaia%3A%3AClock&product=Boot2Gecko&known_name=CLOCK&list_id=9776392

参考

文档标签和贡献者

 此页面的贡献者: chrisdavidmills, ReyCG_sub
 最后编辑者: chrisdavidmills,