Closed Bug 1100792 Opened 10 years ago Closed 9 years ago

Re-organize the view hierarchy of keyboard

Categories

(Firefox OS Graveyard :: Gaia::Keyboard, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(b2g-master fixed)

RESOLVED FIXED
2.2 S4 (23jan)
Tracking Status
b2g-master --- fixed

People

(Reporter: rudyl, Assigned: rudyl)

References

Details

Attachments

(1 file)

46 bytes, text/x-github-pull-request
timdream
: review+
timdream
: feedback+
Details | Review
We should separate the CandidatePanel rendering part out of IMERender for better structure.
Assignee: nobody → rlu
Status: NEW → ASSIGNED
Attached file Patch V1
Hi Tim,

This patch took much more time than I thought, since it has to cover multiple layouts, like zhuyin, pinyin, and latin layouts, and Vietnamese related layouts.
 - I tried to handle this with 2 classes of CandidatePanelView.

The tests are not complete yet, however, please help give an early feedback, if you can help.

Thanks.
Attachment #8541155 - Flags: feedback?(timdream)
Comment on attachment 8541155 [details] [review]
Patch V1

I think we need to sort out the view hierarchy here. I would imagine we should do

Keyboard
- Layout
-- Candidate Panel
-- Page
--- AltMenu
--- Key

But I don't see Layout in this patch. Please tell me your intention here...
Attachment #8541155 - Flags: feedback?(timdream)
Right now the draw() in render.js would accept a page as an parameter, so we would have the following structures so far,
 Keyboard
   - LayoutPageView
   -- CandidatePanel (should be moved out)
   -- Key
   - Alt Menu (since we got only one alt menu for now)

And I would like to make it look like this in a follow-up bug,
 Keyboard
   - Candidate Panel (Moved out)
   - LayoutPageView
   -- Key
   - Alt Menu (since we got only one alt menu for now)

It seems to make the hierarchy clearer by adding "Layout" layer to aggregate the candidate panel and pages, though I am not sure if there are other reasons it is a must-have.
I'll change the summary of this bug, since we may want to re-org the view hierarchy, instead of just moving candidate panel out.
Summary: Create CandidatePanelView component → Re-organize the view hierarchy of keyboard
Target Milestone: --- → 2.2 S3 (9jan)
Comment on attachment 8541155 [details] [review]
Patch V1

As our offline discussion, this patch is aiming at making the code sync with the DOM structure, so the LayoutPageView would contain candidatePanelView.

Tim, could you please help to give a second look on this?
Thanks!
Attachment #8541155 - Attachment description: WIP → WIP 2
Attachment #8541155 - Flags: feedback?(timdream)
Comment on attachment 8541155 [details] [review]
Patch V1

We are on the right direction here.

The main problem here is that you are trying to pass ad-hoc objects into registerView() but you should really pass a View class instance. Please correct there calls.

The other issues are cosmetic.
Attachment #8541155 - Flags: feedback?(timdream) → feedback+
Comment on attachment 8541155 [details] [review]
Patch V1

The patch has been updated to address the review comments.
 - Create BaseView and let other simple views to inherit from it.
 - Move fitText() and getScale() to ViewUtils since they should be a general util functions.

Tim, could you please help review this change?
Thank you.
Attachment #8541155 - Attachment description: WIP 2 → Patch V1
Attachment #8541155 - Flags: review?(timdream)
Comment on attachment 8541155 [details] [review]
Patch V1

Getting close! We should be able to land this in the final review :)
Attachment #8541155 - Flags: review?(timdream)
Comment on attachment 8541155 [details] [review]
Patch V1

Tim, 

Patch updated.

Could you please review again?
Thanks for your advice and patience.
Attachment #8541155 - Flags: review?(timdream)
Comment on attachment 8541155 [details] [review]
Patch V1

Nice! Thanks for the hard work.
Attachment #8541155 - Flags: review?(timdream) → review+
With this change, I am facing a test failure here,
https://treeherder.mozilla.org/ui/#/jobs?repo=gaia-try&revision=deff4a411790

For latin candidate panel,

The original DOM structure is:
  <div role="presentation">
   <span role="option" class="autocorrect"> candidate 1 </span>
  </div>

  <div role="presentation">
   <span role="option"> candidate 2 </span>
  </div>


And I want to change it to: 
 <div role="presentation" class="autocorrect">
   <span role="option"> candidate 1 </span>
  </div>

  <div role="presentation">
   <span role="option"> candidate 2 </span>
  </div>

i.e. move the "autocorrect" to the parent div element.
Note that I also made the span "pointer-events: none" so that in the code we would get the <div> as the touch event target.

Eitan, since you're the original author, could you help shed some light on how we're going to get the tests right?
Thanks.
Flags: needinfo?(eitan)
(In reply to Rudy Lu [:rudyl] from comment #11)
> With this change, I am facing a test failure here,
> https://treeherder.mozilla.org/ui/#/jobs?repo=gaia-try&revision=deff4a411790
> 
> For latin candidate panel,
> 
> The original DOM structure is:
>   <div role="presentation">
>    <span role="option" class="autocorrect"> candidate 1 </span>
>   </div>
> 
>   <div role="presentation">
>    <span role="option"> candidate 2 </span>
>   </div>
> 
> 
> And I want to change it to: 
>  <div role="presentation" class="autocorrect">
>    <span role="option"> candidate 1 </span>
>   </div>
> 
>   <div role="presentation">
>    <span role="option"> candidate 2 </span>
>   </div>
> 
> i.e. move the "autocorrect" to the parent div element.
> Note that I also made the span "pointer-events: none" so that in the code we
> would get the <div> as the touch event target.
> 
> Eitan, since you're the original author, could you help shed some light on
> how we're going to get the tests right?
> Thanks.

Hi Rudy,

I'm not 100% sure I understand how the test failure is related. But I could definitely give some input on how to update that markup in a way that keeps it accessible: Swap the roles between the div and span. 
 <div role="option" class="autocorrect">
   <span role="presentation"> candidate 1 </span>
  </div>

  <div role="option">
   <span role="presentation"> candidate 2 </span>
  </div>

This will keep it in sync with your intended touch target, and generally things should be good. The presentation role on the span might even be redundant.
Flags: needinfo?(eitan)
Eitan, thanks for the valuable advice, now I can get the tests to pass!


Landed to Gaia master,
https://github.com/mozilla-b2g/gaia/commit/d6232cd6d099e53c90f4dd581e8963d65b8fec80
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: 2.2 S3 (9jan) → 2.2 S4 (23jan)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: